akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(reader basicIO.Reader, writer basicIO.Writer) {
	io := NewIO(reader, writer)
	var N int
	var Q int
	var str string
//	N, _ = io.nextInt()
//	Q, _ = io.nextInt()
//	str = io.nextString()
	fmt.Scan(&N, &Q, &str)
	t := make([]byte, Q)
	d := make([]byte, Q)

	for i := 0; i < Q; i++ {
		t[i] = io.nextString()[0]
		d[i] = io.nextString()[0]
	}

	l := -1
	r := N
	for i := Q - 1; i >= 0; i-- {
		if d[i] == 'L' {
			if l < N-1 && t[i] == str[l+1] {
				l++
			}
			if r < N && t[i] == str[r] {
				r++
			}
		} else {
			if r > 0 && t[i] == str[r-1] {
				r--
			}
			if l > -1 && t[i] == str[l] {
				l--
			}
		}
	}
	if r-l < 0 {
		io.PutInt(0)
		return
	}
	io.PutInt(r - l - 1)
	return
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 2816
/*******************************************************************
 * 		Author : yash1402_										   *
 * 
 * 
 * 		Don't forget to comment input of T....
 ******************************************************************/

#include <bits/stdc++.h>

using namespace std;

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

#define all(__VEC) __VEC.begin(),__VEC.end()

#define opvec(__VEC) cout << #__VEC << " : "; for(auto _ITER:__VEC) cout << _ITER << " "; cout << "\n";
#define opv(__VAR) cout << #__VAR << " : " << _VAR << "\n";

#define MP make_pair
#define PB push_back

void solve() {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll mx;
	mx = a*c;
	mx = max(a*d,mx);
	mx = max(b*c,mx);
	mx = max(b*d,mx);
	
	cout << mx << "\n";
}

int main() {
	ll T=1;
	//cin >> T;
	while(T--) {
		solve();
	}
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n, x; cin >> n >> x;
  vector<ll> v(n, 0);
  ll ans = 0;
  rep(i,n){
    cin >> v[i];
    if(v[i]>x){
      ans += v[i]-x;
      v[i]=x;
    }
  }
  for(ll i=1; i<=n-1; i++){
    ll sum = v[i-1]+v[i];
    if(sum>x){
      ll dif = sum-x;
      if(dif<=v[i]){
        v[i]-=dif;
      }else{
        v[i-1]-=dif-v[i];
        v[i]-=v[i];
      }
      ans+=dif;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   long long int h,w,ans;
  cin>>h>>w;
  if(h==1||w==1){
    cout<<"1"<<endl;
    return 0;
  }
  ans=h*w;
  if(ans%2==1) cout<<ans/2+1<<endl;
  else cout<<ans/2<<endl;
  return 0;
}


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

int main() {
  int ans = 0;
  int A,B;
  int outlet = 1;

  cin >> A >> B;
  
  while(outlet < B){
    --outlet;
    outlet += A;
    ans += 1;
  }

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


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){

	int x, y, s;

	while(1){
		cin >> x;
		cin >> y;
		cin >> s;

		if(x==0 && y==0 && s==0) break;

		int hold=0;

		int temp;
		for(int i=1 ; i<s ; i++){
			for(int j=1 ; j<s ; j++){
				temp = i*(100+x)/100 + j*(100+x)/100;
				if(temp == s){
					int temp2;
					temp2 = i*(100+y)/100 + j*(100+y)/100;
					if(temp2 > hold) hold = temp2;
				}
			}
		}

		cout << hold << endl;

	}


	return 0;
}

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

int main() {
    int n;
    vector<int> a;
    
    cin>>n;
    a.resize(n);
    for (int i=0; i<n; ++i) {
        cin>>a.at(i);
    }
    
    map<int,int> mp;
    for (int bit=0; bit<(1<<n); ++bit) {
        int sum=0;
        for (int j=0; j<n; ++j) {
            if (bit&(1<<j)) {
                sum+=a.at(j);
            }
        }
        mp[sum]+=1;
    }

    int q;
    cin>>q;
    for (int i=0; i<q; ++i) {
        int m;
        cin>>m;
        if (mp[m]) {
            cout<<"yes"<<endl;
        }
        else {
            cout<<"no"<<endl;
        }
    }
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[2222][2222],sp[2222][2222],calc[2222];

int main(void){
	int x,y,z,i,j,n;
	ll b = 0ll, ans=0ll;
	std::fill(dp[0],dp[2222],-INFLL);
	std::fill(calc,calc+2222,-INFLL);
	std::cin >> n;
	std::cin >> x >> y;
	dp[x][y] = 0ll; calc[x] = 0ll; calc[y] = 0ll;
	for(i=1; i<n; ++i){
		std::cin >> x >> y >> z;
		if(x == y && y == z && z == x){
			++b;
			continue;
		}
		for(j=1; j<=n; ++j){
			sp[j][x] = -INFLL;
			sp[j][y] = -INFLL;
			sp[j][z] = -INFLL;
		}
		// x を残す
		for(j=1; j<=n; ++j){
			sp[j][x] = std::max(sp[j][x],calc[j]);
			if(y == z){
				sp[j][x] = std::max(sp[j][x],dp[y][j]+1);
				sp[j][x] = std::max(sp[j][x],dp[j][y]+1);
			}
		}
		// y を残す
		for(j=1; j<=n; ++j){
			sp[j][y] = std::max(sp[j][y],calc[j]);
			if(x == z){
				sp[j][y] = std::max(sp[j][y],dp[x][j]+1);
				sp[j][y] = std::max(sp[j][y],dp[j][x]+1);
			}
		}
		// z を残す
		for(j=1; j<=n; ++j){
			sp[j][z] = std::max(sp[j][z],calc[j]);
			if(x == y){
				sp[j][z] = std::max(sp[j][z],dp[x][j]+1);
				sp[j][z] = std::max(sp[j][z],dp[j][x]+1);
			}
		}
		// x,y を残す
		sp[x][y] = std::max(sp[x][y],ans);
		sp[x][y] = std::max(sp[x][y],dp[z][z]+1);
		// y,z を残す
		sp[y][z] = std::max(sp[y][z],ans);
		sp[y][z] = std::max(sp[y][z],dp[x][x]+1);
		// x,z を残す
		sp[x][z] = std::max(sp[x][z],ans);
		sp[x][z] = std::max(sp[x][z],dp[y][y]+1);
		for(j=1; j<=n; ++j){
			dp[j][x] = std::max(dp[j][x],sp[j][x]);
			dp[j][y] = std::max(dp[j][y],sp[j][y]);
			dp[j][z] = std::max(dp[j][z],sp[j][z]);
			calc[x] = std::max(calc[x],sp[j][x]);
			calc[y] = std::max(calc[y],sp[j][y]);
			calc[z] = std::max(calc[z],sp[j][z]);
			calc[j] = std::max(calc[j],sp[j][x]);
			calc[j] = std::max(calc[j],sp[j][y]);
			calc[j] = std::max(calc[j],sp[j][z]);
			ans = std::max(ans,sp[j][x]);
			ans = std::max(ans,sp[j][y]);
			ans = std::max(ans,sp[j][z]);
		}
	}
	std::cin >> z;
	ans = std::max(ans,dp[z][z]+1);
	ans += b;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 76828
import math
n, l = map(int, input().split())
a_l = [l + i for i in range(n)]

min1 = 100
min2 = 10000

for j in a_l:
    if j ** 2 <= min2:
        min2 = j **2
        min1 = j
print(sum(a_l) - min1)

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

int main() {
  int num;
  cin >> num;
  int atMost = num / 100;
  int dest = num - atMost * 100;
  while(dest >= 5){
    dest -= 5;
  	atMost--;
  }
  if(dest >= 1 && dest <= 4) atMost--;
  if(atMost >= 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long Z;
    scanf("%lld", &Z);
    cout << Z << " " << X << " " <<Y << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
ans=10**9
from itertools import combinations as co
l=[list(map(int,input().split())) for _ in range(n)]
for i in range(1,n+1):
  for ch in co(range(n),i):
    f=1
    t=[0]*m
    s=0
    for j in ch:
      s+=l[j][0]
      for k in range(1,m+1):
        t[k-1]+=l[j][k]
    for test in t:
      if test<x:
        f=0
        break
    if f:
      ans=min(ans,s)
if ans==10**9:
  ans=-1
print(ans)

Measured memory_bytes: 9228
n=int(input())
x=[]
y=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)
ans=0
import math
for i in range(n):
  for j in range(n):
    ans+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
ans=ans/(n*(n-1))
print(ans*(n-1))

Measured memory_bytes: 9144
#include<iostream>

using namespace std;

int main(){
    int n,m,e,j;	
	while(cin >> n,n){
		while(n--){
			cin>>m>>e>>j;
			if(m==100 || e==100 || j==100)	cout<<'A'<<endl;
			else if(m+e>=180)	cout<<'A'<<endl;
			else if(m+e+j>=240)	cout<<'A'<<endl;
			else if(m+e+j>=210)	cout<<'B'<<endl;
			else if(m+e+j>=150 && (m>=80 || e>=80))	cout<<'B'<<endl;
			else	cout<<'C'<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3004
#include <stdio.h>
#include <string.h>

using ll  = long long;

int main()
{
	ll A;
	ll B1, B2;
	scanf("%lld", &A);
	scanf("%lld.%lld", &B1, &B2);

	printf("%lld\n", A * (B1 * 100 + B2) / 100);

	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a,0);
  for(ll i=0;i<a-1;i++){
    ll b;
    cin>>b;
    vec.at(b-1)+=1;
  }
  for(ll i=0;i<a;i++){
    cout<<vec.at(i)<<endl;
  }
}    

Measured memory_bytes: 4768
#include <iostream>
#include <stdio.h>
#include <queue>
#include <vector>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main(){
    string S;
    long long K;
    cin >> S >> K;
    
    for ( int i = 0; i < min( (long long)S.size(), K); i++ ) {
        if ( S[i] >= '2' ) { cout << S[i] << endl; return 0;}
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000
int main(){
  int i,j,n,q,S[10000],T[500],count=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j=0; j<q; j++){
    scanf("%d",&T[j]);
  }
  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(S[j]==T[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
}


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

//abc163
//C-management
int main() {
    int n; cin >> n;
    vector<int> cnt(n);
    rep(i,n-1) {
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    rep(i,n) cout << cnt[i] << endl;
}

Measured memory_bytes: 3956
package main

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

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N float64
	var Na int
	var ans int
	if scanner.Scan() {
		Na, _ = strconv.Atoi(scanner.Text())
		N = float64(Na)
	}
	q := math.Trunc(N / 1.08)
	if int(math.Floor(q*1.08)) == Na {
		ans = int(q)
		fmt.Fprintln(wtr, ans)
	} else if int(math.Floor((q+1)*1.08)) == Na {
		ans = int(q + 1)
		fmt.Fprintln(wtr, ans)
	} else {
		fmt.Fprintln(wtr, ":(")
	}

	_ = wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,ans=1,mod=1000000007;
    cin >> n >> m;
    if(max(n,m)-min(n,m)>1){
      cout << 0 << endl;
      return 0;
    }
    for(int i=2;i<=n;i++){
      ans*=i;
      ans%=mod;
    }
    for(int i=2;i<=m;i++){
      ans*=i;
      ans%=mod;
    }
    if(n==m){
      ans*=2;
      ans%=mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
const int d=64;
LL store[d];
//from 0
LL a[202];
string s;

void sv(){
	int N;
	cin>>N;
	rb(i,1,N) cin>>a[i];
	cin >>s;
	reverse(ALL(s));
	reverse(a+1,a+1+N);
	s='%'+s;
	memset(store,0,sizeof(store));
	rb(i,1,N){
		LL inser=a[i];
		rep(j,d){
			if(store[j]&&((inser>>(j))&1)){
				inser ^=store[j];
			}
		}
		if(s[i]-'0'){
			if(inser){
				cout<<1<<endl;
				return;
			}	
		}
		else{
			if(inser){
				rep(j,d){
					if(1&(inser>>j)){
						store[j]=inser;
						break;
					}
				}
			}
		}
	}
	cout<<0<<endl;
}
int main(){
	fastio;
	int T;
	cin>>T;
	while(T--) sv();
	return 0;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 29 06:00:56 2020

@author: Aruto Hosaka
"""


N,M,X = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]

# C =[[100, 3, 7, 5, 3, 1], [164, 4, 5, 2, 7, 8], [334, 7, 2, 7, 2, 9], [234, 4, 7, 2, 8, 2], [541, 5, 4, 3, 3, 6], [235, 4, 8, 6, 9, 7], [394, 3, 6, 1, 6, 2], [872, 8, 4, 3, 7, 2]]
# N = 8
# M = 5
# X = 10


P = [row[0] for row in C]
A = [row[1:M+1] for row in C]

K = [0 for i in range(2**N)]
G = [[0 for k in range(M)] for i in range(2**N)]
for i in range(2**N):
    i2 = format(i, '012b')
    s = 0
    for k in range(N):
        K[i] += int(i2[11-k])*P[k]
        for j in range(M):
            G[i][j] += int(i2[11-k])*A[k][j]

J = [[K[i],G[i]] for i in range(2**N)]
J = sorted(J)

t = 0
for i in range(2**N):
    for j in range(M):
        if (J[i][1])[j] < X:
            break
        if j == M-1:
            t = 1
            print(J[i][0])
    if t== 1:
        break

if t==0:
    print(-1)
    


Measured memory_bytes: 11868
unittest
{
	assert( [ "10" ].solve == 170 );		// 追加ケース
	
	assert( [ "4" ].solve == 23 );
	assert( [ "100" ].solve == 26879 );
	assert( [ "10000000" ].solve == 838627288460105 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	// 素数の組み合わせで2からnまでを列挙
	auto ans = 1L;		// 1の約数の個数
	auto ds = new long[ 1 + n ];
	ds[ 1 ] = 1;
	foreach( p; n.primes )
	{
		foreach_reverse( long x, d; ds[ 0 .. n / p + 1 ] )
		{
			if( d == 0 ) continue;
			for( auto y = 1L; x * p ^^ y <= n; y++ )
			{
				// kの約数の個数は組み合わせた各素数の乗数の掛け算で計算できる
				auto k = x * p ^^ y;
				auto f = d * ( y + 1 );
				ds[ k ] = f;
				ans += k * f;
			}
		}
	}
	return ans;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}


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

#define SOSU 1000000007

using namespace std;

int main(){
  int n,m; cin >> n >> m;
  long long x,y,sumx=0,sumy=0;
  for(int i=0;i<n;++i) {
    cin >> x;
    sumx+=i*x;
    sumx-=(n-(i+1))*x;
  }
  for(int i=0;i<m;++i) {
    cin >> y;
    sumy+=i*y;
    sumy-=(m-(i+1))*y;
  }
  sumx%=SOSU; sumy%=SOSU;
  cout << (sumx*sumy)%SOSU << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static long gcd (long a, long b) {
	    return b == 0 ?  a: gcd (b, a % b);
	}
	static long lcm(long a, long b) {
		return (a)/gcd(a,b)*b; 
	}
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		Long ans = 1l;
		for(int i = 0; i<n; i++) {
			long x = in.readLong();
			ans = lcm(ans,x);
		}
		System.out.println(ans);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  // エラトステネスのふるい ---
  vector<bool>primeNum(100005, true);
  primeNum.at(0) = false; primeNum.at(1) = false;

  int N = 100001;
  FOR(x, 2, floor(sqrt(N))) {
    if (primeNum.at(x) == false) continue;

    for(int y = x; y < N; y += x) {
      if (y == x){
        primeNum.at(y) = true;
      } else {
        primeNum.at(y) = false;
      }
    }
  }
  //  ---

  // 2017likeの累積和 --
  vector<int> likeNum(100005);
  int sum = 0;
  FOR(i, 3, N) {
    int a = i; 
    int b = (i+1) / 2;
    if (primeNum.at(a) and primeNum.at(b)) sum += 1;
    likeNum.at(i) = sum;
  }
  // --

  int Q; cin >> Q;
  REP(i, Q) {
    int l, r; cin >> l >> r;
    cout << likeNum.at(r) - likeNum.at(l-1) << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int a,b;
int main() {
  cin >> a >> b;
  if (a == b)
  {
      cout << "Draw" << endl;
  }
  else if(a == 1){
      cout << "Alice" << endl;
  }
  else if(b == 1){
      cout << "Bob" << endl;
  }
  else if(a > b){
      cout << "Alice" << endl;
  }
  else if(b > a){
      cout << "Bob" << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1)
    a = 14;
  if (b == 1)
    b = 14;
  if (a > b)
    cout << "Alice" << endl;
  else if (a < b)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::Chars;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

fn check(s: &Vec<char>, i: usize, t: &Vec<char>) -> bool {
  if i + t.len() > s.len() {
    return false;
  }
  for j in 0..t.len() {
    if s[i+j] != t[j] {
      return false;
    }
  }
  true
}

#[fastout]
fn main() {
  input!{
    s: Chars
  };
  let mut dp = vec![false; s.len()+1];
  dp[0] = true;
  let keywords = ["dream", "dreamer", "erase", "eraser"];
  let keywords : Vec<Vec<char>> = keywords.iter().map(|kw| kw.chars().collect()).collect();
  for i in 0..s.len() {
    if dp[i] {
      for kw in &keywords {
        if check(&s, i, kw) {
          dp[i+kw.len()] = true;
        }
      }
    }
  }
  if dp[s.len()] {
    echo!("YES");
  } else {
    echo!("NO");
  }
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A;
    A.push_back('$');
    string s;
    cin >> s;
    A += s;
    const int N = A.size();
    vector<vector<int>> nextpos(N, vector<int>(26, N));
    for (int c = 0; c < 26; c++) {
        int pos = N;
        for (int j = N - 1; j >= 0; j--) {
            nextpos[j][c] = pos;
            if (A[j] == c + 'a') {
                pos = j;
            }
        }
    }
    vector<int> dp(N + 1, 0);
    vector<int> next(N + 1, -1);
    vector<int> ch(N + 1);
    dp[N] = 0;
    for (int i = N - 1; i >= 0; i--) {
        int mini = N;
        for (int c = 0; c < 26; c++) {
            const int n = nextpos[i][c];
            if (dp[n] + 1 < mini) {
                mini = dp[n] + 1;
                next[i] = n;
                ch[i] = c;
            }
        }
        dp[i] = mini;
    }
    int pos = 0;
    for (; pos < N;) {
        cout << (char)(ch[pos] + 'a');
        pos = next[pos];
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 29588
def main():
    n, l = map(int, input().split(' '))
    a = 199
    for i in range(1, n+1):
        if abs(taste(i, l)) < abs(a):
            a = taste(i, l)
    print(sum([taste(j, l) for j in range(1, n+1)]) - a)


def taste(i, l):
    return l + i - 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        long r = 0;
        long g = 0;
        long b = 0;

        for(int i = 0 ; i < s.length() ; i++){
            switch (s.charAt(i)){
                case 'R':
                    r++;
                    break;
                case 'G':
                    g++;
                    break;
                case 'B':
                    b++;
                    break;
            }
        }

        long sum = r*g*b;

        for(int i = 0 ; i < n ; i++){
            for(int d = 1 ; i + 2*d < n ; d++){
                if(s.charAt(i) != s.charAt(i+d) && s.charAt(i+d) != s.charAt(i+2*d) && s.charAt(i+2*d) != s.charAt(i)){
                    sum--;
                }
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 37080
#include <iostream>
#include<string>
using namespace std;
int main(){
   int a=0;
   string s;
   cin>>s;
   for(int i=0;i<s.length()-1;i++){
       if(s[i]==s[i+1]){
           cout<<"Bad";
           a=1;
           break;
       }
   }
   if(a==0){
       cout<<"Good";
   }// Your code here!
    
}


Measured memory_bytes: 256
#include <iostream>
#include<string>

 
using namespace std;
char S[101010];
 
int main()
{
	scanf("%s", S);
 
	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x,n,d;
	cin >> x >> n;
	set <int> s;
	for (int i = -100; i <= 200; ++i){
		s.insert(i);
	}
	for (int i = 0; i < n; ++i){
		cin >> d;
		s.erase(d);
	}
	int ans = INT_MAX, m = INT_MAX;
	for (auto j : s){
		if (abs(j - x) < m){
			ans = j;
			m = abs(j-x);
		}
	}
	cout << ans << "\n";	
	return 0;
}


Measured memory_bytes: 3664
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  myout(Math.pow(Math.floor(Math.sqrt(input)),2));
}

Main(myin());


Measured memory_bytes: 7372
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 10**12
for i in range(N - K + 1):
    l = A[i]
    r = A[i + K - 1]
    d = r - l + min(abs(r), abs(l))
    ans = min(d, ans)

print(ans)


Measured memory_bytes: 14252
import math
A, B = map(int,input().split())
def yakusuu(N):
    P = set([1,N])
    for k in range(2,math.floor(math.sqrt(N))+1):
        if N % k == 0:
            P.add(k)
            P.add(N//k)
    return P
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
C = sorted(list(yakusuu(A)&yakusuu(B)))
N = len(C)
if N == 1:
    print(1)
else:
    ans = 0
    for k in range(N):
        f = 1
        for l in range(k):
            if gcd(C[k],C[l]) != 1:
                f = 0
                break
        ans += f
    print(ans)


Measured memory_bytes: 42096
N,L,T=map(int,input().split())
X=[0 for i in range(N)]
W=[0 for i in range(N)]
D=0
for i in range(N):
    X[i],W[i]=map(int,input().split())
    W[i]=-2*W[i]+3
    D+=(X[i]+T*W[i])//L
D%=N
Y=sorted([((T*W[i])+X[i])%L for i in range(N)])
for i in range(N):
    print(Y[(D+i)%N])

Measured memory_bytes: 12968
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto HW = readints;
    int H = HW[0], W = HW[1];
    auto hw = readints;
    int h = hw[0], w = hw[1];

    int ans = H * W - h * W - H * w + h * w;
    writeln(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

#define LENGTH 256

int main(void) {
    char input[LENGTH];
    int n[2];
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d %d", &n[0], &n[1]);
    int add, dec, div;

    add = n[0] + n[1];
    dec = n[0] - n[1];
    div = n[0] * n[1];

    int max = add;
    if(max < dec){
        max = dec;
    }
    if(max < div){
        max = div;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string s, t, x;
int i, j, mn=10000, l;
int main()
{
	cin >> s >> t;
	for (i=0; i<=s.size()-t.size(); i++)
	{
		for (j=i; j<=i+t.size(); j++)
		x+=s[j];
		for (j=0; j<t.size(); j++)
		if (t[j]!=x[j]) l++;
		if (l<mn) mn=l;
		l=0; x="";
	}
	cout<<mn;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n,k,t,h=0,a[1000]={0};
	 while(cin>>n)
	 {
	 	 if(!n)
	 	 {
	 	 	 printf("0\n");
	 	 	 continue;
		  }
		  while(n)
		  {
		  	k=n%(-2);
			 t=n/(-2);
			 if(k<0)
			 {
			 	 k=-k;
			 	 t++;
			  } 
			  n=t;
			  a[h++]=k;
		  }
		  for(int i=h-1;i>=0;i--)
		  printf("%d",a[i]);
		  printf("\n");
	 }
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val xs = getArray[Int]

    out.println(
      xs.zipWithIndex.find {
        case (x, i) => x == 0
      }.get._2 + 1
    )

    out.flush()
  }
}

Measured memory_bytes: 56976
#include<iostream>
using namespace std;
int main() {
	string S, T,U;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	cin >> U;
	if (S == U) {
		A--;
	}
	else {
		B--;
	}
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  map<ll, ll> mp;
  REP(i, n){
    ll a;
    cin >> a;
    mp[a+1]++;
    mp[a-1]++;
    mp[a]++;
  }
  ll ans = 0;
  for(auto p : mp){
    chmax(ans, p.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6144
y, m, d = map(int, input().split("/"))
b = 0
if y <= 2018:
    b = 1
elif y == 2019 and m <= 3:
    b = 1
elif y == 2019 and m == 4 and d <= 30:
    b = 1
if b:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int N, odd=0, i, a;
	scanf("%d",&N);
	for(int i=0; i<N; i++){
		scanf("%d", &a);
		if(a%2)odd++;
	}
	if(odd%2==0)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 128
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    print(read_list().index(0) + 1)

if __name__ == "__main__":
    main()



Measured memory_bytes: 9812
#include<iostream>
#include<algorithm>
using namespace std;
long long a, b, p[64], q[64];
long long overlap(long long a1, long long a2, long long b1, long long b2) {
	long long z[4] = { a1,a2 + 1,b1,b2 + 1 }; sort(z, z + 4);
	int used[4] = { 0,0,0,0 };
	int pos1 = lower_bound(z, z + 4, a1) - z;
	int pos2 = lower_bound(z, z + 4, a2 + 1) - z;
	int pos3 = lower_bound(z, z + 4, b1) - z;
	int pos4 = lower_bound(z, z + 4, b2 + 1) - z;
	for (int i = pos1; i < pos2; i++)used[i] = 1;
	for (int i = pos3; i < pos4; i++)used[i] = 1;
	long long ret = 0;
	for (int i = 0; i < 3; i++)ret += 1LL * used[i] * (z[i + 1] - z[i]);
	return ret;
}
int main() {
	cin >> a >> b; if (a == b) { cout << "1" << endl; return 0; }
	for (int i = 0; i < 62; i++)p[i] = (a / (1LL << i)) % 2, q[i] = (b / (1LL << i)) % 2;
	long long D = 0, E = 0;
	for (int i = 61; i >= 0; i--) {
		if (q[i] == 1)E = max(E, (long long)i + 1);
		D += q[i] * (1LL << i);
		if (p[i] != q[i]) {
			long long L1 = a + (1LL << i), R1 = D + (1LL << i) - 1;
			long long L2 = a, R2 = D - (1LL << i) * q[i];

			int P = 0;
			for (int j = i; j >= 0; j--) { if (p[j] == 1)P = 1; }
			for (int j = i - P; j >= 0; j--) { if (q[j] == 1) { R2 += (1LL << (j + 1)) - 1; break; } }
			if (R2 < b)R2 += (1LL << i)*q[i];
			cout << overlap(L1, R1, L2, R2) << endl; break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
base_dict = {"A": "T", "T": "A", "G": "C", "C": "G"}

S = input()

max_count = 0
current_count = 0

i = 0
loop = 0
while i < len(S):
    if S[i] in base_dict:
        current_count += 1
        i += 1
    else:
        if max_count < current_count:
            max_count = current_count
        current_count = 0
        loop += 1
        i = loop

if max_count < current_count:
    max_count = current_count

print(max_count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
long N,M,i,x;
std::priority_queue<int>q;
main(){
std::cin>>N>>M;
for(;N--;std::cin>>x,q.push(x));
for(;M--;x=q.top()/2,q.pop(),q.push(x));
for(x=0;!q.empty();x+=q.top(),q.pop());
std::cout<<x;
}

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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

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

    ll temp;
    for(int i=0;i<m;i++){
        cin>>temp;
        n -= temp;
    }
    if(n < 0) cout<<-1<<endl;
    else cout<<n<<endl;


    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<bitset>
#include<cctype>

int read(){
	char ch;
	while (isspace(ch=getchar()));
	int ret=ch&15;
	while (isdigit(ch=getchar())) ret=(ret<<1)+(ret<<3)+(ch&15);
	return ret;
}

int n,sum,ans;
std::bitset<4000001> B;

int main(){
	n=read();B[0]=1;
	while (n--){
		int x=read();
		sum+=x;
		B|=B<<x;
	}
	ans=sum>>1;
	while (!B[ans]) ans--;
	printf("%d\n",sum-ans);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ld = long double;
constexpr ld eps = 1e-8;

struct S {
  ld p[3];
  ld v[3];
  ld r, vr;
};

vector<ld> solve_quad_eq(ld a, ld b, ld c) {
  vector<ld> res;
  if (abs(a) < eps) {
    res.push_back(-c/b);
    return res;
  }
  ld d = b*b - 4*a*c;
  if (d < -eps) return res;
  if (d < eps) {
    res.push_back(-b/(2*a));
    return res;
  }
  ld p = -b + sqrt(d);
  if (abs(p) < eps) {
    res.push_back(-2*c/(b+sqrt(d)));
  } else {
    res.push_back(p/(2*a));
  }
  ld q = -b - sqrt(d);
  if (abs(q) < eps) {
    res.push_back(-2*c/(b-sqrt(d)));
  } else {
    res.push_back(q/(2*a));
  }
  return res;
}

int main() {
  cout << fixed << setprecision(10);
  while (true) {
    int n;
    cin>>n;
    if(!n) break;
    vector<S> vs;
    using P = pair<int,int>;
    multimap<ld, P> vt;
    REP(i,n) {
      ld px, py, pz, vx, vy, vz, r, vr;
      cin >>px>>py>>pz>>vx>>vy>>vz>>r>>vr;
      vs.push_back({{px,py,pz},{vx,vy,vz},r,vr});
      vt.insert(make_pair(r/vr, make_pair(i, i)));
    }
    REP(i,n)REP(j,i) {
      ld c0 = 0, c1 = 0, c2 = 0;
      REP(k,3) {
        ld a = vs[i].v[k] - vs[j].v[k];
        ld b = vs[i].p[k] - vs[j].p[k];
        c0 += b*b;
        c1 += 2*a*b;
        c2 += a*a;
      }
      ld a = -vs[i].vr + -vs[j].vr;
      ld b = vs[i].r + vs[j].r;
      c0 -= b*b;
      c1 -= 2*a*b;
      c2 -= a*a;
      vector<ld> r = solve_quad_eq(c2, c1, c0);
      for (ld t : r) {
        if (t > 0) {
          vt.insert(make_pair(t, make_pair(i, j)));
        }
      }
    }
    vector<bool> exist(n, true);
    vector<ld> death(n);
    for (const auto &p : vt) {
      ld t = p.first;
      int i, j;
      tie(i, j) = p.second;
      if (exist[i] && exist[j]) {
        death[i] = death[j] = t;
        exist[i] = exist[j] = false;
      }
    }
    for (ld t : death) {
      cout << t << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5040
k = int(input())

if(k%2 == 0 or k%5 == 0):
    print('-1')
else:
    if(k%7 == 0):
        k = k // 7
    num = 1
    ans = 1
    while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1




Measured memory_bytes: 9076
from itertools import permutations

N = int(input())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))

for i, Rs in enumerate(permutations(range(1, N+1)), 1):
    Rs = list(Rs)
    if Ps == Rs:
        a = i
    if Qs == Rs:
        b = i

print(abs(a-b))


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

int main() {
	int N, M;
	cin >> N >> M;
	int ans = 0;
	if (N != 1) {
		ans += (N * (N - 1) / 2);
	}
	if (M != 1) {
		ans += (M * (M - 1) / 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
		int a = sc.nextInt();
		// 出力
		System.out.println(x>=a?10:0);
	}
}

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

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    cin>>n;
    int d[200][200];
    rep(i,200){
        rep(j,200){
            if(i==j)d[i][j] = 0;
            else d[i][j] = 1<<20;
        }
    }
    rep(i,n){
        int src,k;
        cin>>src>>k;
        src--;
        rep(j,k){
            int dst;cin>>dst;
            dst--;
            d[src][dst] = 1;
        }
    }

    rep(k,n)rep(i,n)rep(j,n){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }

    int p;cin>>p;
    rep(i,p){
        int s, t, ttl;
        cin >> s >> t >> ttl;
        --s; --t;
        if(d[s][t] >= ttl) puts("NA");
        else printf("%d\n", d[s][t] + 1);
    }
}

Measured memory_bytes: 1296
#include<stdio.h>
int main(int argc){
int W,H,x,y,r,M,m,R,L;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
M=y+r;
m=y-r;
R=x+r;
L=x-r;
if (M<=H&&m>=0&&R<=W&&L>=0)
puts("Yes");
else puts("No");
return 0;
}

Measured memory_bytes: 584
# D

# 10^12 < 2^40

def hard_log2(N):
    
    r = 1
    l = 0
    while N >= 2*r:
        r *= 2
        l += 1
    return r, l

def maximize_simple(r_list, K, N):
    if K == 0:
        return 0
    R = 0
    L, M = hard_log2(K)
    for i in range(M+1):
        R += max(r_list[i], N - r_list[i])*(2**i)
        
    return R

def maximize(r_list, K, N):
    
    if K == 0:
        return 0
    
    L, M = hard_log2(K)
    
    if r_list[M] >= N - r_list[M]:
        return maximize_simple(r_list, L-1, N)+r_list[M]*(2**M)
    else:
        R = (N-r_list[M])*(2**M)
        m = M - 1
        while 2**m > K-L and m >=0:
            R += r_list[m]*(2**m)
            m -= 1
        
        return max(maximize(r_list, K-L, N)+R, maximize_simple(r_list, L-1, N)+r_list[M]*(2**M))

def main_d(A_list, N, K):
    r_list = [0]*41
    for i in range(41):
        for A in A_list:
            if (A % 2**(i+1)) >= 2**i:
                r_list[i] += 1
    if K == 0:
        R = 0
        for i in range(41):
            R += r_list[i]*(2**i)
        return R
    else:
        L, M = hard_log2(K)
        R = 0
        for i in range(M+1, 41):
            R += r_list[i]*(2**i)
        return R + maximize(r_list, K, N)
    

if __name__ == "__main__":
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    res = main_d(A_list, N, K)
    print(res)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n,m,k; cin >> n >> m >> k;
    vector<string> A(n);
    ll S=0;
    for (int i=0;i<n;i++)
    {
        cin >> A[i];
        for (int j=0;j<m;j++) S+=(A[i][j]=='#');
    }
    ll sum=0,ans=0;
    for (ll x=0;x<(1<<n);x++)
    {
        for (ll y=0;y<(1<<m);y++)
        {
            sum=0;
            for (int i=0;i<n;i++)
            {
                if (x&(1<<i))
                {
                    for (int j=0;j<m;j++)
                    {
                        if ((y&(1<<j))==0) sum+=(A[i][j]=='#');
                    }
                }
            }
            for (int j=0;j<m;j++)
            {
                if (y&(1<<j))
                {
                    for (int i=0;i<n;i++)
                    {
                        sum+=(A[i][j]=='#');
                    }
                }
            }
            if (S-sum==k) ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
int main(){
int temp,L,R,i,ans =3000,m;
scanf("%d%d",&L,&R);
  temp = L%2019;
  if(R-L > 2019){
    printf("0");
  }
  else if(temp+R-L >= 2019){
    printf("0");
  }
  else{
    for(i = temp;i<=R%2019;i++){
      for(m =temp;m<=R%2019;m++){
      if(i!=m){
        if(ans>(i*m)%2019){
          ans=(i*m)%2019;
          }
      }
      }
    }
    printf("%d",ans);
  }
return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
c = 0
min = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if a[j] < a[minj]:
            minj = j
    if(i != minj):
        a[i],a[minj] = a[minj],a[i]
        c += 1
    
print(*a)
print(c)


Measured memory_bytes: 5608
#include <cstdio>
#include <algorithm>
#define inf 1001001001
using namespace std;
int n, a, dp[100000];
int main() {
	scanf("%d", &n);
	fill(dp, dp+n, inf);
	for (int i=0; i<n; i++) {
		scanf("%d", &a);
		*lower_bound(dp, dp+n, a) = a;
	}
	printf("%ld\n", (lower_bound(dp, dp+n, inf) - dp));
}

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

class Program
{
    static int N, K;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        K = Input.NextInt();

        var log2 = Math.Log(2);
        double ans = 0;
        for (int n = 1; n <= Math.Min(K, N); n++)
        {
            var K_n = (double)K / (double)n;
            var m = Math.Log(K_n) / log2;
            var M = Math.Ceiling(m);

            var inCasen = Math.Pow(0.5, M);

            ans += inCasen / N;
        }
        if (N > K)
        {
            ans += (double)(N - K) / N;
        }

        Console.WriteLine(ans);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
//Be Name Khoda
//man az biganegan  hargez  nanalam
//ke harche kard ba man ashena kard
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n;
ll a[M];
ll mx,gc,k;

int main()
{
    GEL(n);
    GEL(k);
    For(i,0,n) 
    {
        ll x;
        GEL(x);
        smax(mx,x);
        gc=__gcd(x,gc);
    }    
    if (k>mx || k%gc)
    {
        RET("IMPOSSIBLE");
    }
    RET("POSSIBLE");
}

Measured memory_bytes: 256