akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string prev = s.substr(0,1);

  vector<map<string,int>> dp(s.size()+10);
  dp[1][s.substr(0,1)] = 1;
  dp[2][s.substr(0,2)] = 1;
  FOR(i,1,s.size()){
    for(auto x :dp[i]){
      if(s.substr(i,1) != x.first) dp[i+1][s.substr(i,1)] = max(x.second+1,dp[i+1][s.substr(i,1)]);
      if(i+1 < s.size() && s.substr(i,2) != x.first) dp[i+2][s.substr(i,2)] = max(x.second+1,dp[i+2][s.substr(i,2)]);
    }
  }
  int ans = 0;
  for(auto x : dp[s.size()]) ans = max(x.second, ans);
  for(auto x : dp[s.size()+1]) ans = max(x.second, ans);
  // rep(i,s.size()+2){
  //   cout << "------------------->" << i << endl;
  //   for(auto x: dp[i]){
  //     cout << x.first << ":" << x.second << endl;
  //   }
  //   cout << endl;
  // }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 53652
using System;

class C{
  public static void Main(){
    int N = int.Parse(Console.ReadLine());
    int c = 0;
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    for (int i = 0; i < N; i++){
      if (Ar[i] <= Ar[0]){
        c++;
        Ar[0] = Ar[i];
      }
    }
    Console.WriteLine(c);
  }
}


Measured memory_bytes: 33116
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define F first
#define S second
#define MP make_pair
int N, K;
int c[5000], r[5000];
bool flag[5000];
int flag2[5000];
vector<int> G[5000], G2[5000];
priority_queue<P, vector<P>, greater<P> > pq;
void bfs(int s)
{
	queue<P> que;
	que.push(MP(s, 0));
	memset(flag, 0, sizeof(flag));
	flag[s] = true;
	while(!que.empty())
	{
		P now = que.front();
		que.pop();
		if(now.S == r[s]) continue;
		for(int i = 0; i < G[now.F].size(); ++i)
		{
			if(!flag[G[now.F][i]])
			{
				flag[G[now.F][i]] = true;
				que.push(MP(G[now.F][i], now.S + 1));
				G2[s].push_back(G[now.F][i]);
			}
		}
	}
}
void dijkstra(int s)
{
	pq.push(MP(0, 0));
	while(!pq.empty())
	{
		P now = pq.top();
		pq.pop();
		for(int i = 0; i < G2[now.S].size(); ++i)
		{
			if(flag2[G2[now.S][i]] > now.F + c[now.S])
			{
				flag2[G2[now.S][i]] = now.F + c[now.S];	
				pq.push(MP(now.F + c[now.S], G2[now.S][i]));
			}
		}
	}
}
int main()
{
	cin >> N >> K;
	for(int i = 0; i < N; ++i)
		scanf("%d%d", c + i, r + i);
	for(int i = 0; i < K; ++i)
	{
		int in1, in2;
		scanf("%d%d", &in1, &in2);
		--in1; --in2;
		G[in1].push_back(in2);
		G[in2].push_back(in1);
	}
	fill(flag2 + 1, flag2 + N, INT_MAX);
	for(int i = 0; i < N; ++i)
		bfs(i);
	dijkstra(0);
	cout << flag2[N - 1] << endl;
}

Measured memory_bytes: 70808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func String(arr []int) string {
	return strings.Trim(fmt.Sprint(arr), "[]")
}

func Stringln(arr []int) string {
	text := strings.Trim(fmt.Sprint(arr), "[]")
	return strings.Replace(text, " ", "\n", -1)
}

func insertionSort(arr []int, len, g int) int {
	cnt := 0
	for i := g; i < len; i++ {
		v := arr[i]
		j := i - g
		for j >= 0 && arr[j] > v {
			arr[j+g] = arr[j]
			j -= g
			cnt++
		}
		arr[j+g] = v
	}
	return cnt
}

func shellSort(arr []int, l int) {
	var g []int
	for i := 1; i <= l; i = 3*i + 1 {
		g = append(g, 0)
		copy(g[1:], g[0:])
		g[0] = i
	}

	cnt := 0
	for _, e := range g {
		cnt += insertionSort(arr, l, e)
	}
	fmt.Println(len(g))
	fmt.Println(String(g))
	fmt.Println(cnt)
	fmt.Println(Stringln(arr))
}

func main() {
	n := scanInt()

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = scanInt()
	}

	shellSort(arr, n)
}



Measured memory_bytes: 74416
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 10100;
int n;
ll a[N];
vector<int> g[N];
ll ans[N];
int m;
bool used[N];

void dfs(int v) {
	used[v] = 1;
	ans[v] = a[m--];
	for (int u : g[v])
		if (!used[u])
			dfs(u);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	ll res = 0;
	for (int i = 0; i < n - 1; i++)
		res += a[i];
	printf("%lld\n", res);
	m = n - 1;
	dfs(0);
	for (int i = 0; i < n; i++)
		printf("%lld ", ans[i]);
	printf("\n");

	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  map<int, int> a;
  rep(i, n){
    int temp;
    cin >> temp;
    a[temp]++;
  }
  int ans = 0;
  for(auto x : a){
    int first = x.first, second = x.second;
    if(second > first)ans += second - first;
    else if(second < first) ans += second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		long X=stdIn.nextLong();
		long a=2;
		boolean key=false;
		while(true){
			for(;a<Math.sqrt(X);a+=2){
				if(X%a==0){
					key=true;
					break;
				}
				if(a==2)
					a--;
			}
			if(key==false){
				System.out.println(X);
				System.exit(0);
			}
			key=false;X++;a=2;
		}
	}
}


Measured memory_bytes: 23892
N, A, *x = map(int, open(0).read().split())
dp = [[[0]*(3000) for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*A+1):
            if j >= 1:
                dp[j][k][s] += dp[j-1][k][s]  # 選ばない場合
                if k >= 1 and s >= x[j-1]:
                    dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]  # 選ぶ場合
ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]
print(ans)

Measured memory_bytes: 112604
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

bool is_valid(int area){
  for(int x=1;2*x*x+2*x<=area;x++){
    if((area - x) % (2*x + 1) == 0) return true;
  }
  return false;
}

int main(){
  int n;
  while(~scanf("%d",&n)){
    int res = 0;
    for(int i=0;i<n;i++){
      int area;
      scanf("%d",&area);
      if(!is_valid(area)) res++;
    }
    printf("%d\n",res);
  }
}

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

using namespace std;

int main() {
    int x, tmp;
    cin >> x;

    tmp = 1;
    for (int i = 1; i <= x; ++i) {
        for (int j = 2; pow(i,j) <= x && j <= x; ++j) {
            tmp = max(tmp, (int)pow(i,j));
        }
    }

    cout << tmp << endl;

    return 0;
}

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

void show_list(std::vector<int> list) {
    for (int i = 0; i < list.size(); i++) {
        printf("%d", list.at(i));
        if (i != list.size() - 1) {
            printf(" ");
        }
    }
    printf("\n");
} 

int main(void) {
    using namespace std;

    int n;
    cin >> n;
    vector<int> a;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a.push_back(tmp);
    }

    show_list(a);

    for (int i = 1; i < n; i++) {
        int v = a.at(i);
        int j = i - 1;
        while (j >= 0 && a.at(j) > v) {
            a.at(j + 1) = a.at(j);
            j--; 
        }
        a.at(j + 1) = v;
        show_list(a);
    }
    return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

//拡張ユークリッドの互除法
//ax + by = cとなるようなc=gcd(a,b)をxをペアにして返す
//firstがx,secondがc
template <typename number>
pair<number, number> extended_euclid(number a, number b)
{
    number r0, r1, a0, a1, b0, b1;
    r0 = a; r1 = b;
    a0 = 1; a1 = 0;
    b0 = 0; b1 = 1;
    while (r1>0) {
        number q1 = r0 / r1;
        number r2 = r0 % r1;
        number a2 = a0 - q1 * a1;
        number b2 = b0 - q1 * b1;
        r0 = r1 ; r1 = r2;
        a0 = a1 ; a1 = a2;
        b0 = b1 ; b1 = b2;
    }
    number c = r0;
    a = a0; //x
    b = b0; //y
    return  {a, c};
}

//Nを法とした逆元を求める関数
template  <typename number>
number inverse_N(number a, number N)
{
    pair<number, number> result = extended_euclid(a, N);
    if(result.first < 0)
    {
        result.first = result.first + N;
    }
    return result.first;
}

//Nを法とした組み合わせを求める関数
template  <typename number>
number comb_N(number a, number b, number N)
{
  number af = 1;
  for (int i = a - b + 1; i <= a; ++i) {
    af = (af * i) % N;
  }
  number bf = 1;
  for (int i = 1; i <= b; ++i) {
    bf = (bf * i) % N;
  }
  bf = inverse_N(bf, N);
  af = (af * bf) % N;
  return af;
}

int main() {
  using lint = long long int;
  lint h, w, a, b;
  cin >> h >> w >> a >> b;
  lint mod = 1000000000 + 7;
  vector<lint> fact(h + w - 2 + 1);
  vector<lint> factI(h + w - 2 + 1);
  fact[0] = 1;
  factI[0] = inverse_N(1ll, mod);
  for(lint i = 1; i <= h + w - 2; i++)
  {
    fact[i] = (fact[i - 1] * i) % mod;
    factI[i] = inverse_N(fact[i], mod);
  }
  lint i = h - a - 1;
  lint result = 0;
  for(lint j = b; j <= w - 1; j++)
  {
    ///h - a - 1, iに行くまでの組み合わせ
    lint before = (((fact[i + j] * factI[i]) % mod) * factI[j]) % mod;
    lint i2 = h - 1 - (i + 1);
    lint j2 = w - 1 - j;
    lint after = (((fact[i2 + j2] * factI[i2]) % mod) * factI[j2]) % mod;
    result = (result + (before * after) % mod) % mod;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <limits>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)

template<typename Type>
class RMQ {
private:
	int size_; std::vector<Type> dat;
public:
	RMQ() : size_(0), dat(std::vector<Type>()) {};
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max() / 2);
	}
	template<class T>
	RMQ(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max() / 2);
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max() / 2;
		if (l >= r)return ret;
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

long long dp[200009], x[200009], E, N, T;

int main() {
	cin >> N >> E >> T;
	for (int i = 1; i <= N; i++) scanf("%lld", &x[i]);
	x[N + 1] = E;

	RMQ<long long>X1(N + 5), X3(N + 5);
	dp[1] = x[1]; X1.update(1, dp[1] - x[1]); X3.update(1, dp[1] - 3LL * x[1]);
	for (int i = 2; i <= N + 1; i++) {
		int pos1 = lower_bound(x, x + N + 2, x[i - 1] - (T / 2)) - x;
		long long P1 = X1.query(pos1, i); P1 += T; P1 += x[i - 1];
		long long P2 = X3.query(1, pos1); P2 += 3 * x[i - 1];
		dp[i] = min(P1, P2) + (x[i] - x[i - 1]);
		X1.update(i, dp[i] - x[i]);
		X3.update(i, dp[i] - 3LL * x[i]);
	}
	cout << dp[N + 1] << endl;
	return 0;
}

Measured memory_bytes: 6016
N = int(input())
h = list(map(int, input().split()))
dp = [0] * N

for i in range(N-1):
  if(i == 0):
    dp[i+1] = dp[i] + abs(h[i] - h[i+1])
  else:
    dp[i+1] = min(dp[i] + abs(h[i] - h[i+1]), dp[i-1] + abs(h[i-1] - h[i+1]))

print(dp[-1])


Measured memory_bytes: 13928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.next().trim();
        String b = in.next().trim();
        String c = in.next().trim();
        Solver solver = new Solver();
        solver.solve(a, b, c);
        System.out.println(output);
    }

}

class Solver {
    public void solve(String a, String b, String c) {
        String ans = "";
        char turn = 'a';
        int an = a.length();
        int bn = b.length();
        int cn = c.length();
        while (true) {
            if (turn == 'a') {
                if (an == 0) {
                    ans = "A";
                    break;
                }
                turn = a.charAt(a.length() - an);
                an--;
            }

            if (turn == 'b') {
                if (bn == 0) {
                    ans = "B";
                    break;
                }
                turn = b.charAt(b.length() - bn);
                bn--;
            }

            if (turn == 'c') {
                if (cn == 0) {
                    ans = "C";
                    break;
                }

                turn = c.charAt(c.length() - cn);
                cn--;
            }
        }
        Main.output.append(ans);
    }
}

Measured memory_bytes: 35740
class UnionFindNode(object):
    def __init__(self, u):
        self.p = u
        self.rank = 0
        self.size = 1


class UnionFind(object):
    def __init__(self, n):
        self.table = [UnionFindNode(i) for i in range(n)]

    def unite(self, u, v):
        self.link(self.find_set(u), self.find_set(v))

    def link(self, u, v):
        if self.table[u].rank > self.table[v].rank:
            self.table[v].p = u
            self.table[u].size += self.table[v].size
        else:
            self.table[u].p = v
            self.table[v].size += self.table[u].size
            if self.table[u].rank == self.table[v].rank:
                self.table[v].rank += 1

    def find_set(self, u):
        if self.table[u].p != u:
            self.table[u].p = self.find_set(self.table[u].p)
        return self.table[u].p

    def size(self, u):
        return self.table[self.find_set(u)].size


n, m = map(int, input().split())
edges = []
for i in range(m):
    ai, bi = map(int, input().split())
    edges.append((ai-1, bi-1))
edges.reverse()

ans = [n * (n - 1) / 2]
uf = UnionFind(n)
for i in range(m-1):
    ai, bi = edges[i]
    if uf.find_set(ai) == uf.find_set(bi):
        ans.append(ans[i])
    else:
        ans.append(ans[i] - uf.size(ai) * uf.size(bi))
        uf.unite(ai, bi)
ans = list(map(int, ans))
ans.reverse()

for x in ans:
    print(x)

Measured memory_bytes: 42060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split(" ");
    Integer n = Integer.parseInt(input[0]);
    Integer r = Integer.parseInt(input[1]);
    Integer x = 0;
    if(n < 10) {
      x = r + 100 * (10-n);
    } else {
      x = r;
    }
    System.out.println(x); 
  }
}




Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using graph = vector<vector<ll>>;
using vll = vector<ll>;
 
template <class type> void printVector(vector<type> vec){
    stringstream ss;
    for(ll i=0;i<vec.size();i++)
    {
        ss<<vec[i]<<" ";
        if(i!=vec.size()-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}
 
 
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

void solve(){
    ll A,B;
    cin>>A>>B;
    ll gcd=GCD(A,B);
    ll res=prime_factorize(gcd).size()+1;
    cout<<res;
}
 
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
  string s;
  cin>>s;
  int cnt=0;
  string a="CODEFESTIVAL2016";
  for(int i=0;i<(int)s.length();i++){
	   cnt+=(a[i]!=s[i]); 
	 }
	cout<<cnt<<endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


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




int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 string s; cin>>s;
 char d=s[s.size()-1];
 int n=s.size();
 ll count{}; 
 for(int i=n-1;i>=0;i--){
    if(s[i]!=d) {
      count++;
      d=s[i];
    }
 }
 cout<<count<<endl;
 return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <iomanip>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int N, sum=0;
  cin >> N;
  rep(i, N){
    if ((i+1) % 2 == 1)
      sum++;
  }
  cout << fixed << setprecision(10) << sum / (double)N << endl;;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
  l,r = map(int,input().split())
  L.append(l)
  R.append(r)
if min(R) - max(L) >= 0:
  print(min(R) - max(L) + 1)
else:
  print(0)

Measured memory_bytes: 16744
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
    }
    for a in 1..=1000_i64 {
        for b in -1000..=1000_i64 {
            if a.pow(5) - b.pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


Measured memory_bytes: 2164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int64_t X,t;
	cin >> X >> t;
	int64_t ans = X -t;
	if (ans<0){ans = 0;}
	printf("%ld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    ll n,cnt;
    cin >> n;
    cnt = n - 1;
    vector<ll> a(n),ans(n);
    rep0(i, n)cin >> a[i];
    rep0(k, n)rrep0(i, a.size()){
        if(a[i] == i + 1){
            ans[cnt] = a[i];
            --cnt;
            a.erase(a.begin() + i);
            break;
        }
    }
    if(!a.empty())pf(-1);
    else rep0(i, n)pf(ans[i]);
    return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())

x = []
y = []
for _ in range(n):
	x_dash,y_dash = map(int,input().split())
	x.append(x_dash)
	y.append(y_dash)

p = list(itertools.permutations(range(n)))

ans = 0
c = 0
for i in p:
	for j in range(1,n):
		ans += ( (x[i[j]]-x[i[j-1]])**2 + (y[i[j]]-y[i[j-1]])**2) **(0.5)
	c += 1

print(ans / c)


Measured memory_bytes: 8436
#include<iostream>
#include<vector>

using namespace std;

int c_i(char x){
    if(x=='S'){
        return 0;
    }
    if(x=='H'){
        return 1;
    }
    if(x=='C'){
        return 2;
    }
    if(x=='D'){
        return 3;
    }
}
char i_c(int a){
    if(a==0){
        return 'S';
    }
    if(a==1){
        return 'H';
    }
    if(a==2){
        return 'C';
    }
    if(a==3){
        return 'D';
    }
}


int main(){
    int n;
    cin >> n;
    vector<vector<bool>>trump(4,vector<bool>(13,true));
    for(int a=0;a<n;a++){
        char x;
        int y;
        cin >> x >> y;
        int p=c_i(x);
        trump.at(p).at(y-1)=false;
    }
    
    for(int a=0;a<4;a++){
        for(int b=0;b<13;b++){
            if(trump.at(a).at(b)){
                char x;
                x=i_c(a);
                cout << x << ' ' <<b+1 <<endl;
            }
            
        }
    }
    
    return 0;
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))

from fractions import gcd

l = [a[0]]
for i in range(1, n):
    l.append(gcd(l[i - 1], a[i]))
r = [a[n - 1]]
for i in range(1, n):
    r.append(gcd(r[i - 1], a[n - 1 - i]))
r.reverse()
from functools import reduce

print (reduce(lambda x,y:max(x,y),[gcd(l[i-1]if 0<i else r[i+1],r[i+1] if i<n-1 else l[i-1])for i in range(n)]))

Measured memory_bytes: 14080
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n,x;
	cin>>n>>x;
	ll arr[n];
	input(arr,n);
	ll ans=1,d=0;
	if(arr[0]<=x)ans++;
	for(ll i=1;i<n;i++)
{
	arr[i]+=arr[i-1];
	if(arr[i]<=x)ans++;
}
	cout<<ans;
}

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

int main(){
    int X, N; cin >> X >> N;
    vector<bool> exist(110, false);
    rep(i,N){
        int P; cin >> P;
        exist[P] = true;
    }

    int cur_min = 1000, ans = -1;
    rep(i,110){
        if(exist[i]) continue;

        if(cur_min > abs(X-i)){
            ans = i;
            cur_min = abs(X-i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
k,n=map(int,input().split())
a=list(map(int,input().split()))

ans=1e9
for i in range(n):
    if i==0:
        ans=min(ans,a[n-1]-a[0])
    else:
        ans=min(ans,k-a[i]+a[i-1])

print(ans)

Measured memory_bytes: 32372
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  ll s = a + b + c;
  std::cout << (s-max({a, b, c})==max({a, b, c})?"Yes":"No") << '\n';
  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong s, i;

	cin >> s;
	set<llong> a{s};
	for (i = 2;; ++i) {
		s = s % 2 == 0 ? s/2 : s*3+1;
		if (a.count(s))
			break;
		a.insert(s);
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
#a=list(map(int,input().split()))
d=[0]*(2*10**6+1)
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      d[i**2+j**2+k**2+i*j+i*k+j*k]+=1
for i in range(1,n+1):
  print(d[i])
  

Measured memory_bytes: 24740
'use strict'
function main(input) {
    const tmp1 = input.split('\n');
    const tmp2 = tmp1[0].split(' ');
    const N = parseInt(tmp2[0], 10);
    const X = parseInt(tmp2[1], 10);
    const L = tmp1[1].split(' ').map((l) => parseInt(l, 10));

    let D = [0];
    for (let i = 1; i <= N; i++) {
        D[i] = D[i - 1] + L[i - 1];
    }
    const DlowerThanX = D.filter((d) => d <= X);
    console.log(DlowerThanX.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
using namespace std;
int main(){
    int N,i,ans,cnt,m,tmp,k;
    cin>>N;
    for(i=1;i<=N;i=i+2){
       m=i;
       cnt=1;
       k=3;
       do{
            tmp=1;
            while(m%k==0){
                tmp++;m=m/k;
            }
            cnt*=tmp;
            k=k+2;
       }while(m>k-1);
      if(cnt==8){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	int ans=1,k,n;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		ans>k?ans+=k:ans+=ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n;cin>>n;
	vector<ll> P, p2idx;
	rep(i,n+2){
		p2idx.push_back(-1);
	}
	P.push_back(INF);
	reps(i,n){
		ll p;
		cin>>p;

		P.push_back(p);
		p2idx[p] = i;
	}
	P.push_back(INF);

	vector<vector<ll>> dp;
	rep(i,n+2){
		dp.push_back(vector<ll>());
		dp[i].push_back(max(0, i-2));
		dp[i].push_back(max(0, i-1));
		dp[i].push_back(min(n+1, (ll)i+1));
		dp[i].push_back(min(n+1, (ll)i+2));
	}

	reps(p, n){
		int i = p2idx[p];
		int now = i;
		while(P[now] <= P[i]){
			now = dp[now][1];
		}
		dp[i][1] = now;
		now = dp[now][1];
		while(P[now] <= P[i]){
			now = dp[now][1];
		}
		dp[i][0] = now;

		now = i;
		while(P[now] <= P[i]){
			now = dp[now][2];
		}
		dp[i][2] = now;
		now = dp[now][2];
		while(P[now] <= P[i]){
			now = dp[now][2];
		}
		dp[i][3] = now;
		/*reps(i,n){
		rep(j,4){
			cerr<<dp[i][j]<<" ";
		}
		cerr<<endl;
		}
		cerr<<endl;*/
	}

	ll ans = 0;

	reps(i,n){
		ans += P[i] * ((dp[i][1] - dp[i][0]) * (dp[i][2] - i) + (i - dp[i][1]) * (dp[i][3] - dp[i][2]));
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 9456
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int m=Integer.parseInt(line.split(" ")[1]);
int[] v=new int[m];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<m;i++) v[i]=Integer.parseInt(st.nextToken());
int[][] dp=new int[m+1][n+1];
Arrays.fill(dp[m],INF);
dp[m][0]=0;
for(int j=m-1;j>=0;j--){
for(int i=0;i<=n;i++){
if(i<v[j]) dp[j][i]=dp[j+1][i];
else dp[j][i]=Math.min(dp[j+1][i],dp[j][i-v[j]]+1);
}
}
out.println(dp[0][n]);
}
out.flush();
}
}

Measured memory_bytes: 25312
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double) a / b;
        System.out.printf("%d %d %f", d, r, f);
    }
}


Measured memory_bytes: 26452
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

void solve()
{
long long n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
int m=a[0];
long long s=0;
for(int i=1;i<n;i++)
{
	if(a[i]<m)	
	{
		s+=m-a[i];
	}
	else
		m=a[i];
}
cout<<s;
}
int main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
}	


Measured memory_bytes: 4440
N = int(input())
an = list(map(int,input().split(' ')))
cnt = 1
is_increased = True
is_init = True
for i in range(1,N):
    if is_init:
        if an[i] > an[i-1]:
            is_increased = True
        elif an[i] < an[i-1]:
            is_increased = False
        elif an[i] == an[i-1]:
            continue
        is_init = False
    else:
        if is_increased:
            if an[i] >= an[i-1]:
                continue
            else:
                is_init = True
                cnt +=1
        else:
            if an[i] <= an[i-1]:
                continue
            else:
                is_init = True
                cnt +=1
print(cnt)

Measured memory_bytes: 58536
#include <iostream>
#include <string>

using namespace std;

int WriteStar(int nodes)
{
    static auto next_node = 1;

    auto centre = next_node;
    next_node += 1;

    for (int i = 2; i <= nodes; i += 1) {
        cout << centre << " " << next_node << "\n";
        next_node += 1;
    }
    return centre;
}

int main()
{
    string str;
    getline(cin, str);

    auto good = (str[0] == '1' && str.back() == '0');
    for (size_t i = 0; i < str.size() / 2 && good; i += 1) {
        good = (str[i] == str[str.size() - i - 2]);
    }

    if (!good) {
        cout << "-1\n";
        return 0;
    }

    int nodes_left = str.size();
    auto last_centre = -1;

    for (size_t i = 1; i < str.size() / 2; i += 1) {
        if (str[i] == '1') {
            auto nodes_needed = i + 1 - (str.size() - nodes_left);
            auto new_centre = WriteStar(nodes_needed);

            if (last_centre != -1) {
                cout << last_centre << " " << new_centre << "\n";
            }
            last_centre = new_centre;
            nodes_left -= nodes_needed;
        }
    }

    auto new_centre = WriteStar(nodes_left);
    if (last_centre != -1) {
        cout << last_centre << " " << new_centre << "\n";
    }

    return 0;
}


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

#define INF 1000000000000


int main()
{
	int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<c-(d-b)<<' '<<d+c-a<<' '<<a-(d-b)<<' '<<b+c-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int N; cin >> N;
    vl L(N);
    rep(i, N) {
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (L[i] == L[j]) continue;
            for (int k = j + 1; k < N; k++) {
                if (L[i] == L[k]) continue;
                if (L[j] == L[k]) continue;

                if (L[i] + L[j] > L[k]) cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

//nを3桁の数字にしてchar配列に入れる
//空き桁は0でパディングする
void assign_pat(char *c, int n);

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

  //暗証番号の候補
  char pat[4];
  int i, j;
  int count = 0;
  //000〜999の暗証番号を総当たりで調べる
  for(i=0; i<=999; i++){
    assign_pat(pat, i);
    j = 0;
    //暗証番号0桁目がSと一致する最小の添字j
    while(pat[0]!=S[j++] && j<N);
    //暗証番号1桁目がSと一致する最小の添字j
    while(pat[1]!=S[j++] && j<N);
    //暗証番号2桁目がSと一致する最小の添字j
    while(pat[2]!=S[j++] && j<N);
    //ループを抜けたら必ずj==Nとなっているため，
    //N-1文字目と一致しているかどうかで条件を確かめられる
    if(pat[2] == S[j-1])
      count++;
  }

  cout << count << endl;

  return 0;
}


void assign_pat(char *c, int n){
  c[0] = '0' + (n/100);
  n %= 100;
  c[1] = '0' + (n/10);
  n %= 10;
  c[2] = '0' + n;
  c[3] = '\0';
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

int n, m, k;
bool vis[1000100];

int main(){
	scanf("%d%d%d", &n, &m, &k);
	For(i, 0, n)  For(j, 0, m) vis[i * m + (n - 2 * i) * j] = true;
	puts(vis[k] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1280
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

vi ans[1000];
int main()
{
	fast();
	int j,n,x,i,d=1e6;
	cin>>x>>n;
	int z;
	umap<int,int> m;
	rep(i,n)
	{
		cin>>z;
		m[z]++;
	}
	i=x;j=x;
	while(true)
	{
		if(m[i]==0)
		{
			cout<<i;
			exit(0);
		}
		if(m[j]==0)
		{
			cout<<j;
			exit(0);
		}
		i--;j++;
	}
}

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

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

int main(){
  int a,b;
  cin >> a >> b;
  int x = a/b;
  int y = a%b;
  double z = double(a)/double(b);
  cout << fixed;
  cout << setprecision(5);
  cout  << x << ' ' << y << ' ' << z << endl;
}



Measured memory_bytes: 3284
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy";
	if (s == "Rainy") cout << "Sunny";
	if (s == "Cloudy") cout << "Rainy";
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b ] <- readInts
	print $ max 0 $ a - 2 * b

Measured memory_bytes: 380
#include<iostream>
using namespace std;
int main(){
int a,b;
char op;
while(1){
cin >> a >> op >> b;
if(op=='?')break;
if(op=='+') cout << a+b <<endl;
if(op=='-') cout << a-b <<endl;
if(op=='*') cout << a*b <<endl;
if(op=='/') cout << a/b <<endl;
}
return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <string>

using namespace std;


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

    string sa = "";
    string sb = "";

    for(int i=0; i<b; i++){
        sa += to_string(a);
    }

    for(int i=0; i<a; i++){
        sb += to_string(b);
    }

    if(sa >= sb) cout << sb;
    else cout << sa;

    return 0;
}

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

int N;
int S[101];
bool T[101][10010] = {{0}};
vector<int> v;
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> S[i];
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=10000;j++){
			T[i][j] = false;
		}
	}
	T[0][0] = true;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=10000-S[i];j++){
			T[i][j] = (T[i-1][j] | T[i][j]);
			T[i][j+S[i]] = (T[i-1][j] | T[i][j+S[i]]);
		}
	}
	for(int i=10000;i>0;i--){
		if(T[N][i] && i%10!=0 && i!=0){
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 1280
#include <iostream>

int main(){
  int N;
  int a,b,c;
  std::cin >> N;

  if(N>100){
    a = N % 100;
    b = a % 10;
    if(b==3){
      std::cout << "bon" << std::endl;
    }else if(b==0||b==1||b==6||b==8){
      std::cout << "pon" << std::endl;
    }else{
      std::cout << "hon" << std::endl;
    }
  }else if(N>10){
    c = N % 10;
    if (c==3){
      std::cout << "bon" << std::endl;
    }else if(c==0||c==1||c==6||c==8){
      std::cout << "pon" << std::endl;
    }else{
      std::cout << "hon" << std::endl;
    }
  }else{
    if(N==3){
      std::cout << "bon" << std::endl;
    }else if(N==0||N==1||N==6||N==8){
      std::cout << "pon" << std::endl;
    }else{
      std::cout << "hon" << std::endl;
    }

  }

}


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

#define ll long long
#define UN unsigned
#define pb push_back
#define mod 1000000007
#define mt make_tuple
typedef tuple<int, int> tii;
typedef pair<int, int> pii;

void solve(){
    int n;
    cin >> n;

    vector<int> a(n);
    for(auto& x: a)
        cin >> x;
    
    int dp[100005];
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout << dp[n-1];
}

int main(void){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y){
	return x/gcd(x, y)*y;
}
int main()
{
	int n;
	ll m;
	cin>>n>>m;
	ll a[100010];
	int e[100010]={};
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i]/=2;
	}
	for(int i=0; i<n; i++){
		while(a[i]%2==0){
			a[i]/=2;
			e[i]++;
		}
	}
	for(int i=1; i<n; i++){
		if(e[i]!=e[i-1]){
			cout<<0<<endl;
			return 0;
		}
	}
	ll l=1;
	for(int i=0; i<n; i++){
		l=lcm(l, a[i]);
		if(l>m){
			cout<<0<<endl;
			return 0;
		}
	}
	ll ans=m/((1ll<<e[0])*l)-m/((1ll<<(e[0]+1))*l);
	cout<<ans<<endl;
	return 0;
}

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

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

    map<string, int> S;
    for (size_t i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        S[s]++;
    }

    int max = 0;
    for (auto i : S)
    {
        if (i.second > max)
        {
            max = i.second;
        }
    }

    for (auto i : S)
    {
        if (i.second == max)
        {
            cout << i.first << endl;
        }
    }
}


Measured memory_bytes: 25216
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int i,j,num,*arr,min,temp,count = 0;
	scanf("%d",&num);
	arr = (int *)malloc(sizeof(int) * num);
	for(i=0;i<num;i++)scanf("%d",&arr[i]);
	for(i=0;i<num;i++){
		min = i;
		for(j=i;j<num;j++){
		if(arr[j] < arr[min]) min = j;
		}
	if(arr[i] != arr[min]){
	temp = arr[i];
	arr[i] = arr[min];
	arr[min] = temp;
	count++;
	}
	}
	for(i=0;i<num;i++) i != num-1 ? printf("%d ",arr[i]) : printf("%d\n",arr[i]);
	printf("%d\n",count);
	free(arr);
	return  0;
	}	

Measured memory_bytes: 600
n = gets.to_i
ary =gets.chomp.split(' ').map(&:to_i)

def mergesort(a,b)
    i=0
    j=0
    new_ary = []
    flag = true
    while flag
        if(i<a.size)&&(j>=b.size||a[i]<=b[j])
            new_ary << a[i]
            i+=1
        elsif(j<b.size)&&(i>=a.size||b[j]<a[i])
            new_ary << b[j]
            j+=1
        else
            flag = false
        end
    end
    return new_ary
end
def merge(a)
    if a.size==1
        return a
    end
    ary1 = merge(a[0...(a.size/2)])
    ary2 = merge(a[(a.size/2)..-1])
    return mergesort(ary1,ary2)
end

ary = merge(ary)
ans = "YES"
(ary.size-1).times do |a|
    if ary[a]==ary[a+1]
        ans = "NO"
        break
    end
end

puts ans

Measured memory_bytes: 30344
n = int(input())
p = list(map(int, input().split()))
a = list(range(20000, (n + 1) * 20000, 20000))
b = a[::-1]
for i in range(len(p)):
	a[p[i] - 1] -= n - i - 1
print(*a)
print(*b)

Measured memory_bytes: 76324