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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_V 1111

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

//// bipartite_match
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void init(int v){
	V=v;
	for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v]=true;
	for(int i=0; i<G[v].size();i++){
		int u=G[v][i],w=match[u];
		if(w<0||(!used[w]&&dfs(w))){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_match(){
	int res=0;
	memset(match,-1,sizeof(match));
	for(int v=0; v<V;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v))res++;
		}
	}
	return res;
}

int n,m;
int b[555],r[555];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>m>>n;
		if(n==0)break;
		rep(i,m)cin>>b[i];
		rep(i,n)cin>>r[i];
		init(n+m);
		rep(i,m)rep(j,n){
			if(gcd(b[i],r[j])!=1)add_edge(i,j+m);
		}
		cout<<bipartite_match()<<endl;
	}
	return 0;
}

Measured memory_bytes: 4836
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  Matrix c(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  bool ok = true;
  for (int i = 1; i <= 2; i++){
    int sa0 = c[i][0] - c[0][0];
    int sa1 = c[i][1] - c[0][1];
    int sa2 = c[i][2] - c[0][2];
    if (sa0 == sa1 && sa1 == sa2) continue;
    else ok = false;
  }
  if (ok) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#食品をおいしく感じた場合 delicious
#おいしくは感じなかったがお腹は壊さなかった場合 safe
#お腹を壊した場合 dangerous を出力せよ。

#X：消費期限過ぎてもOK日数
#A：消費期限前A日に購入
#B：A日に購入後、食べた日はB日後

Data = input().split()

X = int(Data[0])
A = int(Data[1])
B = int(Data[2])

set1 = A-B

if set1 >= 0:
    print("delicious")

elif X + set1 >= 0:
    print("safe")

else:
    print("dangerous")



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	auto bin_pows =[](ll x, ll n, ll mod){
		ll res = 1LL;
		for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
		return res;
	};
	fct[0] = fct[1] = inv[1] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	inv[cmx] = bin_pows(fct[cmx], mod-2, mod);
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, a, b;
	cin >>h >>w >>a >>b;
	finit(h+w+30);
	a = h-a; b--;
	vector<pii> ps;
	rep2(i, 1, max(h,w)){
		if(a - i<0 || b+i>=w) break;
		ps.emplace_back(a-i, b+i);
	}
	ll ans = 0;
	//dbg(sz(ps));
	for(auto x :ps){
		int si = abs(x.first - 0);
		int bo = abs(x.second - 0);
		ll tmp = nCk(si+bo, bo);
		si = abs(h-1 - x.first);
		bo = abs(w-1 - x.second);
		(tmp *= nCk(si+bo, bo)) %=MD;
		(ans += tmp)%=MD;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4472
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[2100];
int p[2100];
int dp[2100][2100];
int opt[2100][2100];
int w[2100][2100];
int sum[2100];
void calc(int a,int l,int r,int L,int R){
	//printf("%d %d %d %d %d\n",a,l,r,L,R);
	if(l>=r){
		return;
	}
	int M=(l+r)/2;
	for(int i=L;i<R;i++){
		if(i<=M&&dp[a][M+1]>dp[a-1][i]+w[i][M]){
			opt[a][M+1]=i;
			dp[a][M+1]=dp[a-1][i]+w[i][M];
		}
	}
	if(l+1<r){
		calc(a,l,(l+r)/2,L,opt[a][M+1]+1);
		calc(a,(l+r)/2,r,opt[a][M+1],R);
	}
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(b<=c){
		printf("0\n");return 0;
	}
	for(int i=0;i<a;i++)scanf("%d",d+i);
	int mv=0;
	for(int i=0;i<b;i++){
		int s,t;
		scanf("%d%d",&s,&t);
		p[i]=s-d[t-1];
		mv=min(mv,p[i]);
	}
	std::sort(p,p+b);
	//for(int i=0;i<b;i++)p[i]-=mv;
	//for(int i=0;i<b;i++)printf("%d\n",p[i]);
	for(int i=0;i<b;i++)sum[i+1]=sum[i]+p[i];
	for(int i=0;i<2100;i++)for(int j=0;j<2100;j++)dp[i][j]=999999999;
	for(int i=0;i<b;i++)for(int j=i;j<b;j++){
		w[i][j]=sum[i]-sum[j+1]+p[j]*(j-i+1);
	}
	dp[0][0]=0;
	for(int i=1;i<=c;i++){
		calc(i,0,b,0,b);
	}
	/*for(int i=1;i<=c;i++){
		for(int j=1;j<=b;j++)printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	printf("%d\n",dp[c][b]);
}

Measured memory_bytes: 46600
#include<iostream>
using namespace std;
int main() {
  int t;
  while(cin >> t, t) {
    int n;
    int sum = 0;
    cin >> n;
    for(int i=0; i<n; i++) {
      int a, b;
      cin >> a >> b;
      sum += (b-a);
    }

    if( t <= sum ) cout << "OK" << endl;
    else cout << t-sum << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n;cin>>n;
    
    bool dp[101] = {false};
    dp[0]=true;
    dp[4]=true;
    dp[7]=true;
    for(auto i = 0; i<=n;i++){
        
        if(i>=4){
            dp[i] |= dp[i-4];
        }
        if(i>=7){
            dp[i] |=dp[i-7];
        }
        
    }
    
    if(dp[n])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
    return 0;
}





Measured memory_bytes: 256
<?php
$o=array();
while(1){
  $x=explode(' ',trim(fgets(STDIN)));
  if($x[0]||$x[1]) $o[]=($x[0]<$x[1])?$x[0].' '.$x[1]:$x[1].' '.$x[0];
  else break;
}
print implode(PHP_EOL,$o);
?>

Measured memory_bytes: 15672
// in the name of god 
// vaght hast vali kam ast !

#include <bits/stdc++.h>
using namespace std ;

const int MAXN = 1e6 + 100 ;

int a[MAXN] ; 
int32_t main(){
	ios_base::sync_with_stdio(0) ;
	cin . tie(0) ; cout . tie(0) ; 

	int H ,W , h , w ; cin >> H >> W >> h >> w ; 
	if((H % h) + (W % w) == 0)return cout << "No\n" , 0 ; 
	else cout << "Yes\n" ; 
	int T = 0 ;
	if(H % h){
		T = H / h + 1 ; 
		for(int i = 0 ; i < H ; i ++){
			for(int j = 0 ; j < W ; j ++){
				if((i + 1) % h == 0) cout << -(T * h - T + 1) ; 
				else cout << T ; 
				cout << ' '  ; 
			}
			cout << '\n' ; 
		}
	} else {
		T = W / w + 1 ; 
		for(int i = 0 ; i < H ; i ++){
			for(int j = 0 ; j < W ; j ++){
				if((j + 1) % w == 0) cout << -(T * w - T + 1) ; 
				else cout << T ; 
				cout << ' '  ; 
			}
			cout << '\n' ; 
		}
	}
}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};
ll mod=1e9+7;
ll dp[100010];
bool ok[100010];

int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;

    std::cout << std::fixed;
    std::cout << std::setprecision(10) << w*h/2<<" ";

    if(x*2==w && y*2==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define DEF 2000000000
int count=0;
int L[500000];
int R[500000];


void sort(int A[],int n,int left,int right);
void merge(int A[],int n,int left,int mid,int right);



int main(){
  int number;
  scanf("%d",&number);
  int A[1000000];
  int i;
  for(i=0;i<number;i++){
    scanf("%d",&A[i]);
  }

  
  sort(A,number,0,number);

  for(i=0;i<number;i++){
    if(i==number-1){printf("%d",A[i]);}
    else {printf("%d ",A[i]);}
    
  }
  printf("\n");
  printf("%d\n",count);
  
  
  
  return 0;
}




void merge(int A[],int n,int left,int mid,int right){
  int a1=mid-left;
  int a2=right-mid;



  
  int i;
  for(i=0;i<a1;i++){L[i]=A[left+i];}
  for(i=0;i<a2;i++){R[i]=A[mid+i];}



  
  L[a1]=R[a2]=DEF;


  
  i=0;        
  int j=0;
  int k;
  
  
  for(k=left;k<right;k++){
    count++;
    
    if(L[i]>R[j]){
      A[k]=R[j];
      j++;
    }
    
    else{


      A[k]=L[i];
      i++;
    }
    
  }
  
}


void sort(int A[],int n,int l,int r){
  
  if(l+1<r){
    int mid;
    mid=(l+r)/2;
    
    sort(A,n,l,mid);
    sort(A,n,mid,r);
    
    
    merge(A,n,l,mid,r);
  }
  
}



Measured memory_bytes: 5648
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int N = 1e6 + 10;
int dp[N][10][2];
int n;
int solve(string &s, int lastDig, int pos, int flag){
	if(pos == n){
		return 0;
	}
	if(dp[pos][lastDig][flag] != -1){
		return dp[pos][lastDig][flag];
	}
	int ans = 0;
	int dig = s[pos] - '0';
	if(flag)
		dig = (pos == n-1 ? 10 : 9) - (s[pos] - '0');
	ans = dig + solve(s,dig,pos+1,flag);
	ans = min(ans,(dig + 1) + solve(s,(dig+1) % 10,pos+1,flag^1));
	
	return dp[pos][lastDig][flag] = ans;
}

int32_t main(){
	string s;
	cin >> s;
	n = s.size();
	memset(dp,-1,sizeof dp);
	
	cout << min(solve(s,0,0,0),1 + solve(s,1,0,1)) << endl;

	return 0;
}



Measured memory_bytes: 235780
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int a, b, c, d, mon = 0, ans = 0;
	cin >> a >> b;
	vector<pair<int, int>>v(b);
	for (int i = 0; i < b; ++i) {
		cin >> c >> d;
		v[i] = make_pair(d, c);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < b; ++i) {
		if (mon <= v[i].second) {
			mon = v[i].first;
			++ans;
		}
	}
	cout << ans << endl;
}

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

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

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main(){
	ll n; cin >> n;
	ll h[n+1];
	ll L[n+1], R[n+1];
	map<ll,ll>cnt;
	for(ll i = 1; i <= n; i++) {
		cin >> h[i];
		L[i] = i + h[i];
		R[i] = i - h[i];	
		cnt[R[i]]++;	
	}
	// for(ll i = 1; i <= n; i++) cout << L[i] << " ";
	// cout << endl;
	// for(ll i = 1; i <= n; i++) cout << R[i] << " ";
	// cout << endl;
	ll ans = 0;
	for(ll i = 1; i < n; i++) {
		ans += cnt[L[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 31036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
int main() {
  int X,N;
  cin>>X>>N;
  X--;
  int answer=100000;
  vector<bool> ans(101,true);
  rep(i,N){
    int a;
    cin>>a;
    a--;
    ans.at(a)=false;
  }
  rep(i,101){
    if(ans.at(i)){
      int tmp=abs(X-i),aa=abs(X-answer);
      if(tmp==aa)break;
      if(tmp<aa) answer=i;
    }
  }
  answer++;
  if(abs(X+1-answer)>=X+1) answer=0;
  cout<<answer;
}


Measured memory_bytes: 3596
import Data.List
import Control.Monad

minDiff :: Int -> [Int] -> Int
minDiff k xs = minimum $ zipWith (-) (drop (k - 1) xs') xs'
  where xs' = sort xs

main :: IO ()
main = do
  [n, k] <- mapM readIO . words =<< getLine
  xs <- replicateM n (readIO =<< getLine)
  print $ minDiff k xs

Measured memory_bytes: 64892
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());

  string a = "maerd";
  string b = "remaerd";
  string c = "esare";
  string d = "resare";

  while (S.size()) {
    if (S.substr(0, a.size()) == a) S = S.substr(a.size(), S.size() - a.size());
    else if (S.substr(0, b.size()) == b) S = S.substr(b.size(), S.size() - b.size());
    else if (S.substr(0, c.size()) == c) S = S.substr(c.size(), S.size() - c.size());
    else if (S.substr(0, d.size()) == d) S = S.substr(d.size(), S.size() - d.size());
    else {
      cout << "NO" << endl;
      return;
    }
  }

  cout << "YES" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    map<int, int> rev_a, rev_b;
    vector<pair<int, int>> ab(2*n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        ab[2*i] = make_pair(a[i], 1);
        ab[2*i+1] = make_pair(b[i], -1);
        rev_a[a[i]] = i;
        rev_b[b[i]] = i;
    }
    sort(ab.begin(), ab.end());

    int ans = 0;
    if(n % 2 == 1){
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        int l = a[n/2], r = b[n/2];
        ans = r-l+1;
    }
    else{
        int left = 0, right = n;
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        int l_l = a[n/2-1], l_u = b[n/2-1], r_l = a[n/2], r_u = b[n/2];
        ans = (r_u+l_u) - (r_l+l_l) + 1;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  ll h,w; cin >> h >> w;
  ll ans;
  if (h==1 || w==1) { cout << 1 << endl; return 0; }
  if (h%2==0){
    ans = w*h/2;
  } else {
    if (w%2==0) {
      ans = w*(h-1)/2+w/2;
    } else {
      ans = w*((h-1)/2)+w/2+1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int p[3]={0,0,0};
    int a,b;
    cin>>a>>b;
    p[a-1]=1;
    p[b-1]=1;
    for(int i=0;i<3;i++){
        if(p[i]==0) cout<<i+1<<endl;
    }
}

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

#define int long long

#define PB push_back
#define PPB pop_back
#define MK make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;

constexpr int INF = 1LL << 61;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 3 * 100005;

int n;
pii mic[MAX_N];

bool Solve(int k) {
    priority_queue<pii, vector<pii>> pq;
    
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        const pii p = mic[i];
        pq.push({ p.second, p.first });
        sum += p.second;
    }

    if (sum <= mic[k - 1].first * k) return true;

    for (int i = k; i < n; ++i) {
        const pii p = mic[i];
        sum += p.second;
        pq.push({ p.second, p.first });
        sum -= pq.top().first;
        pq.pop();
        if (sum <= mic[i].first * k) return true;
    }
    
    return false;
}

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

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        mic[i] = { b, a };
    }
    sort(mic, mic + n, greater<pii>());

    int l = 0, r = n;
    while (1 < r - l) {
        int mid = (l + r) / 2;

        if (Solve(mid)) {
            l = (l + r) / 2;
        } else {
            r = (l + r) / 2;
        }
    }

    cout << (Solve(r) ? r : l) << endl;
}

Measured memory_bytes: 20476
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long k = scan.nextLong();

		if(k >= a) {
			k -= a;
			a = 0;
		}else {
			a -= k;
			k = 0;
		}

		if(k >= b) {
			b = 0;
		}else {
			b -= k;
		}

		System.out.println("" + a + " " + b);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int X;
    cin >> X;
    int y=X/500;
    int z=X%500;
    z/=5;
    cout <<y*1000+z*5 << endl;



}


Measured memory_bytes: 256
n,t=input().split()
N=int(n)
T=int(t)
i=0
v=0
while i<N:
    x=input().split()
    y=[int(i) for i in x]
    if y[1]<=T:
        if v==0:
            m=y[0]
        if y[0]<=m:
            m=y[0]
            v=1
    i+=1
if v!=0:
    print(m)
else:
    print('TLE')


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int Num = Integer.parseInt(br.readLine());
			String[] input = new String[Num];
			for(int i = 0 ; i < Num ; i++){
				input[i] = br.readLine();
			}
			HashMap<String, Integer> result = new HashMap<String, Integer>();
			HashMap<String, Integer> temp = new HashMap<String, Integer>();
			for(int i = 0 ; i < input[0].length() ; i++){
				result.put(Character.toString(input[0].charAt(i)), input[0].length());
			}
			for(int i = 0 ; i < Num ; i++){
				result.forEach((k, v) -> temp.put(k, 0));
				for(int j = 0 ; j < input[i].length() ; j++){
					temp.computeIfPresent(Character.toString(input[i].charAt(j)), (k, v) -> v + 1);
				}
				temp.forEach((k, v) -> {
					result.put(k, ( v < result.get(k)? v : result.get(k)));
				});
			}
			result.forEach((k,v) -> {
				while(v > 0){
					System.out.print(k);
					v--;
				}
			});
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}


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

using ll = long long;

int main() {
    int N, A, minA = 1e9 + 1, m = 0;
    cin >> N;
    ll s = 0;
    bool z = false;
    rep(i, N) {
        cin >> A;
        s += abs(A);
        minA = min(minA, abs(A));
        if (A == 0) z = true;
        if (A < 0) m++;
    }
    if (z || m % 2 == 0) cout << s << "\n";
    else cout << s - 2 * minA << "\n";
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = [0] + list( map( int, input().split()))
    ANS = [0]*(N+1)
    for i in range(N,0,-1):
        t = sum([ANS[i*(j+1)] for j in range(N//i)] )%2
        if t == A[i]:
            continue
        ANS[i] = 1
    print( sum(ANS))
    print( " ".join( map( str, [ i for i in range(N+1) if ANS[i] == 1])))
if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

vvi mult(vvi a, vvi b, ll MOD) {
    int l = a[0].size();
    int m = a.size(), n = b[0].size();
    vvi res(m, vi(n));
    REP (i, m) REP (j, n) REP (k, l) {
        res[i][j] += a[i][k] * b[k][j];
        res[i][j] %= MOD;
    }
    return res;
}

vvi pow(vvi a, ll k, ll MOD) {
    int n = a.size();
    vvi res(n, vi(n));
    REP (i, n) res[i][i] = 1;
    while(k) {
        if (k&1) res = mult(res,a,MOD);
        a = mult(a,a,MOD);
        k >>= 1;
    }
    return res;
}

ll L, A, B, MOD;
ll digit[19];

ll s(ll n) {
    return A + B * n;
}

int solve() {
    ll k = 1;
    REP (i, 18) {
        ll lo = -1, hi = L;
        while (hi - lo > 1ll) {
            ll mid = (hi+lo)/2;
            if (s(mid) >= k*10) hi = mid;
            else lo = mid;
        }
        digit[i] = hi;
        k *= 10;
    }
    digit[18] = L;
    FORR (i, 1, 19) digit[i] = digit[i] - digit[i-1];
    REP (i, 19) assert(digit[i] >= 0);

    vvi X(3, vi(1));
    X[0][0] = A % MOD;
    X[1][0] = A % MOD;
    X[2][0] = 1;
    k = 1;
    bool f = true;
    REP (i, 19) {
        k *= 10;
        k %= MOD;
        vvi C(3, vi(3));
        C[0][0] = k;
        C[0][1] = 1;
        C[0][2] = B % MOD;
        C[1][0] = 0;
        C[1][1] = 1;
        C[1][2] = B % MOD;
        C[2][0] = 0;
        C[2][1] = 0;
        C[2][2] = 1;
        ll n = digit[i];
        if (n == 0) continue;
        if (f) {
            C = pow(C, n-1, MOD);
        }
        else C = pow(C, n, MOD);
        f = false;
        X = mult(C, X, MOD);
    }
    return X[0][0] % MOD;
}

int main() {
    cin >> L >> A >> B >> MOD;
    cout << solve() << endl;
}

Measured memory_bytes: 256
import numpy as np

n, MOD = map(int, input().split())
n3 = n * 3
dp = np.zeros((n3 + 1, int(n * 4.5) + 1), np.int64)
dp[0][0] = dp[1][1] = dp[2][2] = dp[2][-1] = 1

for i in range(3, n3 + 1):
    dp[i] += dp[i - 3] * (i - 2) * (i - 1)
    dp[i] += np.roll(dp[i - 2], -1) * (i - 1)
    dp[i] += np.roll(dp[i - 1], 1)
    dp[i] %= MOD

print(dp[-1][:n3 + 1].sum() % MOD)


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    string s1 = s.substr(0, i);
    string s2 = s.substr(i, n);
    // cout << s1 << ", " << s2 << endl;
    sort(s1.begin(), s1.end());
    s1.erase(unique(s1.begin(), s1.end()), s1.end());
    sort(s2.begin(), s2.end());
    s2.erase(unique(s2.begin(), s2.end()), s2.end());
    // cout << s1 << ", " << s2 << endl;
    int count = 0;
    for (auto c : s1) {
      if (s2.find(c) != string::npos) {
        count++;
      }
    }
    ans = max(ans, count);
  }

  cout << ans << endl;

  return 0;
}


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

long int num[200001] = {0};

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

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

  long int sum=0;
  for(int i=1; i<=n; i++){
    sum += num[i]*(num[i]-1)/2;
  }

  for(int i=0; i<n; i++){
    cout << sum - num[a[i]]+1 << endl;
  }
  
  return 0;
}

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

struct node{int t, i, j, k;};
vector<node>ans;
void a(int i, int j, int k) {ans.push_back((node){0, i, j, k});} // ak = ai + aj
void c(int i, int j, int k) {ans.push_back((node){1, i, j, k});} // ak = [ai < aj]
void print() {
	printf("%d\n", ans.size());
	for(unsigned i=0;i<ans.size();i++)
		printf("%c %d %d %d\n", ans[i].t ? '<' : '+', ans[i].i, ans[i].j, ans[i].k);
}

int e, cnt = 2;
int a(int x, int y) {a(x, y, ++cnt); return cnt;} // x + y
int c(int x, int y) {c(x, y, ++cnt); return cnt;} // x < y
int db(int x) {return a(x, x);} // x * 2
int l(int x, int p) {
	int y = x;
	for(int i=1;i<=p;i++) y = db(y);
	return y;
} // x << p
int m(int x, int y) {return c(e, a(x, y));} // x * y (x, y = 0 or 1)
int n(int x) {return c(x, e);} // not x (x = 0 or 1)

int bts[2][32], pw[32];

int main() {
	e = c(2, a(0, 1));
	
	pw[0] = e; for(int i=1;i<=30;i++) pw[i] = db(pw[i - 1]);
	for(int i=29;i>=0;i--) pw[i] = a(pw[i], pw[i + 1]);
	
	for(int o=0;o<=1;o++) {
		int t = o;
		for(int i=30;i>=0;i--) {
			int p = c(t, pw[i]); bts[o][i] = n(p);
			t = a(t, l(p, i));
		}
	}
	
	for(int i=0;i<=30;i++) {
		for(int j=0;j<=30;j++) {
			int x = l(m(bts[0][i], bts[1][j]), i + j);
			a(2, x, 2);
		}
	}
	
	print();
}

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

const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007ll;
//const long long MOD = 998244353ll;
const int INF = 1000000001;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  while (q-- > 0) {
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll xo = 0ll;
    for (int i = 2; i < n; ++i) xo ^= a[i];
    ll sum = a[0] + a[1];
    if (xo > sum) {
      cout << -1 << endl;
      continue;
    }
    ll dif = a[0] + a[1] - xo;
    if (dif & 1ll) {
     cout << -1 << endl;
     continue;
    }
    dif >>= 1;
    int maxr = 42;
    bool fail = false;
    bool ones[maxr];
    for (int j = 0; j < maxr; ++j) {
      ll mask = (1ll << (maxr - 1 - j)); 
      ones[j] = false;
      if (dif & mask) {
        if (xo & mask) {
          fail = true;
          break;
        } else {
          //cout << " ones " << j << endl;
          ones[j] = true;
        }
      }
    }
    if (fail) {
     cout << -1 << endl;
     continue;
    }
    ll MMM = (1ll << (maxr + 1));
    ll dyn[maxr + 1][2];
    dyn[0][0] = 0ll;
    dyn[0][1] = MMM;
    for (int i = 0; i < maxr; ++i) {
      ll mask = (1ll << (maxr - 1 - i)); 
      if (xo & mask) {
        if (a[1] & mask) {
          dyn[i + 1][0] = dyn[i][0] | mask;
          dyn[i + 1][1] = dyn[i][1];
        } else {
          dyn[i + 1][0] = dyn[i][0];
          dyn[i + 1][1] = min(dyn[i][1], dyn[i][0] | mask);
        }
      } else {
        if (ones[i]) { 
          if (a[1] & mask) {
            dyn[i + 1][0] = dyn[i][0] | mask; 
            dyn[i + 1][1] = dyn[i][1] | mask;
          } else {
            dyn[i + 1][0] = MMM;
            dyn[i + 1][1] = min(dyn[i][1], dyn[i][0]) | mask;
          }
        } else {
          if (a[1] & mask) {
            dyn[i + 1][0] = MMM;
            dyn[i + 1][1] = dyn[i][1]; 
          } else {
            dyn[i + 1][0] = dyn[i][0];
            dyn[i + 1][1] = dyn[i][1];
          }
        }
      }
      //cout << " for I+1 " << i + 1 << " mask:  " << mask << " dyn ::: "  << dyn[i + 1][0] << " ::: " << dyn[i + 1][1] << endl;
      assert (dyn[i + 1][1] > a[1]);
      assert (dyn[i + 1][0] >= MMM || dyn[i + 1][0] <= a[1]);
    }
    if (dyn[maxr][0] < MMM) {
      assert (dyn[maxr][0] == a[1]);
      if ((dyn[maxr][0] ^ (sum - dyn[maxr][0])) != xo) {
        cout << -1 << endl; 
      } else cout << 0 << endl;
    } else {
      if (dyn[maxr][1] >= sum) {  //|| ((dyn[maxr][1] ^ (sum - dyn[maxr][1])) != xo)) {
        cout << -1 << endl; 
      } else {
        assert (dyn[maxr][1] > a[1]);
        cout << dyn[maxr][1] - a[1] << endl; 
      }
    }

  }
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

template <typename T, T mod>
class ModuloCombination {
 private:
  std::vector<T> factrial, inverse_factrial;
  T Pow(T x, T y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return Pow(x * x % mod, y / 2);
    return x * Pow(x, y - 1) % mod;
  }

 public:
  ModuloCombination(T n) : factrial(n + 1), inverse_factrial(n + 1) {
    inverse_factrial[0] = factrial[0] = 1;
    for (T i = 1; i <= n; i++) {
      factrial[i] = factrial[i - 1] * i % mod;
      inverse_factrial[i] = Pow(factrial[i], mod - 2);
    }
  }
  T operator()(T n, T k) { return factrial[n] * inverse_factrial[k] % mod * inverse_factrial[n - k] % mod; }
};

int main() {
  int n, k;
  cin >> n >> k;
  ModuloCombination<ll, mod> c(n);
  for (int i = 1; i <= k; i++) {
    cout << c(k - 1, i - 1) * (n - k + 1 >= i ? c(n - k + 1, i) : 0) % mod << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	ll H, A;
	cin >> H >> A;
	puts((H + A - 1) / A);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = -1;
    if(a<=9 && b<=9)ans = a*b;

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A + B > C + D)      cout << "Left" << endl;
    else if(A + B < C + D) cout << "Right" << endl;
    else                   cout << "Balanced" << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    unsigned long long n,a,b;
    cin >> n>>a>>b;
    if((b-a)%2==0) cout << (b-a)/2;
    else{
        cout << min({n-a,b-1,(n-b)+(b-a+1)/2,(a-1)+(b-a+1)/2});
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> data(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
        sum += data.at(i);
    }

    int count = 0;
    for(int i = 0; i < n; i++){
        if (data.at(i) >= sum / (4.0 * m)){
            count++;
        }
    }

    cout << (count >= m ? "Yes" : "No") << endl;
}


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




int main(void) {
  int n;
  cin >> n;
  int a[100001];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  int t = a[n/2] - a[n/2-1];
  cout << t << endl;
  
 
   
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m, k;
int c[100001];
struct edge {
    int x, y, w;
    void scan() {
        cin >> x >> y >> w;
    }
    bool operator<(const edge &p) const {
        return w < p.w;
    }
} es[100000];

int par[200001];
int find(int x) {
    if (par[x]) return par[x] = find(par[x]);
    return x;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i) {
        cin >> c[i];
        if (c[i] == 0) c[i] = i + k;
	}
	for (int i = 0; i < m; ++i) {
        es[i].scan();
	}
	sort(es, es + m);
	int cnt = 0;
	llong sum = 0;
	for (int i = 0; i < m; ++i) {
        int x = find(c[es[i].x]);
        int y = find(c[es[i].y]);
        if (x == y) continue;
        ++cnt;
        sum += es[i].w;
        par[x] = y;
        if (cnt == k - 1) break;
	}
	if (cnt < k - 1) {
        printf("-1\n");
        return 0;
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li x; cin >>x;
  int h00,h;
  h00=x/500*1000; x%=500;
  h=x/5*5;
  print(h00+h);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
//#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}


signed main(){

  int v,e,r;
  cin>>v>>e>>r;

  WG<int> g(v);
  rep(i,e){
    int a,b,c;
    cin>>a>>b>>c;
    g[a].emplace_back(b,c);
  }
  for(auto &dist:dijkstra(g,r)){
    if(dist == numeric_limits<int>::max())
      cout<<"INF"<<endl;
    else
      cout<<dist<<endl;
  }
}



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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        lld n, k;
        cin >> n >> k;
        lld ans = -1;
        vector<lld> deno;
        for(lld i = 1; i <= n; i++) {
            lld sc = i;
            lld turn = 0;
            while(sc < k) {
                sc = 2 * sc;
                turn++;
            }
            lld val = (1 << turn) * 1LL;
            deno.push_back(val);
            ans = max(ans, val);
        }
        lld num = 0;
        for(lld i = 0; i < deno.size(); i++) {
            num += (ans / deno[i]);
        }
        // cout << num << " " << ans * n << "\n";
        cout << fixed << setprecision(10) << (num * 1.0 / (ans * n)) << "\n";
    }
}

Measured memory_bytes: 1400
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		int[] num=new int[n];
		String[] buf=sc.nextLine().split(" ");
		for(int i=0; i<n; i++){
			num[i]=Integer.parseInt(buf[i]);
		}
		Arrays.sort(num);
		
		System.out.println(Math.abs(num[0]-num[num.length-1]));
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
}


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


public class Contest
{
	public static void Main()
	{

/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) MyIO.ReadArray(out e[i]);

		int[] a;
		MyIO.ReadArray(out a);

        long a,b,c,d,e,f;
        MyIO.ReadMulti(out a, out b, out c, out d, out e, out f);

		MyIO.WriteArray(ans);
*/

        int n;
		MyIO.ReadMulti(out n);
		string[] s = new string[n];
        for(int i=0; i<n; i++) {
			string id;
			MyIO.ReadMulti(out id);
			char[] sd = id.ToCharArray();
		    Array.Sort(sd);
			s[i] = new string(sd);
		}

		Array.Sort(s);
		int[] a = new int[n];
		String bs = "";
		int k=0;
        for(int i=0; i<n; i++) {
			if(bs==s[i]){
				a[k]++;
			}else{
				k++;
			}
			bs=s[i];
		}



		long ans = 0;

        for(int i=0; i<=Math.Min(k,n-1); i++) {
			long w = (long)a[i];
           ans+= w*(w+1)/2;			


		}

		Console.Write(ans);
	}


}

public static class MyIO
{
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
	                                  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	                                  : eq<T, double>() ? ct<T, double>(double.Parse(s))
	                                  : eq<T, char>()   ? ct<T, char>(s[0])
	                                                    : ct<T, string>(s);
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 												
		a = System.Array.ConvertAll(ar, new Converter<string,T>(cv<T>));
		return ar;
	}										
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}

	public static void WriteArray<T>(T[] a) {
		Console.WriteLine(string.Join(" ", Array.ConvertAll(a, x => x.ToString())));
	}


}




Measured memory_bytes: 23364
#include<stdio.h>
int main(void)
{
  int n,i,o;
  while(scanf("%d",&n)==1){
    for(o=i=0;n;i++,n>>=1){
      if(n&1){
	if(o)putchar(' ');
	o=printf("%d",1<<i);
      }
    }
    puts("");
  }
  return 0;
}

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


Measured memory_bytes: 2104
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  ll h, a;
  cin >> h >> a;
  ll ans = ceil((double)h/(double)a);
  cout << ans << endl;
  return 0;
}


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

int main(){
    string ocelo;
    cin >> ocelo;
    int a = 0;
    int b = 0;
    int N = ocelo.size();
    for(int i=0; i < N; i++){
        if(i%2 == 0){
            if(ocelo.at(i)=='1'){//0101010...を目指す場合
                b ++;
            }else{//1010101010を目指す場合
                a ++;
            }
        }else{
            if(ocelo.at(i)=='1'){//0101010...を目指す場合
                a ++;
            }else{//1010101010を目指す場合
                b ++;
            }
        }
    }
    cout << min(a,b) << endl;

}


Measured memory_bytes: 512
nums = int(input())
tmp = list()
for num in range(nums):
    tmp.append([int(_) for _ in str(input()).split(" ")])

for num, case in enumerate(tmp):
    t, x, y = case
    if t < abs(x) + abs(y):
        print("No")
        break
    else:
        if ((abs(x) + abs(y)) % 2) and (t % 2):
            if num +1 == len(tmp):
                print("Yes")
        elif ((abs(x) + abs(y)) % 2 == 0) and (t % 2 == 0):
            if num +1 == len(tmp):
                print("Yes")
        else:
            print("No")
            break


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

int main() {
	int n,t;
	int num[100005] = {};
	cin >> n >> t;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		num[a]++;
		num[b]--;
	}
	int ma = num[0];
	for(int i = 1;i <= t;i++){
		num[i] += num[i - 1];
		ma = max(num[i],ma);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3508
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
if N%2==1:
    n = N//2
    print(sorted(B, reverse=True)[n]-sorted(A)[n]+1)
    exit()
l, r = (N-2)//2, N//2
A.sort()
B.sort()
print(-A[r]-A[l]+B[r]+B[l]+1)


Measured memory_bytes: 27064
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, K) = get!(usize, i64);
    let A = get!(Vec<i64>);

    // 解の候補はsum(A)の約数である
    let s = A.iter().sum::<i64>();
    let D = (1..s).take_while(|d| d * d <= s).collect::<Vec<_>>();
    let D2 = (1..s).take_while(|d| d * d <= s).map(|d| s / d).collect::<Vec<_>>();
    let ans = D.iter().chain(D2.iter())
        .filter(
            |&d|
            {
                let mut B = A.iter()
                    .map(|a| a % d)
                    .collect::<Vec<_>>();
                B.sort();
                let mut acc = vec!(0; N + 1);
                let mut rev_acc = vec!(0; N + 2);
                for i in 0..N {
                    acc[i + 1] = B[i] + acc[i];
                    rev_acc[N - i] = (d - B[N - i - 1]) + rev_acc[N - i + 1]
                }
                (0..(N + 1)).any(|i| acc[i] <= K && acc[i] == rev_acc[i + 1])
            }
        )
        .max()
        .unwrap();

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int ans=0;
  int sn=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='T'){
      if(sn==0)ans++;
      else sn--;
    }
    else{
      sn++;
    }
  }
  cout<<ans+sn<<endl;
}

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

#define   ipair         pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   ll            unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int mod  =  1000000007;
const ld  pi   =  acos(-1);
const int Maxn =  100005;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}


int main(){ IOS;
    int shift;  cin>>shift;  
    string s;   cin>>s;
    int n = s.size();
    vector<int > A(n);
    fr(i,0,s.size())    A[i] = s[i]-'A';
    fr(i,0,n){
        A[i] += shift;
        A[i] %= 26;
    }
    fr(i,0,n)   s[i] = A[i] + 'A';
    cout<<s<<endl; 
}

Measured memory_bytes: 384