akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] count = new int[5];
		for (int i = 0; i < 6; i++) {
			count[sc.nextInt()]++;
		}
		boolean bre = false;
		for (int i = 1; i <= 4; i++) {
			if (count[i] != 1 && count[i] != 2) {
				bre = true;
				break;
			}
		}
		if (!bre) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int N,A=0,B=0;cin>>N;
  int c[120];REP(i,N)cin>>c[i];
  sort(c,c+N);
  for(int i=N-1;i>=0;i-=2){
    A+=c[i];
  }
  for(int i=N-2;i>=0;i-=2){
    B+=c[i];
  }
  cout<<A-B<<endl;
}

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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template
// configure" from the list 🔧 📝 If you spot any bugs or miss any features,
// create an issue at https://github.com/pustaczek/icie/issues 📝 🎉 ... or just
// ask me about anything via Discord at https://discord.gg/ffSEhtb 🎉

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC";
  else
    cout << "ABC";
}

Measured memory_bytes: 3652
from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ma = 2*10**6
table = [0]*ma
for i in a:
    table[i] += 1
ok2 = True
for i in range(2,ma):
    s = 0
    for j in range(i,ma,i):
        s += table[j]
    if s>1:
        ok2 = False

if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")


Measured memory_bytes: 212792
#!/usr/bin/env python
from collections import Counter
import sys

input = sys.stdin.readline

def main():
    n = int(input().rstrip())
    l = list(input().rstrip().split())

    c = Counter(l)
    total = 0
    for key in c:
        total += c[key] * (c[key] -1) // 2
    for item in l:
        print(total - (c[item] -1))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 80084
import sys
N, M = map(int, input().split())
S = [int(c) for c in input()][::-1]

c = 0
path = []
while c < N:
    g = c+M if c+M < N else N
    for m in range(g, c, -1):
        if S[m] == 1:
            continue
        else:
            path.append(m-c)
            c = m
            break
    else:
        if c < N:
            print(-1)
            sys.exit()

print(*path[::-1])



Measured memory_bytes: 7048
S = input()
s = S[::-1]
a = "dream"[::-1]
b = "dreamer"[::-1]
c = "erase"[::-1]
d = "eraser"[::-1]

idx = 0
ans = "YES"
while idx < len(s):
    if s[idx] == "m":
        if s[idx : idx + 5] == a:
            idx = idx + 5
        else:
            ans = "NO"
            break

    elif s[idx] == "e":
        if s[idx : idx + 5] == c:
            idx = idx + 5
        else:
            ans = "NO"
            break

    elif s[idx] == "r":
        if s[idx : idx + 7] == b:
            idx = idx + 7
        elif s[idx : idx + 6] == d:
            idx = idx + 6
        else:
            ans = "NO"
            break

    else:
        ans = "NO"
        break

print(ans)

Measured memory_bytes: 9256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

a = i()
s = s()

if a >= 3200:
    print(s)
else:
    print("red")

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

int main(){
    int H, W; cin >> H >> W; char a[H][W];
    for (int i = 0; i < H  ; i++)
        for (int j = 0; j < W; j++) cin >> a[i][j];

    for (int i = 0; i < W+2; i++)   cout << '#';     cout << endl;
    for (int i = 0; i < H  ; i++) {
        cout << '#' ;
        for (int j = 0; j < W; j++) cout << a[i][j];
        cout << '#' ;                                cout << endl;
    }
    for (int i = 0; i < W+2; i++)   cout << '#';     cout << endl;
    return 0;
}


Measured memory_bytes: 256
def answer(s: str) -> int:
    if len(s) % 2 == 1:
        s += ' '

    for _ in range(len(s) // 2):
        s = s[:-2]
        l = len(s)
        middle = l // 2

        if s[:middle] == s[middle:]:
            return l


def main():
    s = input()
    print(answer(s))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8864
#include <bits/stdc++.h>
#define FRU                                  freopen("out.txt","w",stdout);
#define FRO                                  freopen("in.txt","r",stdin);
#define pb                                   push_back
#define pf                                   push_front
#define ppb                                  pop_back()
#define ppf                                  pop_front()
#define mp                                   make_pair
#define ff                                   first
#define ss                                   second
#define flash                                ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mem(ara,n)                           memset(ara,n,sizeof ara)
#define fr(i,j,n)                            for(i=j;i<n;i++)
#define rf(i,j,n)                            for(i=n;i>=j;i--)
#define inf                                  2147483647
#define ll                                   long long
#define ull                                  unsigned long long
#define pii                                  pair<int,int>
#define vi                                   vector<int>
#define vll                                  vector <long long>
#define vch                                  vector <char>
#define itr                                  ::iterator
#define msi                                  map<string,int>
#define psi                                  pair <string,int>
#define vii                                  vector <pair<int,int> >
#define all(n)                               n.begin(),n.end()
#define INF                                  10000000000000000LL
#define pi                                   3.1415926535897932384626434
#define sii                                  set <int>
#define max3(a,b,c)                          max(a,max(b,c))
#define min3(a,b,c)                          min(a,min(b,c))
#define mid3(a,b,c)                          min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d)                        max(max(a,b),max(c,d))
#define min4(a,b,c,d)                        min(min(a,b),min(c,d))
#define endl                                 '\n'
#define endll                                cout<<"\n";
#define spc                                  ' '
#define ld                                   long double

using namespace std;



int main()
{
    flash
    string s,st;
    int n,t,T,i,j,J,I,k,m;
    char ch;
    double a,b;
    cin>>a;
    cout<<a*2*pi;
    return 0;
}




Measured memory_bytes: 3792
#include <stdio.h>
#include <math.h>

#define FALSE 0
#define TRUE 1

int isPrime(int);

int main(){
	int n,i,num[10000],cnt=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(i=0;i<n;i++){
		if((isPrime(num[i]))==TRUE) cnt++;
	}
	
	printf("%d\n",cnt);
	
	return 0;
}

int isPrime(int x){
	int i;
	
	if(x==2) return TRUE;
	if(x<2 || x%2==0) return FALSE;
	
	i=3;
	while(i<=sqrt(x)){
		if(x%i==0) return FALSE;
		i+=2;
	}

	return TRUE;
}
	


Measured memory_bytes: 2056
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
//#define  standard_File_input freopen(in.txt,r,stdin);
//#define  standard_File_output freopen(out.txt,w,stdout);
#define FastIO ios_base::sync_with_stdio(0);cin.tie(nullptr);
using namespace std;
typedef long long int ll;
typedef double ld;

int main()
 {
    //standard_File_input
    //standard_File_output
      int m1,d1,m2,d2;
      cin>>m1>>d1>>m2>>d2;
      if(abs(d1-d2)>1)
        cout<<"1"<<endl;
      else
      {
          cout<<"0"<<endl;
      }
      
 }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long m = sc.nextLong();
		n = (n >= 2) ? n - 2 : 1;
		m = (m >= 2) ? m - 2 : 1;
		
		System.out.println(m*n);
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21072
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
typedef struct{
    int land;
    int used;
}mesh;
int w, h;
int count;
mesh c[50][50];
void dfs(int i,int j){
    c[i][j].used=1;
    for(int x=-1;x<=1;x++){
        for(int y=-1;y<=1;y++){
            if(x==0&&y==0) continue;
            int ny=i+y,nx=j+x;
            if(nx<0||nx>=w||ny<0||ny>=h) continue;
            else if(c[ny][nx].used==1) continue;
            else if(c[ny][nx].land==1) dfs(ny,nx);
        }
    }
}
int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break; count=0;
        rep(i,h) rep(j,w) scanf("%d",&c[i][j].land),c[i][j].used=0;
        rep(i,h)rep(j,w){
            if(c[i][j].used==0&&c[i][j].land==1)
                dfs(i,j),count++;
        }
        printf("%d\n",count);
    }
}



Measured memory_bytes: 2100
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  string s;
  cin >> s;
  for(auto i : s){
    if(i == '7'){puts("Yes");return;}
  }
  puts("No");
}

int main() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(0, min(B, D) - max(A, C)) << endl;

    return 0;
}

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

int main(){
    int X, N;
    cin >> X >> N;
    vector<int> P(N);
    rep(i, N){
        cin >> P.at(i);
    }

    int finish = 0;

    rep(i,100){
        rep(j,N){
            if(X-i == P.at(j)){
                finish = 1;
                break;
            }
        }
        if(finish == 1){
            rep(j,N){
                if(X+i == P.at(j)){
                    finish = 2;
                    break;
                }
            }
        }
        if(finish == 0){
            cout << X-i << endl;
            break;
        }
        else if(finish == 1){
            cout << X+i <<endl;
            break;
        }
        else{
            finish = 0;
            continue;
        }
    }
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    cout << a * b / 2;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

class Node
  attr_accessor :id, :parent, :left, :right, :sibling, :degree, :depth, :height, :node_type
  def initialize(i)
    @id = i
    @parent = -1
    @left = -1
    @right = -1
    @depth = 0
    @height = 0
    @sibling = -1
    @degree = -1
  end
end

nodes = {}
# 大きさが分かるので初期化しておく
n.times do |i|
  nodes[i] = Node.new(i)
end

# 高さを決める
def height_rec(par, nodes)
  l, r = 0, 0
  if nodes[par].left >= 0
    tmp_left = nodes[par].left
    l = height_rec(tmp_left, nodes) + 1
  end
  if nodes[par].right >= 0
    tmp_right = nodes[par].right
    r = height_rec(tmp_right, nodes) + 1
  end
  nodes[par].height = [r, l].max
end

# 深さを再帰的に更新
def depth_rec(par, nodes)
  left_child = nodes[par].left
  if left_child >= 0
    nodes[left_child].depth = nodes[par].depth + 1
    depth_rec(left_child, nodes)
  end
  right_child = nodes[par].right
  if right_child >= 0
    nodes[right_child].depth = nodes[par].depth + 1
    depth_rec(right_child, nodes)
  end
end

n.times do |i|
  data = gets.chomp.split.map(&:to_i)
  my_id = data[0]
  child_l = data[1]
  child_r = data[2]
  # 子データをセット
  nodes[my_id].left = child_l
  nodes[my_id].right = child_r
  # 子に親と兄弟データをセット
  if child_l >= 0
    nodes[child_l].parent = my_id
    if child_r >= 0
      nodes[child_l].sibling = child_r
    end
  end
  if child_r >= 0
    nodes[child_r].parent = my_id
    if child_l >= 0
      nodes[child_r].sibling = child_l
    end
  end
  # 子の数をセット
  nodes[my_id].degree = [child_l, child_r].select{|c|c!=-1}.size
  # 深さ更新
  depth_rec(my_id, nodes)
end

# 高さ計算とタイプ確定
# root、internal node、leaf 
nodes.each do |k, node|
  height_rec(k, nodes)
  if node.parent == -1
    node.node_type = "root"
  elsif node.degree.zero? 
    node.node_type = "leaf"
  else
    node.node_type = "internal node"
  end
end

# 出力
# node id: parent = p , sibling = s , degree = deg, depth = dep, height = h, type
nodes.each do |k, node|
  puts "node #{node.id}: parent = #{node.parent}, sibling = #{node.sibling}, degree = #{node.degree}, depth = #{node.depth}, height = #{node.height}, #{node.node_type}"
end


Measured memory_bytes: 6884
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int a, b, c, d, e, s = 0;
  cin >> a >> b >> c >> d >> e;
  s = (a+9)/10 + (b+9)/10 + (c+9)/10 + (d+9)/10 + (e+9)/10;
  s *= 10;
  int a1 = a%10, b1 = b%10, c1 = c%10, d1 = d%10, e1 = e%10;
  if(a1 == 0) {
    a1 = 10;
  }
  if(b1 == 0) {
    b1 = 10;
  }
  if(c1 == 0) {
    c1 = 10;
  }
  if(d1 == 0) {
    d1 = 10;
  }
  if(e1 == 0) {
    e1 = 10;
  }
  int f = min(min(a1, b1), min(c1, min(d1, e1)));
  s -= 10 - f;
  cout << s;
}

Measured memory_bytes: 256
import java.util.Scanner;

// 7/26

public class Main {

	/**
	 * @param args
	 */
	static char[] s;
	static int idx;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			idx=0;
			String str = cin.next();
			if(str.equals(".")){
				break;
			}
			int count=0;
			for(int i = 0; i < 3;i++){
				for(int j = 0;j < 3;j++){
					for(int k =0; k < 3;k++){
						idx=0;
						String a = str.replace('P', (char)('0'+i));
						a = a.replace('Q', (char)('0'+j));
						a = a.replace('R', (char)('0'+k));
						s = new char[a.length()+100];
						for(int m= 0; m < a.length();m++){
							s[m]=a.charAt(m);
						}
						//System.out.println(s);
						if(expression()==2){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	static int expression(){
		int res = term();
		
		if(s[idx]=='+'){
			idx++;
			res = or(res, expression());
		}
		return res;
	}
	static int term(){
		int res = fact();
		
		if(s[idx]=='*'){
			idx++;
			res = and(res, fact());
		}
		return res;
	}
	static int fact(){
		int res;
		if(s[idx]=='('){
			idx++;
			res = expression();
			idx++;
		}
		else if(s[idx]=='-'){
			idx++;
			res = bikkuri(fact());
		}
		else{
			return variable();
		}
		return res;
	}
	static int variable(){
		if(s[idx]=='0'){
			idx++;
			return 0;
		}
		else if(s[idx]=='1'){
			idx++;
			return 1;
		}
		else if(s[idx]=='2'){
			idx++;
			return 2;
		}
		else
			return -1;
	}
	static int bikkuri(int a){
		if(a==0){
			return 2;
		}
		else if(a==2){
			return 0;
		}
		else{
			return 1;
		}
	}
	static int or(int a,int b){
		if(a==2||b==2){
			return 2;
		}
		else if(a+b==0){
			return 0;
		}
		else
			return 1;
	}
	static int and(int a,int b){
		if(a==0||b==0){
			return 0;
		}
		else if(a+b==4){
			return 2;
		}
		else{
			return 1;
		}
	}
}

Measured memory_bytes: 12000
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const ll INF = 1001001001;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };



int main(void) {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for(int i=0; i<N; i++) cin >> A[i] >> B[i];
  
  vector<int> dp(H+1, INF);
  
  dp[0] = 0;// dp[i] : 体力i の敵を倒すのに必要な最小魔力

  for(int i=1; i<= H; i++){
    for(int j=0; j<N; j++){
      if(i-A[j] >=0 )dp[i] = min(dp[i], dp[i-A[j]] + B[j]);
      
      else if(i-A[j] < 0) dp[i] = min(dp[i] , dp[0] + B[j]);
      
      
      
    }
  }
  
  //for(int i=0; i<=H; i++) cout << i << ": "<< dp[i]<< endl;
  cout << dp[H] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N,K,X,Y;
	N,K>=1&&N,K<=100; 
	X>Y>=1&&Y<X<=10000;
	scanf("%ld",&N);
	scanf("%ld",&K);
	scanf("%ld",&X);
	scanf("%ld",&Y);
	if(N>=K){
	printf("%d\n",K*X+Y*(N-K));}
	if(N<K){
		printf("%d\n",N*X);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define P 1000000007
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second

using namespace std;

int dp[3030][3030];
string s, t;


int main(){

	cin >> s >> t;

	int zs = s.size(), zt = t.size();

	for(int i=1; i<=zs; i++){
		for(int j=1; j<=zt; j++){
			dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
			if(s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
		}
	}

	int i=zs, j=zt;
	string ans;

	while(i>0 && j>0){
		int a = dp[i-1][j], b = dp[i][j-1], c = dp[i][j];
		if(c>b && c>a){ans.push_back(s[i-1]); i--; j--;}	
		else if(a>b) i--;
		else j--;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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;
}

string s;

void solve() {
  cin >> s;

  int rnum = 0, lnum = 0, rin, lin;
  int n = s.length();
  vi ans(n, 0);
  rep(i, 0, n) {
    if (i == n - 1) {
      lnum++;
      int num = rnum + lnum;
      if (num % 2 == 0) {
        ans[lin] = num / 2;
        ans[rin] = num / 2;
        rnum = 0;
        lnum = 0;
      } else {
        if (rnum > lnum) {
          if (rnum % 2 == 0) {
            ans[rin] = (rnum + lnum - 1) / 2;
            ans[lin] = (rnum + lnum + 1) / 2;
          } else {
            ans[rin] = (rnum + lnum + 1) / 2;
            ans[lin] = (rnum + lnum - 1) / 2;
          }
        } else {
          if (lnum % 2 == 0) {
            ans[rin] = (rnum + lnum + 1) / 2;
            ans[lin] = (rnum + lnum - 1) / 2;
          } else {
            ans[rin] = (rnum + lnum - 1) / 2;
            ans[lin] = (rnum + lnum + 1) / 2;
          }
        }
        rnum = 0;
        lnum = 0;
      }
      continue;
    }
    if (s[i] == 'R') {
      if (s[i + 1] == 'R') {
        rnum++;
      } else {
        rin = i;
        lin = i + 1;
        rnum++;
      }
    } else {
      if (s[i + 1] == 'L') {
        lnum++;
      } else {
        lnum++;
        int num = rnum + lnum;
        if (num % 2 == 0) {
          ans[lin] = num / 2;
          ans[rin] = num / 2;
          rnum = 0;
          lnum = 0;
        } else {
          if (rnum > lnum) {
            if (rnum % 2 == 0) {
              ans[rin] = (rnum + lnum - 1) / 2;
              ans[lin] = (rnum + lnum + 1) / 2;
            } else {
              ans[rin] = (rnum + lnum + 1) / 2;
              ans[lin] = (rnum + lnum - 1) / 2;
            }
          } else {
            if (lnum % 2 == 0) {
              ans[rin] = (rnum + lnum + 1) / 2;
              ans[lin] = (rnum + lnum - 1) / 2;
            } else {
              ans[rin] = (rnum + lnum - 1) / 2;
              ans[lin] = (rnum + lnum + 1) / 2;
            }
          }
          rnum = 0;
          lnum = 0;
        }
      }
    }
  }

  rep(i, 0, n) { cout << ans[i] << ' '; }
  cout << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,a,b;
    cin>>n>>m;
    vector<int> h(n);
    vector<bool> g(n,true);
    for(auto&i:h) cin>>i;
    fr(i,m){
        cin>>a>>b;
        --a,--b;
        if(h[a]<=h[b]) g[a]=false;
        if(h[a]>=h[b]) g[b]=false;
    }
    int c{};
    fr(i,n) if(g[i]) ++c;
    cout<<c<<'\n';

}

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

int main(){
    int r,d;
    vector<int> x(20);
    cin >> r >> d >> x[0];
    rep(i,10){
        x[i+1] = r * x[i] - d;
        cout << x[i+1] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int a[110];
int main(){
	int n,i,j,k,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			for(k=j+1;k<=n;k++)
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  std::vector<int> yakusu;
  for(int i=0;i<N;i++)
    if(v[i]>1)yakusu.push_back(v[i]);
  for(int i=0;i<N;i++)
    for(int j=2;j*j<=v[i];j++)
      if(v[i]%j==0){
        yakusu.push_back(j);
        yakusu.push_back(v[i]/j);
      }
  for(int p:yakusu){
    int res=0;
    for(int i=0;i<N;i++)
      if(v[i]%p==0)res+=v[i];
    ans=max(ans,res);
  }
  fin(ans);
}



Measured memory_bytes: 4044
N = int(input())
h = input().split()
h = [int(i) for i in h]
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(1, N-1):
    dp[i+1] = min(dp[i] + abs(h[i]-h[i+1]), dp[i-1] + abs(h[i-1]-h[i+1]))
print(dp[N-1])

Measured memory_bytes: 20316
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c && c==a){
cout<<1<<endl;
  }
else if(a==b && b!=c){
cout<<2<<endl;
}
else if(a==c && c!=b){
cout<<2<<endl;
}
else if(b==c && c!=a){
cout<<2<<endl;
}
  else {
cout<<3<<endl;
  }
return 0;
}


Measured memory_bytes: 256
def main():
  n,q,*t=map(int,open(0).read().split())
  for v,w in zip(t[::2],t[1::2]):
    if n<2:
      print(min(v,w))
      continue
    s,t=[],[]
    while v:
      s.append(v)
      v=(v+n-2)//n
    while w:
      t.append(w)
      w=(w+n-2)//n
    print(max(set(s)&set(t)))
if __name__=='__main__':
  main()

Measured memory_bytes: 25196
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int x; cin >> x;
  if (x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  //cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LiangJiaJun main
#define MOD 1000000007
using namespace std;
long long n,m,ans;

int LiangJiaJun(){
	cin>>n>>m;
	if(abs(n-m)<=1){
		ans=1;
		for(int i=1;i<=n;i++) ans = (ans * i) % MOD;
		for(int i=1;i<=m;i++) ans = (ans * i) % MOD;
		if(n == m) ans = (ans * 2) % MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  using coord= pair<int64_t, int64_t>;
  vector<coord> data(N);
  int64_t bufx,bufy;
  for(int64_t i=0; i<N; i++){
    cin >> bufx >> bufy;
    data.at(i)= make_pair(bufx,bufy);
  }

  int64_t inc= 2'000'000'000;
  int64_t exc= -1;
  while(abs(inc- exc) > 1){
    int64_t mid= (inc+ exc)/ 2;

    auto is_inc= [&](int64_t mid){
      int64_t plus_upper = INT_MAX;
      int64_t minus_upper= INT_MAX;
      int64_t plus_lower = INT_MIN;
      int64_t minus_lower= INT_MIN;
      for(auto [x,y]:data){
        plus_upper = min(plus_upper , x+y+mid);
        minus_upper= min(minus_upper, x-y+mid);
        plus_lower = max(plus_lower , x+y-mid);
        minus_lower= max(minus_lower, x-y-mid);
      }

      bool bool_mid= true;
      for(auto [x,y]:data){
        int64_t plus = x+y;
        int64_t minus= x-y;
        if(plus_lower <= plus and plus <= plus_upper and minus_lower <= minus and minus <= minus_upper){ continue; }
        else{
          bool_mid= false;
          break;
        }
      }

      return bool_mid;
    };

    if(is_inc(mid)){ inc= mid; }
    else           { exc= mid; }
  }


  int64_t ans= inc;
  
  cout << ans << endl;
}

Measured memory_bytes: 6436
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
string p[4] = { "SS", "SW", "WS", "WW" };
int n; string s;
bool solve(string t) {
	for (int i = 0; i < n; i++) {
		char cp = t[(i + n - 1) % n], cq = t[(i + 1) % n];
		if (t[i] == 'S' && s[i] == 'o' && cp != cq) return false;
		if (t[i] == 'S' && s[i] == 'x' && cp == cq) return false;
		if (t[i] == 'W' && s[i] == 'o' && cp == cq) return false;
		if (t[i] == 'W' && s[i] == 'x' && cp != cq) return false;
	}
	return true;
}
int main() {
	cin >> n >> s;
	string ret = "-1";
	for (int i = 0; i < 4; i++) {
		string t = p[i];
		for (int j = 1; j < n - 1; j++) {
			if (t[j] == 'S') {
				if (s[j] == 'o' && t[j - 1] == 'S') t.push_back('S');
				if (s[j] == 'o' && t[j - 1] == 'W') t.push_back('W');
				if (s[j] == 'x' && t[j - 1] == 'S') t.push_back('W');
				if (s[j] == 'x' && t[j - 1] == 'W') t.push_back('S');
			}
			else {
				if (s[j] == 'o' && t[j - 1] == 'S') t.push_back('W');
				if (s[j] == 'o' && t[j - 1] == 'W') t.push_back('S');
				if (s[j] == 'x' && t[j - 1] == 'S') t.push_back('S');
				if (s[j] == 'x' && t[j - 1] == 'W') t.push_back('W');
			}
		}
		if (solve(t)) {
			ret = t;
			break;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 776
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;

#pragma GCC Optimize("Ofast")

ll a[maxn];
map<ll,ll>mp;

ll solve(ll l,ll r){
	if(l==r)return (a[l]==0);
	ll ans=0;
	ll mid=(l+r)/2;
	ans=solve(l,mid)+solve(mid+1,r);
	mp.clear();
	ll s=0;
	FOR(i,(mid+1),r){
		s+=a[i];
		mp[s]++;
	}
	s=0;
	FORD(i,mid,l){
		s+=a[i];
		ans+=mp[-s];
	}
	return ans;
}

int main(){
	ll n;cin>>n;
	REP(i,n)
		cin>>a[i];
	cout<<solve(0,n-1);
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

ll N = 1000;
int main() {
  ll x,y,z,k;
  cin >> x;
  cin >> y;
  cin >> z;
  cin >> k;
  vector<bool> checked(N*N*N,false);
  vl a(x);
  REP(i,x) cin >> a[i];
  sort(a.begin(),a.end());
  vl b(y);
  REP(i,y) cin >> b[i];
  sort(b.begin(),b.end());
  vl c(z);
  REP(i,z) cin >> c[i];
  sort(c.begin(),c.end());
  //vector<vl> cand(0,vl(2));
  auto comp = [](vl a,vl b){return a[0]<b[0];};
  priority_queue<vl,vector<vl>,decltype(comp)> q(comp);
  q.push({a[x-1]+b[y-1]+c[z-1],(x-1)*N*N+(y-1)*N+(z-1)});
  while(k>0){
    ll ans = (q.top())[0];
    while(k>0 && !q.empty() && (q.top())[0]==ans){
      ll xi = (q.top())[1]/(N*N);
      ll yi = ((q.top())[1]%(N*N))/N;
      ll zi = (q.top())[1]%N;
      cout << ans << endl;
      checked[(xi) * N*N + (yi) * N + (zi)] = true;
      if(xi>0 && !checked[(xi-1) * N*N + (yi) * N + (zi)]){
        q.push({a[xi-1]+b[yi]+c[zi],(xi-1)*N*N+yi*N+zi});
        checked[(xi-1) * N*N + (yi) * N + (zi)] = true;
      }
      if(yi>0 && !checked[(xi) * N*N + (yi-1) * N + (zi)]){
        q.push({a[xi]+b[yi-1]+c[zi],xi*N*N+(yi-1)*N+zi});
        checked[(xi) * N*N + (yi-1) * N + (zi)] = true;
      }
      if(zi>0 && !checked[(xi) * N*N + (yi) * N + (zi-1)]){
        q.push({a[xi]+b[yi]+c[zi-1],xi*N*N+yi*N+zi-1});
        checked[(xi) * N*N + (yi) * N + (zi-1)] = true;
      }
      k--;
      q.pop();
    }
  }
  return 0;
}


Measured memory_bytes: 122624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%lf", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));
}


Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 300005
#define LL long long
using namespace std;

inline int rd(){
	int x=0,f=1;char c=getchar();
	while(c<'0' || c>'9') f=c=='-'?-1:1,c=getchar();
	while(c<='9' && c>='0') x=x*10+c-'0',c=getchar();
	return x*f;
}

int n,m,x[maxn],d[maxn],id[maxn],stk[maxn],top;
LL k,ans[maxn];
bool vis[maxn];

int main(){
	n=rd();
	for(int i=1;i<=n;i++) x[i]=rd(),d[i]=x[i]-x[i-1],id[i]=i;
	m=rd(); scanf("%lld",&k);
	for(int i=1,a;i<=m;i++) a=rd(),swap(id[a],id[a+1]);
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			top=0;
			for(int j=i;!vis[j];j=id[j]) stk[++top]=j,vis[j]=1;
			for(int j=1;j<=top;j++) ans[stk[j]]=d[stk[(k+j-1)%top+1]];
		}
	for(int i=1;i<=n;i++) ans[i]+=ans[i-1],printf("%.1lf\n",(double)ans[i]);
	return 0;
}

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

int main(){
    int i = 0;
    while(i < 3010){
        int x,y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y){
            int tmp;
            tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n",x,y);
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) <= (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;          using vi  = vector<int>;
using unit= unsigned;           using vl  = vector<ll>;
using ull = unsigned long long; using vvi = vector<vi>;
using P   = pair<int,int>;      using vvl = vector<vl>;
                                using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){ stringstream s; rep(i,0,sz(v))s<<' '<<v[i]; return s.str().substr(1); }
template<class T>istream &operator>>(istream&i, v(T)&v){ fore(x,v){ i >> v; } return i; }
template<class T>ostream &operator<<(ostream&o, const v(T)&v){ o<<"["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const deque<T>&v){ o<<"deq["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T1,class T2>ostream &operator<<(ostream &o, const pair<T1,T2>&p){ o<<"("<<p.fi<<","<<p.se<<")"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const unordered_map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class T>void YES(T c){ if(c) cout<<"YES"<<endl; else cout<<"NO"<<endl; }
template<class T>void Yes(T c){ if(c) cout<<"Yes"<< endl; else cout<<"No"<<endl; }
template<class T>void POSS(T c){ if(c) cout<<"POSSIBLE"<<endl; else cout<<"IMPOSSIBLE"<<endl; }
template<class T>void Poss(T c){ if(c) cout<<"Possible"<<endl; else cout<<"Impossible"<<endl; }
template<class T>void chmax(T &a, const T &b){ if(a<b) a=b; }
template<class T>void chmin(T &a, const T &b){ if(b<a) a=b; }
template<class T>T gcd(T a, T b){ return (b==0) ? a : gcd(b,a%b); }
template<class T>T lcm(T a, T b){ return a * (b / gcd(a,b)); }
const double  EPS = 1e-10;
const double  PI  = acos(-1.0);
const int     INF = INT_MAX / 2;
const ll      INFL= 1LL << 60;
const int dx[] = { -1, 0, 1, 0 , -1,-1, 1, 1 };
const int dy[] = {  0, 1, 0,-1 , -1, 1,-1, 1 };

void _main() {
  int N;
  cin >> N;

  int ans = 0;
  rep(i, 1, N+1) {
    if (to_string(i).size() % 2 == 1) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

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


int main() {
	int n;
	cin >> n;
	int money = 1000;
	while (money < n){
		money += 1000;
	}
	int ans = money - n;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main() {
	int i,K,X,A,count=0;
	scanf("%d %d", &K, &X);
	A = X - (K - 1);
	for(i=0;i<=2*K-2;i++){
		count = A + i;
		printf("%d\t", count);
		count = A;
	}
	return 0;
}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		(new Main()).execute();
	}
	public void execute() { ;
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		BigInteger A = new BigInteger(sc.next());
		BigInteger B = new BigInteger(sc.next());
		BigInteger C = new BigInteger(sc.next());
		BigInteger D = new BigInteger(sc.next());

		BigInteger B_A = B.add(A.multiply(new BigInteger("-1"))).add(BigInteger.ONE);//A～Bまでの個数（B-A + 1）を求める

		//Cの約数の個数
		BigInteger c_y = yakusuu(A,B,C) ;

		//Dの約数の個数
		BigInteger d_y = yakusuu(A,B,D) ;

		//C*Dの約数の個数
		BigInteger cd_y = yakusuu(A,B,lcm(C,D)) ;

		//答え
		BigInteger count = B.subtract(A).add(BigInteger.ONE);//A～Bまでの個数（B-A + 1）を求める
		BigInteger ans = count.subtract(c_y).subtract(d_y).add(cd_y) ;

		System.out.println(ans.toString(10));
	}

	private BigInteger yakusuu(BigInteger start, BigInteger end, BigInteger num) {
		if(0 < num.compareTo(end)) {
			return BigInteger.ZERO ;
		}
		if(num.compareTo(end) == 0) {
			return BigInteger.ONE ;
		}

		BigInteger top ;

		if(start.mod(num).equals(BigInteger.ZERO)) {
			top = start ;
		}else {
			top = num.multiply(start.divide(num).add(BigInteger.ONE)) ;
		}

		BigInteger last ;
		if(end.mod(num).equals(BigInteger.ZERO)) {
			last = end ;
		}else {
			last = num.multiply(end.divide(num)) ;
		}

		BigInteger top_count = top.divide(num) ;
		BigInteger last_count = last.divide(num) ;

		BigInteger count = last_count.subtract(top_count.subtract(BigInteger.ONE)) ;


		return count ;
	}

	private BigInteger lcm(BigInteger m, BigInteger n) {
	    return m.multiply(n).divide(gcd(m, n));
	}
	private BigInteger gcd(BigInteger m, BigInteger n) {
	    if(m.compareTo(n) < 0) return gcd(n, m);
	    if(n.equals(BigInteger.ZERO)) return m;
	    return gcd(n, m.mod(n));
	}
}


Measured memory_bytes: 21972
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    """
    N <= M
    N = 1かつ、M = 1のとき、1枚だけあるカードは1毎裏返されるので、答えは1でｓ。
    N = 1かつ M ≠ 1のとき、 M 枚のカードのうち両端のカードは2回、それ以外のカードは
    3回裏替えされるので、答えはM-2
    N >= 2のとき、 N <= M より M >= 2で、このとき、
    ・四隅のカードは4回、　# 表になる
    ・それ以外のカードは週上のカードは6回 # 表になる
    ・それ以外のカードは9回
    裏返されるので、答えは、(N-2)(M-2)
    """

    if n == 1 and m == 1:
        print(1)
    elif n == 1 and m != 1:
        print(m-2)
    elif m == 1 and n != 1:
        print(n-2)
    else:
        print((n-2) * (m-2))
if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,O;
  cin >> N >> K;
  O = 1;
  for(int i=0;i<N;i++){
    if(O*2 <= O + K) O *= 2;
    else O += K;
  }
  cout << O << endl;
}
    
    

Measured memory_bytes: 256
#include<stdio.h>

int  main(){
    int N;
    scanf("%d", &N);
    char S[N+1];
    for(int i = 0; i < N+1; i++) scanf("%c", &S[i]);
    int flag = 0;
    for(int i = 0; i < N; i++){
        if(S[i] != S[i+1]) flag++;
    }
    printf("%d", flag);
    return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
   var a = Number(inputs[0]);
   var b = Number(inputs[1]);
   console.log(a*b,(a+b)*2);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15480
fn main() {
    let s: usize = read();
    println!("{}:{}:{}", s / 3600, (s / 60) % 60, s % 60);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5032
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	int N, x;
	cin >> N >> x;
	vector<int>data(N);
	long sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> data.at(i);
		sum += data.at(i);
	}
	sort(data.begin(), data.end());
	int ans = N;
	if (sum == x) {
		cout << ans << endl;
		return 0;
	}
	else{
		ans--;
		sum -= data.at(N - 1);
		for (int i = N - 2; i >= 0; i--) {
			if (x >= sum) {
				cout << ans << endl;
				return 0;
			}
			ans--;
			sum -= data.at(i);
		}
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
		int N = sc.nextInt();
		int[] h = new int[N];
		
		for(int i=0; i<N; i++) {
			h[i]= sc.nextInt();
		}
		
		int max = h[0];
		boolean b = true;
		for(int i=0; i<N; i++) {
			if(h[i]<max-1) {
				b = false;
				break;
			}
			if(h[i]>max) {
				max = h[i];
			}
		}
		System.out.println(b? "Yes":"No");
    }
}

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

int main() {
	ios :: sync_with_stdio(false);
	int a[5];
	for(int i = 0; i < 5; i ++)
		cin >> a[i];
	sort(a, a + 5, greater<int>());
	for(int i = 0; i < 5; i ++)
		cout << a[i] << (i + 1 == 5 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3124
import heapq
N = 4
ARR = [2, 2, 1, 3]


N = 7
ARR = [1, 1, 1, 1, 1, 1, 1]

N = int(input())
ARR = list(map(int,input().split()))
def calculate(n,arr):

    arr = sorted(arr,reverse=True)

    arr = [-1 * ar for ar in arr]


    mmk = []

    ans = 0
    for i in range(n):
        if i == 0:
            heapq.heappush(mmk,arr[i])
            continue

        ans -= heapq.heappop(mmk)

        heapq.heappush(mmk,arr[i])
        heapq.heappush(mmk,arr[i])

    print(ans)




calculate(N, ARR)

Measured memory_bytes: 33032
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;
vector<int> v1(4);
vector<int> v2(4);
int main()
{
  while(scanf("%d %d %d %d",&v1[0],&v1[1],&v1[2],&v1[3])!=EOF){
    scanf("%d %d %d %d",&v2[0],&v2[1],&v2[2],&v2[3]);
    int i,j,hit=0,blow=0;
    rep(i,4){
      if(v1[i]==v2[i])
	hit++;
      else
	rep(j,4){
	  if(i==j)continue;
	  if(v1[i]==v2[j])blow++;
	}
    }
    cout<<hit<<" "<<blow<<endl;
  }
}

Measured memory_bytes: 1212
N = int(input())
left = []
right = []
for _ in range(N):
    l, r = map(int, input().split())
    left.append(l)
    right.append(r)
left.sort()
right.sort()
if N%2==0:
    for i, (l, r) in enumerate(zip(left, right), 1):
        if i==N//2:
            L = l
            R = r
        if i==N//2+1:
            R +=r
            L += l
            print((R-L)+1)
else:
    for i, (l, r) in enumerate(zip(left, right), 1):
        if i==N//2+1:
            print(r-l+1)

Measured memory_bytes: 25412