akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


/*
           1) long long vs int overflow
           2) read question carefully
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a;i <= b; i++)

#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap 
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not



*/
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int inf = 1e9 + 7;

int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<long double> prob(n);
    for(int i = 0; i < n; i++){
        cin >> prob[i];
    }
    vector<vector<long double>> dp(n, vector<long double>(n + 1, 0));
    dp[0][0] = 1 - prob[0]; dp[0][1] = prob[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j <= i + 1; j++){
            dp[i][j] = (j == 0 ? 0 : (prob[i] * dp[i - 1][j - 1])) + (1 - prob[i]) * dp[i - 1][j];
        }
    }
    long double ans = 0.00;
    for(int heads = 0; heads <= n; heads++){
        int tails = n - heads;
        if(heads > tails){
            ans += dp[n - 1][heads];
        }
    }
    cout << setprecision(10) <<ans << '\n';
}

Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
int n,h,ans;
int main()
{
	cin>>n;
    for(int i=1;i<=n;++i)
    {
    	char s;cin>>s;
        if(s=='I')h++;
        if(s=='D')h--;
        ans=max(ans,h);
    }
    cout<<ans; 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	    public static void main(String[]args){
	    	Scanner scan=new Scanner(System.in);
	    	int a=scan.nextInt();
	    	int b=scan.nextInt();
	    	int c=scan.nextInt();
	    	
	    	if(a<b&&b<c){
	    		System.out.println("Yes");
	    	}else{
	    		System.out.println("No");
	    	}
	    	
	    	
	    	
	    }
	}


Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200020];
ll b[200020];
ll c[200020];
bool cmp(ll a,ll b)
{
	return a>b;
}
int main()
{
	int n;
	ll k;
	scanf("%d%lld",&n,&k);
	for(int i = 1;i <= n;i++){
		scanf("%lld",&a[i]);
	}
	for(int j = 1;j <= n;j++){
		scanf("%lld",&b[j]);
	}
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+n+1);
	ll maxn = 0;
	for(int i = 1;i  <= n;i++){
		c[i] =  a[i] * b[i];
		maxn = max(maxn,c[i]);
	}
	//cout<<maxn<<endl;
	ll l = 0;
	ll r = maxn;
	ll ans = r;
	while(l<r)
	{
		ll mid = (l+r)>>1;
		ll res = 0;
		for(int i = 1;i <= n;i++){
			if(c[i]>mid){
				if((c[i]-mid)%b[i] == 0){
					res += (c[i]-mid)/b[i];
				}
				else{
					res += (c[i]-mid)/b[i]+1;
				}
				//res = res + a[i]-(mid/b[i]);
			}
			if(res>k) break;
		}
		if(res>k){
			l = mid+1;
		}
		else{
			r = mid;
			ans = r;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992
<?php
$N=(int)trim(fgets(STDIN));
$A=explode(' ',trim(fgets(STDIN)));

$trade=0;
for($i=0;$i<$N;$i++){
  $mini=$i;
  for($j=$i;$j<$N;$j++) if($A[$j]<$A[$mini]) $mini=$j;
  if($mini==$i) continue;
  list($A[$i],$A[$mini])=[$A[$mini],$A[$i]];
  ++$trade;
}
echo implode(' ',$A),PHP_EOL,$trade;
?>

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

typedef long long ll;
ll P, Q, A, N;

ll DFS(ll p, ll q, ll n, ll m)
{
    if(P * q == p * Q)return 1;
    if(P * q < p * Q)return 0;
    if(n == N)return 0;

    ll ret = 0;
    for(ll i = m; q * i <= A; i++)
    {
        ret += DFS(p * i + q, q * i, n + 1, i);
    }
    return ret;
}

int main()
{
    while(scanf("%lld%lld%lld%lld", &P, &Q, &A, &N))
    {
        if(P == 0 && Q == 0 && A == 0 && N == 0)return 0;
        printf("%lld\n", DFS(0, 1, 0, 1));
    }

    return 0;
}



Measured memory_bytes: 3188
import math
X = int(input())
if X == 2 or X == 3:
    print(X)
else:

 while True:
    for i in range(2,int(math.sqrt(X))):
       Flag = True
       if X % i == 0:
           Flag = False
           break
    if Flag:
        break
    X += 1
 print(X)

Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vi a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    int ans = 0;
    rep(k,29){//k-bit目
        int t = 1LL<<k;
        int cnt = 0;
        vi ma(n),mb(n);
        rep(i,n){
            ma[i] = a[i]%(2*t);
            mb[i] = b[i]%(2*t);
        }
        sort(all(mb));
        rep(i,n){
            //ma[i]について、mb[j]との和が
            //[t,2*t)または[3*t,4*t)に入るようなjの個数を数え上げ
            cnt += lower_bound(all(mb),2*t-ma[i]) - lower_bound(all(mb),t-ma[i]);
            cnt += mb.end() - lower_bound(all(mb),3*t-ma[i]);
        }
        if(cnt&1)ans += t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6548
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int num = 0;
//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
//  ????????????????????????
std::string Replace(std::string String1, std::string String2, std::string String3)
{
	std::string::size_type  Pos(String1.find(String2));
	num = 0;
	while (Pos != std::string::npos)
	{
		num++;
		String1.replace(Pos, String2.length(), String3);
		Pos = String1.find(String2, Pos + String3.length());
	}

	return String1;
}
bool getans(string st) {
	if (st == "ABC")return true;
	bool ans = false;
	for (char c = 'A'; c <= 'C'; ++c) {
		string ast = Replace(st, "ABC", string(1,c));
		if (st == ast)return false;
		bool ok = count(ast.begin(), ast.end(), c) == num;
		if (ok)ans |= getans(ast);
	}
	return ans;
}

int main() {
	string st; cin >> st;
	bool ans = getans(st);
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}//ABCABCBCC

Measured memory_bytes: 15836
#include <iostream>
#include <set>
#include <map>
using namespace std;
const int N=100000+10;
int n,m,deg[N],u[N],v[N];
int par[N];
set<int> st[N];
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}

int main(){
    for(int i=0;i<N;i++)par[i]=i;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) {
        scanf("%d%d",&u[i],&v[i]);
        deg[u[i]]++, deg[v[i]]++;
    }
    for(int i=1;i<=n;i++)if(deg[i]&1)return !printf("No\n");
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(deg[i]>=6)return !printf("Yes\n");
        if(deg[i]==4)cnt++;
    }
    if(cnt==2){ 
        for(int i=1;i<=m;i++){
            if(deg[u[i]]==2 && deg[v[i]]==2) par[find(u[i])]=find(v[i]);
        }
        for(int i=1;i<=m;i++){
            if(deg[u[i]]==4 && deg[v[i]]==2) st[find(v[i])].insert(u[i]);
            if(deg[u[i]]==2 && deg[v[i]]==4) st[find(u[i])].insert(v[i]);
        }
        bool ok = 0;
        for(int i=1;i<=n;i++){
            if(st[i].size()==1) ok=1;
        }
        return !printf("%s\n", ok?"Yes":"No");
    }
    printf("%s\n", cnt>=3?"Yes":"No");
}

Measured memory_bytes: 6528
using System;class P{static void Main(){while(1>0){var r=Console.ReadLine().Split();var o=r[1];if(o=="?")break;int a=int.Parse(r[0]),b=int.Parse(r[2]);Console.WriteLine(o=="+"?a+b:o=="-"?a-b:o=="*"?a*b:a/b);}}}


Measured memory_bytes: 15944
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    100256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );
using namespace std;

int n, m, k, i;
string s;
vector < ll > ans;
void solve()
{
    cin >> n >> m >> s;
    while( n > 0 )
    {
        ll j = min( m, n );
        while( s[n - j] == '1' )j --;
        ans.pb( j );
        n -= j;
        if( j <= 0 )
        {
            pr( "-1" );
            rt;
        }
    }
    rev(ans);
    for( ll i: ans )cout << i << " ";
}
int main()
{
    ll tt = 1;
   // sc( "%d", &tt );
    for( ll i = 1; i <= tt; i ++ )
    {
        solve();
    }
}












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

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

  ll D; cin >> D;
  vector<ll> C(26); for (ll i = 0; i < 26; i++) cin >> C[i];
  vector<vector<ll>> S(D, vector<ll>(26, 0));
  for (ll i = 0; i < D; i++) {
    for (ll j = 0; j < 26; j++) {
      cin >> S[i][j];
    }
  }

  ll cnt = 0;
  vector<ll> T(D, 0);
  vector<ll> last(26, 0);

  ll ans = 0;
  for (ll i = 0; i < D; i++) {
    ll t = 0;
    for (ll j = 0; j < 26; j++) {
      if ( S[i][j] + C[j] * (i + 1 - last[j]) > S[i][t] + C[t] * (i + 1 - last[t]) ) t = j;
    }
    T[i] = t;
    ans += S[i][T[i]];
    last[T[i]] = i + 1;
    ll temp = 0;
    for (ll j = 0; j < 26; j++) {
      temp += C[j] * (i + 1 - last[j]);
    }
    ans -= temp;
  }
  for (ll i = 0; i < D; i++) {
    cout << (T[i] + 1) << '\n';
  }
  // cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3740
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;
typedef long long ll;
#define N 100050
int n,a[N],m,p[N],vis[N],b[N],lb;ll X[N],d[N],K,ans[N];
int main() {
	scanf("%d",&n);
	int i,y=0,j;
	for(i=1;i<=n;i++) scanf("%lld",&X[i]),d[i]=X[i]-X[i-1];
	scanf("%d%lld",&m,&K);
	for(i=1;i<=m;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) p[i]=i;
	for(i=1;i<=m;i++) swap(p[a[i]],p[a[i]+1]);
	for(i=1;i<=n;i++) if(!vis[i]) {
		int x=i;lb=0;
		for(;!vis[x];x=p[x]) {
			vis[x]=1;
			b[lb++]=x;
		}
		for(j=0;j<lb;j++) {
			ans[b[j]]=d[b[(j+K)%lb]];
		}
	}
	for(i=1;i<=n;i++) X[i]=ans[i]+X[i-1];
	for(i=1;i<=n;i++) printf("%lld.0\n",X[i]);
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i=1; i<N; i++) {
    int cnt = 0;
    for (char c='a'; c<='z'; c++) {
      bool left = false; bool right = false;
      for (int j=0; j<i; j++) {
        if (S[j] == c) {
          left = true;
        }
      }
      for (int j=i; j<N; j++) {
        if (S[j] == c) {
          right = true;
        }
      }
      if (left&&right) {
        cnt++;
      }
    }
    if (cnt > ans) {
      ans = cnt;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

int main(){
	int N =0;
	scanf("%d",&N);
	if(N<1200)	printf("ABC\n");
	else if(N<2800) printf("ARC\n");
	else printf("AGC");
	
	return 0;
}



Measured memory_bytes: 256
from collections import deque


def main():
    x = input()

    st, cnt = deque(), 0
    for i in range(len(x)):
        if x[i] == "S":
            st.append(i)
        elif len(st) != 0:
            st.pop()
            cnt += 1

    print(len(x)-2*cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7524
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
class UnionFind{
private:
	vector<int> Parent;
public:
	UnionFind(int N){rep(i,N) Parent.push_back(-1);}
	int root(int A){
		if(Parent[A]<0) return A;
		else return root(Parent[A]);
	}
	int size(int A){return -Parent[root(A)];}
	bool connect(int A,int B);
};

signed main(){
    int H,W;
    cin>>H>>W;
    vector<string> C(H);
    rep(i,H) cin>>C[i];
    rep(i,2*H){
    	rep(j,W){
    	    cout<<C[i/2][j];
    	}
    	cout<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

int main(int argc, char const *argv[]) {
    ull N, M;
    cin >> N >> M;

    ull l = 0;
    ull u = (N + M) / 3 + 1;
    while (u - l > 1) {
        ull m = (u + l) / 2;
        // p(l, m, u);
        if (M < m*2 || N + M/2 < m*2) {
            u = m;
            // p("ng");
        } else {
            l = m;
            // p("ok");
        }
    }

    cout << l << endl;

    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
def xor(i):
    if i%4==0:
        m = i
    elif i%4==1:
        m = 1
    elif i%4==2:
        m = 1 ^ i
    else:
        m=0
    return m
print(xor(a-1) ^ xor(b))


Measured memory_bytes: 2940
awk '$0=NR%2FS$NF' RS=\ |sort|uniq -c|sort -nr|awk 's+=$1{$2?a?b||b=$1:(a=$1)>c=$3:d?e||e=$1:(d=$1)>f=$3}END{print s-(c~f?a+e<b+d?b+d:a+e:a+d)}'

Measured memory_bytes: 11676
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const int MAX = 210000;
ll fac[MAX],finv[MAX],inv[MAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n,ll k){
    if(n < 0 || k < 0 || n < k) return 0;
    return fac[n] * finv[n-k] % MOD * finv[k] % MOD;
}

ll pow(ll x,ll k){
    ll res = 1;
    ll y = x;
    while(k){
        if(k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    init();
    ll res = 0;
    ll pa = a * inv[a+b] % MOD;
    ll pb = b * inv[a+b] % MOD;
    // i banme : iCn-1 * (A^n*B^(i-n) + B^n*A(i-n))
    for(int i = n; i <= 2*n - 1; ++i){
        // prob
        ll tmp = comb(i-1,n-1) * (pow(pa,n) * pow(pb,i-n)%MOD + pow(pb,n) * pow(pa,i-n)%MOD)%MOD;
        // exp
        (tmp *= i) %= MOD;
        // add
        (res += tmp) %= MOD;
    }
    cout << res * 100%MOD * inv[a+b]%MOD << endl;
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
long double ff(long double a){
  
  a*=10000.0;
  //  cout<<a<<endl;
  int c = a;
  if(c%10>4)c+=10;
  c/=10;
  return (long double)c/1000.0;
}



long double ax,ay,bx,by,cx,cy,ox,oy,dx,dy,ex,ey;
//ack はACの傾き  eos はEOの切片
long double abk,ack,dok,eok,eos,dos,eps=0.0;
int n;
int main(){
  // cout<<ff(999.9999)<<endl;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    //ABの中点をD,  ACの中点をE 外接円の中心をO とする
    dx=(ax+bx)/2.0;
    dy=(ay+by)/2.0;
    ex=(ax+cx)/2.0;
    ey=(ay+cy)/2.0;
    
    if(ax==bx){
      abk=(ay-by)/0.000000000001;
    }else{
      abk=(ay-by)/(ax-bx);
    }
    if(abk==0.0)abk=0.000000000001;
    dok=-1.0/abk;
    dos=dy-dx*dok;
    
    
    if(ax==cx){
      ack=(ay-cy)/0.000000000001;
    }else{
      ack=(ay-cy)/(ax-cx);
    }
    if(ack==0.0)ack=0.000000000001;
    eok=-1.0/ack;
    eos=ey-ex*eok;
    
    //Y  =  dok X  + dos
    //Y  =  eok X  + eos
    //dok X + dos = eok X + eos
    
    long double Y,X;
    if(dok-eok==0.0){
      X=(eos-dos)/0.000000000001;
    }else{
      X=(eos-dos)/(dok-eok);
    }
    Y= dok * X + dos;
    
    printf("%.3Lf %.3Lf ",X,Y);
    //cout<<ax<<' '<<X<<' '<<ay<<' '<<Y<<endl;
    printf("%.3Lf\n" ,   sqrt( pow(ax-X,2) + pow(ay-Y,2) ));

    
    
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const ll MAX = 200000;
 
ll fact[MAX],finv[MAX];
ll inv(ll x){
    int res = 1;
    int k = MOD - 2;
    ll y = x;
    while(k){
        if(k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k >>= 1;
    }
    return res;
} 
 
int N,M,K;
int main() {
    cin >> N >> M >> K;
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    rep(i,2,MAX) {
        fact[i] = fact[i-1] * i % MOD;
        finv[i] = inv(fact[i]) % MOD;
    }
    ll C = fact[N*M-2] * finv[K-2] % MOD * finv[N*M-K] % MOD;

    ll d = 0;
    // 行の差がd(i=1~N-1)の2点の選び方数 * 2点が選ばれる回数
    // d * (N-d) * M * M
    for(ll i=0; i < N; ++i) (d += (i * (N-i) % MOD * M) % MOD * M % MOD) %= MOD;
 
    // 列
    for(ll i=0; i < M; ++i) (d += (i * (M-i) % MOD * N) % MOD * N % MOD) %= MOD;
 
    cout << d * C % MOD << endl;
 
    return 0;
}

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x=abs(a-b);
  int y=abs(a-c);
  int z=abs(b-c);
  cout<<min({x+y,y+z,z+x})<<endl;
}

Measured memory_bytes: 256
#define s(a)(a)*(a)
M=99;main(n,i,j,k,a,b,c){
	float p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
		for(a=i=0;i<n;a=a>b?a:b,i++)for(b=k=0;k<M;b=b>c?b:c,k++)for(x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M),c=0,j=i;j<n;j++)
			if(s(X[j]-x)+s(Y[j]-y)<1+1e-3)c++;
	}
exit(0);}

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

int main(){
    int A, B;
    string S;
    cin >> A >> B >> S;

    bool ok = true;
    rep(i, A){
        if(isdigit(S[i]) == false) ok = false;
    }
    if(isdigit(S[A])) ok = false;
    repa(i, A+1, A+B){
        if(isdigit(S[i]) == false) ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

ll GetMinValue(ll x, ll k, ll d)
{
	x = abs(x);
	ll n = x / d;
	if (k < n) return x - k * d;
	else {
		if (n % 2 == k % 2) return x - n * d;
		else return min(x - (n - 1) * d, abs(x - (n + 1) * d));
	}
}

int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	if (x == 0) {
		if (k % 2 == 0) cout << 0 << endl;
		else cout << d << endl;
	}
	else cout << GetMinValue(x, k, d) << endl;
}


Measured memory_bytes: 3628
N = str(input())

if len(N) <4:
    print(1000-int(N))
elif len(N) == 5:
    print(10000-int(N))
else:
    n = (1+int(N[0]))*1000 
    if int(N) % 1000 == 0:
      print(0)
    else:
      print(n - int(N))


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  string result = "NG";
  for (int i = A; i <= B; i++)
  {
    if(i % K == 0)
      result = "OK";
  }
  cout << result << endl;
  return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int count = 0;
    for (int i = 0; i < n; i++)
    {

        if (i == n - 1 && a[i] == i + 1)
        {
            int temp = a[i];
            a[i] = a[i - 1];
            a[i - 1] = temp;
            count++;
        }
        else if (a[i] == i + 1)
        {
            int temp = a[i];
            a[i] = a[i + 1];
            a[i + 1] = temp;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
XS = sorted(map(int, input().split()))
DIFFS = []
for i in range(M - 1):
    DIFFS.append(XS[i + 1] - XS[i])

DIFFS.sort()
for i in range(N - 1):
    if DIFFS != []:
        DIFFS.pop(-1)

print(sum(DIFFS))


Measured memory_bytes: 56872
#!/usr/bin/env python3
# N = int(input())
S = input()
# N, A, B = map(int, input().split())
# A = list(map(int, input().split()))
cnt = [0 for i in range(200)]
syurui = []
for s in S:
    syurui.append(s)
    cnt[ord(s)] += 1
for s in syurui:
    if cnt[ord(s)] != 2:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll N,K; cin >> N >> K;
	if(K==0){
		cout << N*N << endl;
		return 0;
	}
	ll ans = 0;
	for(ll b=K+1;b<=N;b++){
		for(ll l=K,r=b;;l+=b,r+=b){
			if(N < l) break;
			ans += min(N+1,r)-l;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define ll long long
#define MAXN 100000
using namespace std;



int Solve(const string& S, int step) {
    
    int ans=0;
    for(int i=0;i<S.size()-2;i++) {
        string nS=S;
        if (S[i]=='1' && S[i+1]=='0' && S[i+2]=='1') {
            nS[i]='0';
            nS[i+1]='1';
            nS[i+2]='0';
            ans=max(ans, 1+Solve(nS, step+1));
        }
    }
    
    return ans;
    
}


int nearest_z[555555];

int dp[555555];

int SolveDp(const string& S) {
    int L=S.size();
    for(int pos=L-1;pos>=0;pos--) {
        if (pos >= L-2) {
            dp[pos]=0;
            continue;
        }
        
        if (S[pos]=='0')
        {
            dp[pos]=dp[pos+1];
            continue;
        }
        
        if (nearest_z[pos]==-1 || nearest_z[pos]>=S.size()-1) {
            dp[pos]=0;
            continue;
        }
        
        if (S[nearest_z[pos]+1]=='0') {
            dp[pos]=dp[nearest_z[pos]+1];
            continue;
        }
        
        int jn=nearest_z[pos]-1;
        
        if (jn == pos) {
            int fz=nearest_z[pos+2];
            if (fz == -1) {
                dp[pos]=S.size()-pos-2;
                continue;
            }
            dp[pos]=max(fz-pos-2+dp[fz],fz-pos-3+dp[fz-1]);
            continue;
        }
        
        
        if (jn > pos) {
            dp[pos]=max(jn-pos+1+dp[jn+3],dp[jn]);
            continue;
        }

    }
    return dp[0];
    
}


int Solve(int pos, const string& S) {
    
    if (pos >= S.size()-2)
        return 0;
    
    if (S[pos]=='0') {
        return Solve(pos+1,S);
    }
    
    
    // nearest_z[pos-1],nearest_z[pos] and nearest_z[pos+1]
    
    
    if (nearest_z[pos]==-1 || nearest_z[pos]>=S.size()-1)
        return 0;
    
    if (S[nearest_z[pos]+1]=='0')
        return Solve(nearest_z[pos]+1, S);
    
    int jn=nearest_z[pos]-1;
    
    
    
    /*int jn=-1;
    for(int j=pos;j+2<=S.size()-1;j++) {
        if (S[j]=='1' && S[j+1]=='0' && S[j+2]=='1') {
            jn=j;
            break;
        }
        if (S[j]=='0')
            return Solve(j+1,S);
    }
    
    if (jn != -1 && jn != nearest_z[pos]-1)
    printf("%d vs %d\n",jn,nearest_z[pos]-1);
     */

    
    if (jn == pos) {
        
        int fz=nearest_z[pos+2];

        if (fz == -1) {
            return S.size()-pos-2;
        }
        
        int ans = max(fz-pos-2+Solve(fz,S),fz-pos-3+Solve(fz-1,S));
        return ans;
        
    }
    
    
    if (jn > pos) {
        return max(jn-pos+1+Solve(jn+3,S),Solve(jn,S));
    }
    
    
    return 0;
}

int main() {

    int L;
    cin>>L;
    
    string S;
    cin>>S;

    
    
    nearest_z[L]=-1;
    for(int j=L-1;j>=0;j--) {
        if (S[j]=='0')
            nearest_z[j]=j;
        else
            nearest_z[j]=nearest_z[j+1];
    }
    
    
    //cout << Solve(S, 0) << endl;
    
    
   // cout << Solve(0, S) << endl;
    
    cout << SolveDp(S) << endl;
    
    
}

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

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << 1 << endl;
  } else {
    ll tb_L = 2;
    ll ob_L = 1;
    ll cur_L = 0;
    for (int i = 2; i <= N; ++i) {
      cur_L = tb_L + ob_L;
      tb_L = ob_L;
      ob_L = cur_L;
    }
    cout << cur_L << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a;

	for (int i = 0; i < 5; i++) {
		scanf("%d", &a);
		if (a == 0) {
			a = i + 1;
			break;
		}
	}

	printf("%d ", a);

	return 0;
}

Measured memory_bytes: 2136
function main (s) {
    s=s.split(" ");
	var c=[0,0];
	for(var i=0;i<3;i++){
		s[i]=parseInt(s[i]);
		if(s[i]==5)c[0]++;
		if(s[i]==7)c[1]++;
	}
	console.log((c[0]==2&&c[1]==1)?"YES":"NO");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define INF 999999999
vector<int>C, D;
int N, M;

vector<vector<int> > memo;

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

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		D.push_back(tmp);
	}
	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		C.push_back(tmp);
	}

	memo = vector<vector<int> >(N, vector <int>(M, INF));

	for (int i = N - 1; i >= 0; i--)for (int j = M - 1; j >= 0; j--) {
		if (i > j)continue;
		if (i == N - 1) {
			memo[i][j] = D[i] * C[j];
		}
		else {
			int a = INF;
			for (int k = i + 1; k < M; k++) {
				if (j < k) {
					if (a > memo[i + 1][k])a = memo[i + 1][k];
				}
			}
			memo[i][j] = a + D[i]*C[j];
		}
	}

	int ans = INF;
	for (int i = 0; i < M; i++) {
		if (ans > memo[0][i])ans = memo[0][i];
	}

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


Measured memory_bytes: 9220
program main
  implicit none
  
  integer :: i, s
  
  read(*,*)s
  if ((s == 4).or.(s == 2)) then
    write(*,*)4
    stop
  endif
  if (s == 1) then
    write(*,*)4
    stop
  endif
  
  do i = 2, 1000000
    if (mod(s,2) == 0) then
      s = s /2
    else
      s = 3*s + 1
    end if
    
    if (s == 4) then
      exit
    endif
  end do
  
  write(*,*)i + 3
end program main

Measured memory_bytes: 256
s = input()
n = len(s)

l = 0
r = 0
ans = 0
for i in range(n):
    if '<' == s[i]:
        if r != 0:
            M = max(l,r)
            m = min(l,r)
            ans += M*(M+1)//2 + m*(m-1)//2
            r = 0
            l = 0
        l += 1
    if '>' == s[i]:
        r += 1

M = max(l,r)
m = min(l,r)
ans += M*(M+1)//2 + m*(m-1)//2
print(ans)

Measured memory_bytes: 9944
s = input()
t = input()
ls = []
for i in range(len(s) - len(t)+1):
    ls.append(s[i:i+len(t)])
ans = 10000
for word in ls:
    tmp = 0
    for j in range(len(word)):
        if word[j] != t[j]:
            tmp += 1
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 67864
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<N;i++){
			long l = C * i - D * (N - 1 - i);
			long r = D * i - C * (N - 1 - i);
			if(InRange(B,A+l,A+r)){
				Console.WriteLine("YES");
				return;
			}
			if(InRange(B,A-r,A-l)){
				Console.WriteLine("YES");
				return;
			}
		
		}
		Console.WriteLine("NO");
		
	}
	
	bool InRange(long t, long l, long r){
		return l <= t && t <= r;
	}
	
	int N;
	long A,B,C,D;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1]; B = d[2]; C = d[3]; D = d[4];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
s = input()
t = input()
no = 0

A = "abcdefghijklmnopqrstuvwxyz"
B = {}
for i in range(26) :
    B[A[i]] = i

S = []
for i in range(len(s)) :
    S.append(B[s[i]])
T = []
for i in range(len(t)) :
    T.append(B[t[i]])
S.sort()
T.sort(reverse=1)
#print(S)
#print(T)
i = 0
while i < len(s) and i < len(t) and S[i] == T[i] :
    i += 1
#print(i)
if i == len(t) and len(s) >= len(t) :
    no = 1
elif i <= len(s)-1 and  S[i] > T[i] :
    no = 1
if no == 1 :
    print("No")
else :
    print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#define str(a) to_string(a)
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define endl "\n"
using namespace std;

std::vector<int> adj[100001];

void rec(vector<bool>&vis, int source, vector<int>&dp) {
	vis[source] = true;
	dp[source] = 0;
	for (int child : adj[source]) {
		if (!vis[child]) {
			rec(vis, child, dp);
		}
		dp[source] = max(dp[source], 1 + dp[child]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m; cin >> n >> m;
	while (m--) {
		int x, y; cin >> x >> y;
		adj[x].pb(y);
	}
	vector<bool> vis(n + 1, false);
	vector<int> dp(n + 1, 0);
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) {
			rec(vis, i, dp);
			mx = max(mx, dp[i]);
		}
	}
	cout << mx << endl;
}


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

int main()
{
	int n;
	while(cin >> n){
		if(n==0)
			break;
		int *n_num = new int[n];
		bool *is_n = new bool[n];
		for(int i=0;i<n;i++){
			is_n[i] = false;
		}
		for(int i=1;i<=(n-1)/2;i++){
			is_n[i*i%n] = true;
		}
		int a=0;
		for(int i=0;i<n;i++){
			if(is_n[i] == true){
				n_num[a++] = i;
			}
		}

		int *n_cou = new int[(n-1)/2+1];
		for(int i=1;i<=(n-1)/2;i++){n_cou[i] = 0;}

		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				int n_mem = (n_num[i]-n_num[j])%n;
				int tmp;
				do{
					tmp = n_mem;
					if(n_mem < 0)
						n_mem += n;
					if(n_mem > (n-1)/2)
						n_mem = n - n_mem;
				}while(tmp != n_mem);
				n_cou[n_mem]++;
			}
		}

		for(int i=1;i<=(n-1)/2;i++){
			cout << n_cou[i] << endl;
		}
		delete[] n_num;
		delete[] n_cou;
	}
	return 0;
}

Measured memory_bytes: 996
#include<bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F;
int water[3005],sugar[3005];
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	water[0]=sugar[0]=1;
	for(int i=1;i<=F;i++){
		if(i>=100*A)water[i]=water[i-100*A];
		if(i>=100*B)water[i]=(water[i]|water[i-100*B]);
		if(i>=C)sugar[i]=sugar[i-C];
		if(i>=D)sugar[i]=(sugar[i]|sugar[i-D]);
	}
	int ansx=100*A;
	int ansy=0;
	for(int x=1;x<=F;x++){
		if(water[x]==1){
			for(int y=0;y<=F-x;y++)if(sugar[y]==1){
				double s=y*1.0/x;
				double t=E*1.0/100;				
				double u=ansy*1.0/ansx;
				if(s<=t&&s>u){
					ansx=x;
					ansy=y;
				}
			}
		}
	}
	cout<<ansx+ansy<<" "<<ansy;
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll x,y; cin >> x >> y;
  
  ll ans = 0;
  
  rep(i,10000000){
    ans++;
    x *= 2;
    if(x > y) break;
  }
  
  cout << ans << endl;
  
  
}

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

int main(){
  int A,B,X;cin>>A>>B>>X;
  if(A>X) cout<<"NO"<<endl;
  else{
    if(A+B>=X) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}


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

int main() {
	long long n, sum;
	cin >> n >> sum;
	long long a[n + 1];
	for(long long i = 1; i <= n; i++) {
        cin >> a[i];
	}
	bool f = false;
	long long pos = -1;
	for(long long i = 1; i < n; i++) {
        if(a[i] + a[i + 1] >= sum) {
            f = true;
            pos = i;
            break;
        }
	}
	if(!f) {
        cout << "Impossible" << endl;
	}
	else {
        cout << "Possible" << endl;
        for(long long i = 1; i < pos; i++) {
            cout << i << endl;
        }
        for(long long i = n - 1; i > pos; i--) {
            cout << i << endl;
        }
        cout << pos << endl;
	}
	return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
using namespace std;
namespace rng {
    using namespace boost;
    using namespace boost::range;
}
constexpr char nl = '\n';
template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> AS(N, vector<int>(M));
    cin >> B >> AS;
    cout << rng::count_if(AS, [&](auto& A){ return rng::inner_product(A, B, C) > 0; }) << nl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H, W;

    for (int i = 0;; i++) {
      H = sc.nextInt();
      W = sc.nextInt();
      if (H == 0 && W == 0) break;
      for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
          System.out.printf("#");
        }
        System.out.printf("\n");
      }
      System.out.printf("\n");
    }

    sc.close();
  }
}



Measured memory_bytes: 63052
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

int main()
{
	vector <int> common_divisors;

	int a,b,k;
	cin >> a >> b >> k;

	for (int i = 1; i <= min(a,b); ++i)
	{
		if (a%i == 0 && b%i == 0)
		{
			common_divisors.pb(i);
		}
	}
	int size = common_divisors.size() - k;
	cout << common_divisors[size];
	
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}


signed main(){
	IOS
	int n;	cin >> n;
	map<string, int> m;
	rep(i,n){
		string s;	cin >> s;
		m[s]++;
	}
	vector<pair<int,string>> vec;
	for(auto i:m){
		pair<int,string> p = {i.S, i.F};
		vec.pb(p);
	}
	sort(vec.begin(), vec.end(), greater<pair<int,string>>());
	int ans = vec[0].F;
	vector<string> print;
	rep(i,SZ(vec)){
		if(vec[i].F == ans){
			print.pb(vec[i].S);
		}
		else	break;
	}
	rep(i,SZ(print))	cout << print[SZ(print) - 1 - i] << '\n';
}

Measured memory_bytes: 31468
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

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

const ll INF = 1e18;

//#####################
//Dijkstra
//#####################
struct edge
{
    int to, cost;
};

int n;
vector<edge> g[112345];
ll dis[112345];

void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(dis, dis + n + 1, INF);
    dis[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int n_ = p.second;
        if (dis[n_] < p.first)
            continue;
        for (int i = 0; i < g[n_].size(); i++)
        {
            edge e = g[n_][i];
            if (dis[e.to] > dis[n_] + e.cost)
            {
                dis[e.to] = dis[n_] + e.cost;
                que.push(P(dis[e.to], e.to));
            }
        }
    }
}

int main()
{
    int q, k;
    cin >> n;

    REP(i, n - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;

        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    cin >> q >> k;

    int x[112345];
    int y[112345];

    REP(i, q)
    {
        cin >> x[i] >> y[i];
    }

    dijkstra(k);

    REP(i, q)
    {
        cout << dis[x[i]] + dis[y[i]] << endl;
    }

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  int ans = 0;
  bool flag = true;
  while(flag) {
    for(int i = 0; i < N; i++) {
      if(A[i] % 2 != 0) {
        flag = false;
        break;
      }
      A[i] /= 2;
    }
    if(flag) { ans++; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    long long W, H, x, y;
    std::cin >> W >> H >> x >> y;

    double max = (double)(W * H / 2);
    if (W * H % 2 == 1) {
        max += 0.5;
    }

    int has_multiple = 0;
    if (2 * x == W && 2 * y == H) {
        has_multiple = 1;
    }

    std::cout << max << " " << has_multiple << "\n";
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- map read.words <$> getLine :: IO [Int]
    let f t = case splitAt t xs of
         (xs1@(_:_), xs2@(_:_)) -> abs $ sum xs1 - sum xs2
    print . minimum $ map f [1..n-1]


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 1020