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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
double P[int(2e5+5)], sum[int(2e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++){
    cin >> P[i]; P[i]++;
    sum[i] = sum[i-1] + P[i];
  }

  double M = sum[K];
  for (int i = K; i <= N; i++){
    M = max(sum[i] - sum[i - K], M);
  }
  cout << setprecision(16) << M / 2 << endl;

  return 0;
}


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

int main(void){
    int n;
    cin>>n;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin>>a;
        mp[a]++;
    }
    ll ans=0;
    for(auto p : mp){
        if(p.second>=p.first) ans+=(p.second-p.first);
        else ans+=p.second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
int main()
{
    int w,a,b,t;
    scanf("%d%d%d",&w,&a,&b);
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(b>a+w)
        printf("%d",b-a-w);
    else
        printf("0");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] nums = new int[N];
		for(int i=0;i<N;i++){
			nums[i] = sc.nextInt();
		}
		int pivot = partition(nums,0,nums.length-1);
		for(int i=0;i<N;i++){
			if(i>0) System.out.print(" ");
			if(i==pivot){
				System.out.print("[");
			}
			System.out.print(nums[i]);
			if(i==pivot){
				System.out.print("]");
			}
		}
		System.out.println();
		sc.close();
	}
	public static int partition(int[] nums,int p,int r){
		int x = nums[r];
		int i=p-1;
		for(int j=p;j<r;j++){
			if(nums[j]<=x){
				i++;
				swap(nums,i,j);
			}
		}
		swap(nums,i+1,r);
		return i+1;
	}
	public static void swap(int[] nums,int i,int j){
		int temp = nums[i];
		nums[i] = nums[j];
		nums[j] = temp;
	}
}

Measured memory_bytes: 71860
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

enum int INF = 1 << 28;

alias Node = Tuple!(int, "value", int, "index");
bool comp(Node a, Node b) {
	if (a.value != b.value) {
		return a.value < b.value;
	}
	return a.index > b.index;
}

void main() {
	int n = readln.chomp.to!int;
	auto x = readln.chomp.split.map!(to!int).array;
	Node[] arr = new Node[](n);
	foreach (int i, v; x) {
		arr[i] = Node(v, i);
	}
	std.algorithm.sort!comp(arr);
	debug arr.writeln;
	debug arr.length.writeln;
	debug writeln = n / 2;
	immutable target = arr[n / 2];
	debug target.writeln;
	auto left = arr.assumeSorted!comp.lowerBound(Node(target.value, -INF)).back;
	debug "hello".writeln;
	debug left.writeln;
	foreach (i; 0..n) {
		debug writefln("[%d] %d", i, x[i]);
		Node dst = target;
		if (Node(x[i], i) >= left) {
			dst = arr[(n - 1) / 2];
		}
		dst.value.writeln;
	}
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> data(M);
  for (int i = 0; i < M; i++) {
    cin >> data.at(i);
  }
  int sum = 0;
  for (int i = 0; i < M; i++) {
    sum += data.at(i);
  }
  if (N - sum >= 0) {
    cout << N - sum << endl;
  }
  else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define nn 65536*8
#define ll long long
ll n;ll pa[nn];
ll bel[nn];
ll fin(ll x)
{
	if(bel[x]==x) return x;
	return bel[x]=fin(bel[x]);
}
struct status{
	ll c0,c1;
	ll x;
};
bool operator<(status a,status b)
{
	if(a.c0*b.c1!=b.c0*a.c1)
		return a.c0*b.c1>b.c0*a.c1;
	return a.x>b.x;
}
set<status> tot;
ll ans=0;
status cs[nn];
status merge(status a,status b)//b is parent
{
//	assert(tot.count(a));assert(tot.count(b));
	tot.erase(a);
	if(b.x>1) tot.erase(b);
	status c;
	c.x=bel[a.x]=b.x;
	c.c0=a.c0+b.c0;c.c1=a.c1+b.c1;
	ans=ans+1ll*a.c0*b.c1;
	cs[c.x]=c;
	return c;
}
int main()
{
	scanf("%lld",&n);
	for(ll i=2;i<=n;i++) scanf("%lld",&pa[i]);
	for(ll i=1;i<=n;i++)
	{
		ll x;scanf("%lld",&x);
		status s;s.x=i;
		s.c0=!x,s.c1=x;
		cs[s.x]=s;bel[i]=i;
		if(s.x!=1) tot.insert(s);
	}
	while(tot.size())
	{
		status o=*tot.begin();assert(fin(o.x)==o.x);
		status cc=merge(o,cs[fin(pa[o.x])]);
		if(cc.x!=1) tot.insert(cc);
	}
	assert(cs[1].c0+cs[1].c1==n);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 23040
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    print $ solve a b

solve a b | a <= 2 * b = 0
          | otherwise = a - 2 * b

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

const Long N = 302;
const Long mod = 1e9 + 7;

vector< pair<Long,Long> > fin[N];
Long n, m;
Long memo[N][N][N];

Long dp(Long p1, Long p2, Long p3){
	if(memo[p1][p2][p3] != -1){
		return memo[p1][p2][p3];
	}
	
	Long mx = max({p1,p2,p3});
	for(Long i = 0; i < (Long)fin[mx].size(); i++){
		Long cnt = 0;
		if(fin[mx][i].first <= p1) cnt++;
		if(fin[mx][i].first <= p2) cnt++;
		if(fin[mx][i].first <= p3) cnt++;
		if(cnt != fin[mx][i].second){
			memo[p1][p2][p3] = 0;
			return 0;
		}
	}
	
	Long pos = mx+1;
	if(pos == n+1){
		return 1;
	}
	
	Long ans = 0;
	ans += dp(pos,p2,p3);
	ans %= mod;
	ans += dp(p1,pos,p3);
	ans %= mod;
	ans += dp(p1,p2,pos);
	ans %= mod;
	memo[p1][p2][p3] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;
	
	for(Long i = 0; i < N; i++){
		for(Long j = 0; j < N; j++){
			for(Long k = 0; k < N; k++){
				memo[i][j][k] = -1;
			}
		}
	}
	
	Long l, r, c;
	cin >> n >> m;
	
	for(Long i = 0; i < m; i++){
		cin >> l >> r >> c;
		fin[r].push_back({l,c});
	}
	//sdf
	cout << dp(0,0,0) << "\n";
	return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  priority_queue<int> pq;
  rep(i,N){
    int t;
    cin>>t;
    pq.push(t);
  }
  
  rep(i,M){
    int max=pq.top();
    max=max/2;
    pq.pop();
    pq.push(max);
  }
  
  int64_t answer=0;
  rep(i,N){
    answer+=pq.top();
    pq.pop();
  }
  cout<<answer;
}

Measured memory_bytes: 892
def solve():
    N,K = [int(i) for i in input().split()]
    min_N = N
    if min_N > K:
        min_N = min_N - (min_N//K)*K
    min_N = min(min_N, abs(min_N-K))
    print(min_N)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9176
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve [a, b]
  | a < 10 && b < 10 = a * b
  | otherwise = -1

main = solve <$> readInts >>= print

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

int main(){
    const int T_MAX = 105;
    int K, T, a[T_MAX];

    cin >> K >> T;
    int max = -1, max_i = -1;
    for(int i = 0; i < T; i++){
        cin >> a[i];
        if(max < a[i]){
            max = a[i];
            max_i = i;
        }
    }

    int res = max;
    for(int i = 0; i < T; i++){
        if(i != max_i){
            res -= a[i];
        }
    }

    if(res - 1 < 0){
        cout << 0 << endl;
    }else{
        cout << res - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for( int i=0; i<n; ++i ) {
        double x1, y1, x2, y2, x3, y3, x4, y4;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        cout << ( ( ( y2 - y1 ) * ( x4 - x3 ) == ( y4 - y3 ) * ( x2 - x1 ) ) ? "YES" : "NO" ) << endl;
    }
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>

using namespace std;

int a[100];
int n;

int bubble_sort(void){

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

int main(void){

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

  int ans = bubble_sort();
  for( int i = 0 ; i < n ; i++ ){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int n,k;
    cin>>n>>k;
    vector<int64_t> a(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-k){
        if(a[i]<a[i+k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4844
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int popcnt(int n){
  int sum=0;
  while(n){
    sum+=n&1;
    n>>=1;
  }
  return sum;
}

void run(void){
  const int mod=1000000000+7;
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n*n,sizeof(int));
  int i;
  for(i=0;i<n*n;i++) scanf("%d",a+i);
  int *dp=(int *)calloc(1<<n,sizeof(int));
  dp[0]=1;
  for(i=1;i<(1<<n);i++){
    int k=popcnt(i)-1;
    int local=0;
    int j;
    for(j=0;j<n;j++){
      if(((i>>j)&1)==0) continue;
      if(a[k*n+j]){
	local=(local+dp[i^(1<<j)])%mod;
      }
    }
    dp[i]=local;
  }
  printf("%d\n",dp[(1<<n)-1]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec));
  int ANS = 0;
  for (int i = 1; i < 1e5+1; i++)
  {
    int A = i -1;
    int B = i + 1;
    int X = distance(lower_bound(ALL(vec),A),upper_bound(ALL(vec),B));
    chmax(ANS,X);
    // if(i==2) DEBUG(X);
  }
  cout<<ANS<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

A, B, C, X = map(int, open(0).read().split())

count = 0

for a in range(0, A+1):
    for b in range(0, B+1):
        for c in range(0, C+1):
            money = 500 * a + 100 * b + 50 * c
            if money == X:
                count += 1

print(count)

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N,X;
    scanf("%lld", &N);
    REP(int,i,0,50000){
        X = i * 1.08;
        if ( N == X ){
            printf("%lld\n", i);
            return 0;
        }
    }
    printf(":(\n");
    return 0;
}

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

const int mod = 1000000007;

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

  int ans = 0;
  int x = 0;
  for (int i = 0; i < n; i++)
  {
    ans = (ans + (ll)a[i] * x) % mod;
    x = (x + a[i]) % mod;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int array[10];
  
  for(int i=0; i<10; i++){
    std::cin >> array[i];
  }
  
  std::vector<int> vector(array, array+10);
  std::sort(vector.begin(), vector.end(), std::greater<int>());
  for(int i=0; i<3; i++){
    std::cout << vector[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3116
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string N=Console.ReadLine();
     if(N.IndexOf("9")!=-1){
      Console.WriteLine("Yes");
     }else{
       Console.WriteLine("No");
     }
    }
    
  }

}


Measured memory_bytes: 26116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s1,s2;
    cin>>s1>>s2;
    int flag=0;
    for (int i=0;i<3;i++) {
        if (s1.at(i)!=s2.at(2-i)) {
            cout<<"NO"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"YES"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int col[501][501];
int d[501][501];
int mod0[31];
int mod1[31];
int mod2[31];

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

	for (int i = 1; i <= c; i++){
		for (int j = 1; j <= c; j++){
			cin >> d[i][j];
		}
	}
	int cnt0 = 0, cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			cin >> col[i][j];
			if ((i+j) % 3 == 0) mod0[col[i][j]]++;
			if ((i+j) % 3 == 1) mod1[col[i][j]]++;
			if ((i+j) % 3 == 2) mod2[col[i][j]]++;
		}
	}
	int ans = MOD;
	for (int i = 1; i <= c; i++){
		for (int j = 1; j <= c; j++){
			for (int k = 1; k <= c; k++){
				if (i != j && j != k && k != i){
					int temp = 0;
					for (int l = 1; l <= c; l++){
						temp += d[l][i]*mod0[l];
						temp += d[l][j]*mod1[l];
						temp += d[l][k]*mod2[l];
					}
					ans = min(ans, temp);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4636
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    ll a,b,x,ans;
    cin>>a>>b>>x;
    if (a==0) ans=b/x+1;
    else ans=(b/x+1)-(a-1)/x-1;
    
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
    complex<double> a,b,c,d,e,f,x,y;
    double p,q;
    cin>>p>>q;
    a=complex<double>(p,q);
    cin>>p>>q;
    b=complex<double>(p,q);
    e=b-a;
    f=complex<double>(-e.imag(),e.real());
    x=b+f;
    y=b+f-e;
    cout<<x.real()<<" "<<x.imag()<<" "<<y.real()<<" "<<y.imag();
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<utility>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
//typedef pair<int,int>P;

//先頭と末尾のpairを求める．pair<int,int>で返す
pair<int,int> f(int x)
{
  //pair<int,int> pa;
  int a,b;
  b=x%10;
  while(x)
  {
    a=x;
    x/=10;
  }
  return pair<int,int>(a,b);
}

int main()
{ 
  int N,a,b,i;
  long long ans;
  cin>>N;//読む
  ans=0;
  pair<int,int>pa;
  pair<int,int>ap;
  map<pair<int,int>,int>mp;//pairのmapを取る
  for(i=1;i<=N;i++)
  {
    pa=f(i);
    mp[pa]++;
  }
  
  for(i=1;i<=N;i++)
  {
    pa=f(i);
    ap=pair<int,int>(pa.second,pa.first);//末尾と先頭を入れ替える
    ans+=mp[ap];//入れ替えたときにその組み合わせを探す．
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


N = int(sys.stdin.readline())

divs = get_divisors(N)
ans = INF
for d in divs:
    a = N // d
    b = d
    ans = min(ans, a + b)
print(ans - 2)


Measured memory_bytes: 13648
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode/utf8"
)

const (
	L = 'L'
	R = 'R'
)

var SIntListInitialValue int
var SIntListIsInitialized bool
var SIntListRecFunc func(int) int = nil

type SIntList []int

func lib_NewSIntList(length int, initialValue int) SIntList {
	if SIntListIsInitialized {
		panic("SIntList is already used")
	}
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	SIntListInitialValue = initialValue
	return ret
}
func lib_TernaryOPInt(ok bool, v1, v2 int) int {
	if ok {
		return v1
	}
	return v2
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var S string
	scanner.Scan()
	S = scanner.Text()
	solve(S)
}
func (si SIntList) Rec(f func(index int) int) {
	SIntListRecFunc = f
}
func (si SIntList) Update(index int) int {
	if SIntListRecFunc == nil {
		panic("SIntListRecFunc is nil")
	}
	if si[int(index)] != SIntListInitialValue {
		return si[int(index)]
	}
	ret := SIntListRecFunc(index)
	si[int(index)] = ret
	return ret
}
func solve(S string) {
	s := []rune(S)
	N := utf8.RuneCountInString(S)
	lastPos := lib_NewSIntList(N, -1)
	count := make([]int, N, N)
	lastPos.Rec(func(i int) int {
		nextPos := lib_TernaryOPInt(s[i] == R, i+1, i-1)
		if s[nextPos] != s[i] {
			return i
		}
		lPos := lastPos.Update(nextPos)
		return lPos + lib_TernaryOPInt(s[lPos] == L, -1, 1)
	})
	for i := 0; i < len(lastPos); i++ {
		count[lastPos.Update(i)]++
	}
	for i := 0; i < len(count)-1; i++ {
		fmt.Print(count[i], " ")
	}
	fmt.Println(count[len(count)-1])
}


Measured memory_bytes: 34176
// 2019.9.9 bal4u
// Template for Online Contest

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

int cmp_int(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int main()
{
	int H, W, h, w, white, black;

	H = in(), W = in(), h = in(), w = in();
	white = H*W, black = h*W+w*H-h*w;
	out(white-black);
	return 0;
}


Measured memory_bytes: 128
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000009;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

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

	ll n, k;
	cin >> n >> k;
	double res = 0;
	for(int i=1; i<=n; i++) {
		ll r = 0, j = i;
		while(j < k) {
			j *= 2;
			r++;
		}
		res += pow(0.5, r) / n;
	}
	cout << fixed << setprecision(12) << res << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
   long long k;
   long long x;
   cin>>k>>x;
   long long l=x-(k-1);
   long long r=x+(k-1);
   if(l<=-1000000){
       l=-1000000;
   }
   if(r>=1000000){
       r=1000000;
   }
   for(long long i=l; i<=r; i++){
       cout<<i<<endl;
   }
}





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


int main(){
  	int n;
  	cin >> n;
	long nn= 2;
  	long tmp = -1,tmp2 = 0;
  
	for(int i = 1; i <= n; i++) {
    	tmp2 = nn;
      	nn += tmp;
      	tmp = tmp2;
    }
  	cout << nn << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
	long long  N;
	long long input;
	vector<long long> A;
	vector<long long > B;
	long long i;
	long long total = 0;
	cin >> N;
	for (i = 0; i < N+1; i++) {
		cin >> input;
		A.push_back(input);
	}
 
	for (i = 0; i < N; i++) {
		cin >> input;
		B.push_back(input);
	}
 
	for (i = 0; i < N; i++) {
		if((A[i] - B[i]) >= 0) total += B[i];
		else {
			total += A[i];
			if((A[i+1] - abs(A[i] - B[i])) >= 0) {
				total += abs(A[i] - B[i]);
				A[i+1] -= abs(A[i] - B[i]);
			}
				
			else {
				total += A[i+1];
				A[i+1] = 0;
			}
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for(int (i) = (n)-1; (i) >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define FI first
#define SE second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}



int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  int q;
  cin >> q;
  int ans = 0;
  rep(qi,q) {
    int b;
    cin >> b;
    if(mp.count(b)) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7832
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
#define MOD3 999999937
ll power(ll a, ll b){ll res=1;a=a%MOD1;while(b>0){if(b&1){res=(res*a)%MOD1;}a=(a*a)%MOD1;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD1-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo INT_MAX

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    fo(i,n){
        cin>>a[i];
    }
    ll ans = 0;
    sort(a,a+n,greater<ll>());
    ll c = 0;
    ll l = 0;
    fo(i,n){
        if(i==0){c++;continue;}
        if(c%2==0)l++;
        ans+=a[l];
        c++;
    }
    cout<<ans;
}

int main(){
    Boost();
    #ifndef ONLINE_JUDGE 
    kill
    #endif
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
 
 
 
 
 

Measured memory_bytes: 5216
import sys
from itertools import accumulate
h, w = [int(i) for i in sys.stdin.readline().split()]
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
cumsum = [j for j in accumulate(a_ls)]
start = [0,0]
flg = True
_map = [[0 for i in range(w)] for j in range(h)]
color = 1
cnt = 0
while True:
    if cnt in cumsum:
        color += 1
    y, x = start
    _map[y][x] = color
    if flg:
        if x + 1 >= w:
            if y + 1 >= h:
                break
            flg = False
            y += 1
        else:
            x += 1
    else:
        if x - 1 < 0:
            if y + 1 >= h:
                break
            y += 1
            flg = True
        else:
            x -= 1
    _next = [y, x]
    start = _next
    cnt += 1

for y in range(h):
    print(" ".join([str(j) for j in _map[y]]))

Measured memory_bytes: 41200
#include<stdio.h>

int main(){
   int a[10010];
   int n,m;
   int x = 0;
   scanf("%d %d", &n, &m);

   for(int i = 0; i < m; i++){
      scanf("%d", &a[i]);
   }

   for(int i = 0; i < m; i++){
      x += a[i];
   }
   if(x > n){
      printf("-1\n");
   }else{
      printf("%d\n", n-x);
   }
   return 0;
}


Measured memory_bytes: 1736
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
for _ in range(m):
    p,s = map(str, input().split())
    p=int(p)
    if AC[p-1]==0:
        if s=="AC":
            AC[p-1]=1
        else:
            WA[p-1]+=1
penalty=0
for i in range(n):
    if AC[i]==1:
        penalty+=WA[i]
print(sum(AC),penalty)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

const int p = 1e9 + 7;

int n, m, k;
int x, y;
vector<int> v1[maxn];
vector<vector<int> > v2;
int dfn[maxn], low[maxn], cnt;
int sk[maxn], top;

void dfs1(int i){
	dfn[i] = low[i] = ++cnt, sk[++top] = i;
	for(int j = 0;j < v1[i].size();j++){
		int to = v1[i][j];
		if(!dfn[to]){
			dfs1(to);
			low[i] = min(low[i], low[to]);
			if(dfn[i] == low[to]){
				vector<int> v; 
				v.push_back(i);
				while(sk[top + 1] != to) v.push_back(sk[top--]);
				//一定要注意是弹到to为止 而不是到栈顶是i 因为中间可能还有别的！！
				v2.push_back(v); 
			} 
		}else{
			low[i] = min(low[i], dfn[to]);
		}
	}
}

inline int fpow(int x, int y){
	int ans = 1;
	while(y){
		if(y & 1) ans = 1ll * ans * x % p;
		x = 1ll * x * x % p, y >>= 1;
	}
	return ans;
}

int sum[maxn], inv[maxn];

inline int C(int n, int m){
	return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
}

inline int polya(int n){
	int sum = 0;
	for(int i = 0;i < n;i++) sum = (sum + fpow(k, __gcd(i, n))) % p;
	return 1ll * sum * fpow(n, p - 2) % p;
}

bool vis[maxn];
int ans = 1;

int main(){
	sum[0] = 1;for(int i = 1;i < maxn;i++) sum[i] = 1ll * sum[i - 1] * i % p;
	inv[maxn - 1] = fpow(sum[maxn - 1], p - 2);
	for(int i = maxn - 2;~i;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1;i <= m;i++){
		scanf("%d%d", &x, &y);
		v1[x].push_back(y), v1[y].push_back(x);
	}
	dfs1(1);
	for(int i = 0;i < v2.size();i++){
		vector<int> v = v2[i];
		for(int j = 0;j < v.size();j++) vis[v[j]] = true;
		int sum = 0;
		for(int j = 0;j < v.size();j++){
			x = v[j];
			for(int l = 0;l < v1[x].size();l++) sum += vis[v1[x][l]];
		}
		if(!m) continue;
		m -= (sum >>= 1);
		x = v.size();
		if(sum == x) ans = 1ll * ans * polya(x) % p;
		else ans = 1ll * ans * C(sum + k - 1, k - 1) % p;
		for(int j = 0;j < v.size();j++) vis[v[j]] = false;
	}
	printf("%d", 1ll * ans * fpow(k, m) % p);
}

Measured memory_bytes: 6912
# -*- coding: utf-8 -*-

# 関数定義
def dfs(now_p, visited, comb_p, p_num):
    # N頂点と同じ数のルートを通ったら有効なパスとして1を返す
    if len(visited) == p_num:
        return 1

    ans = 0

    # now_pの検索
    for tmp_p in comb_p:
        if tmp_p[0] == now_p and tmp_p[1] not in visited:
            # visitedのtmp
            tmp_visited = visited[:]
            tmp_visited.append(tmp_p[1])
            #print(*tmp_visited)
            # 次の頂点
            next_p = tmp_p[1]
            #print('next_p: ', next_p)
            # comb_pのtmp
            tmp_comb = comb_p[:]
            tmp_comb.remove(tmp_p)
            # 往復対象の削除
            tmp_p_r = [tmp_p[1], tmp_p[0]]
            tmp_comb.remove(tmp_p_r)
            #print(*tmp_comb)
            # dfsの再起呼び出し
            ans += dfs(next_p, tmp_visited, tmp_comb, p_num)

    return ans

## 入力読み取り
N, M = map(int, input().split())
a_b = []
tmp = []
tmp_r = []

# 辺読み取り
for i in range(M):
    tmp = list(map(int, input().split()))
    tmp_r = [tmp[1], tmp[0]]
    a_b.append(tmp)
    a_b.append(tmp_r)

visited = [1]

# 再起関数の実施
pass_num = dfs(1, visited, a_b, N)
print(pass_num)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,k; cin>>n>>k;
    int p[n];
    rep(i,n)cin>>p[i];

    int sum=0;
    rep(i,k)sum+=p[i];
    int mx=sum;
    rep2(i,k,n)
    {
        sum+=p[i]-p[i-k];
        mx=max(mx,sum);
    }
    double ans=mx+k;
    printf("%.12lf\n",ans/2);
}

Measured memory_bytes: 1024
#include <iostream>
#include <list>
#include <string>
#include <algorithm>//std::find
#include <functional>
#include <set>
using namespace std;

int main(void){
	std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
	
	
	int n;
	cin >> n;
	std::string command;
	std::string str;
	//list<string> dictionary;
	std::set<string>dictionary;
	//list<string> ans;
	for(int i=0 ; i < n; i++){
		cin >> command;
		if(command == "insert"){
			cin >> str;
			
			
			
			
			dictionary.insert(str);
			//dictionary.sort();
			
			
		}
		if(command == "find"){
			cin >> str;
			//list<string>::iterator itr = std::find(dictionary.begin(), dictionary.end(), str);
			//dictionary.find(str);
			set<string>::iterator itr = dictionary.find(str);
			
			if(itr != dictionary.end()){
				cout << "yes" << endl;
				//ans.insert(ans.begin(), "no")
			}else cout << "no" << endl;
		}
			
			
		
	}
	
}

Measured memory_bytes: 27812
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    cin>>N;

    vector<int> D;
    for(int i = 0;i < N;i++) {
        int d;
        cin>>d;
        D.push_back(d);
    }

    sort(D.begin(),D.end());
    int mid = N/2;
    int ml = D[mid-1];
    int mr = D[mid];

    cout<<mr-ml<<endl;

    return 0;
}


Measured memory_bytes: 892
main(){
    int x,y,tmp;
    for(int i=0;;i++){
        scanf("%d %d",&x,&y);
        if( x==y && y==0 )break;
        if(x>y){
            tmp=x;
            x=y;
            y=tmp;
        }
        printf("%d %d\n",x,y);
    }
}


Measured memory_bytes: 2056
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


int main() {
	char X, Y;
	cin >> X >> Y;

	if (X > Y) {
		cout << ">" << endl;
	}
	else if (X < Y) {
		cout << "<" << endl;
	}
	else {
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2*60+M2)-(H1*60+M1)-K << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

int main()
{
	std::string W;
	std::cin >> W;
	int count = 0;
	while (true) {
		std::string T;
		std::cin >> T;
		if (T == "END_OF_TEXT") break;
		
		transform(T.begin(), T.end(), T.begin(), tolower);
		if (T == W) count++;
	}
	std::cout << count << std::endl;
		
	return 0;
}




Measured memory_bytes: 3180
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs(a - b) < EPS)

class Vector {
public:
  double x, y;
  Vector() {}
  Vector(double x, double y) : x(x), y(y) {}

  Vector operator+(Vector v) { return Vector(x + v.x, y + v.y); }
  Vector operator-(Vector v) { return Vector(x - v.x, y - v.y); }
  Vector operator*(double s) { return Vector(s * x, s * y); }
  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }
};

// inner product
double dot(Vector v1, Vector v2) { return v1.x * v2.x + v1.y * v2.y; }

// cross product
double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; }

class Line {
public:
  Vector v1, v2;
  Line() {}
  Line(Vector v1, Vector v2) : v1(v1), v2(v2) {}
};

bool is_parrallel(Vector a, Vector b) { return equals(cross(a, b), 0); }
bool is_parrallel(Line a, Line b) {
  return is_parrallel(a.v1 - a.v2, b.v1 - b.v2);
}

bool is_orthogonal(Vector a, Vector b) { return equals(dot(a, b), 0); }
bool is_orthogonal(Line a, Line b) {
  return is_orthogonal(a.v1 - a.v2, b.v1 - b.v2);
}

Vector project(Line l, Vector v) {
  Vector a = v - l.v1;
  Vector b = l.v2 - l.v1;
  return l.v1 + b * (dot(a, b) / b.norm());
}

Vector reflect(Line l, Vector v) {
  return v + (project(l, v) - v) * 2.0;
}

int main() {
  int x0, y0, x1, y1;
  cin >> x0 >> y0 >> x1 >> y1;
  auto line = Line(Vector(x0, y0), Vector(x1, y1));
  int nq;
  cin >> nq;
  for (int i = 0; i < nq; i++) {
    int x, y;
    cin >> x >> y;
    auto ans = reflect(line, Vector(x, y));
    printf("%.10f %.10f\n", ans.x, ans.y);
  }
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long X,A,B;
	cin >> X >> A >> B;
	if(A >= B){
		cout << "delicious" << endl;
	}else if(B <= A + X){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      Scanner scn = new Scanner(System.in);
      boolean n[]=new boolean[scn.nextInt()+1];
      int h[]=new int[n.length];
      int m=scn.nextInt();
      int ans=0;
      
      for(int i=1;i<h.length;i++){
          h[i]=scn.nextInt();
          n[i]=true;
      }
      for(int i=0;i<m;i++){
          int a=scn.nextInt();
          int b=scn.nextInt();
          if(h[a]<=h[b]){
            n[a]=false;
          }
         if(h[a]>=h[b]){
            n[b]=false;
          }
      }
      for (int i=0;i<n.length;i++){
          if(n[i]) ans++;
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 59636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  vector<vector<tuple<int, int, int>>> G(n);
  for (int i = 0; i < m; i++)
  {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    G.at(u).push_back(make_tuple(a, b, v));
    G.at(v).push_back(make_tuple(a, b, u));
  }
  
  vector<vector<int>> sd(2, vector<int>(n, INF));
  vector<vector<bool>> done(2, vector<bool>(n, false));
  priority_queue<pair<int, int>, vector<pair<int, int>>, 
    greater<pair<int, int>>> que;
  
  for (int i = 0; i < 2; i++)
  {
    if (i == 0) que.push(make_pair(0, s));
    else que.push(make_pair(0, t));
    while (que.size() > 0)
    {
      int C = que.top().first;
      int V = que.top().second;
      que.pop();

      if (done.at(i).at(V)) continue;
      done.at(i).at(V) = true;
      sd.at(i).at(V) = C;
      
      for (int j = 0; j < G.at(V).size(); j++)
      {
        int c;
        if (i == 0) c = get<0>(G.at(V).at(j));
        else c = get<1>(G.at(V).at(j));
        int v = get<2>(G.at(V).at(j));
        if (!done.at(i).at(v))
        { 
          chmin(sd.at(i).at(V), C + c);
          que.push(make_pair(C + c, v));
        }
      }
    }
  }
  
  vector<int> ans(n);
  for (int i = 0; i < n; i++)
  {
    ans.at(i) = pow(10, 15) - sd.at(0).at(i) - sd.at(1).at(i);
  }

  for (int i = n - 2; i >= 0; i--)
  {
    chmax(ans.at(i), ans.at(i + 1));
  }

  for (int i = 0; i < n; i++)
  {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 13696
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector<ll> va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  std::sort(va.begin(), va.end());
  va.erase(std::unique(va.begin(), va.end()), va.end());

  print(va.size());
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC150_E___Change_a_Little_Bit
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var C = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            C = C.OrderByDescending(n => n).ToArray();
            long MOD = 1000000007;

            var result = 0L;
            for (int i = 0; i < N; i++)
            {
                long temp1 = (C[i] * modPow(2, N - i - 1, MOD)) % MOD;
                long temp2 = (temp1 * ((modPow(2, i, MOD) % MOD) + (modPow(2, i - 1, MOD) * i) % MOD)) % MOD;
                result += temp2;
                result %= MOD;
            }
            result *= modPow(2, N, MOD);
            result %= MOD;
            Console.WriteLine(result);
        }
        static long modPow(long a, long n, long mod)
        {
            long result = 1;
            while (n > 0)
            {
                if ((n & 1) > 0) result = result * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return result;
        }
    }
}



Measured memory_bytes: 35968
#include<iostream>

using namespace std;



int main(void){
	int A,B,C[3],max,i;

	cin >> A;
	cin >> B;

	C[0] = A + B;
	C[1] = A - B;
	C[2] = A*B;
	max = C[0];
	for (i = 0; i <= 2; i++){
		if (max < C[i]){
			max = C[i];
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import copy

n = int(input())
arr = [int(input()) for i in range(n)]
brr = sorted(arr, reverse=True)
ind = arr.index(max(arr))
# for i in range(n):
#     brr = copy.copy(arr)
#     brr.pop(i)
#     print(max(brr))
for i in range(n):
    if i == ind:
        print(brr[1])
    else:
        print(brr[0])

Measured memory_bytes: 14584
import math
a,b,x = map(int,input().split())
half = (a * a * b) / 2
p=0
if x > half:
    t = 2 * b - 2 * x / (a*a)
    x1 = a
    y1 = t
    rad = math.atan2(y1, x1)
    p = math.degrees(rad)
elif x == half:
    x1 = a
    y1 = b
    rad = math.atan2(y1, x1)
    p = math.degrees(rad)
else:
    t = 2 * x / (a*b)
    x1 = t
    y1 = b
    rad = math.atan2(y1, x1)
    p = math.degrees(rad)
print(p)

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

int main() {
  int n;
  string s, alphabets, res;
  cin>>n>>s;

  alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for(int i=0; i < s.length(); i++) {
    res += alphabets[(alphabets.find(s[i]) + n) % alphabets.length()];
  }

  cout<<res;

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split();
        int[] H = new int[N];
        int max = 0;
        int temp = 0;
        for (int i = 0; i < N; i++)
        {
            H[i] = int.Parse(input[i]);
            if (i > 0&&H[i-1]>=H[i]) { temp++; }
            else {
                if (temp > max) { max = temp; }
                    temp = 0;
            }
        }
        if (temp > max) { max = temp; }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 25052
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  double answer; // to output 
  int n; // to input 

  scan = scanf("%d", &n);

  answer = n * 2 * 3.141592;

  printf("%lf", answer);
  return (0);
}


Measured memory_bytes: 1740