akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,sum=0;

int main(){
    cin>>N;
    int l[N],r[N];
    rep(i,N){
        cin>>l[i]>>r[i];
        sum+=r[i]-l[i]+1;
    }
    out(sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,D;
  cin>>N>>D;
  VL X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  int ans=0;
  rep(i,N){
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D) ans++;
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

struct UnionFind {
  vector< int > data;
  
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
  
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main () {
  cin.tie(0);
  cout << setprecision(10);

  vi a(3), b(3);
  REP(i, 3) {
    cin >> a[i] >> b[i];
  }
  map<int, int> m;
  REP(i, 3) {
    m[a[i]]++;
    m[b[i]]++;
  }
  int one = 0, two = 0;
  MFOR(i, m) {
    if(i->second == 1) {
      one++;
    } else {
      two++;
    }
  }
  if(one == 2 && two == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        llong n;
        read n;
        echo lcm(n,2ll) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(char c)
{
	int a,b;
	cin>>a>>b;
	for(int n=1;n<=a+b+1;n++)
	{
		cin>>c;
		if(n==a+1)
		{
			if(c!='-')
			{
			cout<<"No\n";
			return 0;
		}
		}
		else if(c<'0'||c>'9')
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        int count = 0;
        for (int i=100; i>0; i--) {
            if (A%i != 0) {
                continue;
            }
            if (B%i != 0) {
                continue;
            }
            count++;
            if (count == K) {
                System.out.println(i);
                break;
            }
        }
    }

}


Measured memory_bytes: 22996
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2 == 1:
    for i in ac:
        if i == 0:
            if ac[i] != 1:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print((2 ** (n // 2)) % (10 ** 9 + 7))
else:
    for i in ac:
        if i == 0:
            if ac[i] != 0:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print((2 ** (n // 2)) % (10 ** 9 + 7))

Measured memory_bytes: 14812
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll d, n;
    cin >> d >> n;
    ll count = 0;
    for(ll x = 1; ; x++){
        ll dcount = 0;
        ll x2 = x;
        while(x2 % 100 == 0){
            dcount++;
            x2 /= 100;
        }
        count += (dcount == d);
        if(count == n){
            cout << x << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    ll ans=0;
    rep(i,n){
        cin>>a[i];
    }

    rep(i,n-1){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<pair<ll,ll>> vep;
const ll mod=998244353;
const ll INF=1e15;
const int BIG=1e7;

int main(){
    ll ans=1;
    int N; cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++) d.at(i)=0;
    for(int i=0;i<N;i++){
        int x; cin>>x;
        if(i*x==0 && i+x>0) {ans=0; break;}
        d.at(x)++;
    }

    for(int i=1;i<N;i++){
        int K=d.at(i);
        if(K==0) {
            while(d.at(i)==0) {i++; if(i==N) break;}
            if(i==N) break;
            if(i!=N) ans=0;
        }

        else{
            for(int j=0;j<K;j++) {ans*=d.at(i-1); ans=(ans%mod);}
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
using namespace std;
static const int MAX = 1001;

void lcs(string X, string Y) {
	int dp[MAX][MAX];  
	int i,j;

	int xLength = X.size();
	int yLength = Y.size();


	// initialize dp[][]
	for (i = 1; i <= xLength; i++)
		dp[i][0] = 0;
	for (i = 1; i <= yLength; i++)
		dp[0][i] = 0;

	for (i = 1; i <= xLength; i++){
		for (j = 1; j <= yLength; j++){
			// Because the original string is 0-based , so subtracted from 1
			if (X[i - 1] == Y[j - 1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			}else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	// testing code: print out the dp[][]
	// cout << "j";
	// for (j = 1; j <= yLength; j++)
	// 	cout << ' ' << j ;
	// cout << endl;
		

	// for (i = 1; i <= xLength; i++){
	// 	cout << i << '.';
	// 	for (j = 1; j <= yLength; j++){
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }

	cout << dp[xLength][yLength] << endl;
}

int main() {
	int n , i;
	string X, Y;

	cin >> n;
	for (i = 0 ; i < n; i++ ) {
		cin >> X;
		cin >> Y;
		lcs(X, Y);
	}

	return 0;

}

Measured memory_bytes: 6948
def swap_range(li, b, e, t):
    """Swap element (b + k) and element (t + k) (0 <= k < e-b).

    >>> li = ['1', '2', '3', '4', '5', '6', '7', '8']
    >>> swap_range(li, 1, 3, 5)
    >>> " ".join(li)
    '1 6 7 4 5 2 3 8'
    >>> swap_range(li, 3, 5, 4)
    >>> " ".join(li)
    '1 6 7 5 2 4 3 8'
    """
    for k in range(e-b):
        li[b+k], li[t+k] = li[t+k], li[b+k]


def run():
    n = int(input())
    li = input().split()
    assert(n == len(li))

    q = int(input())
    for _ in range(q):
        b, e, t = [int(x) for x in input().split()]
        swap_range(li, b, e, t)

    print(" ".join(li))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
const int N = 6003;

struct ban
{
    int a, b;
};
bool operator<(const ban& a, const ban& b)
{
    return a.a < b.a;
}

int n, m;
ban a[N];

int dp[N];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &a[i].a, &a[i].b);
    sort(a, a + n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = m - 1; j >= 0; --j)
        {
            dp[j + a[i].a] = max(dp[j + a[i].a], dp[j] + a[i].b);
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
        ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;

void Main()
{
	int a;
	std::cin >> a;
	std::cout << 3 * a * a << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
  long int n,k,i,ans,cnt=0;
  scanf("%ld %ld",&n,&k);
  ans=pow(n/k,3);
  if(k%2==0){
    for(i=1;i<=n;i++){
      if(i%k==k/2) cnt++;
    }
    ans+=pow(cnt,3);
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int H,A;
	cin>>H>>A;
	int x=H/A;
	int y=H%A;
	if(y>0)
	{cout<<x+1;
	}
	else{
		cout<<x;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long INF = 1000000000000000L;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        
        long min = INF;
        for (int i = 0; i < n - k+1; i++) {
            min = Math.min(min, array[i+k-1] - array[i]);
        }
        System.out.println(min);
    }
}


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

using namespace std;

int main()
{
   int n,i;

  

   cin>>n;

   long long res = 0;

   long b[n-1];

   for(i = 0;i < n-1;i++)
   {
     cin>>b[i];
   }
   res += b[n-2];
   for(i = n-3;i >= 0;i--)
   {
      res += min(b[i],b[i+1]);
   }
   res += b[0];
   cout<<res<<"\n";

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <functional>
#define REP(i, n) for(int i = 0; i < n; i++)
//using ll = long long;
using namespace std;
const int mod = 1000000007;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int s,w;
  cin >> s >> w;
  
  if (s <= w){
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  

  
      
}


Measured memory_bytes: 3652
N = int(input())
countans = 1
if(N < 105):
  print(0)
elif(N < 107):
    print(1)
else:
    for i in range(107, N+1, 2):
        count = 1
        for j in range(1, int(N/2)):
            if(i%j == 0):
                count += 1
        if(count == 8):
            countans += 1
    print(countans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n,C;
  cin>>n>>C;
  vi s(n);
  vi t(n);
  vi c(n);
  rep(i,n){
    cin>>s[i]>>t[i]>>c[i];
    c[i]--;
    s[i]--;t[i]--;
  }
  vii rec=vii(C,vi(d_5+10,0));
  rep(i,n){
    rec[c[i]][s[i]]++;
    rec[c[i]][t[i]]--;
  }
  rep(j,C){
    rep(i,d_5+10-1){
      rec[j][i+1]+=rec[j][i];
    }
  }
  /*rep(j,C){
    rep(i,d_5+10-1){
      rec[j][i+1]+=rec[j][i];
    }
  }*/
  vii rec2=vii(C,vi(2*d_5+20,0));
  rep(j,C){
    rep(i,d_5+10-1){
      rec2[j][2*i]=rec[j][i];
      rec2[j][2*i+1]=rec[j][i];
    }
  }
  rep(i,n){
    if(s[i]*2-1<0)continue;
    if(rec2[c[i]][max(s[i]*2-1,0)]>0)continue;
    rec2[c[i]][max(s[i]*2-1,0)]++;
  }
  /*rep(i,C){
    rep(j,10){
      cout<<rec2[i][j]<<" ";
    }
    cout<<endl;
  }*/
  int ans=0;
  rep(i,2*d_5+10){
    int tmp=0;
    rep(j,C){
      tmp +=rec2[j][i];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,m,v,p;cin>>n>>m>>v>>p;
  vector<ll> a(n);
  rep(i, n)cin>>a[i];
  sort( a.rbegin(), a.rend() );

  int max=n, min=-1, mid;
  while(max-min>1){
    mid = (max+min)/2;
    if(a[mid]+m<a[p-1]){
      max=mid;
      continue;
    }

    ll used = m*(p-1+1);
    used += (n-1-mid)*m;
    for(int i=p-1; i<mid; i++) used+=a[mid]+m-a[i];

//cout<<mid<<' '<<used<<endl;

    if(used>=v*m)min=mid;
    else max=mid;
  }

  cout<<min+1;

  return 0;
}

Measured memory_bytes: 1152
n, k, q = [int(i) for i in input().split()]
fake_score = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    fake_score[a-1] += 1
# each time other earn a score, i deduct a score
# total_score is q
for i in range(n):
    fake_score[i] = k - (q - fake_score[i])
    if fake_score[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7804
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a, b;
ll h[100010];

bool check(int k) {
    ll d = 0;
    ll p = a - b;
    for (int i = 0; i < n; i++) {
        ll r = h[i] - b * k;
        if (r > 0) {
            d += (r + p - 1) / p;
        }
    }
    return d <= k;
}

int solve() {
    int lb = 0, ub = inf;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (check(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub;
}

void input() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> h[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1024
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int mod = 1e9 + 7;
const int Inf = (int)2e9 + 5;
const ll  Lnf = (ll)2e18 + 5;
const int N   = 4e5 + 5;
int solve() 
{
	
	long long n,m;
	scanf("%lld%lld", &n,&m);
	ll x = min(n%m,abs(n%m-m));
	printf("%lld\n",x);

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 256
// ABC099_B

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    
    vector<int> v(1000);
    v[0] = 0;
    for(int i = 1; i <= 999; i++) {
        v[i] = v[i - 1] + i;
    }
    
    for(int i = 1; i < 999; i++) {
        int tmp = v[i + 1] - v[i];
        if(tmp == b - a) {
            cout << v[i] - a << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

class SEGTREE {
    unsigned int n;
    ll dflt;
    vector<ll> dat;

    static ll op(const ll a, const ll b) {
        return max(a, b);
    }

    bool f(const unsigned int id, const ll a){
        return dat[id] >= a;
    }

public:
    SEGTREE(unsigned long _n, ll _a) : n(1), dflt(_a) {
        while (n < _n) {n *= 2;}
        dat.resize(n * 2, dflt);
    }

    void update(unsigned int k, ll a) {
        k += n;
        dat[k] = a;
        while (k > 0) {
            k >>= 1;
            dat[k] = op(dat[k<<1], dat[(k<<1)|1]);
        }
    }

    void init(vector<ll> &v) {
        for (int i = 0; i < (int)v.size(); ++i) dat[i + n] = v[i];
        for (int i = n - 1; i >= 1; --i) {
            dat[i] = op(dat[i * 2], dat[i * 2 + 1]);
        }
    }

    ll query(unsigned int l, unsigned int r) {
        ll res_left = dflt, res_right = dflt;
        l += n; r += n;
        for ( ; l < r; l >>= 1, r >>= 1){
            if(l&1){
                res_left = op(res_left, dat[l]);
                if((++l) == r) break;
            }
            if(r&1){
                res_right = op(dat[r ^ 1], res_right);
            }
        }
        return op(res_left, res_right);
    }

    unsigned int max_right_search(unsigned int id, ll a){
        while(id < n) id = (id<<1) | !f(id<<1, a);
        return id - n;
    }

    unsigned int max_right(unsigned int l, unsigned int r, ll a){
        //[l, r)内のindexであるjであって、query(l, j) < a <= query(l, j + 1)なるものを求める
        //つまり、j >= l かつ dat[j] >= a である最小の数jを求める(func = maxの場合)
        unsigned int see_after = r + n;
        l += n;
        for (unsigned int tr = r + n ; l < tr; l >>= 1, tr >>= 1){
            if(l&1){
                if(f(l, a)) return max_right_search(l, a);
                if((++l) == tr) break;
            }
            if((tr&1) && f(tr ^ 1, a)) see_after = tr ^ 1;
        }
        return see_after == r + n ? r : max_right_search(see_after, a);
    }

    //単項にアクセスする[]だが、書き換え厳禁
    //一応後でinitすれば書き換えてもよさそうだが…
    ll &operator[](int k) { return dat[k + n]; }
};
int main() {
    cin>>N>>Q;
    vec a(N);
    rep(i, N) scanf("%lld", &a[i]);
    SEGTREE seg(N, 0);
    seg.init(a);
    rep(_, Q){
        int t, x, v, l, r;
        scanf("%d", &t);
        if(t == 1){
            scanf("%d%d", &x, &v); --x;
            seg.update(x, v);
        }else if(t == 2){
            scanf("%d%d", &l, &r);
            printf("%lld\n", seg.query(l - 1, r));
        }else{
            scanf("%d%d", &x, &v); --x;
            printf("%u\n", seg.max_right(x, (unsigned int) N, v) + 1);
        }
    }
}



Measured memory_bytes: 9120
/*
Author: QAQ-Automaton
LANG: C++
PROG: a.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const signed inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>int dcmp(T a,T b){return a>b;}
template<int *a>int cmp_a(int x,int y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	inline void read (signed &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}

	inline void read (long long &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	inline void read (char &x) {
		x=gc();
	}
	inline void read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc();
		*x=0;
	}
	template<typename A,typename ...B>
	inline void read(A &x,B &...y){
		read(x);read(y...);
	}
	// print a signed integer
	inline void write (signed x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}

	inline void write (long long x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	inline void write (char x) {
		putc(x);
	}
	inline void write(const char *x){
		while(*x){putc(*x);++x;}
	}
	inline void write(char *x){
		while(*x){putc(*x);++x;}
	}
	template<typename A,typename ...B>
	inline void write(A x,B ...y){
		write(x);write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
int main(){
#ifdef QAQAutoMaton 
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	ll a,b,c;
	read(a,b,c);
	if(a&1 && b&1 && c&1){
		write(min(a*b,min(a*c,b*c)),'\n');
	}
	else write("0\n");

	return 0;
}



Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#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 pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    //解説あり
    int Q;
    cin >> Q;
    rep(i, 0, Q) {
        ll A, B;
        cin >> A >> B;
        ll X = A*B;
        if (A>B) swap(A, B);

        ll l = 0, r = A+B-1;
        while (r-l>1) {
            ll m = (r+l)/2;
            ll k = (m+1)/2;
            ll mx = 0;
            if (m>=1 && m<2*(A-1)) mx = k*(m-k+1);
            else if (m<2*(B-1)) mx = (k+1)*(m-k+1);
            else mx = k*(m-k+2);

            if (mx<A*B) l = m;
            else r = m;
            
        }

       
      
        cout << l << endl;
    }

    return 0;
}





Measured memory_bytes: 3580
import math
a, b, x = map(int, input().split())

if a ** 2 * b >= x * 2:
  print(math.degrees(math.atan(b ** 2 * a / (x * 2))))
else:
  r = a ** 2 * b - x
  print(math.degrees(math.atan(r * 2 / a ** 3)))

Measured memory_bytes: 3188
N =int(input())
AAA = map(int,input().split())
AA = list(AAA)
total = 3**len(AA)
total2 = 0
total3 = 0
for i in AA:
  if i%2==0:
    total2 +=1
total3 = 2**total2
ans = total - total3
print(ans)

Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    char c;
    cin >> c;

    if(c=='a' || c=='b' || c=='c' || c=='d' || c=='e' || c=='f' || c=='g' || c=='h' || c=='i' || c=='j' || c=='k' || c=='l' || c=='m' || c=='n' || c=='o' || c=='p' || c=='q' || c=='r' || c=='s' || c=='t' || c=='u' || c=='v' || c=='w' || c=='x' || c=='y' || c=='z')
        cout << 'a' << endl;
    else
        cout << 'A' << endl;

    return 0;
}


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

void init() {
  cin.tie(nullptr);               // Do not flush "cout" when processing "cin".
  // cout << "hogehoge" << '\n';  // "endl" executes flush in addition to line break.
  // ios::sync_with_stdio(false); // Be careful when using both "cin/cout" and "scanf/printf".
}

int main() {
  init();
  int n;
  cin >> n;

  const int mod = 1e9+7;

  // 全パターン
  // = 数列のどの項も、0-9 の数字である数列
  // パターン数 : 10**n
  ll a = 1;
  // Ai=0 なる i が存在しないような数列
  // = 数列のどの項も 1-9 の数字である数列
  // パターン数 : 9**n
  ll b = 1;
  // Ai=9 なる i が存在しないような数列
  // = 数列のどの項も 0-8 の数字である数列
  // パターン数 : 9**n
  ll c = 1;
  // Ai=0 なる i も Ai=9 なる i も存在しないような数列
  // = 数列のどの項も 1-8 の数字である数列
  // パターン数 : 8**n
  ll d = 1;
  for (int i = 0; i < n; i++) {
    a = a * 10 % mod;
    b = b * 9 % mod;
    c = c * 9 % mod;
    d = d * 8 % mod;
  }

  ll ans = (a - b - c + d) % mod;
  // 例えば n=20 の場合 (a-b-c+d) % mod < 0 となる (ans = -370140969)
  // そのため、mod を必要な回数だけ加算して正の数にする
  //
  // cout << "a: " << a << "\n";
  // cout << "b: " << b << "\n";
  // cout << "c: " << c << "\n";
  // cout << "d: " << d << "\n";
  // cout << "ans: " << ans << "\n";
  while (ans < 0) {
    ans = ans + mod;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ans = 0,a[30],b[30],c[30];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		cin >> b[i];
		ans += b[i];
	}
	for(int i = 0;i < n - 1;i++) cin >> c[i];
	for(int i = 0;i < n - 1;i++){
		if(a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
	}
	cout << ans << endl;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int N, M, S;
struct edge{
  int v, money;
  ll cost;
  edge(){
  }
  edge(int v, int m, ll c):v(v), money(m), cost(c){}
  bool operator < (const edge r) const{
    return cost < r.cost;
  }
  bool operator > (const edge r) const{
    return cost > r.cost;
  }
};
vector<vector<vector<edge>>> g;

vector<vector<ll>> dijkstra(int start, int money){
  vector<vector<ll>> dist(N, vector<ll>(2501, INF));
  priority_queue<edge, vector<edge>, greater<edge>> pq;
  pq.push(edge(start, money, 0));
  dist[start][money] = 0;
  while(!pq.empty()){
    edge e = pq.top(); pq.pop();
    int v = e.v, m = e.money;
    ll cost = e.cost;
    if(cost > dist[v][m]) continue;
    for(auto ne : g[v][m]){
      int nv = ne.v, nm = ne.money;
      ll ncost = cost + ne.cost;
      if(ncost < dist[nv][nm]){
        pq.push(edge(nv, nm, ncost));
        dist[nv][nm] = ncost;
      }
    }
  }
  return dist;
}
int main(){
  cin >> N >> M >> S;
  g.resize(N, vector<vector<edge>>(2501));
  S = min(S, 2500);
  REP(i, M){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    FOR(j, a, 2501){
      g[u][j].push_back(edge(v, j-a, b));
      g[v][j].push_back(edge(u,j-a, b));
    }
  }
  REP(i, N){
    int c, d;
    cin >> c >> d;
    REP(j, 2501-c){
      g[i][j].push_back(edge(i, j+c, d));
    }
  }
  auto dist = dijkstra(0, S);
  FOR(i, 1, N){
    ll ans = INF;
    REP(j, 2501){
      ans = min(ans, dist[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 23944
void main()
{
    string s = rdStr;

    writeln(s[0..4], " ", s[4..$]);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

int main(){
    int n;
    cin>>n;
    vector<ll> l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    int ans=0;
    for(int i=0;i<n-2;++i){
        for(int j=i+1;j<n-1;++j){
            for(int k=j+1;k<n;++k){
                if((l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i])&&
                (l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[i]+l[k]>l[j])){
                    ++ans;
                }

            }
        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

//ベルマンフォード法
int V,E; //Vは頂点数、Eは辺数
struct edge {int from, to, cost;};
edge es[5010];
int d[2510]; //最短距離
bool roop = false;

bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];
vi to[2505],rto[2505];
 
void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}

void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

void init(){
    dfs(0); rdfs(V-1);
    rep(i,V) ok[i] = false;
    rep(i,V){
        if(reachableFrom1[i] && reachableToN[i]) ok[i] = true;
    }
}

void shortest_path(int s){
    rep(i,V) d[i]=INF;
    d[s]=0;
    int cnt=0;
    while(true){
        bool update = false;
        rep(i,E){
            edge e = es[i];
            if(!ok[e.from]||!ok[e.to]) continue;
            if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
                d[e.to] = d[e.from]+e.cost;
                update = true;
            }
        }
        if(!update) break;
        cnt++;
        if(cnt>V){
            roop = true;
            break;
        }
    }
}

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

    cin >> V >> E;
    int p; cin >> p;
    rep(i,E){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        c-=p; c=-c;
        es[i].from=a; 
        es[i].to=b;
        es[i].cost=c;
        to[a].pb(b);
        rto[b].pb(a);
    }

    init();
    shortest_path(0);
    if(roop) cout << -1 << endl;
    else if(d[V-1]>0) cout << 0 << endl;
    else cout << -d[V-1] << endl;

}

Measured memory_bytes: 768
(let* ((n (read))
    (a (make-array n :initial-element 0))
    (cnt (make-array 1000005 :initial-element 0))
    (ans 0))
    (dotimes (i n)
        (incf (aref a i) (read))
    )
    (loop for x across a do
        (if (not (= (aref cnt x) 0))
            (setf (aref cnt x) 2)
            (loop for i from x by x while (< i 1000005) do
                (incf (aref cnt i))
            )
        )
    )

    (loop for x across a do
        (if (= (aref cnt x) 1)
        (incf ans))
    )
    (princ ans)
)

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

const int N = 2005;
const ll mod = 1e9+7;
ll ncr[N][N];

void doncr(){
	for(int i=1; i<N; ++i){
		ncr[0][i] = 0;
	}
	for(int i=0; i<N; ++i){
		ncr[i][0] = 1;
	}
	for(int i=0; i<N; ++i){
		ncr[i][i] = 1;
	}
	for(int i=1; i<N-1; ++i){
		for(int j=1; j<i; ++j){
			ncr[i][j] = (ncr[i-1][j-1] + ncr[i-1][j]) % mod;
		}
	}
}

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

	int n,k;
	cin>>n>>k;
	int red = n - k;
	for(int i=1; i<=k; ++i){
		// do this in i moves:
		// ncr( red + 1, i) * ncr(k-1 i-1)
		ll ans = ncr[red+1][i];
		ans %= mod;
		ans *= (ncr[k-1][i-1] % mod);
		ans %= mod;
		cout<<ans<<'\n';
	}
	return 0;
}


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

int n, k, x;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	x = (n - 1) * (n - 2) / 2;
	if(k > x) {
		cout << -1;
		return 0;
	}
	cout << n - 1 + x - k << '\n';
	for (int i = 2; i <= n; i++)
		cout << 1 << ' ' << i << '\n';
	x -= k;
	for (int i = 2; i <= n; i++)
		for (int j = i + 1; j <= n && x; j++, x--)
			cout << i << ' ' << j << '\n';
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	scanf("%d", &N);



	printf("%.23f\n", (N - N / 2) / (double)N);

	return 0;
}


Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n = sc.read();
    let p: Vec<usize> = sc.read_vec(n);
    let sum: usize = p.iter().sum();
    let max = *p.iter().max().unwrap();
    println!("{}", sum - max / 2);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .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 chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x = [a, b, c, d, e]
#print(min(x))
#print(max(x))
if (max(x) - min(x)) <= k:
    print("Yay!")
else :
    print(":(")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int longestIncreasingSubsequence(const vector<int>& a)
{
    int n = a.size();
    vector<int> dp(n, INT_MAX);
    for(int i=0; i<n; ++i){
        vector<int>::iterator it = upper_bound(dp.begin(), dp.end(), a[i]);
        *it = a[i];
    }
    return lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin();
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        -- a[i];
    }

    int ret = 0;
    for(int i=0; i<n; ++i){
        if(i < a[i])
            continue;

        vector<int> b(n);
        for(int j=0; j<n; ++j)
            b[(j+i)%n] = (a[j] + i) % n;

        vector<int> v;
        for(int j=0; j<b[0]; ++j){
            if(b[j] > b[0])
                v.push_back(b[j]);
        }
        ret = max(ret, longestIncreasingSubsequence(v) + 1);
    }

    ret = min(n/2, ret + k);
    cout << ret << endl;

    return 0;
}

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

int main(){
    ll n, ans = 0;
    cin >>n;
    vector<int> L(n);
    rep(i,n) cin >> L.at(i);
    sort(L.begin(), L.end());
    for (ll low = 0; low < n - 2; low++){
        for (ll mid = low + 1; mid < n; mid ++){
            auto itr = lower_bound(L.begin(), L.end(), L[low] + L[mid]);
            ll tmp = distance(itr, L.end());
            ans += n - 1 - tmp - mid;
        }
    }
    cout << ans << endl;
    return 0;
}

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

char a[100], b[100], c[100];
int main()
{
    scanf("%s %s %s",a,b,c);
    int la = strlen(a);
    int lb = strlen(b);
    printf("%s",(a[la-1]==b[0]?(b[lb-1]==c[0]?"YES":"NO"):"NO"));
}

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

using namespace std;

int main(){

    int A, B;
    cin >> A >> B;
    string allWhite = "";
    string allBlack = "";
    string wb = "";
    for(int i = 0; i < 100; i++){
        allWhite += ".";
        allBlack += "#";
        if(i % 2 == 0){
            wb += ".";
        }
        else{
            wb += "#";
        }
    }

    A--;
    B--;
    vector<string> ans(100);
    int line = 0;
    ans[line] = allBlack;
    line++;
    while(A > 0){
        string temp = wb;
        if(A >= 50){
            A -= 50;
        }
        else{
            for(int i = 0; i < 100; i += 2){
                temp[i] = '#';
                A++;
                if(A == 50){
                    A = 0;
                    break;
                }
            }
        }
        ans[line] = temp;
        line++;
        ans[line] = allBlack;
        line++;
    }

    ans[line] = allWhite;
    line++;
    while(B > 0){
        string temp = wb;
        if(B >= 50){
            B -= 50;
        }
        else{
            for(int i = 1; i < 100; i += 2){
                temp[i] = '.';
                B++;
                if(B == 50){
                    B = 0;
                    break;
                }
            }
        }
        ans[line] = temp;
        line++;
        ans[line] = allWhite;
        line++;
    }

    cout << line << " " << 100 << "\n";
    for(int i = 0; i < line; i++){
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(a==b&&a==c)cout << 1 <<endl;
    if(a != b && b != c && c != a) cout << 3 << endl;
    if((a==b&&a==c) || (a != b && b != c && c != a)){}
    else cout << 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e13+5;
const int maxn=1e6+8;
const double PI=acos(-1);
const ll mod=1e9+7;
ll n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    printf("%lld\n",max(n-m,max(n+m,n*m)));
    return 0;
}


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

int H, W, Rp, Cp;
vector<vector<char> > G;
vector<vector<int> > psum;

int cc2[42][42][42][42];
int calc(int r1, int c1, int r2, int c2) {
    int &ret = cc2[r1][c1][r2][c2];
    if(ret != -1) return ret;
    ret = psum[r2][c2];
    if(r1) ret -= psum[r1 - 1][c2];
    if(c1) ret -= psum[r2][c1 - 1];
    if(r1 && c1) ret += psum[r1 - 1][c1 - 1];
    return ret;
}

int cc1[42][42][42][42];
int dp(int r1, int c1, int r2, int c2) {
    int &ret = cc1[r1][c1][r2][c2];
    if(ret != -1) return ret;

    if(Rp < r1 || r2 < Rp || Cp < c1 || c2 < Cp) return ret = 0;
    if(!calc(r1, c1, Rp, Cp) || !calc(r1, Cp, Rp, c2) || !calc(Rp, c1, r2, Cp) || !calc(Rp, Cp, r2, c2)) return ret = 0;

    ret = 1e9;
    ret = min(ret, calc(r1, c1, Rp, Cp));
    ret = min(ret, calc(r1, Cp, Rp, c2));
    ret = min(ret, calc(Rp, c1, r2, Cp));
    ret = min(ret, calc(Rp, Cp, r2, c2));
    for(int i = r1; i < r2; i++) {
        for(int j = c1; j < c2; j++) {
            ret = min(ret, dp(r1, c1, i, j) + dp(i + 1, j + 1, r2, c2) + calc(i + 1, c1, r2, j) + calc(r1, j + 1, i, c2));
            ret = min(ret, dp(i + 1, c1, r2, j) + dp(r1, j + 1, i, c2) + calc(r1, c1, i, j) + calc(i + 1, j + 1, r2, c2));
        }
    }
    return ret;
}

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

    G = vector<vector<char> >(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        scanf("\n");
        for(int j = 0; j < W; j++) {
            scanf("%c", &G[i][j]);
            if(G[i][j] == 'P') {
                Rp = i;
                Cp = j;
            }
        }
    }

    psum = vector<vector<int> >(H, vector<int>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            psum[i][j] = G[i][j] == '#';
            if(i) psum[i][j] += psum[i - 1][j];
            if(j) psum[i][j] += psum[i][j - 1];
            if(i && j) psum[i][j] -= psum[i - 1][j - 1];
        }
    }

    memset(cc1, -1, sizeof(cc1));
    memset(cc2, -1, sizeof(cc2));
    printf("%d", dp(0, 0, H - 1, W - 1));
}


Measured memory_bytes: 24704
n = int(input())
s = input() + '_'
    
dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n-2, -1, -1):
    for j in range(n-1, i,-1):
        if i + dp[i+1][j+1] >= j:
            break
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1
print(max(list(map(lambda x: max(x), dp))))

Measured memory_bytes: 264544