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

using namespace std;

typedef long long ll;
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int N;
ll X;

ll dfs(ll x, int n) {
    if(x < n) return 0;
    if(n == 0) return 1;
    ll m = pow(2, n+2)-3;
    if(x > m-n) return pow(2, n+1) - 1;
    if(x < m/2) return dfs(x-1, n-1);
    else if(x > m/2) return pow(2, n) + dfs(x-m/2-1, n-1);
    else return pow(2, n);
}

int main() {
    cin >> N >> X;
    cout << dfs(X-1, N) << endl;
}


Measured memory_bytes: 256
from collections import deque
N=int(input())
d=deque()
d.append("a")
dall=deque()
dall.append(d)
i=0
while i<N-1:
    length=len(dall)
    j=0
    while j<length:
        l=dall.popleft()
        llen=len(set(l))
        for k in range(llen+1):
            q = deque()
            for m in range(len(l)):
                c = l.popleft()
                q.append(c)
                l.append(c)
            q.append(chr(ord("a")+k))
            dall.append(q)
        #print(dall)
        #input()
        j=j+1
    i=i+1
    #print(dall)
    #input()
#print(len(dall))
ans=[]
for i in range(len(dall)):
    print("".join(dall[i]))

Measured memory_bytes: 148952
let N = Int(readLine()!)!
if N < 105 {
  	print(0)
} else {
  	var ans = 1
    for i in 107.stride(to: N+1, by: 2) {
        var cnt = 0
        for j in 3.stride(to: i, by: 2) {
            if i % j == 0 {
                cnt += 1
            }
        }
        if cnt == 6 {
            ans += 1
        }
    }
  	print(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing


int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	if(k % 2 == 0 && n >= k / 2) {
		ll x = (n - k / 2) / k + 1;
		ans += x * x * x;
	}
	ans += (n / k) * (n / k) * (n / k);
	cout << ans;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D = map(int, input().split())

        def gcd(a, b):
            while b:
                a, b = b, a % b
            return a

        def lcm(a, b):
            return a * b // gcd(a, b)

        def f(x):
            return x - (x // C + x // D - x // lcm(C, D))

        print(f(B) - f(A - 1))


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int ans = 0;

    for(int i = 1; i <= N; i++){
        int tmp = i, digit = 0;
        while(tmp > 0){
            tmp /= 10;
            digit++;
        }

        if(digit%2) ans++;
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>


// @author: pashka

const long long INF = (const long long int) 1e18;
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m), c(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    vector<long long> d(n);
    for (int i = 0; i < n; i++) {
        d[i] = -INF;
    }
    d[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            d[b[j]] = min(max(d[b[j]], d[a[j]] + c[j]), INF);
        }
    }
    for (int j = 0; j < m; j++) {
        if (d[b[j]] < d[a[j]] + c[j]) {
            d[b[j]] = INF;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            d[b[j]] = min(max(d[b[j]], d[a[j]] + c[j]), INF);
        }
    }

    if (d[n - 1] == INF) {
        cout << "inf" << endl;
    } else {
        cout << d[n - 1] << endl;
    };
    return 0;
}



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

int n, m, x, y, a;
std::vector<int> vecx, vecy;

int main() {
    std::cin >> n >> m >> x >> y;
    for (int i = 0; i < n; i++) {
        std::cin >> a;
        vecx.push_back(a);
    }
    for (int i = 0; i < m; i++) {
        std::cin >> a;
        vecy.push_back(a);
    }
    int x_max = *std::max_element(vecx.begin(), vecx.end());
    int y_min = *std::min_element(vecy.begin(), vecy.end());
    if (y_min - x_max >= 1 && x_max > x && y_min <= y) {
        std::cout << "No War" << std::endl;
    }
    else {
        std::cout << "War" << std::endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int s[100000], t[50000];
int main() {
	int n, q, i, j, count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &s[i]);
	std::sort(s, s + n);
	scanf("%d", &q);
	for (i = 0; i < q; i++)scanf("%d", &t[i]);
	std::sort(t, t + q);
	i = 0;
	j = 0;
	while (i < n&&j < q) {
		if (s[i] == t[j]) {
			count++;
			i++;
			j++;
		}
		else if (s[i] > t[j]) j++;
		else i++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 3136
n = int(input())
s_dict = {}
for i in range(n):
  add_dict = {}
  a = int(input())
  for j in range(a):
    b = list(map(int, input().split()))
    add_dict[b[0]-1] = b[1]
  s_dict[i] = add_dict
max_num = 0

def rec_get_list(i, tmp_num_list, tmp_honest, tmp_unkind):
  add_dict = s_dict[i]
  tmp_num_list.add(i)
  tmp_honest.add(i)
  for k, v in add_dict.items():
      if v:
        if k not in tmp_num_list:
        	tmp_num_list, tmp_honest, tmp_unkind = rec_get_list(k, tmp_num_list, tmp_honest, tmp_unkind)
        tmp_honest.add(k)
      else:
        tmp_unkind.add(k)
  return tmp_num_list, tmp_honest, tmp_unkind

def rec_check(i, tmp_num_list, tmp_honest, tmp_unkind):
  global max_num
  global n
  for j in range(i, n):
    if j in tmp_num_list:
      continue
    use_num_list = tmp_num_list.copy()
    use_honest = tmp_honest.copy()
    use_unkind = tmp_unkind.copy()
    use_num_list, use_honest, use_unkind = rec_get_list(j, use_num_list, use_honest, use_unkind)
    check_flg = len(use_honest & use_unkind)
    if check_flg:
      continue
    else:
      if len(use_num_list) > max_num:
        max_num = len(use_num_list)
    if j+1 < n:
      rec_check(j+1, use_num_list, use_honest, use_unkind)
  
rec_check(0, set(), set(), set()) 
    
print(max_num)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;
typedef complex<double> P;

int main() {
	int s, t;
	P p(0.0, 0.0);
	P o(0.0, 1.0);
	while(scanf("%d,%d", &s, &t), s|t) {
		p = p + o * (double)s;
		double theta = -M_PI * t / 180.0;
		o = o * P(cos(theta), sin(theta));
	}
	printf("%d\n%d\n", (int)p.real(), (int)p.imag());
}

Measured memory_bytes: 1196
a = input()
N = int(a)
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
flag = 0

for i in range(1,N-1):
    if (x[i-1] == y[i-1]) and (x[i] == y[i]) and (x[i+1] == y[i+1]):
        flag = 1
        break
if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s;
  cin >> s;
  int a=(s[0]-'0')*10+s[1]-'0';
  int b=(s[2]-'0')*10+s[3]-'0';
  if(1<=a&&a<=12&&1<=b&&b<=12){
    cout << "AMBIGUOUS" << endl;
    return 0;
  }
  else if(1<=a&&a<=12){
    cout << "MMYY" << endl;
  }
  else if(1<=b&&b<=12){
    cout << "YYMM" << endl;
  }
  else{
    cout << "NA" << endl;
  }
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int gcd(int x,int y){
  if(y==0)return x;
  if(x<=y) swap(x,y);
  if(x%y==0) return y;
  else return(gcd(y,x%y));//最大公約数
}

int main(){
    int n,X;
    cin >> n >> X;
    int ans = 0;
    REP(i,n){
        int x;
        cin >> x;
        ans = gcd(abs(X-x),ans);
    }
    cout << ans << endl;
    return 0;
}    

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i, k, len_s, count[200], c, len_p, x;
  char s[200], p[200];
  fgets(s, sizeof(s), stdin);
  len_s = strlen(s)-1;
  fgets(p, len_s+1, stdin);
  len_p = strlen(p)-1;
  for(i=0;i<len_s;i++){
    c=0;
    for(k=0;k<len_p;k++){
      x = i+k;
      if(x>=len_s){
        x -= len_s;
      }
      if(p[k] == s[x]){
        c++;
      }
      if(c!=0 && p[k]!=s[x]){
        c = 0;
      }
    }
    if(c==len_p){
      printf("Yes\n");
      break;
    }
    if(i==len_s-1){
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,m,A[200001];
    cin>>n>>m;
    rep(i,m) cin>>A[i];
    ll sum=0;
    rep(i,m) sum+=A[i];
    if(sum>n) cout<<-1;
    else cout<<n-sum;
}



Measured memory_bytes: 3636
list = input().split()

stack = []

for i in range(len(list)):
        if list[i].isdigit():
                stack.append(int(list[i]))
        else:
                if list[i] == "+":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b + a))
                elif list[i] == "-":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b - a))
                elif list[i] == "*":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b * a))

print(stack[0])


Measured memory_bytes: 5604
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
v = []
t = []

for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    v.append(a)
    ti = 0
    
    for i in range(b):
        ti += 1<<(c[i]-1)
    
    t.append(ti)

dp = [10**18]*(1<<N)
dp[0] = 0

for S in range(1<<N):
    for i in range(M):
        dp[S|t[i]] = min(dp[S|t[i]], dp[S]+v[i])

if dp[-1]==10**18:
    print(-1)
else:
    print(dp[-1])

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  if(N&1){
    OUT(0);
    return 0;
  }

  ll ans = 0;
  ll tmp = 10;
  while(tmp<=N){
    ans += N/tmp;
    tmp *= 5;
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main(void)
{
  char str[256];
  int length;
  int i;
 
  fgets(str, 256, stdin);
  length = (int)strlen(str);
  for (i = 0; i < length; i++) {
    if ( isalpha(str[i]) && islower(str[i]) ) {
      str[i] = toupper(str[i]);
    }
  }
  printf("%s", str);
 
  return 0;
}

Measured memory_bytes: 524
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func attack(H int) int {
	if H == 1 {
		return 1
	}
	return attack(H/2)*2 + 1
}

func main() {
	sc.Split(bufio.ScanWords)

	H := getInt()

	ans := attack(H)

	out(ans)
}


Measured memory_bytes: 640
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int a,b;cin>>a>>b;
  for(int i=1;i<=3;++i) {
    if(a!=i&&b!=i) {
      p(i);
      return 0;
    }
  }
}



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

int main() {
    int n; string s; cin >> n >> s;
    if(n % 2 != 0) {
        cout << "No" << endl;
    } else {
        cout << (s.substr(0, n / 2) == s.substr(n / 2) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    ll N; cin >> N;
    ll x[100000][3];
    rep(i,N)cin >> x[i][0] >> x[i][1] >> x[i][2];
    ll dp[100000][3];
    rep(i,100000){rep(j,3){ dp[i][j] = -INF;}}
    rep(i,N){
        rep(j,3){
            if (i>0){
                rep(k,3){
                    if (k==j) continue;
                    chmax(dp[i][j],dp[i-1][k]+x[i][j]);
                }
            }else{
                chmax(dp[i][j], x[i][j]);
            }
        }
    }

ll res = -INF;
rep(i,3) chmax(res, dp[N-1][i]);
cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N, K, Q;
    cin >> N >> K >> Q;
    long long cnt[N] = {0};
    long long Ai;
    for(int i = 0; i < Q; i++){
        cin >> Ai;
        cnt[Ai-1]++;
    }
    for(int i = 0; i < N; i++){
        if(K - Q + cnt[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
s = input()
n = len(s)
num = 0
for i in range(1 << n):
    if i % 2 == 0:
        continue
    pre = 0
    tmp = []
    for j in range(n):
        if i & 1 << j:
            if len(s[pre:j]) != 0:
                tmp.append(int(s[pre:j]))
            pre = j
    tmp.append(int(s[pre:]))
    num += sum(tmp)

print(num)



Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<unordered_map<int, int>> edges(N);
    vector<unordered_set<int>> reverse_edges(N);
    loop(i, M){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        scanInt(ci);
        edges[ai].emplace(bi, -ci);
        reverse_edges[bi].emplace(ai);
    }
    {
        unordered_set<int> reachable;
        reachable.emplace(N - 1);
        queue<int> q;
        q.emplace(N - 1);
        while (!q.empty()){
            int node = q.front();
            q.pop();
            for (auto& next : reverse_edges[node]){
                if (reachable.count(next) == 0){
                    reachable.emplace(next);
                    q.emplace(next);
                }
            }
        }
        loop(i, N){
            if (reachable.count(i)){
                for (auto& e : edges[i]){
                    if (reachable.count(e.first) == 0){
                        edges[i].erase(e.first);
                    }
                }
            }else{
                edges[i].clear();
            }
        }
        reverse_edges.clear();
    }
    vector<ll> scores(N, LLONG_MAX);
    scores[0] = 0;
    loop(i, N - 1){
        loop(node, N){
            for (auto& e : edges[node]){
                if (scores[node] != LLONG_MAX){
                    scores[e.first] = min(scores[e.first], scores[node] + e.second);
                }
            }
        }
    }
    ll result = -scores[N - 1];
    vector<char> negative_looped(N, false);
    loop(i, N){
        loop(node, N){
            for (auto& e : edges[node]){
                if (scores[node] != LLONG_MAX){
                    ll score = scores[node] + e.second;
                    if (score < scores[e.first]){
                        negative_looped[e.first] = true;
                        scores[e.first] = score;
                    }
                    if (negative_looped[node]){
                        negative_looped[e.first] = true;
                    }
                }
            }
        }
    }
    if (negative_looped[N - 1]){
        puts("inf");
    }else{
        printf("%lld\n", result);
    }
}


Measured memory_bytes: 640
// I cannot use C++14 :(
 
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } else return false; }
  
main {
  int d,e;
  while(cin>>d>>e,d) {
    double c=1000000000;
    rep(i,d+1){
      int x=i,y=d-i;
      cmin(c,abs(sqrt(x*x+y*y)-e));
     }
    cout<<prec(32)<<c<<endl;
  }
  bye;
}

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

int ans[20010][2] = {};

void calc(){
	
	for( int i=1 ; i<=20000 ; i++ ){
		ans[i][0] += ans[i-1][0] ;
		ans[i][1] += ans[i-1][1] ;
		
		int tmp = i;
		while( tmp>0 ){
			if( !(tmp%5) ){
				ans[i][0]++;
				tmp /= 5;
			}
			else if( !(tmp%2) ){
				ans[i][1]++;
				tmp /= 2;
			}
			else break;
		}
	}
	
}

int main(){
	
	calc();
	
	int N;
	while( cin >> N , N ){
		cout << min(ans[N][0],ans[N][1]) << endl ;
	}
	
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int dp[2222][2222];
int Max[2222], A[6666];
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; ++i) cin >> A[i], A[i]--;
  for (int i = 0; i < 2222; ++i)
    for (int j = 0; j < 2222; ++j) dp[i][j] = -1e9;
  for (int i = 0; i < 2222; ++i) Max[i] = -1e9;
  dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0;
  Max[A[0]] = Max[A[1]] = 0;
  int tot = 0;
  struct P {
    int x, y, v;
    P(int a = 0, int b = 0, int c = 0) : x(a), y(b), v(c) {}
  };
  for (int i = 2; i + 2 < n * 3; i += 3) {
    if (A[i] == A[i + 1] && A[i + 1] == A[i + 2]) {
      tot++;
      continue;
    }
    vector<P> upd;
    int cMax = -1e9;
    for (int j = 0; j < n; ++j) cMax = max(cMax, Max[j]);
    upd.emplace_back(A[i], A[i + 1], cMax);
    upd.emplace_back(A[i], A[i + 2], cMax);
    upd.emplace_back(A[i + 2], A[i + 1], cMax);
    for (int j = 0; j < n; ++j) upd.emplace_back(A[i], j, Max[j]);
    for (int j = 0; j < n; ++j) upd.emplace_back(A[i + 1], j, Max[j]);
    for (int j = 0; j < n; ++j) upd.emplace_back(A[i + 2], j, Max[j]);
    upd.emplace_back(A[i + 1], A[i + 2], dp[A[i]][A[i]] + 1);
    upd.emplace_back(A[i], A[i + 2], dp[A[i + 1]][A[i + 1]] + 1);
    upd.emplace_back(A[i + 1], A[i], dp[A[i + 2]][A[i + 2]] + 1);
    if (A[i] == A[i + 1] || A[i] == A[i + 2] || A[i + 1] == A[i + 2]) {
      if (A[i] == A[i + 2])
        swap(A[i + 1], A[i + 2]);
      else if (A[i + 1] == A[i + 2])
        swap(A[i], A[i + 2]);
      assert(A[i] == A[i + 1]);
      for (int j = 0; j < n; ++j) upd.emplace_back(j, A[i + 2], dp[A[i]][j] + 1);
    }
    for (auto j : upd) {
      dp[j.x][j.y] = max(dp[j.x][j.y], j.v);
      dp[j.y][j.x] = max(dp[j.y][j.x], j.v);
      Max[j.y] = max(Max[j.y], j.v);
      Max[j.x] = max(Max[j.x], j.v);
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j && i == A[3 * n - 1])
        res = max(res, dp[i][j] + 1);
      else
        res = max(res, dp[i][j]);
    }
  }
  cout << res+tot;
  return 0;
}
//2020.08.22 23:18:22


Measured memory_bytes: 23084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

vector<int> G[MX];
int N;

int dfs(int x, int p = -1){
	int cnt = 0;
	for(int c : G[x]){
		if( c == p ) continue;
		cnt += dfs(c, x);
	}
	if( p == -1 && cnt == 0 ) return 2;
	if( cnt == 0 ) return 1;
	else if( cnt == 1 ) return 0;
	else return 2;
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if( dfs(1) >= 2 ) printf("First\n");
	else printf("Second\n");
}


Measured memory_bytes: 5888
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n;
int a[3010];

int cache[3010][3010];

int dp(int l, int r, int cur){
    if(l>r) return 0;
    int &ans=cache[l][r];
    if(ans!=-1) return ans;
    if(cur==0){
        ans=max(dp(l+1,r,cur^1)+a[l],dp(l,r-1,cur^1)+a[r]);
    }
    else{
        ans=min(dp(l+1,r,cur^1)-a[l],dp(l,r-1,cur^1)-a[r]);
    }
    return ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    rep(i,1,n+1) cin >> a[i];
    mst(cache,-1);
    int res=dp(1,n,0);
    cout << res;
    return 0;
}

Measured memory_bytes: 71168
#include <stdio.h>

int main(int argc, char *argv[])
{
    long long v = 1;
    int i, N;
    scanf("%d", &N);
    for ( i = 1; i <= N; i++ ){
        v *= i;
        v %= 1000000007LL;
    }
    printf("%lld\n", v);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
const int MAX_V = 10000;
int prime[MAX_V+1];
int main() {
  int i, k, v;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }

  while(scanf("%d", &v) != EOF) {
    if(v == 0){
      break;
    }
    while(1){
      if(prime[v] == 0 || prime[v - 2] == 0){
        v--;
      }else{
        printf("%d %d\n", v - 2, v);
        break;
      }
    }
  }
  return 0;
}

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

int c[1500];
int d[1500];
int main() {
	int a, b;
	while (scanf("%d%d", &a, &b),a | b) {
		unordered_map<int, int>e;
		unordered_map<int, int>f;
		memset(c, 0, a * 4);
		memset(d, 0, b * 4);
		for (int g = 0; g < a; g++) {
			int h;
			scanf("%d", &h);
			for (int i = 0; i <= g; i++) {
				c[i] += h;
				e[c[i]]++;
			}
		}
		for (int g = 0; g < b; g++) {
			int h;
			scanf("%d", &h);
			for (int i = 0; i <= g; i++) {
				d[i] += h;
				f[d[i]]++;
			}
		}
		int s = 0;
		for (auto k = e.begin(); k != e.end(); k++) {
			s += f[k->first] * k->second;
		}
		printf("%d\n", s);
	}
}

Measured memory_bytes: 32000
n=gets.strip.to_i
a = gets.strip.split.map(&:to_i)

sorted = a.sort
grouped = sorted.group_by {|x| x }
counted = grouped.map {|_,v| v.count }


if n.odd? && counted.shift!=1
  p 0
  exit
end

if n==1 && counted.empty?
  p 1
  exit
end

if counted.uniq!=[2]
  p 0
  exit
end

div=10**9+7

result = 1
(n/2).floor.times do |num|
  result = result*2%div
end

p result



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

namespace _1027_biginner_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputNum = int.Parse(Console.ReadLine());
            bool flg = false;

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    int result = i * j;
                    if(inputNum == result)
                    {
                        flg = true;
                        break;
                    }
                }

                if (flg)
                {
                    break;
                }
                
            }

            if(flg)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;

int minprice(string name, map<string,vector<string> > recipes, map<string,int> price){
	int p = price[name];
	map<string,vector<string> >::iterator recipe;
	if((recipe = recipes.find(name)) != recipes.end()){
		int tmp = 0;
		vector<string> materials = recipe->second;
		for(vector<string>::iterator material = materials.begin(); material != materials.end(); ++material){
			tmp += minprice(*material, recipes, price);
		}
		if(p > tmp){
			p = tmp;
		}
	}
	return p;
}

int main(){
	int n;
	cin >> n;
	while(n != 0){
		map<string,int> items;
		for(int i = 0; i < n; ++i){
			string name;
			int price;
			cin >> name >> price;
			items[name] = price;
		}
		int m;
		cin >> m;
		map<string,vector<string> > recipes;
		for(int i = 0; i < m; ++i){
			string name;
			int k;
			cin >> name >> k;
			for(int j = 0; j < k; ++j){
				string material;
				cin >> material;
				recipes[name].push_back(material);
			}
		}
		string item;
		cin >> item;
		cout << minprice(item, recipes, items) << endl;
		cin >> n;
	}
}

Measured memory_bytes: 1260
n=input()
N=int(n)
L=input().split()

A=[int(L[i]) for i in range(N)]

#for i in range(N):#入力をそのまま返す
#    if i<N-1:
#        print(A[i],end=" ")
#    else:
#        print(A[i])

for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]#==になってた
        j=j-1
    A[j+1]=v

    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        else:
            print(A[k])



Measured memory_bytes: 5980
if __name__ == '__main__':
    N = int(input())
    arms = []
    for _ in range(N):
        x, l = map(int, input().split())
        arms.append([x + l, x - l])

    arms.sort()

    ans = 0

    for idx, (e, s) in enumerate(arms):
        if idx == 0:
            pos = e
            ans += 1
        else:
            if pos <= s:
                ans += 1
                pos = e
    print(ans)


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

int main(){
	long long int L,R;	cin>>L>>R;
	int ans=2019;
	int l,r;
	if(R-L+1>=2019)cout<<0<<endl;
	else{
		for(int i=L;i<R;i++){
			for(int j=i+1;j<=R;j++){
				l=i%2019;
				r=j%2019;
				ans=min(ans, (l*r)%2019);
			}
		}
		cout<<ans<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)

    var answerN int = n
    var answerCnt int = 0
    for i := 1; i <= n; i++ {
        var val = i
        var cnt = 0
        for val%2 == 0 {
            cnt = cnt + 1
            val = val / 2
        }
        if answerCnt < cnt {
            answerN = i
            answerCnt = cnt
        }
    }

    fmt.Println(answerN)
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
  int k,t,array[100],i,frag=1,temp,ans=0;
  scanf("%d %d",&k,&t);
  for(i=0;i<t;i++)
    {
      scanf("%d",&array[i]);
    }
  while(frag == 1)
    {
      frag = 0;
      for(i=0;i<t-1;i++)
	{
	  if(array[i] < array[i+1])
	    {
	      temp = array[i];
	      array[i] = array[i+1];
	      array[i+1] = temp;
	      frag = 1;
	    }
	}
    }
  ans = array[0];
  for(i=1;i<t;i++)
    {
      if(ans < array[i])
	{
	  ans = array[i] - ans;
	}
      else
	{
	  ans -= array[i];
	}
    }
  if(ans > 0)
    {
      ans--;
    }
  else
    {
      ans = 0;
    }
  printf("%d\n",ans);
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string S;

int a[6];

signed main(){
    cin>>S;

    int cur=0;
    while(cur<S.size()){
        bool m=false;
        if(S[cur]=='-')m=true;

        int v=0;
        if(S[cur]=='+'||S[cur]=='-')cur++;
        if(!isdigit(S[cur]))v=1;
        while(cur<S.size()&&isdigit(S[cur])){
            v=v*10+S[cur]-'0';
            cur++;
        }
        if(m)v*=-1;
        if(cur==S.size()){
            a[0]=v;
            continue;
        }
        int t;
        cur++;
        if(cur!=S.size()&&S[cur]=='^'){
            cur++;
            t=S[cur]-'0';
            cur++;
        }
        else t=1;
        a[t]=v;
    }

    vint lis;
    for(int i=-2222;i<=2222;i++){
        int d=1;
        int v=0;
        for(int j=0;j<=5;j++){
            v+=d*a[j];
            d*=i;
        }
        if(v==0)lis.pb(-i);
    }

    sort(all(lis));
    stringstream ss;
    rep(i,lis.size()){
        ss<<"(x";
        if(lis[i]>0)ss<<"+";
        ss<<lis[i]<<")";
    }
    cout<<ss.str()<<endl;
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include<math.h>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{

    int a,b;
    cin>>a>>b;
    int s= a-1;
    int t =b-1;
    int ans = (t+s-1)/s;
    cout<<ans;
    return 0;
}


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

int main() {
  cout << fixed <<setprecision(5);
  int n; cin >>n;
  vector<double> v(n);
  for (int i=0; i<n; i++) cin >>v.at(i);
  sort(v.begin(), v.end());
  double ans = v.at(0);
  for (int i=1; i<n; i++){
    ans = (ans+v.at(i))/2;
  }
  
  cout <<ans;
  cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,k,x,ans;
void solve(){
	cout << ans << endl;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	rep(i,0,n-1){
		cin >> x;
		if(x >= k) ans++;
	}
	solve();
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
N = int(input())
D,X = map(int, input().split())
C = 0

def Chocolate(A,D):
  b = 0
  i = 0
  while(True):
    date = i*A + 1
    if date > D:
      break
    else:
      b += 1
      i += 1
  
  return b

for n in range(N):
  A = int(input())
  C += Chocolate(A,D)
  
print(C+X)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h> 
using namespace std;
long long a[100];
int main()
{
	 a[0]=2;
	 a[1]=1;
	int n;
	scanf("%d",&n);
	for( int i=2;i<=n;i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int f[44];
  int n, i;
  scanf("%d", &n);
  f[0] = f[1] = 1;
  for(i=2;i<=n;i++)f[i] = f[i-1] + f[i-2];

  printf("%d\n", f[n]);
  return 0;
}



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

#define W 21
#define H 21

typedef struct Queue{
    int q_x, q_y;
    struct Queue *next;
} Queue;

char board[W][H];
int check[W][H];
Queue *top, *bot;
int ans, wid, hei;
int dx[4] = {0, 1, 0, -1}, 
    dy[4] = {1, 0, -1, 0};

int plus_check(int a, int b);
void push(int a, int b);
Queue *pop(void);
void wfs(void);

int main(void)
{
    int i, j, x = 200, y = 200;

    scanf("%d %d",&wid, &hei);

    while (wid) {
        for (i = 0; i < hei; i++) {
            scanf("%s",board[i]);
        }

        top = NULL;
        bot = NULL;
        ans = 1;
        for (i = 0; i < hei; i++) {
            for (j = 0; j < wid; j++) {
                if (board[i][j] == '@') {
                    //printf("start : %d %d\n",i,j);
                    x = i; 
                    y = j;
                }
                check[i][j] = 0;
            }
        }
        check[x][y] = 1;
        for (i = 0; i < 4; i++) {
            if (plus_check(x+dx[i], hei) && plus_check(y+dy[i], wid)) {
                if (board[x + dx[i]][y + dy[i]] == '.') {
                    push(x + dx[i], y + dy[i]);
                    check[x + dx[i]][y + dy[i]] = 1;
                }
            }
        }
        wfs();
        printf("%d\n",ans);
        scanf("%d %d",&wid, &hei);
    }
    return 0;
}

void wfs(void) 
{
    int i;
    Queue *now;
    now = pop();
    while (now != NULL) {
        ans++;
        for (i = 0; i < 4; i++) {
            if (plus_check(now->q_x+dx[i], hei) && 
                    plus_check(now->q_y+dy[i], wid)) {
                if (board[now->q_x + dx[i]][now->q_y + dy[i]] == '.'
                        && !check[now->q_x + dx[i]][now->q_y + dy[i]] )  {
                    push(now->q_x + dx[i], now->q_y + dy[i]);
                    check[now->q_x + dx[i]][now->q_y + dy[i]] = 1;
                }
            }
        }
        now = pop();
    }
}

void push(int a, int b)
{
    Queue *new;
    //printf("%d %d\n",a, b);
    new = (Queue *)malloc(sizeof(Queue));
    new->q_x = a;
    new->q_y = b;
    new->next = NULL;
    if (bot == NULL) {
        bot = new;
        top = new;
    } else {
        top->next = new;
        top = new;
    }
}

Queue *pop(void)
{
    Queue *tmp;
    tmp = bot;
    if (bot != NULL) {
        bot = bot->next;
    }
    return tmp;
}

int plus_check(int a, int b)
{
    if (a < 0 || b <= a) {
        return 0;
    } else {
        return 1;
    }
}

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

int main() {
  int  n,m; cin>>n>>m;  
  vector<int>num(n);
  for(int i=0;i<m;i++){
    int a,b; cin>>a>>b;
    num[a-1]++; num[b-1]++;
  }
  for(int i=0; i<n; i++){
    cout<<num[i]<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main( )
{	
    int n;
    int maxProfit = 1-1000000000;
    int Rj, Ri = 2000000000, t;
   
    cin>>n;
    for( int i=0; i<n; i++ ) {
    	cin>>Rj;
    	if( maxProfit < Rj - Ri ) {
       		maxProfit = Rj - Ri;
       	}
       	if( Rj < Ri ) {
    		Ri = Rj;
    	}
    }
    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
s = input()
n = len(s)
if n % 2 == 0:
    print('Yes' if s[0]==s[n//2-1] and s[n//2]==s[n-1] and s[0:n//2-1]==s[n//2:n-1] else 'No')
elif n % 2 == 1:
    print('Yes' if s[0]==s[n//2-1] and s[n//2+1]==s[n-1] and s[0:n//2-1]==s[n//2+1:n-1] else 'No')

Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  
  if (abs(x[0] - x[2]) <= x[3] || 
     (abs(x[0] - x[1]) <= x[3] && abs(x[1] - x[2]) <= x[3])) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

int main(void) {
	int cost[100] = { 0 };
	int N, M,X, Nans = 0,ans0=0,x=0;
	cin >> N>>M>>X;
	for (int i = 0;i < M;i++)
		cin >> cost[i];
	for (x = X;x <= N;x++) {
		for (int i = 0;i < M;i++) {
			if (cost[i] == x) {
				Nans++;
				break;
			}
		}
	}
	for (x = X;x >= 0;x--) {
		for (int i = 0;i < M;i++) {
			if (cost[i] == x) {
				ans0++;
				break;
			}
		}
	}
	cout << min(ans0,Nans) << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  string S; cin >> S;
  string ans = "Yes";
  REP(i, S.size()) {
    if((i + 1) % 2 == 1) {
      if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {

      } else {
        ans = "No";
      }
    } else {
      if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {

      } else {
        ans = "No";
      }
    }
  }

  cout << ans << endl;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
 int n; cin>>n;
 string s; cin>>s;
 ll ans = 0,r = 0, g = 0, b = 0;
rep(i,n){
    if(s[i] == 'R') r++;
    else if(s[i] == 'B') b++;
    else g++;
}
ans = r*b*g;
    for(int i = 0; i < n-2;i++){
        for(int j = i+1; j < n-1;j++){
            if(s[i]!=s[j]&&s[i]!=s[2*j-i]&&s[2*j-i]!=s[j]&&2*j-i<n)ans--;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int n, m, x, c[12], a[12][12], ans = INT_MAX;

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

	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j)
			cin >> a[i][j];
	}

	for (int mask = 0; mask < (1 << n); ++mask) {
		bool f = true;
		int sum[m], cost = 0;
		for (int i = 0; i < m; ++i)
			sum[i] = 0;

		for (int i = 0; i < n; ++i) {
			if (mask & (1 << i)) {
				for (int j = 0; j < m; ++j)
					sum[j] += a[i][j];
				cost += c[i];
			}
		}
		
		for (int i = 0; i < m; ++i) {
			if (sum[i] < x) {
				f = false;
				break;
			}
		}

		if (f)
			ans = min(ans, cost);
	}

	cout << (ans == INT_MAX ? -1 : ans) << endl;
}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int i;
    int count=0;
    for(i=0;i<N-1;i++){
        if(S[i] == S[i+1]){
            count++;
        }
    }
    cout << N-count << endl;
    return 0;
}

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

vector<int> v;

int n,m,V,p;
bool check(int mid){
	vector<int> now;
	for(int i=0;i<n;i++)
		if(i!=mid){
			now.emplace_back(v[i]);
		}
	long long int limit=0;
	for(int i=0;i<p-1;i++){
		limit+=m;
		now.pop_back();
	}
	long long int to=v[mid]+m;
	if(now.size()&&to<now.back())	return false;
	for(int it:now){
		limit+=min((long long int)m,to-it);
	}
	return limit>=1LL*m*(V-1);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m>>V>>p;
	v.resize(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(v.begin(),v.end());
	int l=0,r=n-1;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<n-l<<endl;
}


Measured memory_bytes: 1624
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)cout<<"Zero"<<endl;
    else if(a>0&&b>0)cout<<"Positive"<<endl;
    else if((b-a)%2==0)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll t;
  cin>>t;
  unordered_map<string,ll> ma;
  while(t--)
  {
    string str;
    cin>>str;
    ma[str]++;
  }
  cout<<ma.size()<<"\n";
  return 0;
}

Measured memory_bytes: 17732
#include<stdio.h>

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

  int a = 0;
  int b = 0;
  int sum = 0;

  for(int i=0; i<N; i++){
    scanf("%d %d",&a,&b);
    sum += b - a + 1;
  }

  printf("%d",sum);

  return 0;

}

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

int main()
{
	int n,i,j,cnt,maxv=0;
	char ch;
	string s;
	cin>>n>>s;
	
	for(i=1;i<n;i++)
	{
		cnt=0;
		for(ch='a';ch<='z';ch++)
		{
			bool left=false,right=false;
			for(j=0;j<i;j++)
			  if(s[j]==ch) left=true;
			for(j=i;j<n;j++)
			  if(s[j]==ch) right=true;
			
			if(left && right) cnt++;
			
			
		}
		if(cnt>maxv) maxv=cnt;
	}
	cout<<maxv; 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

nums = {}
for i in range(n):
    if A[i] not in nums.keys():
        nums[A[i]] = 1
    else:
        nums[A[i]] += 1

calc_list = {}
for key, v in nums.items():
    calc_list[key] = int(v*(v-1)/2)
s = sum(calc_list.values())
# print(calc_list,s)

for i in range(n):
    tmp = nums[A[i]]-1
    diff = int(nums[A[i]]*(nums[A[i]]-1)/2 - tmp*(tmp-1)/2)
    print(s-diff)

# print(nums)


Measured memory_bytes: 33784
#include<stdio.h>
int main(void)
{
    int N,i=0;
    char str[4];
    
    double x,sum;
    sum = 0;
    
    scanf("%d",&N);
    
    do{
        scanf("%lf%s",&x,str);
        if(str[0]=='B'){
            x=x*380000;
        }
        
        sum=sum+x;
        x=0;
        i++;
        
    }while(i<N);
    
    printf("%lf",sum);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
using namespace std;
int main()
{
	stack<int> s;
	int k;
	while (cin >> k){
		if (0 == k){
			k = s.top();
			s.pop();
			cout << k << "\n";
		}
		else s.push(k);
	}
	return 0;
}

Measured memory_bytes: 1200