akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long W = sc.nextInt();
		long H = sc.nextInt();
		long x = sc.nextInt();
		long y = sc.nextInt();
		
		sc.close();

		String a = BigDecimal.valueOf(((double)W*H)/2.0).toPlainString();		
		out.print(a);
		out.print(" ");
		
		if(W == x*2 && H == y*2) {
			out.println("1");
		}else {
			out.println("0");
		}
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23124
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <string>
#include <functional>
#include <map>
#include <cstring>
using namespace std;

using ii = pair < int , int >;
using ti = tuple < int ,int ,int >;
using lint = long long;
using ll = pair < lint , lint >;
const int N = 1e2 + 4;
int a[2][N];
int d[2][N];
int main(){
	//freopen("in.txt","r",stdin);
	int n;scanf("%d",&n);
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	d[0][0] = a[0][0];
	d[1][0] = a[1][0] + a[0][0];
	for(int i=1;i<n;i++){
		d[0][i] = a[0][i] + d[0][i-1];
		d[1][i] = a[1][i] + max(d[1][i-1],d[0][i]);
	}
	printf("%d\n",d[1][n-1]);
	return 0;
}


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

string t;
int l;

bool solve (int i)
{
	bool res = false;
	if (i == l) return true;
	if (i > l) return false;

	if (i+5 <= l && t.substr (i, 5) == "dream") {
		res |= solve (i+5);
	}
	if (res) return res;

	if (i+7 <= l && t.substr (i, 7) == "dreamer") {
		res |= solve (i+7);
	}
	if (res) return res;

	if (i+5 <= l && t.substr (i, 5) == "erase") {
		res |= solve (i+5);
	}
	if (res) return res;

	if (i+6 <= l && t.substr (i, 6) == "eraser") {
		res |= solve (i+6);
	}
	return res;
}

int main ()
{
	cin >> t;
	l = t.size ();

	cout << (solve (0) ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> x(n),y(n);
	rep(i,n){
		cin>>x[i];
		y[i]=x[i];
	}
	sort(begin(y),end(y));
	int ans1=y[n/2-1],ans2=y[n/2];
	rep(i,n){
		if(ans1>=x[i]) cout<<ans2<<endl;
		else cout<<ans1<<endl;
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);

    // i日目よりもi+k日目のほうが株価が高い日があればi日目では買う

    int money = 1000;
    int stock = 0;

    for(int i=0;i<N;i++){
        if(i==N-1){
            money += stock*A.at(i);
            cout<<money<<endl;
            return 0;
        }

        if(A.at(i)<A.at(i+1)){//この時には持ち金すべてを使って株を買っておく
            int num = money / A.at(i);
            stock += num;
            money -= num*A.at(i);
        }else if(A.at(i)>A.at(i+1)){
            //この時には株を全部売っておく
            money += stock*A.at(i);
            stock = 0 ;
        }
        //価格が同じときには何もしない
    }

    return 0;
}

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

int main() {
	int a,b,c;cin >> a>>b>>c;
	if(a>b){int k=b;b=a;a=k;}
	if(b>c){int k=c;c=b;b=k;}
	if(a>b){int k=b;b=a;a=k;}
	cout << a << " " << b << " " << c << "\n";
	return 0;
}

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

int main() {
	int n,a[100];
	 
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	int nSum = 0;
	for (int i = 0;i < n;i++) {
		nSum += a[i];
	}
	if (nSum%n != 0) {
		if (nSum%n <= n / 2)
			nSum = nSum / n;
		else
			nSum = nSum / n + 1;
	}
	else {
		nSum = nSum / n;
	}
	int Sum = 0;
	for (int i = 0;i < n;i++) {
		Sum += (nSum - a[i])*(nSum - a[i]);
	}
	std::cout << Sum << std::endl;
	return 0;
}
	


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		LinkedList<Character> aCard = new LinkedList<>();
		LinkedList<Character> bCard = new LinkedList<>();
		LinkedList<Character> cCard = new LinkedList<>();

		// input
		String aString = scan.next();
		for (int i = 0; i < aString.length(); i++) {
			aCard.add(aString.charAt(i));
		}
		String bString = scan.next();
		for (int i = 0; i < bString.length(); i++) {
			bCard.add(bString.charAt(i));
		}
		String cString = scan.next();
		for (int i = 0; i < cString.length(); i++) {
			cCard.add(cString.charAt(i));
		}

		// check
		char turn = aCard.poll();
		boolean endFlag = false;
		while (true) {

			switch (turn) {
			case 'a':
				if (aCard.size() == 0) {
					System.out.println("A");
					endFlag = true;
					break;
				}
				turn = aCard.poll();
				break;
			case 'b':
				if (bCard.size() == 0) {
					System.out.println("B");
					endFlag = true;
					break;
				}
				turn = bCard.poll();
				break;
			case 'c':
				if (cCard.size() == 0) {
					System.out.println("C");
					endFlag = true;
					break;
				}
				turn = cCard.poll();
			}

			if (endFlag) {
				break;
			}
		}

	}
}


Measured memory_bytes: 22612
// https://atcoder.jp/contests/agc032/tasks/agc032_a
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        b: [usize; n]
    };
    let mut isok = true;
    let mut b = b;

    let mut ans = vec![0; n];
    while b.len() >= 1 {
        let mut n = b.len();
        let mut found = false;
        while n >= 1 {
            n -= 1;
            if b[n] == n + 1 {
                ans[b.len() - 1] = n + 1;
                let mut nb = vec![];
                for i in 0..b.len() {
                    if i != n {
                        nb.push(b[i]);
                    }
                }
                b = nb;
                found = true;
                break;
            }
        }
        if !found {
            isok = false;
            break;
        }
    }
    if isok {
        for x in ans {
            println!("{}", x);
        }
    } else {
        println!("-1")
    }
}


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

int main() {
  int N;
  cin >> N;
  double ans;
  if ( N % 2 == 0 ) {
    ans = 0.5;
  }
  else {
    ans = ((double)((N+1)/2))/((double)N);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

pair<int, int> dxdy[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

const int mod = 1000000007;

bool isWhite[55][55];
int cnt;
int h, w;

const int MAX_V = 2550;
vector<int> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+h*w, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            int e = G[v][i];
            if (d[e] > d[v] + 1) {
                d[e] = d[v] + 1;
                que.push(P(d[e], e));
            }
        }
    }
}

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

  cin >> h >> w;

  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if(s[j] == '.') {
        cnt++;
        isWhite[i][j] = true; 
      }
    }
  }

  rep(i, h) rep(j, w) {
    for(auto p : dxdy) {
      int x = i+p.first;
      int y = j+p.second;
      if(x >= 0 && x < h && y >= 0 && y < w && isWhite[i][j] && isWhite[x][y]) {
        G[i*w+j].push_back(x*w+y);
      }
    }
  }

  dijkstra(0);
  int kyori = d[h*w-1];

  if(kyori != INF) {
    cout << cnt - kyori - 1 << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void) {
  int a, i, j, x;
  char s[100000], c;
  scanf("%d", &a);
  scanf("%s", s);
  // for (i = 0; i < a; i++) {
  for (j = 0; j < a; j++) {
    //   if (s[j] == 'X')
    //     ;
    //   else
    if (s[j] == s[j - 1]) {
      c = s[j];
      s[j] = 'X';
    } else if (s[j] == c)
      s[j] = 'X';
    else {
      c = 'Y';
      x++;
    }
  }
  //}
  // j = 0;
  // for (i = 0; i < a; i++) {
  //   // printf("%c", s[i]);
  //   if (s[i] != 'X') j++;
  // }
  // printf("%d\n", j);
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 256
from itertools import product
flag = True
c_list = []
for _ in range(3):
    c_list.append(list(map(int, input().split())))
min_n = min(sum(c_list, []))
new_list = []
for i in c_list:
    new_list.append([j-min_n for j in i])
a = [None, None, None]
b = [None, None, None]
for i in range(3):
    for j in range(3):
        if new_list[i][j] == 0:
            a[i] = 0
            a_other = [num for num in [0, 1, 2] if i!=num]
            b[j] = 0
            b_other = [num for num in [0, 1, 2] if j!=num]
            for k in a_other:
                a[k] = new_list[k][j]
            for k in b_other:
                b[k] = new_list[i][k]
            break
for i, j in product([0, 1, 2], repeat=2):
    if new_list[i][j] != a[i]+b[j]:
        print('No')
        flag = False
        break
if flag:
    print('Yes')

Measured memory_bytes: 3192
#include <iostream>
#include <climits>

#define N 500000

using namespace std;

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  int L[n1+1], R[n2+1];
  for(int i = 0; i < n1; i++) L[i] = A[left + i];
  for(int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  int i = 0;  
  int j = 0;
  int count = 0;
  for(int k = left; k < right; k++) {
	if(L[i] <= R[j]) {
      A[k] = L[i];
      i = i + 1;
	  count++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
	  count++;
    }
  }

  return count;
}

int mergeSort(int A[], int left, int right) {
  int count = 0;
  if(left+1 < right) {
    int mid = (left + right)/2;
    count += mergeSort(A, left, mid);
    count += mergeSort(A, mid, right);
    count += merge(A, left, mid, right);
  }

  return count;
}

int main(void)
{
  int n;
  cin >> n;
  int S[N];
  for(int i= 0; i<n; i++) cin >> S[i];

  int count = mergeSort(S, 0, n);

  for(int i= 0; i<n; i++) {
    if(i == n-1) cout << S[i] << endl;
    else cout << S[i] << " ";
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 6920
#include <stdio.h>

int main(void){
  int n,p,q=0,sum=0;
  	
  	scanf("%d", &n);
  	
  	for(int i=0;i<n;i++){
		scanf("%d", &p);
      	sum+=p;
      	if(p>q){
		q=p;
        }
    }
  
  	printf("%d", sum-q/2);
}


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

int main() {
  int N,Y,x,y,z,sum;
  cin >> N >> Y;
  x=-1;y=-1;z=-1;
  for(int i=0;i<=N;i++){
  	for(int j=0;i+j<=N;j++){
    int k=N-i-j;
    int sum = 10000*i + 5000*j + 1000*k;
    if(sum==Y){x=i;y=j;z=k;}
    }
  }
  
  cout << x <<' '<< y <<' '<<  z <<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0; i < n ; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
 
    map<string,int> str_freq;
    for(string x: s) str_freq[x]++;
 
    long long ans = 0;
    for(auto p: str_freq) {
        long long c = p.second;
        ans += c * (c-1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <limits.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;



int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vi p(A+1);
	for (int i = 0; i < A; i++)
		cin >> p[i];
	vi q(B+1);
	for (int i = 0; i < B; i++)
		cin >> q[i];
	vi r(C+1);
	for (int i = 0; i < C; i++)
		cin >> r[i];

	sort(begin(p), end(p), greater<int>());
	sort(begin(q), end(q), greater<int>());
	sort(begin(r), end(r), greater<int>());
	p[X] = -9999;
	q[Y] = -9999;

	int pi = 0, qi = 0, ri = 0;
	ll ans = 0ll;
	for (int i = 0; i < X + Y; i++)
	{
		int pp = p[pi], qq = q[qi], rr = r[ri];
		int mm = max({pp, qq, rr});
		ans += mm;
		if (mm == pp)
			++pi;
		else if (mm == qq)
			++qi;
		else
			++ri;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner input;
    static void Main()
    {

        input = new Scanner();
        int n = input.Int();
        int[] p = input.linesInt(n);
        WriteLine((double)p.Max()/2+(double)(p.Sum()-p.Max()));

    }
    static double f(double a)
    {
        if (a%2 == 0)
        {
            return (double)(a/2);
        }
        else
        {
            return (double)(3*a+1);
        }

    }
}

class Scanner
{

    public Scanner()
    {
    }

    public void skip()
    {
        ReadLine();
        return;
    }
    public string String()
    {
        return ReadLine();
    }
    public string[] splitString()
    {
        return ReadLine().Split();
    }
    public string[] linesString(int len)
    {
        var arr = new string[len];
        for(int a = 0; a < len; a++)
        {
            arr[a] = ReadLine();
        }
        return arr;
    }
    public int Int()
    {
        return int.Parse(ReadLine());
    }
    public int[] splitInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public int[] linesInt(int len)
    {
        var arr = new int[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = int.Parse(ReadLine());
        }
        return arr;
    }
    public long Long()
    {
        return long.Parse(ReadLine());
    }
    public long[] splitLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public long[] linesLong(int len)
    {
        var arr = new long[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = long.Parse(ReadLine());
        }
        return arr;
    }
    public double Double()
    {
        return double.Parse(ReadLine());
    }
    public double[] splitDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
    public double[] linesDouble(int len)
    {
        var arr = new double[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = double.Parse(ReadLine());
        }
        return arr;
    }
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	for (int N, Q; cin >> N >> Q&&N;) {
		set<pair<int, int>> st;
		vector<string> name(N);
		vector<int> B(N);
		rep(i, 0, N) {
			int b, y; cin >> name[i] >> b >> y;
			st.insert(pair<int, int>(y - b + 1, i));
			B[i] = b;
		}
		rep(i, 0, Q) {
			int y; cin >> y;
			auto it = st.upper_bound(pair<int, int>(y, INF));
			if (it == st.begin()) {
				cout << "Unknown" << endl;
			}
			else {
				--it;
				int id = it->second;
				y = y - it->first + 1;
				if (y <= B[id]) {
					cout << name[id] << " " << y << endl;
				}
				else {
					cout << "Unknown" << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3184
from bisect import bisect_left, bisect_right
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
 
negative_end = bisect_left(A, 0)
positive_start = bisect_right(A, 0)
 
positive_cnt = N - positive_start
negative_cnt = negative_end
zero_cnt = N - (positive_cnt + negative_cnt)
 
negative_pairs_cnt = positive_cnt * negative_cnt
zero_pairs_cnt = zero_cnt * (positive_cnt + negative_cnt) + (zero_cnt * (zero_cnt - 1) // 2)

if K <= negative_pairs_cnt:
    ok, ng = 0, -10 ** 18
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt, r = 0, positive_start
        for l in range(negative_end):
            while (r < N) and (A[l] * A[r] > X):
                r += 1
            or_higher_cnt += positive_cnt - (r - positive_start)
 
        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X
 
    print(ok)

elif K <= negative_pairs_cnt + zero_pairs_cnt:
    print(0)

else:
    K -= (negative_pairs_cnt + zero_pairs_cnt)
    ok, ng = 10 ** 18, 0
    while abs(ok - ng) > 1:
        X = (ok + ng) // 2
        or_higher_cnt = 0
 
        r = N - 1
        for l in range(positive_start, N):
            while (r < N) and (A[l] * A[r] > X) and (l < r):
                r -= 1
            or_higher_cnt += max(0, r - l)
 
        l = 0
        for r in range(negative_end - 1, -1, -1):
            while (l < N) and (A[l] * A[r] > X) and (l < r):
                l += 1
 
            or_higher_cnt += max(0, r - l)
 
        if or_higher_cnt >= K:
            ok = X
        else:
            ng = X
 
    print(ok)

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

using namespace std;

int main() {

    string integer;
    char checkValue;
    
    
    cin >> integer;

    checkValue = integer[1];



    if((integer[0] == checkValue && integer[2] == checkValue) || (integer[2] == checkValue && integer[3] == checkValue)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split(' ').map(&:to_i)

(n - 1).downto(0) do |i|
  if i == 0
    puts 'Yes'
    break
  end

  if h[i - 1] - h[i] == 1
    h[i - 1] -= 1
  elsif h[i - 1] - h[i] > 1
    puts 'No'
    break
  end
end


Measured memory_bytes: 9604
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
int main(void){
	int W,H;
	cin>>W>>H;
	int n;
	cin>>n;

	int in = 0 , out = 0 , c = 0;
	for(int i = 0 ; i < n ; i ++){
		int inp;
		cin>>inp;
		if(inp){
			in ++;
		}else{
			out ++;
		}
		if(out < W){
			if(in == out) c ++;
		}else if(out < W + H - 1){
			if(in == out - 2) c ++;
		}else{
			if(in == out - 4) c ++;
		}
	}
	cout<<c<<endl;
}

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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1,T2>& p)const{
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1^h2;
		}
	};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	int t[n];
	int v[n];
	int prefixT[n];
	
	int tSum = 0;
	for (int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		t[i] = temp*2;
		tSum += t[i];
		prefixT[i] = tSum;
		}
		
	for (int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		v[i] = temp*2;
		}
		
	int perSec[tSum+1];
	memset(perSec, 0, sizeof(perSec));
	
	for (int i = 0; i < tSum+1; i++){
		perSec[i] = min(i, tSum-i);
		}
	
	int tracker = 0;
	for (int i = 0; i < n; i++){
		for (int j = tracker; j < prefixT[i]+1; j++){
			perSec[j] = min(perSec[j], v[i]);
			}
			tracker += t[i];
		}
		
	for (int i = 0; i < tSum; i++){
		perSec[i+1] = min(perSec[i]+1,perSec[i+1]);
		}
	
	for (int i = tSum; i > 1; i--){
		perSec[i-1] = min(perSec[i]+1, perSec[i-1]);
		}
		
	int total = 0;
	for (int i = 0; i < tSum+1; i++){
		total += perSec[i];
		}
	
	// because we start and end in 0
	// number of ups and number of downs have to be the same
	// the are fills in perfectly
	ld ans = (ld) total / 4;
	cout << fixed << setprecision(6) << ans << endl;
	}
	
	
	


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

using namespace std;

using ll = long long;
using ld = long double;

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	int b[30];
	for (int i = 0; i < m; ++i)
	{
		cin >> b[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int buf = c;
		for (int j = 0; j < m; ++j)
		{
			int a;
			cin >> a;
			buf += a * b[j];
		}
		if (buf > 0)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int N=2e5+200;
vector<int>v[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int x,i=2;i<=n;i++){
		scanf("%d",&x);
		v[x].push_back(i);
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",v[i].size());
	}
}

Measured memory_bytes: 14696
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
int main() {
	string S;
	cin >> S;
	vector<string>A(S.size() - 2);
	vector<int>C(S.size() - 2);

	for (int i = 0; i < S.size() - 2; i++) {
		A[i] = S.substr(i, 3);
	}
	for (int i = 0; i < S.size() - 2; i++) {
		C[i] = abs(753 - stoi(A[i]));
	}
	sort(C.begin(), C.end());
	cout << C[0] << endl;
}


Measured memory_bytes: 3612
maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])



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

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n";
#define all(c)  (c).begin(),(c).end()
#define SORT(a) sort((a).begin(),(a).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

string s;

int main(){
    cin >> s;
    int n = s.size();
    vector<bool> b(4,false);
    REP(i,n){
        if(s[i]=='N')b[0]=true;
        if(s[i]=='S')b[1]=true;
        if(s[i]=='E')b[2]=true;
        if(s[i]=='W')b[3]=true;
    }
    if ((b[0]^b[1])||(b[2]^b[3])) {
        put("No");
    } else {
        put("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, M, D, T;
	cin >> N;
	multiset<int> dset;
	for (int i = 0; i < N; i++) {
		cin >> D;
		dset.insert(D);
	}
	
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T;
		auto itr = dset.find(T);
		if (itr == dset.end()) {
			print("NO");
			return 0;
		}
		else {
			dset.erase(itr);
		}
	}
	print("YES");
	return 0;
}

Measured memory_bytes: 12960
//#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int x,y,a,b,c;
ll p[N],q[N],r[N];
bool cmp(int a,int b){
    return a>b;
}
vector<ll> v;
int main(){
    cin>>x>>y>>a>>b>>c;
    rep(i,1,a)read(p[i]);
    rep(i,1,b)read(q[i]);
    rep(i,1,c)read(r[i]);
    sort(p+1,p+1+a,cmp);
    sort(q+1,q+1+b,cmp);
    sort(r+1,r+1+c,cmp);
    ll ans=0;
    rep(i,1,x)v.pb(p[i]);
    rep(i,1,y)v.pb(q[i]);
    sort(v.begin(),v.end());
    int now=0;
    rep(i,1,c){
        if(now<v.size()&&r[i]>v[now])v[now]=r[i];
        now++;
    }
    rep(i,0,v.size()-1)ans+=v[i];
    cout << ans << '\n';
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

void go(vl &a) {
	ll n = sz(a);
	ll i = 0;
	FOR(j,0,n) if (a[j] > a[i]) i = j;

	a[i] -= n;
	FOR(j,0,n) if (j != i) a[j]++;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	vl c(n);
	
	ll res = 0;
	bool done = false;
	while (!done) {
		done = true;
		
		FOR(i,0,n) {
			if (a[i] + res - (n+1)*c[i] <= n-1) continue;
			ll x = a[i] + res - (n+1)*(c[i]) - (n-1);
			c[i] += (x+n-1)/n, res += (x+n-1)/n;
			done = false;
		}
	}
	cout << res << endl;



/*sort(all(a));
	reverse(all(a));
	
	ll res = 0;
	FOR(k,1,n+1) {
		sort(all(a));
		reverse(all(a));
		ll x = (a[0]-a[k])/(n+k);

		res += x*k;
		FOR(i,0,k) a[i] -= x*n;
		FOR(i,k,n) a[i] += x*k;

		FOR(i,0,n) cerr << a[i] << " ";
		cerr << res << endl;
	}
	
	ll amax = -oo;
	FOR(i,0,n) amax = max(amax,a[i]);
	cout << res << endl;*/
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin(), x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

// i: layer
// j: the number haven't been decided
// k: k at that time (if not connected, k is increased with the number)
ll dp[51][51][2501];
vector<int> A;
vector<int> ans;

signed main(void) {
  	ll S;
  	cin >> S;

  	// suppose x1, x2 = 0;
  	// find x2*y3- x3*y2 = S
  	// suppose x2 = 1e9, y2 = 1
  	ll y3 = int(S/1000000000) + 1;
  	ll x3 = 1000000000*y3 - S;
  	if (S == 1e18) {
  		y3 = 1e9; x3 = 0;
  	}
  	cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << x3 << " " << y3 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  
  int L = A +B;
  int R = C +D;
  if(L > R ) cout <<"Left" << endl;
  else if(L < R) cout << "Right"<< endl;
  else cout <<"Balanced" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#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>
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 ll MOD=1e9+7;

int main(){

	string s;
	cin >> s;
	int cnt=0, ans=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
			cnt++;
			ans=max(ans, cnt);
		} else {
			cnt=0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{   int n;
    scanf("%d",&n);
    int a[n+1];
    a[n]=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    long long ans=0,sum=0;
    for(int i=0;i<=n;i++){
        if(a[i]==0){
            ans+=sum/2;
            sum=0;
        }else{
            sum+=a[i];
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int w, h, n; cin >> w >> h >> n;

    vector<VI> f(h, VI(w, 0));
    FOR(i, 0, n) {
        int x, y, a; cin >> x >> y >> a;
        switch (a) {
        case 1:
            FOR(j, 0, h)FOR(k, 0, x)f[j][k]++;
            break;
        case 2:
            FOR(j, 0, h)FOR(k, x, w)f[j][k]++;
            break;
        case 3:
            FOR(j, 0, y)FOR(k, 0, w)f[j][k]++;
            break;
        case 4:
            FOR(j, y, h)FOR(k, 0, w)f[j][k]++;
            break;
        }
    }
    int ans = 0;
    FOR(i, 0, h)FOR(j, 0, w)ans += !bool(f[i][j]);
    cout << ans << "\n";
}

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

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var N = Console.ReadLine();
			var answer = 0;

			for(int i = 0; i < N.Length; i++)
			{
				answer += N[i] - '0';
			}

			if(answer % 9 == 0)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}
	}
}

Measured memory_bytes: 17276
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
int a,b,c,d,ans,N,M,tt;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%.9lf ",1.0*a*b/2);
	if (a==c*2&&b==d*2) printf("1\n");
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	double x, t;
	cin >> x >> t;
	dumpf(x / t, 4);
}

Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);   
    long double a,b,c;
    cin >> a;
    b = a/3.0;
    b = b*b*b;
    cout << setprecision(10) << fixed << b << endl;
    return 0;

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAX = 2100;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n), s(MAX+1);
    rep(i, n){
        cin >> v[i];
        s[v[i]+1]++;
    }
    rep(i, MAX) s[i+1] += s[i];

    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j) continue;
            ll a = v[i], b = v[j];
            int left = abs(a-b)+1;
            int right = a+b;
            ll d = (left <= a && a < right) + (left <= b && b < right);
            ans += max((s[right] - s[left]) - d, 0LL);
        }
    }
    cout << ans/6 << endl;
}

Measured memory_bytes: 256
from itertools import product
from collections import Counter

S = input()
ML = len(S)

B = {'A', 'T', 'G', 'C'}
L = 0
for b, e in product(range(ML), repeat=2):
    T = S[b:ML-e]
    cc = Counter(T)
    BB = set(cc.keys()) - B
    if len(BB) == 0 and L < len(T):
        L = len(T)

print(L)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
void lcs(string s1[],int l,int k)
{
	int dp[l+1][k+1];
	int i,j;
	for(i=0;i<l;i++)
	{
		for(j=0;j<k;j++)
		{
		   if(s1[i][j]=='.')
		   dp[i][j]=1;
		   else
		   dp[i][j]=0;
		}
	}
	for(i=0;i<k;i++)
	{
	    if(dp[0][i]==0)
	    break;
	}
	for(j=i;j<k;j++)
	dp[0][j]=0;
	for(i=0;i<l;i++)
	{
	    if(dp[i][0]==0)
	    break;
	}
	for(j=i;j<l;j++)
	dp[j][0]=0;
    for(i=1;i<l;i++)
	{
		for(j=1;j<k;j++)
		{
		   if(dp[i][j]==1)
		   dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[l-1][k-1]<<"\n";

}
int main() {
    int l,k;
    cin>>l>>k;
	string s1[1005];
	for(int i=0;i<l;i++)
	cin>>s1[i];
	lcs(s1,l,k);
	return 0;
}

Measured memory_bytes: 5248
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL r;
	cin >> r;

	O(3 * r * r);

	return 0;
}

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            var total = a.Sum();
            var t = 0L;
            var minVal = long.MaxValue;
            for(var i = 0; i < n - 1; i++){
                t += a[i];
                minVal = Math.Min(minVal, Math.Abs(total - (t * 2)));
            }

            Console.WriteLine(minVal);
        }
    }
}


Measured memory_bytes: 34500
from math import sqrt
import itertools

def factorization(n):
    factors = []
    temp = n
    for i in range(2, int(sqrt(n))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factors.append((i, count))
    if temp != 1:
        factors.append((temp, 1))
    if not factors:
        factors.append((n, 1))

    return factors


N = int(input())
factors = factorization(N)
count = 0
for a, b in factors:
    c = 0
    for i in itertools.count(1):
        c += i
        if c > b:
            break
        else:
            count += 1

if N == 1:
    print(0)
else:
    print(count)


Measured memory_bytes: 9164