akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, head = "", tail = "";
    cin >> s;
    bool order = true;
    int q;
    cin >> q;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1) order = !order;
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(order) head += c;
                else tail += c;
            }
            else{
                if(!order) head += c;
                else tail += c;
            }
        }
    }
    if(order){
        for(int i = head.size()-1; i >= 0; --i) cout << head[i];
    }
    else{
        for(int i = tail.size()-1; i >= 0; --i) cout << tail[i];
    }
    if(order) cout << s;
    else{
        for(int i = s.size()-1; i >= 0; --i) cout << s[i];
    }
    if(order){
        for(int i = 0; i < tail.size(); ++i) cout << tail[i];
    }
    else{
        for(int i = 0; i < head.size(); ++i) cout << head[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1104
#include <stdio.h>

int main(void)
{
	int n, d, ans;
	scanf("%d %d", &n, &d);
	if (n % (d * 2 + 1) == 0)
		ans = n / (d * 2 + 1);
	else
		ans = n / (d * 2 + 1) + 1;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int sx, sy, gx, gy;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> sx >> sy >> gx >> gy;
    string ans = "";
    rep(i, sx, gx) ans += "R";
    rep(i, sy, gy) ans += "U";
    rep(i, sx, gx) ans += "L";
    rep(i, sy, gy) ans += "D";

    ans += "D";
    rep(i, sx, gx+1) ans += "R";
    rep(i, sy, gy+1) ans += "U";
    ans += "LU";
    rep(i, sx, gx+1) ans += "L";
    rep(i, sy, gy+1) ans += "D";
    ans += "R";
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
ans=0
c=0
tmp=10**9
for a in A:
    if a<0:
        c+=1
    ans+=abs(a)
    tmp=min(tmp,abs(a))
if c%2==0:
    print(ans)
else:
    print(ans-tmp*2)

Measured memory_bytes: 14284
public class
Main
{
  public void
  run (
    final java.util.Scanner sc,
    final java.io.PrintStream out
    )
  {
    Pair[ ] heap;
    int[ ]  paeh;
    int n, q;
    int i;
    
    n = sc.nextInt ( );
    q = sc.nextInt ( );

    heap = new Pair[ n ];
    paeh = new int[ n + 1 ];
    for ( i = 1; i <= n; ++i )
    {
      paeh[ i ] = i - 1;
      heap[ paeh[ i ] ] = new Pair ( i, 0 );
    }

    for ( ; q > 0; --q )
    {
      int a, v, b;

      a = sc.nextInt ( );
      v = sc.nextInt ( );
      b = heap[ heap.length - 1 ].index;

      swap ( heap, paeh[ a ], paeh[ b ] );
      swap ( paeh, a, heap[ paeh[ a ] ].index );
      for ( ; ; )
      {
        if ( paeh[ b ] * 2 + 2 < heap.length - 1
          && heap[ paeh[ b ] * 2 + 2 ].compareTo ( heap[ paeh[ b ] * 2 + 1 ] ) < 0
          && heap[ paeh[ b ] * 2 + 2 ].compareTo ( heap[ paeh[ b ] ] ) < 0 )
        {
          swap ( heap, paeh[ b ], paeh[ b ] * 2 + 2 );
          swap ( paeh, b, heap[ paeh[ b ] ].index );
        }
        else if ( paeh[ b ] * 2 + 1 < heap.length - 1
               && heap[ paeh[ b ] * 2 + 1 ].compareTo ( heap[ paeh[ b ] ] ) < 0 )
        {
          swap ( heap, paeh[ b ], paeh[ b ] * 2 + 1 );
          swap ( paeh, b, heap[ paeh[ b ] ].index );
        }
        else break ;
      }
      heap[ paeh[ a ] ].value += v;
      for ( ; ; )
      {
        if ( paeh[ a ] > 0
          && heap[ paeh[ a ] ].compareTo ( heap[ ( paeh[ a ] - 1 ) / 2 ] ) < 0 )
        {
          swap ( heap, paeh[ a ], ( paeh[ a ] - 1 ) / 2 );
          swap ( paeh, a, heap[ paeh[ a ] ].index );
        }
        else break ;
      }
      System.out.println ( heap[ 0 ].index + " " + heap[ 0 ].value );
    }
  }

  private static void
  swap (
    int[ ] a,
    int i,
    int j
    )
  {
    final int t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
  }

  private static <T> void
  swap (
    T[ ] a,
    int i,
    int j
    )
  {
    final T t = a[ i ];
    a[ i ] = a[ j ];
    a[ j ] = t;
  }

  public static void
  main (
    final String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ), System.out );
  }

  private class
  Pair
  implements Comparable<Pair>
  {
    public final int index;
    public       int value;

    public
    Pair (
      final int index,
      final int value
      )
    {
      this.index = index;
      this.value = value;
    }

    public int
    compareTo (
      final Pair obj
      )
    {
      if ( this.value == obj.value )
        return ( this.index - obj.index );
      return ( obj.value - this.value );
    }
  }
}

Measured memory_bytes: 137092
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

bool cat(string &s,int &p){
	if(s[p]=='m'){
		p++;
		bool x=cat(s,p);
		if(!x)return false;
		if(s[p]!='e')return false;
		p++;
		bool y=cat(s,p);
		if(!y)return false;
		if(s[p]!='w')return false;
		p++;
		return true;
	}else{
		return true;
	}
}

int main(){
	string s;
	cin>>s;
	int p=0;
	bool ok=cat(s,p);
	cout<<(ok&&p==s.size()?"Cat":"Rabbit")<<endl;

}

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

int main(){
  long long n,k;
  std::cin >> n>>k;
  std::vector<long long> a(n,0);

  long long tot=0;
  rep(i,n){
    std::cin >> a[i];
    if(i<k)tot+=a[i];
  }


  for (int i = k; i < n; i++) {
    if(a[i-k] >= a[i])std::cout << "No" << '\n';
    else std::cout << "Yes" << '\n';
  }

  return 0;
}


Measured memory_bytes: 4836
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
ll inv(ll a){
  return powmod(a, MOD-2);
}
int main()
{
	int n, m;
  cin>>n>>m;
  string s;
  cin>>s;
  int ct[3001];
  ct[0]=0;
  for(int i=1; i<=n; i++){
    ct[i]=ct[i-1];
    if(s[i-1]=='1') ct[i]++;
  }
  vector<P> v[3001];
  int t=0;
  for(int i=0; i<m; i++){
    int l0, r0;
    cin>>l0>>r0;
    if(v[t].empty() || (v[t].back()).second<r0){
      if(!v[t].empty() && (v[t].back()).second<l0) t++;
      v[t].push_back(P(l0, r0));
    }
  }
  ll f[3001], invf[3001];
  f[0]=1;
  for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
  invf[n]=inv(f[n]);
  for(ll i=n-1; i>=0; i--){
    invf[i]=invf[i+1]*(i+1)%MOD;
  }
  ll ans=1;
  for(int k=0; k<=t; k++){
    if(v[k].size()==1){
      int l0=v[k][0].first, r0=v[k][0].second;
      ans=ans*f[r0-l0+1]%MOD*invf[ct[r0]-ct[l0-1]]%MOD*invf[r0-l0+1-ct[r0]+ct[l0-1]]%MOD;
      continue;
    }
    ll dp[2][3001]={};
    int l0=v[k][0].first, r0=v[k][0].second, l1=v[k][1].first;
    for(int i=max(0, ct[r0]-ct[l0-1]-l1+l0); i<=min(ct[r0]-ct[l0-1], r0-l1+1); i++){
      int c0=ct[r0]-ct[l0-1]-i, d0=l1-l0;
      dp[0][i]=f[d0]*invf[c0]%MOD*invf[d0-c0]%MOD;
    }
    for(int i=1; i<=v[k].size()-2; i++){
      int l0=v[k][i].first, r0=v[k][i].second, l1=v[k][i+1].first, rp=v[k][i-1].second;
      int c0=ct[r0]-ct[rp];
      for(int j=0; j<=n; j++){
        dp[i%2][j]=0;
        if(j>r0-l1+1) continue;
        for(int p=max(0, j-c0); p<=min(n, j-c0+l1-l0); p++){
          dp[i%2][j]+=(dp[(i+1)%2][p]*f[l1-l0]%MOD*invf[c0+p-j]%MOD*invf[l1-l0-c0-p+j]%MOD);
          dp[i%2][j]%=MOD;
        }
      }
    }
    int par=v[k].size()%2;
    r0=(v[k].back()).second, l0=(v[k].back()).first;
    int rp=v[k][v[k].size()-2].second;
    int c=ct[r0]-ct[rp];
    ll ans1=0;
    for(int i=0; i<=r0-l0+1-c; i++){
      ans1+=(dp[par][i]*f[r0-l0+1]%MOD*invf[i+c]%MOD*invf[r0-l0+1-i-c]%MOD);
      ans1%=MOD;
    }
    ans=ans*ans1%MOD;
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio;
	cin.tie(NULL);
	cout.tie(NULL);
	long long int i,j,k,l,m,n;
	cin>>n;
	long long int a[n],dp[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<dp[n-1];
	return 0;
	
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
struct rect { int x1, x2, y1, y2; };
int invx[1 << 20],invy[1<<20];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main(){
	int n;
	while (cin >> n, n) {
		vector<int> vx, vy;
		rect a[50];
		rep(i, n) {
			int x1, x2, y1, y2;
			cin >> x1 >> y2 >> x2 >> y1;
			a[i] = { x1,x2,y1,y2 };
			vx.push_back(x1);
			vx.push_back(x2);
			vy.push_back(y1);
			vy.push_back(y2);
		}
		sort(vx.begin(), vx.end());
		sort(vy.begin(), vy.end());
		int cnt = 0;
		rep(i, (int)vx.size()) {
			if (i - 1 >= 0 && vx[i] == vx[i - 1])continue;
			invx[vx[i]] = cnt; cnt++;
		}
		cnt = 0;
		rep(i, (int)vy.size()) {
			if (i - 1 >= 0 && vy[i] == vy[i - 1])continue;
			invy[vy[i]] = cnt; cnt++;
		}
		rep(i, n) {
			a[i].x1 = invx[a[i].x1];
			a[i].x2 = invx[a[i].x2];
			a[i].y1 = invy[a[i].y1];
			a[i].y2 = invy[a[i].y2];
		}
		ll mp[200][200];
		rep(i, 200) {
			rep(j, 200) {
				mp[i][j] = 0;
			}
		}
		rep(i, n) {
			Rep(j, a[i].x1, a[i].x2) {
				Rep(k, a[i].y1, a[i].y2) {
					mp[j+50][k+50] += (ll)1 << i;
				}
			}
		}
		int out = 0;
		bool used[200][200];
		rep(i, 200) {
			rep(j, 200) {
				used[i][j] = false;
			}
		}
		rep(i, 200) {
			rep(j, 200) {
				if (used[i][j])continue;
				queue<P> q;
				used[i][j] = true;
				q.push({ i,j });
				while (!q.empty()) {
					P x = q.front(); q.pop();
					rep(k, 4) {
						int nx = x.first + dx[k];
						int ny = x.second + dy[k];
						if (nx < 0 || ny < 0 || nx == 200 || ny == 200)continue;
						if (used[nx][ny])continue;
						if (mp[x.first][x.second] != mp[nx][ny])continue;
						used[nx][ny] = true;
						q.push({ nx,ny });
					}
				}
				out++;
			}
		}
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 11200
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}	 
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, q;
int s[100100];

int main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	int ans = 0;
	cin >> q;
	rep(i, q) {
		int num;
		cin >> num;
		int lb = 0, ub = n;
		while (ub - lb >= 1) {
			int mid = (ub + lb) / 2;
			if (s[mid] == num) {
				ans++;
				break;
			}
			else if (s[mid] > num)ub = mid;
			else lb = mid + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3392
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
//#include <numeric>
#define ll long long
using namespace std;


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



int main(){

int N;cin>>N;
vector <int> A(0); //0 index
for(int i=0;i<N;i++){
  int a;cin>>a;
  A.push_back(a);
}

for(;;){
if(A.size()==2){
  break;
}

int g=gcd(A[0],A[1]);
A.erase(A.begin());
A.erase(A.begin());
A.push_back(g);
}

cout<<gcd(A[0],A[1])<<endl;



  return 0;
}
  


Measured memory_bytes: 892
import math

K = int(input())
ans = 0
for a in list(range(1, K+1)):
    for b in list(range(1, a+1)):
        for c in list(range(1, b+1)):
            a_b = math.gcd(a, b)
            a_b_c = math.gcd(a_b, c)
            if a == b == c:
                ans = ans + a_b_c
            elif a != b and b != c and a != c:
                ans = ans + a_b_c * 6
            else:
                ans = ans + a_b_c * 3

print(ans)

Measured memory_bytes: 9228
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve(){
    int k;
    cin >> k;
    vector<ll> a(k);
    for (int i=0; i<k; i++) {
        cin >> a.at(i);
    }
    ll maxi = 2, mini = 2;
    for (auto iter=a.rbegin(); iter!=a.rend(); iter++) {
        ll tmp = *iter;
        ll cnt = maxi / tmp - mini / tmp + (mini%tmp == 0);
        if (cnt == 0) {
            cout << -1 << "\n";
            return;
        } else {
            if (mini%tmp == 0) {
                maxi = (maxi/tmp) * tmp + tmp - 1;
            } else {
                mini = (mini/tmp + 1) * tmp;
                maxi = (maxi/tmp) * tmp + tmp - 1;
            }
        }
    }

    cout << mini << " " << maxi << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    rep(i, 0, n) cin >> S.at(i);
    
    rep(i,0,n){
        sort(all(S.at(i)));
        S.at(i) += " ";
    }
    rep(i, 0, 26){
        priority_queue<int, vector<int>, greater<int>> q;
        char x = 'a' + i;
        rep(j,0,n){
            int count = 0;
            while(S.at(j).at(0) == x){
                S.at(j) = S.at(j).substr(1);
                count++;
            }
            q.push(count);
        }
        int z = q.top();
        rep(i, 0, z){
            cout << x;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int taste = 0;
    for (int i = 1; i <= N; ++i) {
        taste += L + i - 1;
    }

    int ans = 0;
    int min_diff = 1000000000;

    for (int j = 1; j <= N; ++j) {
        int t = 0;
        for (int i = 1; i <= N; ++i) {
            if (i == j) {
                continue;
            }

            t += L + i - 1;
        }

        int diff = abs(t - taste);
        if (diff < min_diff) {
            ans = t;
            min_diff = diff;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll n,k,x[110];
  cin>>n>>k;
  rep(i,n)cin>>x[i];
  ll ans=0;
  rep(i,n){
    ans+=min(x[i],abs(k-x[i]));
  }
  cout<<ans*2<<endl;

  return 0;
}


Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){
    int i,x,n;
    cin >> x;
    n = x;
    cout << x << ":";
    for(i=2;i*i<=x;i++){
        while(n%i==0){
            cout << " " << i;
            n /= i;
        }
    }
    if(n!=1) cout << " " << n;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const int MOD = 1000000007;
ll dp[101][4][4][4] = {0};
 
bool ng(int a, int b, int c) {
  return (a == 1 && b == 2 && c == 3);
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  dp[0][0][0][0] = 1;
  // T = 0, A = 1, G = 2, C = 3
  for (int i = 0; i < N; i++) {
    for (int a = 0; a < 4; a++) {
      for (int b = 0; b < 4; b++) {
        for (int c = 0; c < 4; c++) {
          for (int d = 0; d < 4; d++) {
            if (ng(b, c, d) || ng(c, b, d) || ng(b, d, c)) continue;//AGC,GAC,ACG
            if (ng(a, c, d) || ng(a, b, d)) continue;
            dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % MOD;//不味くなければ足す
          }
        }
      }
    }
  }
  ll res = 0;
  for (int a = 0; a < 4; a++) {
    for (int b = 0; b < 4; b++) {
      for (int c = 0; c < 4; c++) {
        res = (res + dp[N][a][b][c]) % MOD;
      }
    }
  }
  cout << res << '\n';
  return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll n; cin >> n;
    ll ans = 0;
    for (ll i = 1; i * i < n; i++) {
        if ((n - i) % i == 0 && i < (n - i) / i) ans += (n - i) / i;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll x;
  cin >> x;

  vector<ll> a;
  a.push_back(5);
  a.push_back(4);
  a.push_back(3);
  a.push_back(2);
  a.push_back(1);

  ll ans = 0;
  for (ll i = 0; i < a.size(); ++i) {
    ll n = x % 100;
    if (n == 0) {
      ans = 1;
      break;
    }

    ll w = n / a[i];
    x -= (100+a[i]) * w;
    if (x < 0) {
      break;
    }
    if (x % 100 == 0) {
      ans = 1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
import math
import statistics
import itertools
from collections import deque
N=int(input())

ans_lis =[0]*10000000


nn=math.sqrt(N)
n=int(nn)
#per_lis=itertools.permutations(list(range(1,4)))
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            tmp=0
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            ans_lis[tmp-1]+=1
for g in range(N):
    print(ans_lis[g])
            





Measured memory_bytes: 152584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

  rep(i, ty-sy) cout << 'U';
  rep(i, tx-sx) cout << 'R';
  rep(i, ty-sy) cout << 'D';
  rep(i, tx-sx+1) cout << 'L';

  rep(i, ty-sy+1) cout << 'U';
  rep(i, tx-sx+1) cout << 'R';
  cout << "DR";
  rep(i, ty-sy+1) cout << 'D';
  rep(i, tx-sx+1) cout << 'L';
  cout << 'U';

  return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
hl = list(map(int, input().split()))
ll = [t-h*0.006-a for h in hl]
ans = 1
dd = 1000000000
for i in range(n):
    if ll[i] >= 0 and ll[i] < dd:
        ans = i+1
        dd = ll[i]
    elif ll[i] < 0 and -ll[i] < dd:
        ans = i+1
        dd = -ll[i]
    else:
        pass

print(ans)


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

int main() {
  int A, B;
  double tax_a = 0.08, tax_b = 0.10;
  cin >> A >> B;
  
  int ans = -1, x = 0;
  while (1) {
    int a = x * tax_a; // 小数点切り捨て
    int b = x * tax_b;

    if (a == A && b == B) {
      ans = x;
      break;
    }
    if (b > B) break;
    x++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int n2,m2;
int a,b;
int fie[1001][1001];
string str=".<>^v";

void print(){
	printf("YES\n");
	for(int i=0;i<n2;i++){
		for(int j=0;j<m2;j++){
			cout << str[fie[i][j]];
		}
		printf("\n");
	}
}

void solve(){
	//printf("%d %d\n",n,m);
	if(n%2==0 && m%2==0){
		int po=n*m/4;
		int ua=(a/2)+a%2;
		int ub=(b/2)+b%2;
		if(po>=ua+ub){
			int x=0,y=0;
			while(a>0){
				fie[y][x]=1;
				fie[y][x+1]=2;
				a--;
				if(a>0){
					fie[y+1][x]=1;
					fie[y+1][x+1]=2;
				}
				a--;
				x+=2;
				if(x==m){
					x=0;
					y+=2;
				}
			}
			while(b>0){
				fie[y][x]=3;
				fie[y+1][x]=4;
				b--;
				if(b>0){
					fie[y][x+1]=3;
					fie[y+1][x+1]=4;
				}
				b--;
				x+=2;
				if(x==m){
					x=0;
					y+=2;
				}
			}
			print();
			return;
		}else{
			puts("NO");
			return;
		}
	}
	if(n%2==1 && m%2==0){
		for(int i=0;i<m;i+=2){
			if(a==0)break;
			fie[n-1][i]=1;
			fie[n-1][i+1]=2;
			a--;
		}
		n--;
		solve();
	}
	if(n%2==0 && m%2==1){
		for(int i=0;i<n;i+=2){
			if(b==0)break;
			fie[i][m-1]=3;
			fie[i+1][m-1]=4;
			b--;
		}
		m--;
		solve();
	}
	if(n%2==1 && m%2==1){
		if((m-1)*n/2<a || (n-1)*m/2<b){
			puts("NO");
		}else{
			if((n*m-1)!=(a+b)*2 || ((m-1)*n/2-a)%2==0){
				for(int i=0;i<m-1;i+=2){
					if(a==0)break;
					fie[n-1][i]=1;
					fie[n-1][i+1]=2;
					a--;
				}
				for(int i=0;i<n-1;i+=2){
					if(b==0)break;
					fie[i][m-1]=3;
					fie[i+1][m-1]=4;
					b--;
				}
				m--;
				n--;
				solve();
			}else{
				fie[n-3][m-3]=1;
				fie[n-3][m-2]=2;
				fie[n-1][m-2]=1;
				fie[n-1][m-1]=2;
				fie[n-3][m-1]=3;
				fie[n-2][m-1]=4;
				fie[n-2][m-3]=3;
				fie[n-1][m-3]=4;
				a-=2;
				b-=2;
				for(int i=0;i<m-3;i+=2){
					if(a==0)break;
					fie[n-1][i]=1;
					fie[n-1][i+1]=2;
					a--;
				}
				for(int i=0;i<n-3;i+=2){
					if(b==0)break;
					fie[i][m-1]=3;
					fie[i+1][m-1]=4;
					b--;
				}
				if(n-3<=a){
					for(int i=0;i<n-3;i++){
						fie[i][m-3]=1;
						fie[i][m-2]=2;
						a--;
					}
					n--;
					m-=3;
				}else{
					for(int i=0;i<m-3;i++){
						fie[n-3][i]=3;
						fie[n-2][i]=4;
						b--;
					}
					n-=3;
					m--;
				}
				solve();
			}
		}
	}
}

int main(void){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	n2=n;
	m2=m;
	if(n*m<(a+b)*2){
		puts("NO");
		return 0;
	}
	solve();
	

	return 0;
}

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


ll lcm(ll a, ll b){
  return a / __gcd(a,b) *b;
}

int main(){
  ll a, b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string A,B;
	cin >> A >> B;
	int N =A.length();
	bool all0 =true;
	for(int i =0; i < N; i++) if(B[i] != '0') all0 =false;
	if(all0) {
		for(int i =0; i < N; i++) if(A[i] != '0') {
			cout << "-1\n";
			return 0;
		}
		cout << "0\n";
		return 0;
	}
	vector<int> dl(N,N), dr(N,N);
	for(int i =0; i < N; i++) if(B[i] == '1') {
		for(int j =0; j < N; j++) {
			if(j != 0 && B[(i+j)%N] == '1') break;
			dl[(i+j)%N] =min(dl[(i+j)%N],j);
		}
		for(int j =0; j < N; j++) {
			if(j != 0 && B[(i+N-j)%N] == '1') break;
			dr[(i+N-j)%N] =min(dr[(i+N-j)%N],j);
		}
	}
	int ans =10*N;
	for(int i =0; i < N; i++) {
		int dif =0, minr =10*N;
		vector< pair<int,int> > V;
		for(int j =0; j < N; j++) if(A[(i+j)%N] != B[j]) {
			dif++;
			if(dr[j] > i) V.push_back(make_pair(dl[j],dr[j]-i));
		}
		sort(begin(V),end(V));
		vector<int> rmax(V.size()+1,0);
		for(int j =(int)V.size()-1; j >= 0; j--) rmax[j] =max(rmax[j+1],V[j].ss);
		minr =rmax[0];
		for(int j =0; j < (int)V.size(); j++) minr =min(minr,rmax[j+1]+V[j].ff);
		ans =min(ans,dif+i+2*minr);
	}
	for(int i =0; i < N; i++) {
		int dif =0, minr =10*N;
		vector< pair<int,int> > V;
		for(int j =0; j < N; j++) if(A[(j+N-i)%N] != B[j]) {
			dif++;
			if(dl[j] > i) V.push_back(make_pair(dl[j]-i,dr[j]));
		}
		sort(begin(V),end(V));
		vector<int> rmax(V.size()+1,0);
		for(int j =(int)V.size()-1; j >= 0; j--) rmax[j] =max(rmax[j+1],V[j].ss);
		minr =rmax[0];
		for(int j =0; j < (int)V.size(); j++) minr =min(minr,rmax[j+1]+V[j].ff);
		ans =min(ans,dif+i+2*minr);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////

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

int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll g=0;
    rep(i,0,n-1)g=gcd(g,a[i]);
    if(g!=1){
        cout<<"not coprime";return 0;
    }
    set<ll>s;
    rep(i,0,n-1){
        vector<ll>v;
        for(ll j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                v.pb(j);
                while(a[i]%j==0){
                    a[i]/=j;
                }
            }
        }
        if(a[i]!=1)v.pb(a[i]);
        for(auto x:v){
            if(s.find(x)!=s.end()){
                cout<<"setwise coprime"<<endl;return 0;
            }
            s.insert(x);
        }
    }
    cout<<"pairwise coprime"<<endl;
    
    
    return 0;
}


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

int main() {
    int x;
    cin >> x;
    int max = 0;

    if(x == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 1; i <= x; i++){
        for(int j = 2; j <= x; j++){
            if(pow(i, j) > max && pow(i, j) <= x){
                max = pow(i, j);
            }
        }
    }
    cout << max << endl;
    return 0;
    
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 12 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001];
int kotae[100001], C;
char d[100001];
void sagasu(int P, int D) {
	if (!kotae[P]) kotae[P] = C;
	if (d[P] < D) {
		d[P] = D;
		for (int p = he[P]; p; p = ne[p]) {
			sagasu(to[p], D - 1);
		}
	}
}

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


	int N, M, Q;
	N = getint();
	M = getint();
	for (int i = 1; i < 2 * M; i++) {
		int a = getint(), b = getint();
		to[i] = a;
		ne[i] = he[b];
		he[b] = i++;
		to[i] = b;
		ne[i] = he[a];
		he[a] = i;
	}
	Q = getint();
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		v[i] = getint();
		d[i] = getint();
		c[i] = getint();
	}
	for (int i = Q - 1; i >= 0; i--) {
		C = c[i];
		sagasu(v[i], d[i]);
	}
	rep1(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
    ll n,mx=LONG_MIN,mn=LONG_MAX,maxi=LONG_MIN,mini=LONG_MAX;
    cin >> n;
    
    for(int i=0;i<n;++i)
    {
        int a,b;
        cin >> a >> b;
        if(a+b>mx)
        {
            mx=a+b;
        }
        if(a-b>maxi)
        maxi=a-b;
        if(a+b<mn)
        {
            mn = a+b;
        }
        if(a-b<mini)
        mini=a-b;
    }
    cout << max(mx-mn,maxi-mini) << "\n";
    return 0;
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
S = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    S[a-1].append(b-1)
    S[b-1].append(a-1)

for b in S[0]:
    if N-1 in S[b]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38320
import sys
input = sys.stdin.readline
from scipy.misc import comb

N, K = map(int,input().split())
MOD = 10**9+7
for i in range(1,K+1):
    if i==1 and N==K:
        print(1)
        continue
    val1 = comb(K-1, i-1, exact=True)%MOD
    val2 = comb(N-K-1, i, exact=True)%MOD
    val3 = comb(N-K-1, i-1, exact=True)%MOD
    val4 = comb(N-K-1, i-2, exact=True)%MOD
    res = (val1*(val2+2*val3+val4))%MOD
    print(res)


Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, K; cin >> N >> K;
  
  int ans = 1;
  rep(i,N) {
    ans *= i==0 ? K : K-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    s=list(input())
    key=0
    key2=0
    cnt1=0
    cnt2=0
    ans=0
    for i in range(len(s)):
        if key==0 and s[i]=="<":
            cnt1+=1
            key2=1
        elif key==0 and s[i]==">":
            key=1
            cnt2+=1
            key2=0
        elif key==1 and s[i]==">":
            cnt2+=1
            key2=0
        elif key==1 and s[i]=="<":
            M=max(cnt1,cnt2)
            m=min(cnt1,cnt2)
            ans+= (( M * (M+1) )//2 ) + (( m * (m-1) ) //2 )
            key=0
            key2=1
            cnt1=1
            cnt2=0
    if key==1:
        M=max(cnt1,cnt2)
        m=min(cnt1,cnt2)
        ans+= (( M * (M+1) )//2 ) + (( m * (m-1) ) //2 )
    if key2==1:
        ans+=(cnt1*(cnt1+1))//2
    print(ans)
if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

const int N = 2e5 + 10;
ll members[N], dishes[N];

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k; cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> members[i];
  for (int i = 0; i < n; i++) cin >> dishes[i];
  sort(members,members+n);
  sort(dishes,dishes+n);
  
  ll begin = 0, end = 0;
  ll total = 0;
  for (int i = 0; i < n; i++) {
    end = max(end, members[i] * dishes[n-i-1]);
    total += members[i];
  }

  if (k == 0) {
    cout << end << endl;
    return 0;
  }

  if (k >= total) {
    cout << 0 << endl;
    return 0;
  }



  while (begin < end) {
    ll mid = begin + ((end - begin) / 2);
    bool fail = false;
    ll kk = k;
    for (int i = 0; i < n; i++) {
      ll x = members[i];
      ll y = dishes[n-i-1];
      if (x * y <= mid) continue;
      kk -= (x - mid / y);
      if (kk < 0) {
        fail = true;
        break;
      }
    }
    if (fail) begin = mid + 1;
    else end = mid;
  }


  cout << end << endl;

  return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string O = Console.ReadLine();
            string E = Console.ReadLine();
            string password = "";
            int cnt = 0;
            while (true)
            {
                if(cnt < O.Length)
                {
                    password += O.Substring(cnt, 1);
                }
                else
                {
                    break;
                }
                if(cnt < E.Length)
                {
                    password += E.Substring(cnt, 1);
                }
                else
                {
                    break;
                }
                cnt++;
            }
            Console.WriteLine(password);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);

Measured memory_bytes: 25628
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}



Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main() 
{
    IOS;
    int x;
    cin>>x;
    if(x<=599)
        print(8);
    else if(x<=799)
        print(7);
    else if(x<=999)
        print(6);
    else if(x<=1199)
        print(5);
    else if(x<=1399)
        print(4);
    else if(x<=1599)
        print(3);
    else if(x<=1799)
        print(2);
    else
        print(1);
}   

Measured memory_bytes: 3648
program main
      implicit none
      integer(8) :: a, b, k, i

      read *, a, b, k

      if ( k >= a ) then
        b = b - ( k-a )
        if ( b < 0 ) b = 0
        a = 0
      else
        a = a - k
      end if

      print *, a, b

end program main


Measured memory_bytes: 256
n, k, q = map(int, input().split())
alist = []
for i in range(q):
  a = int(input())
  alist.append(a - 1)
pscore = [0] * n
for j in range(q):
  pscore[alist[j - 1]] += 1
for i in range(n):
  pscore[i] -= (q - k)
  if pscore[i] <= 0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
 
 
 
int main()
{
    long long  n;cin>>n;
    long long  ar[n];
    unordered_map<long long int,long long int>m;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        m[ar[i]]++;
    }
    
   long long int ans=0;
    for(auto i : m)
    {
        ans=ans+ i.second*(i.second-1)/2;
    }

    for(int i=0;i<n;i++)
    {
        cout<<ans-m[ar[i]]+1<<endl;
    }
    
   return 0;
}

Measured memory_bytes: 9160
import sys

sys.setrecursionlimit(10 ** 7)
n = int(input())
t = [[] for _ in range(n)]
e = []
for i in range(n - 1):
    a, b = map(int, input().split())
    t[a - 1].append([i, b - 1])
    t[b - 1].append([i, a - 1])
    e.append([a - 1, b - 1])
colors = [len(t[i]) for i in range(n)]
res1 = max(colors)
print(res1)

res = [0 for _ in range(n - 1)]
f = [False for _ in range(n)]


def dfs2(d, c):
    f[d] = True
    nc = 1
    for j in range(len(t[d])):
        if not f[t[d][j][1]]:
            if c == nc:
                nc += 1
            res[t[d][j][0]] = nc
            dfs2(t[d][j][1], nc)
            nc += 1


dfs2(0, 1000000)

print("\n".join(map(str, res)))


Measured memory_bytes: 88600
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long K, std::vector<long long> a);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll tmp = c-a-b;
    if(4*a*b<tmp*tmp && tmp>0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
// atcoder/diverta2019/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += (i + k) < n;
    }

    cout << cnt+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256