akhauriyash/Code-Regression huggingface dataset:
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  p;
struct edge{int to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
double EPS=1e-10;
double add(double a,double b){
    if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
    return a+b;
}
struct P{
    double x,y;int num;
    P(){}
    P (double x,double y):x(x),y(y){
    }
    P operator +(P p){
        return P(add(x,p.x),add(y,p.y));
    }
    P operator -(P p){
        return P(add(x,-p.x),add(y,-p.y));
    }
    P operator *(double d){
        return P(x*d,y*d);
    }
    double dot(P p){
        return add(x*p.x,y*p.y);
    }
    double det(P p){
        return add(x*p.y,-y*p.x);
    }
};
int n;P ps[114];
bool comp_x(const P& p,const P& q){
    if(p.x!=q.x)return p.x<q.x;
    else  return p.y>q.y;
}
vector<P> convex_full(P*ps,int n){
    sort(ps,ps+n,comp_x);
    int k=0;
    vector<P> qs(n*2);
    rep(i,0,n){
        while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
        qs[k++]=ps[i];
    }
    for(int i=n-2,t=k;i>=0;i--){
        while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
        qs[k++]=ps[i];
    }
    qs.resize(k-1);
    return qs;
}
//ベクトルの長さを計算する
double get_vector_length( P v ) {
    return pow( ( v.x * v.x ) + ( v.y * v.y ), 0.5 );
}

//ベクトル内積
double dot_product(P vl, P vr) {
    return vl.x * vr.x + vl.y * vr.y;
}

//２つのベクトルABのなす角度θを求める
double AngleOf2Vector(P A, P B )
{
    //　※ベクトルの長さが0だと答えが出ませんので注意してください。
    
    //ベクトルAとBの長さを計算する
    double length_A = get_vector_length(A);
    double length_B = get_vector_length(B);
    
    //内積とベクトル長さを使ってcosθを求める
    double cos_sita = dot_product(A,B) / ( length_A * length_B );
    
    //cosθからθを求める
    double sita = acos( cos_sita );
    
    //ラジアンでなく0～180の角度でほしい場合はコメント外す
    return sita*180.0;
}

signed main(){
    cin>>n;
    rep(i,0,n){
       cin>>ps[i].x>>ps[i].y;
        ps[i].num=i;
    }
    if(n==2){
        rep(i,0,n){
            cout<<0.5<<endl;
        }
        return 0;
    }
    vector<P>key=convex_full(ps,n);
    double ans[114]={};
    int s=key.size();
    rep(i,0,key.size()){
        P a;P b;
        a.x=key[(i+1)%s].x-key[i].x;
        b.x=key[(i-1+s)%s].x-key[i].x;
        a.y=key[(i+1)%s].y-key[i].y;
        b.y=key[(i-1+s)%s].y-key[i].y;
        double al=sqrt((a.x*a.x)+(a.y*a.y));
        double bl=sqrt((b.x*b.x)+(b.y*b.y));
        double th=(a.dot(b))/(al*bl);
        th=max(-1.0,min(1.0,th));
        th=acos(th);
        ans[key[i].num]=(180.0-(th*180.0/M_PI))/360.0;

    }
    rep(i,0,n)cout<<fixed<<setprecision(15)<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = zeros(Int,n)
	for i in 1:n
		a[i] = readline() |> parseInt
	end
	b = Tuple{Int,Int}[(a[i],i) for i in 1:n]
	b = sort(b,by=x->x[1])
	c = zeros(Int,n)
	k = 0
	for i in 1:n
		if b[i][2]%2!=i%2
			c[b[i][2]] += 1
      		k += 1
		end
	end
	
	println((k+1)>>1)
end

main()

Measured memory_bytes: 133124
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;

fn main() {
    input! {
        A: f64,
        B: f64,
        H: f64,
        M: f64
    };

    let thetaH = (H / 12. + M / 60. / 12.) * PI * 2.;
    let thetaM = M / 60. * PI * 2.;

    let (hX, hY) = (thetaH.cos() * A, thetaH.sin() * A);
    let (mX, mY) = (thetaM.cos() * B, thetaM.sin() * B);

    let (dx, dy) = (hX - mX, hY - mY);

    println!("{}", (dx * dx + dy * dy).sqrt());
}

Measured memory_bytes: 2852
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = K

powlist = [2**x for x in range(0,40)]
list1 = [0 for x in range(0,40)]
list0 = [0 for x in range(0,40)]
k = [0 for x in range(0,40)]

for x in range(0,N):
    for y in range(1,41):
        if A[x] >= powlist[-y]:
            A[x] = A[x] - powlist[-y]
            list1[-y] += 1
        else:
            list0[-y] += 1

for y in range(1,41):
        if B >= powlist[-y]:
            B = B - powlist[-y]
            k[-y] += 1

z = 0

for n in powlist:
    if n > K:
        break
    z = n

if z == 0:
    Kindex = 0
else:
    Kindex = powlist.index(z)

answer1 = 0
if K == 0:
    answer2 = 0
else:
    answer2 = powlist[Kindex]*list0[Kindex]

for x in range(0,Kindex):
    answer1 += powlist[x]*max(list1[x],list0[x])
for x in range(Kindex,40):
    answer1 += powlist[x]*list1[x]

for x in range(Kindex-1,-1,-1):
    if k[x] == 0:
        answer2 += powlist[x]*list1[x]
        continue
    if max(list1[x],list0[x]) == list1[x]:
        for y in range(0,x+1):
            answer2 += powlist[y]*max(list1[y],list0[y])
        break
    else:
        answer2 += powlist[x]*list0[x]

for x in range(Kindex+1,40):
    answer2 += powlist[x]*list1[x]

answer = max(answer1,answer2)

print(answer)

Measured memory_bytes: 14620
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333,inf=0x3f3f3f3f;
int n,head[N],to[N],val[N],nxt[N],edgenum;
void add(int u, int v, int w){
	to[++edgenum]=v;val[edgenum]=w;
	nxt[edgenum]=head[u];head[u]=edgenum;
}
int sz[N];ll res;
void dfs(int u, int fa, Pii &r){
	int mx=0;
	sz[u]=1;L(i,u)if(to[i]!=fa)dfs(to[i],u,r),mx=max(mx,sz[to[i]]),sz[u]+=sz[to[i]];
	mx=max(mx,n-sz[u]);r=min(r,Pii(mx,u));
}
void DFS(int u, int fa){
	sz[u]=1;L(i,u)if(to[i]!=fa){
		DFS(to[i],u);res+=2LL*val[i]*sz[to[i]];sz[u]+=sz[to[i]];
	}
}
int main() {
	read(n);rep(i,2,n){int u,v,w;read(u);read(v);read(w);add(u,v,w);add(v,u,w);}
	Pii r(inf,0);dfs(1,0,r);int rt=r.se;DFS(rt,0);
//	cerr << n << ' ' << res << endl;
	if(r.fi*2==n){
		int mn=inf;
		L(i,rt)if(sz[to[i]]==r.fi)mn=val[i];res-=mn;
	}
	else{
		int mn=inf;
		L(i,rt)mn=min(mn,val[i]);res-=mn;
	}
	cout<<res;return 0;
}


Measured memory_bytes: 9088
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h,w;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();

            if(h == 0 && w == 0)    break;
            for(int i = 0;i < h;i++){
                if(i == 0 || i == h - 1){
                    for(int j = 0;j < w;j++){
                        System.out.print("#");
                    }
                    System.out.print("\n");
                }
                else{
                    for(int j = 0;j < w;j++){
                        if(j == 0 || j == w - 1)    System.out.print("#");
                        else    System.out.print(".");
                    }
                    System.out.print("\n");
                }
            }
            System.out.print("\n");
        }
    }
}



Measured memory_bytes: 37008
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;


 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k;
  std::cin>>n>>k;
  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];
  std::sort(all(a));

  ll left=-1,right=n;
  while(right-left>1){
    ll mid=left+(right-left)/2;
    bool flag = false;

    if(a[mid]>=k){
      flag=true;
    }else{
      std::vector<std::vector<bool>> dp(n,std::vector<bool>(k,false));
      dp[0][0]=true;
      rep(i,0,n-1){
        ll temp=i;
        if(temp>=mid)temp++;
        rep(j,0,k){
          dp[i+1][j]=dp[i][j]|dp[i][(j-a[temp]>=0)?j-a[temp]:j];
        }
      }
      rep(i,k-a[mid],k)flag=(flag|dp[n-1][i]);
    }
    if(flag)right=mid;
    else left=mid;
  }

  std::cout<<left+1;
  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";
    cout << '\n';
}


Measured memory_bytes: 3616
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) color[u] = WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j] = 0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
  
  return 0;
}



Measured memory_bytes: 2736
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        var (n, m) = sc.longList()
        val a = Math.min(n, m / 2)
        n -= a
        m -= 2 * a
        val b = m / 4
        println(a + b)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
double ar1[10000000];
int main()
{
    double n,k;
    ll i,j;
    ll m;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>k;
        ar1[i]=(k*(k+1))/(2*k);
    }
    for(i=1;i<=n;i++)
    {
        ar1[i]=ar1[i-1]+ar1[i];
    }
    double ans=0;
    for(i=m;i<=n;i++)
    {
        ans=max(ans,(ar1[i]-ar1[i-m]));
    }
    printf("%.6lf\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main()
{
  ll x;
  cin >> x;
  
  string S;
  cin >> S;

  ll n;
  
  if(S.length()%2==0){
    n = S.length()/2;
  }else{
    cout << "No" << endl;
    return 0;
  }

  ll flag=1;
  
  rep(i,n){
    if(S[i]!=S[i+n]) flag=0;
  }
       
  if(flag==1) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	
	static int w, h;
	static boolean[][] ice;
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long l = sc.nextLong();
		long rem = l - l / 500 * 500;
		println(l / 500 * 1000 + rem / 5 * 5);
	}
	
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};
	
	public static void println(String s) {System.out.println(s);}
	public static void println(long s) {System.out.println(s);}
	public static void println(int s) {System.out.println(s);}
	
	public static void prt(String s) {
		System.out.print(s);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, K; cin >> N >> K;
  vector<int> dist(N, 0);
  rep(i, N){
    int x; cin >> x;
    dist[i] = min(abs(x), abs(x - K));
  }
  int ans = 0;
  rep(i, N) ans += 2 * dist[i];
  cout << ans << endl;

}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


const int MOD = 1000000007;

long long solve(int N, const string &S) {
    if (S[0] == 'W') return 0;

    char prev = 'L';
    int num = 1;
    long long res = 1;
    for (int i = 1; i < N*2; ++i) {
        if (prev == 'L') {
            if (S[i-1] == S[i]) prev = 'R', res *= num--, res %= MOD;
            else prev = 'L', ++num;
        }
        else {
            if (S[i-1] == S[i]) prev = 'L', ++num;
            else prev = 'R', res *= num--, res %= MOD;
        }
    }
    if (num != 0) return 0;

    for (long long i = 1; i <= N; ++i) res = (res * i) % MOD;
    return res;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    cout << solve(N, S) << endl;
}


Measured memory_bytes: 640
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on
#include <boost/math/common_factor_rt.hpp>

void solve(long long N, std::vector<long long> T) {
  ll ans = T[0];
  rep(i, N) ans = boost::math::lcm(ans, T[i]);
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> T(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&T[i]);
  }
  solve(N, std::move(T));
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c){
                System.out.println("Yes");
        }
        else
            System.out.println("No");
        sc.close();
    }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	ll k;cin >> k;
	int ans=0;
	rep(i,s.size()){
		if(s.at(i)=='1' && i+1==k){
			ans=1;
			break;
		}
		else if(s.at(i)!='1'){
			ans=s.at(i)-'0';
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, T: int):
    print(T // A * B)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, B, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		final int MOD = 1_000_000_007;

		int n = sc.nextInt();
		int k = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		long[] tt = new long[n];
		long[] t = new long[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[j] > a[i]) {
					tt[i]++;
					if (j < i) {
						t[i]++;
					}
				}
			}
		}

		long inv2 = modPow(2, MOD - 2, MOD);
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long tmp = (t[i] + t[i] + (k - 1) * tt[i]) % MOD * (k) % MOD * inv2 % MOD;
			ans += tmp;
			ans %= MOD;
		}
		
		pr.println(ans);
	}
	
	static long modPow(long a, long n, int MOD) {
		long loop = n;
		long ret = 1;
		long x = a % MOD;
		while (loop > 0) {
			if (loop % 2 == 1) {
				ret = ret * x % MOD;
			}
			x = x * x % MOD;
			loop /= 2;
		}

		return ret;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25424
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;
    ll n,q;
    cin>>n>>s>>q;
    s = '$' + s;
    set<ll> st[26];
    for(ll i=1;i<=n;i++)st[s[i]-'a'].insert(i);
    while(q--){
        ll type;cin>>type;
        if(type==1){
            ll i;cin>>i;
            char ch;cin>>ch;
            st[s[i]-'a'].erase(i);
            st[ch-'a'].insert(i);
            s[i]=ch;
        }
        else{
            ll ans = 0 , l , r;
            cin>>l>>r;
            for(ll i=0;i<26;i++){
                auto pos = st[i].lower_bound(l);
                if(pos==st[i].end())continue;

                if( *pos <= r)ans++;
            }

            cout<<ans<<"\n";
        }
    }
}




Measured memory_bytes: 24240
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	pair<int, int> a[m];
	REP(i, m) cin >> a[i].second >> a[i].first;

	sort(a, a+m);

	int right = a[0].first - 1;
	int ans = 1;
	for (int i = 1; i < m; i++){
		if (right >= a[i].second) continue;
		ans++;
		right = a[i].first-1;
	}

	cout << ans << endl;

}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func sum(a []int64) int64 {
	ret := int64(0)
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	var n int
	fmt.Scan(&n)
	minus := 0
	min := int64(1000000000)
	a := make([]int64, n)
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] <= 0 {
			minus++
			a[i] *= -1
		}
		if min > a[i] {
			min = a[i]
		}
	}

	ans := sum(a)
	if minus%2 == 1 {
		ans -= min * 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
N = int(input())

A = [0] * (N + 1)
B = [0] * (N + 1)
C = [0] * (N + 1)

for i in range(1, N + 1):
    A[i], B[i], C[i] = map(int, input().split())

dp = [[0] * 3 for _ in range(N + 1)]
for i in range(1, N + 1):
    dp[i][0] = A[i] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = B[i] + max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = C[i] + max(dp[i-1][0], dp[i-1][1])

print(max(dp[N]))

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

long long cnt;
int l, A[1000000], n;
vector<int> G;

//間隔gを指定した挿入ソート
void insertionSort(int A[], int n, int g){//gは間隔
    for(int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j -=g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n){
    //間隔を決める
    //数列G={1, 4, 13, 40, 121, ...}を生成
    for(int h = 1; ; ){//永遠ループ
        if(h > n) break;
        G.push_back(h); //配列Gの末尾に新たな要素hを追加する
        h = 3 * h + 1; //こうすることで、それなりに良い結果が得られることが知られている
    }
    //逆順にg＝G[i]を指定(Gの要素は大きい値から縮めていく必要があるから（...121, 40, 13, 4, 1の順）)
    for(int i = G.size() - 1; i >= 0; i--){
        insertionSort(A, n, G[i]);
    }
}

int main(){
    cin >> n;
    //より早い入力scanf関数を使用
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for(int i = G.size() - 1; i >= 0; i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%lld\n", cnt);
    for(int i = 0; i < n; i++) printf("%d\n", A[i]);

    return 0;
}



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

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    sort(p.rbegin(), p.rend());
    vector<int> a;
    int flag = 0;
    rep(i, -1, 102){
        flag = 0;
        rep(j, 0, n){
            if(i == p[j]) flag = 1;
        }
        if(flag == 0){
            a.push_back(i);
        }
    }
    int mn = 1001001001;
    int ans = 0;
    rep(i, 0, a.size()){
        if(abs(a[i] - x) < mn){
            mn = abs(a[i] - x);
            ans = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	string s[3];
	cin >> s[0];
	cin >> s[1];
	cin >> s[2];

	char result[3] = { 'A', 'B', 'C' };

	reverse(s[0].begin(), s[0].end());
	reverse(s[1].begin(), s[1].end());
	reverse(s[2].begin(), s[2].end());

	int turn_id = 0;
	int max_turn = s[0].size() + s[1].size() + s[2].size();
	for (int i = 0; i < max_turn; i++)
	{
		if (s[turn_id].empty())
		{
			cout << result[turn_id];
			break;
		}

		char curr = s[turn_id].back();
		s[turn_id].pop_back();

		turn_id = curr - 'a';
	}

	return 0;
}


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

int gdb(int a, int b);

int main() {
  int x, y;
  cin >> x >> y;
  cout << 1 + x + y - gdb(x, y) << endl;
  return 0;
}

int gdb(int a, int b) {
  if (a < b) {
      swap(a, b);
  }
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 2e4+100;
const ll mod = 1e9+7;
ll qpow(ll a,ll b,ll mod) {
    ll ans = 1;
    while(b) {
        if(b&1)
            ans = ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=1;
    ll p=1,q = 1;
    for(ll i=1,j=(n-a)+1; i<=a; i++,j++)
        p=p*i%mod,q=q*j%mod;
    ans= (ans+q*qpow(p,mod-2,mod))%mod;
    p=1,q = 1;
    for(ll i=1,j=(n-b)+1; i<=b; i++,j++)
        p=p*i%mod,q=q*j%mod;
    ans=(ans+q*qpow(p,mod-2,mod))%mod;
    cout<<(qpow(2,n,mod)-ans+mod)%mod<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
using namespace std;
 
struct Point{ double x,y; };
 
void koch(int n, Point a, Point b){
  if(n==0) return;
 
  Point s,t,u;
  double th = M_PI * 60.0/180.0;
 
  s.x = (2.0*a.x + 1.0*b.x)/3.0;
  s.y = (2.0*a.y + 1.0*b.y)/3.0;
  t.x = (1.0*a.x + 2.0*b.x)/3.0;
  t.y = (1.0*a.y + 2.0*b.y)/3.0;
  u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
  u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;
 
  koch(n-1,a,s);
  printf("%.8f %.8f\n", s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n", u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n", t.x,t.y);
  koch(n-1,t,b);
}
 
int main() {
  Point a,b;
  int n;
 
  scanf("%d",&n);
 
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
 
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
   
  return 0;
}

Measured memory_bytes: 1068
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#define maxn 55
#define maxm 105
#define mod 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,K;
int head[maxn],nxt[maxm*2],to[maxm*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int dfn[maxn],low[maxn],cnt;
int cnt_bcc,bcc[maxn];
int size_e[maxn],size_p[maxn];
stack<pii>s;
void tarjan(int u,int las)
{
    dfn[u]=low[u]=++cnt;
    for(int i=head[u];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        int v=to[i];
        if(!dfn[v])
        {
            s.push(mp(u,v));
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if(dfn[u]<=low[v])
            {
                ++cnt_bcc;
                while(true)
                {
                    int x=s.top().fi,y=s.top().se;
                    s.pop();
                    size_e[cnt_bcc]++;
                    if(bcc[x]!=cnt_bcc)  size_p[cnt_bcc]++,bcc[x]=cnt_bcc;
                    if(bcc[y]!=cnt_bcc)  size_p[cnt_bcc]++,bcc[y]=cnt_bcc;
                    if(x==u&&y==v)  break;
                }
            }
        }
        else if(dfn[v]<dfn[u])
        {
            s.push(mp(u,v));
            low[u]=min(low[u],dfn[v]);
        }
    }
}
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int fac[maxm*2],inv[maxm*2];
int C(int x,int y)
{
    return 1ll*fac[x]%mod*inv[y]%mod*inv[x-y]%mod;
}
int gcd(int x,int y)
{
    if(!y)  return x;
    return gcd(y,x%y);
}
int main()
{
    n=read();m=read();K=read();
    fac[0]=1;
    for(int i=1;i<=m+K;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[m+K]=quick_pow(fac[m+K],mod-2);
    for(int i=m+K-1;i>=0;i--)  inv[i]=1ll*inv[i+1]*(i+1)%mod;
    for(int i=1;i<=m;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
    }
    for(int i=1;i<=n;i++)
      if(!dfn[i])  tarjan(i,0);
    int ans=1;
    for(int i=1;i<=cnt_bcc;i++)
    {
        if(size_e[i]==1)  ans=1ll*ans*K%mod;
        else if(size_e[i]==size_p[i])
        {
            int res=0;
            for(int j=1;j<=size_p[i];j++)
            {
                res=(res+quick_pow(K,gcd(j,size_p[i])))%mod;
            }
            res=1ll*res*quick_pow(size_e[i],mod-2)%mod;
            ans=1ll*ans*res%mod;
        }
        else{
            ans=1ll*ans*C(size_e[i]+K-1,K-1)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
MOD = 10**9 + 7
tree = [[] for i in range(N+1)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b)
  tree[b].append(a)

# 頂点1をルートにして各頂点より下にある部分木の頂点数を求めていく
root, par = 1, 0
sizes = [0] * (N+1)
order = [[root, par]]
def calc_nums(node, par):
  global sizes
  global order
  if sizes[node] > 0:
    return sizes[node]
  children = tree[node]
  res = 1
  for child in children:
    if child == par:
      continue
    order.append([child, node])
    res += calc_nums(child, node)
  sizes[node] = res
  return res

_ = calc_nums(root, par)

# 2の累乗を事前に計算しておく
prod2 = [1]
for i in range(N):
  prod2.append(prod2[-1] * 2 % MOD)

# 各頂点について、その頂点が穴あき度としてカウントされる状況を独立に計算する
demo = 0 # 分子
div = prod2[N] # 分母
base = prod2[N-1] - 1
for node, par in order:
  children = tree[node]
  num = base
  num_par = N - 1
  for child in children:
    if child == par:
      continue
    s = sizes[child]
    num_par -= s
    num -= prod2[s] - 1 
  num -= prod2[num_par] - 1
  demo += num
    
ans = demo * pow(div, MOD-2, MOD) % MOD
print(ans)

Measured memory_bytes: 187880
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 7; i++){
        if(S.substr(0, i) + S.substr(S.size() - (7 - i)) == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int r,c,n;
set<pair<int,int> > st;
int dis(int x,int y){
	if(x==0) return y;
	if(y==c) return c+x;
	if(x==r) return r+c+c-y;
	if(y==0) return c+c+r+r-x;
	return -1;
}
int main(){
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;i++){
		int x1,y1,x2,y2,d1,d2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		d1=dis(x1,y1);
		d2=dis(x2,y2);
		if(d1!=-1&&d2!=-1) st.insert(make_pair(min(d1,d2),max(d1,d2)));
	}
	stack<int> sta;
	for(auto x=st.begin();x!=st.end();x++){
		while(!sta.empty() && x->first > sta.top()) sta.pop();
		if(!sta.empty() && x->second > sta.top()) return puts("NO"),0;
		sta.push(x->second);
	}
	return puts("YES"),0;
} 

Measured memory_bytes: 5120
package main

import (
	"fmt"
	"sort"
)

func abs(i int) int {
	if i >= 0 {
		return i
	} else {
		return -i
	}
}
func g(a, b, c int) int {
	x := []int{a, b, c}
	sort.Ints(x)
	return x[2] - x[0]
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func div2(a, h, w int) int {
	if h%2 == 0 || w%2 == 0 {
		return abs(a - h*w/2)
	} else {
		x := h / 2
		b := x * w
		c := (h - x) * w
		d := g(a, b, c)
		x = w / 2
		b, c = x*h, (w-x)*h
		return min(d, g(a, b, c))
	}
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	if h%3 == 0 || w%3 == 0 {
		fmt.Println(0)
		return
	}

	ans := 1 << 30
	for a := 1; a < h; a++ {
		b := div2(w*a, h-a, w)
		ans = min(ans, b)
	}
	for a := 1; a < w; a++ {
		b := div2(h*a, h, w-a)
		ans = min(ans, b)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
S=int(input())
X1=0
Y1=0
if S==10**18:
  print(' '.join(['0', '0', '0', '1000000000', '1000000000', '0']))
else:
  X2=10**9
  Y2=1
  Y3=S//(10**9)+1
  X3=Y3*(10**9)-S
  print(' '.join(map(str, [X1, Y1, X2, Y2, X3, Y3])))

Measured memory_bytes: 3064
#include <stdio.h>
int change;

int main(){
    int N;
		scanf("%d",&N);
		change = calculate(N);
		printf("%d\n",change);
}

int calculate(int total){
	  int payment;
		int i;
	  for(i=1; total>payment; i++){
	      payment = 1000*i;
	  }
		return payment - total;
}


Measured memory_bytes: 1708
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N; cin >> N;
    vector<string>S(N);
    map<string, int>c;
    rep(i, N) {
        cin >> S[i];
        c[S[i]] = 1;
    }
    int ans = 0;
    for (auto itr = c.begin(); itr != c.end(); itr++) {
        ans++;
    }
    cout << ans << endl;


}

   

    
    



    
                

 













































































































































Measured memory_bytes: 25120
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    while(true){
        int N;
        cin >> N;
        if(N == 0) break;
        vector<point> P(N);
        for(int i=0;i<N;i++){
            cin >> P[i].real() >> P[i].imag();
        }

        int ret = 1;

        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i == j) continue;
                point p1 = P[i];
                point p2 = P[j];

                if(abs(p1-p2) <= 2.0+EPS){
                    point d = p1 - p2;
                    point m = (p1+p2)/(point(2,0));

                    point nor = d * point(0,1);
                    nor /= abs(nor);
                    nor *= point(sqrt(1-(abs(d)/2)*(abs(d)/2)),0);

                    point p = m + nor;
                    int cnt = 0;
                    for(int k=0;k<N;k++){
                        if(abs(P[k]-p) <= 1+EPS) cnt++;
                    }
                    ret = max(ret,cnt);
                }
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1264
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(10);
  std::cerr << std::fixed << std::setprecision(10);

  long double T, X;

  std::cin >> T >> X;

  std::cout << T / X << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int main(){
  ll x,y,a,b,c,sum=0;
  cin>>x>>y>>a>>b>>c;
  vll red(a),green(b),no(c),all(x+y+c);
  REP(i,a){
    cin>>red[i];
  }
  sort(red.begin(),red.end());reverse(red.begin(),red.end());
  REP(i,x){
    all[i]=red[i];
  }
  REP(i,b){
    cin>>green[i];
  }
  sort(green.begin(),green.end());reverse(green.begin(),green.end());
  REP(i,y){
    all[i+x]=green[i];
  }
  REP(i,c){
    cin>>no[i];
    all[x+y+i]=no[i];
  }
  sort(all.begin(),all.end());reverse(all.begin(),all.end());
  REP(i,x+y){
    sum+=all[i];
  }
  cout<<sum<<endl;
}

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


void display(int A[], int n)
{
	for(int i = 1; i <= n; i++)
	{
		cout << A[i];
		if(i < n)
		{
			cout << " ";
		}
	}
	cout << endl;
}



int main(void)
{
	int N = 100;
	int n;
	int count = 0;
	int A[N];

	cin >> n;
	if(n < 1)
	{
		cout << "input Error!!" << endl;
		return 0;
	}

	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}

	int flag = 1;       	//BubbleSort
	while(flag)
	{
		flag = 0;
		int i = 0;
		for(int i = 1; i <= n; i++)
		{
			for(int j = n; j >= (i+1); j--)
			{
				if(A[j] < A[j-1])
				{
					int k = A[j-1];
					A[j-1] = A[j];
					A[j] = k;
					count++;
					flag = 1;
				}
			}
		}
	}
	display(A, n);
	cout << count << endl;
	return 0;

}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll c[4][4];
	FOR(i,1,4){
		FOR(j,1,4){
			cin >> c[i][j];
		}
	}
	bool ok = true;
	ll a[4];
	FOR(i,0,101){
		FOR(j,0,101){
			FOR(k,0,101){
				a[1]=i;
				a[2]=j;
				a[3]=k;
				set<ll> b[4];
				FOR(i,1,4)FOR(j,1,4){
					b[i].insert(c[j][i]-a[j]);
				}
				if(b[1].size()==1&&b[2].size()==1&&b[3].size()==1){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define INF 1<<30
#define LINF 1LL<<60
const ll Mod = 1e9 + 7;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, m; cin >> n >> m;
	if (n == 1) {
		cout << ((m + 1)%Mod) << endl;
		return 0;
	}
	ll d = m / (n - 1);
	ll a, b;
	a = ((m + 1)%Mod)*(d%Mod); a %= Mod;
	if (d % 2 == 0) {
		b = ((d / 2)%Mod)*((d + 1)%Mod); b %= Mod;
		b *= (n - 1)%Mod; b %= Mod;
	}
	else {
		b = (((d + 1) / 2)%Mod)*(d%Mod); b %= Mod;
		b *= (n - 1)%Mod; b %= Mod;
	}
	ll ans = (a - b + Mod)%Mod;
	ans = (ans * 2) % Mod;
	ans = (ans + (m + 1)%Mod) % Mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

     
int main(void){
	ios::sync_with_stdio(false);
	int a = 0;
	int b = 0;
	float tmpAnswer = 0;
	float answer = 0;
	
	cin >> a >> b;

	tmpAnswer = a + b;
	answer = round(tmpAnswer/2);
  
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 512
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, K, *H = map(int, read().split())
print(sum(x >= K for x in H))


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    int ans;
    ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if (i % 2 == 0)
        {
            if (a[i] % 2 == 1)
            {
                ans++;
            }
            
        }
        
    }
    
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a;
  
  return 0;
}


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

int main(){
	int s; cin>>s;
	int a=s/100,b=s%100;
	string ans;
	if((a==0&&b==0)||(a==0&&b>12)||(b==0&&a>12)||(a>12&&b>12))ans="NA"s;
	else if(a!=0&&b!=0&&a<=12&&b<=12)ans="AMBIGUOUS"s;
	else if(a!=0&&a<=12)ans="MMYY"s;
	else if(b!=0&&b<=12)ans="YYMM"s;
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 256