akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int t[1010];

int main(void) {
  int a,b; cin >> a >> b;
  reps(i,999) t[i] = t[i-1]+i;
  int index = b-a;
  cout << t[index]-b << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i,0,n) {cin >> a[i]; ans += a[i] - 1;}
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, K;

int Sum[200010];
map<int, int> counter;

int f(int a)
{
	a += K * 1001001001;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	rep(i, N+1) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;


int main()
{
	int n, x[1001], y[1001], p = 0, p1 = 0;
	double p2 = 0, p3 = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n; i++)
		cin >> y[i];
	for (int i = 0; i < n; i++)
	{
		p1 += abs(x[i] - y[i]);
		p2 += pow(x[i] - y[i], 2);
		p3 += pow(abs(x[i] - y[i]), 3);
		p = max(abs(x[i] - y[i]), p);
	}
	printf("%.6f\n", p1*1.0);
    printf("%.6f\n", sqrt(p2));
    printf("%.6f\n", cbrt(p3));
    printf("%.6f\n", p*1.0);
	return 0;
}



Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define cir(I,B,A) for(ll I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

/************************************************/

void Execute()
{
      ll N,NB,VAL,A,B,C,G,INC,DEC,L,R,D;
      cin >> N;
      ll ar[N];
      ll br[N];
      FOR(i,1,N) {cin >> ar[i];br[i]=ar[i];}
      sort(ar+1,ar+1+N);
      FOR(i,1,N)
      {
        if(br[i]==ar[N]) rad(ar[N-1]);
        else rad(ar[N]);
      }











}

int32_t main()
{
    //freopen("atomm.txt", "r", stdin);
    FAST();
    //CASES

        Execute();

}


Measured memory_bytes: 4736
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, K = map(int, readline().split())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]

C = 1 * (C == b'#')

def f(C, x, y):
    rows = [i for i in range(H) if x & (1<<i)]
    cols = [i for i in range(W) if y & (1<<i)]
    D = C[rows][:,cols]
    return D.sum() == K

ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)


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

int main(){
  int n; cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin>>d[i];
  sort(d.begin(),d.end());
  int ans=d[n/2]-d[n/2-1];
  cout <<ans <<endl;
}

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

int main() {
	// your code goes here
	stack<char>s;
	string s1,s2;
	cin>>s1>>s2;
	ll l1=s1.size();
	ll l2=s2.size();
	ll arr[l1+1][l2+1];
	for(ll i=0;i<=l1;i++)
	{
		arr[i][0]=0;
	}
	for(ll i=0;i<=l2;i++)
	{
		arr[0][i]=0;
	}
	for(ll i=1;i<=l1;i++)
	{
		for(ll j=1;j<=l2;j++)
		{
			if(s1[i-1]==s2[j-1])
			{
				arr[i][j]=arr[i-1][j-1]+1;
			//	cout<<s1[i-1];
			}
			else
			{
				arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
			}
		}
	}
  ll i=l1,j=l2;
  while(i>0&&j>0)
		{
			if(arr[i][j]>max(arr[i-1][j],arr[i][j-1]))
			{
				s.push(s2[j-1]);
				i=i-1;
				j=j-1;
			}
			else if(arr[i][j]==arr[i][j-1])
			{
			j=j-1;
			}
			else
			{
				i=i-1;
			}
		}
	while(!s.empty())
	{
		cout<<s.top();
		s.pop();
	}
	return 0;
}

Measured memory_bytes: 70656
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int f(int w, int h) {
	return (w % 3 == 0) ? 0 : h;
}

int g1(int w, int h, int x) {
	int a = x * h, b = (w - x) * (h / 2), c = (w - x) * ((h + 1) / 2);
	return max(a, max(b, c)) - min(a, min(b, c));
}

int g(int w, int h) {
	return min(g1(w, h, w / 3), g1(w, h, w / 3 + 1));
}

int main(int argc, char **argv) {
	int h, w;
	cin >> h >> w;
	cout << min(f(w, h), min(f(h, w), min(g(w, h), g(h, w)))) << endl;
	return 0;
}


Measured memory_bytes: 256
def judgiment(number_num):
  flag = True
  for number in list(map(int, input().split())):
    if number % 2 == 0:
      if not (number % 3 == 0 or number % 5 == 0):
        flag = False
        return flag
        break
    else:
      continue
  return flag

if __name__ == "__main__":
  number_num = int(input())
  flag = judgiment(number_num)
  if flag == True:
    print("APPROVED")
  else:
    print("DENIED")
  
      

Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<int> a = new List<int>();
        a.Add(0);
        a.AddRange(Console.ReadLine().Split().Select(int.Parse).ToArray());
        a.Add(0);
        List<int> b = new List<int>();
        for (int i = 0; i < n+1; i ++) b.Add(Math.Abs(a[i]-a[i+1]));
        int sum = b.Sum();
        for (int i = 0; i < n; i ++) {
            int result = sum;
            result -= b[i]+b[i+1];
            result += Math.Abs(a[i]-a[i+2]);
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 30812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int w,a,b;
  int x,y;
   cin>>w>>a>>b;
  x=min(a,b)+w;
  y=max(a,b);
  if(y>x){cout<<y-x<<endl;}
  else if(y<=x){cout<<0<<endl;}
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <cstdlib>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int W[N];
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }

    int min = 2147483645;
    for(int i = 0; i < N-1; i++){
        int s1=0;
        int s2=0;
        for(int j = 0; j <=i; j++){
            s1 += W[j];
        }
        for(int k = i+1; k < N; k++){
            s2 += W[k];
        }
        int ab = abs(s1-s2);
        if(ab < min){
            min = ab;
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	map<int,int> b;
	for (auto& x : A) b[x]++;
	cout << ((b.size() - 1) / 2 * 2 + 1) << endl;
}


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

using namespace std;
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define MOD 1000000007
#define fix(n) cout << fixed << setprecision(n)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for(long i=a; i<=b; i++)
#define REN(i, a, b) for(long i=b; i>=a; i--)
// Debugging 
#define line cout << endl
#define out(n) cout << n << " "
#define bug(n) cout << n << "\n"
#define print(arr, start, end) REP(i, start, end) out(arr[i]); line

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pi;
typedef map<int, int> mii;

///// General Purpose functions /////

/////////////////

void solve(){
	string s, t;
  	cin >> s >> t;
  	
  	int n = s.length();
  	int m = t.length();
  	int ans = 0;
  	
  	for(int i=0; i<n-m+1; i++)
    {
      	int j = i;
      	int count = 0;
      	for(int k=0; k<m; k++)
        {
          if(s[j] == t[k])
            count++;
          j++;
        }
      	ans = max(ans, count);
    }
  	
  	bug(m-ans);
}

void prep(){

}

int main()
{
	//code
	io;
	int t = 1;
	//cin >> t;
	prep();
	fix(12);
	while(t--){
	    solve();
	}
	
	return 0;
}

Measured memory_bytes: 3640
from fractions import gcd
A,B,C,D = (int(x) for x in input().split())
E = A-1
F = (C * D) // gcd(C,D)
nc = B // C
nc2 = E // C
nd = B // D
nd2 = E // D
ncd = int(B // F)
ncd2 = int(E // F)
print(B-A+1-nc+nc2-nd+nd2+ncd-ncd2)

Measured memory_bytes: 5628
from sys import setrecursionlimit
setrecursionlimit(4100000)

x, y = map(int, input().split())

mod = 1000000007
f = 0
df = abs(x-y)     #difference
tm = (x+y)//3   #time

if (x+y)%3 != 0:
    f = 1
elif tm < df:
    f = 1
else:
    pass

def mod_a_to_bth_power(a:int, b:int):
    if b%2 == 0:
        return (mod_a_to_bth_power(a, b//2)**2)%mod
    elif b == 1:
        return a%mod
    else:
        return ((mod_a_to_bth_power(a, b//2)**2)*a)%mod

def mod_inverse(a:int):
    return mod_a_to_bth_power(a, mod-2)

def mod_nCr(n:int, r:int):
    num, den = 1, 1 #numerator denominator
    for i in range(r):
        num = (num*(n-i))%mod
        den = (den*(i+1))%mod
    return (num*mod_inverse(den))%mod

if f == 1:
    print(0)
else:
    if df == 0:
        c = tm//2
    else:
        c = (tm-df)//2+df
    ans = mod_nCr(tm, c)
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string a;
  string b;
  
  cin >> a;
  cin >> b;
  
  for(int i=0;i<a.length();i++){
    if(a==b){
      cout << "Yes\n";
      return 0;
    }
    a.insert(a.begin(),a.back());
    a.pop_back();
  }
  
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
n,k=map(int, input().split())
import math
ans = 0

for i in range(1, n+1):
    if k <= i:
        ans += 1 /n
        continue
    c = math.log(k/i, 2)
    c = math.ceil(c)
    ans += pow(2, -c) / n

print(ans)

Measured memory_bytes: 3060
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
ll const MAX = 1e5 + 5;
ll a[105];
bool dp[MAX] = {};

int main() {
	ll n, k;
	cin >> n >> k;
	REP(i, 1, n) {
		cin >> a[i];
	}
	REP(i, 0, k) {
		REP(j, 1, n) {
			if (i - a[j] >= 0) {
				if (!dp[i - a[j]]) {
					dp[i] = 1;
					break;
				}
			}
			dp[i] = 0;
		}
	}
	if (dp[k]) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,n;
  cin>>x>>n;
  int z,a[102]={0};
  for(int i=0;i<n;i++) { cin>>z; a[z]++; }
  bool good = false;
  int i=x,j=x;
  while(!good)
  {
    if(a[i]==0) { good = true; cout<<i<<"\n"; }
    else if(a[j]==0) { good = true; cout<<j<<"\n"; }
    i--;
    j++;
  }
  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var line = Input.Line();
            int count = 0;
            for (int i = 1; i < line.Length; i++) {
                if(line[i - 1] != line[i]) {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 11232
#include<iostream>
#include<algorithm>
#include<cmath>
#define mod 1000000007
using namespace std;
long long int seive(long long int n){
    int i,j;
    long long int prime[1001];
    long long int sqr=sqrt(1000);
    for(i=0;i<=1000;i++) prime[i]=1;
    prime[0]=prime[1]=0;
    for(i=2;i<=sqr;i++){
        if(prime[i]==1){
            for(j=2;i*j<=1000;j++){
                 prime[i*j]=0;
            }
        }
    }
//    for(i=0;i<=1000;i++){
//        if(prime[i]==1) cout<<i<<" ";
//    }
//    cout<<endl;
    long long int num;
    for(j=2;j<=n;j++){
        num=j;
        for(i=2;i<=1000;i++){
            if(prime[i]>=1){
                while(num%i==0){
                    num/=i;
                    prime[i]++;
                }
            }
        }
    }
//    for(i=0;i<=1000;i++){
//        if(prime[i]>1) cout<<i<<"->"<<prime[i]<<endl;
//    }
//    cout<<endl;
    long long int prod=1;
    for(i=0;i<=1000;i++){
        if(prime[i]>1){
            prod=(prod*prime[i])%mod;
        }
    }
    return prod;
}
int main()
{
    long long int n;
    cin>>n;
    cout<<seive(n)<<endl;
}



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

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

using namespace std;

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

    vector<int> h;
    for(int i=1; i < 101; i++) {
        if (a % i == 0 && b % i == 0) {
            h.push_back(i);
        }
    }

    sort(h.begin(), h.end(), greater<int>());

    cout << h[k-1] << endl;
    return 0;

}



Measured memory_bytes: 256
import math
N,P = map(int,input().split())
A = list(map(int,input().split()))
A = [i%2 for i in A]
odd = A.count(1)
even = A.count(0)
sumo = 0
for i in range(odd+1):
    if i%2 == P:
        sumo += int(math.factorial(odd)//(math.factorial(odd-i)*math.factorial(i)))
ans = sumo*(2**even)
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int dp[10001];
int N,W;
int v,w;
int main()
{
	cin>>N>>W;
	rep(i,N){
		cin>>v>>w;
		rrep(i,W-w+1){
			dp[i+w]=max(dp[i+w],dp[i]+v);
		}
	}
	int ans=0;
	rep(i,W+1){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef unsigned long long int ull;
using namespace std;
int main(void){
  int N,X;
  cin >> N >> X;
  int m[N];
  rep(i,N) cin >> m[i];
  sort(m,m+N);
  X-=accumulate(m,m+N,0);
  cout << N+X/m[0] << endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200090;

int a,b,ans;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans=0;
	a = read(),b = read();
	int t = 1;
	while(t<b){
		++ans;
		t=t+a-1;
	}
	printf("%d\n",ans);
	
	return 0;
}

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

using namespace std;

int main(void) {
	long long int N, A, B, C, D, M, delta;
	cin >> N >> A >> B >> C >> D;
	A *= 2;
	B *= 2;
	C *= 2;
	D *= 2;
	M = (C + D) / 2;
	delta = (D - C) / 2;
	long long int i;
	for (i = -N + 1; i <= N - 1; i += 2) {
		if (abs(A + i * M - B) <= (N - 1) * delta) break;
	}
	if (i <= N - 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <cstdio>
using namespace std;

class Dice{
    public:
    int face[6], temp1, temp2;
    
    Dice(int nums[6]){
        face[0] = nums[0];
        face[1] = nums[1];
        face[2] = nums[2];
        face[3] = nums[3];
        face[4] = nums[4];
        face[5] = nums[5];
    }
    
    int move(char c){
        if (c == 'W'){
            temp1 = face[0];
            temp2 = face[3];
            face[0] = face[2];
            face[2] = face[5];
            face[3] = temp1;
            face[5] = temp2;
        }
        if (c == 'E'){
            temp1 = face[0];
            temp2 = face[2];
            face[0] = face[3];
            face[2] = temp1;
            face[3] = face[5];
            face[5] = temp2;
        }
        if (c == 'S'){
            temp1 = face[0];
            temp2 = face[1];
            face[0] = face[4];
            face[1] = temp1;
            face[4] = face[5];
            face[5] = temp2;
            
        }
        if (c == 'N'){
            temp1 = face[0];
            temp2 = face[4];
            face[0] = face[1];
            face[1] = face[5];
            face[4] = temp1;
            face[5] = temp2;
        }
        return 0;
    }
};

int main(void){
    int nums[6];
    char direction;
    scanf("%d%d%d%d%d%d", &nums[0], &nums[1], &nums[2], &nums[3], &nums[4], &nums[5]);
    Dice dice(nums);
    while(scanf("%c", &direction) != EOF){
        dice.move(direction);
    }
    printf("%d\n", dice.face[0]);
    return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =1e5+100;

int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll Max =-1,x,flag =1;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&x);
            Max =max(Max,x);
            if(x<Max&&Max-x>1)
                flag =0;
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int main() {
	int a, b, c, d, p; cin >> a >> b >> c >> d >> p;
	int ans_x = a * p; int ans_y = b;
	if (p > c) ans_y = ans_y + d * (p - c);
	cout << (ans_x > ans_y ? ans_y : ans_x) << endl;
	return 0;
}


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

void solve(long long N)
{
    cout << (N * N * N) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,d,x,y;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a<c)
		x=c;
	else
		x=a;
	if(b<d)
		y=b;
	else
		y=d;
	if(y-x<=0)
		printf("0\n");
	else
		printf("%d\n",y-x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	
	deque<int> color_index;
	rep(i, n) {
		rep(j, a.at(i)) {
			color_index.push_back(i + 1);
		}
	}


	vector<vector<int>> image(h, vector<int>(w, 0));

	rep(i, h) {
		int x = i;
		if (x % 2 == 0) {
			for (int j = 0; j < w; j++) {
				int y = j;
				image[x][y] = color_index.at(0);
				color_index.pop_front();
			}
		}
		else if (x % 2 != 0) {
			for (int j = (w - 1); j > -1; j--) {
				int y = j;
				image[x][y] = color_index.at(0);
				color_index.pop_front();
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << image[i][j] << ' ';
		}
		cout << endl;
	}
	
	return 0;
	
}



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

using namespace std;


int main(){
  
   int mai,yen;
  cin>>mai>>yen;
  
  bool kanryo=false;
  
  for(int i=0;i<=mai;i++){
    for(int j=0;j<=mai-i;j++){
      if(yen-1000*i-5000*j==10000*(mai-i-j)){
        cout<<mai-i-j<<" "<<j<<" "<<i<<endl;
      kanryo=true;
        break;}
    }
      if(kanryo) break;
      }
  if(!kanryo){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;}
  
        
 
}


Measured memory_bytes: 256
S=input()
if S=="RRR":
    print(3)
elif S=="RRS" or S=="SRR":
    print(2)
elif S=="SSS":
    print(0)
else:
    print(1)



















    

                
            





    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 8880
import sys
import math
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
  money = 100
  X = int(input())
  ans = 0

  while money < X:
    money = math.floor(money * 1.01)
    ans += 1
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 9172
N = int(input())
A = list(map(int, input().split()))
List = []
judge = 0
for i in range(N):
    if A[i]%2 == 0:
        List.append(A[i])
i = 0
for i in range(len(List)):
    if List[i]%5 == 0 or List[i]%3 == 0:
        pass
    else:
        print('DENIED')
        judge += 1
        break

if judge == 0:
    print('APPROVED')

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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
	int n; cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	int res = 0;
	for (int i = 0; i < n - 1; ++i)
		if (a[i] == a[i + 1]) {
			++res; a[i + 1] = 0;
		}

	cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
import Control.Monad

data Point = Point { point :: Int
                    ,trail :: Int
                    ,flag :: Bool} deriving (Eq,Show)

data Road = Road { p1 :: Int
                  ,p2 :: Int
                  ,len :: Int} deriving (Show)

minPoint :: [Point] -> Point
minPoint ps = foldl1 f ps
                where f p1 p2
                        | flag p1 = p2
                        | (not (flag p2)) && (trail p1 > trail p2) = p2
                        | otherwise = p1

allAcces :: [Road] -> [Point]-> [Point]
allAcces [] visited = visited
allAcces roads visited = allAcces roads' visited'
  where minP = minPoint visited
        roads' = deleteRoad minP roads
        visited' = used minP (acces minP roads visited)

acces :: Point -> [Road] -> [Point] -> [Point]
acces p [] visited = visited
acces p (r:rs) visited
  | point p == p1 r = acces p rs (update p r visited)
  | otherwise       = acces p rs visited

update :: Point -> Road -> [Point] -> [Point]
update p r [] = [(Point (p2 r) ((trail p) + (len r)) False)]
update p r (v:vs)
  | p2 r == point v = (Point (point v) (min (trail v) ((trail p) + (len r))) (flag v)):vs
  | otherwise       = v:(update p r vs)

used :: Point -> [Point] -> [Point]
used p [] = []
used p (x:xs)
  | point p == point x  = (Point (point p) (trail p) True):xs
  | otherwise           = x:(used p xs)

deleteRoad :: Point -> [Road] -> [Road]
deleteRoad _ [] = []
deleteRoad p (r:rs)
  | point p == p1 r = deleteRoad p rs
  | otherwise       = r:(deleteRoad p rs)

splitByC :: String -> [String] -> [String]
splitByC "" ss = ss
splitByC (',':xs) ss = splitByC xs (ss ++ [""])
splitByC (x:xs) ss = splitByC xs ((init ss) ++ [(last ss) ++ [x]])

split' :: String -> [String]
split' s = splitByC s [""]

makeRoadL :: [Road]-> [Int] -> [Road]
makeRoadL rs [] = rs
makeRoadL rs [a,b,c,d] = (Road a b c):(Road b a d):rs

minTrail :: Int -> [Point] -> Int
minTrail i (p:ps)
  | i == point p = trail p
  | otherwise    = minTrail i ps

main :: IO ()
main = do
  n <- getLine
  m <- readLn
  sss <- replicateM m getLine
  sgvp <- getLine
  let ss = map (map (read :: String -> Int)) $ map split' sss
      [s,g,v,p] = map (read :: String -> Int) $  split' sgvp
      rs = foldl makeRoadL [] ss
      go = allAcces rs [(Point s 0 False)]
      back = allAcces rs [(Point g 0 False)]
      ans = - (minTrail g go) - (minTrail s back) + v - p
  putStrLn $ show ans

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){

  int n,k;
  cin>>n>>k;
  n--;
  cout<<ceil((double)n/(k-1))<<endl;

  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vi a(n);
    rep(i, n)cin >> a[i], --a[i];

    int ans = 0;
    rep(i, n)if (a[a[i]] == i)ans++;
    cout << ans / 2 << endl;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n,x;
  cin>>n;
  x=n/1000;
  char a;
  if(n>999)a='C'+x;
  else a='C';

  cout<<"AB"<<a<<endl;

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    bool check[3000000] = {false};
    check[n] = true;
    int i = 1;
    while(true){
        i++;
        n%2==0 ? n /= 2 : n = 3*n + 1;
        if(check[n]) {cout << i << endl; break;}
        else check[n] = true;
    }
}

Measured memory_bytes: 6564
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B;

int main()
{
  std::cin >> A >> B;

  std::cout << A*B << std::endl;

  return 0;
}

Measured memory_bytes: 3192
n = int(input())
b = input().split()
b = [int(i) for i in b] 

a = []
sum_a = b[0] + b[-1]
for i,b_i in enumerate(b):
    
    if i+1 < n-1:
        if b[i+1] >= b[i]:
            a.append(b[i])
            sum_a += b[i]
        else:
            a.append(b[i+1])
            sum_a += b[i+1]
print(sum_a)

Measured memory_bytes: 3064
import numpy as np
x = [int(i) for i in input().split()]
cost = x[1]
value = 0
li = []
for i in range(x[0]):
  tmp = [int(j) for j in input().split()]
  li.append(tmp)
t = np.array(li)
index = np.lexsort([t[:,0]])
data = t[index,:]
for i in range(x[0]):
  if data[i][1] <= cost:
    value += data[i][0]*data[i][1]
    cost -= data[i][1]
  else:
    value += data[i][0]*cost
    break
print(value)

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

int main(){
	int d;
	while(cin >> d){
		int s = 0;
		for(int i = 1; i * d < 600; i++){
			s += (i * d) * (i * d) * d;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from itertools import product
A = [int(a) for a in input().split()]
K = int(input())
X = list(product([0, 1, 2], repeat = K))
for x in X:
    B = A[:]
    for xx in x:
        B[xx] *= 2
    if B[0] < B[1] < B[2]:
        print("Yes")
        break
else:
    print("No")    

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll next_snuke(ll in){
	ll dig = 1;
	ll ten = 1;

	double MIN = 1e20;
	ll ret;

	ll tmp = in;
	ll sum = 0;
	ll idx = 1;
	ll lis[20];


	while(tmp != 0){
		sum += tmp%10;
		tmp /= 10;
		lis[idx] = sum;
		idx++;
	}

	while(ten < in){
		ll top = (in/ten)%10;
		for (int i = top;i <= 9;i++){
			ll num = (in/(ten*10))*ten*10 + i*ten + 1*ten-1;
			ll snum = lis[idx-1] - lis[dig] + i + 9*(dig-1);
			double a = double(num)/double(snum);
			if(MIN > a){
				ret = num;
				MIN = a;
			}		
			//cout << num << " " << snum << " " << a << " from func \n";
		}
		dig++;
		ten *= 10;
	}

	return ret;
}

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

	ll K; cin >> K;

	ll num = 1;
	cout << 1 << endl;

	for (int i = 1;i < K;i++){
		num = next_snuke(num+1);
		cout << num << endl;
	}

	return 0;

}


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

int main(){
    long long K,A,B;
    cin >> K >> A >> B;
    if(B-A > 2 || K < A){
        long long res = A;
        long long n = max((long long)0,(K-A+1)/2);
        res += n * (B-A) + (K-A+1) % 2;
        cout << res << endl;
    }else{
        cout << K + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl a,b;
    a = stoi(s.substr(0,2));
    b = stoi(s.substr(2,2));
    bool f1,f2;
    f1 = ((a < 13)&&(a > 0));
    f2 = ((b < 13)&&(b > 0));
    string t;
    if((f1)&&(f2))t = "AMBIGUOUS";
    if((!f1)&&(f2))t = "YYMM";
    if((f1)&&(!f2))t = "MMYY";
    if((!f1)&&(!f2))t = "NA";
    cout << t << endl;
    return 0;
}

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

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        double a = Double.parseDouble(br.readLine());
		double x = a * 2 * Math.PI;
        double y = a * a * Math.PI;
        System.out.println(String.format("%.6f", y) + " " + String.format("%.6f", x));

    }
}




Measured memory_bytes: 24736
<?php
    fscanf(STDIN,"%s %s",$X ,$Y);


    if(strnatcmp($X,$Y) == 0){
        echo "=\n";
    }elseif(strnatcmp($X,$Y) > 0){
        echo ">\n";
    }else{
        echo "<\n";
    }

    


Measured memory_bytes: 4604
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
nx = x2
ny = y2
l = []
for i in range(2) :
    dx, dy = -dy, dx
    nx += dx
    ny += dy
    l.append(nx)
    l.append(ny)
print(l[0], l[1], l[2], l[3])


Measured memory_bytes: 9144
import java.util.*;

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

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

        int out = a + b;
        if (out < a - b) out = a - b;
        if (out < a * b) out = a * b;
        System.out.print(out);
    }

}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


int main() {

	int d,e;

	while (cin >> d >> e, d != 0 || e != 0) {
		

		double mini = 10000000;

		for (double i = 0; i <= d; i++) {
			double x = i;
			double y = d - i;

			double kyori = sqrt(x * x + y * y);

			

			mini = min(mini, abs(kyori-e));


		}

		cout << fixed << setprecision(8) << mini << endl;

		mini = 1000000;

			
	}
	
	return 0;
}






Measured memory_bytes: 3184
#[allow(unused_imports)]
use std::cmp;

fn rec(i: usize, sum: usize, s: &String) -> usize {
    if i == s.len() {
        sum
    } else {
        let mut ret = 0;
        for j in i + 1..s.len() + 1 {
            ret += rec(j, sum + s[i..j].parse::<usize>().unwrap(), s);
        }
        ret
    }
}

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s: String = sc.read();
    let ans = rec(0, 0, &s);
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 8572
import java.util.Scanner;

/**
 * TITLE : Papers, Please
 * URL : https://atcoder.jp/contests/abc155/tasks/abc155_b
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            if (A % 2 == 0 && (A % 3 != 0 && A % 5 != 0)) {
                System.out.println("DENIED");
                sc.close();
                return;
            }
        }
        System.out.println("APPROVED");
        sc.close();
    }
}

Measured memory_bytes: 21844
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M, X = map(int,readline().split())
ca = np.array([list(map(int, readline().split())) for _ in range(N)])
#ca = np.array(sorted(ca, key=lambda x: -sum(x[1:])))

#ca = np.array(sorted(ca, key=lambda x: x[0]))

ans = pow(10, 9) + 7
#count = np.zeros(M)
flag = False
for bit in range(0, 1<<N):
    acc = 0
    count = np.zeros(M)
    for i in range(N):
        if bit & (1<<i):
            ca_ = ca[i]
            acc += ca_[0]
            count += ca_[1:]
    if count.min() >= X:
        ans = min(ans, acc)
        flag = True
    
print(ans) if flag else print(-1)



Measured memory_bytes: 27192
#include<iostream>
int n,a[50];
int search(int i,int m){
	if(m==0)
	return 1;
	if(i>=n)
	return 0;
	int r=search(i+1,m)||search(i+1,m-a[i]);
	return r;
}
int main()
{
	int q,m,i;
	std::cin>>n;
	for(int i=0;i<n;i++)
		std::cin>>a[i];
		std::cin>>q;
	for(i=0;i<q;i++){
		std::cin>>m;
		if(search(0,m))
		std::cout<<"yes"<<"\n";
		else
		std::cout<<"no"<<"\n";
	}
	return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

pair<ll, ll> po[1 << 18];
ll a[1 << 18];
ll sum[1 << 18];

void update(P &p1, P p2){
    vector<ll> v = {p1.first, p1.second};
    if(p1.first != p2.first && p1.second != p2.first) v.push_back(p2.first);
    if(p1.first != p2.second && p1.second != p2.second) v.push_back(p2.second);
    sort(v.begin(), v.end(), [](ll x, ll y){return a[x] > a[y];});
    p1.first = v[0];
    p1.second = v[1];
}

int main(){
    ll N;
    cin >> N;
    for(ll i = 0; i < (1 << N); i++) cin >> a[i];
    for(ll i = 0; i < (1 << N); i++) po[i].first = i;
    for(ll i = 0; i < N; i++) for(ll j = 0; j < (1 << N); j++) if(!((j >> i) & 1)) update(po[j | (1 << i)], po[j]);
    for(ll i = 1; i < (1 << N); i++){
        sum[i] = max(sum[i - 1], a[po[i].first] + a[po[i].second]);
        cout << sum[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define ll long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);


int n, m, q, a[52], b[52], c[52], d[52];
int ans = INT_MIN;
int arr[12];

void solve(int len, int start)
{
    if(len == n)
    {
        int cur_score = 0;
        // for(int i = 0; i < n; i++)
        // cout << arr[i] << " ";
        // cout << endl;
        for(int i = 0; i < q; i++)
        {
            if(arr[b[i]] - arr[a[i]] == c[i])
                cur_score += d[i];
        }
        ans = max(ans, cur_score);
        return;
    }
    
    for(int i = start; i <= m; i++)
    {
        arr[len] = i;
        solve(len + 1, i);
    }
}

int main()
{
    fastIO
    cin >> n >> m >> q;
    
    for(int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
        
    solve(0, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
ans = True
if sum(A) < sum(B):
    res = -1
    ans = False
    print(res)
if ans:
    N = [A[i]-B[i] for i in range(n) if A[i] < B[i]]
    P = [A[i]-B[i] for i in range(n) if A[i] >= B[i]]
    res = len(N)
    P.sort(reverse=True)
    dif = abs(sum(N))
    i = 0
    while dif>0:
        dif -= P[i] 
        res += 1
        i += 1
    print(res)

Measured memory_bytes: 19508
#import<cstdio>
int main(){int a,c=3,r=1;for(char d[]="123546",s[9];a=scanf("%s",s),*s>60;r+=*d&7)*s%6-4?a+=*s%5+*s%2*2+c&3,d[5]=d[a],d[a]=*d,d[++a%4+1]=~*d,*d=~d[5]:c+=*s+3;~-r&&printf("%d\n",r);~a&&main();}

Measured memory_bytes: 0
n=int(input())
t=[list(map(int,input().split())) for i in range(n)]
t=sorted(t,key=lambda x:x[1])

time=0
for i in range(len(t)):
  time+=t[i][0]
  if time>t[i][1]:
    print("No")
    break
else:
  print("Yes")


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

int main() {
  int a,b,ans;
  cin >> a >> b;
  ans = 0;
  vector<int> x(5);
  for(int i=a;i<=b;i++){
    x.at(0) = i/10000;
    x.at(1) = i/1000 - x.at(0)*10;
    x.at(2) = i/100 - x.at(0)*100 - x.at(1)*10;
    x.at(3) = i/10 - x.at(0)*1000 - x.at(1)*100 - x.at(2)*10;
    x.at(4) = i%10;
    if(x.at(0) == x.at(4) && x.at(1) == x.at(3)){
      ans++;
    }
  }
  
  cout << ans << endl;
}


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

int main(void){
  int a[4];
  int b[4];

  while( cin >> a[0] >> a[1] >> a[2] >> a[3] ){
    cin >> b[0] >> b[1] >> b[2] >> b[3];

    int count=0;
    int hit=0;
    int blow=0;

    for(int i=0; i<3; i++){
      for(int j=i+1; j<4; j++){
        if(a[i] == a[j]){
          count++;
        }
        if(b[i] == b[j]){
          count++;
        }
      }
    }
    if(count==0){
      for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
          if(a[i]==b[j]){
            if(i==j){
              hit++;
            }else{
              blow++;
            }
          }
        }
      }
      cout << hit << " " << blow << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160