akhauriyash/Code-Regression huggingface dataset:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = collections.Counter(il())
    A = sorted(A.items(), key=lambda x: -x[0])
    o, t = 0, 0
    for k, v in A:
        n = v // 2
        if n == 1 and o == 0:
            o = k
        elif n == 1 and t == 0:
            t = k
        elif n > 1:
            o = max(k, o)
            t = max(k, t)

        if t != 0 and o != 0: break

    print(o * t)


if __name__ == '__main__':
    main()


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

long long n, s, d[55];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        for(int j = 0; j < i; j++) s += d[i]*d[j];
    }
    cout << s;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;
ll bit[100010], num;
ll par[100010], sz[100010];
ll n, k, a[200010];
ll uni[200010], top[200010], NUM[500010];
map<ll, ll> mp;


struct edge { ll to, cost; };
ll V;
vector<edge> G[300010];
ll d[300010];

ll root(int x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) { // x��y�̖؂𕹍�
	int rx = root(x); //x�̍���rx
	int ry = root(y); //y�̍���ry
	if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
	par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
}

bool same(int x, int y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> n >> k;
	for(ll i = 1; i <= n; i++)
	{
		cin >> a[i];
	}

	for (int i = n; i >= 1; i--)
	{
		if (mp[a[i]] != 0)
		{
			uni[i] = mp[a[i]];
		}
		mp[a[i]] = i;
	}
	
	top[n + 1] = n + 1;

	for (ll i = n; i >= 1; i--)
	{
		if (uni[i] == 0)
		{
			top[i] = i;
		}
		else
		{
			top[i] = top[uni[i] + 1];
		}
	}

	ll u = top[1], t = 1;
	NUM[1] = top[1];



	while (top[u] != n + 1)
	{
		u = top[mp[a[u]] + 1];
		t++;
		NUM[t] = u;
	}

	

	k %= t;
	if (k == 0) k = t;

	t = NUM[k];
	vector<ll> ans;
	while (t != n + 1)
	{
		if (top[t] == t)
		{
			ans.push_back(a[t]);
			t++;
		}
		else
		{
			t = top[t];
		}
	}

	for (int i = 0; i < ans.size(); i++)
	{
		cout << ans[i];
		if (i == ans.size() - 1)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}

	int www;
	cin >> www;
}


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

using namespace std;

int main()
{
    int R, n;
    int min_R, ans = -1000000000;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> R;

        if (i == 0)
            min_R = R;
        else {
            ans = max(ans, R-min_R);
            min_R = min(min_R, R);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 4/26/2020
 
 16:49-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N];
int N,M;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  int Q;
  cin>>N>>M>>Q;
  const LL Inf=1e12;
  A[0]=B[0]=-Inf;
  REP(i,N) cin>>A[i+1];
  REP(i,M) cin>>B[i+1];
  A[N+1]=B[M+1]=Inf;

  //sort(A,A+N),sort(B,B+M);
  while(Q--) {
    LL x; cin>>x;
    int i=lower_bound(A,A+N+2,x)-A,j=lower_bound(B,B+M+2,x)-B;
    vector<LL> dx1={x-A[i-1],A[i]-x},dx2={x-B[j-1],B[j]-x};
//    dumpc(dx1);
//    dumpc(dx2);
    vector<LL> ds={
      max(dx1[0],dx2[0]),
      max(dx1[1],dx2[1]),
      dx1[0]*2+dx2[1],
      dx2[0]*2+dx1[1],
      dx1[1]*2+dx2[0],
      dx2[1]*2+dx1[0]};
    LL res=*min_element(ALL(ds));
    cout<<res<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 6272
# include <bits/stdc++.h>
# define fi first
# define se second

using namespace std ;

long long N, vc[1000000] ;
long long sum, x;

int main() {
    cin >> N ;
    for( int i = 1 ; i <= N ; i ++ ) {
        cin >> vc[i] ;
        sum += abs(vc[i]-vc[i-1]) ;
    }
    sum += abs(vc[N]-0) ;
    for( int i = 1 ; i <= N ; i ++ ) {
        x = sum ;
        x -= abs( vc[i]-vc[i-1] ) ;
        x -= abs( vc[i]-vc[i+1] ) ;
        x += abs( vc[i-1] - vc[i+1] ) ;
        cout << x << endl;
    }
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
using namespace std;

 int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


      ll n,a,h,sum = 0;
      cin >>h>> n;
        for(ll i = 1; i<=n; i++){
        cin >> a;
         sum +=a;
        }

        if(sum>=h){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 256
x,y = (int(x) for x in input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,iv=(mod+1)/2;
int n,m,dp[5555][5555],sum[5555][5555];
int pw[5555],ipw[5555];
int main()
{
	scanf("%d%d",&n,&m);
	pw[0]=ipw[0]=1;
	for (int i=1;i<=5005;i++) 
	{
		pw[i]=(pw[i-1]+pw[i-1])%mod;
		ipw[i]=1ll*iv*ipw[i-1]%mod;
	}
	for (int i=1;i<=m;i++) dp[0][i]=1;
	for (int i=1;i<=m;i++) sum[0][i]=(1ll*dp[0][i]*i%mod*ipw[i]+sum[0][i-1])%mod;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			dp[i][j]=(1ll*sum[i-1][j-1]*pw[j-1]%mod+1ll*dp[i-1][j]*(j+1))%mod;
		}
		for (int j=1;j<=m;j++)
		{
			sum[i][j]=(1ll*dp[i][j]*j%mod*ipw[j]+sum[i][j-1])%mod;
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 220796
#include <iostream>
#include <vector>
using namespace std;
int main(void){
	int n;
	cin >> n;
	vector<int> arr;
	int x;
	int media=0;
	while(n--){
		cin >> x;
		arr.push_back(x);
		media+=x;
	}
	media/=arr.size();
	int minimo=10000000;
	for(int j=-100;j<=100;j++){
		int casox=0;
		for(int i=0;i<arr.size();i++){
			casox+=(arr[i]-j)*(arr[i]-j);
		}
		minimo = min(minimo,casox);
	}
	cout <<minimo << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ld INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int n;
vector<ld> x, y;
vector<char> d;

ld gets(ld t) {
  ld xmin = INF, xmax = -INF, ymin = INF, ymax = -INF;
  rep(i, n) {
    ld cx = x[i], cy = y[i];
    if (d[i] == 'R') cx += t;
    else if (d[i] == 'L') cx -= t;
    else if (d[i] == 'U') cy += t;
    else cy -= t;
    xmin = min(xmin, cx);
    xmax = max(xmax, cx);
    ymin = min(ymin, cy);
    ymax = max(ymax, cy);
  }
  return (xmax - xmin) * (ymax - ymin);
}

int main() {
  cin >> n;
  x.resize(n);
  y.resize(n);
  d.resize(n);
  rep(i, n) cin >> x[i] >> y[i] >> d[i];

  vector<ld> t = {0};
  vector<ld> c(3, INF);
  rep(i, n) {
    if (d[i] == 'R') c[0] = min(c[0], x[i]);
    else if (d[i] == 'U' || d[i] == 'D') c[1] = min(c[1], x[i]);
    else c[2] = min(c[2], x[i]);
  }
  if (c[0] != INF && c[1] != INF) t.push_back(fabs(c[0] - c[1]));
  if (c[0] != INF && c[2] != INF) t.push_back(fabs(c[0] - c[2]) / 2);
  if (c[1] != INF && c[2] != INF) t.push_back(fabs(c[1] - c[2]));
  rep(i, 3) c[i] = -INF;
  rep(i, n) {
    if (d[i] == 'R') c[0] = max(c[0], x[i]);
    else if (d[i] == 'U' || d[i] == 'D') c[1] = max(c[1], x[i]);
    else c[2] = max(c[2], x[i]);
  }
  if (c[0] != -INF && c[1] != -INF) t.push_back(fabs(c[0] - c[1]));
  if (c[0] != -INF && c[2] != -INF) t.push_back(fabs(c[0] - c[2]) / 2);
  if (c[1] != -INF && c[2] != -INF) t.push_back(fabs(c[1] - c[2]));
  rep(i, 3) c[i] = INF;
  rep(i, n) {
    if (d[i] == 'U') c[0] = min(c[0], y[i]);
    else if (d[i] == 'L' || d[i] == 'R') c[1] = min(c[1], y[i]);
    else c[2] = min(c[2], y[i]);
  }
  if (c[0] != INF && c[1] != INF) t.push_back(fabs(c[0] - c[1]));
  if (c[0] != INF && c[2] != INF) t.push_back(fabs(c[0] - c[2]) / 2);
  if (c[1] != INF && c[2] != INF) t.push_back(fabs(c[1] - c[2]));
  rep(i, 3) c[i] = -INF;
  rep(i, n) {
    if (d[i] == 'U') c[0] = max(c[0], y[i]);
    else if (d[i] == 'L' || d[i] == 'R') c[1] = max(c[1], y[i]);
    else c[2] = max(c[2], y[i]);
  }
  if (c[0] != -INF && c[1] != -INF) t.push_back(fabs(c[0] - c[1]));
  if (c[0] != -INF && c[2] != -INF) t.push_back(fabs(c[0] - c[2]) / 2);
  if (c[1] != -INF && c[2] != -INF) t.push_back(fabs(c[1] - c[2]));
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  ld ans = INF;
  rep(i, t.size()) {
    ans = min(ans, gets(t[i]));
  }
  cout << setprecision(20) << ans << endl;


  


  
  return 0;
}

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

#define mod 1000000007;

int main(void)
{
    int N, i;
    scanf("%d", &N);
    long long A[N], B[N+1], ans=0, sum=0;
    B[0] = 0;
    for(i=0; i<N; i++){
        scanf("%lld", &A[i]);
        B[i+1] = B[i]+A[i];
    }

    for(i=1; i<=N; i++){
        sum = (B[N]-B[i])%mod;
        ans += A[i-1]*sum;
        ans %= mod;
    }

    printf("%lld", ans);

    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  
  int cnt = 0;
  
  for (int i = 1; i < n-1; ++i) {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N , M = map(int,input().split())

checked = [False] * N

edge = [ [] for _ in range(N) ]

for _ in range(M) :
    x , y , z = map(int,input().split())
    edge[x - 1].append(y-1)
    edge[y - 1].append(x-1)

component = 0

for c , check in enumerate(checked) :
    if check :
        continue

    stack = deque([c])
    component += 1

    while stack :
        current = stack.pop()

        if checked[current] :
            continue

        checked[current] = True
        for v in edge[current] :
            if not checked[v] :
                stack.append(v)

print(component)

Measured memory_bytes: 23892
N, A, B = map(int, input().split())
S=0
for i in range(1,N+1):
  s=0
  C=str(i)  #N文字化
  c=list(C)
  
  w=[int(i) for i in c]
  s=sum(w)
  if s>=A and s<=B:
    S +=i
print(S)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
static inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main()
{
    fast_io();

    int a, b;
    cin >> a >> b;
    cout << a * b;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  int T, X;
  cin >> T >> X;

  cout << setprecision(10) << T / (double)X << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.141592653589793
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

double a, b, x;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> x;

  double h = b - (x / (a * a));
  if (2 * h <= b) {
    double ans = atan2(h * 2, a) * 180.0 / PI;
    cout << fixed << setprecision(10) << ans << endl;
  } else {
    h = x / (a * b) * 2;
    double ans = atan2(a * b / h, a) * 180.0 / PI;
    // double ans = 90 * h / a;
    cout << fixed << setprecision(10) << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;


int main(void) {
  string S;
  while(cin >> S, S != "#") {
    int H = 0, W = 0, m[10][10];
    REP(i, 0, S.length()) {
      char c = S[i];
      if(c == '/') {
        H++;
        W = 0;
      } else if('0' <= c && c <= '9') {
        REP(j, 0, c - '0') {
          m[H][W++] = 0;
        }
      } else if(c == 'b') {
        m[H][W++] = 1;
      }
    }
    H++;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    m[a - 1][b - 1] = 0;
    m[c - 1][d - 1] = 1;

    string ans = "";
    REP(i, 0, H) {
      REP(j, 0, W) {
        if(m[i][j] == 0) {
          int cnt = 1;
          while(j + 1 < W && m[i][j + 1] == 0) {
            cnt++;
            j++;
          }
          ans += ('0' + cnt);
        } else {
          ans += 'b';
        }
      }
      if(i + 1 != H) {
        ans += '/';
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
int main() {
    ll ans = -2e18;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int parent[200005];
int length[200005];

void init(){
  for (int i=0; i<200005; i++){
    parent[i]=i;
    length[i]=1;
  }
  return;
}

int getroot(int n){
  while(parent[n]!=n){
    n=parent[n];
  }
  return n;
}

bool samegroup(int n, int m){
  int nroot = getroot(n);
  int mroot = getroot(m);
  return nroot==mroot;
}

void unite(int n, int m){
  if (samegroup(n, m)) return;
  int nroot=getroot(n);
  int mroot=getroot(m);
  if (length[nroot]>length[mroot]){
    parent[mroot]=nroot;
  } else if (length[mroot]>length[nroot]){
    parent[nroot]=mroot;
  } else {
    parent[mroot]=nroot;
    length[nroot]++;
  }
  return;
}

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > K(N);
  int l;
  std::vector<int > L[N];
  for (int i=0; i<N; i++){
    scanf("%d", &K[i]);
    for (int j=0; j<K[i]; j++){
      scanf("%d", &l);
      L[i].push_back(l);
    }
  }
  init();
  for (int i=0; i<N; i++){
    for (int j=0; j<K[i]; j++){
      unite(i, 100001+L[i][j]);
    }
  }
  bool ok = true;
  int parent = getroot(0);
  for (int i=0; i<N; i++){
    if (getroot(i)!=parent){
      ok=false;
      break;
    }
  }
  printf("%s\n", ok?"YES":"NO");
  return 0;
}
 

Measured memory_bytes: 10156
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    n, m = map(int, input().split())

    print((n-1)*(m-1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10432
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
using namespace std;
#define sd(n) scanf("%d",&n)
#define clr(a) memset(a,0,sizeof(a)) 
int a[200];
int main(){
	int N;cin>>N;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	sort(a,a+N);
	cout<<a[N-1]-a[0];
}

Measured memory_bytes: 256
import numpy as np


def solve():
    MOD = 10**9+7
    N = int(input())
    a = np.array(input().split(), int)

    ans = 0
    for i in range(60):
        ones = np.count_nonzero((a >> i) & 1)
        zeros = N - ones
        ans += zeros * ones * 2 ** i
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 62776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ankur
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            if (Math.abs(x - y) % 2 == 0) {
                out.println("Alice");
            } else {
                out.println("Borys");
            }

        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader(InputStream st) {
            this.stream = st;
        }

        public int read() {
            //*-*------clare------

            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        long X = cin.Long();
        var x = cin.ArrayLong(N);

        long ans = Math.Abs(X - x[0]);
        for (int i = 1; i < N; i++) {
            ans = GCD(Math.Abs(X - x[i]), ans);
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
    static long GCD(long a, long b) //a,bの最大公約数
        {
        if (a < b)
            return GCD(b, a);
        while (b != 0) {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 22752
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

// dp[i] := 座標iまでにかかる時刻の最小値
ll x;

void input(){
    cin >> x;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll i = 1;
    ll sm = 0;
    while(x > sm){
        sm += i;
        i++;
    }
    cout << i-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int a, b;
  std::cin >> a >> b;
  if(a>=13) std::cout << b << std::endl;
  else if(a>=6) std::cout << b/2 << std::endl;
  else std::cout << 0 << std::endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
from math import sin,cos,pi
def main():
    #入力
    readline=stdin.readline
    A,B,H,M=map(int,readline().split())

    s=M*pi/30
    t=(H/6)*pi+(M/360)*pi
    x_A=A*sin(t)
    y_A=A*cos(t)

    x_B=B*sin(s)
    y_B=B*cos(s)

    print(((x_A-x_B)**2+(y_A-y_B)**2)**0.5)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int H,W;
    string S[30];
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    cin >> H >> W;
    REP(i,H){
        cin >> S[i];
    }
    int Ans=0;
    REP(sx,W){
        REP(sy,H){
            if(S[sy][sx]=='#')continue;
            int d[30][30]={};
            REP(i,H){
                REP(j,W){
                    d[i][j]=INF;
                }
            }
            d[sy][sx]=0;
            queue<pair<int,int>> Q;
            Q.push({sy,sx});
            
            while(!Q.empty()){
                int Py=Q.front().first;
                int Px=Q.front().second;
                Q.pop();
                REP(i,4){
                    if(0<=Px+dx[i] && Px+dx[i]<W && 0<=Py+dy[i] && Py+dy[i]<H && S[Py+dy[i]][Px+dx[i]]=='.' && d[Py+dy[i]][Px+dx[i]]==INF){
                        Q.push({Py+dy[i],Px+dx[i]});
                        d[Py+dy[i]][Px+dx[i]]=min(d[Py+dy[i]][Px+dx[i]],d[Py][Px]+1);
                    }
                }
            }
            
            REP(i,H){
                REP(j,W){
                    if(S[i][j]=='.'){
                        Ans=max(Ans,d[i][j]);
                    }
                }
            }
            
            /*cout << sx MM sy << endl;
            REP(i,H){
                REP(j,W){
                    cout << d[i][j] << " ";
                }cout << endl;
            }cout << endl;*/
            
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

    ll a, b, c;
    cin>>a>>b>>c;

    if(a+b-c>=0){
        cout<<"No"<<endl;
        return 0;
    }


    ll temp=a*a+b*b+c*c-2*(a*b+b*c+a*c);
    if(temp>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
    int a, n, t=0, h=0;
    char c1[101], c2[101];
    scanf("%d", &n);
    for (;n>0;n--) {
        scanf("%s %s", c1, c2);
        a=strcmp(c1, c2);
        if (a == 0) { t++; h++; }
        else if (a > 0) t+=3;
        else h+=3;
    }
    printf("%d %d\n", t, h);
    return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

vector <vector <int>> gr;

void dfs(int v, int p, int depth, vector <vector <int>>& levels) {
    levels[depth].pb(v);
    for (int u : gr[v])
        if (u != p)
            dfs(u, v, depth + 1, levels);
}

vector <vector <int>> a, b;

bool check(int m) {
    set <int> x, y;
    for (int i = m; i >= 0; i -= 2) {
        for (int j : a[i])
            x.insert(j);
        for (int j : b[i])
            y.insert(j);
    }
    for (int i : x)
        if (y.find(i) == y.end())
            return false;
    return true;
}

bool check1(int m) {
    set <int> x, y;
    for (int i = m; i >= 0; i -= 2) {
        for (int j : a[i])
            x.insert(j);
        if (i - 1 >= 0)
            for (int j : b[i - 1])
                y.insert(j);
    }
    for (int i : x)
        if (y.find(i) == y.end())
            return false;
    return true;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y, x--, y--;
    gr.resize(n);
    forn (i, 1, n) {
        int v, u;
        cin >> v >> u, v--, u--;
        gr[v].pb(u), gr[u].pb(v);
    }
    a.resize(n + 2), b.resize(n + 2);
    dfs(x, -1, 0, a), dfs(y, -1, 0, b);
    /*forn (i, 0, n) {
        cout << i << ":";
        for (int j : a[i])
            cout << j << " ";
        cout << "\n";
    }
    forn (i, 0, n) {
        cout << i << ":";
        for (int j : b[i])
            cout << j << " ";
        cout << "\n";
    }*/
    /*forn (i, 0, n - 1)  {
        cout << i << ": " << check(i) << "\n";
    }
    cout << "\n";
    forn (i, 1, n)
        cout << i << ": " << check1(i) << "\n";*/
    int l = 0, r = n - 1;
    while (r - l > 1) {
        int m = (l + r) / 2;
        if (check(m))
            r = m;
        else
            l = m;
    }
    int ans;
    if (check(r))
        ans = r;
    else
        ans = 0;
    //cout << ans << " ";
    l = 1, r = n - 1;
    while (r - l > 1) {
        int m = (l + r) / 2;
        if (check1(m))
            r = m;
        else
            l = m;
    }
    if (check1(r))
        ans = max(ans, r - 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 22656
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

const int MAX_N = 1009;
int ps[MAX_N];
int N, M;

int solve(){
	ps[N++] = 0;
	vector<int> as;
	for(int i=0; i<N; i++)for(int j=i; j<N; j++)if(ps[i]+ps[j] <= M){
		as.push_back(ps[i] + ps[j]);
	}
	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());

	int ret = 0;
	for(int i=0; i<as.size(); i++){
		ret = max(ret, as[i] + *lower_bound(as.rbegin(), as.rend(), M-as[i], greater<int>()));
	}
	return ret;
}

int main(){
	while(scanf("%d%d",&N,&M),N){
		for(int i=0; i<N; i++){
			scanf("%d",ps+i);
		}
		printf("%d\n",solve());
	}
	return 0;
}

Measured memory_bytes: 0
import sys

if __name__ == "__main__":
    X, N = [int(x) for x in input().split(" ")]
    if N == 0:
        print(X)
        sys.exit(0)
    P = set([int(x) for x in input().split(" ")])
    for diff in range(10 ** 3):
        if (X - diff) not in P:
            print(X - diff)
            sys.exit(0)
        if (X + diff) not in P:
            print(X + diff)
            sys.exit(0)


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll cnt = 0;
	rep(i, 0, N) {
		ll l, r;
		cin >> l >> r;
		cnt += r - l + 1;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N];
int tmp[N];
long long ans[N];
int cnt;
long long pre[N];
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , arr + i);
        tmp[i] = arr[i];
    }
    pre[1] = 1;
    for(int i = 2 ; i <= n ; ++i){
        if(arr[i] > arr[pre[i - 1]]){
            pre[i] = i;
        }
        else{
            pre[i] = pre[i - 1];
        }
    }
    sort(tmp + 1 , tmp + 1 + n);
    reverse(tmp + 1 , tmp + 1 + n);
    cnt = 0;
    tmp[0] = 1e9 + 9;
    int cur = pre[n];
    while(cur){
        int nxt = pre[cur - 1];
        int val = arr[nxt];
        ans[cur] += 1LL * cnt * (arr[cur] - arr[nxt]);
        while(tmp[cnt + 1] > val){
            ans[cur] += tmp[cnt + 1] - val;
            ++cnt;
        }
        cur = nxt;
    }
    for(int i = 1 ; i <= n ; ++i){
        printf("%lld\n" , ans[i]);
    }
}

Measured memory_bytes: 3456
l,r = map(int,input().split())

if r-l >= 672:
    m = 0
else:
    m = 10000000000000000
    cnt_i = 0
    for i in range(l,r+1):
        cnt_j = 0
        if cnt_i == 2019:
            break
        cnt_i += 1
        for j in range(i+1,r+1):
            if cnt_j == 2019:
                break
            cnt_j += 1
            m = min(m,i%2019*j%2019)
print(m)



Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val N = Integer.parseInt(readInputLine())
    
    var abCount = 0
    var aEndCount = 0
    var bStartCount = 0
    var bStartAEndContains = true
    
    // 部分文字列のABが含まれている数 + min(Aで終わる文字列の数, Bで始まる文字列の数)
    // ただし、Aで終わる文字列の数=Bで始まる文字列の数かつ、すべてのAで終わる文字列がBで始まる場合は1減算する必要がある
    for (i in 1..N) {
        var aFlag = false
        val s = readInputLine()
        if (s[0] == 'B') {
            bStartCount++
        }
        if (s[s.length - 1] == 'A') {
            aEndCount++
            if (s[0] != 'B') {
                bStartAEndContains = false
            }
        }
        for (chr in s) {
            if (chr == 'A') {
                aFlag = true
            } else {
                if (chr == 'B' && aFlag) {
                    abCount++
                }
                aFlag = false
            }
        }
    }

    if (aEndCount == 0) {
        println(abCount)
    } else if (aEndCount == bStartCount && bStartAEndContains) {
        println(abCount + aEndCount - 1)
    } else {
        println(abCount + min(aEndCount, bStartCount))
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}

fun min(a: Int, b: Int): Int {
    if (a < b) return a
    else return b
}


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

ll N,K,LR=0,RL=0;
string S;
ll ans=0;
ll m,M;

int main(void){
    cin >> N >> K;
    cin >> S;
    rep(i,N-1){
        if(S[i] == 'L' && S[i+1] =='R') LR++;
        if(S[i] == 'R' && S[i+1] =='L') RL++;
        if(S[i] =='L' && S[i+1] =='L') ans ++;
        if(S[i] =='R' && S[i+1] =='R') ans ++;
    } 
    m = min(LR,RL);
    M = max(LR,RL);
    if(K<=m) cout << ans + 2*K<<endl;
    else if(K < M) cout << ans + m*2 + K-m<<endl;  
    else cout << ans + m*2 + M-m<<endl;
    
}


Measured memory_bytes: 512
l,r=map(int,input().split())
for i in range(l,r+1):
    if (i % 2019) == 0:
        print(0)
        exit()
ans = float('inf')
for i in range(l,r):
    for j in range(i+1, r+1):
        ans = min(ans,(i*j)%2019)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

const double oo = -2.0;
const int maxn = 4000;
double dp[maxn][maxn];
vector<double> v(maxn);

const double EPS = 1e-7;
int N;
double Brute(int i,int j){
	if(i == N && j <= i-j) return 0;
	else if(i == N && j > i-j) return 1;
	double & ans = dp[i][j];
	if(ans + 1 > EPS) return ans;
	return ans = Brute(i+1,j+1)*v[i] + Brute(i+1,j)*(1-v[i]);
}


void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> N;
	for(int i = 0;i<N;++i)
		cin >> v[i];
	
	printf("%.10f",Brute(0,0));
}



int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	for(int i = 1;i<=tt;++i){
		//printf("Case %d: ",i);
		solve();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 129032
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= min(b, a + k - 1); i++) {
        cout << i << endl;
    }
    for (int i = max(a + k, b - k + 1); i <= b; i++) {
        cout << i << endl;
    }
}




Measured memory_bytes: 3592
import sys


def solve(inp):
    (A, B, C, D, E, F) = map(int, inp.readline().split(' '))

    # sum(ABCD) < F
    # sum(AB) * E <= sum(CD)

    max_dense = 0
    result = (A * 100, 0)
    AB = sorted(list(set([a for a in range(0, int(F / 100) + 1, A)] + [b for b in range(0, int(F / 100) + 1, B)])))
    for water in AB:
        if water == 0:
            continue
        c = 0
        while water * 100 + c <= F and c <= water * E:
            d = 0
            while water * 100 + c + d <= F and c + d <= water * E:
                sugar = c + d
                total = water * 100 + sugar
                dense = 100 * sugar / total
                if dense > max_dense:
                    # print("{} {} {} {} : {}".format(total, water * 100, c, d, dense))
                    max_dense = dense
                    result = (total, sugar)
                d += D
            c += C

    return "{} {}".format(result[0], result[1])


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
a=[0]*5
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
time=0
ama=0
  
for i in range(5):
  tmp=10-a[i]%10
  if tmp==10:
    tmp=0
  a[i]+=tmp
  if ama<tmp:
    ama=tmp
    
print(sum(a)-ama)

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    ll x, k, d;
    cin >> x >> k >> d;
    ll diff = abs(x);

    ll times = diff/d;
    times = min(k,times);
//    if(k >= times)
//    {
        ll ans = 0;
        x = abs(x) - times*d;
        ans = abs(x);
        k -= times;
        if(k > 0 and k&1)
        {
            x = abs(x) - d;
            ans = abs(x);
        }

        cout << ans;
//    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007


int main()
{
    int N, H; cin >> N >> H;
    vi a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];
    
    int ans = 0;
    ll sum = 0;
    if (N==1) {
        sum += b[0];
        ans++;
        if (sum < H) {
            ans += ((ll)H - sum + (a[0]-1)) / a[0];
        }
    } else {
        sort(all(a), greater<int>());
        sort(all(b), greater<int>());
    
        for (int i = 0; i < N; i++) {
            if (b[i] > a[0]) {
                sum += b[i];
                ans++;
                if (sum >= H) break;
            } else {
                break;
            }
        }
        if (sum < H) {
            ans += ((ll)H - sum + (a[0]-1)) / a[0];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	ll N,Q,H,S,D;
	cin>>Q>>H>>S>>D>>N;
	ll T=min(D,2*S);
	T=min(T,4*H);
	T=min(T,8*Q);
	ll ans=N/2*T;
	if(N%2==1)
		ans+=min(S,min(4*Q,2*H));
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N;cin>>N;
  cout<<10-(N/200)<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
	vector<int> par,siz;
	UnionFind(int N): par(N), siz(N){
		rep(i, N){
			par[i] = i; siz[i] = 1;
		}
	}
	int root(int x){
		if(par[x]==x) return x;
		else return root(par[x]);
	}
	void unite(int x, int y){
		x=root(x); y=root(y);
		if(x==y) return;
		if(siz[x] < siz[y]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int size(int x){
		return siz[root(x)];
	}
};

int main(){
  int N, M, K; cin >> N >> M >> K;
  UnionFind uf(101010); 
  vector<int> to[101010]; int mai[101010] = {};
  rep(i, M){
    int a, b; cin >> a >> b; a--; b--;
    uf.unite(a, b);
    to[a].push_back(b); to[b].push_back(a);
  }
  vector <int> block[101010];
  rep(i, K){
    int c, d; cin >> c >> d;
    c--; d--;
    block[c].push_back(d);
  }
  rep(i, N){
    bool check[101010] = {};
    for(int j: to[i]){
      check[j] = true;
    }
    for(int j: block[i]){
      if(uf.same(i, j) && !check[j]){
        mai[i]++; mai[j]++;
      }
    }
  }
  rep(i, N){
    int ans = uf.size(i);
    ans-=to[i].size();
    ans--;
    ans-=mai[i];
    cout << ans;
    if(i!=N-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 12280
#Floyd-Warshall Algo


H,W=[int(x) for x in str(input()).split()]
c=[]
for i in range(0,10):
  c.append([int(x) for x in str(input()).split()])

A=[]
A.append([0 for i in range(0,W+1)])
for i in range(1,H+1):
  A.append([0]+[int(x) for x in str(input()).split()])

for k in range(0,10):
  for i in range(0,10):
    for j in range(0,10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])


abc=[]
for i in range(0,10):
  abc.append(c[i][1])

count=0

for i in range(1,H+1):
  for j in range(1,W+1):
    if A[i][j]!=-1:
      count+=abc[A[i][j]]
print(count)

Measured memory_bytes: 3444
#include<iostream>
#include<stdlib.h>
#include<stdio.h>

#define A 0
#define B 1
#define C 3
#define D 4
#define AX 2
#define AY 5
#define X 6
#define Y 7

main(){
  using namespace std;
  float data[1000][8],dt,temp[8];
  int size;
  for(size = 0;size<1000;size++){
    if(!(cin>>data[size][0]))break;
    for(int i=1;i<6;i++)cin>>data[size][i];
    dt = (data[size][A]*data[size][D])-(data[size][B]*data[size][C]);
    for(int i=0;i<6;i++){
      temp[i]=data[size][i];
    }
    data[size][A]=temp[D]/dt;
    data[size][B]=(-1)*temp[B]/dt;
    data[size][C]=(-1)*temp[C]/dt;
    data[size][D]=temp[A]/dt;
    data[size][X]=(data[size][A]*data[size][AX])+(data[size][B]*data[size][AY]);
    data[size][Y]=(data[size][C]*data[size][AX])+(data[size][D]*data[size][AY]);
  }
  for(int i=0;i<size;i++){
    printf("%.3f %.3f\n",data[i][6],data[i][7]);
  }
  
}

Measured memory_bytes: 1240