akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CColon {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B, H, M;
        in>>A>>B>>H>>M;
        double d = 0.5 * (60*H+M) > 6 * M ? 0.5 * (60*H+M) - 6 * M : 6 * M - 0.5 * (60*H+M);
        d = min(d, 360-d);
        out<<setprecision(12)<<fixed<<sqrt(A*A+B*B-2*A*B*cos(1.0*d/180*PI))<<'\n';
    }
};


int main() {
	CColon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <cstring>

using namespace std;

#define LIMIT 330

int cnt[11][LIMIT+1];
bool used[11];

void make(int k,int N,int sum){
  if(sum > LIMIT) return;

  if(N == 0){
    cnt[k][sum]++;
    return;
  }

  for(int i = 0 ; i <= 9 ; i++){
    if(!used[i]){
      used[i] = true;
      make(k + 1 , N - 1 ,sum + (k+1)*i);
      used[i] = false;
    }
  }
}

void init(){
  for(int i = 0 ; i <= 10 ; i++){
    memset(used,false,sizeof(used));
    make(0,i,0);    
  }
}

int main(){
  int n,s;

  init();

  while(cin >> n >> s){
    if(s <= LIMIT){
      cout << cnt[n][s] << endl;
    }else{
      cout << 0 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1172
b,r,g,c,s;
main(t){
  for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),~b&&t;)
//    printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r);
    printf("%d\n",100-(t-s)*3+c*2+95*b+7*(9*r+g));
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b == c || a + c == b || b + c == a) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    string s;
    cin>>n>>s;
    //cout<<n*n;
    if(n%2){
        cout<<"No";
        return 0;
    }
    for(int i=0; i<n/2; i++){
        if(s[i]!=s[i+n/2]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(){
    int h,w;
	int a=0;
	while(true){
		cin>>h>>w;
		a=0;
		if(h==0&&w==0)
			break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a%2==0)
				cout<<"#";
			else
				cout<<".";
			a++;
		}
		cout<<endl;
		a-=w%2+1;
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
/* ex7-3
   Sagzar1993  */

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int row, col, i, j;//行と列の数

    /*  各行・各列が全て白であるか否かを記憶する配列
        各行、各列について全てのマス目が白なら１、そうでなければ０ */
    int *ptrWhiteRow, *ptrWhiteCol;
    
    char **ptrColor; //各マスの記号の配列
    scanf("%d %d", &row, &col); //行数、列数の入力

    //各配列のポインタについて、メモリを動的確保
    ptrColor = (char**)calloc(row, sizeof(char*));
    ptrWhiteRow = (int*)calloc(row, sizeof(int));
    ptrWhiteCol = (int*)calloc(col, sizeof(int));
    //メモリの確保に失敗した場合はエラー終了
    if(ptrColor == NULL || ptrWhiteRow == NULL || ptrWhiteCol == NULL){
        exit(1);
    }
    //各行の要素分のメモリを確保
    for(i = 0; i < row; i++){
        ptrColor[i] = (char*)calloc(col, sizeof(char));
        //メモリの確保に失敗した場合はエラー終了
        if(ptrColor[i] == NULL){
            exit(1);
        }
    }

    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            scanf(" %c", &ptrColor[i][j]); //各マス目の色記号の入力
        }
    }

    for(i = 0; i < row; i++){
        for(j = 0; j < col; j++){
            if(ptrColor[i][j] != '.'){
                break; //各行について、白でないマス目があれば終了して次の行へ
            }
        }
        if(j == col){
            ptrWhiteRow[i] = 1; //行の全てのマス目が白ならwhiteRowに1を保存
        }
    }
    
    for(j = 0; j < col; j++){
        for(i = 0; i < row; i++){
            if(ptrColor[i][j] != '.'){
                break; //各列について、白でないマス目があれば終了して次の行へ
            }
        }
        if(i == row){
            ptrWhiteCol[j] = 1; //列の全てのマス目が白ならwhiteColに1を保存
        }
    }
    
    for(i = 0; i < row; i++){
        if(ptrWhiteRow[i] == 1){
            continue;  //各行について、whiteRowを参照し、その行の全てのマス目が白ならスキップ
        }

        for(j = 0; j < col; j++){
            if(ptrWhiteCol[j] == 1){
                continue; //各行の各列のマス目について、その列が全てのマス目が白である列ならスキップ
            }
            printf("%c", ptrColor[i][j]); //そのマス目の行と列がともに全て白でないときは出力
        }
        printf("\n"); //各行について、全てのマス目を調べ終えたら改行
    }
    
    //ptrColorの各行の要素分のメモリを解放
    for(i = 0; i < row; i++){
        free(ptrColor[i]);
    }
    //ptrColorの各行の配列と他の２つの配列へのポインタの領域を解放
    free(ptrColor);
    free(ptrWhiteRow);
    free(ptrWhiteCol);

    return 0;
}

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

long long int min(long long int a,long long int b){
    if(a<b)
        return a;
    else
        return b;
}

int main()
{
    ios::sync_with_stdio(false);
    int n,w;
    cin >> n >> w;
    vector<pair<int,int> > v(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> v[i].first >> v[i].second;
        sum+=v[i].second;
    }
    vector<long long int> dp(sum+1,INT_MAX);
    
    // first = weight & second = value
    for(int i=0;i<n;i++){
        for(int j=sum-v[i].second;j>0;j--)
            if(dp[j])
                dp[j+v[i].second] = min(dp[j+v[i].second],dp[j]+v[i].first);
        dp[v[i].second] = min(dp[v[i].second],v[i].first);
    }
    for(int i=sum;i>0;i--){
        if(dp[i]<=w){
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
struct edge{int64_t sum1,w1,s1,v1;};
int64_t dp[1005][20005];
int main(){
  int N;cin>>N;
  map<int64_t,int64_t>Mw;
  map<int64_t,int64_t>Ms;
  map<int64_t,int64_t>Mv;
  vector<pair<int64_t,int64_t>>A(N);
  for(int i=0;i<N;i++){
  int64_t w,s,v;cin>>w>>s>>v;
    Mw[i]=w;
    Ms[i]=s;
    Mv[i]=v;
    pair<int64_t,int64_t>p(w+s,i);
    A.at(i)=p;
  }sort(A.begin(),A.end());
  vector<edge>B(N);
  for(int i=0;i<N;i++){
  int64_t j=A.at(i).second;
    B.at(i).w1=Mw.at(j);
     B.at(i).s1=Ms.at(j);
     B.at(i).v1=Mv.at(j);
  }for(int i=1;i<=N;i++)
    for(int j=1;j<=20004;j++){
    if(B.at(i-1).w1<=j && j<=B.at(i-1).w1+B.at(i-1).s1)
      dp[i][j]=max(dp[i][j-1],max(dp[i-1][j],dp[i-1][j-B.at(i-1).w1]+B.at(i-1).v1));
      else
        dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }cout<<dp[N][20004]<<endl;
  return 0;
}

Measured memory_bytes: 160140
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


template< class T >
struct CumulativeSum2D {
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W+1,vector<T>(H + 1, 0)) {}

  CumulativeSum2D(vector<vector<T>> v) : data(v.size()+1,vector<T>(v[0].size()+1,0)){rep(i,v.size())rep(j,v[i].size())add(i,j,v[i][j]); build();}

  void add(int x, int y, T z) {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build() {
    for(int i = 0; i < data.size()-1; i++) {
      for(int j = 0; j < data[i].size()-1; j++) {
        data[i+1][j+1] += data[i][j+1]+data[i+1][j]-data[i][j];
      }
    }
  }

  T query(int sx, int sy, int gx, int gy) {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }

  T get(int x,int y){
    return data[x][y];
  }

};

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

  int n;
  cin>>n;
  CumulativeSum2D<int> s(1010,1010);

  while(n--){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    s.add(x2,y2,1);
    s.add(x1,y2,-1);
    s.add(x2,y1,-1);
    s.add(x1,y1,1);
  }
  s.build();

  int ans=0;
  rep(i,1010){
    rep(j,1010){
      ans=max(ans,s.get(i,j));
    }
  }

  cout<<ans<<endl;



}


Measured memory_bytes: 10800
import numpy as np
def calc(number):
    result = np.log10(number) - np.log10(number) % 1
    return(result)

input_num = int(input())

if(input_num % 2 == 1):
    print(0)
else:
    result_1 = 0
    num = 5
    while(input_num - num >= 0):
        result_1 += (input_num - num) // (num * 2) + 1
        num = num * 5
    num = 5
    result = 0
    while(input_num - num >= 0):
        result += input_num // num
        num = num * 5
    print(result - result_1)


Measured memory_bytes: 12468
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

const int mod = 1000000007;

int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 64) {
    ll cnt = 0;
    rep(j, n) {
      if((a[j] & 1) == 0)
        cnt++;
      a[j] >>= 1;
    }
    ll p = (1LL << i) % mod;
    ll m = cnt * (n - cnt) % mod;
    ll d = m * p % mod;
    ans = (ans + d) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    LL X;
    cin >> N >> X;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    reverse(a.begin(), a.end());
    vector<LL> cost(N);
    vector<LL> pref(N+1, 0);
    for (int i = 0; i < N; i++) pref[i+1] = pref[i] + a[i];
    for (int i = 0; i < N; i++) {
        cost[i] = 2*i+3;
    }
    cost[0] = 5;

    LL res = 1ll<<60;
    for (int G = N; G >= 1; G--) {
        LL ris = (N+G)*X;
        int it = 0;
        for (int k = 0; it < N; k++) {
            int next_it = min(it + G, N);
            ris += cost[k] * (pref[next_it] - pref[it]);
            it = next_it;
            if (ris > res) break;
        }
        res = min(res, ris);
    }

    cout << res << "\n";
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		sc.close();
		if(x < 1200) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
	}
}

Measured memory_bytes: 21844
n=int(input())
l=[0]+list(map(int,input().split()))
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
s=1
ans=[0 for i in range(n+1)]

from bisect import bisect_left, bisect_right
INF=float('inf')

import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
def dfs(s,d,c):
    dep[s]=d
    x=bisect_left(c,l[s])
    c[x],y=l[s],c[x]
    ans[s]=bisect_left(c,INF)
    for i in edge[s]:
        if dep[i]==-1:
            dfs(i,d+1,c)
    c[x]=y
c=[INF]*len(l)
dfs(1,0,c)
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 232412
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define VI vector<ll>
#define int long long
using namespace std;

using P = pair<int, int>; // min, max
struct edge {
  int to;
  int cost;
};

int n, m;
vector<vector<edge>> G;
vector<bool> visited;
vector<set<int>> d1;
vector<set<int>> d2;

void dfs(int v, int acc, bool is_odd) {
  if (is_odd) {
    d1[v].insert(acc);
  } else {
    d2[v].insert(-acc);
  }
  if (visited[v]) { return; }
  visited[v] = true;
  REP (i, G[v].size()) {
    edge e = G[v][i];
    dfs(e.to, e.cost - acc, !is_odd);
  }
}

int solve() {
  int left = 0;
  int right = 1e10;
  dfs(0, 0, false);
  REP (i, n) {
    if (d1[i].size() > 1) { return 0; }
    if (d2[i].size() > 1) { return 0; }
    if (d1[i].size() > 0 && d2[i].size() > 0) {
      if ((*d1[i].begin() + *d2[i].begin()) % 2) { return 0; }
      int mid = (*d1[i].begin() + *d2[i].begin()) / 2;
      left = max(left, mid-1);
      right = min(right, mid+1);
      continue;
    }
    if (d2[i].size() > 0) {
      left = max(left, *d2[i].begin());
    }
    if (d1[i].size() > 0) {
      right = min(right, *d1[i].begin());
    }
  }
  return max(0ll, right-left-1);
}

signed main() {
  cin >> n >> m;
  visited = vector<bool>(n, false);
  G = vector<vector<edge>>(n);
  REP (i, m) {
    int u, v, s;
    cin >> u >> v >> s;
    u--; v--;
    G[u].push_back({v, s});
    G[v].push_back({u, s});
  }

  d1 = vector<set<int>>(n);
  d2 = vector<set<int>>(n);

  cout << solve() << endl;
}


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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;

  int ans = 0;
  int l = 0, r = 0, c = 0;
  while (l < n) {
    while ((c < k || (c == k && s[r + 1] == '1')) && r < n - 1) {
      if (s[r] == '0' && s[r + 1] == '1') {
        ++c;
      }
      ++r;
    }

    ans = max(ans, r - l + 1);

    while (l < n) {
      ++l;
      if (s[l - 1] == '0' && s[l] == '1') {
        --c;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s, t = "CODEFESTIVAL2016";
	int ans = 0;
	cin >> s;
	for (int i = 0; i < 16; ++i) {
		ans += (s[i] != t[i] ? 1 : 0);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 1048576
#define MOD 1000000007
#define at(i,j) (((i)>>(j))&1)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int limit[25][2], f[MAXN+5], nex[25][MAXN+5], cro[MAXN+5], n, m, k, E, Ans; inline void Add(int &x, int v){x += v, x<MOD?:x-=MOD;}
int main()
{
	n = read()-1, m = read(), k = read(), E = 1<<n, f[0] = 1;
	for(rint i = 0, a, b; i < k; a = read(), b = read()-1, limit[a][0] |= 1<<b, limit[a][1] |= read()<<b, i++);
	for(rint S = 0, j, t; S < E; S++) for(j = 0, t = 0; j < n; t += at(S,j), j&&at(S,j)&&!at(S,~-j) ? nex[t][S] = S^(1<<j)^(1<<~-j) : 0, j++);
	for(rint S = 0, j, t; S < E; S++) for(j = n-1, t = 1; ~j && t; !at(S,j) ? cro[S] = S^(1<<j), t = 0 : 0, j--);
	for(rint i = 1, S, j; i <= m; i++)
	{
		for(S = 0; S < E-1; Add(f[cro[S]],f[S]), S++);
		for(j = 0; j < n; j++) for(S = ~-E; ~S; nex[j][S] ? Add(f[nex[j][S]],f[S]),0 : 0, S--);
		for(S = 0; S < E; (S&limit[i][0])^limit[i][1] ? f[S] = 0 : 0, S++);
	}	for(rint S = 0; S < E; Add(Ans,f[S]), S++); printf("%d\n",Ans); return 0;
}

Measured memory_bytes: 69888
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  int N;
  cin >> N;
  vpii A(N);
  int tmp;
  rep(i, N){
    cin >> tmp;
    A[i] = make_pair(tmp, i+1);
  }

  stable_sort(A.begin(), A.end());

  rep(i, N)
    cout << A[i].second << " ";

  cout << endl;
  
  return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    long double sum = 0;
    ll count = 0;
    vector<pair<ll, ll>> cords;
    vector<ll> v;
    cin >> N;
    cords.resize(N);
    v.resize(N);
    for(ll i = 0;i < N;i++) {
        ll x, y;
        cin >> x >> y;
        cords[i] = pair<ll, ll>{x, y};
        v[i] = i;
    }
    do {
        for(ll i = 0;i < N - 1;i++) {
            ll x, y;
            x = cords[v[i]].first - cords[v[i + 1]].first;
            y = cords[v[i]].second - cords[v[i + 1]].second;
            sum += sqrt(x * x + y * y);
        }
        count++;
    } while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(6) << sum / count << endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


ll dp[110000][13]; // 下位からi文字目までみたときで，余りjとなるような数の総数
inline void showDP(int h, int w) {
  REP(i, h) {
    REP(j, w) {
      cerr << Decimal << dp[i][j] << ' ';
    }
    cerr << endl;
  }
}
int main()
{
  string S; cin >> S;
  reverse(ALL(S));

  dp[0][0] = 1;
  ll dig = 1;
  REP(i, S.size()) {
    REP(j, 13) {
      if (S[i] == '?') {
        REP(k, 10) {
          int m = (k*dig) % 13;
          (dp[i + 1][(j + m) % 13] += dp[i][j]) %= MOD;
        }
      } else {
        int m = ((S[i]-'0')*dig) % 13;
        (dp[i + 1][(j + m) % 13] += dp[i][j]) %= MOD;
      }
    }
    (dig *= 10) %= 13;
  }
  cout << dp[S.size()][5] << endl;
  return 0;
}


Measured memory_bytes: 10752
import math
ans = 0
c = 0
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        c = math.gcd(i,j)
        for m in range(1,K+1):
            ans += math.gcd(c,m) 
print(ans)
            

Measured memory_bytes: 9208
N=int(input())

X=list(map(int, input().split()))

X.sort()

min=10000000000
for P in range(100):

    power=0
    for j in range(len(X)):
        power=power+(X[j]-P)**2

    if power<=min:
        min=power

    P=P+1


print(min)

Measured memory_bytes: 3060
import itertools
class Dice:
    def __init__(self, labels):
        self.labels = labels
        self.up = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.down = labels[5]
    def east(self):
        self.up, self.right, self.down, self.left = self.left, self.up, self.right, self.down
        self.update_labels()
    def north(self):
        self.up, self.back, self.down, self.front = self.front, self.up, self.back, self.down
        self.update_labels()
    def south(self):
        self.up, self.front, self.down, self.back = self.back, self.up, self.front, self.down
        self.update_labels()
    def west(self):
        self.up, self.left, self.down, self.right = self.right, self.up, self.left, self.down
        self.update_labels()
    def clockwise(self):
        self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        self.update_labels()
    def counterclockwise(self):
        self.front, self.right, self.back, self.left = self.left, self.front, self.right, self.back
        self.update_labels()
    def set_up(self, up):
        for i in range(6):
            if up == self.up:
                break
            if i % 2:
                self.east()
            else:
                self.north()
    def set_front(self, front):
        while True:
            if front == self.front:
                break
            self.clockwise()
    def update_labels(self):
        self.labels = [self.up, self.front, self.right, self.left, self.back, self.down]

def is_the_same(d1, d2):
    for i in range(30):
        if d1.labels == d2.labels:
            return True
        if i % 5 == 0:
            if i % 10 == 0:
                d2.east()
            else:
                d2.north()
        else:
            d2.clockwise()
    else:
        return False

n = int(input())
dices = []
for _ in range(n):
    dices.append(Dice(list(map(int, input().split()))))
for d in itertools.combinations(dices, 2):
    if is_the_same(d[0], d[1]):
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 7892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			if (s[2] == s[3] && s[4] == s[5]) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.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[] 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[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int dh[] = { -1,-1,-1,0,0,1,1,1};
int dw[] = { -1,0,1,-1,1,-1,0,1};

int main()
{
	int H, W;
	cin >> H;
	cin >> W;
	vector<string> s(H);
	for (int i = 0; i < H; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (s[i][j]=='.')
			{
				s[i][j] = '0';
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (s[i][j]=='#')
			{
				for (int k = 0; k < 8; k++)
				{
					int x = j + dw[k];
					int y = i + dh[k];
					if (x< 0 || x >= W || y < 0 || y >= H || s[y][x]=='#')
					{
						continue;
					}
					s[y][x]= '0'+((s[y][x]-'0')+1);
				}
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
ans=[]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i+n//i)
    divisors.sort()
    return divisors
ans=make_divisors(N)
print(ans[0]-2)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::{HashSet, HashMap, BinaryHeap};

const MOD: i64 = 1e9 as i64 + 7;

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

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

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

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

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

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

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

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

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        h: usize,
        n: usize,
        a: [usize; n],
    }
    let ans = if h <= a.iter().fold(0, |sum, x| sum + x){"Yes"} else {"No"};
    println!("{}", ans);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
#ABC102 B

N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(1,N):
    for j in range(i):
        if ans < abs(A[i]-A[j]):
            ans = abs(A[i]-A[j])
print(ans)


Measured memory_bytes: 38768
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int y, int m, int d) {
  if (m == 1 || m == 2) y--, m += 12;
  return 365 * y + y / 4 - y / 100 + y / 400 + 306 * (m + 1) / 10 + d - 428;
}

void solve() {
  int y1, m1, d1, y2, m2, d2;
  while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 != -1) {
    cout << f(y2, m2, d2) - f(y1, m1, d1) << endl;
  }
}

Measured memory_bytes: 2988
package main

import (
	"fmt"
	"math"
)

func max(nums ...int) int {
    if len(nums) == 0 {
        panic("funciton max() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Max(float64(res), float64(nums[i])))
    }
    return res
}

func main() {
	var (
		A, B int
	)
	fmt.Scan(&A, &B)
	fmt.Println(max(A+B, A-B, A*B))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);


int n,m,x,t,ans,y;
int memo3[20];

int msb(int state,int bit){
    for(int i=n-1;i>=0;i--){
        if( (state/(int)pow(3,i)) % 3 == bit){
            return i;
        }
    }
    return -1;
}

int pow(int x,int y){
    if(y==0)return 1;
    if(memo3[y])return memo3[y];
    return memo3[y] = std::pow(3,y);
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int size = pow(3,15);
    while(true){
        cin >> n >> m;
        if(n==0 && m == 0)break;
        ans = 0;
        queue<int> q;
        vector<int> d(size);
        vector< vector<int> > b(3);
        int mask = 0;
        for(int i=0;i<3;i++){
            cin >> x;
            for(int j=0;j<x;j++){
                cin >> t;
                t--;
                b[i].push_back(t);
                mask += i * pow(3,t);
            }
        }
        q.push(mask);
        d[mask] = 1;
        while(!q.empty()){
            int c = q.front();q.pop();
            if(c== 0 || c == pow(3,n)-1)break;
            // 現在の状態から4通りの遷移を考える
            if(d[c]-1 > m)continue;
            // 0 -> 1 のとき
            int now = c;
            x = msb(now,0);
            y = msb(now,1);
            now += 1 * pow(3,x);
            if(x>y && d[now] == 0){
                q.push(now);
                d[now] = d[c] + 1;
            }
            // 1 -> 0 のとき
            now = c;
            x = msb(now,1);
            y = msb(now,0);
            now -= 1* pow(3,x);
            if(x>y && d[now] == 0){
                q.push(now);
                d[now] = d[c] + 1;
            }
            // 1 -> 2 のとき
            now = c;
            x = msb(now,1);
            y = msb(now,2);
            now += 1 * pow(3,x);
            if(x>y && d[now] == 0){
                q.push(now);
                d[now] = d[c] + 1;
            }
            // 2 -> 1 のとき
            now = c;
            x = msb(now,2);
            y = msb(now,1);
            now -= pow(3,x);
            if(x>y && d[now] == 0){
                q.push(now);
                d[now] = d[c] + 1;
            }
        }
        ans = max(d[0],d[pow(3,n)-1]) - 1;
        cout << (ans<=m?ans:-1) << endl;
    }
}


Measured memory_bytes: 59200
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=998244353;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////


void Solve(){
  int n,D,ans=0;
  cin>>n>>D;
  rep(i,1,n){
    LL x,y;
    cin>>x>>y;
    if(square(x)+square(y)<=(LL)D*D)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f q.front()
#define SIZE (ll)(1e3)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long int ll;

int main(){
int a,b;
cin>>a>>b;
ll w[a+1],val[a+1];
for(int i=0;i<a;i++)
	cin>>w[i]>>val[i];
ll dp[a+1][b+1];
for(int i=0;i<=a;i++){
	for(int j=0;j<=b;j++){
		if(i==0||j==0)
			dp[i][j]=0;
	else if(w[i-1]<=j){
		dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+val[i-1]);
	}
	else 
	dp[i][j]=dp[i-1][j];}

}
cout<<dp[a][b];
return 0;}

Measured memory_bytes: 79104
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int R;
    cin >> R;
    cout << 3 * R * R << endl;
    return 0;
};


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    int flag=0;
    if(abs(x-a)<abs(x-b))flag=1;
    if(flag)
    {
        printf("A\n");
    }
    else
    printf("B\n");
}


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

int main() {

  int N, ps, ls, occ, i, j;
  
  cin >> N;
  
  for (i = 0; i < N; i++) {
    cin >> ps >> ls;
    
    for (j = ps; j <= ls; j++) {
      occ++;
    }
  }

  cout << occ << endl;
}

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

using namespace std;

#define ll long long
#define ld long double

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << max(a - 2 * b, (ll) 0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  cout << a[0]*10 + a[1] + a[2] << endl;
}


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

#define endl '\n'
#define pb push_back
#define ll long long
#define len(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define deb(X) cout << #X << " " << X << '\n'

void solve(int test_case) {
    int n;
    cin >> n;
    int x = INT_MAX, y = INT_MIN, p = INT_MAX, q = INT_MIN;
    for(int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        x = min(x, (a+b));
        y = max(y, (a+b));
        p = min(p, (a-b));
        q = max(q, (a-b));
    }
    cout << max(abs(x-y), abs(p-q)) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    for(int tc = 1; tc <= t; ++tc) solve(tc);
}


Measured memory_bytes: 3656
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())
def println(s):
    print(f"{s}\n")

# https://atcoder.jp/contests/abc075/tasks/abc075_a
xs  = LI()

if xs[0] == xs[1]:
    println(xs[2])
elif xs[0] == xs[2]:
    println(xs[1])
else:
    println(xs[0])


Measured memory_bytes: 68336
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 200000+9;
int fa[MAXN];
int val[MAXN];
int n,m;

int Find(int x){
	if(fa[x]==x)return x;
	int tmp=fa[x];
	fa[x]=Find(fa[x]);
	val[x]=val[tmp]+val[x];
	return fa[x];
}

void Union(int x,int y,int det){
	int xx=Find(x);int yy=Find(y);
	val[yy]=det;
	fa[yy]=xx;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		int aa=Find(a);
		int bb=Find(b);
		if(aa==bb){
			if(c!=val[b]-val[a]){
				puts("No");
				return 0;
			}
		}
		else
			Union(a,b,c+val[a]-val[b]);
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  int ans;
  if (n % 1000 == 0) ans = 0;
  else
    ans = 1000 - n % 1000;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3644
N, Y = map(int, input().split())
a = -1
b = -1
c = -1
for A in range(N+1):
    for B in range(N+1-A):
        C = N - (A+B)
        total = 10000*A + 5000*B + 1000*C
        if total == Y:
            a = A
            b = B
            c = C
print('{} {} {}'.format(a, b, c))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int con = 0;
	vector<vector<int>> G;
	vector<int> hoge;
	
	cin>>N>>M;
	
	G.resize(N, vector<int>(N));
	
	for(int i = 0; i < M; i++){
		int a, b;
		
		cin>>a>>b;
		a--, b--;
		
		G[a][b]++;
		G[b][a]++;
	}
	
	for(int i = 0; i < N; i++){
		hoge.push_back(i);
	}
	
	do {
		bool flag = true;
		
		for(int i = 1; i < N; i++){
			if(G[hoge[i-1]][hoge[i]] == 0){
				flag = false;
				break;
			}
		}
		
		if(flag) con++;
		
	} while(next_permutation(hoge.begin()+1, hoge.end()));
	
	cout<<con<<endl;
	
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string a, b, c;
    cin >> a >> b >> c;
    char tmp='a';
    a = a.substr(1);
    while(true){
        if(tmp=='a'){
            tmp = a[0];
            if(a==""){
                cout<<'A'<<endl;
                return 0;
            }else a = a.substr(1);
        }else if(tmp=='b'){
            tmp = b[0];
            if(b==""){
                cout<<'B'<<endl;
                return 0;
            }else b = b.substr(1);
        }else if(tmp=='c'){
            tmp = c[0];
            if(c==""){
                cout<<'C'<<endl;
                return 0;
            }else c = c.substr(1);
        }
    }
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

int main() {
    int n;
    cin >> n;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        ans*=10;
        ans%=MOD;
    }
    ll nine = 1;
    for(int i=0;i<n;i++){
        nine*=9;
        nine%=MOD;
    }
    rep(i,2){
        ans-=nine;
        ans%=MOD;
    }
    ll eight = 1;
    for(int i=0;i<n;i++){
        eight*=8;
        eight%=MOD;
    }
    ans+=eight;
    if(ans<0)
        ans+=MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n, m,ans=0,a,b; cin >> n >> m;	
 	priority_queue<ll> que;
	vector<vector<int>> d(100001, vector<int>());
	for (int i = 0; i < n; i++) 
		cin >> a >> b , d[a].push_back(b);
	for (int i = 1; i <= m; i++) 
    {
		for (int j = 0; j < d[i].size(); j++) 
			que.push(d[i][j]);
		if (!que.empty()) 
			ans += que.top() , que.pop();
	}
	cout << ans;
}

Measured memory_bytes: 5632