akhauriyash/Code-Regression huggingface dataset:
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
 
 
int n, a[100005], b[100005], arr[100005];
 
 
int main(){
 
    ios_base::sync_with_stdio(0);
 
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
 
    for(int i=1;i<=n;i++)
        a[i] = n*i;
    b[arr[1]] = (n-arr[1]+1)*n+n;
 
    for(int i=2;i<=n;i++){
 
        if(arr[i] < arr[i-1]){
            b[arr[i]] = b[arr[i-1]] + (arr[i-1] - arr[i])*n + 1;
        }
        else{
            b[arr[i]] = b[arr[i-1]] - n*(arr[i] - arr[i-1]) + 1;
        }
    }
   
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    for(int i=1;i<=n;i++)
        cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 896
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

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

	vector<vector<int>> a(3, vector<int>(3));
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	int n, b;
	cin >> n;
	for (int k = 0; k < n; ++k) {
		cin >> b;
		for (int i = 0; i < 3; ++i)
			for (int j = 0; j < 3; ++j) {
				if (a[i][j] == b)
					a[i][j] = 0;
			}
	}
	bool ok = false;
	//row
	for (int i = 0; i < 3; ++i) {
		bool bingo = true;
		for (int j = 0; j < 3; ++j) {
			if (a[i][j] != 0) bingo = false;
		}
		if (bingo) ok = true;
	}
	//column
	for (int i = 0; i < 3; ++i) {
		bool bingo = true;
		for (int j = 0; j < 3; ++j) {
			if (a[j][i] != 0) bingo = false;
		}
		if (bingo) ok = true;
	}
	//diagonal
	if (a[0][0] == a[1][1] && a[1][1] == a[2][2] && a[0][0] == 0)
		ok = true;
	if (a[0][2] == a[1][1] && a[1][1] == a[2][0] && a[0][2] == 0)
		ok = true;
	cout << (ok ? "Yes" : "No");
	return 0;
}

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

int main()
{ long long a,b,c,d;
  cin>>a>>b>>c>>d;
  
   long long x1= a*c;
   long long x2= a*d;
   long long x3= b*c;
   long long x4= b*d;
   
   long long ans= max({x1,x2,x3,x4});
   
   cout<<ans<<endl;

}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

int main(void){
    int N;
    scanf("%d",&N);

    long ans=0;
    for(int i=1;i<N;i++){
        ans+=i;
    }
    printf("%ld\n",ans);

    return 0;
}

//400点

Measured memory_bytes: 128
# 20/5/28
from collections import deque

N, Q = [int(x) for x in input().split()]
AL = [[] for _ in range(N + 1)]
for i in range(1, N):
    a, b = [int(x) for x in input().split()]
    AL[a].append(b)
    AL[b].append(a)

cnt = [0] * (N + 1)
for j in range(Q):
    p, x = [int(x) for x in input().split()]
    cnt[p] += x

visited = [False] * (N + 1)
stk = deque([1])
while stk:
    root = stk.pop()
    visited[root] = True
    for v in AL[root]:
        if not visited[v]:
            cnt[v] += cnt[root]
            stk.append(v)

print(*cnt[1:])

Measured memory_bytes: 56180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define max_n 100

vector<bool>have_been(max_n,false);
vector<vector<int>>edge(max_n);
int n,m;

void dfs(int start, int a, int b){
    have_been[start]=true;
    for(int i=0;i<edge[start].size();i++){
        if((start==a && edge[start][i]==b) || (start==b && edge[start][i]==a)) continue;
        if(have_been[edge[start][i]]==true) continue;
        dfs(edge[start][i],a,b);
    }
}

int main(void){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b; a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<edge[i].size();j++){
            for(int k=0;k<n;k++) have_been[k]=false;
            dfs(0,i,edge[i][j]);
            for(int k=0;k<n;k++){
                if(have_been[k]==false){
                    ans++;
                    break;
                } 
            } 
        }
    }
    cout << ans/2 << endl;


    return 0;

}

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

int main()
{
    long long n;
    cin >> n;
    map<long long,long long>mp;
    vector<long long>v;
    for(long long i=0;i<n;i++)
    {   long long  a;
        cin >> a;
        mp[a]++;
        if(mp[a]==2)
        {
            v.push_back(a);
            mp[a]=0;
        }
    }
    sort(v.begin(),v.end());
    n=v.size();
    if(n>=2)
    {
        cout << v[n-1]*v[n-2] << '\n';
    }
    else
    {
        cout << 0 << '\n';
    }
    return 0;
}


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

using namespace std;

long long calc(long long a, long long b) {
    if (a == b) return 1;
    long long c = a ^ b, k;
    for (int i = 60; i >= 0; --i) if (c >> i & 1) {
        k = i;
        a &= (1LL << k + 1) - 1; b &= (1LL << k + 1) - 1;
        break;
    }
    long long ret = (1LL << k) - a;
    c = b - (1LL << k);
    long long l = 1;
    while (l <= c) l <<= 1;
    if (a <= l) return ret + (1LL << k);
    return ret + (1LL << k) - (a - l);
}

int main(void) {
    long long a, b;
    cin >> a >> b;
    cout << calc(a, b) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var n,k,h int
	fmt.Scan(&n,&k)
	ans := 0

	for i := 0; i < n; i++ {
		fmt.Scan(&h)
		if h >= k {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<string, int>P;

map<string, int>mp;
int main() {
	int n; cin >> n;
	rep(i, n) {
		string s; int a; cin >> s >> a;
		mp[s] += a;
	}
	vector<P>v;
	for (auto m : mp)v.push_back(m);
	stable_sort(v.begin(), v.end(), [](P a, P b) {return a.first.length() < b.first.length(); });
	for (auto m : v)cout << m.first << ' ' << m.second << endl;
	return 0;
}

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

int main(){
int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0; i<N; i++){
   cin>>d[i];  }
  
  sort(d.begin(), d.end());
  
  int count=1;
  for(int i=0; i<N-1; i++){
   if(d[i]<d[i+1]){count++;}
  }
  
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> W(N);
    rep(i, 0, N) cin >> W[i];

    vector<int> wsLeft(N), wsRight(N);
    wsLeft[0] = W[0];
    rep(i, 1, N) wsLeft[i] = wsLeft[i-1] + W[i];
    wsRight[N-1] = W[N-1];
    rrep(i, N-2, 0) wsRight[i] = wsRight[i+1] + W[i];

    int res = INT_MAX;
    rep(T, 0, N-1) res = min(res, abs(wsLeft[T] - wsRight[T+1]));

    cout << res << endl;
}

Measured memory_bytes: 256
K = int(input())

n = 1
x = 7


if (K % 2 == 0)or(K % 5 == 0):
  print( -1 )
  exit( 0 )
#

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x * 10 + 7) % K
  n += 1
#


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
map<int,int> ma;
int mypow(int a,int b){
	if(b==0) return 1;
	if(b%2) return mypow(a,b-1)*a%mod;
	int z=mypow(a,b/2);
	return z*z%mod;
}
int mutu(int a,int b){
	int x=1,y=1;
	f(i,b){
		x=x*(a-i)%mod;
		y=y*(i+1)%mod;
	}
	return x*mypow(y,mod-2)%mod;
}
signed main(){
	int n,m,ans=1;
	cin>>n>>m;
	for(int i=2;i*i<=m;i++){
		while(m%i==0){
			m/=i;
			ma[i]++;
		}
	}
	if(m!=1) ma[m]++;
	for(P p:ma){
		ans=ans*mutu(p.S+n-1,p.S)%mod;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc163_c();
	}
  
  	public static void solve_abc163_c(){

		FastScanner sc = new FastScanner(System.in);
		
		
		int n = sc.nextInt();
		int[] ans = new int[n+1];
		Arrays.fill(ans, 0);
		
		for(int i=2;i<=n;i++){
			int b = sc.nextInt();
			ans[b]++;
		}
		
		for(int i=1;i<=n;i++){
			System.out.println(ans[i]);
		}


	}
}

Measured memory_bytes: 56536
#include<bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define pb push_back
using namespace std;
int main()
{
    string a,b;
    char p,q;
    ll i,j,k,n,f=0,h,w;
    cin>>a>>b;
    n=a.length();
    k=b.length();
    if(n>k)
    {
        cout<<"GREATER"<<endl;
    }
    else if(n<k)
    {
        cout<<"LESS"<<endl;
    }
    else
    {
        for(i=0;i<n;i++)
        {
            if(a[i]!=b[i])
            {
              f=1;
               p=a[i];
               q=b[i];
               break;
            }
        }
        if(f==0)
        {
            cout<<"EQUAL"<<endl;
        }
        else
        {
            if(p>q)
            {
                cout<<"GREATER"<<endl;
            }
            else
                cout<<"LESS"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]
  
n,k,l=map(int,input().split())
t1=UnionFind(n)
t2=UnionFind(n)
for _ in range(k):
  a,b=map(int,input().split())
  t1.Unite(a,b)
for _ in range(l):
  a,b=map(int,input().split())
  t2.Unite(a,b)
dic={}
for i in range(1,n+1):
  pos=(t1.FindRoot(i),t2.FindRoot(i))
  if pos not in dic:
    dic[pos]=1
  else:
    dic[pos]+=1
ans=[]
for i in range(1,n+1):
  pos=(t1.FindRoot(i),t2.FindRoot(i))
  ans.append(dic[pos])
print(*ans)

Measured memory_bytes: 44520
import sys

n = int(input())
a = list(map(int,input().split()))
q = int(input())
for query in (line.split() for line in sys.stdin):
    query = list(map(int, query))
    if query[0] == 0:
        print(min(a[query[1]:query[2]]))
    else:
        print(max(a[query[1]:query[2]]))


Measured memory_bytes: 5788
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxx = 1e5;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int cnt = 0;
	for(int i = 0; i < 3; i ++)
	{
		if(s1[i] == s2[i]) cnt ++;
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 256
# Problem C - /\/\/\/

from collections import Counter

# input process
n = int(input())
v_list = list(map(int, input().split()))

# initialization
even_list = []
odd_list = []
for i in range(n):
    if (i+1)%2:
        even_list.append(v_list[i])
    else:
        odd_list.append(v_list[i])
e_len = len(even_list)
o_len = len(odd_list)
# condition flow process
even_counter = Counter(even_list).most_common()
odd_counter = Counter(odd_list).most_common()
# adjustment process
if len(even_counter)==1:
    even_counter.append((0, 0))
if len(odd_counter)==1:
    odd_counter.append((0, 0))

if not even_counter[0][0]==odd_counter[0][0]:
    even_count = e_len - even_counter[0][1] # even list count
    odd_count = o_len - odd_counter[0][1] # odd list count
    print(even_count + odd_count)
else:
    even_count_1 = e_len - even_counter[0][1]
    odd_count_1 = o_len - odd_counter[1][1]
    cost_1 = even_count_1 + odd_count_1

    even_count_2 = e_len - even_counter[1][1]
    odd_count_2 = o_len - odd_counter[0][1]
    cost_2 = even_count_2 + odd_count_2

    ans = min(cost_1, cost_2)
    print(ans)


Measured memory_bytes: 65644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 5000000
#define MEMBER 3

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int groups;
  sscanf(line, "%d", &groups);

  int i;
  int members = groups*MEMBER;
  int *arr = malloc(sizeof(int)*members);
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  for(i = 0; i < members; i++) {
    char *tmp = strtok(tmpbuf, " ");
    arr[i] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
  }
  qsort(arr, members, sizeof(int), comp);
  int trashes = 0;
  long sum = 0;
  for(i = members-1; i >= trashes; i -= 2) {
    sum += arr[i-1];
    trashes += 1;
  }
  printf("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 6268
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int L = scan.nextInt();
        int[] apple = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            apple[i] = L + i + 1 - 1;
            sum += apple[i];
        }
        Arrays.sort(apple);
        int diff = Integer.MAX_VALUE;
        int answer = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int taste = sum - apple[i];
            if (Math.abs(sum - taste) < diff) {
                answer = taste;
                diff = Math.abs(sum - taste);
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23636
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>

using namespace std;

int N;


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

    cin >> N;    

    vector<pair<int, int>> edges;

    if (N % 2) {
        for (int i = 1; i <= N - 1; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                if (i + j != N) {
                    edges.emplace_back(i, j);
                }
            }
        }
        for (int i = 1; i <= N - 1; i++) {
            edges.emplace_back(N, i);
        }
    } else {
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i + j != N + 1) {
                    edges.emplace_back(i, j);
                }
            }
        }
    }

    cout << edges.size() << "\n";
    for (auto e : edges)
        cout << e.first << " " << e.second << "\n";

    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    for (ll i = 0; i < N + 1; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> B[i];
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        //まずA[i]から処理
        ll num1 = min(B[i], A[i]);
        ans += num1;
        A[i] -= num1;
        B[i] -= num1;

        //A[i + 1]を処理
        ll num2 = min(B[i], A[i + 1]);
        ans += num2;
        A[i + 1] -= num2;
        B[i] -= num2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_N 110
int n;
int rcs[MAX_N];

#define ROW(i) (rcs[i])
#define COL(i) (rcs[i+1])

int dp[MAX_N][MAX_N];

int min(int a, int b) {
	if (a < b) return a;
	else return b;
}

/* returns minimum value of i, i+1, i+2, ..., i+size matrix multiplication */
int rec(int i, int size) {
	if (size < 2) {
		return 0;
	} else if (size == 2) {
		return dp[i][size] = ROW(i)*COL(i)*COL(i+1);
	} else if (dp[i][size]) {
		return dp[i][size];
	}

	int j, m = MYINF;
	for (j = 1; j < size; j++) {
		m = min(m,   rec(i, j)
			   + rec(i+j, size-j)
			   + ROW(i)*ROW(i+j)*COL(i+size-1));
	}
	return dp[i][size] = m;
}

int solve() {
	return rec(0, n);
}

int main(int argc, char **argv)
{
	int i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &rcs[i], &rcs[i+1]);
	}

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

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n, k;
  cin >> n >> k;
  cout << (n + k - 3) / (k - 1) << endl;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
L, R = [], []
for _ in range(M):
    l, r = [int(x) for x in input().split()]
    L.append(l)
    R.append(r)

ans = max(min(R) - max(L) + 1, 0)
print(ans)


Measured memory_bytes: 11020
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d,c=0;
	cin >> n >> d;
	while(n--){
		double x,y,s;
		cin >> x >>y;
		s=sqrt(x*x+y*y);
		if(s<=d) c++;
	}
	cout << c;	
}

Measured memory_bytes: 3792
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int l;
    cin >> l;
    vl a(l);
    ll sum = 0;
    for (int i = 0; i < l; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    vvl dp(l + 1, vl(5, 0));
    for (int i = 1; i <= l; ++i) {
        dp[i][0] = dp[i - 1][0] + a[i - 1];
        dp[i][1] = dp[i - 1][1] + (a[i - 1] == 0 ? 2 : a[i - 1] % 2);
        dp[i][2] = dp[i - 1][2] + 1 - a[i - 1] % 2;
        dp[i][3] = dp[i - 1][3] + (a[i - 1] == 0 ? 2 : a[i - 1] % 2);
        dp[i][4] = dp[i - 1][4] + a[i - 1];
        chmin(dp[i][1], dp[i][0]);
        chmin(dp[i][2], dp[i][1]);
        chmin(dp[i][3], dp[i][2]);
        chmin(dp[i][4], dp[i][3]);
    }
    cout << dp[l][4] << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long  long 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const unsigned int M = 1000000007;


  
int main()
{
	#ifndef ONLINE_JUDGE


		 freopen("input.txt","r",stdin);
		 freopen("output.txt","w",stdout); 

	#endif

    ll k;
    cin>>k;
   
    ll sum=0;
  for (int i = 0; i <1000000; ++i)
  {

    sum=sum*10+7;
    sum=sum%k;
    if(sum==0)
     {
      cout<<i+1;
      return 0;
    }
  }
  cout<<-1;
      
return 0;
}




Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n,a[31],year,i;
    a[1] = 1;
    a[2] = 2;
    a[3] = 4;
    for(i = 4; i < 31; i++){
        a[i] = a[i-3] + a[i-2] + a[i-1]; 
        //cout << n[i] << endl;                   //a[i]=何通りか
    }
    while(true){
        cin >> n;                                   //n=段数   
        if(n == 0)    break;
        else{
            year = a[n] / 3650;
            cout << year + 1 << endl; 
        }
    }
}



Measured memory_bytes: 3072
import java.util.*;

class Main{
	static int mod=1000000007;
	static Scanner s=new Scanner(System.in);
	public static void main(String[]$){
		int n=s.nextInt()-1,m=s.nextInt()-1;
		long[]a=new long[n],b=new long[m];
		f(a);
		f(b);
		System.err.println(Arrays.toString(a));
		System.err.println(Arrays.toString(b));
		long A=g(n,a),B=g(m,b);
		System.out.println(A*B%mod);
	}
	static void f(long[]a){
		long p=s.nextLong();
		for(int i=0;i<a.length;++i) {
			long q=s.nextLong();
			a[i]=q-p;
			p=q;
		}
	}
	static long g(int n,long[]a){
		long A=0;
		for(int i=0;i<n;++i) {
			long p=Math.min(i,n-1-i);
			A+=((p+1)*p+(n-p*2)*(p+1))%mod*a[i];
			A%=mod;
		}
		return A;
	}
}


Measured memory_bytes: 93760
import sys
import math
from heapq import heappush, heappop, heapify

N,M=map(int, raw_input().split())
A=map(int, sys.stdin.readline().split())
A=map(lambda a: a*-1, A)
heapify(A)

for _ in range(M):
	a=heappop(A)
	a=math.ceil(float(a)/2)
	heappush(A,a)

print int(sum(A)*-1)


Measured memory_bytes: 45396
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getA :: [Int] -> Int
getA [] = 0
getA [x] = x
getA (x : y : xs) = minimum [x, y] + getA (y : xs)

getA' :: [Int] -> Int
getA' xs = head xs + getA xs

main = do
  n <- getInt
  bs <- getIntList
  print $ getA' bs


Measured memory_bytes: 508
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

const char *str[] = {
    "null",
    "one pair",
    "two pair",
    "three card",
    "straight",
    "full house",
    "four card",
};

bool is_fcd(int n[5],int m[12]){ return (m[0] == 4); }
bool is_flh(int n[5],int m[12]){ return (m[0] == 3 && m[1] == 2); }
bool is_str(int n[5],int m[12]){
    if(n[0] == n[1]-1 && n[1] == n[2]-1 && n[2] == n[3]-1 && n[3] == n[4]-1) return true;
    if(n[0] == 1 && n[1] == 10 && n[2] == 11 && n[3] == 12 && n[4] == 13) return true;
    return false;
}
bool is_thr(int n[5],int m[12]){ return (m[0] == 3); }
bool is_two(int n[5],int m[12]){ return (m[0] == 2 && m[1] == 2); }
bool is_one(int n[5],int m[12]){ return (m[0] == 2); }

int poker(int n[5]){
    int m[13];
    memset(m, 0, sizeof(m));
    REP(i,5) m[n[i]-1]++;
    sort(n, n+5, less<int>());
    sort(m, m+13, greater<int>());

    if(is_fcd(n,m)) return 6;
    if(is_flh(n,m)) return 5;
    if(is_str(n,m)) return 4;
    if(is_thr(n,m)) return 3;
    if(is_two(n,m)) return 2;
    if(is_one(n,m)) return 1;
    return 0;
}

int main(){
    string s;
    while(getline(cin, s)){
        int n[5];
        sscanf(s.c_str(), "%d,%d,%d,%d,%d", &n[0], &n[1], &n[2], &n[3], &n[4]);
        cout << str[poker(n)] << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define INF 10000000
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll mod = 1000000007;

void solve()
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> s(n+1, 0);
	rep(i, n)s[i+1]=s[i]+a[i];
	map<ll,ll> m;
	rep(i, n)m[s[i+1]]++;
	ll ans = 0;
	for(auto e:m)
	{
		ll x = e.second;
		ans += (x-1)*x/2;
	}
	ans += m[0];
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b(n);
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	vector<int> c(n-1);
	for(int i = 0; i < n-1; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += b[a[i] - 1];
		if(i != 0 and a[i] - a[i-1] == 1) {
			ans += c[a[i - 1] - 1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  map<string,int> mp;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  
  int mx=0;
  for(auto a:mp){mx=max(mx,a.second);}
  for(auto a:mp){
    if(a.second==mx){cout<<a.first<<endl;}
  }
}

    
  

Measured memory_bytes: 25216
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

void main() {
  long[] hw = readln.chomp.split.to!(long[]);
  if(hw[0]==1 || hw[1]==1) writeln(1);
  else writeln((hw[0]*hw[1]+1)/2);
}


Measured memory_bytes: 256
using System;

namespace B_Easy_Linear_Programming
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int k = int.Parse(str[3]);
            int ans = 0;

            if(a >= k)
            {
                ans += k;
            }
            else
            {
                ans += a;
                k -= a;
                if (b < k)
                {
                    k -= b;
                    ans -= k;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, c, cnt[111111];

int main() {
	cin >> n;
	rep(i,n) {
		cin >> c;
		cnt[c]++;
	}
	
	ll ans = 0;
	if (n%2==0) {
		for (int i = 1; i < n; i+=2) {
			if (cnt[i]!=2) goto fin;
		}
	} else {
		if (cnt[0]!=1) goto fin;
		for (int i = 2; i < n; i+=2) {
			if (cnt[i]!=2) goto fin;
		}
	}
	
	ans = 1;
	rep(i,n/2) ans = (ans*2)%mod;
	fin:
	cout << ans << ln;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){

  int N;
  cin>>N;
  int A,B;
  cin>>A>>B;
  int ans=0;
  int sum=0;
  int k10000;
  int k1000;
  int k100;
  int k10;
  int k1;
  int i2;
  for(int i=1;i<=N;i++){
  
    i2=i;
    k10000=i2/10000;
    i2-=10000*k10000;
    k1000=i2/1000;
    i2-=1000*k1000;
    k100=i2/100;
    i2-=100*k100;
    k10=i2/10;
    i2-=10*k10;    
    k1=i2;
    sum=k10000+k1000+k100+k10+k1;
    if(A<=sum&&sum<=B)ans+=i;
  }
  cout<<ans;
  return 0; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int n, nxt[200002], viz[200002];
ll k;
vector<int> vc;
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> n >> k;
	for(int i = 1; i <= n; ++i)
		cin >> nxt[i];
	int poz = 1;
	int stp = 0;
	while(k && stp <= 10000000)
		poz = nxt[poz], ++stp, --k;
	int init = poz;
	while(1)
	{
		viz[init] = 1;
		vc.pb(init);
		init = nxt[init];
		if(viz[init])
			break;
	}
	cout << vc[k%(vc.size())] << '\n';
    return 0;
}


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

using ll= long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<bool>> sign(3, vector<bool>(3, false));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    int N; cin >> N;
    vector<int> b(N);
    for(auto &x: b){
        cin >> x;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(x == A[i][j]) sign[i][j]=true;
            }
        }
    }
    bool ans=false;
    for(int i=0; i<3; i++){
        if(sign[i][0] && sign[i][1] && sign[i][2]) ans=true;
        if(sign[0][i] && sign[1][i] && sign[2][i]) ans=true;
    }
    if(sign[0][0] && sign[1][1] && sign[2][2]) ans=true;
    if(sign[0][2] && sign[1][1] && sign[2][0]) ans=true;
    if(ans) cout << "Yes" << endl;
    else cout << "No"  << endl;
    return 0;
}


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

int main() {
int a,b,c; cin>>a>>b>>c;
  cout<<max({a,b,c})-min({a,b,c})<<endl;
}
 

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

int p[200100];

void prime()
{
    rep(i, 200000) p[i] = 1;
    for (int i = 2; i < 200000; i++)
    {
        if (p[i] == 0)
            continue;
        for (int j = i + i; j < 200000; j += i)
        {
            p[j] = 0;
        }
    }
    return;
}

int main()
{
    prime();
    // rep(i, 100) if (p[i] == 1) cout << i << endl;
    int x;
    cin >> x;
    int ans = 0;
    for (int i = x; i < 200000; i++)
    {
        if (p[i] == 1)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

class index_sync_sort{
public:
    int N;
    std::vector< int > index;
    std::vector< int > data;
    std::vector< int > sync_data;
    
    index_sync_sort(int N_in){
        N = N_in;
        index.resize(N);
        data.resize(N);
        sync_data.resize(N);
        for(int i=0; i<N; i++){
            index[i] = i;
        }
    }
    
    void sort(int begin, int end){
        if(begin == end){
            return;
        }
        int tmp = begin;
        int threshold;
        while(1){
            tmp++;
            if(tmp > end){ return; }
            if(data[begin] > data[tmp]){
                threshold = data[begin];
                break;
            }else if(data[begin] < data[tmp]){
                threshold = data[tmp];
                break;
            }
        }
        int head_index = begin;
        int tail_index = end;
        while(1){
            while(data[head_index] < threshold){
                head_index++;
            }
            while(data[tail_index] >= threshold){
                tail_index--;
            }
            if(head_index > tail_index){
                break;
            }else{
                std::swap(data[head_index], data[tail_index]);
                std::swap(index[head_index], index[tail_index]);
                std::swap(sync_data[head_index], sync_data[tail_index]);
                head_index++;
                tail_index--;
            }
        }
        
        sort(begin, head_index - 1);
        sort(head_index, end);
        return;
    }
};

int main(){
    int N;
    std::cin >> N;
    index_sync_sort S(N);
    for(int i=0; i<N; i++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        S.sync_data[i] = tmp1 - tmp2;
        S.data[i] = tmp1 + tmp2;
    }
    
    S.sort(0, N - 1);
    
    int cnt = 0;
    int pre_right = -1e9;
    
    for(int i=0; i<N; i++){
        if(pre_right <= S.sync_data[i]){
            pre_right = S.data[i];
            cnt++;
        }
    }
    
    std::cout << cnt << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 1, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007
using namespace std;
int main(){
    FAST
    int n,m; cin >> n >> m;
    int h[n], a[m],b[m];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int good[n];
    for(int i = 0; i < n; i++){
        good[i] = 1;
    }
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        if(h[a[i] - 1] <= h[b[i] - 1]){
                good[a[i]-1] = 0;
        }
        if(h[b[i] - 1] <= h[a[i] - 1]){
            good[b[i] - 1] = 0;
        }
    }
    int sum=0;
    for(int i=0; i<n; i++){
        sum += good[i];
    }
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 5184
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;

    if (n > 999) {
        cout << "ABD";
        n++;
    } else {
        cout << "ABC";
    }
    // cout << n / 100 % 10;
    // cout << n /  10 % 10;
    // cout << n /   1 % 10 << endl;
    cout << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[5],k;
	cin >> a[0] >> a[1] >> a[2] >>a[3] >> a[4] >>k;
    for (int i =0 ; i < 5; ++i) {
        for (int j = 1; j < 5; ++j) {
            if (a[j] - a[i] > k) {

                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!"<< endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int w = sc.nextInt();

		int a = sc.nextInt();
		int b = sc.nextInt();

		StringBuffer sb = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();

		for (int j = 0; j < a; j++) {
			sb.append(0);
			sb2.append(1);
		}

		for (int j = 0; j < w - a; j++) {
			sb.append(1);
			sb2.append(0);
		}

		String b1 = sb.toString();
		String b2 = sb2.toString();
		List<String> result = new ArrayList<>();
		for (int j = 0; j < b; j++) {
			result.add(b1);
		}

		for (int j = 0; j < h - b; j++) {
			result.add(b2);
		}

		System.out.println(String.join(System.getProperty("line.separator"), result));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
            return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
            }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
            }
        }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
        }

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 29652
#include<bits/stdc++.h>
using namespace std;
int n,ans;
char s[100001];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1),ans=15-n;
	for(int i=1;i<=n;i++)if(s[i]=='o')ans++;
	if(ans>=8)puts("YES");else puts("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[1005][1005];
ll res(string a,string b){
  memset(dp,0,sizeof(dp));
  rep(i,sz(a))rep(j,sz(b)){
    if(a[i]==b[j]) dp[i+1][j+1]=dp[i][j]+1;
    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
  }
  return dp[sz(a)][sz(b)];
}
int main(){
  ll q;
  cin>>q;
  rep(i,q){
    string a,b;
    cin>>a>>b;
    COUT(res(a,b));
  }
}


Measured memory_bytes: 11048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  vector<int> j(N-K+1);
  for(int i=0;i<N-K+2;i++){
    j[i]=h[i+K-1]-h[i];
  }
  sort(j.begin(),j.end());
  cout << j[0] <<endl;
}


Measured memory_bytes: 1024
import math
import decimal

N,K=map(int, input().split())

sum = 0

for i in range(1,min(N+1,K)):
    num = K/i
    sum += 0.5 ** max(math.ceil(math.log2(num)), 1) * (1/N)


if (N>=K):
    sum += (N-K+1)/N

print('{:.12f}'.format(sum))

Measured memory_bytes: 5076