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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 059_arc_b / Link: https://abc043.contest.atcoder.jp/tasks/arc059_b?lang=en  ----- */
/* ------問題------

文字列 t について、t の長さが 2 以上であり、かつ t の中の文字のうち過半数が同じ文字であるとき、t をアンバランスであると呼ぶことにします。例えば、voodoo や melee はアンバランスであり、noon や a はアンバランスではありません。
小文字のアルファベットからなる文字列 s が与えられます。s にアンバランスな (連続する) 部分文字列が存在するか判定してください。存在する場合は、s の中でそのような部分文字列が存在する位置を一つ示してください。

-----問題ここまで----- */
/* -----解説等-----

例えば長さ4のアンバランスな文字列があったとき、この中には長さ2か3のアンバランスな文字列を含んでいる。
同様にアンバランスな文字列の中には2,3の長さのアンバランスな文字列が含まれているのでこれを判定するだけでよい。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s;
	cin >> s;

	FOR(i, 0, SZ(s) - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	FOR(i, 0, SZ(s) - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


lis = [e,d,c,b,a]
lis2 = [a,b,c,d,e]

yay_flg = 0
exist_flg = 0

for x in lis:
  for j in lis2:
    if x == j:
      break
      
    if x - j <= k:
      yay_flg = 1
      
    if x - j > k:
      exist_flg = 1
      
if yay_flg == 1 and exist_flg == 0:
  print("Yay!")
  
else:
  print(":(")


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

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

int dist[100005][3];

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int> > to(n);
    rep(i,m)
    {
        int u,v;
        cin >> u >> v;
        u--; v--;
        to[u].push_back(v);
    }
    int s,t;
    cin >> s >> t;
    s--; t--;

    rep(i,100005)
    {
        rep(j,3)
        {
            dist[i][j] = INF;
        }
    }
    queue<P> q;
    q.push(P(s,0));
    dist[s][0] = 0;
    while(!q.empty())
    {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (auto u : to[v])
        {
            int nl = (l+1)%3;
            if (dist[u][nl] != INF)continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u,nl));
        }
    }
    int ans = dist[t][0];
    if (ans == INF)
    {
        ans = -1;
    }else
    {
        ans /=3;
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 6912
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int a, b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		long K=stdIn.nextLong();
		long A=stdIn.nextLong();
		long B=stdIn.nextLong();
		int z=0;
		if(B-A>2){
			K-=A-1;
			if(K%2==1)
				System.out.println((K/2)*(B-A)+1+A);
			else
				System.out.println((K/2)*(B-A)+A);
		}
		else
			System.out.println(1+K);
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            System.out.println(solve(in.nextInt()));
        }
    }
    static int solve(int n){
        int res = 0;
        for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k=0;k<10;k++)for(int l=0;l<10;l++){
            res += (i+j+k+l == n) ? 1 : 0;
        }
        return res;
    }

}

Measured memory_bytes: 19304
//small,large or equal

#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a<b)
  cout<<"a < b"<<endl;
else if(a>b)
  cout<<"a > b"<<endl;
else if(a==b)
  cout<<"a == b"<<endl;

return 0;
}

Measured memory_bytes: 1160
<?php
// ini_set("memory_limit", "-1");
fscanf(STDIN, "%d", $count);

$koch_arr = [];

if ($count == 0) {
    $koch_arr[] = [0, 0];
    $koch_arr[] = [100,0];
    foreach ($koch_arr as $koch) {
        echo implode(" ", $koch). "\n";
    }
    
    return;
}

koch([0,0], [100,0], $count);
echo "100 0\n";



function koch($p1, $p2, $count) {
    global $koch_arr;
    
    $s = [$p1[0]+($p2[0]-$p1[0])/3, $p1[1]+($p2[1]-$p1[1])/3];
    $t = [$p2[0]-($p2[0]-$p1[0])/3, $p2[1]-($p2[1]-$p1[1])/3];
    $u = [$s[0]+($t[0]-$s[0])/2-($t[1]-$s[1])*sqrt(3)/2, $s[1]+($t[0]-$s[0])*sqrt(3)/2+($t[1]-$s[1])/2];

    
    if ($count <= 1) {
        print_arr($p1);
        print_arr($s);
        print_arr($u);
        print_arr($t);
    } else {
        koch($p1, $s, $count-1);
        koch($s, $u, $count-1);
        koch($u, $t, $count-1);
        koch($t, $p2, $count-1);
    }
    
}


function print_arr($arr) {
    echo $arr[0], " ", $arr[1], "\n";
}


Measured memory_bytes: 9300
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn gcd(a:usize, b:usize) -> usize {
   match b {
      0 => a,
      _ => gcd(b, a%b),
   }
}


fn main() {
   input! {
      n: usize,
      t: [usize; n],
   }
   let mut ans = 1;
   for t in t {
      ans /= gcd(ans, t) ;
      ans *= t;
   }
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  vector<ll> pa(a);
  vector<ll> qb(b);
  vector<ll> rc(c);
  ll ans=0;
  rep(i,a) cin>>pa[i];
  rep(i,b) cin>>qb[i];
  rep(i,c) cin>>rc[i];
  sort(pa.begin(),pa.end(),greater<ll>());
  sort(qb.begin(),qb.end(),greater<ll>());
  sort(rc.begin(),rc.end(),greater<ll>());
  vector<ll> v(x+y+c);
  rep(i,x){
    v[i]=pa[i];
  }
  rep(i,y){
    v[x+i]=qb[i];
  }
  rep(i,c){
    v[x+y+i]=rc[i];
  }
  sort(v.begin(),v.end(),greater<ll>());
  rep(i,x+y){
    ans+=v[i];
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin>>n;
    
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    int idx=0;
    vector<bool> bb(n, false);
    bb[0]=true;
    
    bool ok=false;
    
    int cnt=0;
    
    int cntloop=0;
    
    while(1){
        
        if(cntloop>1000000){
            ok=false;
            break;
        }
        
        if(bb[idx]){
            bb[idx]=false;
            idx=a[idx]-1;
            bb[idx]=true;
            cnt++;
        }else{
            ok=false;
            break;
        }
        
        if(bb[idx]&&idx==1){
            ok=true;
            break;
        }
        
        cntloop++;
    }
    
    if(ok){
        cout<<cnt<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

int main(){
	string s;
	while(getline(cin,s)){
		replace(s.begin(),s.end(),',',' ');
		replace(s.begin(),s.end(),'.',' ');
		istringstream iss(s);
		set<string> st;
		string b;
		int i = 0;
		while(iss>>b) if(b.size() >= 3 && b.size() <= 6){
			if(i != 0)
				cout << " ";
			cout << b;
			i++;
		}
		puts("");
	}
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std;

int main(){
    int ar[3][3],a[3],b[3];
    pan(i,3)
        pan(j,3) cin>>ar[i][j];
    int ans=false;
    a[0]=0;
    pan(i,3) b[i]=ar[0][i];
    for(int i=1;i<3;i++) a[i]=ar[i][i]-b[i];
    pan(i,3)
        pan(j,3){
            if(ar[i][j]==a[i]+b[j]) ans++;
        }
    if(ans==9) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	ios::sync_with_stdio(false);

	int c, d, w, x;
	while (cin >> c >> d >> w >> x, c)
	{
		int e[32][16], f[32][16];
		for (int i = 0; i < c; ++i)
			for (int j = 0; j < d; ++j)
				cin >> e[j][i];
		for (int i = 0; i < c; ++i)
			for (int j = 0; j < d; ++j)
				cin >> f[j][i];

		static int dp[32][64][6];	// d, w, x;
		CLEAR(dp, 0);

		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j <= w; ++j)
			{
				for (int k = 0; k <= x; ++k)
				{
					max_swap(dp[i + 1][j][k], dp[i][j][k]);

					for (int p = 0; p < c; ++p)
					{
						if (e[i][p] == 0 || j + f[i][p] > w)
							continue;

						int nj = j + f[i][p];
						max_swap(dp[i + 1][nj][k], dp[i][j][k] + e[i][p]);


						if (k == x)
							continue;

						int sum_e = e[i][p];
						for (int q = p + 1; q < c && e[i][q] > 0 && nj + f[i][q] <= w; ++q)
						{
							sum_e += e[i][q];
							nj += f[i][q];
							max_swap(dp[i + 1][nj][k + 1], dp[i][j][k] + sum_e);
						}
					}
				}
			}
		}

		int res = -1;
		cout << dp[d][w][x] << endl;
	}
}

Measured memory_bytes: 0
n,m=map(int,input().split())
h=list(map(int,input().split()))
A=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    A[a].append(b)
    A[b].append(a)

s=0
for x in range(1,n+1):
    if A[x]==[]:s+=1
    else:
        f=True
        for y in A[x]:
            if h[x-1]<=h[y-1]:f=False
        if f==True:s+=1
print(s)



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

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>

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

    ll large = max(n - x, x);
    ll small = min(n - x ,x);
    ll t = n;
    while(large != small)
    {
        ll v = large / small;
        if(large % small == 0)
        {
            t += (v-1) * 2 * small + small;
            cout << t << endl;
            return 0;
        }
        t += v * small * 2;
        ll tmp = large - small * v;
        large = small;
        small = tmp;
    }
    cout << t + small << endl;
    return 0;
}

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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL sumOfDigits(LL n)
{
  LL sum = 0;
  while(0 < n)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

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

int x;

void input()
{
  cin >> x;
}

void solve()
{
  if(x == 7 || x == 5 || x == 3) cout << "YES";
  else cout << "NO";
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main () {
    char x[1001];

    while (true) {
        scanf("%s", x);

        if (x[0] == '0') break;

        int sum = 0;
        for (int i = 0; i < strlen(x); i++) {
            sum += (x[i] - '0');
        }

        cout << sum << endl;
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << b * 2 - 1 << endl;
	}
	if (a > b) {
		cout << a * 2 - 1 << endl;
	}
	if (a == b) {
		cout << a * 2 << endl;
	}
}

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

int main(){
    
    // 1. 入力情報.
    char c[20];
    scanf("%s", c);
    int l = strlen(c);
    
    // 2. 判定.
    bool ok = false;
    if(l >= 4 && c[0] == 'Y' && c[1] == 'A' && c[2] == 'K' && c[3] == 'I') ok = true;
    
    // 3. 出力.
    if(ok) printf("%s\n", "Yes");
    else   printf("%s\n", "No");
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x;
    if(b>n) x = n;
    else x = b-1;
    //cout << x << endl;
    ll A = (a*x)/b;
    ll B = x/b;
    ll ans = A-a*B;
    //cout << A << " " << B << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import math
import itertools

n = input()
n = int(n)
nlist = []
for i in range(0,n):
    nlist.append(input().split())

#nの階上
njunretu = []
for i in range(0,n):
    njunretu.append(i)

#全ての順列が求まった
jlist = list(itertools.permutations(njunretu,n))

result = 0
for i in range(0,len(jlist)):
    for j in range(0,n-1):
        f = jlist[i][j]
        l = jlist[i][j+1]
        result += math.sqrt(((int(nlist[f][0]) - int(nlist[l][0]))**2) + ((int(nlist[f][1]) - int(nlist[l][1]))**2))

print(result / len(jlist))

Measured memory_bytes: 10100
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	double x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
	bool X_FLG,Y_FLG;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xp,&yp)!=EOF){
		X_FLG = false,Y_FLG = false;

		if(y1 == y2){
			X_FLG = true;
		}else if(x1 == x2){
			Y_FLG = true;
		}else{
			slope = (y2-y1)/(x2-x1);
		}

		if(X_FLG){
			ansx = xp,ansy=y1;
			printf("%.6lf %.6lf\n",2*ansx-xp,2*ansy-yp);
		}else if(Y_FLG){
			ansx = x1,ansy = yp;
			printf("%.6lf %.6lf\n",2*ansx-xp,2*ansy-yp);
		}else{
			ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
			printf("%.6lf %.6lf\n",2*ansx-xp,2*ansy-yp);
		}

	}
	return 0;
}

Measured memory_bytes: 2592
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 2005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll h,w,i,j, dl[mx][mx], dr[mx][mx], du[mx][mx], dd[mx][mx];
	char s[mx][mx];
	cin>>h>>w;
	for(i=1; i<=h ; i++)
	for(j=1; j<=w; j++)
	cin>>s[i][j];
	
	for(i=1; i<=h ; i++)
	{
	    for(j=1; j<=w; j++)
	    {
	       if(s[i][j]=='#')
	       dl[i][j]= 0;
	       else
	       dl[i][j]= dl[i][j-1]+1;
	       
	    }
	}
	
	for(i=h; i>0; i--){
	    
	    for(j=w; j>0; j--){
	        if(s[i][j]=='#')
	        dr[i][j]= 0;
	        else
	        dr[i][j]= dr[i][j+1]+1;
	        
	    }
	}
	
	for(i=1; i<=w; i++){
	    
	    for(j=1; j<=h; j++){
	        if(s[j][i]=='#')
	        du[j][i]= 0;
	        else
	        du[j][i]= du[j-1][i]+1;
	    }
	}
	
	for(i=w; i>0; i--){
	    
	    for(j=h; j>0; j--){
	        if(s[j][i]=='#')
	        dd[j][i]= 0;
	        else
	        dd[j][i]= dd[j+1][i]+1;
	    }
	}
	
	ll ans=0, an;
	for(i=1; i<=h; i++){
	    
	    for(j=1; j<=w; j++){
	    	if(s[i][j]=='.'){
	        ll kk= dl[i][j-1] + dr[i][j+1] + du[i-1][j] + dd[i+1][j] +1;
	        if(kk> ans)
	        {
	        	ans= kk;
	        	//an= j;
	        }
	    	}
	    }
	}
	cout<<ans;//<<" "<<an;
    return 0;
}























Measured memory_bytes: 129792
memo = {}
def dfs(N, K, S):
    key = (N, K, S)
    if key in memo:
        return memo[key]
    if N == 0:
        return S == K == 0
    r = dfs(N-1, K, S)
    if S >= N:
        r += dfs(N-1, K-1, S-N)
    memo[key] = r
    return r

ans = []
while 1:
    N, K, S = map(int, input().split())
    if N == 0:
        break
    ans.append(dfs(N, K, S))
print(*ans, sep='\n')


Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define YN(c) (c)?(print("YES")):(print("NO"))
#define Yn(c) (c)?(print("Yes")):(print("No"))
#define yn(c) (c)?(print("yes")):(print("no"))
#define in(v) int v; cin >> v
#define din(v) double v;cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  in(n);in(k);
  vector<double> p(n),exp(n+1,0);
  rep(i,n){
  	double x;
  	cin >> x;
  	p[i]=(x+1)/2;
  	exp[i+1]=exp[i]+p[i];
  }
  double ans=0;
  rep(i,n-k+1){
  	ans=max(ans,exp[i+k]-exp[i]);
  }
  cout << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fly ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define ll long long

const ll mxm = 100010;

using namespace std;

ll a[mxm][4];
ll n;
ll dp[mxm][4];

ll fnc(ll i, ll old){
  if(i == n){
    return 0;
  }else{
    if(dp[i][old] != -1)return dp[i][old];
    ll res1 = 0;
    for(ll j = 1;j<=3;j++){
      if(old != j)
        res1 = max(res1, a[i][j] + fnc(i+1,j));
    }
    return dp[i][old] = res1;
  }
}


int main(int argc, char const *argv[]) {
  fly;
  cin >> n;
  for(int i = 0;i<n;i++){
    cin >> a[i][1] >> a[i][2] >> a[i][3];
  }
  memset(dp,-1,sizeof(dp));
  cout << fnc(0,0) << endl;
  return 0;
}


Measured memory_bytes: 17680
Q = int(input())

from heapq import *

lows = []
highs = []

a = []
b = 0
r = 0

for i in range(Q):
    vs = [int(_) for _ in input().split()]
    if vs[0] == 1:
        b += vs[2]
        if not lows:
            x = vs[1]
            heappush(lows, -x)
        else:
            r += abs(vs[1] + lows[0])
            if vs[1] <= -lows[0]:
                heappush(lows, -vs[1])
            else:
                heappush(highs, vs[1])

        if len(lows) < len(highs):
            x = heappop(highs)
            y = -lows[0]
            r += y - x
            heappush(lows, -x)
        elif len(lows) > len(highs) + 1:
            x = -heappop(lows)
            y = highs[0] if len(highs) else 0
            heappush(highs, x)
            # r += x - y

        # print("center", -lows[0], r, lows, highs)

    else:
        print(-lows[0], r + b)


Measured memory_bytes: 11164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,ml,mh,a[200005],b[200005];
int main() {
	n=read();
	for(int i=0;i<n;i++)
		a[i]=read(),b[i]=read();
	sort(a,a+n),sort(b,b+n);
	ml=a[n/2],mh=b[n/2];
	if(n%2==0){
		ml+=a[n/2-1];
		mh+=b[n/2-1];
	}
	cout << mh-ml+1;
	return 0;
}

Measured memory_bytes: 5204
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=2e5+15;
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

vector<int>adj[N];
int h[N];
ll ans=0;
priority_queue<int,vector<int>,greater<int> >q;
vector<pair<int,int> >L,R;

int main()
{
    Nitroboost;
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
     cout<<"WA x "<<mp["WA"]<<"\n";
      cout<<"TLE x "<<mp["TLE"]<<"\n";
       cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 8372
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> A = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);

		int q = sc.nextInt();
			for (int i = 0; i < q; i++) {


				switch (Integer.parseInt(sc.next())) {
				case 0:
					A.add(Integer.parseInt(sc.next()));
					break;
				case 1:
					System.out.println(A.get(Integer.parseInt(sc.next())));
					break;
				case 2:
					A.remove(A.size() - 1);
					break;
				}
 			}
		sc.close();
	}
}



Measured memory_bytes: 123012
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
map<string, int> m;
int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 1 && y == 1)
    ans += 400000;
  if (x == 1)
    ans += 300000;
  else if (x == 2)
    ans += 200000;
  else if (x == 3)
    ans += 100000;
  if (y == 1)
    ans += 300000;
  else if (y == 2)
    ans += 200000;
  else if (y == 3)
    ans += 100000;
  cout << ans << endl;
}

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

long long x;
bool y[32];

int main() {
    cin >> x;
    for (int i=0; i<32; i++) {
        y[31-i] = x%2;
        x/=2;
    }
    for (int i=0; i<32; i++) cout << y[i];
    cout << endl;
    for (int i=0; i<32; i++) y[i] = 1 - y[i];
    for (int i=0; i<32; i++) cout << y[i];
    cout << endl;
    for (int i=0; i<32; i++) y[i] = 1 - y[i];
    for (int i=1; i<32; i++) cout << y[i];
    cout << 0 << endl << 0;
    for (int i=0; i<31; i++) cout << y[i];
    cout << endl;
}


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

int i,j,k;
vector<ll> sum;

//累積和/////////////////////////////////////////////////////////////////
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n;cin>>n;
    vector<ll> length(n);//棒の長さ
    for(i=0;i<n;i++){cin>>length[i];}
    
    sort(length.begin(),length.end());//降順sort

    pre_process(length,sum);//累積和の作成

    ll ans=0;
    int number;
    for(i=n-1;i>=2;i--){
        for(j=i-1;j>=1;j--){
            //binary search
            number=length[i]-length[j];
            int key;
            vector<long long int>::iterator position;
            position=upper_bound(length.begin(),length.begin()+j,number);
            key=distance(length.begin(),position);
            ans+=(j-key);
        }
    }

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

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

int main()
{
  int x, len;
  cin >> x >> len;
  if (len == 0)
  {
    cout << x << endl;
    exit(0);
  }
  vector<int> p(len);
  for (int i = 0; i < len; i++)
  {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = -100;
  int diff = 1000000000;
  for (int i = p.at(0) - 1; i <= p.at(p.size() - 1) + 1; i++)
  {
    if (find(p.begin(), p.end(), i) != p.end())
    {
      continue;
    }
    int now_diff = abs(x - i);
    if (now_diff < diff)
    {
      diff = now_diff;
      ans = i;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

ll dp[110][110000];
ll v[110];
ll w[110];

int main()
{
    ll N, W;
    cin >> N >> W;
    rep(i, 0, N) cin >> w[i] >> v[i];

    rep(i, 0, 110) rep(j, 0, 110000) dp[i][j] = INF;

    dp[0][0] = 0;

    rep(i, 0, N)
    {
        rep(sum_v, 0, 110000)
        {
            if (sum_v - v[i] >= 0)
            {
                chmin(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i]);
            }
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    ll res = 0;
    rep(sum_v, 0, 110000)
    {
        if (dp[N][sum_v] <= W)
        {
            res = sum_v;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 94720
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)

	var r int
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++{
				r += gcd(gcd(a, b), c)
			}
		}
	}
	fmt.Println(r)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

Measured memory_bytes: 1776
#include <stdio.h>
int main(void)
{
  int m[10];
  int i,j,temp;
  for (i=0;i!=10;i++)
    {
      scanf("%d",&m[i]);
    }
  for (i=0;i!=9;i++)
    {
      for (j=9;j!=i;j--)
	{
	  if (m[j-1]>m[j])
	    {
	      temp=m[j];
	      m[j]=m[j-1];
	      m[j-1]=temp;
	    }
	}
    }
  printf("%d\n%d\n%d\n",m[9],m[8],m[7]);
  return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))
flg = 1
for i in A:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 !=0:
            flg = 0
            break

if flg == 1:
    print("APPROVED")
else:
    print("DENIED")

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a == b) {
    cout << "Draw" << endl;
  }else if((a > b && b != 1) || a == 1){
    cout << "Alice" << endl;
  }else if((a < b && a!=1) || b == 1){
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,t = gets.chomp.split.map(&:to_i)
rs = n.times.map{gets.chomp.split.map(&:to_i)}.sort_by(&:first)
ans = "TLE"
rs.each do |r|
  if r[1] <= t
    ans = r[0].to_s
    break
  end
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  long double n,m,d;
  cin>>n>>m>>d;
  long double ans=(m-1.0)*2*(n-d)/(n*n);
  if(d==0.0) ans/=2.0;
  cout<<fixed<<setprecision(7)<<ans<<endl;
  return 0;
}


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

#define pb push_back
#define ff first
#define ss second

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

ll n, x;

ll f(ll a, ll b) {
	cerr << a << ' ' << b << endl;
	if (a % b == 0 || b % a == 0)
		return 2 * min(a, b) * (max(a, b) / min(a, b)) - min(a, b);
	if (a < b)
		return f(a, b % a) + 2 * a * (b / a);
	else
		return f(a % b, b) + 2 * b * (a / b);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x;
	cout << f(x, n - x) + n << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    char c[110];
    for(int i=0; i<s.size(); i++){
        c[i] = s[i];
    }
    sort(c, c+s.size());
    bool isok = true;
    for(int i=0; i<s.size(); i+=2){
        if(c[i]!=c[i+1]){
            isok = false;
            break;
        }
    }
    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

inline int read(){
    int a = 0;
    char c = getchar();
    while(!isdigit(c)) c = getchar();
    while(isdigit(c)){
        a = a * 10 + c - 48;
        c = getchar();
    }
    return a;
}

const int MAXN = 1e5 + 7;
struct Edge{
    int end , upEd;
}Ed[MAXN << 1];
int head[MAXN] , N , M , cntEd;
bool vis[MAXN];

inline void addEd(int a , int b){
    Ed[++cntEd].end = b;
    Ed[cntEd].upEd = head[a];
    head[a] = cntEd;
}

int ans;

int dfs(int x){
    vis[x] = 1;
    int col = 0 , more = 0;
    for(int i = head[x] ; i ; i = Ed[i].upEd)
        if(!vis[Ed[i].end]){
            int t = dfs(Ed[i].end);
            if(t > 0) more += t;
            else col -= t;
        }
    ans += more + col;
    return col - more - 1;
}

namespace solveTree{
    void main(){
        if(dfs(1))
            cout << "-1";
        else
            cout << ans;
    }
}

namespace solveCir{
    vector < int > cir , val;
    int find(int x , int p){
        vis[x] = 1;
        for(int i = head[x] ; i ; i = Ed[i].upEd)
            if(Ed[i].end != p)
                if(vis[Ed[i].end]){
                    cir.push_back(x);
                    return Ed[i].end;
                }
                else{
                    int t = find(Ed[i].end , x);
                    if(t){
                        cir.push_back(x);
                        return x == t ? 0 : t;
                    }
                }
        vis[x] = 0;
        return 0;
    }

    inline int abss(int x){return x < 0 ? -x : x;}
    
    void main(){
        find(1 , 0);
        for(auto t : cir)
            val.push_back(-dfs(t));
        int sum = 0;
        for(auto t : val)
            sum += t;
        if(sum & 1){puts("-1"); return;}
        sum >>= 1;
        if(cir.size() & 1){
            for(int i = 0 ; i + 1 < cir.size() ; i += 2)
                sum -= val[i];
            ans += abss(sum);
            for(int i = (int)val.size() - 2 ; i >= 0 ; --i){
                sum = val[i] - sum;
                ans += abss(sum);
            }
        }
        else{
            int cur = 0;
            for(auto t : val)
                cur = t - cur;
            if(cur){puts("-1"); return;}
            vector < int > now;
            now.push_back(0);
            cur = 0;
            bool f = 0;
            for(int i = (int)val.size() - 2 ; i >= 0 ; --i){
                cur = val[i] - cur;
                now.push_back(f ? -cur : cur);
                f ^= 1;
            }
            sort(now.begin() , now.end());
            int mid = now[((int)now.size() - 1) >> 1];
            for(auto t : now)
                ans += abss(mid - t);
        }
        cout << ans;
    }
}

signed main() {
    N = read();
    M = read();
    for(int i = 1 ; i <= M ; ++i){
        int a = read() , b = read();
        addEd(a , b);
        addEd(b , a);
    }
    if(M == N - 1)
        solveTree::main();
    else
        solveCir::main();
    return 0;
}

Measured memory_bytes: 8568
#include <iostream>
#include <utility>
#include <math.h>
using namespace std;

double th = M_PI * 60.0 / 180.0;

void koch(int d, pair<double, double> p1, pair<double, double> p2) {
  if (d == 0) return;

  pair<double, double> s = make_pair(((2.0 * p1.first) + (1.0 * p2.first)) / 3.0, ((2.0 * p1.second) + (1.0 * p2.second)) / 3.0);
  pair<double, double> t = make_pair(((1.0 * p1.first) + (2.0 * p2.first)) / 3.0, ((1.0 * p1.second) + (2.0 * p2.second)) / 3.0);
  pair<double, double> u;
  u.first = s.first + (t.first - s.first) * cos(th) - (t.second - s.second) * sin(th);
  u.second = s.second + (t.first - s.first) * sin(th) + (t.second - s.second) * cos(th);

  koch(d-1, p1, s);
  cout << s.first << " " << s.second << endl;
  koch(d-1, s, u);
  cout << u.first << " " << u.second << endl;
  koch(d-1, u, t);
  cout << t.first << " " << t.second << endl;
  koch(d-1, t, p2);
}

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

  pair<double, double> a = make_pair(0.0, 0.0);
  pair<double, double> b = make_pair(100.0, 0.0);
  cout << a.first << " " << a.second << endl;
  koch(n, a, b);
  cout << b.first << " " << b.second << endl;
  return 0;
}



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

UL N; ULL W;
pair<ULL,ULL> V[100000];

bool vCmp(const pair<ULL,ULL>& l,const pair<ULL,ULL>& r){
 return l.first*r.second > l.second*r.first;
}

int main(){
 scanf("%u%llu",&N,&W);
 rep(i,N) scanf("%llu%llu",&V[i].first,&V[i].second);
 sort(V,V+N,vCmp);

 ULL ans=0;
 double small=0;
 rep(i,N){
  if(W < V[i].second){
   ans += V[i].first * W / V[i].second;
   small += double(V[i].first * W % V[i].second) / V[i].second;
   W=0;
   break;
  }
  else{
   ans += V[i].first;
   W-=V[i].second;
  }
  ans += floor(small);
  small -= floor(small);
 }
 printf("%llu",ans);
 printf(".");
 rep(i,10){
  UL ans=floor(small*10.0);
  small=small*10-ans;
  printf("%u",ans);
 }
 printf("\n");
 return 0;
}



Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> a,b,c,d;

long long score(const vector<int>& A){
  long long res=0;
  for(int i=0; i<q; ++i) if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
  return res;
}

long long dfs(vector<int>& A){
  if(A.size()==n) return score(A);
  
  long long res=0;
  int start=(A.empty()? 0 : A.back());
  
  for(int j=start; j<m; ++j){
    A.push_back(j);
    res = max(res,dfs(A));
    A.pop_back();
  }
  return res;
}

int main(void){
  cin>>n>>m>>q;
  a.resize(q);b.resize(q);c.resize(q);d.resize(q);
  for(int i=0; i<q; ++i){ cin>>a[i]>>b[i]>>c[i]>>d[i]; --a[i];--b[i];}
  vector<int> A;
  cout<<dfs(A)<<endl;
  return 0;
}


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

int main() {
  int n;
  int key[100];
  string s;
  
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) cin >> key[i];
    cin >> s;
    
    for(int i = 0; i < s.length(); i++) {
      int temp = key[i%n];
      while(temp--) {
	if(s[i] == 'a') s[i] = 'Z';
	else if(s[i] == 'A') s[i] = 'z';
	else s[i]--;
      }
    }

    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
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<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,Q;
int a[200010];
int front[200010];
int cover[200010];
int covered;

void add(int x){
	int n = front[x]-1;
	if(n>0){
		if(cover[n]==0) covered++;
		cover[n]++;
	}
	front[x]--;
}
void erase(int x){
	int n = front[x];
	if(n>0){
		cover[n]--;
		if(cover[n]==0) covered--;
	}
	front[x]++;
}

int main(){
	cin>>N>>Q;
	rep1(i,N) front[i] = i+1;
	rep(i,N){
		cin>>a[i];
		add(a[i]);
	}
	rep(t,Q){
		int x,v;
		cin>>x>>v;
		x--;
		int pv = a[x];
		erase(pv);
		add(v);
		a[x] = v;
		cout<<N-covered<<endl;
	}
}


Measured memory_bytes: 3840
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, k;
vvi mat;

vvi mul(vvi a, vvi b) {
	vvi tmat;
	tmat.resize(n, vi(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			for(int k = 0; k < n; k++) {
				tmat[i][j] += (a[i][k]*b[k][j])%mod;
				while(tmat[i][j] >= mod)
					tmat[i][j] -= mod;
			}
	return tmat;
}

vvi bp(vvi mat, ll p) {
	if(p == 1)
		return mat;
	if(p&1) {
		vvi t = bp(mat, p-1);
		vvi t2 =  mul(t, mat);
		return t2;
	}
	vvi t = mul(mat, mat);
	t = bp(t, p>>1);
	return t;
}

int main() {
	doin();
	cin >> n >> k;
	mat.resize(n, vi(n));
	for(auto& i : mat)
		for(auto& j : i)
			cin >> j;
	mat = bp(mat, k);
	ll ans = 0;
	for(auto& i : mat)
		for(auto& j : i) {
			ans += j;
			if(ans >= mod)
				ans -= mod;
		}
	cout << ans;
}


Measured memory_bytes: 4096
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

int W, H, ans, cnt, turn;
int table[25][25];
P curr, goal;

bool check(int x, int y){
  return (0 <= x && x < H && 0 <= y && y < W);
}

void solve(P point){
  if(turn != 11){
    turn++;
    int x = point.first, y = point.second;
    int t = table[x+1][y];
    if(t == 0 || t == 3){
      FOR(i, x+1, H){
	if(table[i][y] == 3 && turn < cnt){
	  cnt = turn;
	  break;
	}
	if(table[i][y]==1){
	  table[i][y] = 0;
	  solve(make_pair(i-1,y));
	  table[i][y] = 1;
	  break;
	}
      }
    }

    t = table[x-1][y];
    if(t == 0 || t == 3){
      ROF(i, x-1, 0){
	if(table[i][y] == 3 && turn < cnt){
	  cnt = turn;
	  break;
	}
	if(table[i][y]==1){
	  table[i][y] = 0;
	  solve(make_pair(i+1,y));
	  table[i][y] = 1;
	  break;
	}
      }
    }

    t = table[x][y+1];
    if(t == 0 || t == 3){
      FOR(i, y+1, W){
	if(table[x][i] == 3 && turn < cnt){
	  cnt = turn;
	  break;
	}
	if(table[x][i]==1){
	  table[x][i] = 0;
	  solve(make_pair(x,i-1));
	  table[x][i] = 1;
	  break;
	}
      }
    }
    

    t = table[x][y-1];
    if(t == 0 || t == 3){
      ROF(i, y-1, 0){
	if(table[x][i] == 3 && turn < cnt){
	  cnt = turn;
	  break;
	}
	if(table[x][i]==1){
	  table[x][i] = 0;
	  solve(make_pair(x,i+1));
	  table[x][i] = 1;
	  break;
	}
      }
    }
    turn--;
  } 
}

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

  while(true){
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    cnt=11;
    REP(i, H) REP(j, W) {
      cin >> table[i][j];
      if(table[i][j] == 2) curr.first = i, curr.second = j;
    }
    turn = 0;
    table[curr.first][curr.second] = 0;
    solve(curr);
    if(cnt == 11) cout << -1 << endl;
    else cout << cnt << endl;
  }

    
  
  return 0;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <inttypes.h>

int gcd(int a, int b) {
	while (b > 0) {
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(void) {
	int K;
	int a, b, c;
	uint64_t kotae = 0;
	if (scanf("%d", &K) != 1) return 1;
	for (a = 1; a <= K; a++) {
		for (b = 1; b <= K; b++) {
			int mofu = gcd(a, b);
			for (c = 1; c <= K; c++) {
				kotae += gcd(mofu, c);
			}
		}
	}
	printf("%" PRIu64 "\n", kotae);
	return 0;
}


Measured memory_bytes: 1728
n = int(input())
t, a = map(int, input().split())
list_h = list(map(int, input().split()))

min_diff = 100000
result = -1
for i, h in enumerate(list_h):
  temp_t = t - h * 0.006
  if abs(a - temp_t) < min_diff:
    min_diff = abs(a - temp_t)
    result = i + 1
print(result)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(void){
  int W, H, N;
  cin>>W>>H>>N;
  vector<int> x_min(1,0), x_max(1,W), y_min(1,0), y_max(1,H);
  int i,j;
  int tmp[3];
  for(i=0;i<N;i++){
    cin>>tmp[0]>>tmp[1]>>tmp[2];
    if(tmp[2]==1) x_min.push_back(tmp[0]);
    if(tmp[2]==2) x_max.push_back(tmp[0]);
    if(tmp[2]==3) y_min.push_back(tmp[1]);
    if(tmp[2]==4) y_max.push_back(tmp[1]);
  }

  sort(x_min.begin(),x_min.end());
  sort(x_max.begin(),x_max.end());
  sort(y_min.begin(),y_min.end());
  sort(y_max.begin(),y_max.end());

  if (x_max.front()<x_min.back() or y_max.front()<y_min.back()){
    cout<<0;
    exit(0);
  }
  cout<<max(0,((x_max.front()-x_min.back())*(y_max.front()-y_min.back())));
}


Measured memory_bytes: 256