akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void) {
  int a, b, c, d;

  cin >> a >> b >> c >> d;
  if ( abs(c-a) <= d ) {
    cout << "Yes" << endl;
  } else if ( abs(b-a) <= d && abs(c-b) <= d ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from string import ascii_lowercase

n = int(input())
s = input()

ans = -1
for mid in range(1, n):
    # [0, mid), [mid, n)
    left = set(s[:mid])
    right = set(s[mid:])

    cnt = 0
    for c in ascii_lowercase:
        if c in left and c in right:
            cnt += 1
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int MX = 100005;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int N;

ll ans = 1;
ll fac[MX];

void comp() {
	fac[0] = fac[1] = 1;
	for (int i = 2; i < MX; i++) {
		fac[i] = modMul(fac[i - 1], i);
	}
}

ll combo(ll n, ll k) {
	ll re = 1;
	re = modMul(re, fac[n + k - 1]);
	re = modMul(re, modInv(fac[k]));
	re = modMul(re, modInv(fac[n - 1]));
	return re;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	comp();
    cin >> N;
    vector<int> a(N);
    map<int, int> cnt;
    for (auto& i : a) {
		cin >> i;
		cnt[i]++;
	}
    
    // Make sure vertex 1 is the root
    if (a[0] || cnt[0] > 1) {
		cout << 0;
		return 0;
	}
	
	int lastd = 0, lastc = 1;
	for (auto& i : cnt) {
		if (i.first == 0) continue;
		if (i.first - 1 != lastd) {
			cout << 0;
			return 0;
		} else {
			// cout << lastc << " " << i.second << " " << combo(lastc, i.second) << "\n";
			ans = modMul(ans, modExp(lastc, i.second));
		}
		lastd = i.first;
		lastc = i.second;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main{

	/**
	 * 2つの自然数x,yを入力とし、それらの最大公約数を求めるプログラム
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();

		System.out.println(Gcd(x, y));

	}

	/**
	 * 最大公約数をもとめる
	 * 
	 * @param x
	 *            入力１
	 * @param y
	 *            入力２（x%y)
	 * @return 最大公約数
	 */
	public static int Gcd(int x, int y) {
		if (y > x) {
			int tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		if (y == 0) {
			return x;
		} else {
			return Gcd(y, x % y);
		}
	}
}



Measured memory_bytes: 26208
def addleave(p):
    for i in range(1, n-1):
        if s[i]=="o":
            if p[i]=="S":
                p += "S" if p[i-1]=="S" else "W"
            else:
                p += "W" if p[i-1]=="S" else "S"
        else:
            if p[i]=="S":
                p += "W" if p[i-1]=="S" else "S"
            else:
                p += "S" if p[i-1]=="S" else "W"
    return p
def solve():
    result = addleave("SS")
    if check(result):
        return result
    result = addleave("SW")
    if check(result):
        return result
    result = addleave("WS")
    if check(result):
        return result
    result = addleave("WW")
    if check(result):
        return result
    return -1

def check(res):
    flag = True
    for i in range(n):
        if res[(i + n - 1) % n] == res[(i + n + 1) % n] and res[i]=="S" and s[i]=="o":
            pass
        elif res[(i + n - 1) % n] != res[(i + n + 1) % n] and res[i]=="S" and s[i]=="x":
            pass
        elif res[(i + n - 1) % n] == res[(i + n + 1) % n] and res[i]=="W" and s[i]=="x":
            pass
        elif res[(i + n - 1) % n] != res[(i + n + 1) % n] and res[i]=="W" and s[i]=="o":
            pass
        else:
            flag = False
    return flag
if __name__=="__main__":
    n = int(input())
    s = input()
    print(solve())

Measured memory_bytes: 3572
"""
参考 Xenous
if sortを少なくし、maxで処理
""" 
# 初期入力
N = int(input())
a=[]
b=[]
c=[]
for i in range(N):
    a1,b1,c1 = (int(x) for x in input().split())
    
    a.append(a1)
    b.append(b1)
    c.append(c1)

dp_A = [0]*(N) ;dp_A[0] =a[0] 
dp_B = [0]*(N) ;dp_B[0] =b[0] 
dp_C = [0]*(N) ;dp_C[0] =c[0] 


#
for i in range(0,N-1):
    dp_A[i+1] = max(dp_B[i] + a[i+1] , dp_C[i] + a[i+1])
    dp_B[i+1] = max(dp_A[i] + b[i+1] , dp_C[i] + b[i+1])
    dp_C[i+1] = max(dp_A[i] + c[i+1] , dp_B[i] + c[i+1])
print(max (dp_A[N-1],dp_B[N-1],dp_C[N-1]) )

Measured memory_bytes: 26844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b, k[100005], l[100005];
	double ans = 0;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i] >> l[i];
		ans = max(ans, (double)(l[i] * b) / k[i]);
	}
	cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 3308
#include<stdio.h>
int main(){
int a,b,c,d,e,f,g,n,m,x,y,i,z;
int A[100][100],B[100],ab[100]={0};
scanf("%d %d",&n,&m);
for(x=0;x<n;x++){
for(y=0;y<m;y++){
scanf("%d",&A[x][y]);
}	
}
for(z=0;z<m;z++){
scanf("%d",&B[z]);
}
for(a=0;a<n;a++){
for(b=0;b<m;b++){
ab[a]+=A[a][b]*B[b];
}

}
for(i=0;i<n;i++){
	printf("%d\n",ab[i]);
}
return 0;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Integer> list2 = new ArrayList<>();
    //final List<Long> list3 = new ArrayList<>();

    int s = sc.nextInt();
    int count = 1;
    int n = s;
    int check = 0;
    list.add(s);
    for(int i = 1 ; i < 50000 ; i++){
        if(n % 2 == 0){
            n = n / 2;
            list.add(n);
        }else{
            n = n*3 + 1;
            list.add(n);
        }
        count++;
        Collections.sort(list);
        for(int j = 0 ; j < list.size() - 1; j++){
            if(list.get(j).equals(list.get(j+1))){
                check = 1;
                break;
            }

        }
        if(check == 1){
            break;
        }
    }

    //System.out.println(list);
    System.out.println(count);
    

    

    




    







}
}

Measured memory_bytes: 35744
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
                break
print(cnt)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();
		if(A == 0) {
			System.out.println(0);
			return;
		}
		long p = N / (A + B);
		long d = N % (A + B);
		if(A < d) d = A;
		System.out.println((p * A) + d);
	}
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	char x;
	cin >> x;
	x ++;
	cout << x;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,m,n) for(int a=m;a<n;a++)
#define repn(a,m,n,p) for(int a=m;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

map<string,ll> mpp;
int main(){
	ios::sync_with_stdio(0);
	ll ans=0;
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		//cout<<s<<endl;
		mpp[s]++;
	}
	foreach(i,mpp){
		ll cur=i->second;
		if(cur>1){
			ans+=cur*(cur-1)/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

  int main() {
  double R = 0;
  cin >> R;//現在のレーティング
  double G = 0;
  cin >> G;//したいレーティング
  //(R + ans) / 2 = G
  //R + ans = 2*G
  double ans  = 0;
  ans = 2*G - R;
    cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int d;
    while (cin >> d)
    {
        ll sum = 0;

        for (int i = 1;; ++i)
        {
            if (i * d >= 600)
                break;
            sum += d * (i * d) * (i * d);
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll mini = INF;
  for (int i = 0; i < n; i++) {
    if (i == 0) continue;
    vector<int> b(n);
    vector<int> c(n);
    copy(a.begin(), a.begin() + i, b.begin());
    copy(a.begin() + i, a.end(), c.begin());
    ll dis = abs(accumulate(b.begin(), b.end(), 0) - accumulate(c.begin(), c.end(), 0)); 
    mini = min(mini, dis);
  }

  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	const int mid_A = A[(N - 1) / 2] + A[N / 2];
	const int mid_B = B[(N - 1) / 2] + B[N / 2];

	const int dif = 1 + (N & 1);

	cout << (mid_B - mid_A + dif) / dif << "\n";

	return 0;
}



Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int a[100+5];

int main(){
	int n;
	double sum=0;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		sum += (1.0/a[i]);
	printf("%lf",1/sum);	
	return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int isPrime(int n) {
	int i = 0;
	int ret = 1;
	for (i = 3; i <= sqrt((double)n); i+=2) {
		//printf("n=%d\n", i);
		if ((n%i) == 0) {
			ret = 0;
			break;
		}
	}
	return ret;
}

int main()
{
	int X = 0, i = 0;
	int ans = 0;
	scanf("%d", &X);

	if (X == 2) {
		ans = 2;
	} else {
		if (X%2 == 0) {
			X++;
		}
		for (i = X; i < 100004; i++) {
			if (i%2 == 0) {
				continue;
			}
			//printf("i=%d\n", i);
			if (isPrime(i)) {
				ans = i;
				break;
			}
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=LI()

	X=[-10**10]*(n+1)
	Y=[-10**10]*(n+1)
	X[0]=0
	Y[1]=A[0]
	X[1]=0

	for i in range(2,n+1):
		if i%2==0:
			X[i]=max(Y[i-1],X[i-2]+A[i-1])
		else:
			X[i]=max(X[i-1],X[i-2]+A[i-1])
			Y[i]=Y[i-2]+A[i-1]
	print(X[n])




















if __name__ == "__main__":
	main()


Measured memory_bytes: 100708
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    int sum=0;
    int i=0;
    while(sum<n){
        i++;
        sum+=i;
    }
    FOR(j,1,i+1){
        if(j==sum-n){
            continue;
        }
        cout<<j<<endl;
    }
    return 0;
}

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

int main() {
  int a, b, c, d, x, y;
  cin >> a >>  b >> c >> d;
  x = a + b;
  y = c + d;
  if (x > y) {
    cout << "Left" << endl;
  }
  if (x== y) {
    cout << "Balanced" << endl;
  }
  if (x < y) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: String = sc.read();
    let b: String = sc.read();
    if a.len() < b.len() {
        println!("LESS");
    } else if a.len() > b.len() {
        println!("GREATER");
    } else {
        match a.cmp(&b) {
            Ordering::Less => println!("LESS"),
            Ordering::Equal => println!("EQUAL"),
            Ordering::Greater => println!("GREATER"),
        }
    }
}

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

int main(){

  int a,b,c,temp;
  cin >> a >> b >> c;
  
  if(a>c){
    temp = a;
    a = c;
    c = temp;
  }
  if(a>b){
    temp = a;
    a = b;
    b = temp;
  }
  if(b>c){
      temp = b;
      b = c;
      c = temp;  
  }
  cout << a << " " << b << " " << c << endl;
    
}

Measured memory_bytes: 1164
import collections, math, bisect, re

local = False
if local:
    file = open("input.txt", "r")
    import time

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


if local:
    start=time.time()


N, K = ints()
S = inp()

ans = []

for i in range(1, N+1):
    if i == K:
        ans.append(S[i-1].lower())
    else:
        ans.append(S[i-1])

print("".join(ans))




if local:
    fin = (time.time()-start)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 38256
a,b=['light fly', 'fly', 'bantam', 'feather', 'light', 'light welter','welter', 'light middle', 'middle', 'light heavy', 'heavy'],[48, 51, 54, 57, 60, 64, 69, 75, 81, 91]
while 1:
    try:
        c=float(input())
    except:break
    for i in range(10):
        if c<=b[i]:
            print(a[i])
            break
    else: print(a[10])


Measured memory_bytes: 5580
import java.util.Scanner;

public class Main {
	int L;
	long[] Ai = null;

	long[] totalLeftAi1 = null;
	long[] totalLeftAi2 = null;
	long[] totalRightAi2 = null;
	
	private void prepare() {
		Scanner in = new Scanner(System.in);
		L = in.nextInt();
		Ai = new long[L+1];
		for (int i=1; i<=L; i++) {
			Ai[i] = in.nextInt();
		}
		in.close();

		long totalLeftAi = 0;
		totalLeftAi1 = new long[L+1];
		totalLeftAi2 = new long[L+1];
		totalLeftAi1[0] = 0;
		totalLeftAi2[0] = 0;
		for (int i=1; i<=L; i++) {
			totalLeftAi += Ai[i];
			if (Ai[i] < 1) {
				totalLeftAi1[i] = totalLeftAi1[i-1] + (1 - Ai[i]);
			} else {
				totalLeftAi1[i] = totalLeftAi1[i-1] + (Ai[i] + 1) % 2;
			}
			if (Ai[i] < 2) {
				totalLeftAi2[i] = totalLeftAi2[i-1] + (2 - Ai[i]);
			} else {
				totalLeftAi2[i] = totalLeftAi2[i-1] + (Ai[i] % 2);
			}
			if (totalLeftAi2[i] > totalLeftAi) {
				totalLeftAi2[i] = totalLeftAi;
			}
		}
		
		long totalRightAi = 0;
		totalRightAi2 = new long[L+2];
		totalRightAi2[L+1] = 0;
		
		for (int i=L; i>=1; i--) {
			totalRightAi += Ai[i];
			if (Ai[i] < 2) {
				totalRightAi2[i] = totalRightAi2[i+1] + (2 - Ai[i]);
			} else {
				totalRightAi2[i] = totalRightAi2[i+1] + (Ai[i] % 2);
			}
			if (totalRightAi2[i] > totalRightAi) {
				totalRightAi2[i] = totalRightAi;
			}
		}
		totalRightAi2[0] = totalRightAi2[1];
		
	}
	
	public long solve() {
		prepare();
		long min = Long.MAX_VALUE;

		long leftMin = Long.MAX_VALUE;
		
		long rightMins[] = new long[L+1];
		for (int right=L; right>=0; right--) {
			long rightScore = totalLeftAi1[right] + totalRightAi2[right+1];
			if (right==L) {
				rightMins[right] = rightScore;
			} else {
				if (rightMins[right+1] < rightScore) {
					rightMins[right] = rightMins[right+1];
				} else {
					rightMins[right] = rightScore;
				}
			}
		}
		
		for (int left=0; left<=L; left++) {
			long leftScore = totalLeftAi2[left] - totalLeftAi1[left];

			if (leftScore < leftMin) {
				leftMin = leftScore;
			} else {
				continue;
			}
			
			long rightScore = rightMins[left];
			
			if (min > leftScore + rightScore) {
				min = leftScore + rightScore;
			}
		}
		return min;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		System.out.println(main.solve());
	}
}

Measured memory_bytes: 94320
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
string read_s() {
	string s;
	scanf("%s", &s);
	return s;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
	bool b[200], c[200];
signed main() {
	int h = read(), w = read();
	char a[200][200];
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			a[i][j] = s[j];
			if (a[i][j] == '#') {
				b[i] = 1;
				c[j] = 1;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (!b[i]) continue;
		for (int j = 0; j < w; j++) {
			if (c[j]) {
				cout << a[i][j];
			}
		}
		cout << endl;
	}

}

Measured memory_bytes: 256
import sys
from typing import Callable, NoReturn, Tuple


def main() -> NoReturn:
    scan: Callable[[], str] = sys.stdin.readline

    n, m = map(int, scan().rstrip().split())
    a: Tuple[int] = tuple(int(a_i) for a_i in scan().rstrip().split())

    playtime: int = n - sum(a)
    if playtime < 0:
        playtime = -1

    print(playtime)


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >> n;
  int a[4] = {};
  rep(i,n) {
    string s;
    cin >> s;
    if(s == "AC") a[0]++;
    if(s == "WA") a[1]++;
    if(s == "TLE") a[2]++;
    if(s == "RE") a[3]++;
  }
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int MOD=1000000007;

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

  vector<bitset<21>> a(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int t;
      cin >> t;
      if(t==1) a[i].set(j);
    }
  } 

  vector<int> r(1<<N);

  r[0]=1;

  for(int i=1;i<=N;i++){
    for(int j=1;j<(1<<N);j++){
      if(__builtin_popcount(j)!=i) continue;
      for(int k=0;k<N;k++){
        if(a[i-1].test(k) && ((j>>k)&1)){
          r[j]+=r[j^(1<<k)];
          r[j]%=MOD;
        }
      }
      //cout << r[i][j] << " ";
    }
    //cout << endl;
  }

  cout << (r[(1<<N)-1]+MOD)%MOD << endl;
  return 0;
}


Measured memory_bytes: 8448
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
using namespace std;
string a,b,c;
int main()
{
	cin>>a>>b>>c;
	int lena=a.length();
	int lenb=b.length();
	if(b[0]==a[lena-1]&&(c[0]==b[lenb-1]))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }   
    bool f = true;
    int cnt = 0;
    int m = sum / (n * (n + 1) / 2);
    if(sum % (n * (n + 1) / 2) != 0) f = false;
    rep(i, 0, n){
        int tmp = a[i] - a[(i - 1 + n) % n];
        if((m - tmp) % n != 0 || (m - tmp) < 0){
            f = false;
        }else{
            cnt += (m - tmp) / n;
        }
    }
    if(cnt != m) f = false;
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////
const int MAX_V = 10 , MAX_M = 45;
vector<vector<ll>> dp(MAX_V,vector<ll>(MAX_V,INF));
//d[[i][j]:i,j間の最短経路
int E,V=0; //頂点数

void wf(){
	rep(k,0,V)
		rep(i,0,V)
			rep(j,0,V)
				dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k][j] );
}

//入力
void make(){
	rep(i,0,E){
		int u,v,c;
		cin>>u>>v>>c;
		dp[u][v] = c;
		dp[v][u] = c;
		V = max(V,u+1);
		V = max(V,v+1);
	}
}

int main(){
	while( cin >> E ){
		if( !E )
			break;

		rep(i,0,MAX_V){
			rep(j,0,MAX_V){
				if( i == j ) dp[i][j] = 0;
				else dp[i][j] = INF;
			}
		}

		V = 0;
		make();
		wf();

		ll ans = INF;
		int idx = 0;
		rep(i,0,V){
			ll sum = 0;
			rep(j,0,V){
				if( dp[i][j] != INF)
					sum += dp[i][j];
			}
			if( ans > sum ){
				ans = sum;
				idx = i;
			}
		}
		cout << idx << " " << ans << endl;
	}
	ret 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M;
vpint G[100000];
int dist[100000];
signed main(){
    cin>>N>>M;
    vpint lis;
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].pb(pint(b,c));
        if(b==N-1)lis.pb(pint(a,c));
    }

    fill_n(dist,N,INF);
    dist[0]=0;
    priority_queue<pint,vector<pint>,greater<pint>>que;
    que.push(pint(0,0));
    while(que.size()){
        int v,c;
        tie(c,v)=que.top();
        que.pop();
        if(dist[v]<c)continue;
        if(v==N-1)continue;
        for(auto &e:G[v]){
            if(e.se<c)continue;
            if(dist[e.fi]<=e.se)continue;
            dist[e.fi]=e.se;
            que.push(pint(dist[e.fi],e.fi));
        }
    }

    int ma=-1;
    for(auto &e:lis){
        if(dist[e.fi]>e.se)continue;
        chmax(ma,e.se);
    }
    cout<<ma<<endl;
    return 0;
}

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

using namespace std;
int main(){
     int n;
     cin>>n;
     string s;
     cin>>s;
     string s1="";
     int i=0;
     while(s[i]!='\0'){
            int t;
        if(s[i]+n>'Z'){
            t='Z'-s[i];
            s1+='A'+(n-t)-1;
        }
        else{
            s1+=s[i]+n;
        }
     i++;
     }
    cout<<s1<<endl;

 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int cnt = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if ((L[i] == L[j]) || (L[j] == L[k]) || (L[k] == L[i])) {
					continue;
				}
				if ((L[i] + L[j]) <= L[k]) {
					continue;
				}
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
#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;
  map<int, int> a;
  REP(i, n){
    int d;
    cin >> d;
    if(a.find(d) == a.end()){
      if(a.size() > 3){
        cout << "No" << endl;
        return 0;
      }
      a[d] = 1;
    }else{
      ++a[d];
    }
  }
  bool res = false;
  if(a.size() == 1){
    res = a[0] == n;
  }else if(a.size() == 2){
    res = a[0] * 3 == n;
  }else{
    auto it = a.begin();
    if(it->second * 3 == n){
      int p = it->first;
      ++it;
      if(it->second * 3 == n){
        int q = it->first;
        ++it;
        res = it->second * 3 == n && (p ^ q) == it->first;
      }
    }
  }
  cout << (res ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  int m;
  cin >> m;
  
  int n;
  n = m%10;
  
  
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    cout << "hon" << endl;
  }
  
  if (n == 0 || n == 1 || n == 6 || n == 8){
    cout << "pon" << endl;
  }
  
  if (n == 3){
    cout << "bon" << endl;
  }
}


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


using namespace std;

int main(){
    int N; cin >> N;
    char c;
    cin >> c;
    vector<char> S = {c};

    for(int i=1; i<N; i++){
        cin >> c;
        if(S.at(S.size() - 1) == c){
            continue;
        }
        else{
            S.push_back(c);
        }
    }
    
    cout << S.size() << endl;
    
}



Measured memory_bytes: 512
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

ll N, A;
ll solve ( int eat_num )
{
	ll l = 0, r = N+1;
	while( r - l > 1 ){
		ll mid = (l+r)/2;
		
		ll tmp = 1;
		rep(i, eat_num+1){
			if( double(tmp)*mid >= N ) tmp = N;
			else tmp *= mid;
		}
		
		if( tmp >= N ) r = mid;
		else l = mid;
	}

	ll m = l+1;
	int num = 0;
	rep(i, eat_num+1){
		ll tmp = 1;
		rep(j, i){
			if( double(tmp)*(m-1) >= N ) tmp = N;
			else tmp *= m-1;
		}
		reep(j, i, eat_num+1){
			if( double(tmp)*m >= N ) tmp = N;
			else tmp *= m;
		}

		if( tmp >= N ){
			num = i;
		}
	}

	ll y = 1, z = 0;
	rep(i, eat_num+1){
		if( i < num ){
			z += m-1;
		}
		else{
			z += m;
		}
	}

	return eat_num*A + z;
}

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

	ll ans = N;
	reep(i, 1, 50){
		ll tmp = solve(i);
		ans = min(ans,tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int MAX = 1e2 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'
    int n, a, b; cin >> n >> a >> b;
    if(a > b)cout << 0 << endl;
    else if(n == 1 && a != b)cout << 0 << endl;
    else cout << (i64)(b - a) * (n - 2) + 1 << endl;
}



Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll dp[1000005];
int main(){
	std::ios::sync_with_stdio(false);
	ll n,val,val1,i,j;
	cin>>n;
	rep(i,n+10){
		dp[i]=inf;
	}	
	dp[1]=1;
	val=6;
	val1=9;
	rep(j,10){
		if(val<=n){
			dp[val]=1;
		}
		if(val1<=n){
			dp[val1]=1;
		}
		val*=6LL;
		val1*=9LL;
	}
	f(i,2,n+1){
		dp[i]=min(dp[i],dp[i-1]+1);
		val=6;
		val1=9;
		rep(j,10){
			if(i-val>=1){
			   dp[i]=min(dp[i],dp[i-val]+1);
			}
			if(i-val1>=1){
				dp[i]=min(dp[i],dp[i-val1]+1);
			}
			val*=6LL;
			val1*=9LL;
		}
	}
	cout<<dp[n]<<endl;
} 
	

Measured memory_bytes: 1024
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ 0 for row in range( l ) ] for row in range( n ) ]

output = []
for i in range( n ):
	for j in range( l ):
		for k in range( m ):
			matrixC[i][j] += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( matrixC[i][j] ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

Measured memory_bytes: 5812
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[101010]={};
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	sort(a,a+n);
	int ans1=a[n-1];
	if(ans1%2==0){
		int tmp=ans1/2;
		int it=lower_bound(a,a+n,tmp)-a;
		if(it>0){
			if(tmp-a[it-1]<=a[it]-tmp)it=it-1;
		}

		cout<<ans1<<" "<<a[it]<<endl;
	}else{
		int tmp=ans1/2;
		int tmp2=(ans1+1)/2;
		int it=lower_bound(a,a+n,tmp)-a;
		int it2=lower_bound(a,a+n,tmp2)-a;
		if(a[it]==tmp&&a[it2]==tmp2){
			cout<<ans1<<" "<<a[it]<<endl;
		}else if(a[it]!=tmp&&a[it2]==tmp2){
			cout<<ans1<<" "<<a[it2]<<endl;
		}else if(a[it]==tmp&&a[it2]!=tmp2){
			cout<<ans1<<" "<<a[it]<<endl;
		}else if(a[it]!=tmp&&a[it2]!=tmp2){
			if(it>0)if(tmp-a[it-1]<=a[it]-tmp2)it=it-1;
			cout<<ans1<<" "<<a[it]<<endl;
		}
	}
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N;
set<int> st;

//解法
void solve() {

	int inp;
	rep(i, N) {
		cin >> inp;
		st.insert(inp);
	}
	cout << st.size();

	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int n,a,b;

   scanf("%d",&n);
   for (a=1;a<=9;a++){
      for(b=1; b<=9; b++)
         if(a*b==n){
            printf("Yes\n");
         return 0;
         }
   }

   printf("No\n");
   return 0;
}


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

int main(void) {
	int n[4];
	cin >> n[0] >> n[1] >> n[2] >> n[3];
	if (n[1] < n[2] || n[3] < n[0])
		cout << 0 << endl;
	else {
		sort(n, n + 4);
		cout << n[2] - n[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding utf-8 -*-
N, M = (int(_) for _ in input().split())

A = [[0]]*N
for i in range(N):
    A[i] = [int(_) for _ in input().split()]

A.sort(key=lambda x: x[0])

food = A.pop(0)
K = food.pop(0)

for i in range(N - 1):
    K = A[i].pop(0)
    food = list(set(food) & set(A[i]))

print(len(food))


Measured memory_bytes: 3064
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<Vec<usize>> = (0..2)
        .map(|_| {
            (0..n)
                .map(|_| itr.next().unwrap().parse().unwrap())
                .collect()
        })
        .collect();

    let mut ans = 0;
    for i in 0..n {
        let mut tmp = 0;
        let mut k = 0;
        for j in 0..n {
            tmp += a[k][j];
            if i == j {
                tmp += a[k + 1][j];
                k += 1;
            }
        }
        ans = std::cmp::max(ans, tmp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
 string arr;
 const int  mod = 1e9+7;
long long dp[10005][101][2];
 
int d;
 
long long back(int in, long sum, bool flag  ){
	
 	if(in> arr.size()) {  if(sum%d==0) return 1; else return 0; }
 	
 	if(dp[in][sum][flag]!=-1)	return dp[in][sum][flag];
 	
 	 int limit = 9;
 	 if(!flag) limit=  arr[in-1]-'0';
 	
	long long res=0;
	
 	for(int i=0; i<=limit; ++i){
 	res+= (back(in+1, (sum+i)%d , flag || i<limit)%mod);		
 	res%=mod;
 	}
 	return dp[in][sum][flag] = res;
 }
 
 
 
int main() {
	

	cin>>arr;
	cin>>d;
	memset(dp, -1, sizeof dp);
	 
	 long long c= back(1,0,false);
	c-=1; c+=mod;
	 c%=mod;
	 cout<<  c <<'\n'; 
	return 0;
}


Measured memory_bytes: 20224
from itertools import accumulate

n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
acc = [0] + list(accumulate(v))
for l in range(min(n, k) + 1):
    for r in range(min(n, k) - l + 1):
        minus = sorted(v[:l] + v[n - r:])
        bag = acc[l] - acc[0] + acc[n] - acc[n - r]
        bag -= sum(vi for vi in minus[:k - l - r] if vi < 0)
        ans = max(ans, bag)
print(ans)


Measured memory_bytes: 74188
#include "stdio.h"
#include "malloc.h"

#define max(X, Y) ((X) < (Y) ? (Y) : (X))

int main()
{
    long long N,temp;
    scanf("%lld",&N);
    temp = 0;
    long long *arr = malloc(N*3*sizeof(long long));
    long long *dp = malloc(N*3*sizeof(long long));
    while(temp<N)
    {
        scanf("%lld %lld %lld",arr+temp*3+0,arr+temp*3+1,arr+temp*3+2);
        *(dp+temp*3+0) = 0;
        *(dp+temp*3+1) = 0;
        *(dp+temp*3+2) = 0;
        temp++;
    }

    *(dp+0*3+0) = *(arr+0*3+0);
    *(dp+0*3+1) = *(arr+0*3+1);
    *(dp+0*3+2) = *(arr+0*3+2);

    for(int i=1;i<N;i++)
    {
        *(dp+i*3+0) = max(*(dp+(i-1)*3+1)+*(arr+i*3+0),*(dp+(i-1)*3+2)+*(arr+i*3+0));
        *(dp+i*3+1) = max(*(dp+(i-1)*3+0)+*(arr+i*3+1),*(dp+(i-1)*3+2)+*(arr+i*3+1));
        *(dp+i*3+2) = max(*(dp+(i-1)*3+0)+*(arr+i*3+2),*(dp+(i-1)*3+1)+*(arr+i*3+2));
    }

    if(*(dp+(N-1)*3+0)>=*(dp+(N-1)*3+1))
    {
        if(*(dp+(N-1)*3+0)>=*(dp+(N-1)*3+2))
            printf("%lld",*(dp+(N-1)*3+0));
        else
        {
            printf("%lld",*(dp+(N-1)*3+2));
        }
    }
    else
    {
        if(*(dp+(N-1)*3+1)>=*(dp+(N-1)*3+2))
            printf("%lld",*(dp+(N-1)*3+1));
        else
        {
            printf("%lld",*(dp+(N-1)*3+2));
        }
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    if (N == 1)
    {
        putout("Yes");
        putout(2);
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    ll k = -1;
    Loop(i, 1, N + 1)
    {
        ll x = i;
        if (x * (x - 1) == 2 * N)
        {
            k = x;
            break;
        }
    }
    if (k == -1)
    {
        putout("No");
        return 0;
    }
    putout("Yes");
    putout(k);
    vector<vector<ll>> S(k);
    ll ind = 0;
    ll now = 1;
    ll kaisu = k - 1;
    loop(i, k - 1)
    {
        loop(j, kaisu)
        {
            S[ind].push_back(now);
            S[ind + 1 + j].push_back(now);
            now++;
        }
        ind++;
        kaisu--;
    }
    loop(i, k)
    {
        cout << k - 1 << " ";
        loop(j, k - 1)
        {
            cout << S[i][j];
            if (j != k - 2)
                cout << " ";
            else
                putout("");
        }
    }
    return 0;
}
//にゃーん(悲痛な叫び)

Measured memory_bytes: 5028