akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

vector<ll> vec;

int main() {
  fast_io
  ll n; cin >> n;
  vec.resize(n+1);
  fill(vec,0);

  ll ans=0;
  loop1(i,1,n) {
    for(ll j=i; j<=n; j+=i) {
      vec[j]++;
    }
    ans = ans + (i*vec[i]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 81316
N,M,X=map(int,input().split())

A=[0]*N
for j in range(N):
    A[j]=[int(x) for x in input().split()]
money=10**7
for i in range(2**N):
    read=[0]*N #その本を読むか否か
    for h in range(N):
        if i%2==1:
            read[h]=1
        i//=2
    understanding=[0]*M
    kouho=0
    for k in range(N):
        if read[k]==1:
            kouho+=A[k][0]
            for m in range(1,M+1):
                understanding[m-1]+=A[k][m]
    if min(understanding)>=X:
        money=min(money,kouho)
if money==10**7:
    print(-1)
else:
    print(money)


Measured memory_bytes: 9084
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

double ans(int q,double x){
	x=x-(x*x*x-q)/(3*x*x);
	if((x*x*x-double(q)<0.000001*double(q))&&(x*x*x-double(q)>-0.000001*double(q))){
		return x;
	}else{
		return ans(q,x);
	}
	
}


int main(){
	int q;
	double x;
	while(scanf("%d",&q),q!=-1){
		x=ans(q,double(q)/2);
		printf("%lf\n",x);
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b >= c ? "Yes" : "No") << endl;
	return 0;
}
 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(N int64) int64 {
	papers := N / 2
	if N%2 == 1 {
		papers++
	}
	return papers
}


Measured memory_bytes: 640
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
max_exp = exp = K + (sum(p[0:K]) - K) / 2
for i in range(1, N - K + 1):
    exp -= p[i-1] / 2
    exp += p[i + K - 1] / 2
    if max_exp < exp:
        max_exp = exp

print(max_exp)

Measured memory_bytes: 71792
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define MOD 1000000007
    #define PI 3.1415926535897932384626433832795
    #define INF (int)1e9
    typedef long long int int64;
     
    void print() {
        cout << endl;
    }
     
    void print(string s, bool endline = true) {
        cout << s;
        if (endline) print();
    }
     
    void print(int s, bool endline = true) {
        cout << s;
        if (endline) print();
    }
     
    template <typename T, typename T2>
    void print(pair<T, T2>& p, bool endline = true) {
        print("(", false);
        print(p.first, false);
        print(", ", false);
        print(p.second, false);
        print(")", false);
     
        if (endline) print();
    }
     
    template <typename T, typename T2>
    void print(map<T, T2>& m, bool endline = true) {
        print("{");
        for (auto& p : m) {
            print("  ", false);
            print(p);
        }
        print("}");
     
        if (endline) {}
    }
     
    template<typename T>
    void print(vector<T>& v, bool endline = true) {
        print("[", false);
        for (size_t i = 0; i < v.size(); ++i) {
            print(v[i], false);
            if(i != v.size() - 1) print(",", false);
        }
        print("]", false);
     
        if(endline) print();
    }
     
    template <typename T>
    vector<T> operator+(const vector<T> &a, const vector<T> &b)
    {
        vector<T> ret;
        ret.reserve( a.size() + b.size() );                // preallocate memory
        ret.insert( ret.end(), a.begin(), a.end() );        // add A;
        ret.insert( ret.end(), b.begin(), b.end() );        // add B;
     
        return ret;
    }
     
    template <typename T>
    vector<T> &operator+=(vector<T> &a, const vector<T> &b)
    {
        a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
        a.insert( a.end(), b.begin(), b.end() );         // add B;
        return a;
    }

    int main() {
        // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
        int64 n, k;

        cin >> n >> k;

        vector<int64> v(n + 1, 0);
        unordered_map<int64, int64> m;
        v[0] = 0;

        for(int i = 0; i < n; ++i) {
            int64 tmp;
            cin >> tmp;

            tmp--;
            tmp %= k;

            v[i + 1] = (v[i] + tmp) % k;
        }

        int64 count = 0ll;
        m[0] = 1;

        for(int i = 0; i < n; ++i) {
            if (i - k + 1 >= 0) {
                m[v[i - k + 1]]--;
            }

            count += m[v[i+1]]++;
        }

        cout << count << endl;
        // print(v);

        return 0;
    }

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

int main(){
    int a,b;
    string x;
    cin >> a >> b;
    if(a > b) x=">";
    else if(a <b) x="<";
    else x="==";
    cout << "a " << x << " b" << endl;
    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	vector<int> p(N);
	rep(i,N){
		cin >> p[i];
		p[i]--;
	}
	vector<int> a(N),b(N);
	a[0] = 1;
	b[N-1] = 1;
	rep(i,N-1){
		a[i+1] = a[i] + 20000;
	}
	for(int i = N-1; i >= 1; i--){
		b[i-1] = b[i] + 20000;
	}
	rep(i,N){
		a[p[i]] += i;
	}
	rep(i,N){
		if(i) cout<< " ";
		cout << a[i];
	}
	cout << endl;
	rep(i,N){
		if(i) cout << " ";
		cout << b[i];
	}
	cout << endl;
}



Measured memory_bytes: 896
s=input()

S=[s[0]]

for i in range(1,len(s)):
    if S[len(S)-1]=="B" and s[i]=="C":
        S[len(S)-1]="D"
    else:
        S.append(s[i])
#print(S)

L=[]
if S[len(S)-1]=="D":
    L.append(1)
else:
    L.append(0)
    
for i in range(1,len(S)):
    if S[len(S)-1-i]=="D":
        L.append(L[len(L)-1]+1)
    elif S[len(S)-1-i]=="A":
        L.append(L[len(L)-1])
    else:
        L.append(0)
L=L[::-1]
#print(L)
ANS=0
for i in range(len(S)):
    if S[i]=="A":
        ANS+=L[i]
print(ANS)

Measured memory_bytes: 8772
s = int(input())
L = [s]
a = s
count = 1
while a not in L[:-1]:
  if a % 2 == 0:
    a = a // 2
    L.append(a)
  else:
    a = 3 * a + 1
    L.append(a)
  count += 1
print(count)
  

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

int main(){
    char a,b;
    cin >> a >> b;

    int c,d;
    a=='H'?c=1:c=-1;
    b=='H'?d=1:d=-1;

    int r = c*d;
    if(r==1){
        cout<<"H";
    }else{
        cout<<"D";
    }
    return 0;
}

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


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

    string s,t;
    int a,b;
    string u;
    cin>>s>>t>>a>>b>>u;

    if(s==u){
        cout<<a-1<<' '<<b<<endl;
    }else{
        cout<<a<<' '<<b-1<<endl;
    }


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

class Data{
public:
	int cost;
	int x;
	int y;
	int dir;

	Data(int cost,int x,int y,int dir){
		this->cost = cost;
		this->x = x;
		this->y = y;
		this->dir = dir;
	}
	bool operator>(const Data& d1) const{
		return cost > d1.cost;
	}
};

int stage[31][31];
int costTable[31][31][4];
int W,H;

void dfs(int x,int y,int dir,int* c){
	for(int i=0;i<=3;i++){
		int cost = c[i];
		if(stage[y][x] == i) cost = 0;

		int prev = dir;
		int next = (prev+i)%4;
		int dx = x + tx[next];
		int dy = y + ty[next];


		if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
		if(costTable[dy][dx][next] > costTable[y][x][prev] + cost){
			costTable[dy][dx][next] = costTable[y][x][prev] + cost;
			dfs(dx,dy,next,c);
		}
	}
}

int main()
{
	while(~scanf("%d %d",&W,&H)){
		if(W==H && H==0) break;

		memset(costTable,0x3f,sizeof(costTable));

		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				scanf("%d",&stage[y][x]);
			}
		}

		int c[4];
		for(int i=0;i<4;i++){
			scanf("%d",c+i);
		}
		//costTable[0][0][1] = 0;

		priority_queue<Data,vector<Data>,greater<Data> > que;

		que.push(Data(0,0,0,1));

		while(!que.empty()){
			int sum = que.top().cost;
			int x = que.top().x;
			int y = que.top().y;
			int dir = que.top().dir;

			que.pop();
			if(costTable[y][x][dir] != 0x3f3f3f3f) continue;
			
			costTable[y][x][dir] = sum;

			for(int i=0;i<=3;i++){
				int cost = c[i];
				if(stage[y][x] == i) cost = 0;

				int prev = dir;
				int next = (prev+i)%4;
				int dx = x + tx[next];
				int dy = y + ty[next];

				if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
				if(costTable[dy][dx][next] == 0x3f3f3f3f){
					//printf("dx:%d dy:%d \n",dx,dy);
					//printf("sum:%d prev:%d next:%d\n",sum,prev,next);
					//costTable[dy][dx][next] = sum;
					que.push(Data(sum+cost,dx,dy,next));
				}
			}

		}

		//dfs(0,0,1,c);

		int minv = numeric_limits<int>::max();
		for(int i=0;i<=3;i++){
			minv = min(minv,costTable[H-1][W-1][i]);
		}

		printf("%d\n",minv);
	}
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

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

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;

vector<int> to[200005]; //vector<int> の配列
vector<int> ans;

int main()
{
    map<string, ll> dic;

    int n;
    cin >> n;
    rep(i, n)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (!dic.count(s))
            dic[s] = 1;
        else {
            dic[s]++;
        }
    }

    ll sum = 0;
    for (auto e : dic) {
        if (e.second >= 2) {
            sum += e.second * (e.second - 1) / 2;
        }
    }

    cout << sum << endl;
}


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

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

  long long N, K;
  cin >> N >> K;
  N %= K;

  long long min_num = 1000000000000000000;
  while(min_num > abs(N - K)) {
    N = abs(N - K);
    if(min_num > N) {
      min_num = N;
    }
  }

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 3636
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d\n" @@ fun x ->
  Printf.printf "%d\n" @@ upper_bound 0 (abs x + 1) @@ fun i -> i * (i - 1) / 2 < abs x


Measured memory_bytes: 384
#include<iostream>
using namespace std;
struct card{
	char suit, value;
};

void Bubblesort (card a[], int n)
{
	bool flag = 1;
	for(int i=0; flag; i++)
	{
		flag = 0;
		for(int j=n-1; j>i; j--)
		{
			if(a[j].value < a[j-1].value)
			{
				card temp = a[j];
				a[j] = a[j-1];
				a[j-1] = temp;
				flag = 1; 
			}
		}
	}
}

void Selectionsort (card a[], int n)
{
	int minj;
	for(int i=0; i<n; i++)
	{
		minj = i;
		
		for(int j=i; j<n; j++)
		{
			if(a[j].value < a[minj].value)
			{
				minj = j;
			}
		}
		
		if(i != minj)
		{
			card temp = a[i];
			a[i] = a[minj];
			a[minj] = temp;
			
		} 
	}
	 
}

bool isstable(card a[], card b[], int n)
{
	for(int i=0; i<n; i++)
	{
		if(a[i].suit != b[i].suit)return false ;
	}
	
	return true;
}

void print(card a[], int n)
{
	for(int i=0; i<n; i++)
	{
		if(i>0)cout << " ";
		cout << a[i].suit << a[i].value;
	}
	
	cout << endl;
	
}

int main()
{
	int n;
	cin >> n;
	card a[n],b[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i].suit >> a[i].value;
	}
	for(int i=0; i<n; i++)b[i] = a[i];
	
	Bubblesort(a,n);
	print(a,n);
	cout << "Stable" << endl;
	
	Selectionsort(b,n);
	print(b,n);
	if(isstable(a,b,n))
	cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
	
	
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main
{

 public static void main(String args[])
 {
  int N=0;
  Scanner s = new Scanner(System.in);
  N = s.nextInt();
  int[] number = new int[N];
  Scanner sc = new Scanner(System.in);
  for(int i=0;i<N;i++)
  {
   number[i]=s.nextInt();
  }
  sc.close();
  for(int k=0;k<N;k++)
  {
	  System.out.print(number[k]);
	  if(k!=N-1)System.out.print(" ");
  }
  System.out.print("\n");
  for(int i=1;i<N;i++)
  {
   int t=number[i];
   int j=0;
   for(j=i-1;j>=0;j--)
   {
    number[j+1]=number[j];
    if(t>number[j])break;
   }
   number[j+1]=t;
   for(int k=0;k<N;k++)
   {
 	  System.out.print(number[k]);
 	  if(k!=N-1)System.out.print(" ");
   }
   System.out.print("\n");
  }
 }
}


Measured memory_bytes: 33992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> v[100010];
    for(int i = 0; i < n; i++){
        int t,d;
        cin >> t >> d;
        v[t].emplace_back(d);
    }
    for(int i = 0; i < 100010; i++) sort(v[i].rbegin(),v[i].rend());
    vector<int> use,non;
    for(int i = 0; i < 100010; i++){
        int flag = 0;
        for(auto x: v[i]){
            if(flag) non.emplace_back(x);
            else{
                use.emplace_back(x);
                flag = 1;
            }
        }
    }
    sort(use.rbegin(),use.rend()),sort(non.rbegin(),non.rend());
    vector<ll> use_sum = {0},non_sum = {0};
    for(auto x: use){
        use_sum.emplace_back(use_sum.back()+x);
    }
    for(auto x: non){
        non_sum.emplace_back(non_sum.back()+x);
    }
    ll ans = 0;
    for(ll i = 1; i <= k; i++){
        if(i >= use_sum.size()) break;
        if(k-i >= non_sum.size()) continue;
        ans = max(ans,use_sum[i]+non_sum[k-i]+i*i);
    }
    cout << ans << endl;
 
 
    return 0;
}

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


int main() {

    string n;
    cin >> n;
    rep(i,3) {
        if (n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }
    int ans = atoi(n.c_str());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef double db;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

namespace Geometry{
	const db eps = 1e-9;
	struct point{
		db x,y;
		inline point operator + (const point &p){return (point){x+p.x,y+p.y};}
		inline point operator - (const point &p){return (point){x-p.x,y-p.y};}
		inline db operator * (const point &p){return x*p.x+y*p.y;}
		inline point operator / (const db &v){return (point){x/v,y/v};}
		inline point operator * (const db &v){return (point){x*v,y*v};}
	};
	typedef point vec;
	inline db dot(vec a,vec b){return a.x*b.x+a.y*b.y;}
	inline db sqr(db x){return x*x;}
	inline db dis(point a,point b){return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
	inline db dis2(point a,point b){return sqr(a.x-b.x)+sqr(a.y-b.y);}
	inline db cross(vec a,vec b){return a.x*b.y-a.y*b.x;}
	struct line{
		point a,b;
	};
	inline point projection(point A,line b){
		point B=b.a,C=b.b;
		vec BA=A-B,BC=C-B,BD=BC*(BA*BC/dis2(B,C));
		return B+BD;
	}
	inline point reflection(point A,line b){
		point D=projection(A,b);
		return (point){D.x*2-A.x,D.y*2-A.y};
	}
	inline int Counter_Clockwise(point A,line b){
		point B=b.a,C=b.b;
		db f1=cross(C-B,A-B);
		if (fabs(f1)>eps) return (f1<0?2:1);
		db f2=(C-B)*(A-B);
		if (f2<0) return 3;
		return dis(B,C)<dis(A,B)?4:5;
	}
	inline int checkline(line a,line b){
		vec A=a.b-a.a,B=b.b-b.a;
		db f1=A*B;
		if (fabs(f1)<=eps) return 1;
		return dis(a.a,a.b)*dis(b.a,b.b)-fabs(f1)<=eps?2:0;
	}
	inline int checkseg(line a,line b){
		point A=a.a,B=a.b,C=b.a,D=b.b;
		if (max(A.x,B.x)<min(C.x,D.x)) return 0;
		if (min(A.x,B.x)>max(C.x,D.x)) return 0;
		if (max(A.y,B.y)<min(C.y,D.y)) return 0;
		if (min(A.y,B.y)>max(C.y,D.y)) return 0;
		db s=cross(B-A,C-A),h=cross(B-A,D-A);
		if (s*h>=eps) return 0;
		db i=cross(D-C,A-C),t=cross(D-C,B-C);
		return i*t<=eps;
	}
	inline point cross_point(line a,line b){
		point A=a.a,B=a.b,C=b.a,D=b.b;
		db s1=fabs(cross(B-A,C-A)),s2=fabs(cross(B-A,D-A));
		vec CO=(D-C)*(s1/(s1+s2));
		return C+CO;
	}
};
using namespace Geometry;

int main(){
//	freopen("data.in","r",stdin);
	int T;scanf("%d",&T);
	while (T--){
		line a;scanf("%lf%lf%lf%lf",&a.a.x,&a.a.y,&a.b.x,&a.b.y);
		line b;scanf("%lf%lf%lf%lf",&b.a.x,&b.a.y,&b.b.x,&b.b.y);
		point c=cross_point(a,b);
		printf("%0.10lf %0.10lf\n",c.x,c.y);
	}
}


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

int main(){
    int n;
    cin>>n;
    int a,b,c;
    int aa,ab,ac,ta,tb,tc;
    cin>>aa>>ab>>ac;
    for(int i=1;i<n;i++){
        cin>>a>>b>>c;
        ta = max(ab,ac) + a;
        tb = max(aa,ac) + b;
        tc = max(aa,ab) + c;
        aa = ta;
        ab=tb;
        ac=tc;
    }
    int ans = max(max(aa,ab),ac);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	int at=0;
	for( ans=0;ans<=n+2;ans++){
		at=a[at];
	//	clog<<at<<endl;
		if(at==1){break;}
	}
	if(ans== n+3){
		cout<<"-1"<<endl;
	}else{
	cout<<ans+1<<endl;
}
}

Measured memory_bytes: 640
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	int x,y;scanf("%d%d",&x,&y);
	if(a%2==0&&ABS(x+y)%2){
		printf("-1\n");return 0;
	}
	bool Xn=false;
	bool Yn=false;
	if(x<0){
		Xn=true;
		x=-x;
	}
	if(y<0){
		Yn=true;
		y=-y;
	}
	vector<pair<int,int> > ans;
	int nx=0;
	int ny=0;
	while(1){
		int d=a;
	//	printf("%d %d\n",nx,ny);
		int mx=min(x-nx,d);
		nx+=mx;
		d-=mx;
		int my=min(y-ny,d);
		ny+=my;
		d-=my;
		if(d>0){
			if(ans.size()==0){
				if(ABS(x+y)%2==0||a%2==0){
					int am=(2*a-x-y)/2;
					if(x<y)ans.push_back(make_pair(x+am,a-x-am));
					else ans.push_back(make_pair(a-y-am,y+am));
					ans.push_back(make_pair(x,y));
					break;
				}else{
					ans.push_back(make_pair(-a,0));
					ny=0;
					nx=-a;
					continue;
				}
			}
			if(d%2){
				int X0=ans[ans.size()-1].first;
				int Y0=ans[ans.size()-1].second;
				int am=(2*a-(x-X0)-(y-Y0))/2;

				if(x-X0<y-Y0)ans.push_back(make_pair(X0+(x-X0)+am,Y0+a-(x-X0)-am));
				else ans.push_back(make_pair(X0+a-(y-Y0)-am,Y0+(y-Y0)+am));
				ans.push_back(make_pair(x,y));
				break;
			}else{
				int am=d/2;
				if(ans[ans.size()-1].second==0){
					ans[ans.size()-1].second-=am;
					ans[ans.size()-1].first-=am;
				}else if(ans[ans.size()-1].second-am>=0){
					ans[ans.size()-1].second-=am;
					ans[ans.size()-1].first+=am;
				}else{
					ans[ans.size()-1].first-=am-ans[ans.size()-1].second;
					ans[ans.size()-1].second=-am;

				}
				ans.push_back(make_pair(x,y));
				break;
			}
		}
		ans.push_back(make_pair(nx,ny));
		
		if(nx==x&&ny==y)break;
	}

	printf("%d\n",(int)(ans.size()));
	for(int i=0;i<ans.size();i++){
		if(Xn)ans[i].first*=-1;
		if(Yn)ans[i].second*=-1;
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
}

Measured memory_bytes: 3952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int answer;
		
		answer = fibonacci(n + 1);
		System.out.println(answer);
	}
	
	public static int fibonacci(int n){
		
		double gold = 1.618033988749895;
		
		int temp = (int) ((Math.pow(gold, n) - Math.pow(-gold, -n)) / Math.sqrt(5));
		
		return temp;
	}
} 

Measured memory_bytes: 24280
#include "bits/stdc++.h"
#include <iostream>
#include <vector>

using namespace std;
int main(){
    int n;
    cin >> n;

    vector<int> p;
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        p.push_back(t);
    }

    int count = 0;
    
    for (int i = 0; i < n; i++)
    {
        if(p[i] != i+1){
            count++;
        }
    }

    if(count > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr ll INF = (1LL << 60);

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,ll>> edge(n);
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    edge.emplace_back(make_tuple(a, b, p - c));
  } 

  vector<ll> d(n, INF);
  d[0] = 0;

  for (int i = 0; i < n; i++) {
    for (auto t : edge) {
      int u, v;
      ll cost;
      tie(u, v, cost) = t;
      if (d[u] == INF) continue;
      if (d[v] > d[u] + cost) {
        d[v] = d[u] + cost;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (auto t : edge) {
      int u, v;
      ll cost;
      tie(u, v, cost) = t;

      if (d[v] != INF && d[v] > d[u] + cost) {
        d[v] = -INF;
      }
    }
  }
  ll res = max(-d[n - 1], 0LL);
  cout << (d[n - 1] == -INF ? -1 : res) << endl;
  return 0;
} 

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;
    int N = (int)S.size();

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') ++cnt;
    }

    cout << min(cnt, N - cnt) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int m,f,r;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m<=50 && f<=50 && r<=100 && m>=-1 && f>=-1 && r>=-1){
			if(m==-1 && f==-1 && r==-1){
			break;
			
			}else if(m==-1 || f==-1){
			printf("F\n");
				
			}else if(80<=m+f){
			printf("A\n");
			
			}else if(65<=m+f && 80>m+f){
			printf("B\n");
			
			}else if(50<=m+f && 65>m+f){
			printf("C\n");
			
			}else if(30<=m+f && 50>m+f){
			
				if(50<=r){
				printf("C\n");
			
				}else{
				printf("D\n");
				}
			
			}else{
				printf("F\n");
			}
			
		}
		
	}return 0;
	
}

Measured memory_bytes: 584
#include<stdio.h>
int main()
{
int a[5],max,min,i,b;
  min=123;
  max=0;
for(i=0;i<5;++i)
 {scanf("%d",&a[i]);
  if(a[i]>max) max=a[i];
  if(a[i]<min) min=a[i];
 }
scanf("%d",&b);
  
if(max-min>b) printf(":(");
else printf("Yay!");
return 0;
}

Measured memory_bytes: 128
package main
 
import (
	"fmt"
)
 
var h, w, k, answer int
var s string
var l [][]string
func main() {
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&k)
	l = make([][]string, h)
	for i:= 0; i < h; i++ { 
		fmt.Scan(&s)
		l[i] = make([]string, w)
		for j := 0; j < w; j++ {
			l[i][j] = s[j:j + 1]
		}
	}
	//gyo(l) 
	/*
	for i := 0; i < h; i++ {
	  cp := make([][]string, h)
	  copy(cp, l)
	  for j := 0; j < w; j++ {
   	    cp[i][j] = "hoge"
		pretty(cp)
	  }
	}
	*/
	a := make([]bool, h)
	gyo(a, 0)
    fmt.Println(answer)
}

func gyo(a []bool, depth int) {
	if depth == h {
		b := make([]bool, w)
		retsu(a, b, 0)
		return
	}
	a[depth] = true
	gyo(a, depth + 1)
	a[depth] = false
	gyo(a, depth + 1)
}

func retsu(a, b []bool, depth int) {
	if depth == w {
		solve(a, b)
		return
	}
	b[depth] = true
	retsu(a, b, depth + 1)
	b[depth] = false
	retsu(a, b, depth + 1)
}

func solve(a, b []bool) {
  obj := paint(l, a, b)
  count := 0
  for _, v := range obj {
	  if v == "#" {
		  count ++
	  }
  }
  if count == k {
	  answer ++ 
  }
}
func paint(obj [][]string, a, b []bool) []string {
    ans := []string {}
	for i, g := range a {
	  for j, r := range b {
		  if !g && !r {
			  ans = append(ans, l[i][j])
		  }
	  }
	}
	return ans
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///binary to decimal
long double btod(string a){
    long double i,c=sz(a)-1,s=0,d=0;
    for(i=c;i>=0;i--){
        a[i]-=48;
        s+=a[i]*pow(2,d);
        d++;
    }
    return s;
}

main()
{
    optimize();
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a sp<<b sp<< c el;;
}










//Brainless_Loco Terminates Here!


Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline().strip()

import heapq

def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())

    # surround the square with '@'
    c = [['@'] * (w+2)]
    for _ in range(h):
        i = input()
        l = ['@']
        for j in i:
            l.append(j)
        l.append('@')
        c.append(l)
    c.append(['@'] * (w+2))

    # Dijkstra
    # seen[x][y] = the minimum cost of (x, y)
    # if seen[x][y] == -1, (x, y) is unresearched
    seen = [[-1] * (w+2) for _ in range(h+2)]

    # todo[i] == (cost, x, y, direction)
    todo = [(0, x1, y1, 0)]
    heapq.heapify(todo)

    # direction
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]

    while len(todo) > 0:
        cost, xi, yi, direction = heapq.heappop(todo)

        # only straight
        if seen[xi][yi] != -1:
            if (seen[xi][yi]+k-1)//k * k > cost:
                xj, yj = xi + dx[direction], yi + dy[direction]
                if c[xj][yj] == '.':
                    heapq.heappush(todo, (cost+1, xj, yj, direction))
            continue
        seen[xi][yi] = cost

        # goal
        if xi == x2 and yi == y2:
            print((cost+k-1)//k)
            exit()
        
        # 4 directions
        for j in range(4):
            xj, yj = xi + dx[j], yi + dy[j]
            if c[xj][yj] == '.':
                if j == direction:
                    if seen[xj][yj] == -1 or (seen[xj][yj]+k-1)//k * k > cost:
                        heapq.heappush(todo, (cost+1, xj, yj, j))
                elif seen[xj][yj] == -1:
                    heapq.heappush(todo, ((cost+k-1)//k * k + 1, xj, yj, j))

    print(-1)

main()

Measured memory_bytes: 77536
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
int a[2123];
signed main() {
	int n, i, t, j;
	cin >> n;
	for (i = 0; i < n; ++i)cin >> a[i];
	sort(a, a + n);
	a[n] = inf;
	int ans = 0;
	for (i = 0; i < n; ++i) {
		for (j = i+1; j < n; ++j) {
			int* tt = lower_bound(a + j + 1, a + n + 1, a[i] + a[j]);
			int t = tt - a;
			ans += (t - j - 1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    vector<int> a[26] = {}, b[26] = {};
    for (int i = 0; i < s.length(); i++) a[s[i] - 'a'].push_back(i);
    for (int i = 0; i < t.length(); i++) b[t[i] - 'a'].push_back(i);
    sort(a, a + 26); sort(b, b + 26);
    for (int i = 0; i < 26; i++) if (a[i] != b[i]) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


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

int main(){
	string s;
	cin >> s;
	string tmp = s;
	reverse(tmp.begin(), tmp.end());
	
	int n = s.size() / 2 + s.size() % 2;
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] != tmp[i]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ld dp[307][307][307];
bool kentou[307][307][307];
ll N;
ld M;
ll A,B,C;

ld dfs(ll X,ll Y,ll Z){
  if(kentou[X][Y][Z]==1){
    return dp[X][Y][Z];
  }
  else{
    ld x=X,y=Y,z=Z;
    dp[X][Y][Z]=((X!=0?x*dfs(X-1,Y,Z):0)+(Y!=0?y*dfs(X+1,Y-1,Z):0)+(Z!=0?z*dfs(X,Y+1,Z-1):0)+N)/(x+y+z);
    kentou[X][Y][Z]=1;
    return dp[X][Y][Z];
  }
}

int main(){
  cin >> N;
  M=N;
  rep(i,N){
    ll X;
    cin >> X;
    if(X==1){
      A++;
    }
    if(X==2){
      B++;
    }
    if(X==3){
      C++;
    }
  }
  kentou[0][0][0]=1;
  dp[0][0][0]=0;
  ld ans = dfs(A,B,C);
  cout << stpr(13) << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

int main(void){
    //標準入力
    ll N;
    string S;
    REP(i,5)
    {
        cin >> N;
        if( N == 0 )
        {
            cout << i+1 << endl;
        }
    }
    
    return 0;
}

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

int N,A,B;
vector<int> H;
bool check(ll x){
  ll c=0;
  for(int i=0;i<N;i++){
    ll h = 1LL * H[i] - 1LL * x * B;
    if(h<=0) continue;
    c += h/A;
    if(h%A) c++;
  }
  return c <= x;
}

int main(){
  cin >> N >> A >> B;
  A -= B;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    H.push_back(x);
  }

  // 2分探索
  int ng=0, ok=1000000000;
  while(ng + 1 != ok){
    int x = (ng + ok) / 2;
    if(check(x)) ok = x;
    else ng = x;
  }
  cout << ok << endl;
}


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

using namespace std;
 
using tint = long long;
using ld = long double;
 
#define forsn(i, s, n) for(int i = int(s); i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
 
using vi = vector<tint>;
 
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
 
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
 
#define DBG(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9+7;
const int MX = 3005;
const int INF = 1e9;
const ld PI = acos(ld(-1)); 
 
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
 
bool valid(int x, int y, int n, int m){
	return (0<=x && x<n && 0<=y && y<m);
}
 
void NACHO(string name = "", bool file = 0){
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(file){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

bool f(vi &a, tint mid, tint k){
	tint cont = 0;
	forn(i, sz(a)){
		cont+=(a[i]/mid-(a[i] % mid == 0));
	}
	return (cont <= k);
}
 
int main(){
    NACHO();
	int n, k; cin >> n >> k;
	vi a (n);
	forn(i, n) cin >> a[i];
	int low = 0, high = 1e9;
	while(high-low > 1){
		int mid = low+(high-low)/2;
		if(f(a, mid, k)) high = mid;
		else low = mid;
	}
	cout << high << endl;
}


Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


ull N, M;

const ull RMAX = 100001;

const ull PMAX = 200001;


typedef struct {
	ull min_dist = RMAX;
	ull to;
	vector <ull> path;
} Room;
Room room[RMAX];



void output() {
	for (int i = 2; i <= N; i++) {
		cout << room[i].to << endl;
		//cout << i << ":" << room[i].to << " dist=" << room[i].min_dist << endl;
	}
	//cout << endl;
}

void output_debug() {
	for (int i = 2; i <= N; i++) {
		cout << i << ":" << room[i].to << " dist=" << room[i].min_dist << endl;
	}
	cout << endl;
}

queue<ull> rooms_to_check;


void set_minpath(ull from) {


	ull cmin = room[from].min_dist;


	//cout << "from:" << from  << " cmin=" << cmin << endl;
	//output();

	bool update = false;


	for (auto itr : room[from].path) {
		// cout << "   checking room=" << itr << endl;

		if (room[itr].min_dist > cmin + 1) {
			room[itr].min_dist = cmin + 1;
			room[itr].to = from;

			rooms_to_check.push(itr);
			
			//cout << "       set itr=" << itr << " cmin=" << cmin+1 << endl;

			//output();
		}
	}



}



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

	ull i, j, k;
	ull from, to;

	for (i = 1; i <= M; i++) {
		
		cin >> from >> to;

		room[from].path.push_back(to);
		room[to].path.push_back(from);
	}

	room[1].min_dist = 0;
	room[1].to = 0;
	// set_minpath_dfs(1);

	rooms_to_check.push(1);

	while (!rooms_to_check.empty()) {
		ull itr = rooms_to_check.front();
		rooms_to_check.pop();
		set_minpath(itr);
	}

	set_minpath(1);


	//output_debug();

	bool check = true;

#ifdef NEVER 
	for (i = 2; i <= N; i++) {
		if (room[i].min_dist == RMAX || room[i].to == 0) {
			//cout << i << " min_dist=" << room[i].min_dist << " to=" << room[i].to << endl;
			check = false;
			break;
		}

	}
#endif

	if (check) {
		cout << "Yes" << endl;
		output();
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 13388
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	int ires;
	string sres = "Hello World";
	int N; cin >> N;

	int A, B; if (N == 2) cin >> A >> B;

	ires = A + B;

	if (N == 1) cout << sres << endl; else cout << ires << endl;

}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> v(100001,0);
    ll sum = 0;
    for(i = 0;i < n;++i){
        ll a;
        cin >> a;
        sum += a;
        ++v.at(a);
    }
    ll q;
    cin >> q;
    for(i = 0;i < q;++i){
        ll b,c;
        cin >> b >> c;
        sum -= v.at(b)*b;
        sum += v.at(b)*c;
        v.at(c) += v.at(b);
        v.at(b) = 0;
        cout << sum << endl;
    }


    return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    constexpr ll T = 1LL << 10, X = ((((T + 1) * T + 1) * T + 1) * T + 1) * T + 1;
    int p0[60] = {};
    ll r = 0;

    for (int i0 = 0; i0 < n; i0 += (1 << 10) - 1) {
        ll p[10] = {};
        for (int i = i0; i < min(i0 + (1 << 10) - 1, n); i++) {
            ll a;
            cin >> a;

            for (int k = 0; k < 10; k++) {
                p[k] += a & X;
                a >>= 1;
            }
        }

        for (int k = 0; k < 10; k++) {
            ll c = p[k];
            for (int h = 0; h < 6; h++) {
                p0[10 * h + k] += c & T - 1;
                c /= T;
            }
        }
    }

    for (int k = 0; k < 60; k++) {
        r += (1LL << k) % P * p0[k] % P * (n - p0[k]) % P;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import bisect

A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

INF = 10 ** 11
for x in X:
  ids = bisect.bisect_left(S,x)
  if ids == 0:
    sl = -INF
    sr = S[0]
  elif ids == A:
    sl = S[A-1]
    sr = INF
  else:
    sl = S[ids-1]
    sr = S[ids]
  idt = bisect.bisect_left(T,x)
  if idt == 0:
    tl = -INF
    tr = T[0]
  elif idt == B:
    tl = T[B-1]
    tr = INF
  else:
    tl = T[idt-1]
    tr = T[idt]
  print(min(max(x-sl,x-tl),(x-sl)+(tr-sl),(x-tl)+(sr-tl),(tr-x)+(tr-sl),(sr-x)+(sr-tl),max(sr-x,tr-x)))


Measured memory_bytes: 124892
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int a, b, c;
	cin >> a >> b >> c;
	if (abs(a - b) > abs(a - c)) {
		cout<<"B"<<endl;
	}
	else {
		cout<<"A"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      double output = 0;
      for(int i = 0; i < N; i++){
        ArrayList<String> tmp = nextStrArray();
        if(tmp.get(1).equals("JPY")){
          output += Double.parseDouble(tmp.get(0));
        }else{
          output += Double.parseDouble(tmp.get(0)) * 380000;
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33244