akhauriyash/Code-Regression huggingface dataset:
import Data.List
main = interact $ unlines . map (poker_hand . sort . map (read::String->Int) . splitOn ',') . lines
 
splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)

poker_hand xs
 | (maximum . map length . group) xs == 4 = "four card"
 | (sort . map length . group) xs == [2,3] = "full house"
 | xs == [(head xs)..(head xs + 4)] || xs == [1,10,11,12,13] = "straight"
 | (maximum . map length . group) xs == 3 = "three card"
 | (length . group) xs == 3 = "two pair"
 | (length . group) xs == 4 = "one pair"
 | otherwise = "null"

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

using namespace std;

#define int long long
//#define cerr if(false)cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 3000
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
int mod=(int)1e9+7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define mp make_pair
vector<vint> adj;
double a[N];
double cache[N][N];
bool vis[N][N];
int n;

double dp(int idx,int count){

    if(idx==n) return 2*count>=n;

    double &ans=cache[idx][count];
    if(vis[idx][count]==1) return ans;

    ans=a[idx]*dp(idx+1,count+1)+(1-a[idx])*dp(idx+1,count);
    vis[idx][count]=1;

    return ans;
}

int32_t main() {
    faster;

    cout<<setprecision(14);

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

    mm0(vis);

    cout<<dp(0,0)<<endl;
}


Measured memory_bytes: 79616
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
const double EulerConstant = exp(-1);
int main() {
        quick
long long ans=LONG_LONG_MAX,n; cin>>n;
for(long long i=1;i*i<=n;i++){
    if(n%i==0){
        if(n/i==i){ans=min(ans,(i-1)+(n/i-1));}
        else{
            ans=min(ans,(i-1)+(n/i-1));
            ans=min(ans,(n/i-1)+(n-1));
        }
    }
}
cout<<ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")
MOD = 10**7


def solve(N: int, K: int, S: int):
    if S != 10**9:
        ans = [S]*K + [S+1]*(N-K)
    else:
        ans = [S]*K + [1]*(N-K)
    print(*ans, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(N, K, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46148
n = int(input())
lis = []
a, b = [], []
for i in range(n):
    X, Y = map(int, input().split())
    lis.append([min(X, Y), max(X, Y)])
    a.append(min(X, Y))
    b.append(max(X, Y))
lis.sort()
answer = (max(a) - min(a)) * (max(b) - min(b))
a_max, b_min = max(a), min(b)
current = float("inf")
for i in range(n):
    if lis[i][0] > b_min:
        current = min(current, a_max - b_min)
        break
    current = min(current, a_max - lis[i][0])
    a_max = max(a_max, lis[i][1])
print(min(answer, current * (max(b) - min(a))))

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts

int main()
{
  int a,b;cin>>a>>b;
  int ans;
  int min8=(a*25+1)/2;
  int max8=((a+1)*25+1)/2-1;
  int min10=b*10;
  int max10=(b+1)*10-1;
  if(max10<min8||max8<min10)cout<<-1<<endl;
  else cout<<max(min8,min10)<<endl;
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int ans = 0, n, m; cin >> n >> m;
    map<int, int> a;
    set<int> v;
    for (int i = 0; i < m; ++i){
        int x; cin >> x;
        string s; cin >> s;
        if(s == "WA" && v.find(x) == v.end()) a[x]++;
        else v.insert(x);
    }
    cout << v.size() << " ";
    for(auto& l : v){
        ans+=a[l];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 || W==0) break;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if((i+j)%2==0) System.out.print('#');
                    else System.out.print('.');
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

bool exists[300001];
int buf[300010];

int main(){
	int *prev = buf + 5;
	int n, Q, c, m, a;
	scanf("%d%d", &n, &Q);

	int maxa = 0;
	for(int i = 0; i < n; ++i){
		scanf("%d", &a);
		exists[a] = true;
		maxa = max(maxa, a);
	}

	for(int i = 1; i <= 300000; ++i){
		if(exists[i]) prev[i] = i;
		else prev[i] = prev[i-1];
	}

	for(int i = 0; i < Q; ++i){
		scanf("%d", &m);
		int ans = 0;

		int p = maxa;
		while(p > 0){
			int t = p % m;
			ans = max(ans, t);
			p = prev[p - t - 1];
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int h,a; cin>>h>>a;
    cout << (h+a-1)/a << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){

  ll N;
  cin>>N;
  ll ans=0;
  rep(i,N){
bool three=false;
    bool five=false;
    
    if((i+1)%3==0){
three=true;
    }
if((i+1)%5==0){
five=true;
}

    
    if(five==false&&three==false){
      ans+=(i+1);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;

using namespace std;

int main()
{
  string s;
  cin >> s;
  vector<int> num(30,0);
  for (int i=0;i<4;i++)
  {
    num[s[i]-'A']++;
  }
  int count = 0;
  for (int i=0;i<26;i++)
  {
    if (num[i] == 2)
    {
      count++;
    }
    else if (num[i] > 0)
    {
      cout << "No" <<endl;
      return 0;
    }
  }
  if (count == 2) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CManyRequirements solver = new CManyRequirements();
        solver.solve(1, in, out);
        out.close();
    }

    static class CManyRequirements {

        private int n;
        private int m;
        private int q;
        private int[] a;
        private int[] b;
        private int[] c;
        private int[] d;
        private int max = 0;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            q = in.nextInt();
            a = new int[q];
            b = new int[q];
            c = new int[q];
            d = new int[q];
            for (int i = 0; i < q; i++) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt();
                d[i] = in.nextInt();
            }

            ArrayList<Integer> al = new ArrayList<>();
            dfs(al);
            out.println(max);
        }

        private void dfs(ArrayList<Integer> list) {
            // System.out.println(list.size() + " " + list);

            if (list.size() >= n) {
                max = Math.max(max, calc(list));
                // System.out.println("ret");
                return;
            }

            for (int i = list.size() == 0 ? 1 : list.get(list.size() - 1); i <= m; i++) {
                list.add(i);
                dfs(list);
                list.remove(list.size() - 1);
            }
        }

        private int calc(ArrayList<Integer> list) {
            int cmp = 0;
            for (int i = 0; i < q; i++) {
                if (list.get(b[i]) - list.get(a[i]) == c[i]) {
                    cmp += d[i];
                }
            }
            return cmp;
        }

    }
}



Measured memory_bytes: 38752
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll ans = (n/(a+b)) * a;
    ll tmp = (a+b) * (n/(a+b));
    ans += min(a, n-tmp);
    cout << ans << endl;
}


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


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

  string a,b;
  cin >> a >>b;

  if((a[0]=='H' &&b[0]=='H') ||(a[0]=='D' && b[0]=='D') ) cout <<"H" << endl;
  else cout << "D" <<endl;
		 

  return 0;
    

}


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

int N;
int bit[1000010];
void add(int a, int w) {
  for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a) {
  int ret = 0;
  for (int x = a; x > 0; x -= x & -x) ret += bit[x];
  return ret;
}

int main(){
  scanf("%d",&N);
  int Q;
  scanf("%d",&Q);
  for(int i=0;i<Q;i++){
    int com,x,y;
    scanf("%d%d%d",&com,&x,&y);
    if(com==0){
      add(x,y);
    }else if(com==1){
      int ans = sum(y) - sum(x-1);
      printf("%d\n",ans);
    }
  }
  return 0;
}


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

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

int main() {
	int N;
	cin >> N;
	long ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
}

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

using namespace std;

int main ()

{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << ((a*(a-1))/2)+((b*(b-1))/2) << endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

ll h,w,k,cnt,ans=0;
char aaa[15][15];

ll count(vector<ll> a){
    ll total=0;
    rep(i,h){
        rep(j,w){
            bool flag=false;
            rep(k,a.size()){
                if(a[k]<h){
                    if(a[k]==i) flag=true;
                }else{
                    if(a[k]-h==j) flag=true;
                }
            }
            if(flag) continue;
            if(aaa[i][j]=='#') total++;
        }
    }
    return total;
} 

int main(){
    cin >> h >> w >> k;
    
    rep(i,h)rep(j,w){
        cin >> aaa[i][j];
    }
    
    ll abc=h+w;
    
    
    for (int bit = 0; bit < (1 << abc); ++bit) {
        vector<ll> bbb;
        for (int i = 0; i < abc; i++) {
            if (bit & (1 << i)) {
                bbb.push_back(i);
            }
        }
        ll now=count(bbb);
        //cout << now << endl;
        if(now==k) ans++;
    }
    
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, s, e) for( int i = s; i <= e; ++i)
int n;
string s;
int x[101][30] = {};
int y[101][30] = {};
int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> s;
	int res = 0;
	rep(i, 1, n-1) {
		rep(j, 0, i - 1) ++x[i][s.at(j)-'a'];
		rep(j, i, n - 1) ++y[i][s.at(j)-'a'];
		int tt = 0;
		rep(j, 0, 29) {
			if (x[i][j] > 0 && y[i][j] > 0)
				++tt;
		}
		if (res < tt)
			res = tt;
	}	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

import fractions

T = I()
A,B,C,D = LIR(T,4)

for i in range(T):
    if A[i] < B[i]:
        print('No')
        continue

    g = fractions.gcd(B[i],D[i])

    # 0~B-1に突入する際の最小値と最大値を求める
    x = (A[i]%B[i])//g
    min_ = (A[i]%B[i]) - x*g

    x = (B[i]-1-(A[i]%B[i])) // g
    max_ = (A[i]%B[i]) + x*g

    if max_ > C[i] or min_ < B[i]-D[i]:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 64492
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ull unsigned long long
#define ll long long
const int maxn=100000;
using namespace std;
int main()
{

  int a,b;
  cin>>a>>b;
  if(a>=6&&a<=12)cout<<b/2<<endl;
  else if(a<6)cout<<0<<endl;
  else cout<<b<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli h,w;
    cin>>h>>w;
    char mat[h][w];
    for(lli i=0;i<h;i++){
    	for(lli j=0;j<w;j++){
    		cin>>mat[i][j];
		}
	}
	lli dp[h][w];
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++){
			dp[i][j]=INT_MAX;
		}
	}
	if(mat[0][0]=='#')
	dp[0][0]=1;
	else
	dp[0][0]=0;
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++){
			if(mat[i][j]=='#'){
				if(i+1<h)
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				if(j+1<w)
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
			}
			else if(mat[i][j]=='.'){
				if(i+1<h && mat[i+1][j]=='#'){
					dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
				}
				else if(i+1<h)
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				if(j+1<w && mat[i][j+1]=='#'){
					dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
				}
				else if(j+1<w)
				dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<"\n";
	}
	cout<<dp[h-1][w-1];
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 1e4 + 5;
string s , t;

int main(){
    fastIO;
    cin>>s>>t;
    int l = 0 , r  = 0 , ans  = 0 , n = s.size();
    while(r<n && l<n){
        if(s[l] != t[r]){
            ans++;
        }
        r++;
        l++;
    }
    cout<<ans;
}




Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<string>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
template<class T> inline void chmax(T& a, T b) { if(a < b) a = b; }
template<class T> inline void chmin(T& a, T b) { if(a > b) a = b; }
const ll mod = 1000000007;

int main(){
	int X;
	std::cin >>X;
	if(X>=400 && X<=599){
		std::cout << 8 << std::endl;
	}
	if(X>=600 && X<=799){
		std::cout << 7 << std::endl;
	}
	if(X>=800 && X<=999){
		std::cout << 6 << std::endl;
	}
	if(X>=1000 && X<=1199){
		std::cout << 5 << std::endl;
	}
	if(X>=1200 && X<=1399){
		std::cout << 4 << std::endl;
	}
	if(X>=1400 && X<=1599){
		std::cout << 3 << std::endl;
	}
	if(X>=1600 && X<=1799){
		std::cout << 2 << std::endl;
	}
	if(X>=1800 && X<=1999){
		std::cout << 1 << std::endl;
	}


	return 0;
}

Measured memory_bytes: 3628
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;
#define ll         long long
// #define endl       long long
// #define pb            '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    ll k=n/2;
    double ans;
    if(n%2==1) k++;
    ans=(k*1.0)/n;
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int x;
    cin >> x;
    for(int i = 0; i <= 100000; i++) {
        if(i * 100 <= x && x <= i * 105) {
            cout << 1 << endl;
            break;
        }
        if(i == 100000) {
            cout << 0 << endl;
            break;
        }
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:23:06:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pii , null_type, less< pii >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        cout<<n+n*n+n*n*n;
    }
    return 0;
}


























Measured memory_bytes: 3644
a, b, c, d = map(int, input().split())

print(max(a * c, a * d, b * c, b * d))

# a b c d
# - - - -
# - - - +
# - - + +
# - + - -
# - + - +
# - + + +
# + + - -
# + + - +
# + + + +


Measured memory_bytes: 9148
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=0; ; ++i) {
            int sum = 0;
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] score = new int[n];
            for (int j = 0; j < n; ++j) {
                score[j] = sc.nextInt();
            }
            Arrays.sort(score);
            for(int j=1; j<score.length-1; ++j){
                sum += score[j];
            }
            int average = sum/(n-2);
            System.out.println(average);
        }
    }

 }

Measured memory_bytes: 28888
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    ll a, b, c, k; cin >> a >> b >> c >> k;
    
    if (abs(a-b) > pow(10, 18)) {
        cout << "Unfair" << endl;
    }
    else if (k % 2 == 0) {
        out(a - b);
    }
    else {
        out(b - a);
    }
    
    return 0;
}






Measured memory_bytes: 256
# Here your code !


h,w=gets.split

h=h.to_i
w=w.to_i


array=[]
h.times{
    
   array<<gets.chomp.split("") }
   
array2=Array.new(h+2).map{Array.new(w+2,0)}


k=1
h.times{

array2[k][1..w]=array[k-1]
k=k+1
}

n=1
h.times{s=1
    w.times{
        if array2[n][s]=="."
            
        array2[n][s]=0
       end
       s=s+1
    }
   n=n+1 
    
}

   

   
   
   
   
i=0
h.times{
    j=0
       
       w.times{
             if array[i][j]=="."
                 array[i][j]=0
              end
         j=j+1 
    
       }
    
   i=i+1
    
}
   

i=1

h.times{j=1
    
    w.times{
        
        if array2[i][j].is_a?(Integer) && array2[i-1][j-1]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i-1][j]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i-1][j+1]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i][j-1]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i][j+1]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i+1][j-1]=="#"
            array2[i][j]+=1
        end
         if array2[i][j].is_a?(Integer) && array2[i+1][j+1]=="#"
            array2[i][j]+=1
        end
         
         if array2[i][j].is_a?(Integer) && array2[i+1][j]=="#"
            array2[i][j]+=1
        end
       
       j=j+1 
        
        
    }
  i=i+1  
    
    
    
}

t=1
h.times{
    
   array3=array2[t] [1..w]
   puts array3.join
    
 t=t+1
    
}









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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = inf;
    for(int i = 0; i < (1<<12); i++){
        int tmp[m] = {0};
        int money = 0;
        int f = 1;
        for(int j = 0; j < n; j++){
            if((i>>j)&1){
                for(int k = 0; k < m; k++)
                    tmp[k] += a[j][k];
                money += c[j];
            }
        }
        for(int k = 0; k < m; k++){
            if(tmp[k] < x)f = 0;
        }
        if(f)ans = min(ans, money);
    }
    cout << (ans < inf ? ans : -1) << endl;
    // if(ans  < inf){
    //     cout << "Yes" << endl;
    //     cout << ans << endl;
    // } else{
    //     cout << "No" << endl;
    // }

}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

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

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

int main(){

  int n;
  cin>>n;
  int a[n],b[n],c[n];
  REP(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }

  int maxA[n],maxB[n],maxC[n];
  maxA[0] = a[0];
  maxB[0] = b[0];
  maxC[0] = c[0];

  for(int i=1;i<n;i++){
    maxA[i] = max(maxB[i-1],maxC[i-1]) + a[i];
    maxB[i] = b[i] + max(maxA[i-1],maxC[i-1]);
    maxC[i] = c[i] + max(maxA[i-1],maxB[i-1]);
  }

  cout<<max(max(maxA[n-1],maxB[n-1]),maxC[n-1])<<endl;;


  return 0;
}

Measured memory_bytes: 2560
/* AtCoder Regular Contest 082. Task C, by Abreto<m@abreto.net>. */
#include <bits/stdc++.h>

using namespace std;

#define MAXN    100001
int N;
int cnt[MAXN+10];

int main(void)
{
    int i = 0, ai = 0;
    scanf("%d", &N);
    while(N--)
    {
        scanf("%d", &ai);
        cnt[ai]++;
        cnt[ai+1]++;
        cnt[ai+2]++;
    }
    int ans = 0;
    for(i = 0;i < 100002;++i)
        if(cnt[i] > ans)
            ans = cnt[i];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, H, W;
int A[1010], B[1010];


signed main(){
	cin >> N >> H >> W;
	rep(i, 0, N) cin >> A[i] >> B[i];

	int ans = 0;
	rep(i, 0, N)
		if(A[i] >= H && B[i] >= W) ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
l = [int(input()) for i in range(N)]
def dfs(cur,a,b,c):
  if cur==N:
    if min(a,b,c)>0:
      return abs(A-a)+abs(B-b)+abs(C-c)-30
    else:
      return float("INF")
    
  ret0=dfs(cur+1,a,b,c)
  ret1=dfs(cur+1,a+l[cur],b,c)+10
  ret2=dfs(cur+1,a,b+l[cur],c)+10
  ret3=dfs(cur+1,a,b,c+l[cur])+10
  return min(ret0,ret1,ret2,ret3)
  
print(dfs(0,0,0,0))

Measured memory_bytes: 45276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n, k;
string s;
vector<llint> vec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	cin >> s;
	int n = s.size();
	s = "#" + s + "#";
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'L'){
			if(s[i-1] == 'R') vec.push_back(2), ans++;
			else if(s[i-1] == '#')vec.push_back(1), ans++;
		}
		if(s[i] == 'R'){
			if(s[i+1] == 'L') vec.push_back(2), ans++;
			else if(s[i+1] == '#') vec.push_back(1), ans++;
		}
	}
	sort(vec.rbegin(), vec.rend());
	
	for(int i = 0; i < min(k, (llint)vec.size()); i++) ans -= vec[i];
	cout << n - max(1LL, ans) << endl;
	
	return 0;
}

Measured memory_bytes: 1512
City = Struct.new(:prefecture, :year, :serial, :idx)

n, m = gets.split.map(&:to_i)
cities = []
(1..m).each do |i|
  prefecture, year = gets.split.map(&:to_i)
  cities << City.new(prefecture, year, '0', i)
end

prefectures = cities.group_by(&:prefecture)
prefectures.keys.each do |pi|
  cities = prefectures[pi]&.sort_by(&:year)
  next if cities.nil?

  cities.map.with_index do |city, idx|
    first = format('%06d', pi)
    last = format('%06d', idx + 1)
    city.serial = first + last
  end
end

puts prefectures.values.flatten.sort_by(&:idx).map(&:serial)


Measured memory_bytes: 45280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int w;
    cin >> w;
    int x=0;
    while(x<S.length()){
        cout << S[x];
        x+=w;
    }
    
}

/*



 */



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int a[100];
	rep(i, n) {
		cin >> a[i];
	}
	int cnt = 0;
	rep(i, n-1) {
		if (a[i] == a[i + 1]) {
			a[i + 1] = 200 + i; cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
v = readInts()

v.sort()

for i in range(n-1):
	v[i+1] = (v[i]+v[i+1])/2

print(v[n-1])

Measured memory_bytes: 3444
/*input
2 8

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    if(n==1){
    	cout<<1<<endl;
    	return 0 ;
    }
    ll ans = ceil(log(n)/log(k));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>

int p[20000];
int N, S;

using namespace std;

void solve() {
  sort(p, p + N);
  int s = 0;
  for (int i = 0; i < N; i++) {
	int tar = S - p[i];
	int* a = upper_bound(p + i + 1, p + N, tar);
	s += distance(a, p + N);
  }
  cout << s << endl;
}

int main() {
  while (cin >> N >> S) {
	if (N == 0 && S == 0) {
	  break;
	}

	for (int i = 0; i < N; i++) {
	  cin >> p[i];
	}
	solve();
  }
}

Measured memory_bytes: 908
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
  H[u] = (h1 > h2 ? h1 : h2);
  return H[u];
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL) printf("root\n");
  else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i, v, l, r, root = 0;
  scanf("%d", &n);

  for(i = 0; i < n; i++) T[i].parent = NIL;

  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++) print(i);

  return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		ll A; cin >> A;
		a[i] = A - i - 1;
	}
	sort(all(a));
	ll ans = 0,x=0,y=0;
	rep(i, n) {
		ans += abs(a[i] - a[a.size() / 2]);
		x += abs(a[i] - a[(a.size() / 2) + 1]);
		y += abs(a[i] - a[a.size() / 2 - 1]);
	}
	cout << min({ ans,x,y });
	return 0;
}













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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
 
#define INF 10e9
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
 
int main() {
    int r;
    cin >> r;

    cout << 3 * r * r << endl;
}

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

#define Khaled ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lli long long int
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define FOR(i, n) for (i = 0; i < n; i++)
#define FO(i,k,n) for(i = k; i <= n; i++)
#define in(v) for(auto &it : v) cin >> it;
#define out(v) for(auto it : v) cout << it << ' '; cout << endl;
#define all(arr) arr.begin(), arr.end()
#define PI acos(-1)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define MAX 100005
 
using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;

string let = "abcdefghijklmnopqrstuvwxyz";

void solve()
{
    lli i, j, n, m, a, b, c, d, x, y, z, k, l;
    cin >> n; 
    vi d1(n), d2(n);
    FOR(i,n) {
        cin >> d1[i] >> d2[i];
    }
    bool ck = false;
    FOR(i,n-2) {
        if((d1[i] == d2[i]) && (d1[i+1] == d2[i+1]) && (d1[i+2] == d2[i+2])) {
            ck = true;
            break;
        }
    }
    if(ck) yes;
    else no;

    return;
}

int main()
{
    Khaled
    // freopen("input", "r", stdin);
    // freopen("output" , "w" , stdout);
    int t = 1,i;
    // cin >> t;
    FO(i,1,t) {
        solve();
    }

    return 0;
}

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

typedef __int128_t ll;

//typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 2*1e5 + 10;
const int maxC = 1e6 + 10;
const int INF1 = 1e9;
const ll INF = 1LL<<62;

int n,m;
char s[maxN];
vector<int> path[maxN];
int tag[maxN];
int A[maxN];
int B[maxN];
queue<int> Q;
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		path[u].push_back(v);
		path[v].push_back(u);
		if (s[v] == 'A' )
		{
			A[u] ++;
		}	
		else
		{
			B[u] ++;
		}
		if(s[u] == 'A')
		{
			A[v] ++;
		}
		else
		{
			B[v] ++;
		}
	} 
	for(int i=1;i<=n;i++)
	{
		if(A[i] == 0 || B[i] == 0)
		{
			Q.push(i);
			tag[i] = 1;
		}
	}
	while(!Q.empty())
	{
		int x = Q.front();
		Q.pop();
		for(auto y:path[x])
		{
			if(!tag[y])
			{
				if(s[x] == 'A')
				{
					A[y]--;
				}
				else
				{
					B[y]--;
				}
				if(A[y]==0 || B[y]==0)
				{
					tag[y] = 1;
					Q.push(y);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(tag[i] == 0)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N), M(N);
  for(int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for(int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  for(int i = 0; i < N; i++) {
    M.at(i) = V.at(i) - C.at(i);
  }
  int S;
  for(int i = 0; i < N; i++) {
    if(M.at(i) > 0) {
      S += M.at(i);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256