akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define EPS 1e-10
using namespace std;

typedef complex<double> P;

double cross (P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_intersected_ls(P a1, P a2, P b1, P b2) {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < - EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < - EPS );
}

double calc(vector<vector<double> > v) {
    vector<double> ret(v.size(), 1e10);
    ret[0] = 0.0;
    priority_queue<pair<double,int>, vector<pair<double,int> >, greater<pair<double,int> > > que;
    que.push(make_pair(0.0, 0));
    while (que.size()) {
        auto p = que.top(); que.pop();
        auto dist = p.first;
        auto now = p.second;
        for (int i = 0; i < v.size(); i++) {
            if (v[now][i] != 1e5) {
                auto now_dist = dist + v[now][i];
                auto next = i;
                if (now_dist < ret[i]) {
                    ret[i] = now_dist;
                    que.push(make_pair(now_dist, i));
                }
            }
        }
    }

    return ret[1];
}

int main() {
    int A, B;
    cin >> A >> B;
    vector<double> ax(A), ay(A), bx(B), by(B);
    for (int i = 0; i < A; i++) cin >> ax[i] >> ay[i];
    for (int i = 0; i < B; i++) cin >> bx[i] >> by[i];

    P a0 = P(ax[0], ay[0]);
    P a1 = P(ax[1], ay[1]);
    P b0 = P(bx[0], by[0]);
    P b1 = P(bx[1], by[1]);

    double ans = 1e8;
    vector<vector<double> > va(B, vector<double>(B, 1e5));
    for (int i = 0; i < B; i++) {
        for (int j = i + 1; j < B; j++) {
            P x(bx[i], by[i]), y(bx[j], by[j]);
            if (!is_intersected_ls(a0, a1, x, y)) {
                va[i][j] = va[j][i] = abs(x - y);
            }
        }
    }
    ans = min(ans, calc(va) + abs(a0 - a1));
    vector<vector<double> > vb(A, vector<double>(A, 1e5));
    for (int i = 0; i < A; i++) {
        for (int j = i + 1; j < A; j++) {
            P x(ax[i], ay[i]), y(ax[j], ay[j]);
            if (!is_intersected_ls(b0, b1, x, y)) {
                vb[i][j] = vb[j][i] = abs(x - y);
            }
        }
    }
    ans = min(ans, calc(vb) + abs(b0 - b1));

    if (ans == 1e8) cout << -1 << endl;
    else printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 26792
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    ll N , K , a = 0 , mod = 1e9 + 7;
    cin >> N >> K;
    for(ll i = K; N + 1 >= i; i++){
        a = (a + (N - i + 1) * i + 1) % mod;
    }
    cout << a << endl;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

ll h,w,ma,mi,ans;
ll S1,S2,S3; 

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans = 1e15-1;
	h = read() ,w = read();
	
//	if(h<w){ swap(h,w); }
	
//	printf("%lld %lld\n",h,w);
	
	for(ll i = 1;i < h; i++){
		S1 = i * w;
		mi = S1 , ma = S1;
		if(w%2==1){
			S2 = (w / 2ll) * (h - i) * 1ll;
			S3 = ((w / 2ll) + 1ll) * (h - i) * 1ll;
			ma = max(ma,S2); mi = min(mi,S2);
			ma = max(ma,S3); mi = min(mi,S3);
		}else if(w%2==0){
			S2 = (w / 2ll) * (h - i);
			ma = max(ma,S2); mi = min(mi,S2);
		}
		ans = min(ans,ma - mi);
	}
//	printf("%lld\n",ans);
	
	for(ll i = 1;i < w; i++){
		S1 = i * h;
		mi = S1 , ma = S1;
		if(h%2==1){
			S2 = (h / 2ll) * (w - i) * 1ll;
			S3 = ((h / 2ll) + 1ll) * (w - i) * 1ll;
			ma = max(ma,S2); mi = min(mi,S2);
			ma = max(ma,S3); mi = min(mi,S3);
		}else if(h%2==0){
			S2 = (h / 2ll) * (w - i);
			ma = max(ma,S2); mi = min(mi,S2);
		}
		ans = min(ans,ma - mi);
	}
//	printf("%lld\n",ans);
	
	for(ll i = 1;i < h-1; i++){
		S1 = i * w;
		mi = S1 , ma = S1;
		if((h-i)%2==1){
			S2 = ((h-i) / 2ll) * w * 1ll;
			S3 = (((h-i) / 2ll) + 1ll) * w * 1ll;
			ma = max(ma,S2); mi = min(mi,S2);
			ma = max(ma,S3); mi = min(mi,S3);
		}else if((h-i)%2==0){
			S2 = ((h-i) / 2ll) * w;
			ma = max(ma,S2); mi = min(mi,S2);
		}
		ans = min(ans,ma - mi);
	}
//	printf("%lld\n",ans);
	
	for(ll i = 1;i < w-1; i++){
		S1 = i * h;
		mi = S1 , ma = S1;
		if((w-i)%2==1){
			S2 = ((w-i) / 2ll) * h * 1ll;
			S3 = (((w-i) / 2ll) + 1ll) * h * 1ll;
			ma = max(ma,S2); mi = min(mi,S2);
			ma = max(ma,S3); mi = min(mi,S3);
		}else if((w-i)%2==0){
			S2 = ((w-i) / 2ll) * h;
			ma = max(ma,S2); mi = min(mi,S2);
		}
		ans = min(ans,ma - mi);
	}
//	printf("%lld\n",ans);
	
	printf("%lld\n",ans);

	return 0;
}

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

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define all(x) (x).begin(),(x).end()
#define debug(x,n) FOR(i,0,n) cout << x[i] << " "; cout << endl

// Custom global variable 



// ----------------------

auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ----

	int n;
	cin >> n;
	map<string, map<int,int>> E;
	FOR(i,0,n) {
		string s;
		cin >> s;
		int t;
		cin >> t;
		E[s][t] = i;
	}

	for(auto it = E.begin(); it != E.end(); it++) {
		for(auto it2 = it->nd.rbegin(); it2 != it->nd.rend(); it2++) {
			cout << it2->nd+1 << "\n";
		}
	}

  // ---------------------
  #ifdef DEBUG
    cerr << endl << "Time:" << double(clock())/CLOCKS_PER_SEC << " secs" << endl;
  #endif
}


Measured memory_bytes: 256
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/multi_array.hpp>

using namespace std;


int main()
{
    int N;

    std::cin >> N;

    using Point = std::pair<int, int>;

    std::vector<Point> R;
    for (size_t i = 0; i < N; ++i) {
        int a, b;
        std::cin >> a >> b;
        R.push_back({a, b});
    }

    std::vector<Point> B;
    for (size_t i = 0; i < N; ++i) {
        int c, d;
        std::cin >> c >> d;
        B.push_back({c, d});
    }

    // x軸でソート
    std::sort(std::begin(R), std::end(R),
              [](const auto& a, const auto& b) {
                  return a.first < b.first;
              });

    // x軸でソート
    std::sort(std::begin(B), std::end(B),
              [](const auto& a, const auto& b) {
                  return a.first < b.first;
              });

    int count = 0;
    for (auto&& b: B) {
        // bのx軸的相方候補検索
        std::vector<std::vector<Point>::iterator> cands;
        for (auto redItr = R.begin(); redItr != R.end(); ++redItr) {
            if (redItr->first < b.first) {
               cands.push_back(redItr);
            }
        }
        // そのなかからy軸的にマッチしていて、一番大きいものを探す
        std::vector<Point>::iterator cand = R.end();
        for (auto c: cands) {
            if (c->second < b.second) {
                if (cand == R.end()) {
                    cand = c;
                }
                else if (cand->second < c->second) {
                    cand = c;
                }
            }
        }
        if (cand != R.end()) {
            count++;
            R.erase(cand);
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
using namespace std;

ll dp[1001][1001];

ll solve(ll n, ll k, ll m) {
  dp[0][0] = 1;
  for(int i=1;i<=n;++i) {
    for(int j=1;j<=i;++j) {
      dp[i][j] = j*(dp[i-1][j-1] + dp[i-1][j]) % m;
    }
  }
  return dp[n][k];
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<solve(n,k,mod)<<endl;
  return 0;
}


Measured memory_bytes: 10008
/*
[abc127] D - Integer Cards
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int MAX_M = 1e5;

int N, M;
ll A[MAX_N];
int B[MAX_M];
ll C[MAX_M];
map<ll, int> m;

ll solve() {
    for (int i = 0; i < N; i++) {
        m[A[i]]++;
    }

    for (int i = 0; i < M; i++) {
        int b = B[i];
        while (b > 0 && m.begin()->first < C[i]) {
            auto &p = *m.begin();
            int d = min(b, p.second);
            // cerr << "d: " << d << ", first: " << p.first
            //      << ", second:" << p.second << endl;
            b -= d;
            if (p.second - d == 0) {
                m.erase(p.first);
            } else {
                p.second -= d;
            }
            m[C[i]] += d;
        }
        // for (auto &p : m) {
        //     cerr << p.first << ", " << p.second << endl;
        // }
        // cerr << "-----" << endl;
    }

    ll ans = 0;
    for (auto &p : m) {
        ans += p.first * p.second;
    }
    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i] >> C[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int x;
  cin>>x; 
  if(x<1200){
    cout<<"ABC"<<endl;
  }
  
  else{
    cout<<"ARC"<<endl;
  }
 
}








Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int k,a,b;
    cin >> k >> a >> b;
    string ans = "NG";
    for(int i = a;i<=b;i++){
        if(i%k == 0){
            ans = "OK";
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int N,M,K;
  cin >>N>>M>>K;

  vector<P> node[N+1];

  int d[N+1];
  fill(d,d+N+1,INF);

  priority_queue<P, vector<P>, greater<P> > pque;

  REP(_t,M){
    int a,b,l;
    cin >>a>>b>>l;
    node[a].PB( MP(b,l) );
    node[b].PB( MP(a,l) );
  }

  REP(_t,K){
    int a;
    cin >> a;
    pque.push( P(0,a) );
    d[a] = 0;
  }

  // dijkstra
  while( ! pque.empty() ){
    P p = pque.top(); pque.pop();
    int v = p.second;
    if( d[v] < p.first )
      continue;

    PREP(it,node[v]){
      int to = (*it).first;
      int cost = (*it).second;
      if( d[to] > d[v] + cost ){
	d[to] = d[v]+cost;
	pque.push( P(cost,to) );
      }
    }
  }


  int res = 0;
  REP(i, N+1){
    if( d[i] != INF){
      res = max( res, d[i] );

      PREP(it,node[i]){
	int to = (*it).first;
	int cost = (*it).second;
	if( cost  != INF ){
	  int val = (double)(d[i]+cost+d[to])/2+0.5;
	  res = max( res, val );
	}
      }
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

int main(void){
  ll n;
  cin>>n;
  cout<<(n-1)*n/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int field[100][100];

int main(){
    std::ios::sync_with_stdio(false);
    int w, b;
    cin >> w >> b;
    
    for(int i=0;i<100;++i)
    {
        for(int j=0;j<100;++j)
        {
            if(i < 50)
            {
                field[i][j] = 0;
            }
            else
            {
                field[i][j] = 1;
            }
        }
    }

    while(b > 1)
    {
        int row = (b-1) / 50;
        int col = (b-1) % 50;
        field[row * 2][col * 2] = 1;
        --b;
    }

    while(w > 1)
    {
        int row = (w-1) / 50;
        int col = (w-1) % 50;
        field[99 - row * 2][col * 2] = 0;
        --w;
    }

    cout << "100 100" << endl;
    for(int i=0;i<100;++i)
    {
        for(int j=0;j<100;++j)
        {
            cout << (field[i][j] == 0 ? "." : "#");
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))
AC=collections.Counter(A)
AM=AC.most_common()
AM.sort(reverse=True)
#print(AM)
H=0
for i in range(len(AM)):
    if H==0:
        if AM[i][1]>=4:
            print(AM[i][0]**2)
            exit()
        elif AM[i][1]>=2:
            H=AM[i][0]
    else:
        if AM[i][1]>=2:
            
            print(AM[i][0]*H)
            exit()
print(0)

Measured memory_bytes: 21668
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int siz=s.size();
    
  
  vector<char> alp(26);
  
  alp.at(0)='A';
  
  for(int i=1;i<26;i++){
    alp.at(i)='A'+i;
  }
  
  for(int i=0;i<siz;i++){
    for(int j=0;j<26;j++){
      if(s.at(i)==alp.at(j)){
        cout<<alp.at((j+n)%26);
        break;
      }
    }
  }
}
  
  
  

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

char mm[6][6];
char m2[6][6];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int n;
  cin >> n;
  vector<long long> V(n);
  for (auto& i : V) {
    cin >> i;
  }
  sort(V.begin(), V.end(), greater<long long>());

  long long ans = 0;
  ans += V[0];
  int left = n - 2;
  for (int i = 1; i < n; ++i) {
    if (left >= 2) {
      ans += V[i] * 2;
      left -= 2;
    } else if (left == 1) {
      ans += V[i];
      left -= 1;
    } else {
      break;
    }
  }
  cout << ans;
  return 0;
}


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

using namespace std;
const int maxn = 100;
char s[maxn];
int num[30];

int main ()
{
    string v = "KIHBR";
    int flag = 1;
    cin >> s;
    int len = strlen(s);
    memset(num,0,sizeof(num));
    for (int i = 0;i < len;++i) {
        num[s[i]-'A']++;
    }
    string r = "";
    for (int i = 0;i < len;++i) {
        if (s[i] != 'A')
            r += s[i];
    }
    for(int i = 0; i < len - 1; i++){
    	if (s[i] == s[i+1] && s[i] == 'A') {
    		flag = 0;
    	}
    }
    int ans = 0;
    for (int i = 1;i < 30;++i) {
        if (num[i] == 1)
            ans++;
    }
    if (ans != 5 || r != v) flag = 0;
    int ik,ii,ih;
    for (int i = 0;i < len;++i) {
        if (s[i] == 'K')
            ik = i;
        if (s[i] == 'I')
            ii = i;
        if (s[i] == 'H')
            ih = i;
    }
    if (!(ik+1 == ii && ii+1 == ih)) flag = 0;
    if (!flag)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int flr(int x, int y) {
	return x/y;
}

int cel(int x, int y) {
	return (x+y-1) / y;
}

int main() {

	IOS

	int l, r, d;
	cin >> l >> r >> d;

	// deb(flr(r, d));
	// deb(cel(l, d));
	
	cout << (flr(r, d) - cel(l, d) + 1);

	return 0;
}

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


int main(){
  int n, p;
  cin >> n >> p;
  int a[20000];
  int m = 0;
  for(int i=0; i<n;++i){
    cin >> a[i];
    if(a[i] % 2 == 1) m++;
  }
  if(m==0)cout << (p==0 ? (1ll <<n) : 0) << endl;
  else cout << (1ll << (n-1)) << endl;
}


Measured memory_bytes: 3616
/*input
6
30 10 60 10 60 50
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	vector<int> h(n+1);
	for(int i=1;i<=n;i++) cin>>h[i];

	vector<int> dp(n+1,0);
	for(int i=2;i<=n;i++)
	{
		if(i==2) dp[i]=abs(h[2]-h[1]);
		else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<"\n";
	return 0;
}


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
struct cir{
    int x , y , r;
    ld operator * (const cir & other)const &{
        ld dis = sqrt((ll)(x - other.x) * (x - other.x) + (ll)(y - other.y) * (y - other.y));
        return max(dis - r - other.r , (ld)0);
    }
    cir(int x , int y , int r):x(x),y(y),r(r){};
    cir(){r = 0;};
}a[maxn];
ld dis[maxn];
int n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> a[0].x >> a[0].y >> a[1].x >> a[1].y;
    cin >> n;
    for(int i = 2 ; i <= n + 1 ; ++i){
        cin >> a[i].x >> a[i].y >> a[i].r;
    }
    priority_queue<pair<ld,int>,vector<pair<ld,int>>,greater<pair<ld,int>>> pq;
    fill_n(dis,maxn,1e18);
    dis[0] = 0;pq.push(mp(0,0));
    while(pq.size()){
        auto u = pq.top();pq.pop();
        if(u.first > dis[u.second] + 1e-9)continue;
        for(int j = 0 ; j <= n + 1 ; ++j){
            if(u.first + a[u.second] * a[j] < dis[j]){
                dis[j] = u.first + a[u.second] * a[j];
                pq.push(mp(dis[j],j));
            }
        }
    }
    cout << fixed << setprecision(9) << dis[1];
}


Measured memory_bytes: 10476
#include <bits/stdc++.h>
#include <numeric>
#define ll long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair

#define DEBUG

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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;
}
 
//for dfs, I prepare container(tree) at global
vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1){
	for(int u: to[v]){
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}
 
//#define int int64_t
signed main()
{
	int n, q; cin >> n >> q;
	for(int i = 0, i_len = (int)n-1; i < i_len; ++i){
		int a, b;
		cin >> a >> b;
		--a;--b;
		to[a].emplace_back(b);
		to[b].emplace_back(a);		
	}
	ans.resize(n);
	for(int i = 0, i_len = (int)q; i < i_len; ++i){
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
 
	for(int i = 0, i_len = (int)n; i < i_len; ++i){
		cout << ans[i] << "\n";
	}
 
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long)(1e15)
//#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve(){
    int k;
    cin >> k;
    int ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int ii = 1; ii <= k; ii++){
                ans += __gcd(ii, __gcd(j, i));
            }
        }
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": ";
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public static int Main()
    {
        string answer;
        string[] str = Console.ReadLine().Split(' ');
        int A = (int.Parse(str[0]) + 13) % 15;
        int B = (int.Parse(str[1]) + 13) % 15;

        if (A < B)
        {
            answer = "Bob";
        }
        else if (A > B)
        {
            answer = "Alice";
        }
        else
        {
            answer = "Draw";
        }
        Console.WriteLine(answer);
        return 0;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
static const int d = 256;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string T, P;
    cin >> T >> P;
    int tlen = T.size(), plen = P.size();
    rep(i, tlen - plen+1)
    {
        string subT = T.substr(i, plen);
        if (subT == P) {
            printf("%lld\n", i);
        }
    }
    return 0;
}


Measured memory_bytes: 4528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<pair<int,int> > ints[410000];

int main(){
    int n;
    cin >> n;
    int N = (1<<n);
    int g[N];
    map<int,int> used;
    for(int j = 0; j < N; j++){
        cin >> g[j];
        g[j]--;
        used[g[j]] = 1;
    }
    int maxval[N];
    int minval[N];
    int ok = 1;
    for(int j = N-1; j >= 0; j--){
        maxval[j] = N-1;
        if(g[j] != -1) maxval[j] = g[j];
        for(int i = 0; i < n; i++){
            if((1<<i) & j) continue;
            maxval[j] = min(maxval[j], maxval[j ^ (1<<i)]);
        }
    }

    for(int j = 0; j < N; j++){
        minval[j] = 0;
        if(g[j] != -1) minval[j] = g[j];
        for(int i = 0; i < n; i++){
            if(((1<<i) & j) == 0) continue;
            minval[j] = max(minval[j], minval[j ^ (1<<i)]);
        }
    }
    for(int j = 0; j < N; j++){
        if(minval[j] > maxval[j]){
            cout << "NO" << endl;
            return 0;
        }
        ints[minval[j]].push_back(make_pair(maxval[j], j) );
    }
    set<pair<int,int> > d;
    for(int i = 0; i < N; i++){
        for(int f = 0; f < ints[i].size(); f++){
            d.insert(ints[i][f]);
        }
        if(d.empty()){
            cout << "NO" << endl;
            return 0;
        }
        pair<int,int> b = *d.begin();
        d.erase(d.begin());
        if(b.first < i){
            cout << "NO" << endl;
            return 0;
        }
        g[b.second] = i;
    }


    /*for(int j = 0; j < N; j++){
        for(int i = 0; i < n; i++){
            if((1<<i) & j) continue;
            if(g[j] > g[j ^ (1<<i)]){
                cout << "NO" << endl;
                return 0;
            }
        }        
    }*/
    cout << "YES" << endl;
    for(int j = 0; j < N; j++){
        vector<int> f;
        int cj = j;
        int r = 0;
        for(int i = 0; i < n; i++){
            r = 2 * r + (cj % 2);
            cj /= 2;
        }
        cout << g[r] + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 34688
n=int(input())
A=list(map(int,input().split()))
a=0
b=0
c=0
d=sum(A)
for i in range(n):
  if A[i]==1:
    a=a+1
  elif A[i]==2:
    b=b+1
c=n-a-b
i=1
dp=[[[0]*(n+2) for i in range(n+2)] for j in range(n+2)]
for k in range(c+1):
  for j in range(n-k-a+1):
    for i in range(n-k-j+1):
      if i==0 and j==0 and k==0:
        continue
      dp[k][j][i]=(dp[k][j][i-1]*i+dp[k][j-1][i+1]*j+dp[k-1][j+1][i]*k+n)/(i+j+k)
print(dp[c][b][a])

Measured memory_bytes: 513032
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll MOD = 998244353;

map<ull, ll> mm[2];
int cnt = 0;


ll run(string s, int fl) {
	ull hsh = 0;
	for (int i = 0; i < s.size(); ++i)
		hsh = hsh * 3 + (s[i] - '0' + 1);
	if (mm[fl].count(hsh)) {
		return mm[fl][hsh];
	}
	++cnt;
	ll ans = 0;
	if (!fl) {
		for (int j = 1; j < s.size(); ++j)
			ans = (ans + run(s.substr(0, j), 1) * run(s.substr(j), 0)) % MOD;
	}
	if (s.size() == 1) {
		if (s[0] == '0')
			ans = (ans + 1) % MOD;
		else
			ans = (ans + 2) % MOD;
	}
	for (int k = 2; k <= s.size(); ++k) {
		if (s.size() % k != 0)
			continue;
		int len = s.size() / k;
		string t = s.substr(0, len);
		for (int i = 0; i < t.size(); ++i)
			for (int j = 1; j < k; ++j)
				t[i] = min(t[i], s[i + j * len]);
		ans = (ans + run(t, 0)) % MOD;
	}
	return mm[fl][hsh] = ans;
}

int main() {
	string s;
	cin >> s;
	cout << run(s, 0) << "\n";
	//cerr << cnt << "\n";
	return 0;
}




Measured memory_bytes: 6400
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 || b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}


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

int main(){
  int H,N;
  cin>>H>>N;
  
  int A[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  

 
  if(H>sum){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  //cout<<ans<<endl;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll INF = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 300500;
const int inf = (int)1e9;

int X[10], p[N], n, x;
bool used[N];           
bool ok;

int rec(vector <int> v){
	if(v.size() == 1)
		return v[0];
	vector <int> va;
	for(int i = 1; i + 1 < (int)v.size(); ++i){
		X[0] = v[i - 1], X[1] = v[i], X[2] = v[i + 1];
		sort(X, X + 3);
		va.pb(X[1]);
	}
	return rec(va);
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	cout << setprecision(10) << fixed;
	
	cin >> n >> x;

	n = n + n - 1;
	if(x == 1 || x == n){
		cout << "No";
		return 0;
	}

	cout << "Yes\n";

	if(x <= n / 2)
		x = n - x + 1, ok = 1;

	for(int i = 1; i <= n / 2; ++i)
		p[i] = i;

	p[n / 2 + 1] = x;
	p[n / 2 + 2] = x + 1;

	vector <int> v;
	for(int i = n / 2 + 1; i <= n; ++i)
		if(i != x && i != x + 1)
			v.pb(i);

	sort(all(v));
	for(int i = n / 2 + 3; i <= n; ++i)
		p[i] = v[i - n / 2 - 3];

	if(ok){
		for(int i = 1; i <= n; ++i)
			p[i] = n - p[i] + 1;
		rev(p + 1, p + n + 1);
	}

	for(int i = 1; i <= n; ++i)
		cout << p[i] << "\n";
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

Measured memory_bytes: 2808
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

map<long long ,long long >mp;

long long ways(long long n){

    if(n==1)return 1;

    if(mp.find(n)!=mp.end()) return mp[n];

    else {
        return mp[n]=1+2*ways(n/2);
    }

}



int main() {

    long long h;
    cin>>h;

    long long ans;
    ans=ways(h);

    cout<<ans;


	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

break_number = 0
pre_index = 0
cnt = 1
hantei = False
for i in range(N):
    if cnt == N and (cnt != 1):
        break
    if a[i] == cnt:
        break_number += (i-pre_index)
        pre_index = i + 1
        cnt += 1
    if i == (N-1):
        if cnt != 1:
            break_number += max(0, i-pre_index + 1)
if cnt == 1:
    print(-1)
else:
    print(break_number)


Measured memory_bytes: 25716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];
    int now_min = 1000010;
    int count_n = 0;
    rep(i,n)
    {
        if (now_min>=ary[i])
        {
            now_min = ary[i];
            count_n++;
        }
    }
    
    cout << count_n << endl;
    
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/math.hpp>

using namespace std;
using namespace atcoder;

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

  int T;
  cin >> T;
  while (T--) {
    int N, M, A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << '\n';
  }
  cout << flush;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;

    int ans = int(1e9);
    for (int start = 0; start <= S.size() - T.length(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
    int in[6];
    scanf("%d %d", &in[0], &in[1]);
    scanf("%d %d", &in[2], &in[3]);

    while(--in[1] > 0){
        scanf("%d %d", &in[4], &in[5]);
        if(in[2] < in[4]) in[2] = in[4];
        if(in[5] < in[3]) in[3] = in[5];
    }
    in[0] = in[3] - in[2] + 1;
    if(in[0] < 0)
        printf("0\n");
    else
        printf("%d\n", in[0]);
     
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

#if 0
template <class T> void _print(T v) { cerr << v; } void _err(istream_iterator<string> it) { (void)it; }
template <class A, class B> void _print(pair<A,B> v) { cerr << "("; _print(v.ff); cerr << ","; _print(v.ss); cerr << ")"; }
template <class T, class... Args> void _err(istream_iterator<string> it, T a, Args... args) { cerr << '\t' << *it << " = "; _print(a); _err(++it, args...); }
#define trace(...)  { cerr << "Line " << __LINE__ << ":"; string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' ');       \
  stringstream _ss(_s); _err(istream_iterator<string>(_ss), __VA_ARGS__); cerr << nl; }
#define debug if(1)
#else
#define trace(...)	{}
#define debug if(0)
#endif

const int N = 1e6+5;
ll dp[N][2];

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  memset(dp, INF, sizeof dp);
  string s; cin >> s;
  const int n = s.size();
  dp[0][0] = s[0]-'0';
  dp[0][1] = 11-(s[0]-'0');
  trace(dp[0][0], dp[0][1]);
  for (int i = 1; i < n; ++i) {
    int v = s[i] - '0';
    dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + v;
    dp[i][1] = min(dp[i-1][0]+1, dp[i-1][1]-1) + 10-v;
    trace(i, dp[i][0], dp[i][1]);
  }
  cout << min(dp[n-1][0], dp[n-1][1]) << nl;
  return 0;
}



Measured memory_bytes: 17564
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define x first
#define y second
#define oo 1000000000
#define PII pair <int, int>
 
using namespace std;

ll n, x, rs;
 
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    cin >> rs;
    for (int i = 1; i < n; i++){
        cin >> x;
        rs = 1LL * rs / (1LL * __gcd(rs, x)) * x;
    }
    cout << rs;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int d[3] = {-1, 0, 1};

ll diff(ll h, ll w){
    if (h%3 == 0 || w%3 == 0) return 0;
    ll ret = h;
    rep(i, 3) rep(j, 3){
        ll a = 2*h/3 + d[i];
        ll b = w/2 + d[j];
        ll tmp1 = LINF, tmp2 = 0;
        tmp1 = min({w*(h-a), a*b, a*(w-b)});
        tmp2 = max({w*(h-a), a*b, a*(w-b)});
        ret = min(ret, tmp2-tmp1);
    }
    return ret;
}

int main(){
    int h, w;
    cin >> h >> w;

    cout << min(diff(h,w), diff(w,h)) << endl;

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String str = sc.next();
     	String ans = "";
      
      for(int i = 0; i < 3; i++){
      	ans += str.charAt(i);
      }  
      
      System.out.println(ans);
    } 
}

Measured memory_bytes: 39132
#include<stdio.h>

int main(){
	int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	S-=3600*h;
	m=S/60;
	s=S-60*m;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>=1&&a<=13&&b>=1&&b<=13)
	{
	if(a==1)
	a=14;
	if(b==1)
	b=14;
	if(a>b)
	printf("Alice");
	else if(a<b)
	printf("Bob");
	else
	printf("Draw");
}
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int N = 105;
const int mod = 998244353;
string str;
inline string get(string &str , int start){
	string res = "";
	for(int j = start ; j < str.size() ; ++j){
		res += str[j];
	}
	return res;
}
map < string , int > mp;
int solve(string str){
	if(str == ""){
		return 1;
	}
	if(mp.find(str) != mp.end()){
		return mp[str];
	}
	int res = 0;
	char start = str[0];
	str.erase(str.begin());
	if(start == '1'){
		res = (solve(str) * 2) % mod;
	}
	else{
		res = solve(str);
	}
	str.insert(str.begin() , start);
	string tmp;
	for(int i = 1 ; i * 2 <= str.size() ; ++i){
		tmp = "";
		for(int j = 0 ; j < i ; ++j){
			tmp += str[j];
		}
		for(int j = 2 ; j * i <= str.size() ; ++j){
			for(int k = (j - 1) * i ; k < j * i ; ++k){
				if(str[k] == '0'){
					tmp[k % i] = '0';
				}
			}
			res = (res + 1LL * solve(tmp) * solve(get(str , j * i))) % mod;
		}
	}
	return mp[str] = res;
}
int main(){
	cin >> str;
	cout << solve(str) << endl;
}

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

int N, Q;
vector<int> graph[200200];
vector<ll> ans, cnt;

void dfs(int cur, int pre = -1, int now = 0) {
    now += cnt[cur];
    ans[cur] += now;
    for (auto &nxt : graph[cur]) {
        if (nxt != pre) dfs(nxt, cur, now);
    }
}

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

    cin >> N >> Q;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    cnt.assign(N, 0);
    ans.assign(N, 0);

    REP(i, Q) {
        int p, x;
        cin >> p >> x;
        --p;
        cnt[p] += x;
    }

    dfs(0);
    for (auto &e : ans) {
        cout << e << endl;
    }

}


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

using ll = long long;

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b; //順を変えるとオーバーフロー
}

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

    ll ans = 1LL;

    for (int i = 0; i < N; ++i){
        ll T; 
        cin >> T;
        ans = lcm(ans, T);
    }

    cout << ans << endl;
}


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

int main() {
  string str;

  cin >> str;

  for(int i = 0; str[i] != '\0'; i += 2) {
    char c = str[i];
    char a = str[i+1];
    if(c == '2')cout << 'k';
    else if(c == '3')cout << 's';
    else if(c == '4')cout << 't';
    else if(c == '5')cout << 'n';
    else if(c == '6')cout << 'h';
    else if(c == '7')cout << 'm';
    else if(c == '8')cout << 'y';
    else if(c == '9')cout << 'r';
    else if(c == '0') {
      if(str[i+1] == 'U'){
	cout << "nn";
	continue;
      }
      cout << 'w';
    }

    if(a == 'T') cout << 'a';
    else if(a == 'L') cout << 'i';
    else if(a == 'U') cout << 'u';
    else if(a == 'R') cout << 'e';
    else cout << 'o';
  
  }
  cout << endl;
}

Measured memory_bytes: 1180
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>

typedef long long int64;

int main(void) {
  int h, n;
  std::cin >> h >> n;
  std::vector<int> as;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  int sum = std::accumulate(as.begin(), as.end(), 0);
  std::cout << (sum >= h ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 892
#include<iostream>

using namespace std;

int main() {
	int n, a[2][100];
	int sum;
	int max = 0;
	cin >> n;
	for (int i = 0;i < 2;i++) {
		for (int j = 0;j < n;j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0;i < n;i++) {
		int z = 0;
		sum = 0;
		for (int j = 0;j < n;j++) {
			sum += a[z][j];
			if (i == j) {
				z = 1;
				sum += a[z][j];
			}
		}
		if (sum > max) max = sum;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

bool is_triangle(const std::vector<int> &v){
	return (v[0] + v[1] > v[2]);
}


int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

	std::vector<int> vec(3);
	int num_triangles = 0;
	int num_acute_angle_triangles = 0;
	int num_right_angle_triangles = 0;
	int num_obtuse_angle_triagles = 0;

	for(;;){
#if INPUT_FROM_FILE
		ifs >> vec[0] >> vec[1] >> vec[2];
#else
		std::cin >> vec[0] >> vec[1] >> vec[2];
#endif
		std::sort(vec.begin(), vec.end());

		if(!is_triangle(vec)){
			break;
		}
		num_triangles++;

		int vec02 = vec[0] * vec[0];
		int vec12 = vec[1] * vec[1];
		int vec22 = vec[2] * vec[2];
		int sum = vec02 + vec12;

		if(sum < vec22){
			num_obtuse_angle_triagles++;
		}
		else if(sum == vec22){
			num_right_angle_triangles++;
		}
		else{
			num_acute_angle_triangles++;
		}
	}

	std::cout << num_triangles << " " << num_right_angle_triangles << " " << num_acute_angle_triangles << " " << num_obtuse_angle_triagles << std::endl;
	return 0;
}


Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<bool> Vb;
typedef vector<ll> Vl;
typedef vector<vector<ll>> VVl;


string s, t;
ll ns, nt;
VVl nxt;

void init()
{
	cin >> s >> t;
	ns = SZ(s);
	nt = SZ(t);

	s += s;
	ns <<= 1;
	nxt.resize(ns + 1, Vl(26, ns));

	RREP(i, ns)
	{
		REP(j, 26)
			nxt[i][j] = nxt[i + 1][j];
		nxt[i][s[i] - 'a'] = i + 1;
	}
}

int main()
{
	init();

	ll ans = 0;
	int i = 0;

	for (char c : t)
	{
		i %= (ns >> 1);
		c -= 'a';

		if (nxt[i][c] == ns)
		{
			cout << -1 << endl;
			return 0;
		}

		ans += nxt[i][c] - i;
		i = nxt[i][c];
	}

	cout << ans << endl;
}

Measured memory_bytes: 49024