akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>	//C++標準ライブラリ一括読み込み
using namespace std;

// ax+by=c
// dx+ey=f
double unko(double x){
	int y=int(round(x*1000));
	return double(y)/1000;
}

int main(){
    double a,b,c,d,e,f,x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
		x=(c*e-b*f)/(a*e-b*d);
		y=(c*d-a*f)/(b*d-a*e);
		printf("%.3f %.3f\n",unko(x),unko(y));
	}
    return 0;
}


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

#define MAX 100
#define MAXV 1000
#define INF (INT32_MAX/2)

int N, W;
int w[MAX];
int v[MAX];

long long dp[MAX + 1][MAX * MAXV + 1];

int main() {
	cin >> N >> W;
	for( int i = 0; i < N; i++ ) {
		cin >> w[i] >> v[i];
	}

	for( int i = 0; i < MAX * MAXV + 1; i++ ) {
		dp[0][i] = INF;
	}
	dp[0][0] = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j <= MAX * MAXV; j++ ) {
			if( j < v[i] ) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = min( dp[i][j], dp[i][j - v[i]] + w[i] );
			}
		}
	}
	long long ans = 0;
	for( int i = 0; i <= MAX * MAXV; i++ ) {
		if( dp[N][i] <= W ) {
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


/*
pair<ll,ll> trans(ll x, ll y){
  if(x == 9){
    return make_pair(9LL, 2*(y-1));
  }
  if(x == 8){
    return make_pair(9LL-(y%9), 2*(y-1)-y/9);
  }
  if(x == 7){
    return make_pair(9LL-(2*y%9), 2*(y-1)-y/9-(y+4)/9);
  }
  if(x == 6){
    return make_pair(9LL-(3*y%9), 2*(y-1)-y/3);
  }
  if(x == 5){
    return make_pair(9LL-(4*y%9), 2*(y-1)-y/9-(y+6)/9-(y+4)/9-(y+2)/9);
  }
  if(x == 4){
    return make_pair(9LL-(5*y%9), 2*(y-1)-y/9-(y+7)/9-(y+5)/9-(y+3)/9-(y+1)/9);
  }
  if(x == 3){
    return make_pair(9LL-(6*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+4)/9-(y+3)/9-(y+1)/9);
  }
  if(x == 2){
    return make_pair(9LL-(7*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+5)/9-(y+3)/9-(y+2)/9-(y+1)/9);
  }
  if(x == 1){
    return make_pair(9LL-(8*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+5)/9-(y+4)/9-(y+3)/9-(y+2)/9-(y+1)/9);
  }
  return make_pair(0, y-1);
}
*/

pair<ll,ll> trans(ll x, ll y){
  if(y == 1) return make_pair(x, 0);
  if(y%2 == 0){
    if(x + x >= 10){
      ll a = (x+x)/10;
      ll b = (x+x)%10;
      pair<ll,ll> res = trans(a+b, y/2);
      return make_pair(res.first, y + res.second);
    }else{
      pair<ll,ll> res = trans(x+x, y/2);
      return make_pair(res.first, y/2 + res.second);
    }
  }else{
    if(x + x >= 10){
      ll a = (x+x)/10;
      ll b = (x+x)%10;
      pair<ll,ll> res = trans(a+b, (y-1)/2);
      if(res.first+x >= 10){
        ll aa = (res.first+x)/10;
        ll bb = (res.first+x)%10;
        return make_pair(aa+bb, 1 + y + res.second);
      }else{
        return make_pair(res.first+x, y + res.second);
      }
    }else{
      pair<ll,ll> res = trans(x+x, y/2);
      if(res.first+x >= 10){
        ll aa = (res.first+x)/10;
        ll bb = (res.first+x)%10;
        return make_pair(aa+bb, 2 + y/2 + res.second);
      }else{
        return make_pair(res.first+x, 1 + y/2 + res.second);
      }
    }
  }
}


int main(){
  int M;
  cin >> M;
  
  ll ret = 0;
  stack<ll> st;
  rep(i,M){
    ll d, c;
    cin >> d >> c;
    pair<ll,ll> res = trans(d, c);
    st.push(res.first);
    ret += res.second;
  }
  
  while(!st.empty()){
    if(st.size() == 1 && st.top()<10) break;
    if(st.top() >= 10){
      ll a = st.top(); st.pop();
      ll b = (a/10) + (a%10);
      //cout << a << "->" << b << endl;
      st.push(b);
      ret++;
    }
    else {
      ll a = st.top(); st.pop();
      ll b = st.top(); st.pop();
      ll c = a + b;
      //cout << a << " " << b << "->" << c << endl;
      st.push(c);
      ret++;
    }
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second
const int MM = 1e3+5;
int h,w,sr,sc,er,ec,dist[MM][MM];
char grid[MM][MM];
int main()
{
    memset(dist,0x3f,sizeof dist);
	cin.tie(0)->sync_with_stdio(0);
    cin >> h >> w;
    cin >> sr >> sc;
    cin >> er >> ec;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
            cin >> grid[i][j];
    }
    deque<pi> q;
    dist[sr][sc] = 0;
    q.pb({sr,sc});
    while(!q.empty())
    {
        auto[x,y] =q.front(); q.pop_front();
        // do 0 weight moves
        for(auto&[ax,ay]:vector<pi>{{1,0},{-1,0},{0,1},{0,-1}})
        {
            int nx = x + ax, ny = y + ay;
            if(nx < 1 || nx > h || ny < 1 || ny > w || grid[nx][ny] == '#') continue;
            if(dist[nx][ny] <= dist[x][y] + 0) continue;
            dist[nx][ny] = dist[x][y] + 0;
            q.push_front({nx,ny});
        }

        // do 1 weight moves
        for(int i = -2; i <= 2; i++)
        {
            for(int j = -2; j <= 2; j++)
            {
                if(i == 0 && j == 0) continue;
                if(i == 1 && j == 0) continue;
                if(i == -1 && j == 0) continue;
                if(i == 0 && j == 1) continue;
                if(i == 0 && j == -1) continue;
                int nx = x + i, ny = y + j;
                if(nx < 1 || nx > h || ny < 1 || ny > w || grid[nx][ny] == '#') continue;
                if(dist[nx][ny] <= dist[x][y] + 1) continue;
                dist[nx][ny] = dist[x][y] + 1;
                q.push_back({nx,ny});
            }
        }
    }
    cout << (dist[er][ec]==INF ? -1 : dist[er][ec]) << "\n";
}


Measured memory_bytes: 8600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  string s;
  int k;
  cin >> s >> k;
  int idx = 0;

  rep(i, s.size()) {
    if (s[i] == '1')
      continue;
    else {
      idx = i - 1;
      break;
    }
  }
  // cout << idx << endl;
  if (idx == -1) {
    cout << s[0] << endl;
  } else {
    if (k <= idx + 1) {
      cout << 1 << endl;
    } else {
      cout << s[idx + 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String s = sc.nextLine();
		String t = sc.nextLine();
		int a = 0;
		// スペース区切りの整数の入力
		int b = t.length();
		for(int i = 0; i < s.length() - t.length() + 1; i++){
			for(int j = 0;j < t.length();j++){
				if(!s.substring(i + j, i + j + 1).equals(t.substring(j, j + 1))){
					a ++;
				}
			}
			if(b > a){
				b = a;
			}
			a = 0;
		} 
		System.out.println(b);
		
		
	}
}

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

ll gcd(int a,int b,int c){
    int minabc = min(a,min(b,c));
    int gcdnow=1;
    rep(i,minabc){
        if(a%(i+1)==0&&b%(i+1)==0&&c%(i+1)==0){
            gcdnow=(i+1);
        }
    }
    return gcdnow;
}


int main() {
    int K;
    cin>>K;
    ll ans = 0;
    rep(i,K){
        rep(j,K){
            rep(k,K){
                ans+=gcd(i+1,j+1,k+1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
s = open(0).read().rstrip()
n = len(s)

from collections import defaultdict
ans = defaultdict(int)
ans[-2] = -1
ans[-1] = 0
ans[0] = 1

for i in range(1,n):
    if s[i] != s[i-1]:
        ans[i] = ans[i-1]+1
    else:
        ans[i] = ans[i-3]+2

print(ans[n-1])

Measured memory_bytes: 35840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		// ??£?¨?
		String line = "";
		char temp;
		// 26???????????¨?????????
		int[] array = new int[26];
		while (sc.hasNext()) {
			// ??±????????????
			line = sc.nextLine();
			// ??¨???????????????????°??????????????????????
			String lower = line.toLowerCase();
			// System.out.println(lower);
			// ?????????char ??????
			for (int i = 0; i < lower.length(); i++) {
				temp = lower.charAt(i);
				// System.out.println(temp);
				// ??\?????????????????¨a?????¢???????????????????????°?????§??????
				// if(Character.isLetter('a')){
				if ('a' <= temp && temp <= 'z') {
					array[temp - 'a']++;
				}
			}
		}
		for (int i = 0; i < array.length; i++) {
			System.out.println((char) ('a' + i) + " : " + array[i]);
		}
	}
}

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

int N;
vector<int> A, L;

// 広義最長減少部分列の長さ
int solve(){
  L[0] = A[0];
  int length = 1;
  for (int i = 1; i < N; i++) {
    if (L[length - 1] <= A[i]) {
      L[length] = A[i];
      length++;
    } else {
      auto iter = upper_bound(L.begin(), L.begin() + length, A[i]);
      L[iter - L.begin()] = A[i];
    }
  }
  return length;
}
int main() {
  cin >> N;
  A.resize(N);
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = - A[i];
  }
  cout << solve() << "\n";
  return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 1010;
  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int cnt = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i+j) != t.at(j)) cnt++;
    }
    if (cnt < ans) ans = cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
from itertools import product
H, W = list(map(int, input().split()))
board = [['.'] * W] + [list(input()) for _ in range(H)] + [['.'] * W]
board = [['.'] + b + ['.'] for b in board]
dhw = [[1, 0], [-1, 0], [0, 1], [0, -1]]
for h, w in product(range(1, H + 1), range(1, W + 1)):
    if board[h][w] == '#':
        can = False
        for dh, dw in dhw:
            if board[h + dh][w + dw] == '#':
                can = True
                break
        if not can:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000000 + 7
#define vpi vector<pair<int, int>>
#define ll long long int
#define MAX 1000000
#define minus_inf -1000000000


bool checkPalindrome(string x){
    string y = x;
    reverse(x.begin(), x.end());
    for(int i=0; i<x.length(); ++i){
        if(x[i]!=y[i]) return false;
    }
    return true;
}

int main(){
    unsigned long long int N; cin>>N;
    map <unsigned long long int, unsigned long long int> frequency;
    unsigned long long int arr[N];
    set <unsigned long long int, greater <unsigned long long int>> uniq;
    for(int i=0; i<N; ++i){
        cin>>arr[i];
        if(frequency[arr[i]]!=0){
            frequency[arr[i]] = frequency[arr[i]] + 1; 
        }
        else{
            frequency[arr[i]] = 1;
        }
        uniq.insert(arr[i]);
    }
    unsigned long long int sum = 0;
    for(auto &i:uniq){
        if(frequency[i]>=2)
        sum += (frequency[i]*(frequency[i]-1))/2;
    }
    for(unsigned long long int i=0; i<N; ++i){
        unsigned long long int current = sum;
        unsigned long long int freq = frequency[arr[i]];
        if(freq >= 2) current = current - (freq-1);
        cout<<current<<endl;
    }
}

Measured memory_bytes: 17024
using System;
using System.Collections.Generic;

namespace AtCoderABC133E
{
    class Program
    {
        static int MOD = 1000000007;

        static void Main(string[] args)
        {
            long ans = 1;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int[] X = new int[N];

            for (int i = 0; i < N-1; i++)
            {
                s = Console.ReadLine().Split(' ');

                X[int.Parse(s[0]) - 1]++;
                X[int.Parse(s[1]) - 1]++;
            }

            ans = Permitation(K, X[0] + 1);

            for(int i=1;i<N;i++)
            {
                ans = (ans * Permitation(K - 2, X[i] - 1)) % MOD;
            }

            Console.WriteLine(ans.ToString());
        }

        static int Permitation(int n,int r)
        {
            if (r > n)
                return 0;

            long ans = 1;

            for(int i = 0;i<r;i++)
            {
                ans = (ans * (n - i)) % MOD;
            }

            return (int)ans;
        }
    }
}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int R = int.Parse(line[1]);
            if(N >= 10)
            {
                Console.WriteLine(R);
            }
            else
            {
                Console.WriteLine(R + (100 * (10 - N)));
            }


        }
    }
}

Measured memory_bytes: 13140
from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
ans = [0]*(N+1)
visited = [0]*(N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if j in f[n] and visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])


Measured memory_bytes: 137984
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");

		int[] data = new int[line.length];
		for(int i = 0; i < data.length; i++){
			data[i] = Integer.parseInt(line[i]);
		}

		Dice dice = new Dice(data);

		char[] m = br.readLine().toCharArray();
		for(int i = 0; i < m.length; i++){
			dice.move(m[i]);
		}

		System.out.println(dice.getTop());
	}
}

class Dice{
	private int top;
	private int front;
	private int right;
	private int back;
	private int left;
	private int bottom;
	
	public Dice(int[] data){
		this.top = data[0];
		this.front = data[1];
		this.right = data[2];
		this.left = data[3];
		this.back = data[4];
		this.bottom = data[5];
	}

	public void move(char m){
		int temp = -1;
		switch(m){
			case 'N':
				temp = this.top;
				this.top = this.front;
				this.front = this.bottom;
				this.bottom = this.back;
				this.back = temp;
				break;

			case 'E':
				temp = this.top;
				this.top = this.left;
				this.left = this.bottom;
				this.bottom = this.right;
				this.right = temp;
				break;

			case 'S':
				temp = this.top;
				this.top = this.back;
				this.back = this.bottom;
				this.bottom = this.front;
				this.front = temp;
				break;

			case 'W':
				temp = this.top;
				this.top = this.right;
				this.right = this.bottom;
				this.bottom = this.left;
				this.left = temp;
				break;
		}
	}

	public int getTop(){
		return this.top;
	}
}

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

def main():
    N,M = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(M)]
    count = 0
    def bridge(X):
        go = [False for _ in range(N)]
        queue = [0]
        while queue:
            a = queue.pop()
            for i in X[a]:
                if not go[i]:
                    go[i] = True
                    queue.append(i)
        if all(go):
            return 1
        else:
            return 0
    for i in range(M):
        b = a[:i]+a[i+1:]
        road = [[] for _ in range(N)]
        for j in range(M-1):
            road[b[j][0]-1].append(b[j][1]-1)
            road[b[j][1]-1].append(b[j][0]-1)
        count += bridge(road)

    print(M-count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
n=int(input())
a = [int(i) for i in input().split()] 
#print(n,a)

cnt=0
ans=0
mina=float('inf')

for i in range(n):
  if a[i] >= 0:
    ans+=a[i]
    mina=min(mina,a[i])
  else:
    ans-=a[i]
    cnt+=1
    mina=min(mina,-a[i])
    
if a.count(0)>0:
  print(ans)
elif cnt%2==0:
  print(ans)
else:
  print(ans-2*mina)




Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ld long double
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
const int inf=1e9+7;

int main()
{
	ll n;
	ld p,ans=0;
	cin>>n;
	vector<ld> dp(n+1);
	dp[0]=1; 
	loop(coin,0,n)
	{
		cin>>p;
		rloop(i,coin+1,0)
		dp[i]=((i)?dp[i-1]*p:0 )+dp[i]*(1-p);
	}
//	loop(i,0,n+1)
//	cout<<dp[i]<<" ";
//	cout<<endl;
    ll t;
	loop(h,0,n+1)
	{
		t=n-h;
		if(h>t) 
		 ans+=dp[h];
	}
	cout<<setprecision(12)<<ans;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100005;
int a[N], b[N];
int main(){
  int n; cin >> n;
  for(int i=0;i<n;++i) cin >> a[i];
  sort(a,a+n);
  for(int i=0;i<n;i++){
    b[a[i]]++;
  }
  int ans=0;
  for(int X=1;X<=99999;X++) ans = max(ans, b[X-1]+b[X]+b[X+1]);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    vector<int> sum(102,0);
    vector<int> ans(102,0);
    sum[A]++;
    sum[B]--;
    sum[C]++;
    sum[D]--;
    int cnt = 0;
    ans[0]=sum[0];
    for(int i=1;i<102;i++){
        ans[i]=ans[i-1]+sum[i];
    }
    for(int i=0;i<102;i++){
        if(ans[i]==2){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

/*ll gcd(ll a, ll b) {
    if(a*b == 0)return max(a, b);
    if (a < b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    if (a%b == 0)return b;
    return gcd(b, a%b);
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> T(N,0);
    for(int i=0;i<N;i++){
        cin >> T[i];
    }
    ll ans=T[0];
    for(int i=1;i<N;i++){
        ans = lcm(ans,T[1]);
    }
    return 0;
}*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define sllf(n) scanf("%lld",&n)
#define pllf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,greater<int> > q;
const int N=1e5+10;
const int mod=1e9+7;
int n,m,a[N],sum=0;
int main()
{
	stf(n,m);
	rep(i,1,n){
		sf(a[i]);
		if(a[i]>=m)sum++;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
  //input
  str s; cin >> s;
  bool ans; ans = true;
  //examine
  for(int i=0; i<s.length(); i++){
    if(i%2 == 0){
      if(s[i] == 'L'){
      ans = false;
      }
    }
    else{
      if(s[i] == 'R'){
      ans = false;
      }
    }
  }
  if(ans){
    printf("%s", "Yes");
  }
  else{
    printf("%s", "No");
  }
  return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
typedef pair<int, string> p_is;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    int v[100000];
    REP(i, M) {
        v[i] = 0;
    }
    ll ac = 0;
    ll wa = 0;
    REP(i, M) {
        int tmp;
        string st;
        cin >> tmp >> st;
        if (v[tmp] >= 0) {
            if (st == "WA") v[tmp]++;
            if (st == "AC") {
                wa += v[tmp];
                if (v[tmp] >= 0) ac++;
                v[tmp] = -1;
            }
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <utility>
using namespace std;
int main()
{
	int i=0,j,num[6],q,n1,n2;
	char order[100],c;	
	cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5];
	cin>>q;
	for(i=0;i<q;i++){
		cin>>n1>>n2;
		j=0;
		while(1){
			if(num[1]==n2)break;
			swap(num[0],num[1]);
			swap(num[1],num[4]);
			swap(num[1],num[5]);
			if(j==4){
			swap(num[0],num[3]);
			swap(num[2],num[3]);
			swap(num[3],num[5]);	
			}
			j++;
		}
		while(1){
			if(num[0]==n1)break;
			swap(num[0],num[3]);
			swap(num[2],num[3]);
			swap(num[3],num[5]);
		}
		cout<<num[2]<<endl;

	}
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}

	public static void main(String[] $){
		int n=gInt(),k=gInt();
		long[]a=new long[n+1];
		for(int i=1;i<=n;++i)
			a[i]=gInt()+a[i-1];
		
		ArrayList<Long>l=new ArrayList<>();
		for(int i=0;i<n;++i)
			for(int j=i+1;j<=n;++j)
				l.add(a[j]-a[i]);

		long r=0;
		for(int i=62;i>=0;--i) {
			long b=1L<<i;
			int c=0;
			for(long v:l) {
				if((v&b)>0)
					++c;
				if(c==k) {
					r|=b;
					l.removeIf(o->(o&b)==0);
					break;
				}
			}
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 50868
// CppPractice.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include <iostream>

using namespace std;

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

	cout << a*b << " " << a*2+b*2 << endl;

    return 0;
}



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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> d(n);
  int res = 0;
  for (int i = 0; i < n; ++i) cin >> d[i];
  for (int i = 0; i < n; ++i) 
    for (int j = i+1; j < n; ++j) 
      res += d[i]*d[j];
  cout << res << endl;


  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, a;
	cin >> n;
	vector<int>rate(8, 0);
	int highRate = 0;
	rep(i, n) {
		cin >> a;
		if (a <= 399)rate[0] = 1;
		else if (a <= 799)rate[1] = 1;
		else if (a <= 1199)rate[2] = 1;
		else if (a <= 1599)rate[3] = 1;
		else if (a <= 1999)rate[4] = 1;
		else if (a <= 2399)rate[5] = 1;
		else if (a <= 2799)rate[6] = 1;
		else if (a <= 3199)rate[7] = 1;
		else highRate++;
	}
	int kind = accumulate(all(rate), 0);
	cout << max(1,kind) << " " << kind + highRate;
	return 0;
}


Measured memory_bytes: 3588
import math
a, b = map(int, input().split())
x = []
y = []
for i in range(math.ceil(b/0.1), math.floor((b+1)/0.1)):
    y.append(i)
for i in range(math.ceil(a/0.08), math.floor((a+1)/0.08)):
    x.append(i)
    if y.count(i) == 1:
        print(i)
        exit()
print('-1')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  int tmp=10000000;
  int cnt=0;
  for(int i=0; i<N; i++){
    int P; cin >> P;
    tmp=min(tmp,P);
    if(P<=tmp) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
int tbl[N][N];
bool prime[N*N+1];
int m,s;
int sx,sy;
int num[N][N], lastp[N][N];

void maketbl(){
  const int dx[] = {1,0,-1,0};
  const int dy[] = {0,-1,0,1};
  int x=N/2,y=N/2;
  int t = 1;
  int d = 1;
  int dir = 0;
  while(t<=1000000){
    for(int i=0;i<d;++i){
      tbl[y][x]=t++;
      y+=dy[dir];
      x+=dx[dir];
      if(t>1000000) break;
    }
    dir = (dir+1)%4;
    if(dir%2==0) ++d;
  }
}

void solve(int x,int y){
  if(num[y][x]!=-1) return;
  if(tbl[y][x]==s){
    num[y][x] = prime[s];
    lastp[y][x] = (prime[s])?s:0;
    return;
  }
  if(abs(x-sx) > y-sy) return;
  int a1=0,a2=0;
  for(int mx=x-1;mx<=x+1;++mx){
    int my = y-1;
    if(mx<0 || mx>=N) continue;
    if(tbl[my][mx]>m) continue;
    solve(mx,my);
    if(a1 < num[my][mx]){
      a1 = num[my][mx];
      a2 = lastp[my][mx];
    }
    else if(a1 == num[my][mx]) a2 = max(a2,lastp[my][mx]);
  }
  if(prime[tbl[y][x]]){
    a1++;
    a2=tbl[y][x];
  }
  num[y][x]=a1;
  lastp[y][x]=a2;
}

int main(){
  maketbl();
  for(int i=2;i<=N*N;++i) prime[i]=true;
  for(int i=2;i<=N*N;++i) if(prime[i]) for(int j=2;i*j<=N*N;++j) prime[i*j]=false;

  while(cin>>m>>s,m||s){
    memset(num,-1,sizeof(num));
    memset(lastp,-1,sizeof(lastp));
    for(int i=0;i<N;++i)
      for(int j=0;j<N;++j)
	if(tbl[i][j]==s){
	  sx = j;
	  sy = i;
	  break;
	}
    int ans1 = 0,ans2 = 0;
    for(int j=0;j<N;++j){
      for(int i=N-1;i>=0;--i){
	if(tbl[i][j] && tbl[i][j]<=m){
	  solve(j,i);
	  if(ans1 < num[i][j]){
	    ans1 = num[i][j];
	    ans2 = lastp[i][j];
	  }
	  else if(ans1 == num[i][j])
	    ans2 = max(ans2,lastp[i][j]);
	  break;
	}
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}

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

int n;
vector<vector<int>> v(111111);
bool used[111111],flag[111111];
int dist;
 
bool dfs1(int p,int d){
    used[p] = true;
    bool ret = 0;
    if(p == n-1){
        flag[p] = true;
        return 1;
    }
    for(auto i:v[p]){
        if(!used[i]){
            ret ^= dfs1(i,d+1);
        }
    }
    if(ret == 1){
        dist = max(dist,d);
        flag[p] = true;
    }
    return ret;
}
 
bool gone[111111];
int tr;
int dfs2(int p,int d){
    gone[p]=true;
    if(flag[p] && d>tr){
        return 0;
    }
    int ret = 1;
    for(auto i:v[p]){
        if(!gone[i]){
            ret += dfs2(i,d+1);
        }
    }
    return ret;
}

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


    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }    
    bool t = dfs1(0,0);
    cerr<<dist<<endl;

    for(int i=0;i<n;i++) cerr<<flag[i]<<" ";
    cerr<<endl;
    
    int ans = 0;
    tr = (dist+1)/2;
    ans += dfs2(0,0);
    cerr << ans <<endl;
    
    
    if(ans>n/2){
        cout << "Fennec" << endl;
    }
    else {
        cout<<"Snuke" << endl;
    }

    
}

Measured memory_bytes: 12544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
/**
 *それぞれ b: 4棟, f: 3階, r: 10部屋
 *三次元配列で表す。
 * 
 */
		int[][][] A = new int[4][3][10];
		for(int i = 0; i < n; i++) {
			int b = sc.nextInt() - 1;
			int f = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			int v = sc.nextInt();
			A[b][f][r] += v;
		}
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 10; k++) {
					System.out.print(" " + A[i][j][k]);
				}
				System.out.println("");
			}
			if(i == 3) {
			
				break;
			}
			System.out.println("####################");
		}
		
		sc.close();
	}
}



Measured memory_bytes: 29316
n = int(input())

rs = []
aes = []
bs = []

for _ in range(n):
  a, b = map(int, input().split())
  rs.append([a,b])
  aes.append(a)
  bs.append(b)


aes.sort()
bs.sort(reverse=True)

if n % 2 == 1:
  p = aes[(n - 1) // 2]
  q = bs[(n - 1) // 2]
  ans = q - p + 1
else:
  p1 = aes[n // 2 - 1]
  p2 = bs[n // 2]
  q1 = aes[n // 2]
  q2 = bs[n // 2 - 1]
  ans = (p2 - p1 + 1) + (q2- q1 + 1) - 1
 
# print(p1, p2, q1, q2)
print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll n, k, ans = -1e18;
  cin >> n >> k;
  vector<ll> p(n), c(n), M;
  rep(i, n) cin >> p[i], --p[i];
  rep(i, n) cin >> c[i];
  rep(i, n) {
    ll x = i;
    vector<ll> s;
    ll tot = 0;
    do {
      x = p[x];
      s.push_back(c[x]);
      tot += c[x];
    } while (x != i);
    ll l = s.size();
    ll t = 0;
    rep(j, l) {
      t += s[j];
      if (j + 1 > k) break;
      ll now = t;
      if (tot > 0) {
        ll e = (k - j - 1) / l;
        now += tot * e;
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3772
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nab = br.readLine().split(" ");
        int n = Integer.parseInt(nab[0]);
        int a = Integer.parseInt(nab[1]);
        int b = Integer.parseInt(nab[2]);
        String ans;
        
        if (Math.abs(a-b) % 2 == 1) {
            ans = "Borys";
        }
        else {
            ans = "Alice";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main(){
    int S;
    cin >> S;
    int h, m, s;
    h = S / (60 * 60);
    m = S % (60 * 60) / 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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


int main(){
  long long x,y;
  cin >> x >> y;
  long long ans=0;
  if(y>=x && y*x>=0){
    ans=y-x;
  }else if(y>x && y*x<0){
    ans=abs(y-abs(x))+1;
  }else if(x>y && x*y>=0){
    ans=abs(x-y)+2;
    if(x==0 || y==0){
      ans--;
    }
  }else if(x>y && x*y<0){
    ans=abs(x-abs(y))+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Frog 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int hs[MAX_N], dp[MAX_N];

/* subroutines */

/* main */

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

  fill(dp, dp + n, INF);
  dp[0] = 0;
  
  for (int i = 0; i < n; i++)
    for (int j = 1; j <= k && i + j < n; j++) {
      int d = dp[i] + abs(hs[i + j] - hs[i]);
      if (dp[i + j] > d) dp[i + j] = d;
    }

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


Measured memory_bytes: 1024
N = list(map(int,list(input())))
ans = 0
skfl = 0
nf = 0
for i in range(1, len(N) + 1):
    if i != len(N):
        if N[-(i+1)] >= 5:
            nf = 1
    if N[-i] + skfl + nf > 5:
        ans += 10 - N[-i] - skfl
        skfl = 1
    else:
        ans += N[-i] + skfl
        skfl = 0
    nf = 0
print(ans+skfl)

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

int main() {  
  int N, M;
  cin >> N >> M;
  
  bool TF[M] = { false };

  for (int i = 0; i < N; ++i) {
    int K;
    cin >> K;
    int A_K[M] = { false };
    for (int j = 0; j < K; ++j) {
      int A;
      cin >> A;
      A_K[A-1] = true;
    }
    for (int j = 0; j < M; ++j) {
      if (i == 0) {
        TF[j] = A_K[j];
      } else {
        TF[j] = TF[j] & A_K[j] ;
      }
    }
  }
  
  cout << count(TF, TF+M, true) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static int N;
	static int[][] yosou = new int[4][100000];
	static int[] input_array = new int[100000];

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

		N = sc.nextInt();
		String line = sc.next();
		for(int i = 0;i < line.length();i++){
			char ch = line.charAt(i);
			if(ch == 'x')input_array[i] = 1;
		}

		//羊、羊...
		yosou[0][0] =  1;
		yosou[0][1] =  1;
		//羊、狼...
		yosou[1][0] =  1;
		yosou[1][1] = -1;
		//狼、羊...
		yosou[2][0] = -1;
		yosou[2][1] =  1;
		//狼、狼...
		yosou[3][0] = -1;
		yosou[3][1] = -1;

		int yosou_id = -1;
		for(int i = 0;i < 4;i++){
			for(int j = 2;j < N;j++){
				int left1_animal = yosou[i][j-1];
				int left2_animal = yosou[i][j-2];


				if(input_array[j-1] == 0){
					yosou[i][j] = left1_animal * left2_animal;
				}else{
					yosou[i][j] = -left1_animal * left2_animal;
				}
			}

			if(!isCorrect(i, 0))continue;
			if(!isCorrect(i, N-1))continue;
			yosou_id = i;
			break;
		}

		if(yosou_id < 0){
			System.out.println(-1);
		}else{
			for(int i = 0;i < N;i++){
				if(yosou[yosou_id][i] == 1){
					System.out.print("S");
				}else{
					System.out.print("W");
				}
			}
		}
		System.out.println();

		sc.close();
	}

	public static boolean isCorrect(int i,int j){
		int left = j - 1;
		if(left < 0)left += N;
		int right = j + 1;
		if(right >= N) right -= N;

		boolean match = yosou[i][left] == yosou[i][right];

		if(yosou[i][j] == 1){
			if(input_array[j] == 0){
				return match;
			}
			return !match;
		}

		if(input_array[j] == 0){
			return !match;
		}
		return match;
	}
}


Measured memory_bytes: 38568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <functional>
#include <cmath>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int N;
double distSum = 0;
vector<double> x(8);
vector<double> y(8);


// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

void calc( int *indexes ){

    for(int i = 0; i < N - 1; i++){
        double tmp = (x[ indexes[i+1] ] - x[ indexes[i] ]) * (x[ indexes[i+1] ] - x[ indexes[i] ]) + (y[ indexes[i+1] ] - y[ indexes[i] ]) * (y[ indexes[i+1] ] - y[ indexes[i] ]);
        distSum += sqrt(tmp);
    }
}

int main(){

    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    ll div = 1;
    for(ll i = 1; i <= N; i++){
        div *= i;
    }
  foreach_permutation(N, calc);
  //cout << div << endl;
    cout << setprecision(10) << distSum / div << endl;

}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
s = input()

A = B = 0
ans = ''
for c in s:
    if A + B == a + b:
        print('No')
    elif c == 'a':
        print('Yes')
        A += 1
    elif c == 'b' and B < b:
        print('Yes')
        B += 1
    else:
        print('No')


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

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

  int k;
  cin >> k;

  for (int i = 0; i < 5;i ++){
    for (int j = i+1; j < 5; j++){
      if(abs(a.at(i)-a.at(j)) >k){
        cout << ":(";
            return 0;
      }
    }
  }
  cout << "Yay!";
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=1e5+5;
map<ll,int>id,fid;
ll a[N],ans;
int n,siz[N];
vint G[N];
void dfs(int x,int dis){ans+=dis;for(auto y:G[x])dfs(y,dis+1);}
signed main(){
	//freopen("a","r",stdin);
	n=read();rep(i,1,n)a[i]=read(),fid[a[i]]=i;
	sort(a+1,a+n+1,[](ll a,ll b){return a>b;});
	rep(i,1,n)id[a[i]]=i,siz[i]=1;
	rep(i,1,n-1){
		ll to=a[i]+siz[i]-(n-siz[i]);
		if(!id[to])return cout<<-1,signed();
		G[id[to]].pb(i);siz[id[to]]+=siz[i];
	}dfs(n,0);if(ans^a[n])return cout<<-1,signed();
	rep(i,1,n)for(auto j:G[i])cout<<fid[a[i]]<<' '<<fid[a[j]]<<'\n';
	return signed();
}

Measured memory_bytes: 24280
S = input()
T = input()
m = len(S)
n = len(T)

Sa = []

if m >= n:
    for i in range(m+1-n):
        for j in range(n):
            if S[i+j] != T[j] and S[i+j] != "?":
                break
        else:
            s = S[:i] + T + S[i+n:]
            Sa.append(s.replace("?", "a"))
            

if Sa:
    print(min(Sa))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

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

typedef long long llint;

const int mod = 1e9 + 7;

inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }

inline int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }

inline int mul(int a, int b) { return llint(a) * b % mod; }

const int MAX = 3030;

int f[MAX][MAX][2];

int main(void) {
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  REP(j, N + 1) { f[0][j][j == 0] = 1; }

  REP(i, M) REP(j, N + 1) REP(c, 2) {
    if (j > 0) {
      int nc = c || (j - 1 == 0);
      f[i + 1][j][nc] = add(f[i + 1][j][nc], f[i][j][c]);
      f[i + 1][j - 1][nc] = add(f[i + 1][j - 1][nc], f[i][j][c]);
    }
    if (j < N) {
      f[i + 1][j][c] = add(f[i + 1][j][c], f[i][j][c]);
      f[i + 1][j + 1][c] = add(f[i + 1][j + 1][c], f[i][j][c]);
    }
  }

  int ret = 0;
  REP(j, N + 1) ret = add(ret, f[M][j][1]);
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 71936
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const input = (lines[0] as string).split(" ");
  const alice = [Number(input[0]), Number(input[1])];
  const bob = [Number(input[2]), Number(input[3])];

  if (alice[0] > bob[1] || bob[0] > alice[1]) {
    console.log(0);
    return;
  }

  const a = alice[0] > bob[0] ? alice[0] : bob[0];

  const b = alice[1] < bob[1] ? alice[1] : bob[1];

  console.log(b - a);
});


Measured memory_bytes: 11596
count :: String -> String -> String -> Int
count [] _ _ = 0
count (a:as) (b:bs) (c:cs) = if a == b && b == c then count as bs cs
  else if a /= b && b /= c && c /= a then 2+(count as bs cs)
  else 1+(count as bs cs)

main :: IO ()
main = do
  _ <- getLine
  a <- getLine
  b <- getLine
  c <- getLine
  putStrLn $ show $ count a b c

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {

    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      Integer n;
      String line;
      Deque<Integer> que = new ArrayDeque<>(100);
      while (true) {
        line = br.readLine();
        if ((line == null) || line.isEmpty())
          break;

        n = new Integer( Integer.parseInt(line) );

        if (n != 0)
          que.add(n);
        else
          System.out.println(que.pollLast());
      }
    } catch (IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 24388
#include<iostream>

using namespace std;

int main(void){

    int N,M,m;
    cin>>N;
    
    M=1;
    m=1000000000;
    


    for(int i= 0;i<N;i++){
        int A;
        cin>>A;
        M=max(M,A);
        m=min(m,A);
               
    }

    cout<<M-m<<endl;
         

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<short int> vi;
#define REP(i,y) for(int i=0; i<y; ++i)
int INF = 1<<30, N;
vector<vi> X(18, vi(2));
vi V_(18), V(18), Vb(18);
inline int search(int F){
  if(__builtin_popcount(F)&1) return INF;
  REP(i,N) V_[i] = V[i] = X[i][Vb[i] = (F>>=1)%2];
  sort(V.begin(), V.begin()+N);
  int ans = 0;
  REP(i,N){
    for(int j=i; j<N; ++j){
      if(V[i]!=V_[j] || (j-i+Vb[j])&1) continue;
      ans += j-i;
      for(int k=j-1; k>=i; --k){
        V_[k+1] = V_[k];
        Vb[k+1] = Vb[k]+1;
      }
      goto END;
    }
    return INF;
END:
    continue;
  }
  return ans;
}
int main(){
  scanf("%d", &N);
  REP(i,2*N) scanf("%d", &X[i%N][i/N]);
  int ans=INF;
  REP(i,1<<N) ans = min(ans, search(i<<1));
  printf("%d\n", (ans==INF?-1:ans));
  return 0;
}

Measured memory_bytes: 384
#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 = 1'000'000'007;
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; }
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0 << endl;
    else {
        ll min = INF;
        chmin(min, a * b);
        chmin(min, b * c);
        chmin(min, c * a);
        cout << min << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int i = 0;i <n;i++)
class Monoid {
public:
	int unit;
	Monoid(){
		unit = 2147483647;
	}int calc(int a, int b) {
		return min(a, b);
	}
};
struct RUP {
	int n;
	Monoid mono;
	vector<int> dat, laz;
	RUP() {}
	RUP(int n_) { init(n_); }
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, mono.unit);
		laz.clear();
		laz.resize(2 * n - 1, -1);
	}
	inline void eval(int len, int k) {
		if (laz[k] < 0) return;
		if (k * 2 + 1 < n * 2 - 1) {
			laz[k * 2 + 1] = laz[k];
			laz[k * 2 + 2] = laz[k];
		}
		dat[k] = laz[k];
		laz[k] = -1;
	}
	int update(int a, int b, int x, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return dat[k];
		if (a <= l && r <= b) return laz[k] = x;
		eval(r - l, k);
		dat[k] = mono.calc(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
			update(a, b, x, k * 2 + 2, (l + r) / 2, r));
		return dat[k];
	}
	int query(int a, int b, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return mono.unit;
		if (a <= l && r <= b) return dat[k];
		int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return mono.calc(vl, vr);
	}
	void update(int a, int b, int x) {
		update(a, b, x, 0, 0, n);
	}
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};
int main(){
	int n, q; cin >> n >> q;
	RUP rup(n);
	rep(i, q) {
		int a; cin >> a;
		if (a == 0) {
			int s, t, x; cin >> s >> t >> x;
			rup.update(s, t + 1, x);
		}
		else {
			int s, t; cin >> s >> t;
			cout << rup.query(s, t + 1) << endl;
		}
	}
}


Measured memory_bytes: 4948
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll=long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,m,a;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>s;
	a=s.size();
	a=min(a,n);
	for(int i=0;i<a;i++)cout<<s[i];
	if(n<s.size())cout<<"...";
}


Measured memory_bytes: 3660
k=input()
K=int(k)

s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(s[K-1])

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

int main() {
    int V, d;
    while (cin >> V >> d) {
        vector<int> fib_mod(V);
        fib_mod[0] = 2;
        fib_mod[1] = 3;
        for (int i = 2; i < V ; i++) {
            fib_mod[i] = fib_mod[i-1] + fib_mod[i-2];
            fib_mod[i] %= 1001;
        }
        sort(fib_mod.begin(), fib_mod.end());
        int count = 1;
        for (int i = 1; i < V; i++) {
            if (fib_mod[i] - fib_mod[i-1] >= d) count++;
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
N, M = map(int, input().split())
S = input()

S_inv = S[::-1]
count = 0
ans_inv = []
flag = True
flag2 = True

while flag:
    for i in range(M):
        if len(S_inv) - count - 1 < M:
            if len(S_inv) - count - 1 != 0:
                ans_inv.append(len(S_inv) - count - 1)
            flag = False
            break
        elif S_inv[count + M - i] == "0":
            count += M - i
            ans_inv.append(M - i)
            break
    else:
        flag2 = False
        break

if flag2:
    print(*ans_inv[::-1])
else:
    print(-1)


Measured memory_bytes: 6476
import numpy as np
even = np.zeros(100001, dtype=int)
odd = np.zeros(100001, dtype=int)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)


Measured memory_bytes: 23364
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define MAXN 300001

using namespace std;
typedef pair<int, int> pii;

vector<int> ST;

int query(int qlow, int qhigh, int low, int high, int pos) {
    /* 3 states:
     * 1. no overlap
     * 2. complete overlap
     * 3. partial overlap
     */

    // 1. no overlap
    if (low > qhigh || high < qlow) return INT_MIN;

    // 2. complete overlap
    if (low >= qlow && high <= qhigh) return ST[pos];

    // 3. partial overlap (look to both child nodes)
    int mid = (low + high) / 2;
    return max(query(qlow, qhigh, low, mid, pos * 2 + 1),
            query(qlow, qhigh, mid + 1, high, pos * 2 + 2));
}

void update(int pos, int low, int high, int index, int val) {
    if (low == high) ST[pos] = val;
    else {
        int mid = (low + high) / 2;

        if (low <= index && index <= mid) update(pos * 2 + 1, low, mid, index, val);
        else update(pos * 2 + 2, mid + 1, high, index, val);

        ST[pos] = max(ST[pos * 2 + 1], ST[pos * 2 + 2]);
    }
}

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;

    int stSize = 2 * (1 << (int) (ceil(log2(MAXN)))) - 1;
    ST = vector<int>(stSize, 0);

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int left = max(0, a - k), right = min(300000, a + k);

        int val = query(left, right, 0, 300000, 0);
        update(0, 0, 300000, a, val + 1);
    }

    cout << ST[0];
}


Measured memory_bytes: 7420