akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right

n,k = map(int, input().split())
al = list(map(int, input().split()))
negal = []
posil = []
zero_cnt = 0
for a in al:
    if a > 0:
        posil.append(a)
    elif a == 0:
        zero_cnt += 1
    else:
        negal.append(abs(a))

negal.sort()
posil.sort()
nega_comb = len(negal)*len(posil)
zero_comb = zero_cnt*(zero_cnt-1)//2 + (len(negal)+len(posil))*zero_cnt

# ans = positive
if nega_comb+zero_comb < k:
    ng, ok = 0,10**18+1
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        cnt = nega_comb+zero_comb
        for i,nega in enumerate(negal):
            thre = mid//nega
            c_cnt = bisect_right(negal, thre)
            c_cnt -= (i+1)
            c_cnt = max(c_cnt,0)
            cnt += c_cnt
        for i,posi in enumerate(posil):
            thre = mid//posi
            c_cnt = bisect_right(posil, thre)
            c_cnt -= (i+1)
            c_cnt = max(c_cnt,0)
            cnt += c_cnt
        if k <= cnt:
            ok = mid
        else:
            ng = mid
    print(ok)

elif nega_comb < k:
    print(0)

# ans = negative
else:
    ng, ok = (10**18+1)*(-1), 0
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        cnt = 0
        for i,nega in enumerate(negal):
            thre = ((-1)*mid-1)//nega + 1
            c_cnt = len(posil) - bisect_left(posil, thre)
            cnt += c_cnt
        if k <= cnt:
            ok = mid
        else:
            ng = mid
    print(ok)

Measured memory_bytes: 105712
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    map<int,int> score;
    REP(i,N){
        int a; cin>>a;
        score[a-1]++;
        score[a]++;
        score[a+1]++;
    }
    int ans=0;
    for(auto p:score){
        ans=max(ans,p.second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

// A -> 0, G -> 1, C -> 2, T -> 3
ll dp[110][4][4][4];

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

    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                dp[3][k][j][i] = 1;
            }
        }
    }

    // AGC, ACG, GAC are invalid
    dp[3][2][1][0] = 0;
    dp[3][1][2][0] = 0;
    dp[3][2][0][1] = 0;

    for(int i=3; i<n; i++){
        for(int j=0; j<4; j++){ // i-2
            for(int k=0; k<4; k++){ // i-1
                for(int l=0; l<4; l++){ // i

                    if(dp[i][l][k][j] == 0) continue;

                    for(int m=0; m<4; m++){ // i+1
                        // *AGC 
                        if(k == 0 && l == 1 && m == 2) continue;

                        // *ACG
                        if(k == 0 && l == 2 && m == 1) continue;

                        // *GAC
                        if(k == 1 && l == 0 && m == 2) continue;

                        // A*GC
                        if(j == 0 && l == 1 && m == 2) continue;

                        // AG*C
                        if(j == 0 && k == 1 && m == 2) continue;

                        dp[i+1][m][l][k] += dp[i][l][k][j];
                        dp[i+1][m][l][k] %= MOD;
                    }
                }
            }
        }
    }

    ll ans=0;
    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                ans += dp[n][i][j][k];
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	int num[2] = { 0 };
	for (int i = 0; i < M; i++) {
		int A;
		cin >> A;
		num[A > X]++;
	}
	cout << min(num[0], num[1]) << endl;
}

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

int main() {
    int N; cin >> N;
    vector<pair<double, double>> xy(N);
    for(int i = 0; i < N; ++i) {
        cin >> xy[i].first >> xy[i].second;
    }
    sort(xy.begin(), xy.end());
    int cnt = 0;
    double sum = 0;
    do {
        for(int i = 0; i < N - 1; ++i) {
            int j = i + 1;
            double x = xy[i].first - xy[j].first;
            double y = xy[i].second - xy[j].second;
            sum += sqrt(x * x + y * y);
        }
        cnt++;
    } while(next_permutation(xy.begin(), xy.end()));
    printf("%.15lf\n", sum / cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

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

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n;
    string s;
    cin>>n>>s;
    int op=0;
    int i=0,j=n-1;
    while(i<j) {
        while(i<j&&s[j]=='W') {
            j--;
        }
        while(i<j&&s[i]=='R') {
            i++;
        }
        if(i<j&&s[i]=='W'&&s[j]=='R') {
            swap(s[i],s[j]);
            i++;
            j--;
            op++;
        }
    }
    cout<<op;

}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
const int N = 1010;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
int _w;

int n, m;
char str[N][N];
int dis[N][N];
queue<pii> q;

bool inside( int x, int y ) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%s", str[i]+1 );
	memset(dis, -1, sizeof dis);
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			if( str[i][j] == '#' )
				dis[i][j] = 0, q.push( pii(i, j) );
	int ans = 0;
	while( !q.empty() ) {
		pii now = q.front(); q.pop();
		ans = max(ans, dis[now.first][now.second]);
		for( int i = 0; i < 4; ++i ) {
			int nx = now.first + dx[i];
			int ny = now.second + dy[i];
			if( inside(nx, ny) && dis[nx][ny] == -1 ) {
				dis[nx][ny] = dis[now.first][now.second] + 1;
				q.push( pii(nx, ny) );
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16208
#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() {
        int n,k;
        cin >> n >> k;

        int d;
        vector<int> a(n);
        vector<int> cnt_s(n);

        for (int i = 0; i < k; ++i) {
                cin >> d;
                for (int j = 0; j < d; ++j) {
                        cin >> a[j];
                        //if (a[j] == j+1) {
                                cnt_s[a[j]-1]++;
                        //}
                }
        }

        int ans = 0;
        for (int j = 0; j < n; ++j) {
                if (cnt_s[j] == 0) {
                        ans++;
                }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	VI p(n);
	REP(i, n)cin >> p[i];

	int c1 = 0, c2 = 0, c3 = 0;
	REP(i, n) {
		if (p[i] <= a)c1++;
		else if (p[i] > a&&p[i] <= b)c2++;
		else c3++;
	}
	cout << min(c1, min(c2, c3)) << endl;
}

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int nums[3];
        cin >> nums[0] >> nums[1] >> nums[2];
        sort(nums, nums + 3);
        YES(nums[0] * nums[0] + nums[1] * nums[1] == nums[2] * nums[2]);
    }
}



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

vector<int> kmp(const string &s, const string &t) {
  vector<int> ta(t.size() + 1);
  {
    ta[0] = -1;
    int j = -1;
    for (int i = 0; i < t.size(); i++) {
      while (j >= 0 && t[i] != t[j]) j = ta[j];
      ta[i + 1] = ++j;
    }
  }
  vector<int> ret;
  int m = 0, i = 0, n = s.size();
  while (m + i < n) {
    if (t[i] == s[m + i]) {
      if (++i == (int) t.size()) {
        ret.push_back(m);
        m = m + i - ta[i];
        i = ta[i];
      }
    } else {
      m = m + i - ta[i];
      if (i > 0) i = ta[i];
    }
  }
  return ret;
}

int main() {
  string t, p;
  cin >> t >> p;
  auto r = kmp(t, p);
  for (int i = 0; i < r.size(); i++) {
    cout << r[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 8488
#include <stdio.h>
int main () {
	int A,B,C;
	int sum=0,max=0;
	scanf("%d %d %d",&A,&B,&C);
	max = B + C;
	sum = max;
	max = max - B*2 -1;
	if (max - A > 0) {
		sum = sum - (max-A);
	}
	
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int A, B;
    cin >> A >> B;
    printf("%d\n", A*B);

}


Measured memory_bytes: 3764
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let sp = get!(String, usize; n);

    let mut isp = sp.into_iter().enumerate().collect::<Vec<_>>();

    isp.sort_by(|&(_,(ref s1,p1)),&(_,(ref s2,p2))| if s1.cmp(&s2) == Ordering::Equal {
        p2.cmp(&p1)
    } else {
        s1.cmp(&s2)
    });

    for (i, (_, _)) in isp {
        println!("{}", i+1);
    }
}


Measured memory_bytes: 8572
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var d = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    d++;
                }
            }
            Console.WriteLine(N - d);
        }
    }
}


Measured memory_bytes: 11232
#include <stdio.h>

int main() {

    int a, b;

    scanf("%d %d", &a, &b);
    
    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}



Measured memory_bytes: 2060
S = input()
A = [int(s) for s in S]
for i in range(8):
    ii = i
    Sum = A[0]
    for j in range(3):
        if (i >> j) & 1:
            Sum += A[j+1]
        else:
            Sum -= A[j+1]
    if Sum == 7:
        Ans = str(A[0])
        for j in range(3):
            if (i >> j) & 1:
                Ans += "+"
            else:
                Ans += "-"
            Ans += str(A[j+1])
        Ans += "=7"
        print(Ans)
        break

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int N,K,L;
int a[200001],b[200001],rank_a[200001],rank_b[200001];
typedef pair<int ,int > P;
void init(int x){
  for(int i=0;i<x;i++){
    a[i]=i;b[i]=i;
    rank_a[i]=0;rank_b[i]=0;
  }
}

int find(int x,int *par){
  if(par[x]==x)return x;
  else return find(par[x],par);
}

void unite(int x,int y,int *par,int *rank){
  x=find(x,par);
  y=find(y,par);
  if(x==y)return ;
  if(rank[x]<rank[y])par[x]=y;
  else {
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

bool same(int x,int y,int *par){
  return find(x,par)==find(y,par);
}
int main(){
  cin >> N >> K >> L;
  init(N);
  for(int i=0;i<K;i++){
    int p,q;
    cin >> p >> q;
    p--;q--;
    unite(p,q,a,rank_a);
  }

  for(int i=0;i<L;i++){
    int r,s;
    cin >> r >> s;
    r--;s--;
    unite(r,s,b,rank_b);
  }
  map <P,int > m;
  for(int i=0;i<N;i++) m[P(find(i,a),find(i,b))]++;
  for(int i=0;i<N;i++) cout << m[P(find(i,a),find(i,b))] << endl;
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in2(a, b);
  c = max(a + b, a - b);
  c = max(c, a * b);
  out(c);
  memi;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] arr = line.split(" ");
		double a = Double.parseDouble(arr[0]);
		double b = Double.parseDouble(arr[1]);
		double C = Double.parseDouble(arr[2]);

		double h = b * Math.sin(Math.toRadians(C));
		double S = a * h / 2;
		double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b
				* Math.cos(Math.toRadians(C));
		double c = Math.sqrt(c2);

		System.out.printf("%.5f %.5f %.5f%n", S, a + b + c, h);

		if (br != null) {
			br.close();
			br = null;
		}
	}
}

Measured memory_bytes: 16948
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

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

    int res = 0;

    rep(i, 23){
        if(n <= (ll)pow(3., (double)i)) break;
        res++;
    }

    cout << res << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int getsize(string s1, string s2) {
	set<char> st1, st2;
	for(auto u : s1) st1.insert(u);
	for(auto u : s2) if (st1.count(u)) st2.insert(u);
	return st2.size();
}

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	reps(i, 1, s.size()) {
		string s1 = s.substr(0, i);
		string s2 = s.substr(i);
		// cout << s1 << " " << s2 << endl;
		ans = max(ans, getsize(s1, s2));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np


def solve(n, m, q, sss, xy):
    dp1 = np.zeros((n + 1, m + 1), dtype=np.int64)
    dpv = np.zeros((n + 1, m + 1), dtype=np.int64)
    dph = np.zeros((n + 1, m + 1), dtype=np.int64)
    for i in range(n):
        for j in range(m):
            if sss[i, j] == 1:
                dp1[i + 1, j + 1] = 1

                if i > 0 and sss[i - 1, j] == 1:
                    dpv[i + 1, j + 1] = 1
                if j > 0 and sss[i, j - 1] == 1:
                    dph[i + 1, j + 1] = 1

    for i in range(1, n + 1):
        for j in range(1, m + 1):
            dp1[i, j] += dp1[i, j - 1]
            dpv[i, j] += dpv[i, j - 1]
            dph[i, j] += dph[i, j - 1]

    for j in range(1, m + 1):
        for i in range(1, n + 1):
            dp1[i, j] += dp1[i - 1, j]
            dpv[i, j] += dpv[i - 1, j]
            dph[i, j] += dph[i - 1, j]

    buf = np.zeros(q, dtype=np.int64)
    for i in range(q):
        x1 = xy[i * 4 + 0]
        y1 = xy[i * 4 + 1]
        x2 = xy[i * 4 + 2]
        y2 = xy[i * 4 + 3]
        cnt1 = dp1[x2][y2] - dp1[x1 - 1][y2] - dp1[x2][y1 - 1] + dp1[x1 - 1][y1 - 1]
        ver1 = dpv[x2][y2] - dpv[x1][y2] - dpv[x2][y1 - 1] + dpv[x1][y1 - 1]
        hor1 = dph[x2][y2] - dph[x1 - 1][y2] - dph[x2][y1] + dph[x1 - 1][y1]
        buf[i] = cnt1 - ver1 - hor1

    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8,i8,i8,i1[:,:],i8[:])')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8,i8,i8,i1[:,:],i8[:])', cache=True)(solve)

n, m, q = map(int, input().split())
sss = np.array([list(map(int, input())) for _ in range(n)], dtype=np.int8)
xy = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(n, m, q, sss, xy)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 138052
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Result{
  set<int> value;
  int p;
  Result(set<int> v, int p) : value(v), p(p) {}
};
bool is_operator(char c){
  string operators = "+-*/";
  REP(i, operators.size()) if(c == operators[i]) return true;
  return false;
}
Result expr(const string& s, int p);
Result factor(const string& s, int p){
  if(s[p] == '('){
    Result r = expr(s, p + 1);
    assert(s[r.p] == ')');
    r.p ++;
    return r;
  }else{
    int v = 0;
    while(isdigit(s[p])){
      v = v * 10 + s[p++] - '0';
    }
    set<int> res;
    res.insert(v);
    return Result(res, p);
  }
}
Result expr(const string& s, int p){
  Result r = factor(s, p);
  vector<char> operators;
  vector< set<int> > operands;
  operands.push_back(r.value);
  while(is_operator(s[r.p])){
    Result r_ = factor(s, r.p + 1);
    operators.push_back(s[r.p]);
    operands.push_back(r_.value);
    r.p = r_.p;
  }
  set<int> dp[20][20];
  int N = operands.size();
  REP(i, N) dp[i][i + 1] = operands[i];
  for(int len = 2; len <= N; len++){
    for(int left = 0; left + len <= N; left++){
      int right = left + len;
      for(int ope = left + 1; ope < right; ope++){
        FORIT(it1, dp[left][ope])FORIT(it2, dp[ope][right]){
          if(operators[ope - 1] == '+'){
            dp[left][right].insert(*it1 + *it2);
          }else if(operators[ope - 1] == '-'){
            dp[left][right].insert(*it1 - *it2);
          }else if(operators[ope - 1] == '*'){
            dp[left][right].insert(*it1 * *it2);
          }else if(operators[ope - 1] == '/' && *it2 != 0){
            dp[left][right].insert(*it1 / *it2);
          }
        }
      }
    }
  }
  r.value = dp[0][N];
  return r;
}
int main(){
  string s;
  while(cin>>s && s != "#"){
    set<int> res = expr(s, 0).value;
    cout << res.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1468
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  map<i64, i64> m;
  for (i64 i = 0; i < N; i++)
  {
    m[A[i]]++;
  }
  i64 ans = 0;
  for (pair<i64, i64> i : m)
    ans += i.second * (i.second - 1) / 2;
  for (i64 i = 0; i < N; i++)
    cout << ans - m[A[i]] * (m[A[i]] - 1) / 2 + (m[A[i]] - 1) * (m[A[i]] - 2) / 2 << endl;
  return 0;
}


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

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

	vector<int> v;
	while (n--) {
		int a;
		cin >> a;

		v.push_back(a);
	}

	int q;
	cin >> q;

	while (q--)
	{
		int b, e, k;
		cin >> b >> e >> k;

		int count = 0;
		for (; b != e; b++) {
			if (v[b] == k) {
				count++;
			}
		}

		cout << count << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<string>
#include<queue>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	freopen("at81e.in","r",stdin);
#endif
	//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
	inp();
	return 0;
}
const int NN = 1e8;
struct Nod{
	char c;
	int p,pre;
	Nod(){}
	void set(char c,int pre,int p){this->c=c,this->pre=pre,this->p=p;}
}nod[NN];
queue<int > q;
int ans;
const int N=3e5;
char s[N];
int fd[N][30];
int cnt=0;
const int D = 26;
void bfs(){
	nod[cnt].set(-1,-1,-1); cnt++;
	q.push(0);
	while(!q.empty()){
		ans=q.front();q.pop();
		for(int c=0;c<D;c++){
			if(fd[nod[ans].p+1][c]!=-1){
				nod[cnt].set(c,ans,fd[nod[ans].p+1][c]);
				q.push(cnt);
				cnt++;
			}
			else { 
				nod[cnt].set(c,ans,nod[ans].p);
				ans=cnt;
				cnt++;
				return; }
		}
	}
}
int dp[N];
const int inf = 0x7fffffff;
void inp(){
	MS(fd,-1);
	scanf("%s",s);
	int len = strlen(s);
	for(int i =0;i<len;i++){ s[i]-='a'; }
	for(int i =len-1;i>=0;i--){ fd[i+1][(int)s[i]]=i+1; }
	for(int i =len;i>1;i--){
		for(int c=0;c<D;c++){
			if(fd[i][c]!=-1){
				if(fd[i-1][c]==-1)fd[i-1][c]=fd[i][c];
			}
		}
	}
	for(int i =0;i<N;i++){
		for(int j=0;j<D;j++)if(fd[i][j]==-1)
			fd[i][j]=N-1;
	}
	fill(dp,dp+len+1,inf);
	fill(dp+len+1,dp+N,0);
	for(int i =len;i>=0;i--){
		for(int j=0;j<D;j++){
			if(dp[i]>dp[fd[i+1][j]]+1){
				dp[i]=dp[fd[i+1][j]]+1;
			}
		}
	}
	for(int i =0;i<len;){
		for(int j =0;j<D;j++){
			if(dp[i]==dp[fd[i+1][j]]+1){
				putchar('a'+j);
				i=fd[i+1][j];
				break;
			}
		}
	}
	putchar('\n');
}
//at81e.cc by xsthunder at Sun Aug 20 20:48:17 2017


Measured memory_bytes: 37120
/*
    Author  :   jignesh1604
    College :   SVNIT
    "Do what you can , with what you have , where you are"
    1 contest + 2 upsolve + 1 new topic + 5 problems = 1900+ of cf in 3 months
*/

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

void solve() {
    map<string , long long int> mp;
    long long int n , i;
    string s;
    cin >> n;
    for(i = 0 ; i < n ; i++) {
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    
    cout << "WA x " << mp["WA"] << "\n";
    
    cout << "TLE x " << mp["TLE"] << "\n";
    
    cout << "RE x " << mp["RE"] << "\n";
}

int main() {
    long long int tc = 1;
    // cin >> tc;
    while(tc-- > 0) {
        solve();
    }
}

Measured memory_bytes: 3636
n=int(input())
s=input()
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
def func(nums):
  if len(nums)==1:
    return nums[0]%(10**9+7)
  elif len(nums)==2:
    return (nums[0]+nums[1]+nums[0]*nums[1])%(10**9+7)
  else:
    num=func(nums[1:])
    return (nums[0]+num+nums[0]*num)%(10**9+7)
print(func(al))



Measured memory_bytes: 3188
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
l1=[False]*n
ln=[False]*n
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        l1[b-1]=True
    if b==1:
        l1[a-1]=True
    if a==n:
        ln[b-1]=True
    if b==n:
        ln[a-1]=True
for i in range(n):
    if l1[i] and ln[i]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')



            



Measured memory_bytes: 44252
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int tap = sc.nextInt();
		int wantNum = sc.nextInt();

		int cnt = 1;
		int tapWant = 0;
		while(cnt < wantNum) {
			tapWant++;
			cnt += (tap - 1);
		}
		System.out.println(tapWant);
	}
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i <= X + K - 1; ++i) {
    if (i == X + K - 1)
      cout << i << endl;
    else
      cout << i << ' ';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n,m;
vi vals;
vector<ii> zmiana;

void dane() {
	cin>>n>>m;
	LL sum = 0;
	F(i,0,n) {
		int a;
		cin>>a;
		vals.push_back(a);
	}

	F(i,0,m) {
		int a,b;
		cin>>a>>b;
		zmiana.push_back({-b, a});
	}
	sort(ALL(vals));
	sort(ALL(zmiana));
	//FOREACH(it,zmiana) cout<<it->first<<endl;	

	int idx_zmiana = 0;
	int idx_val = 0;
	while(idx_val != n && idx_zmiana != m) {
		int war = -1* zmiana[idx_zmiana].first;
		if(zmiana[idx_zmiana].second == 0) {
			idx_zmiana++;
			continue;
		}

		if(war < vals[idx_val]) {
			idx_val++;
			continue;
		}
		vals[idx_val++] = war;
		zmiana[idx_zmiana].second--;
	}
	F(i,0,n) sum+=vals[i];
	cout<<sum<<endl;
}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long s=0,a=0,b=0,c=0,d=0,e=0;
	int n,i;
	char arr;
	scanf("%d",&n);
	//getchar();
	for(i=0;i<n;i++)
	{
		char tmp[1024];
		scanf("%s",tmp);
		//getchar();
		arr=tmp[0];
		if(arr=='M')
			a++;
		else if(arr=='A')
			b++;
		else if(arr=='R')
			c++;
		else if(arr=='C')
			d++;
		else if(arr=='H')
			e++;
	}
	//printf("%d %d %d %d %d",e,a,b,c,d);
	s=a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e;
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
using namespace std;

int main(int argc, char const *argv[])
{
	int turn=0;
	int taro, hanako=0;
	string t,h;

	cin >> turn;

	for (int i = 0; i < turn; ++i)
	{
		cin >> t;
		cin >> h;

		if(t > h)
		{
			taro+=3;
		}
		else if (t < h)
		{
			hanako+=3;
		}
		else if (t == h)
		{
			taro++;
			hanako++;
		}
	}

	cout << taro << " " << hanako << endl;;
	return 0;
}


Measured memory_bytes: 3148
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	w, h, n := scanInt(), scanInt(), scanInt()

	xl, xr := 0, w
	yl, yr := 0, h
	for i := 0; i < n; i++ {
		x, y, a := scanInt(), scanInt(), scanInt()
		switch a {
		case 1:
			xl = max(xl, x)
		case 2:
			xr = min(xr, x)
		case 3:
			yl = max(yl, y)
		case 4:
			yr = min(yr, y)
		}
	}
	if xr > xl && yr > yl {
		fmt.Println((xr - xl) * (yr - yl))
	} else {
		fmt.Println(0)
	}
}


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

int main(){
  int N;
  bool a=true;
  cin>>N;
  vector<int> t(N),x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>t.at(i)>>x.at(i)>>y.at(i);
    if(i==0){
      if((x.at(i)+y.at(i)-t.at(i))%2!=0||x.at(i)+y.at(i)>t.at(i)){
        a=false;
        break;
      }
    }else{
      if((x.at(i)+y.at(i)+x.at(i-1)+y.at(i-1)+t.at(i)+t.at(i-1))%2!=0||x.at(i)+y.at(i)-x.at(i-1)-y.at(i-1)>t.at(i)-t.at(i-1)){
        a=false;
        break;
      }
    }
  }
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

typedef pair<LL,LL> PLL;
const LL inf = 1e18 + 1e9;

int main()
{
    /* #ifndef ONLINE_JUDGE */
    /*     freopen("foo", "rt", stdin); */
    /* #endif */
    int N;
    while (cin >> N) {
        vector<PLL> A;
        multiset<LL> X,Y;
        FOR(i,0,N) {
            LL x,y; cin >> x >> y;
            if (x > y)
                swap(x,y);
            A.push_back(PLL(x,y)); X.insert(x); Y.insert(y);
        }
        sort(ALL(A));
        LL ans = inf;
        const LL rmin = *X.begin(),  bmax = *Y.rbegin();
        const LL rmax = *X.rbegin(), bmin = *Y.begin();
        const LL res = (rmax-rmin) * (bmax-bmin);
        ans = min(ans,res);
        FOR(i,0,N) {
            const LL x = A[i].first;
            const LL y = A[i].second;
            X.erase(X.find(x)); Y.insert(x);
            Y.erase(Y.find(y)); X.insert(y);
            const LL rmin = *Y.rbegin(), rmax = *Y.begin();
            const LL bmin = *X.rbegin(), bmax = *X.begin();
            const LL res = (rmax-rmin) * (bmax-bmin);
            ans = min(ans,res);
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(void){
    int N, tmp;
    int* st;
    cin >> N;
    
    st = new int[N+1];

    for(int i = 1; i <= N; i++){
        cin >> tmp;
        st[tmp] = i;
    }

    for(int i = 1; i <= N; i++){
        cout << st[i] << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> v(n); cin >> v;
    sort(all(v), greater<ll>());
    ll ans = 0;
    { // xxxooo
        ll a = 0, k = 0;
        rep(i, n-2) {
            if (v[i] < v[i+1] + v[i+2]) {
                a += v[i] + v[i+1] + v[i+2];
                i += 2;
                if (++k == 2) {
                    chmax(ans, a);
                }
            }
        }
    }
    {
        rep(i, n-5) {
            if (v[i] < v[i+1] + v[i+5] && v[i+2] < v[i+3] + v[i+4] // xxooox
             || v[i] < v[i+1] + v[i+4] && v[i+2] < v[i+3] + v[i+5] // xxooxo
             || v[i] < v[i+3] + v[i+4] && v[i+1] < v[i+2] + v[i+5]) { // xooxxo
                ll sum = 0;
                rep(j, 6) sum += v[i+j];
                chmax(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
using System;

class Atcoder48
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int starttime = a + b;

        if (starttime > 23)
            Console.WriteLine(starttime - 24);
        else
            Console.WriteLine(starttime);
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >>n;
	for (int i=0;i<=25;i++){
		for (int j=0;j<=25;j++){
			if (4*i+7*j==n){
				cout <<"Yes";
				return 0;
			}
		}
	}
	cout <<"No";
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int sum=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int l=1;l<=n;l++){
					sum+=gcd(i,gcd(j,l));
				}
			}
		}
		
		System.out.println(sum);
	}
		
	public static int gcd(int m, int n) {
        int r;
        while (n > 0) {
            r = m % n;
            m = n;
            n = r;
        }
        return m;
	}
}

Measured memory_bytes: 35652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	hh := make([]int, n)

	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner)
	}
	sort.Ints(hh)
	var ans int64
	for i := 0; i < n-k; i++ {
		ans += int64(hh[i])
	}

	fmt.Fprintln(writer, ans)
}


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

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

    int num1 = N % 10;//1
    int num1000 = N / 1000;//1000
    N = N / 10;
    int num10 = N % 10;//10
    N = N / 10;
    int num100 = N % 10;//100

    if((num1 == num10 && num10 == num100) || (num10 == num100 && num100 == num1000)){
             cout << "Yes" << endl;   
    }else{
        cout << "No" << endl;
    }
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int A,B;

  cin>>A>>B;

  cout<<max(A+B,max(A-B,A*B))<<endl;
    
  

  return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = GetNumbersDouble();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var rad = Math.PI * c / 180;
            var area = a * b * Math.Sin(rad) / 2;
            var L = a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(rad));
            var h = b * Math.Sin(rad);
            System.Console.WriteLine(area.ToString("F8"));
            System.Console.WriteLine(L.ToString("F8"));
            System.Console.WriteLine(h.ToString("F8"));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10056