akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static int hills[] = new int[10];
	
	public static void main(String[] args){
		for(int i=0;i<10;i++){
			hills[i] = scan.nextInt();
		}
		Arrays.sort(hills);
		
		System.out.println(hills[9]);
		System.out.println(hills[8]);
		System.out.println(hills[7]);
	}
}

Measured memory_bytes: 26376
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int m,di;
vector<int> sx,sy;
bool can(vector<int> x,vector<int> y){
	int md=0;
	if(x[0]==x[1]&&y[0]<y[1]) md=0;
	if(x[0]==x[1]&&y[0]>y[1]) md=2;
	if(x[0]<x[1]&&y[0]==y[1]) md=1;
	if(x[0]>x[1]&&y[0]==y[1]) md=3;
	int k=(md-di+4)%4;
	if(k==1){
		rep(i,m){
			swap(x[i],y[i]);
			x[i]=-x[i];
		}
	}
	if(k==2){
		rep(i,m){
			x[i]=-x[i],y[i]=-y[i];
		}
	}
	if(k==3){
		rep(i,m){
			swap(x[i],y[i]);
			y[i]=-y[i];
		}
	}
	rep(i,m){
		if(x[0]-x[i]!=sx[0]-sx[i]) return false;
		if(y[0]-y[i]!=sy[0]-sy[i]) return false;
	}
	return true;
}
int main(){
	while(true){
		int tt;
		cin>>tt;
		if(tt==0) break;
		sx.clear();
		sy.clear();
		cin>>m;
		rep(i,m){
			int p,q;
			cin>>p>>q;
			sx.pb(p);
			sy.pb(q);
		}
		if(sx[0]==sx[1]&&sy[0]<sy[1]) di=0;
		if(sx[0]==sx[1]&&sy[0]>sy[1]) di=2;
		if(sx[0]<sx[1]&&sy[0]==sy[1]) di=1;
		if(sx[0]>sx[1]&&sy[0]==sy[1]) di=3;
		rep1(t,tt){
			int mm;
			vector<int> x,y;
			cin>>mm;
			if(mm!=m){
				int p;
				rep(i,mm) cin>>p>>p;
				continue;
			}
			rep(i,mm){
				int p,q;
				cin>>p>>q;
				x.pb(p);
				y.pb(q);
			}
			bool ok=can(x,y);
			reverse(all(x));
			reverse(all(y));
			ok|=can(x,y);
			if(ok) cout<<t<<endl;
		}
		puts("+++++");
	}
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	static char[][] f;

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			f = new char[3][3];
			for(int i=0;i<3;i++){
				char[] input = stdIn.nextLine().toCharArray();
				if(input[0]=='0') return;
				f[i] = new char[3];
				for(int j=0;j<3;j++){
					f[i][j] = input[j];
				}
			}
			if(judge()=='b') System.out.println("b");
			else if(judge()=='w') System.out.println("w");
			else System.out.println("NA");
		}
	}

	private static char judge() {
		if(f[0][0]!='+'&&f[0][0]==f[0][1]&&f[0][0]==f[0][2]) return f[0][0];
		if(f[1][0]!='+'&&f[1][0]==f[1][1]&&f[1][0]==f[1][2]) return f[1][0];
		if(f[2][0]!='+'&&f[2][0]==f[2][1]&&f[2][0]==f[2][2]) return f[2][0];
		if(f[0][0]!='+'&&f[0][0]==f[1][0]&&f[0][0]==f[2][0]) return f[0][0];
		if(f[0][1]!='+'&&f[0][1]==f[1][1]&&f[0][1]==f[2][1]) return f[0][1];
		if(f[0][2]!='+'&&f[0][2]==f[1][2]&&f[0][2]==f[2][2]) return f[0][2];
		if(f[0][0]!='+'&&f[0][0]==f[1][1]&&f[0][0]==f[2][2]) return f[0][0];
		if(f[0][2]!='+'&&f[0][2]==f[1][1]&&f[0][2]==f[2][0]) return f[0][2];
		return 'e';
	}
}

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

using namespace std;

vector<vector<int> > graph;
vector<bool> visited;
vector<int> L;

void visit(int n) {
	if(!visited[n]) {
		visited[n] = true;
		for(int i = 0; i < graph[n].size(); ++i) {
			int m = graph[n][i];
			visit(m);
		}
		L.push_back(n);
	}
}

int main(void) {
	long long N, M;
	cin >> N >> M;
	graph = vector<vector<int> >(N);
	visited = vector<bool>(N, false);
	for(int i = 0; i < N - 1 + M; ++i) {
		int a, b;
		cin >> a >> b;
		graph[a - 1].push_back(b - 1);
	}
	for(int n = 0; n < N; ++n) {
		visit(n);
	}
	reverse(L.begin(), L.end());
	vector<int> I(N);
	for(int i = 0; i < N; ++i) {
		I[L[i]] = i;
	}
	vector<int> parent(N, -1);
	for(int k = 0; k < N; ++k) {
		for(int i = 0; i < graph[L[k]].size(); ++i) {
			int b = graph[L[k]][i];
			if(parent[b] == -1) {
				parent[b] = L[k];
			} else if(I[parent[b]] < k) {
				parent[b] = L[k];
			}
		}
	}
	for(int n = 0; n < N; ++n) {
		cout << parent[n] + 1 << '\n';
	}
	return 0;
}



Measured memory_bytes: 9720
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  char a, b;
  cin >> a >> b;
  if(a == b) cout << "H" << endl;
  else cout << "D" << endl;
  return 0;
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 3e3 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900;


int Dp[N][N], B[N], Ps[N][N];
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n; cin >> n;
      string s; cin >> s;
      for(int i = 2; i <= n; i++)
            if(s[i - 2] == '<')
                  B[i] = 1;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= i; j++){
                  if(i == 1){
                        Dp[i][j] = Ps[i][j] = 1;
                        continue;
                  }
                  if(B[i])
                        Dp[i][j] = Ps[i - 1][j - 1];
                  else
                        Dp[i][j] = (Ps[i - 1][i - 1] - Ps[i - 1][j - 1] + Mod) % Mod;
                  Ps[i][j] = (Ps[i][j - 1] + Dp[i][j]) % Mod;
            }
      }
      cout << Ps[n][n];
      return 0;
}



Measured memory_bytes: 69504
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main()
{
  long  n;
  long k;
  cin>>n;
  cin>>k;
  vector<long> nums(n);
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    nums[i]=x;
  }
    vector<long> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(nums[0]-nums[1]);
    for(long i=2;i<n;i++)
    {  
  		for(long j=i-1;j>=0&&j>=i-k;j--)
          dp[i]=min(dp[i],dp[j]+abs(nums[i]-nums[j]));
    }
    cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << ( a + b >= 10 ? "error" : to_string( a + b ) ) << endl;
    return 0;
}

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

using namespace std;

int k;
long long sum=0;

inline int gcd(int a,int b) {
	int r=a%b;
	while(r) {
		a=b,b=r,r=a%b;
	}
	return b;
}

int main() {
	cin>>k;
	for(int i=1,j,l,tmp; i<=k; ++i)
		for(j=1; j<=k; ++j) {
			tmp=gcd(i,j);
			for(l=1; l<=k; ++l)
				sum+=gcd(tmp,l);
		}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  int x;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
  	cin >> x;
    if (x <= K - x)
      sum += 2 * x;
    else
      sum += 2 * (K - x);
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
const int N = 5005;

int main()
{
     string s,t;
     cin >> s >> t;
     ll s1,t1;
     cin >> s1 >> t1;
     string temp;
     cin >> temp;
     if(s==temp)  s1--;
     else         t1--;
     cout<<s1<<" "<<t1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = (int)s.size();
    set<string> st;
    for (int i = 0; i<n; i++) {
        string x = "";
        x += s[i];
        st.insert(x);
        for (int j = i+1; j<n; j++) {
            x += s[j];
            st.insert(x);
            if(j>i+5)break;
        }
    }
    auto it = st.begin();
    it = next(it,k-1);
    cout << *it << endl;
    return 0;
}


Measured memory_bytes: 5564
n = int(input())
s = [str(input()) for _ in range(n)]
ans = [0]*4
for i in range(len(s)):
    if s[i] == "AC":
        ans[0] += 1
    elif s[i] == "WA":
        ans[1] += 1
    elif s[i] == "TLE":
        ans[2] += 1
    else:
        ans[3] += 1

print("AC x ",ans[0])
print("WA x ",ans[1])
print("TLE x ",ans[2])
print("RE x ",ans[3])

Measured memory_bytes: 16320
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

int main() {
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    ll L = N * M / gcd(N, M);

    map<ll, pair<bool, char>> mp;
    for (ll i = 0; i < N; i++) {
        mp[i * L / N].first = true;
        mp[i * L / N].second = S[i];
    }
    for (ll i = 0; i < M; i++) {
        if (mp[i * L / M].first) {
            if (mp[i * L / M].second != T[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << L << endl;
}

Measured memory_bytes: 10880
#include<iostream>
using namespace std;
typedef long long int ll;

ll lucas(int n)
{
/*  if(n==1)return 1;
  else if(n==0)return 2;
  else return lucas(n-1)+lucas(n-2);*/
  ll ans[n+1];
  ans[0]=2;ans[1]=1;
  for(int i=2;i<=n;i++)
  {
    ans[i]=ans[i-1]+ans[i-2];
  }
  return ans[n];
}

main()
{
  int n;cin>>n;
  cout<<lucas(n);
}

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

constexpr int64_t mod{1'000'000'007};

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	using vi = std::vector<int>;
	vi S(N), T(M);
	for (auto& e: S) scanf("%d", &e);
	for (auto& e: T) scanf("%d", &e);

	using vi64 = std::vector<int64_t>;
	std::vector<vi64> dp(N + 1, vi64(M + 1));
	for (int i{}; i < N; i++)
		dp[i][M] = 1;
	for (int i{}; i <= M; i++)
		dp[N][i] = 1;
	for (int i{N - 1}; i >= 0; i--)
	{
		for (int j{M - 1}; j >= 0; j--)
		{
			dp[i][j] = (dp[i + 1][j] + dp[i][j + 1] + mod - dp[i + 1][j + 1]) % mod;
			if (S[i] != T[j]) continue;
			dp[i][j] = (dp[i][j] + dp[i + 1][j + 1]) % mod;
		}
	}
	printf("%lld\n", dp[0][0]);

	return 0;
}

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

using namespace std;

int32_t main() {
 //freopen("input.txt", "r", stdin);
 long long a, b, c, d;
 cin >> a >> b >> c >> d;
 cout << max({a * c, a * d, b * c, b * d});
 return 0;
}



Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char in[110];
int ans[6];
int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);printf("%d\n",min(a,b)+min(c,d));
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> gmos(n), rmos(n);
    gmos[0] = a[0];
    rmos[n-1] = a[n-1];
    REP(i, n-1) {
        gmos[i+1] = gcd(gmos[i], a[i+1]);
        rmos[n-i-2] = gcd(rmos[n-i-1], a[n-i-2]);
    }
    ll cand = max(gmos[n-2], rmos[1]);
    RANGE(i, 1, n-2) {
        chmax(cand, gcd(gmos[i-1], rmos[i+1]));
    }
    cout << cand << endl;
    
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int i, k;
		int n = sc.nextInt();
		int[][] score = new int [n][3];
		int[][] score1 = new int [n][3];
		int[] sum = new int [n];
		for(i = 0; i < n; i++){
			for(k = 0; k < 3; k++){
				score[i][k] = sc.nextInt();
				score1[i][k] = score[i][k];
			}
		}
		for(k = 0; k < 3; k++){
			for(i = 0; i < n; i++){
				for(int m = 0; m < n; m++){
					if(score[i][k] == score[m][k] && i != m){
						score1[i][k] = 0;
					}else{
					}
				}
			}
		}
		for(i = 0; i < n; i++){
			for(k = 0; k < 3; k++){
				sum[i] += score1[i][k];
			}
		}
		for(i = 0; i < n; i++){
			System.out.printf("%d\n", sum[i]);
		}
	
	}
 }

Measured memory_bytes: 29664
#include<bits/stdc++.h>
#define foru(a,b,c) for(int a=b;a<=c;++a)
#define int long long
using namespace std;

int l[100111],r[100111],s[100111];
int n,m;

main()
{
    cin >> n >> m;
    foru(i,1,m) cin >> l[i] >> r[i];
    foru(i,1,m)
    {
        s[l[i]]=s[l[i]]+1;
        s[r[i]+1]=s[r[i]+1]-1;
    }
    foru(i,1,1e5) s[i]=s[i-1]+s[i];
    int re=0;
    foru(i,1,n) if(s[i]==m) re++;
    cout << re;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

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

Measured memory_bytes: 256
function isPrime( x )
{
  if( 2 == x ) return true;
  if( 0 == x%2 ) return false;
  
  for( var i=3; i*i<=x; i+=2 ) {
    if( 0 == x%i ) { return false; }
  }
  return true;
}
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' ).map( Number );
  var n = data[0];
  var cnt = 0;
  for( var i=1; i<=n; i++ ) {
    if( isPrime( data[i] ) ) {
      cnt++;
    }
  }
  
  console.log( cnt );
});

Measured memory_bytes: 17260
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int M=(int)1e9+1,t=0;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
// vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
 
// void dfs(int v){
//     vis[v]=1;
//     for(int i:adj[v]){
//         if(vis[i]){
//             t=1;
//             return ;
//         }
//             //dis[i]=1+dis[v];
//             //parent[i]=v;
//             vis[i]=1;
//             dfs(i);

//     }
//     return ;
    
// }




signed main(){
    fio;
    int n;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    int dp[n+1];
    dp[0]=dp[1]=0;
    dp[2]=abs(v[1]-v[2]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n]<<endl;
    


    

    
    
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().rstrip().split())
    ans = 0
    for k in range(K, N+2):
        mi = ((k-1) * k) // 2
        ma = (N * (N + 1)) // 2 - ((N-k) * (N-k+1)) // 2
        ans += (ma - mi + 1) % MOD

    print(ans % MOD)


if __name__ == '__main__':
    main()

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

#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;

const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


int main(){
	int n;
	cin>>n;
	ll ans=0;
	FOR(i,1,n+1){
		ll left=i;
		ll right=n/i*i;
		int cnt=right/i-left/i+1;
		ans+=cnt*(left+right)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<ll> Ls(N+1);
  for (int i = 0; i < N; i++) {
    cin >> Ls[i];
  }
  int ans = 0;
  ll L1, L2, L3, Lmax;
  for (int i = 0; i < N-2; i++) {
    L1 = Ls[i];
    for (int j = i+1; j < N-1; j++) {
      L2 = Ls[j];
      for (int k = j+1; k < N; k++) {
        L3 = Ls[k];
        if (L1 != L2 and L2 != L3 and L1 != L3) {
          Lmax = max({L1, L2, L3});
          if ((2*Lmax - (L1 + L2 + L3)) < 0) ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
vector<int> book[20];
int dp[16][2005],n,k;
int solve(int ct,int ja){
  if(ct == k || ja > 9) return 0;
  if(dp[ja][ct]) return dp[ja][ct];
  int res = solve(ct,ja+1),sum = 0;
  rep(i,min(k-ct,(int)book[ja].size())){
    sum += book[ja][i];
    res = max(res,solve(ct+i+1,ja+1) + sum + i*(i+1));
  }
  return dp[ja][ct] = res;
}
 
int main(){
  cin >> n >> k;
  rep(i,n){
    int c,g;
    cin >> c >> g;
    book[g-1].push_back(c);
  }
  rep(i,10) sort(book[i].rbegin(),book[i].rend());
  cout << solve(0,0) << endl;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main(){
    int n,k,p;
    cin>>n>>k;
    pair<int,int> sum[n+1];
    sum[0]=make_pair(0,0);
    for(int i=0;i<n;i++){
        cin>>p;
        sum[i+1]=make_pair(sum[i].first+p-k,i+1);
    }
    sort(sum,sum+n+1);
    int a[n+1],t=0;
    a[sum[0].second]=t;
    for(int i=1;i<=n;i++){
        if(sum[i].first!=sum[i-1].first)t=i;
        a[sum[i].second]=t;
    }
    int u=0;
    while(n+1>(1<<u)){
        u++;
    }
    //for(int i=0;i<n+1;i++)cerr<<a[i]<<' ';
    int x[1<<(u+1)]={},ans=0,i0,q;
    for(int i=0;i<=n;i++){
        i0=a[i];q=0;
        for(int j=0;j<=u;j++){
            if(i0>=(1<<(u-j))){
                ans+=x[q];
                q++;
                i0-=(1<<(u-j));
            }
            x[q]++;
            q=2*q+1;

        }
        q=q/2;
        //cerr <<q<<' '<<x[q];
        ans+=x[q]-1;
        //cerr<<ans<<' ';
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

int main (){
  char corBola1[11], corBola2[11], bolaEscolhida[11];
  int qtdBola1, qtdBola2;
  scanf("%s%s", corBola1, corBola2);
  scanf("%d%d", &qtdBola1, &qtdBola2);
  scanf("%s", bolaEscolhida);

  if(strcmp(bolaEscolhida, corBola1) == 0){
    qtdBola1--;
    printf("%d %d\n", qtdBola1, qtdBola2);
  }
  else if(strcmp(bolaEscolhida, corBola2) == 0){
    qtdBola2--;
    printf("%d %d\n", qtdBola1, qtdBola2);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int n, k;
  vector<int> d;
  vector<vector<int>> a;
  bool flag[101];
  cin >> n >> k;
  rep(i, n) flag[i] = false;
  d.resize(k);
  a.resize(k, vector<int>());
  rep(i, k){
    cin >> d[i];
    a[i].resize(d[i]);
    rep(j, d[i]){
      cin >> a[i][j];
      flag[a[i][j] - 1] = true;
    }
  }
  int ans = 0;
  rep(i, n) if(!flag[i]) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val list = List.fill(3)(sc.nextInt)
//  val a, b, c = sc.nextInt

  val ans = list.combinations(2).map(_.sum).min

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int i, n;
    i = 1;
    cin>>n;

    while (i <= n) {
        int x = i;
        if (x % 3 == 0) cout<<" "<<i;
        else {
            while (x) {
                if (x % 10 == 3) {
                    cout<<" "<<i;
                    break;
                }
                x /= 10;
            }
        }
        i++;
    }
    cout<<endl;
}


Measured memory_bytes: 3144
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int h1,h2,k1,k2,a,b,c,d;
        int hcnt=0;
        int kcnt=0;
        h1=sc.nextInt();
        h2=sc.nextInt();
        k1=sc.nextInt();
        k2=sc.nextInt();
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        d=sc.nextInt();
        hcnt=h1*a+c*(h1/10)+h2*b+d*(h2/20);
        kcnt=k1*a+c*(k1/10)+k2*b+d*(k2/20);
        if(hcnt>kcnt){
            System.out.println("hiroshi");
        }else if(kcnt>hcnt){
            System.out.println("kenjiro");
        }else{
            System.out.println("even");
        }
        
    }
}


Measured memory_bytes: 26228
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;




int main()
{
	int X, t;

	cin >> X >> t;

	int ans = X - t;

	if (ans > 0)
	{
		cout << ans << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int m=1;
	while (m<n)
	{
		m*=2;
	}
	if (m==n)
	{
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n1 2\n2 3\n3 "<<1+n<<endl<<1+n<<" "<<2+n<<endl<<2+n<<" "<<3+n<<endl;
	int now=4;
	while (now<n)
	{
		cout<<now<<" "<<now+1<<endl<<now+1<<" "<<1+n<<endl<<1+n<<" "<<now+n<<endl<<now+n<<" "<<now+n+1<<endl;
		now+=2;
	}
	if (n%2==0)
	{
		cout<<n<<" "<<m/2+n<<endl<<n-m/2+1<<" "<<n+n<<endl;
	}
	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	
	if(k % 2 == 1){
		cout << b - a << endl;
	}
	else{
		cout << a - b << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int64

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

let inline memo2 f =
  let dp = new Dictionary<_,_>()
  let rec g x y =
    match dp.TryGetValue((x,y)) with
    | true, v -> v
    | false, _ ->
      let v=f g x y
      dp.Add((x,y), v)
      v
  g


// start
let N=readInt()
let A=readInts()

let count = memo2 <| fun count c i ->
  if c=0 then 0L
  elif i<0||(2*c-i)>2 then int64 -1e15
  else
    max (count c (i-1)) (A.[i]+(count (c-1) (i-2)))

count (N/2) (N-1)
|> printfn "%d"

Measured memory_bytes: 94760
import numpy as np
import itertools
H, W, K = map(int, input().split())
ans = 0
c = []
for _ in range(H):
  c.append(list(input()))
c = np.array(c)

for l in list(itertools.product([True,False], repeat=H)):
  for l2 in list(itertools.product([True,False], repeat=W)):
    c2 = c.copy()
    c2[l, :] = 'R'
    c2[:, l2] = 'R'
    if (c2== '#').sum() == K:
      ans += 1

print(ans)

Measured memory_bytes: 27240
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<ll> A(N), B(N);
    priority_queue<ll> pq;
    int ans = 0;
    REP(i,N) cin >> A[i];
    REP(i,N) {
        cin >> B[i];
        if (A[i] < B[i]) ans++;
        else pq.push(A[i]-B[i]);
    }

    ll a = 0;
    REP(i,N) {
        if (A[i] >= B[i]) continue;
        while(A[i] + a < B[i]) {
            if (pq.empty()) {
                OUT(-1)
                return 0;
            }
            a += pq.top(); pq.pop();
            ans++;
        }
        a = A[i] + a - B[i];
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll unsigned long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define mod (ll)1e9+7
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
#define X first
#define Y second
#define up upper_bound
#define lo lower_bound
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b) 
{
    if(a>b)
        return b;
    return a;
}
ll maxx2( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll maxx(ll a,ll b,ll c)
{
  return maxx2(a,maxx2(b,c));
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
ll dsum(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
ll poww(ll a,ll b)
{
    if(b<=0)
        return 1;
    if(b==1)
        return a;
    if(b==2)
        return (a*a);
    else
        return poww(poww(a,b/2),2)*(poww(a,b%2));
}
ll sumsq(ll x,ll y,ll z)
{
    return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);
} 
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    IOS;
    ll n;
    cin>>n;
    ll a[n],ans=1,f=0;
    f(i,0,n)
    {
        cin>>a[i];
        if(a[i]==0)
            f=1;
    }
    if(f==1)
    {
        cout<<0<<endl;
        return 0;
    }
    f(i,0,n)
    {
        ll x=ans;
        ans*=a[i];
        if(x!=ans/a[i] || ans>1000000000000000000)
        {
            cout<<"-1"<<endl;
            return 0;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0045
{
    public class Program

    {
        public static void Main(string[] args)
        {

            List<Tuple<int, int>> salesInformation = new List<Tuple<int, int>>();
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;

                int[] items = Array.ConvertAll(line.Trim().Split(','), e => int.Parse(e));
                salesInformation.Add(new Tuple<int, int>(items[0], items[1]));
            }

            Console.WriteLine(salesInformation.Select(x => x.Item1 * x.Item2).Sum());
            Console.WriteLine(Math.Round(salesInformation.Select(x => x.Item2).Average(),0,MidpointRounding.AwayFromZero));
        }

    }

}



Measured memory_bytes: 16384
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
using namespace std;
 
typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;
 
const int MOD = 10007;
const int J = 4, O = 2, I = 1;
string str;
int n, attendA[8], attendB[8];
 
int changeNumber(char s) {
    if (s == 'J') return J;
    else if (s == 'O') return O;
    else return I;
}
 
int bfs() {
    Q q;
    q.push(J);
    int res = 0;
    int day = 0;
    attendB[J] = 1;
    while (day < n) {
        while (q.size()) {
            int befor = q.front(); q.pop();
            for (int i = 1; i < 8; i++) {
                if ((befor & i) && (changeNumber(str[day]) & i))
                    attendA[i] += attendB[befor];
            }
        }
        for (int i = 1; i < 8; i++) {
            attendB[i] = attendA[i];
            if (attendB[i] > 0) q.push(i);
            attendA[i] = 0;
            attendB[i] %= MOD;
        }
        day++;
    }
    for (int i = 1; i < 8; i++)
        res += (attendB[i] % MOD);
    res %= MOD;
 
    return res;
}
 
int main()
{
    cin >> n >> str;
    cout << bfs() << endl;
    return 0;
}

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

using namespace std;

int n,cnt[2];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x); ++cnt[x%2];
	}
	if (cnt[0]){
		puts(cnt[1]%2==0?"YES":"NO");
	}
	else{
		if (cnt[1]==1) puts("YES");
		else puts(cnt[1]%2==0?"YES":"NO");
	}
	
	return 0;
}
			


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,x,y,cou=0,v[3];
    char S[3],s[3],X,Y;
    scanf("%d %d",&A,&B);
    printf("%d",A*A-B);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> par;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));

int main() {
  cin >> n;
  vector<ll> v(n);
  REP(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  if (v[n - 1] - v[0] > 1) {
    cout << "No" << endl;
    return 0;
  }
  else if (v[n - 1] - v[0] == 1) {
    int t1 = 0, t2 = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] == v[0]) t1++;
      else t2++;
    }
    if (t1 < v[v.size() - 1] && (v[v.size() - 1] - t1) <= t2 / 2) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if (v[n - 1] - v[0] == 0) {
    if (n / v[0] >= 2 || n == v[0] + 1) {
      cout << "Yes" << endl;
      return 0;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<pii> frend(M), block(K);
    rep(i, M) { cin >> frend[i].first >> frend[i].second; }
    rep(i, K) { cin >> block[i].first >> block[i].second; }

    UnionFind uf(100010);

    rep(i, M) { uf.unite(frend[i].first, frend[i].second); }

    vector<set<int>> se(N + 1);
    vector<set<int>> frends(N + 1);

    rep(i, M) {
        frends[uf.root(frend[i].first)].insert(frend[i].first);
        frends[uf.root(frend[i].first)].insert(frend[i].second);
        se[frend[i].first].insert(frend[i].second);
        se[frend[i].second].insert(frend[i].first);
    }
    rep(i, K) {
        se[block[i].first].insert(block[i].second);
        se[block[i].second].insert(block[i].first);
    }

    for(int i = 1; i <= N; i++) {
        if(frends[uf.root(i)].size()==0){
            cout << 0 << " ";
            continue;
        }
            int c = frends[uf.root(i)].size() - 1;
        for(int s : se[i]) {
            if(frends[uf.root(i)].find(s) != frends[uf.root(i)].end())
                c--;
        }
        cout << c << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 36736
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const int maxv=99999999;
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;

int n,m,maxy,sx,sy,tx,ty,tot,c[maxn+10],pos[maxn+10],cnt;
double ans;

struct point
{
  int x,y;
  
  bool ft()
  {
    return x>=sx&&x<=tx&&y>=sy&&y<=ty;
  }
  
  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

point p[maxn+10],t[maxn+10];

int main(){
  sx=read();
  sy=read();
  tx=read();
  ty=read();
  if(sx>tx)
    {
      std::swap(sx,tx);
      std::swap(sy,ty);
    }
  n=read();
  for(int i=1;i<=n;i++)
    {
      p[i].x=read();
      p[i].y=read();
    }
  if(sy>ty)
    {
      for(int i=1;i<=n;i++)
        {
          p[i].y=maxv-p[i].y;
        }
      sy=maxv-sy,ty=maxv-ty;
    }
  std::sort(p+1,p+n+1);
  ans=(ty+tx-sy-sx)*100.0;
  for(int i=1;i<=n;i++)
    {
      if(p[i].ft())
        {
          t[++tot]=p[i];
        }
    }
  memset(c,0x3f,sizeof(c));
  c[0]=cnt=0;
  for(int i=1;i<=tot;i++)
    {
      // int l=1,r=cnt,md,res=0;
      // while(l<=r)
      //   {
      //     md=((r+l)>>1);
      //     if(c[md]<t[i].y)
      //       {
      //         res=md;
      //         l=md+1;
      //       }
      //     else
      //       {
      //         r=md-1;
      //       }
      //   }
      int res=std::lower_bound(c+1,c+cnt+1,t[i].y)-c;
      if(res>cnt)
        {
          cnt++;
        }
      c[res]=std::min(c[res],t[i].y);
    }
  if(cnt<=tx-sx&&cnt<=ty-sy)
    {
      ans+=cnt*K;
    }
  else
    {
      ans+=(cnt-1)*K+D;
    }
  printf("%.13lf\n",ans);
  return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  double maxv = 0, e=0, next;
  ll k, n, t;
  cin >> n >> k;
  queue<double> q;
  forll(i, 0, n){
	cin >> t;
	next = (1 + t) / 2.0;
	q.push(next);
	e += next;
	if (i >= k){
	  e -= q.front();
	  q.pop();
	}
	maxv = max(e, maxv);
  }
  cout << setprecision(10) << maxv << endl;
}


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

int main(){
    int N,tmp;
    cin >> N;
    int p[N]; 
    for (int i=0;i<N;++i) cin >> p[i];
    
    for (int i=0;i<N;i++){
        if(p[i] != i+1){
            tmp = p[p[i]-1];
            p[p[i]-1] = p[i];
            p[i] = tmp;
            break;
        }
    }

    bool flag=true;

    for (int i=0;i<N;i++){
        if(p[i] != i+1){
            flag = false;
            break;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,k;
int a[105];
int dp[105][100005];
int s[105][100005];

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=k;i++) s[0][i]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(j<=a[i]) dp[i][j]=s[i-1][j];
			else{
				dp[i][j]=s[i-1][j]-s[i-1][j-a[i]-1];
				if(dp[i][j]<0) dp[i][j]+=mod;
			}
		}
		s[i][0]=dp[i][0];
		for(int j=1;j<=k;j++){
			s[i][j]=s[i][j-1]+dp[i][j];
			s[i][j]%=mod;
		}
	}
	printf("%d\n",dp[n][k]);
	
	return 0;
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, k, ans = 0; cin >> a >> b >> c >> k;
	cout << min(a, k) - max(0, k - a - b);

	return 0;
}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;
   if(N<=999)cout<<"ABC";
   else cout<<"ABD";
   return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int main()
{
    IOS;
    string s;
    cin>>s;
    ll mx=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T') continue;
        int j=i;
        ll c=0;
        while(j<s.size()&&(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'))
        {
            j++;
            c++;
        }
        i=j-1;
        mx=max(mx,c);
    }
    cout<<mx<<endl;

}

Measured memory_bytes: 256
class ModInt(x: Long) {

    companion object {
        const val MOD = 1e9.toLong() + 7
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun plus(other: Long): ModInt {
        return this + ModInt(other)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun minus(other: Long): ModInt {
        return this - ModInt(other)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun times(other: Long): ModInt {
        return this * ModInt(other)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun pow(exp: Int): ModInt {
        return pow(exp.toLong())
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

fun main() {
    val n = readLine()!!.toInt()
    var zero = 0L
    val cnt = mutableMapOf<Pair<Long, Long>, Pair<Int, Int>>()
    for (i in 0 until n) {
        var (a, b) = readLine()!!.split(' ').map { it.toLong() }
        if (a == 0L && b == 0L) {
            zero++
            continue
        }

        val g = gcd(a, b)
        a /= g
        b /= g
        if (a < 0) {
            a = -a
            b = -b
        }
        if (b > 0) {
            cnt[a to b] = (cnt[a to b] ?: 0 to 0).let { (a, b) -> a + 1 to b }
        } else {
            cnt[-b to a] = (cnt[-b to a] ?: 0 to 0).let { (a, b) -> a to b + 1 }
        }
    }

    var ans = ModInt(1L)

    val base = ModInt(2)
    for (key in cnt.keys) {
        val (c1, c2) = cnt[key]!!
        ans *= base.pow(c1) - 1 + base.pow(c2) - 1 + 1
    }
    ans -= 1
    ans += zero

    println(ans)
}


Measured memory_bytes: 96092
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
using std::string;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    string S;
    std::cin >> S;
    
    //偶奇は保存
    //流れていって、フリップするところで偶奇が一致する方に加わる
    
    vector<int> cnt(S.length());
    
    char bef = 'R';
    int flp = 0;
    int odd = 0;
    int evn = 0;
    for (int i = 0; i < S.length(); i++) {
        if (bef == 'R' && S[i] == 'L') {
            if (i%2 == 0) {
                cnt[i-1] += odd;
                cnt[i] += evn;
                odd = evn = 0;
            } else {
                cnt[i-1] += evn;
                cnt[i] += odd;
                odd = evn = 0;
            }
            flp = i;
        }
        if (bef == 'L' && S[i] == 'R') {
            if (flp%2 == 0) {
                cnt[flp] += evn;
                cnt[flp-1] += odd;
                odd = evn = 0;
            } else {
                cnt[flp] += odd;
                cnt[flp-1] += evn;
                odd = evn = 0;
            }
        }
        if (i%2 == 0) {
            evn += 1;
        } else {
            odd += 1;
        }
        bef = S[i];
    }
    if (flp%2 == 0) {
        cnt[flp] += evn;
        cnt[flp-1] += odd;
        odd = evn = 0;
    } else {
        cnt[flp] += odd;
        cnt[flp-1] += evn;
        odd = evn = 0;
    }
    
    for (int i = 0; i < S.length(); i++) {
        std::cout << cnt[i] << " ";
    }
    std::cout << std::endl;
    
    return 0;
}



Measured memory_bytes: 1024