akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(i) for i in input().split()]

perm = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        perm += 1
    temp = A[i]
    temp2 = A[minj]
    A[i] = temp2
    A[minj] = temp
print(" ".join(list(map(str, A))))
print(perm)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

ll ad(ll n,ll c,ll d){
    ll lcd=c*d/__gcd(c,d);
    return n-n/c-n/d+n/lcd;
}

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<ad(b,c,d)-ad(a-1,c,d)<<endl;
}

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

int main(){
  int n;  cin >> n;
  vector<int> a(n+1), b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll ans = 0;
  rep(i,n){
    if(a[i]>=b[i]) ans+=b[i];
    else {
      if(a[i+1] > b[i]-a[i]){
        ans+=b[i];
        a[i+1]-=b[i]-a[i];
      }else{
        ans+=a[i]+a[i+1];
        a[i+1]=0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
/// ITNOG :)))
/// SAliB
#include <bits/stdc++.h>

using namespace std;

#define pb                      push_back
#define pp                      pop_back
#define mp                      make_pair
#define fi                      first
#define sec                     second
#define xmax(x,y)               ((x) = max((x),(y)))
#define xmin(x,y)               ((x) = min((x),(y)))
#define all(x)                  (x).begin(),(x).end()
#define mem(x , y)              memset(x , y , sizeof(x))
#define _                       ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug1(a)               cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n';
#define debug2(a , b)           cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n';
#define debug3(a , b , c)       cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n' << #c << " ---> " << c << '\n';
#define debug4(a , b , c , d)   cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n' << #c << " ---> " << c << '\n' << #d << " ---> " << d << '\n';
#define connect(a , b , c)      a[b].pb(c) , a[c].pb(b)
//
typedef long long int ll            ;
typedef unsigned long long int ull  ;
typedef unsigned int uint           ;
typedef long double ld              ;
typedef string str                  ;
typedef pair < int , int > pii      ;
typedef pair < pii , int > ppi      ;
typedef pair < int , pii > pip      ;
typedef pair < ll , ll> pll         ;
typedef pair < ll , pll> plp        ;
typedef pair < pll , ll> ppl        ;
typedef vector < ll > vl            ;
typedef vector < ld > vld           ;
typedef vector < int > vi           ;
typedef vector < str > vs           ;
//
inline int   iin()  { int x   ; scanf("%d" , &x)   ;  return x; }
inline ll    lin()  { ll  x   ; scanf("%lld" , &x) ;  return x; }
inline ll    Lin()  { ll  x   ; scanf("%I64d" , &x);  return x; }
//
inline int   iout(int  x)  { printf("%d" , x)   ;  }
inline ll    lout(ll   x)  { printf("%lld" , x) ;  }
inline ll    Lout(ll   x)  { printf("%I64d" , x);  }
//
const int maxn4 = 1e4 + 85 , maxn5 = 1e5 + 69 , maxn6 = 1e6 + 85 , maxn7 = 1e7 + 69 , maxn8 = 1e8 + 85 , maxn9 = 1e9 + 69 , modi1 = 1e7 + 7 , modi2 = 1e9 + 7;
const ll mod1 = 1e7 + 7 , mod2 = 1e9 + 7;
int mn = INT_MAX , mx = INT_MIN;
//
int h[maxn5];
int main()
{_
    string s; cin >> s;
    int n = s.size();
    if(s[0] != '1' or s[n-1] != '0')
        return cout << -1 , 0;
    for(int i = 1 ; i < n - 1 ; i++)
        if(s[i] != s[n-i-2])
            return cout << -1 , 0;
    cout << "1 2\n";
    int last = 0;
    for(int i = 1 ; i < n - 1 ; i++) 
    {
        cout << last + 1 << " " << i + 2 << '\n';
        if (s[i] == '1')
            last = i + 1;
    }
	return 0;
}

Measured memory_bytes: 1616
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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 a, b;
int main(void) {
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 ||(a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=10000005,mod=1e9+7;
ll n,m,fac[N],ni[N],alb[5005];
ll c(int a,int b){
	return fac[a]*ni[b]%mod*ni[a-b]%mod;
}
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
ll inv(int n){
	return fac[n-1]*ni[n]%mod;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(),m=read();
	For(i,fac[0]=1,n)fac[i]=fac[i-1]*i%mod;
	ni[n]=ksm(fac[n],mod-2);
	Rep(i,n,1)ni[i-1]=ni[i]*i%mod;
	n-=m;
	ll ans=0;
	For(i,0,m)alb[i]=i*inv(i+n)%mod;
	For(mn,2,m+1){
		For(i,0,mn-2){
			//cout<<n+m-i-1<<" "<<endl;
			ans=(ans+(i%2?-1:1)*c(mn-1,i)*(mn<=m?fac[n+m-i-1]:fac[n+m-i])%mod
			*alb[mn-i-1])%mod;
		}
		//cout<<ans<<endl;
	}
	cout<<(ans+mod)%mod<<endl;
	/*
	dp[0][0]=1;
	For(i,0,m-1){
		For(j,0,n){
			For(k,1,m-i){
				For(l,0,n-j){
					if(j!=n&&k+l==1)continue;
					dp[i+k][j+l]+=fac[k+l-1]*dp[i][j]*c(m-i,k)*c(n-j,l);
				}
			}
		}
	}
	cout<<dp[m][n]<<endl;
	*/
}
/*
枚举不合法1第一个位置 
mn-1不能有1 ，容斥这个条件 
mn-i-1无所谓 
m-mn无所谓
n只能连之前的 
*/

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

using namespace std;

inline int change_pixel(int v, string &str)
{
    int nv = v;
    const int d[7][7] =
        {
            { 8,  9,  3,  4,  5,  0,  1},
            { 9, 10,  4,  5,  6,  1,  2},
            {12, 13,  7,  8,  9,  3,  4},
            {13, 14,  8,  9, 10,  4,  5},
            {14, 15,  9, 10, 11,  5,  6},
            {16, 17, 12, 13, 14,  8,  9},
            {17, 18, 13, 14, 15,  9, 10}
        };

    for (int i = 0; i < 7; i++) {
        int bit = 0;
        nv &= ~(1 << d[i][3]);
        for (int j = 0; j < 7; j++) {
            bit |= (v >> d[i][j] & 1) ? (1<<j) : 0;
        }        
        nv |= (1 << d[i][3])*(str[bit] - '0');
    }
    return nv;
}

bool is_idempotent(string &str)
{
    for (int i = 0; i < (1<<19); i++) {
        int before = i, after;
        before = change_pixel(before, str);
        after  = change_pixel(before, str);
        if ((before >> 9 & 1) != (after >> 9 & 1)) {
            return false;
        }
    }
    return true;
}

int main()
{
    string str;
    while (cin >> str, str != "#") {
        cout << (is_idempotent(str) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

		while(true){
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			char[] input = sc.next().toCharArray();
			//System.out.println(input);
			
			int[][] ops = new int[N][2];
			
			for(int i = 0; i < N; i++){
				final int start = sc.nextInt() - 1;
				final int end = sc.nextInt() - 1;
				ops[i][0] = start;
				ops[i][1] = end;
			}
			
			for(int i = N - 1; i >= 0; i--){
				final int start = ops[i][0];
				final int end = ops[i][1];
				
				int sub = Math.abs(start - end) % 26;
				
				//System.out.println(input[start] + " " + input[end]);
				
				input[start] = (char) (input[start] + sub > 'z' ? input[start] - 26 + sub : input[start] + sub);
				input[end] = (char) (input[end] + sub > 'z' ? input[end] - 26 + sub : input[end] + sub);
				
				//System.out.println(input[start] + " " + input[end] + " " + sub);
				
				char tmp = input[start];
				input[start] = input[end];
				input[end] = tmp;
				
				//System.out.println(input[start] + " " + input[end]);
			}
			
			System.out.println(input);
		}
		
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(void){
	char a[4], b[4];
	cin >> a >> b;
	int al = strlen(a), bl = strlen(b), sum = 0;;
	for(int i = 0; i < al; i++){
		sum += (a[i] - '0') * pow(10, al + bl - i - 1);
	}
	for(int i = 0; i < bl; i++){
		sum += (b[i] - '0') * pow(10, bl - i - 1);
	}
	int flg = 0;
	for(int i = 2; i <= 1000; i++){
		if(sum == (i * i)){
			flg = 1;
			break;
		}
	}
	if(flg == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    // g * (b1 + b2 + .. bn) = M
    // (b1 + b2 + .. bn) = M / g
    let mut ans = 1;
    let mut gcd = 1;

    while gcd * gcd <= m {
        if m % gcd == 0 {
            if n <= m / gcd{
                ans = std::cmp::max(gcd, ans);
            }
            let gcd2 = m / gcd;
            if n <= m / gcd2 {
                ans = std::cmp::max(gcd2, ans);
            }
        }        
        gcd += 1;
    }

    println!("{}", ans);
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#endif

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    string S;
    cin >> S;

    bool good = false;

    if (D < C) {
        for (int i=B; i<=D; ++i) {
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                good = true;
                break;
            }
        }
        if ( ! good) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i=A; i<C; ++i) {
        if (S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i=B; i<D; ++i) {
        if (S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	int ans = 0, cnt = 0, H;
	cin >> H;
	for (int i = 1; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp <= H)
			cnt++;
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
		H = tmp;
	}
	ans = max(ans, cnt);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

const int MAXN = 200100;
int suf[MAXN][2];
int pre[MAXN][2];
int pulo[MAXN];
int a[MAXN];
int dp[MAXN][3];
bool vis[MAXN][3];
  int n;
int solve(int id,int pulos){
  if(id>n){
    if(pulos!=2)return -1e15;
    return 0;
  }
  int &x = dp[id][pulos];
  if(vis[id][pulos])return x;
  vis[id][pulos] = 1;
 
  x=0;

  x = a[id] + solve(id+2,pulos);
  if(id+3<=n and pulos<2){
    x = max(x,a[id] + solve(id+3,pulos+1));
  }
  return x;
}

int32_t main(){
  fastio;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    pre[i][i%2]=(i>=2?pre[i-2][i%2]:0) + a[i];
  }

  for(int i=0;i<MAXN;i++){
    for(int j=0;j<3;j++){
      vis[i][j]= 0;
    }
  }
  if(n%2==0){
    int best = solve(1,2);
    best = max(best,solve(2,2));
    best = max(best,solve(1,1));
      cout<<best<<endl;
    return 0;
  }else{
    int best = max(solve(1,0),solve(2,1));
    best = max(best,solve(3,2));
    best = max(best,solve(1,1));
    if(n==3){
      best = max({a[1],a[2],a[3]});
      
    }
    cout<<best<<endl;
    return 0;
  }

  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 21416
import itertools
from collections import deque,Counter
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

x = LMAP()
print(x.index(0) + 1)


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll t;
//    cin >> t;
//    while(t--){
        ll n;
        cin >> n;
        ll tp = n/1000;
        if(n%1000==0){
            cout << 0 << endl;
        }else{
        cout << - n + (tp+1)*1000 << endl;;}
    //}
    return 0;
}


Measured memory_bytes: 3628
x,n = list(map(int,input().strip().split()))

if n == 0:
  print(x)
  exit()
else:
  p = list(map(int,input().strip().split()))

inc = 0

if x not in p:
  print(x)
  exit()

while True:
  inc += 1
  if x-inc not in p:
    print(x-inc)
    exit()
  if x+inc not in p:
    print(x+inc)
    exit()

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
void output(vi ans){
    REP(i,ans.size()){
        cout<<(ans[i]?'S':'W');
    }cout<<endl;
}
int main(){
    int n;
    cin>>n;
    string st;
    cin>>st;
    vi ans(n);
    REP(p,2){
        REP(q,2){
            ans[0]=p;
            ans[1]=q;
            FOR(i,1,n-1){
                if((ans[i]&&st[i]=='o')||(!ans[i]&&st[i]=='x')){
                    ans[i+1]=ans[i-1];
                }else{
                    ans[i+1]=!ans[i-1];
                }
            }
            int a;
            if((ans[0]&&st[0]=='o')||(!ans[0]&&st[0]=='x')){
                a=ans[1];
            }else{
                a=!ans[1];
            }
            int b;
            if((ans.back()&&st.back()=='o')||(!ans.back()&&st.back()=='x')){
                b=ans[n-2];
            }else{
                b=!ans[n-2];
            }
            if(ans.back()==a&&ans[0]==b){
                output(ans);
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.awt.Point;

public class Main {
	static int mod = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		if((x+y)%3 != 0) {
			System.out.println(0);
			return;
		}
		long n = (x+y)/3;
		x = x-n;
		y = y-n;
		if(x<0 || y<0) {
			System.out.println(0);
			return;
		}
		System.out.println(modCombination(x+y, x, mod));
	}
	public static long modCombination(long n, long r, long mod) {
		long top = 1;
		long bottom = 1;
		for (int i = 1; i <= r; i++) {
			top *= n;
			top %= mod;
			n--;
			bottom *= i;
			bottom %= mod;
		}
		bottom = modPow(bottom, mod-2, mod);
		return (top * bottom) % mod;
	}
	public static long modPow(long base, long exp, long mod) {
		if (exp == 0)
			return 1;
		if (exp == 1)
			return base % mod;
		if (exp % 2 == 1)
			return (base * modPow(base, exp - 1, mod) % mod);
		long tmp = modPow(base, exp / 2, mod);
		return (tmp * tmp) % mod;
	}
}


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

#define MAX 1000000000

int main(void){
    long long N, K;
    vector<long long> A;
    int a;

    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> a;
        A.push_back(a);
    }

    long long max = MAX + 1;
    long long min = 0;
    long long mid;
    int d, CountCut;
    while(max - min > 1){
        CountCut = 0;
        mid = (max + min) / 2;
        for(int i = 0; i < N; ++i){
            d = (A[i] +mid - 1) / mid - 1;
            if(d > 0) CountCut += d;
        }
        if (CountCut <= K) max = mid;
        else min = mid;
    }

    cout << max << endl;
}


Measured memory_bytes: 5276
//jian
#include<stdio.h>
int main()
{
	double r,A,p;
	scanf("%lf",&r);
	A=3.141592653589793*r*r;
	p=2*3.141592653589793*r;
	printf("%.6lf %.6lf\n",A,p);
	return 0;
	}



Measured memory_bytes: 2148
#include <iostream>
#include <cstring>
#include <math.h>
using namespace std;
int a[100001], dp[100001], n;
int solve(int i, int sum){
	if(dp[i] != -1){
		return dp[i];
	}
	if(i == n - 1){
		return 0;
	}
	if(i == n - 2){
		return abs(a[i] - a[i + 1]);
	}
	return dp[i] = min(solve(i + 1, abs(a[i] - a[i + 1])) + abs(a[i] - a[i + 1]), solve(i + 2, abs(a[i] - a[i + 2])) + abs(a[i] - a[i + 2]));
}
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i){
		dp[i] = -1;
	}
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	cout << solve(0, 0);
	return 0;
}

Measured memory_bytes: 3328
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn];

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)cin>>d[i];
    ll mn=2,mx=2;
    for(int i=n-1;i>=0;i--)
    {
      mn=((mn-1)/d[i]+1)*d[i];
      mx=(mx/d[i]+1)*d[i]-1;
    }
    debug(mn,mx);
    if(mn>mx)cout<<-1<<endl;
    else cout<<mn<<" "<<mx<<endl;

}


Measured memory_bytes: 1024
#include <stdio.h>
int N;
int tmp = 0;
int cmp_int(const void* v1, const void* v2)
{
  const int _v1 = *((const int*)v1);
  const int _v2 = *((const int*)v2);

  if ( _v1 > _v2 ) {
    return 1;
  } else if ( _v1 < _v2 ) {
    return -1;
  } else {
    return 0;
  }
}
int main (void){
  if(scanf("%d",&N) == 1);
  int x[N];
  for(int i = 0;i < N;i++){
    x[i] = 0;
    if(scanf("%d",&x[i]) == 1);
  }
  
  qsort(x, N, sizeof(int), cmp_int);
  /*for(int i = 0;i <N;i ++){
    for(int j = i + 1;j < N;j++){
      if(x[i]<x[j]){
        tmp = x[i];
        x[i] = x[j];
        x[j] = tmp;
      }
    }
  }*/
  int r = x[N/2] - x[N/2-1];
  if(r < 0){
    r = r * (-1);
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int i = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int i = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int i = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int l, r, d; cin >> l >> r >> d;
    cout << r/d - (l-1)/d << endl;
    return 0;
}

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


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
  int N;
  cin >> N;
  if(N >= 1000){
    cout << "ABD" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{


	static char[][] map;
	static final int MOD = 1000000007;


	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = c-(a-b);
		if(ans < 0){
			ans = 0;
		}
	    System.out.println(ans);






	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



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




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int n,q;
  while(cin >> n >> q) {
    vector<pair<int, string> > v;
    v.push_back(make_pair(1,"kogakubu10gokan"));
    REP(i,n) {
      int year; string s;
      cin >> year >> s;
      v.push_back(make_pair(year,s));
    }
    cout << (--lower_bound(ALL(v),make_pair(q+1,string())))->second << endl;
  }
}

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

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for(int i=0; i<N; i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  int wmin, wmax, hmin, hmax; //白い部分の縦と横の長さを保存
  wmin = 0, wmax = W, hmin = 0, hmax = H;
  for(int i=0; i<N; i++){
    if(a[i] == 1) wmin = max(wmin, x[i]);
    if(a[i] == 2) wmax = min(wmax, x[i]);
    if(a[i] == 3) hmin = max(hmin, y[i]);
    if(a[i] == 4) hmax = min(hmax, y[i]);
  }
  if(wmin >= wmax || hmin >= hmax) cout << 0 << endl;
  else cout << (wmax - wmin)*(hmax - hmin);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main( void )
{
	int t, map[101];
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		for(int i=0; i < n; ++i) {
			cin >> map[i];
		}
		int Max, Min;
		Max = Min = 0; n--;
		for(int i=0; i < n; ++i) {
			int sub = map[i+1] - map[i];
			Max = max(Max, sub);
			Min = min(Min, sub);
		}
		cout << Max << ' ' << -Min << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> omochi(N);
  for(int i = 0; i < N; i++) cin >> omochi.at(i);

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

  int answer = 1;
  for(int i = 0; i < N - 1; i++){
    if(omochi.at(i) < omochi.at(i + 1)) answer++;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    
    int x[100000];
    int d[100000];
    for (int i = 0; i < m; i++) {
        scanf("%d",&x[i]);
    }
    
    qsort( x, m, sizeof(int), cmp );
    
    for(int i=0;i<m-1;i++){
        d[i]=x[i+1]-x[i];
    }
    
    qsort( d, m-1, sizeof(int), cmp );
    
    int time=0;
    for(int i=0;i<m-n;i++){
        time+=d[i];
    }
    
    printf("%d\n",time);
    return 0;
}

Measured memory_bytes: 1396
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
    
    int n,j,fp,sp,carry,ans[100];
    char f[1000],s[1000];
    scanf("%d",&n);
    
    while (n--) {
        scanf("%s %s",f,s);
        if (strlen(f)>80 || strlen(s)>80) {
            printf("overflow\n");
            continue;
        }
        
        fp=strlen(f);
        sp=strlen(s);
        j=carry=0;
        while (fp || sp) {
            ans[j]=carry;
            if(fp) ans[j] +=f[--fp]-'0';
            if(sp) ans[j] +=s[--sp]-'0';
            carry =ans[j]/10;
            ans[j++] %=10;
        }
        
        if(carry) ans[j]=carry;
        else j--;
        if(j >= 80){
            printf("overflow\n");
            continue;
        }
        for (; j>=0; j--) {
            printf("%d",ans[j]);
        }
        printf("\n");
    }
    
    return 0;
    
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<vector<double>> dist(n, vector<double>(n));
    double ans = 0.0;
    rep(i, n)rep(j, n){
        dist[i][j] = sqrt(((x[i]-x[j]) * (x[i]-x[j])) + ((y[i]-y[j]) * (y[i]-y[j])));
        ans += dist[i][j];
    }

    ans /= n;
    cout << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
m = dict()
s = int(input())
mo = 10 ** 9 + 7

def rec(n):
  if n in m:
    return m[n]
  if n < 3:
    m[n] = 0
    return 0
  elif n-3 < 3:
    m[n] = 1
    return 1
  else:
    result = 1
    for x in range(3, n-2):
      result += rec(x)
    m[n] = result
    return result

if s >= 3:
  print(rec(s) % mo)
else:
  print(0)

Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
using namespace std;


int main() {
    int n; cin >> n;
    V h(n);
    rep(i, 0, n) cin >> h[i];

    reverse(h.begin(),h.end());

    //後ろから考えてみる

    bool f = true;
    rep(i, 0, n-1){
        if(h[i] >= h[i+1]) continue;
        else if(h[i]+1 == h[i+1]) h[i+1]--;
        else if(h[i]+2 <= h[i+1]) f = false;
    }


    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 int main(){
   string s;
   cin >> s;
   int  n = s.size();
   
   for(int mask = 0;mask < (1 << n - 1);++mask){
     int t = s[0] - '0';
     char c[3];
     for(int i = 0;i < n - 1;++i){
       if(mask & (1 << i)){
         t += s[i + 1] - '0';
         c[i] = '+';
       }else{
         t -= s[i + 1] - '0';
         c[i] = '-';
       }
     }
     if(t == 7){
       for(int j = 0; j < n - 1;++j){
         cout << s[j] << c[j];
       }
       cout << s[n - 1] << "=7" <<endl;
       break;
     }
   }
   return 0;
 }

Measured memory_bytes: 256
N = int(input())
ans = [0] * (N+1)
for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= n <= N:
                ans[n] += 1
print(*ans[1:], sep='\n')


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

const int MAXW = 1e5 + 5;
ll dp[MAXW], w[105], v[105];

int main() {
    int n, W;
    cin >> n >> W;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];

    for(int i = 1; i <= n; i++) {
        for(int we = W; we >= 0; we--) {
            if(we - w[i] < 0)
                break;
            dp[we] = max(dp[we], dp[we - w[i]] + v[i]);
        }
    }
    ll mx = 0;
    for(int i = 0; i <= W; i++)
        mx = max(mx, dp[i]);
    cout << mx << endl;
}

Measured memory_bytes: 1024
MOD = 10**9+7

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

# i 番目までに j 枚使ったときの場合の数
dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1

upper = 0
for i in range(1, N+1):
    for j in range(1, K+1):
        dp[i-1][j] += dp[i-1][j-1]
    upper += a[i-1]
    for j in range(min(upper, K)+1):
        if j > a[i-1]:
            dp[i][j] = dp[i-1][j] - dp[i-1][j-a[i-1]-1]
        else:
            dp[i][j] = dp[i-1][j]
        dp[i][j] %= MOD

print((dp[N][K]+MOD)%MOD)

Measured memory_bytes: 119532
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x[500005],y[10],z[10];
ll t,i,j;
ll sum;
ll p,q;
ll a,n;

int main (){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		if(x[i] < 0)a++;
	}
		for(i=0;i<n;i++){
			sum += abs(x[i]);
		}
	for(i=0;i<n;i++){
		x[i] = abs(x[i]);
	}
	if(a % 2 == 1){
		sort(x,x+n);
		sum -= 2 * x[0];
	}
	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

p = [0] * N
m = [0] * N

for i in range(N):
    p[i] = A[i] + i + 1
    m[i] = i + 1 - A[i]

from collections import Counter

cp = Counter(p)
cm = Counter(m)

ans = 0

for x, y in cp.items():
    ans += cm[x] * y

print(ans)

Measured memory_bytes: 63208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;

const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 2e5+10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;
bool isPowerOfTwo (ll x)
{
    return x && (!(x&(x-1)));
}


void solve() {

    string s1,s2;
    cin>>s1>>s2;
    ll a,b;
    cin>>a>>b;

    string s;cin>>s;
    if(s == s1)
        a--;
    else if(s== s2)
        b--;
    cout<<a <<" "<<b<<endl;


}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    fio
    int t=1;
    if(imp) cin>>t;

    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }

}


Measured memory_bytes: 3612
function Main(input) {
    input = input.trim().split("\n");
    tmp = input[0].split(" ");
    var N = parseInt(tmp[0],10);
    var A = parseInt(tmp[1],10);
    var B = parseInt(tmp[2],10);
    var C = parseInt(tmp[3],10);
    var D = parseInt(tmp[4],10);
    var S = input[1];
    var output = "Yes";

    if(C < D){
        for(var i = A; i < C; i++){
            if(S[i-1] == "#" && S[i] == "#"){
                output = "No";
                break;
            }
        }
        for(var i = B; i < D; i++){
            if(S[i-1] == "#" && S[i] == "#"){
                output = "No";
                break;
            }
        }
    }
    else{
        var NG = true;
        for(var i = B-1; i < D; i++){
            if(S[i-1] == "." && S[i] == "." && S[i+1] == "."){
                NG = false;
            }
        }
        if(NG){
            output = "No";
        }
        else{
            for(var i = A; i < C; i++){
                if(S[i-1] == "#" && S[i] == "#"){
                    output = "No";
                    break;
                }
            }
            for(var i = B; i < D; i++){
                if(S[i-1] == "#" && S[i] == "#"){
                    output = "No";
                    break;
                }
            }
        }
    }
    console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# coding: utf-8
# Your code here!
import sys
def input():
    return sys.stdin.readline().strip()
    
N = int(input())
s = [int(input()) for _ in range(N)]
s.sort()
i = 0

if sum(s) % 10 == 0:
    while True:
        if i == len(s):
            print(0)
            exit()
        elif s[i] % 10 == 0:
            i += 1
        else:
            s[i] = 0
            break
print(sum(s))

Measured memory_bytes: 38384
### main

loop do
  gn, dur = gets.split.map(&:to_i)
  break if (gn | dur) == 0

  nts = []
  tsis = []

  gn.times do
    tsi = []
    loop do
      ds = gets.split.map(&:to_i)
      tsi += ds
      if tsi.last == 0
        tsi.pop
        break
      end
    end
    nts << tsi.length
    tsis << tsi
  end
  gets
  #p nts
  #p tsis

  st = gn.times.map{:consuming}
  rem = gn.times.map{|i| tsis[i].first}
  ti = gn.times.map{0}
  
  chgr = -1
  q = []
  wt = 0

  dur.times do
    for i in (0...gn)
      case st[i]
      when :consuming
        rem[i] -= 1
        if rem[i] == 0
          st[i] = :queued
          q << i
        end
      when :queued
        wt += 1
      when :charging
        rem[i] -= 1
        if rem[i] == 0
          st[i] = :consuming
          ti[i] = (ti[i] + 1) % nts[i]
          rem[i] = tsis[i][ti[i]]
          chgr = -1
        end
      end
    end

    if chgr < 0 && ! q.empty?
      i = q.shift
      st[i] = :charging
      ti[i] = (ti[i] + 1) % nts[i]
      rem[i] = tsis[i][ti[i]]
      chgr = i
    end
  end

  puts wt
end

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	int mn = sum;
	for (int i = 0; i<N; i++) {
		if (A[i] % 10 != 0 && A[i]<mn) {
			mn = A[i];
		}
	}

	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - mn << endl;
	}
	return 0;
}

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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

long double f(long double a, long double b, long double theta){
    if(theta > PI/2.0 - EPS) return 0.0;
    long double ret;
    if(a*tan(theta) <= b)
        ret = a*a*b - a*a*a*tan(theta)/2.0;
    else
        ret = b*b/tan(theta)*a/2.0;
    return ret;
}

void solve(){
    long double ok = PI/2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++){
        long double mid = (ok+ng)/2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok/PI*180 << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> x;
    solve();
    return 0;
}

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

int main() {
    string S, T;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == '?') {
            T += 'D';
        }
        else {
            T += S.at(i);
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3924
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];

		for(int i=0; i<n; i++){
			for(int s=0; s<m; s++){
				A[i][s] = scan.nextInt();
			}
		}
		for(int i=0; i<m; i++){
			b[i] = scan.nextInt();
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				c[i] += A[i][j]*b[j];
			}
			System.out.println(c[i]);
		}
	}
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int five = 0;
    int seven = 0;
    if (a == 5) {
        five++;
    } else {
        seven++;
    }
    if (b == 5) {
        five++;
    } else {
        seven++;
    }
    if (c == 5) {
        five++;
    } else {
        seven++;
    }
    cout << (five == 2 && seven == 1 ? "YES" : "NO") << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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

int main(){
  bool prime[1000000];
  prime[0]=false;prime[1]=false;
  for(int i=2;i<=999999;i++){
    prime[i]=true;
  }

  for(int i=2;i<=sqrt(999999);i++){
    if(prime[i]){
      for(int j=2;j*i<=999999;j++){
        prime[j*i]=false;
      }
    }
  }
  int n;
  while(cin>>n){
    int cnt=0;
    for(int i=2;i<=n;i++){
      if(prime[i])cnt++;
    }
    cout<<cnt<<endl;
  }
}



Measured memory_bytes: 4044
#include <iostream>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
using namespace std;

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

  int a, b, k;
  cin >> a >> b >> k;
  FOR(i, a, min(a+k, b+1))  cout << i << endl;
  FOR(i, max(a+k, b-k+1), b+1) cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i<=n-2){
            cout<<a.at(i)<<" ";
        }
        else{
            cout<<a.at(i)<<endl;
        }
    }
    
}



Measured memory_bytes: 3088
#include<stdio.h>
int main(void)
{
	int n,i;
	long long x[87];
	scanf("%d",&n);
	x[0]=2;
	x[1]=1;
	for(i=2;i<=n;i++){
		x[i]=x[i-1]+x[i-2];
	}
	printf("%lld\n",x[n]);
	return 0;	
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			char[] s = sc.next().toCharArray();
			if (s.length == 1 && s[0] == '#')
				break;
			solve(s);
		}
	}

	void solve(char[] s) {
		int[] v = new int[s.length];
		for (int i = 0; i < s.length; ++i) {
			v[i] = s[i] - 'A';
		}
		boolean[] valid = new boolean['z' - 'A' + 1];
		for (int i = 0; i < v.length; ++i) {
			valid[v[i]] = true;
		}
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] g = new ArrayList['z' - 'A' + 1];
		for (int i = 0; i < g.length; ++i) {
			g[i] = new ArrayList<>();
		}
		int e_sz = 0;
		for (int i = 0; i + 1 < v.length; ++i) {
			if (!g[v[i]].contains(v[i + 1])) {
				g[v[i]].add(v[i + 1]);
				++e_sz;
			}
		}

		if (v.length <= 2) {
			System.out.println("No Results");
			return;
		}
		int[] indegree = new int[g.length];
		int[] outdegree = new int[g.length];
		for (int i = 0; i < g.length; ++i) {
			if (!valid[i])
				continue;
			outdegree[i] = g[i].size();
			for (int dst : g[i]) {
				++indegree[dst];
			}
		}

		int d = 0;
		for (int i = 0; i < g.length; ++i) {
			if (!valid[i])
				continue;
			if (indegree[i] - outdegree[i] > 0)
				d += indegree[i] - outdegree[i];
		}

		if (d == 0) {
			System.out.println(e_sz + 1);
			return;
		}

		if (d == 1) {
			System.out.println(semi_Eulerian(g, v, valid, indegree, outdegree, e_sz));
			return;
		}

		if (d >= 2) {
			System.out.println(e_sz + d);
			return;
		}

	}

	int semi_Eulerian(ArrayList<Integer>[] g, int[] v, boolean[] valid, int[] indegree, int[] outdegree, int e_sz) {
		if (e_sz + 1 < v.length) {
			return e_sz + 1;
		}
		if (e_sz + 1 != v.length) {
			throw new AssertionError();
		}
		int src = -1;
		int dst = -1;
		for (int i = 0; i < g.length; ++i) {
			if (!valid[i])
				continue;
			if (indegree[i] - outdegree[i] > 0)
				dst = i;
			else if (indegree[i] - outdegree[i] < 0)
				src = i;
		}
		if (src == v[0] && dst == v[v.length - 1]) {
			if (dfs(g, new boolean[g.length][g.length], src, 0, e_sz) > 1)
				return v.length;
			return v.length + 1;
		} else {
			return v.length;
		}
	}

	int dfs(ArrayList<Integer>[] g, boolean[][] vis, int cur, int num, int e_sz) {
		if (e_sz == num)
			return 1;
		int sum = 0;
		for (int dst : g[cur]) {
			if (vis[cur][dst])
				continue;
			vis[cur][dst] = true;
			sum += dfs(g, vis, dst, num + 1, e_sz);
			if (sum >= 2)
				return sum;
			vis[cur][dst] = false;
		}
		return sum;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 30452
s = list(input())
ans = "Yes"
for i in range(len(s)):
  if i%2 == 0 and s[i] != "h":
    ans = "No"
  elif i%2 == 1 and s[i] != "i":
    ans = "No"
if len(s)%2 == 1:
  ans = "No"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
  	cin>>n;
  	double sum=0.0;
  	for(int i=0; i<n; i++){
  	    cin>>x;
  	    sum+= (1.0/(double)x);
    }
  	
     cout<<setprecision(16)<<1.0/sum<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
struct custom {
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=(y>>1);
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,k;
    cin>>n>>k;
    ll arr[n+1],dp[n+1];
    for(i=1;i<=n;i++)cin>>arr[i];
    dp[1]=0;
    for(i=2;i<=n;i++)
    {
        dp[i]=inf;
        for(j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, 0, n) cin >> h[i];

  vector<int> dp(n, 1e9);
  dp[0] = 0;

  rep(i, 1, n) {
    if (i == 1)
      dp[i] = abs(h[i] - h[i - 1]);
    else {
      int min_val = 1e9;
      rep(j, 1, min(i + 1, k + 1)) {
        chmin(min_val, dp[i - j] + abs(h[i] - h[i - j]));
      }
      chmin(dp[i], min_val);
    }
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024