akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <complex>
#include <set>
using namespace std;

using W = double;
using P = complex<W>;
using L = pair<P,P>;
using C = pair<P,W>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const W EPS = (1e-10), pi = acos(-1);

namespace std{
  bool operator < (const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
  bool operator == (const P& a, const P& b){
    return abs(a-b) < EPS;
  }
}

double dot(P a, P b){ return a.X * b.X + a.Y * b.Y;}
W cross(P a, P b){ return a.X * b.Y - a.Y * b.X;}

Poly convex_hull(Poly v){
  int n = v.size(), k = 0;
  sort(v.begin(), v.end(), cmp_y);
  Poly r(2*n);
  for(int i = 0; i < n; i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-2]) < -EPS) k--;
    r[k++] = v[i];
  }
  for(int i = n-2, t = k; i >= 0; i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-2]) < -EPS) k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

int main(){
  int N;
  cin >> N;
  int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1};
  set<P> s;

  vector<P> sq = {{0,0},{1,0},{1,1},{0,1}};
  vector<vector<P>> D(N);
  D[0] = sq;
  for(int i = 1; i < N; ++i){
    int n, d;
    cin >> n >> d;
    vector<P> t = D[n];
    for(auto& p : t)
      p = p+P(dx[d],dy[d]);
    D[i] = t;
  }
  for(int i = 0; i < N; ++i){
    for(auto p : D[i])
      s.insert(p);
  }

  vector<P> ps;
  for(auto p : s)
    ps.push_back(p);
  vector<P> c = convex_hull(ps);

  // for(auto p : c)
  //   fprintf(stderr,"%lld %lld\n",p.X,p.Y);
  
  int v = c.size();
  int l = 0, r = 0, b = 0;
  P d = c[1] - c[0];
  P n(-d.Y,d.X);
  while(dot(d,c[(l+1)%v]-c[0]) >= dot(d,c[l]-c[0])){
    ++l;
    l %= v;
  }
  while(dot(d,c[(r+v-1)%v]-c[0]) <= dot(d,c[r]-c[0])){
    r = (r+v-1)%v;
  }
  while(dot(n,c[(b+1)%v]-c[0]) >= dot(n,c[b]-c[0])){
    b += 1;
    b %= v;
  }
  double ans = 1e18;
  for(int i = 0; i < v; ++i){
    d = c[(i+1)%v] - c[i];
    n = {-d.Y,d.X};
    while(dot(d,c[(l+1)%v]-c[i]) >= dot(d,c[l]-c[i])){
      ++l;
      l %= v;
    }
    while(dot(d,c[(r+1)%v]-c[i]) <= dot(d,c[r]-c[i])){
      ++r;
      r %= v;
    }
    while(dot(n,c[(b+1)%v]-c[i]) >= dot(n,c[b]-c[i])){
      ++b;
      b %= v;
    }
    // fprintf(stderr,"--------------------\n");
    // fprintf(stderr,"top    : (%lld,%lld) - (%lld,%lld)\n",c[(i+1)%v].X,c[(i+1)%v].Y,c[i].X,c[i].Y);
    // fprintf(stderr,"left   : (%lld,%lld)\n",c[l].X,c[l].Y);
    // fprintf(stderr,"bottom : (%lld,%lld)\n",c[b].X,c[b].Y);
    // fprintf(stderr,"right  : (%lld,%lld)\n",c[r].X,c[r].Y);
    // fprintf(stderr,"area   : %lld\n",dot(n,c[b]-c[i])*(dot(d,c[l]-c[i])-dot(d,c[r]-c[i]))/norm(d));
    // fprintf(stderr,"--------------------\n");
    ans = min(ans,dot(n,c[b]-c[i])*(dot(d,c[l]-c[i])-dot(d,c[r]-c[i]))/norm(d));
  }
  printf("%.12f\n",ans);
}



Measured memory_bytes: 38084
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int a,b;cin>>a>>b;
  string aa,bb;
  for(int i=1;i<=b;i++)
    aa.push_back(a+'0');
  for(int i=1;i<=a;i++)
    bb.push_back(b+'0');

  cout<<min(aa,bb)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,p,a[200010],mp[10010];
string s;

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>p;
	cin>>s;
	if(p==2){
		int sum=0;
		for(int i=0;i<s.size();i++){
			if((s[i]-'0')%2==0) sum+=i+1;
		}
		cout<<sum<<endl;
	}
	else if(p==5){
		int sum=0;
		for(int i=0;i<s.size();i++){
			if((s[i]-'0')%5==0) sum+=i+1;
		}
		cout<<sum<<endl;
	}
	else{
		for(int i=0;i<s.size();i++){
			a[i+1]=(a[i]*10+s[i]-'0')%p;
		}
		int sum=0,t=1;
		for(int i=s.size();i>=0;i--){
			sum+=mp[(a[i]*t)%p];
			mp[(a[i]*t)%p]++;
			t=(t*10)%p;
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 2196
#include<stdio.h>
 
int main(){
	int input;
	scanf("%d", &input);
	getchar();

    char s[101];
	scanf("%s", s);

	if(input % 2 == 1){
		puts("No");
		return 0;
	}
	input /= 2;
	for(int i = 0; i < input; i++){
		if(s[i] != s [i + input]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 1624
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mp make_pair
#define fr first
#define sc second
#define M 200005
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};

ll f(ll a, ll b){
    if(a==0) return -b;
    else return (b/a)*a*2 + f(b%a,a);
}

int main()
{
    ios::sync_with_stdio(false);
    ll n,x; cin>>n>>x;
    cout<<n+f(n-x,x)<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
    ll n, m;
    cin >> n >> m;
    if(2*n >= m) return !printf("%lld\n", m/2);
    else return !printf("%lld\n", n + (m-2*n)/4);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx;
    int h = ty - sy;
    string s = "";
    s += string(h, 'U');
    s += string(w, 'R');
    s += string(h, 'D');
    s += string(w, 'L');

    s += string(1, 'L');
    s += string(h + 1, 'U');
    s += string(w + 1, 'R');
    s += string(1, 'D');

    s += string(1, 'R');
    s += string(h + 1, 'D');
    s += string(w + 1, 'L');
    s += string(1, 'U');

    cout << s << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;


#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;




int main(){
	int N,K;	cin >> N >> K;
	
	cout << (N - K + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    if(a.size() != b.size()){
        cout << (a.size() > b.size() ? "GREATER" : "LESS");
        return 0;
    }
    for(unsigned int i = 0; i < a.size(); i++){
        if(a[i] > b[i]){
            cout << "GREATER" << endl;
            return 0;
        }
        if(a[i] < b[i]){
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = []
nb = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        an.append(b)
    elif b == N:
        nb.append(a)

print('IMPOSSIBLE' if len(set(an)&set(nb))==0 else 'POSSIBLE')

Measured memory_bytes: 21816
from collections import Counter
mod = 10**9 + 7
n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
l = 0
for i in range(1,n+1):
	if C[i] > 1:
		l = i
		p = []
		for j in range(n+1):
			if A[j] == l:
				p.append(j)
				if len(p) > 1:
					break
		break
	if l:
		break

t = 1
d = 1
for k in range(n+1):

	t *= (n+1-k)%mod
	t %= mod
	t *= pow(k+1,mod-2,mod)
	t %= mod
	if not k:
		print(n)
	elif k <= n+p[0]-p[1]:
		d *= (n+p[0]-p[1]-k+1)%mod
		d %= mod
		d *= pow(k,mod-2,mod)
		d %= mod
		print((t - d)%mod)
	else:
		print(t%mod)



Measured memory_bytes: 19936
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: i64,
        g: [(i64, i64); n-1],
    }
    let mut ans: i64 = (n+1) * n * (n+1) / 2 - n * (n+1) * (2*n+1) / 6;
    for e in g {
        let e0 = std::cmp::min(e.0, e.1);
        let e1 = std::cmp::max(e.0, e.1);
        ans -= e0 * (n -e1+1)
    }
    println!("{}", ans);
}

Measured memory_bytes: 5136
int main()
{
    int a,b,x,r;
    scanf("%d%d",&a, &b);
    
    if (a<b){
        x=a;
        a=b;
        b=x;
    }
    
    
    while (b>0){
        r=a%b;
        a=b;
        b=r;
    }
    
    printf("%d\n",a);
  
        
 return 0;
}

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

int main() {
    int a, b;
    char op;
    
    while(true) {
        cin >> a >> op >> b;
        if(op == '?')
            break;
        switch(op) {
            case '+' : cout << a + b << endl; break;
            case '-' : cout << a - b << endl; break;
            case '*' : cout << a * b << endl; break;
            case '/' : cout << a / b << endl; break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int max = Math.max(A,B);
		int min = Math.min(A, B);
		int ans = Math.max(max + max - 1, max + min );
		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a; cin >> a;
  ll b1, b0;
  scanf("%lld.%lld", &b1, &b0);
  ll b01, b001;
  b001=b0%10;
  b01=b0/10;
  ll x=a*b1;
  ll y=a*b01*10+a*b001;
  y/=100;
  x+=y;
  cout << x;
  return 0;
}


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

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c) {
  vector<vector<ll>> dp(N + 1, vector<ll>(3));
  vector<vector<ll>> A(3);
  A[0] = a;
  A[1] = b;
  A[2] = c;
  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k)
      continue;
    chmax(dp[i + 1][k], dp[i][j] + A[k][i]);
  }
  ll ans = 0;
  rep(j, 3) chmax(ans, dp[N][j]);
  ANS(ans);
}

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


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;
string s;

int main(){
  getline(cin,s);
  deque<ii> ans;
  deque<int> deq;
  rep(i,s.size()){
    if( s[i] == '\\' ) deq.push_back(i);
    else if( s[i] == '/' && !deq.empty() ){
      int sp = deq.back(); deq.pop_back();
      int area = i - sp;
      while( !ans.empty() && sp <= ans.back().first ){
	area += ans.back().second;
	ans.pop_back();
      }
      ans.push_back(ii(sp,area));
    }
  }
  int sum = 0;
  rep(i,ans.size()) sum += ans[i].second;
  cout << sum << endl << (int)ans.size();
  rep(i,ans.size())cout << ' ' << ans[i].second; puts("");
  return 0;
}



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, b, c,  d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << (e - a <= k ? "Yay!" : ":(") << "\n";
    return 0;
}

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

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

    int sum = pow(10, 9);
    for (int i = 1; i <= N / 2; i++) {
        int A = i;
        int B = N - i;

        int sumA = 0;
        int sumB = 0;

        while (A != 0) {
            sumA += A % 10;
            A /= 10;
        }
        while (B != 0) {
            sumA += B % 10;
            B /= 10;
        }

        sum = min(sum, sumA + sumB);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int ds[N];
  for (int i = 0; i < N; i++) {
    cin >> ds[i];
  }
  int sum = 0;
  for (int a = 0; a < N; a++) {
    for (int b = a + 1; b < N; b++) {
      sum += (ds[a] * ds[b]);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3572
#h = list(map(int, input().split()))
#r = int(input())
#n, d = map(int, input().split())

n = int(input())
a = []

for i in range(n):
    a.append(int(input()))

sa = sorted(a)
sa.reverse()

if sa[0] == sa[1]:
    for i in a:
        print(sa[0])
else:
    for i in a:
        if i == sa[0]:
            print(sa[1])
        else:
            print(sa[0])



Measured memory_bytes: 14068
N, *A = map(int, open(0).read().split())
cnt = 0
tgt = sum(A) // 2
for i in range(N):
    cnt += A[i]
    if cnt >= tgt:
        break
        
a1 = abs(cnt - sum(A[i + 1:]))
a2 = abs((cnt - A[i]) - sum(A[i:]))
print(min(a1, a2))


Measured memory_bytes: 102024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  ll x;
  cin >> x;
  ll res = x / 11;
  res *= 2;
  if((x % 11) > 6)res += 2;
  else if((x % 11) != 0)res++;
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

int main(){
    int n, x, y, m, ii;
    char d;

    while(cin >> n, n){
        vector<pair<int, int>> diamond;
        int sx = 10, sy = 10;
        int rest = n;
        for(int i=0; i<n; i++){
            cin >> x >> y;
            diamond.push_back(make_pair(x, y));
        }
        cin >> m;
        for(int i=0; i<m; i++){
            cin >> d >> ii;
            int dx = 0, dy = 0;
            switch(d){
                case 'N':
                    dy = 1;
                    break;
                case 'E':
                    dx = 1;
                    break;
                case 'S':
                    dy = -1;
                    break;
                case 'W':
                    dx = -1;
                    break;
            }
            for(int i=0; i<ii; i++){
                if(dx != 0) sx += dx;
                if(dy != 0) sy += dy;
                for(auto itr = diamond.begin(); itr != diamond.end();){
                    if(itr->first == sx && itr->second == sy){
                        rest--;
                        itr = diamond.erase(itr);
                    }else{
                        itr++;
                    }
                }
            }
            //cout << "order: " << d << " " << ii << " rest: " << rest << " sx: " << sx << " sy: " << sy << endl;
        }
        if(rest <= 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>

int main(void)
{
	using namespace std;
	int data[3];
	for(int i=0; i<3; i++){
		cin >> data[i];
	}

	sort(data, data+3);
	cout << data[0] << " " << data[1] << " " << data[2] << endl;

	return 0;

}

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

int h, w, ans;
char ch;
bool visited[1010][1010];
queue<ii> q;

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

	cin >> h >> w;
	ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> ch; 
			if (ch == '#') {
				visited[i][j] = 1;
				q.push(make_pair(i, j));
			}
		}
	}
	
	while (!q.empty()) {
	  int size = q.size();
	  for (int i = 0; i < size; i++) {
	  	auto p = q.front();
	  	int x = p.first, y = p.second;
	  	visited[x][y] = true;
	  	q.pop();
	  	if (x > 0 && !visited[x - 1][y]) {visited[x - 1][y] = 1; q.push(mp(x - 1, y));}
	  	if (x < h - 1 && !visited[x + 1][y]){visited[x + 1][y] = 1; q.push(mp(x + 1, y));}
	  	if (y > 0 && !visited[x][y - 1]){visited[x][y - 1] = 1; q.push(mp(x, y - 1));}
	  	if (y < w - 1 && !visited[x][y + 1]){visited[x][y + 1] = 1; q.push(mp(x, y + 1));}
	  }
	  ans++; 
	}
	if (ans == 0) cout << ans << endl;
	else cout << ans - 1 << endl;
 
}	



  //cout << "Case #" << caseNum++ << ": " << ans << endl;  


Measured memory_bytes: 9488
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	ll x;
	cin >> x;

	ll sum = 0;
	rep(i, x+1) {
		sum = i*(i + 1) / 2;
		if (sum >= x) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}





Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int, input().split()))
m = 1
if 0 in a:
    print(0)
    sys.exit()
for i in range(n):
    m = m*a[i]
    if m>10**18:
        print(-1)
        sys.exit()

print(m)

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<long long int> divisor(long long int n)
{
  vector<long long int> ret;
  for (long long int i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> div = divisor(N);
  ll ans = 0;
  for (int i = 0; i < div.size(); i++)
  {
    ll m = (N / div[i]) - 1;
    if (m <= 0)
      continue;
    if (N / m == N % m)
      ans += m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vector<int> a(n+1);rep(i,n)cin >> a[i];
    a[n] = 0;
    vector<int> b(n);rep(i,n)cin >> b[i];
    vector<int> c(n-1);rep(i,n-1)cin >> c[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        int number = a[i] - 1;
        ans += b[number];
        if(a[i] + 1 == a[i+1])ans += c[a[i] - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  while(true){
  int n,m;
  bool finish[501],friender[501];
  int a[10000],b[10000];
  cin>>n>>m;
  if(n==0&m==0)
    break;
  for(int i=0;i<n+1;i++){
    finish[i]=false;
    friender[i]=false;
  }
  for(int i=0;i<m;i++){
    cin >>a[i]>>b[i];
  }
  for(int i=0;i<m;i++){
    if(a[i]==1){
      finish[b[i]]=true;
    friender[b[i]]=true;
    }
    if(b[i]==1){
      finish[a[i]]=true;
    friender[a[i]]=true;
  }
  }
  for(int i=0;i<m;i++){
    if(friender[a[i]]==true)
      finish[b[i]]=true;
    if(friender[b[i]]==true)
      finish[a[i]]=true;
  }

    int get=0;
    for(int i=2;i<n+1;i++){
      if(finish[i]==true){
	get++;
      }
    }
  cout<<get<<endl ;
  }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n;
    cin >>n;
    map<string,int> mm;
    rep(i,n) {
        string s;
        cin >>s;
        mm[s]++;
    }
    cin >>n;
    rep(i,n) {
        string s;
        cin >>s;
        mm[s]--;
    }

    int ans=0;
    for(auto item:mm) ans=max(ans,item.second);
    out(ans)
    
}


Measured memory_bytes: 256
<?php
$list = explode(" ",trim(fgets(STDIN)));
if($list[0] < $list[1]){
echo "a < b";
}elseif($list[0] > $list[1]){
echo "a > b";
}elseif($list[0] == $list[1]){
echo "a == b";
}
?>



Measured memory_bytes: 9180
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

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

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

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

  ll l,r;
  std::cin>>l>>r;

  if(r-l+1>=2019){
    std::cout<<0<<"\n";
    return 0;
  }

  ll ans=2020;

  rep(i,l,r+1){
    rep(j,i+1,r+1){
      chmin(ans,i*j%2019);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a, &b, &c);
    if((a<=c && c<=b) || (b<=c && c<=a)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
a=0;b=0;c=0
S=list(input())
N=len(S)
T=S[:]
S.reverse()
#print(S)
#print(T)
if S==T:
  a=1

x=(N-1)//2
y=(N+2)//2
X=S[0:x]
X1=X[:]
X.reverse()
if X==X1:
  b=1
Y=S[y:N]
Y1=Y[:]
Y.reverse()
if Y==Y1:
  c=1
#print(X,X1)
#print(Y,Y1)
if a*b*c==1:
  print("Yes")
else:
  print("No")

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int num=0;
  for(int i=1;i<=n;i++){
    num+=a[i]-1;
  }
  cout<<num<<endl;
}
 

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ant = [a, b, c, d, e]

k = int(input())

first = ant[0]
for i in reversed(range(1, 5)):
	if ant[i] -  first > k:
		print (":(")
		quit()

print ("Yay!")

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

#define ll long long
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf (int)(1e18)
#define ps(x, y) fixed << setprecision(y) << x
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(p) p.begin(), p.end()
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define sz(x) (int)x.size()
#define PI 3.14159265
#define double long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
vector<int> a;
int k;
bool check(int mid)
{
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += (a[i] / mid);
        if ((a[i] % mid) == 0)
        {
            ans--;
        }
    }
    return ans <= k;
}
void solution()
{
    cin >> n >> k;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    int ans = *max_element(all(a));
    int l = 1, r = ans;
    while (l <= r)
    {
        int mid = (l + r) / 2;
        if (check(mid))
        {
            ans = min(ans, mid);
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }
    cout << ans << endl;
    return;
}
int32_t main()
{
    run();
    solution();
    return 0;
}

Measured memory_bytes: 4752
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
sys.setrecursionlimit(10000)
# MOD = 10**9 + 7


def solve(f):
    n = f.read_int()
    a = f.read_int_list()

    ma = -float("inf")
    st = None
    for l in xrange(n):
        s = a[l]
        for r in xrange(l+2, n, 2):
            if a[r] > 0: s += a[r]
        if s > ma:
            ma = s
            st = l

    pro = [1] * st
    a = a[st:]
    while len(a) > 1:
        if len(a) == 2:
            pro.append(2)
            a.pop(1)
        elif len(a) == 3:
            if a[2] > 0:
                pro.append(2)
            else:
                pro.append(3)
                pro.append(2)
            a.pop(2)
            a.pop(1)
        else:
            if a[2] > 0:
                pro.append(2)
                a.pop(0)
                a.pop(0)
            else:
                pro.append(3)
                a.pop(1)
                a.pop(2)

    return "\n".join(map(str, [ma, len(pro)]+pro))


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 4760
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    int a,b;cin>>a>>b;
    string s;cin>>s;
    int n=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='-')n++;
    }
    if(s.size()==a+b+1&&s[a]=='-'&&n==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int m = sc.nextInt();
    int d = sc.nextInt();
    int ans = 0;

    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= d; j++) {
        int d1 = j % 10;
        int d10 = j / 10;
        if ((d1 >= 2) && (d10 >= 2) && ((d1 * d10) == i)) {
          ans++;
        }
      }
    }

    System.out.println(ans);

  }
}


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

int main() {
	set<int>s;
	rep(i, 4) {
		int e; cin >> e;
		s.insert(e);
	}
	puts(s.size() == 2 ? "yes" : "no");
}

Measured memory_bytes: 3096
<?php
// 標準入力から取得
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
 
class SubmitAnswer {
    public static function println($answer = "") {
        echo $answer . PHP_EOL;
    }
}
 
$sc = new Scanner();
$n = $sc->nextInt();
$maxLength = 0;
$sumOfLength = 0;
for($i=0;$i<$n;$i++){
    $array[] = $sc->nextInt();
    if($array[$i] > $maxLength){
        $maxLength = $array[$i];
    }
    $sumOfLength += $array[$i];
}

if($sumOfLength > $maxLength * 2){
    $answer = "Yes";
} else {
    $answer = "No";
}



SubmitAnswer::println("$answer");

Measured memory_bytes: 3828
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var n = fs.nextInt()
    var a = fs.readLongArray(n)
    var sum:Long = 0
    for (i in 0 until a.size) {
        sum += a[i]
    }
    var ans:Long = 0
    for (i in 0..a.size - 2) {
        sum -= a[i]
        ans += ((a[i]%1000000007)*(sum%1000000007))
        ans %= 1000000007
    }
    println(ans)


}

class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 57220
#include <vector> 
#include <map>
#include <queue>
#include <iostream>
#include <iterator>
#define pb push_back 
#define int long long
using namespace std; 

int32_t main() 
{ 
	int n,q,t,s=0; 
	cin>>n; 
	map<int,int> m;
	vector<int> v(n); 
	for(int i=0;i<n;i++)
	{
		cin>>t;
		v.pb(t);
		m[t]+=1;
		s+=t;
	}
	cin>>q;
	int b, c; 
	for (int i = 0; i < q; i++) { 
		cin>>b>>c; 
		if(m[b]!=0)
		{
			m[c]+=m[b];
			if(b<c)
				s+=(c-b)*m[b];
			else
				s-=(b-c)*m[b];
			m[b]=0;
		}
		cout<<s<<"\n";
		
	} 

	

	return 0; 
} 


Measured memory_bytes: 10436
#include<stdio.h>
char m[182];c;E(p){m[p]-49||--m[p]+E(p-1)+E(p+1)+E(p-13)+E(p+13);}main(i){for(;fread(m+13,1,157,stdin)>155;printf("%d\n",c))for(c=0,i=13;i<168;i++)m[i]-49||E(i)+c++;exit(0);}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
ll l,r;
cin>>l>>r;
r=min(r,l+4038);
ll ans=INF;
for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
       ans=min(ans,(i*j)%2019);
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn prime_factor(n: u64) -> std::collections::HashMap<u64, u64> {
    if n < 2 {
        return std::collections::HashMap::new();
    }
    let mut res = std::collections::HashMap::new();
    let mut n = n;
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let c = res.entry(i).or_insert(0);
            *c += 1;
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}

fn solve() {
    input! {
        n: u64,
        av: [u64; n]
    };

    let mut set1 = HashSet::new();
    let mut is_pairwise = true;
    let mut is_setwise = false;
    let mut b = 0;
    for a in av {
        b = b.gcd(&a);
        if b == 1 {
            is_setwise = true;
        }
        for (k, _) in prime_factor(a) {
            if set1.contains(&k) {
                is_pairwise = false;
            }
            set1.insert(k);
        }
    }
    if is_pairwise {
        println!("pairwise coprime");
    } else if is_setwise {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 17348
from heapq import heapify


def resolve():
    '''
    code here
    '''
    import math
    N, K = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]

    def f(x):
        res = 0
        for item in As:
            res += (item-1)//x

        return res

    ng = 0
    ok = max(As)

    while ok - ng > 1:
        mid = int((ng + ok)/2)

        if f(mid) > K:
            ng = mid
        else:
            ok = mid
            
    print(ok)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 32140
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
ans = 0
for i in range(n + 2):
    ans += abs(a[i] - a[i - 1])
# print(ans)
for i in range(1, n + 1):
    temp = ans
    temp -= abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])
    temp += abs(a[i - 1] - a[i + 1])
    print(temp)

Measured memory_bytes: 16028
#include<stdio.h>

int main(){
  int n, y;
  scanf("%d %d", &n, &y);
  
  int x;
  int z = -1;
  for(int i = 0; i <= n && z == -1; i++){
    for(int j = 0; j <= n - i; j++){
      if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
        x = i;
        y = j;
        z = n - i - j;
        break;
      }
    }
  }
  
  if(z == -1){
    x = y = -1;
  }
  
  printf("%d %d %d\n", x, y, z);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,j,n;
char abacus[10][8];

int main(){
	for(i=0;i<10;i++){
		for(j=0;j<8;j++){
			abacus[i][j]='*';
		}
	}
	for(i=0;i<10;i++){
		abacus[i][1-i/5]=' ';
		abacus[i][2]='=';
		abacus[i][3+i%5]=' ';
	}
	while(scanf("%d",&n)!=EOF){
		if(i!=10)printf("\n");
		for(i=0;i<8;i++){
			printf("%c%c%c%c%c\n",abacus[n/10000][i],abacus[(n/1000)%10][i],abacus[(n/100)%10][i],abacus[(n/10)%10][i],abacus[n%10][i]);
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int X;cin>>X;

  int ans;
  for(int t=1;t<=X;t++){
    int temp=t*(t+1)/2;
    if(temp>=X){
      ans=t;
      break;
    }
  }

  cout<<ans<<endl;
  return 0;
}


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

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

    if (n < 2)
    {
        cout << n << endl;
        return 0;
    }
    
    vector<int> a = { 2, 4, 8, 16, 32, 64 };
    for (int i = 5; i >= 0; i--)
    {
        if (a[i] <= n)
        {
            cout << a[i] << endl;
            return 0;
        }
        
    }
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	int i, j, xdis = abs(tx - sx), ydis = abs(ty - sy);
	bool xdir = tx > sx, ydir = ty > sy;

	for (i = 0; i < 4; i++) {
		if (i > 1) {
			if (ydir ^ (i & 1))
				putchar('D');
			else
				putchar('U');
		}

		for (j = 0; j < xdis + i/2; j++) {
			if (xdir ^ (i & 1))
				putchar('R');
			else
				putchar('L');
		}

		for (j = 0; j < ydis + i/2; j++) {
			if (ydir ^ (i & 1))
				putchar('U');
			else
				putchar('D');
		}

		if (i > 1) {
			if (xdir ^ (i & 1))
				putchar('L');
			else
				putchar('R');
		}
	}
	putchar('\n');

	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

struct Matrix {
	int n;
	vector<vector<ll>> element;

	Matrix(int n) : n(n) {
		element.resize(n);
		for (int i = 0; i < n; ++i)
			element[i].resize(n, 0);
	}

	Matrix operator *(Matrix a) {
		assert(n == a.n);
		Matrix res(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				ll tmp = 0;
				for (int k = 0; k < n; ++k) {
					tmp += element[i][k] * a.element[k][j] % mod;
					tmp %= mod;
				}
				res.element[i][j] = tmp;
			}
		}
		return res;
	}

	Matrix pow(ll k) {
		if (k == 0) {
			Matrix res(n);
			for (int i = 0; i < n; ++i)
				res.element[i][i] = 1;
			return res;
		}
		Matrix tmp = pow(k / 2);
		if (k % 2 == 1)
			return tmp * tmp * (*this);
		return tmp * tmp;
	}
};

signed main() {
	ll n; cin >> n;
	ll a, b; cin >> a >> b;
	Matrix M(2);
	M.element[0][0] = 1;
	M.element[0][1] = -1;
	M.element[1][0] = 1;
	M.element[1][1] = 0;
	M = M.pow(n / 2);
	ll res_a = M.element[0][0] * a + M.element[0][1] * b;
	ll res_b = M.element[1][0] * a + M.element[1][1] * b;
	if (n % 2) {
		cout << (res_a - res_b) << " " << res_b << endl;
	}
	else {
		cout << res_a << " " << res_b << endl;
	}
	return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<string>
#include <map>
#include<algorithm>
using namespace std;
int search(string, pair<string, int>*, pair<string, vector<string> >*);
int n;
int m,si;
int main()
{
	
	while (true){
		pair<string, int>p[101];
		pair<string, vector<string> >chan[101];
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> p[i].first >> p[i].second;
		}

		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> chan[i].first >> si;
			for (int i2 = 0; i2 < si; i2++){
				string s;
				cin >> s;
				chan[i].second.push_back(s);
			}
		}
		string s;
		cin >> s;
		int ans = search(s,p,chan);
		cout << ans << endl;
	}
}
int search(string s, pair<string, int>*p, pair<string, vector<string> >*chan){
	int num = 0;
	bool flag = true;
	for (int i = 0; i < m; i++){
		if (chan[i].first == s){
			flag = false;
			for (int i2 = 0; i2 < chan[i].second.size(); i2++){
				num += search(chan[i].second[i2],p,chan);
			}
			break;
		}
	}
	if (!flag){
		int k;
		for (int i = 0; i < n; i++){
			if (p[i].first == s){
				num=min(p[i].second,num);
				break;
			}
		}
	}
	if (flag){
		for (int i = 0; i < n; i++){
			if (p[i].first == s){
				num += p[i].second;
				break;
			}
		}
	}
	return num;
}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100,M=4e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int head[N],nxt[M],to[M],w[M];
int dis[N];bool vis[N];
inline void dfs(int k) {
	vis[k]=true;
	for (int i=head[k];i;i=nxt[i])
		if (!vis[to[i]])
			dis[to[i]]=dis[k]+w[i],dfs(to[i]);
		else
			if (dis[to[i]]!=dis[k]+w[i])
				puts("No"),exit(0);
}
int main()
{
	int n=gi(),m=gi(),i,a,b,tot=0;
	for (i=1;i<=m;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
		w[tot-1]=w[tot]=gi();w[tot]*=-1;
	}
	for (i=1;i<=n;i++)
		if (!vis[i])
			dfs(i);
	puts("Yes");
	return 0;
}


Measured memory_bytes: 6784