akhauriyash/Code-Regression huggingface dataset:
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll pre[1000005],pre1[1000005],k[100],pre2[1000005];

int main(){
	std::ios::sync_with_stdio(false);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		ll n,q,i,j,id,ans,res=0,val=0;
		cin>>n;
		string s;
		cin>>s;
		cin>>q;
		rep(i,q){
			cin>>k[i];
		}
		rep(i,n){
			pre[i]=i>0?pre[i-1]:0;
			pre1[i]=i>0?pre1[i-1]:0;
			pre2[i]=i>0?pre2[i-1]:0;
			
			if(s[i]=='M'){
				val++;
				pre2[i]++;
			}
			if(s[i]=='C'){
				pre1[i]+=val;
				pre[i]++;
			}
			//cout<<pre[i]<<" "<<pre1[i]<<endl;
		}
		rep(i,q){
			res=0;
			rep(j,n){
				id=min(n-1,j+k[i]-1);
				if(s[j]=='D'){
					ans=pre1[id]-pre1[j];
					ans-=pre2[j]*(pre[id]-pre[j]);
					res+=ans;
				}
			}
			cout<<res<<endl;
		}
	}
} 
	

Measured memory_bytes: 24860
#include<stdio.h>

int main(){
	double taiju;
	
	while(0<=scanf("%lf",&taiju)){
		if(48.00>=taiju){
			printf("light fly\n");
		}else if(51>=taiju){
			printf("fly\n");
		}else if(54>=taiju){
			printf("bantam\n");
		}else if(taiju<=57){
			printf("feather\n");
		}else if(taiju<=60){
			printf("light\n");
		}else if(taiju<=64){
			printf("light welter\n");
		}else if(taiju<=69){
			printf("welter\n");
		}else if(taiju<=75){
			printf("light middle\n");
		}else if(taiju<=81){
			printf("middle\n");
		}else if(taiju<=91){
			printf("light heavy\n");
		}else{
			printf("heavy\n");
		}
	}
	return 0;
}
/*
					
					light fly	
fly	48.00kg ツ陳エ51.00kg ツ暗按可コ
bantam	51.00kg ツ陳エ54.00kg ツ暗按可コ
feather	54.00kg ツ陳エ57.00kg ツ暗按可コ
light	57.00kg ツ陳エ60.00kg ツ暗按可コ
light welter	60.00kg ツ陳エ64.00kg ツ暗按可コ
welter	64.00kg ツ陳エ69.00 kg ツ暗按可コ
light middle	69.00kg ツ陳エ75.00 kg ツ暗按可コ
middle	75.00kg ツ陳エ81.00 kg ツ暗按可コ
light heavy	81.00kg ツ陳エ91.00 kg ツ暗按可コ
heavy	91.00kg ツ陳エ*/

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String moji=sc.nextLine();
        String[] moji2=moji.split(" ");
        int[] moji3=new int[3];
        int five=0;
        int seven=0;
        for(int i=0;i<3;i++)
        {
            moji3[i]=Integer.parseInt(moji2[i]);
        }
        for(int j=0;j<3;j++)
        {
            if(moji3[j]==5)
            {
                five++;
            }
            else if(moji3[j]==7)
            {
                seven++;
            }
        }
        if(five==2&&seven==1)
        {
            System.out.println("YES");
        }
        else 
        {
            System.out.println("NO");
        }
    }
}

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

using namespace std;

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

    int n;
    cin >> n;
    vector <int> A(n);

    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    A.resize(unique(A.begin(), A.end()) - A.begin());

    cout << int(A.size()) - (int(A.size()) % 2 == 0) << '\n';
    return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=100000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
inline int add(int a,int b){return (a+=b)>=P?a-P:a;}
inline int sub(int a,int b){return (a-=b)<0?a+P:a;}
inline int mul(int a,int b){return 1LL*a*b%P;}
int n,mx=0;
bool a[maxn];
int main(){
    read(n);
    for (int i=1;i<=n;i++){
        int l,r;
        read(l),read(r);
        mx=max(mx,r);
        for (int j=l;j<=r;j++) a[j]=1;
    }
    int cnt=0;
    for (int i=1;i<=mx;i++) cnt+=a[i];
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
import sys
from itertools import accumulate
N, K = map(int, input().split())
*A, = map(int, input().split())
S = sum(A)

div_small = []
div_large = []
for p in range(1, int(S**0.5)+1):
    if S % p == 0:
        div_small.append(p)
        if S // p != p:
            div_large.append(S//p)
div_large += div_small[::-1]

for d in div_large:
    R = sorted([a % d for a in A])
    SR = sum(R)
    acc = tuple(accumulate(R))

    for i, l in enumerate(acc):
        r = d*(N-i-1)-(SR-l)
        if l == r:
            if l <= K:
                print(d)
                sys.exit()
            else:
                break


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>

using namespace std;

int main(){
  int N, X; 
  int i=0;
  int min=0;
  int sum=0;
  int input;
  cin >> N >> X;
  while(cin >> input){
    if(i==0 || min > input){
      min = input;
    }
    sum += input;
    i++;

    if(i>=N){
      break;
    }
    
  }
  cout << N+(X-sum)/min << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())


i=0
s=[]
while(i<n):
    s.append(input())
    i+=1

print("AC x "+str(s.count('AC')))
print("WA x "+str(s.count('WA')))
print("TLE x "+str(s.count('TLE')))
print("RE x "+str(s.count('RE')))


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];
    sort(ALL(a));
    int ans = 0;
    for(auto itr = a.begin(); itr != a.end();)
    {
        int count = upper_bound(ALL(a), *itr) - lower_bound(ALL(a), *itr);
        if(count < *itr) ans += count;
        else ans += count - *itr;
        itr = upper_bound(ALL(a), *itr);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 640
import heapq

N,M = map(int, input().split())
A_list = list(map(int, input().split()))
for i in range(N):
    A_list[i] *= -1

heapq.heapify(A_list)

for i in range(M):
    heapq.heappush(A_list, ((heapq.heappop(A_list) * -1 )// 2) * -1)

print(sum(A_list) * -1)



Measured memory_bytes: 14180
package main

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

var alpha = "abcdefghijklmnopqrstuvwxyz"

func dfs(str string, maxNum int, required int) {
	if len(str) == required {
		fmt.Println(str)
		return
	}
	for i := 0; i < maxNum+1; i++ {
		t := str + string(alpha[i])
		dfs(t, compare(i+1, maxNum), required)
	}
}

func compare(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	N := sc.nextInt()
	dfs("", 0, N)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 5888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int a[N];
int main(){

    int n;
    scanf("%d",&n);
    int minn=INF,maxx=-INF;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        minn=min(minn,a[i]);
        maxx=max(maxx,a[i]);
    }

    int res=INF;
    for(int i=minn;i<=maxx;i++){
        int temp=0;
        for(int j=1;j<=n;j++)
            temp+=( (a[j]-i)*(a[j]-i) );
        res=min(res,temp);
    }

    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void sort(int *a,int n)
{
        int max,index,i,j;
        for(i=0;i<n;i++){
                max=a[i];index=i;
                for(j=i;j<n;j++){
                        if(max<a[j]){
                                max=a[j];  index=j;
                        }
                }
                a[index]=a[i]; a[i]=max;
        }
        return ;
}
int  main(void)
{
        int n,i,alice=0,bob=0;
        scanf("%d",&n);
        int a[n];
        for(i=0;i<n;i++)
                scanf("%d",&a[i]);

        sort(a,n);
        for(i=0;i<n;i+=2){
                alice+=a[i];
        }
        for(i=1;i<n;i+=2){
                bob+=a[i];
        }
        printf("%d\n",alice-bob);
        return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	int p[n],mn[n];
	for(int i=0; i<n; i++){
		cin >> p[i];
		mn[i]=1e9;
	}
	int ans=0;
	for(int i=0; i<n; i++){
		mn[i]=min(mn[i],p[i]);
		if(i)mn[i]=min(mn[i],mn[i-1]);
		if(mn[i]==p[i])ans++;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 1792
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, m) = nextIntList()
    val s = next()
    var ng = StringBuilder("")
    repeat(m){
        ng.append("1")
    }
    if(s.contains(ng)){
        println(-1)
        return
    }

    var now = n
    val ans = mutableListOf<Int>()
    while(now != 0){

        if(now <= m){
            ans.add(0, now)
            break
        }
        for(i in m downTo 1){
            val next = now - i
            if(s[next] == '0'){
                ans.add(0, i)
                now = next
                break
            }
        }
    }

    println(ans.joinToString(" "))
}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()


Measured memory_bytes: 41484
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine().replace("\n", "");
        sc.close();

        List<Character> exist = new ArrayList<Character>();
        for (int i = 0; i < s.length(); i++) {
            Character a = s.charAt(i);
            if (exist.contains(a)) {
                System.out.println("no");
                System.exit(0);
            } else {
                exist.add(a);
            }
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//誤差を考慮して足し算
double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
	return a + b;
}
struct P {//2次元ベクトル
	double x, y;
	P() {}
	P(double x, double y) :x(x), y(y) {}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x * d, y * d);
	}
	P operator / (double d) {
		return P(x / d, y / d);
	}
	double dot(P p) {//内積
		return add(x * p.x, y * p.y);
	}
	double det(P p) {//外積
		return add(x * p.y, -y * p.x);
	}
	bool equal(P p) {
		return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) < EPS * EPS;
	}
	double norm()const {
		return sqrt(x * x + y * y);
	}
};

//原点中心回転
P rotate(P p, double rad) {
	double s = sin(rad), c = cos(rad);
	return P(c * p.x - s * p.y, s * p.x + c * p.y);
}
//originを中心に回転
P rotate(P p, double rad, P origin) {
	return origin + rotate(p - origin, rad);
}
//二点間の距離
double dist(P p, P q) {
	p = p - q;
	return sqrt(p.x * p.x + p.y * p.y);
}
//単位ベクトルに変換
P to_unit(P p) {
	double d = sqrt(p.x * p.x + p.y * p.y);
	return p / d;
}
//円同士の交点を計算
pair<P, P> circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	double rad = atan2(y2 - y1, x2 - x1);
	x2 -= x1;
	y2 -= y1;
	P tmp = rotate(P(x2, y2), -rad);
	x2 = tmp.x;
	y2 = tmp.y;
	double x = (r1 * r1 - r2 * r2 + x2 * x2) / (2 * x2);
	if (abs(r1) < abs(x))return make_pair(P(0, 0), P(0, 0));//交点なし
	double y = sqrt(r1 * r1 - x * x);
	return make_pair(P(x1, y1) + rotate(P(x, y), rad), P(x1, y1) + rotate(P(x, -y), rad));
}


int n, k;
double x[60];
double y[60];
double c[60];


bool f(double mid) {
	double r[60];
	rep(i, n)r[i] = mid / c[i];
	vector<P> ps;
	rep(j,n) {
		rep(i,j) {
			if (dist(P(x[i], y[i]), P(x[j], y[j])) < r[i] + r[j] + EPS) {
				auto pp = circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
				ps.push_back(pp.first);
				ps.push_back(pp.second);
			}
		}
	}
	rep(i, n)ps.push_back(P(x[i], y[i]));

	for (const P &p : ps) {
		int cnt = 0;
		rep(i, n) {
			P q(x[i], y[i]);
			if (dist(p, q) <= r[i] + EPS) {
				cnt++;
			}
		}
		if (k <= cnt)return true;
	}

	return false;
}


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

	cin >> n >> k;
	rep(i,n) {
		cin >> x[i] >> y[i] >> c[i];
	}
	double lb = 0, ub = 100 * 4000;
	rep(_, 50) {
		double mid = (lb + ub) / 2;
		if (f(mid))ub = mid;
		else lb = mid;
	}
	printf("%.8f\n", ub);


	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> dp(1e5+1,-1);
  dp[0] = 0;
  for (int i = 1; i <=k; i++) {
    dp[i] = abs(a[0] - a[i]);
  }

  for (int i = k + 1; i < n; i++) {
    int c = INF;
    for (int j = 1; j <= k; j++) {
      int b = dp[i-j] + abs(a[i] - a[i-j]);
      c = min(c,b);
    }
    dp[i] = c;
  }

  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nums = inputs.head.split(" ")
  val a = nums(0)
  val b = nums(1)
  val c = nums(2)

  println(solve(a, b, c))

  private def solve(a: String, b: String, c: String): String = {
    if (a(a.size - 1) == b(0) && b(b.size - 1) == c(0)) {
      "YES"
    } else {
      "NO"
    }
  }
}

Measured memory_bytes: 54980
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll k; cin>>k;
	cout<<a[k-1]<<endl;
	return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

int main() {

    int n;
    cin >> n;
    vi a(n + 1);
    vi b(n);
    fo(i, n + 1) cin >> a[i];
    fo(i, n) cin >> b[i];

    ll ans = 0;

    fo(i, n) {
        ans += min(b[i], a[i]);
        b[i] -= min(b[i], a[i]);
        ans += min(b[i], a[i + 1]);
        a[i + 1] -= min(b[i], a[i + 1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long n,a,b;
    cin>>n>>a>>b;
    
    if(!((b-a)%2)){
        cout<<(b-a)/2;
        return 0;
    }
    cout<<min(a+(b-a)/2,n+1-b+(b-a)/2);
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    cout << a + b/2 << endl;
    
    return 0;
}

Measured memory_bytes: 888
function Main(input) {
    var data = input.split("\n")
	var num = parseInt(data[0]);
 	if(num==1){
    	console.log(1)
    }else if(num%2==0){
    	console.log(0.5)
    }else{
     	console.log((num+1)/2/num);
    }
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
template <class T>
using vector = std::vector<T>;
template <class T, u64 N>
using array = std::array<T, N>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    i32 n, k, q;
    cin >> n >> k >> q;
    auto vec = read_vector(q);
    vector<i32> members(n, k - q);

    for (i32 i = 0; i < q; i++)
    {
        members[vec[i] - 1] += 1;
    }

    for (auto s : members)
    {
        cout << (s <= 0 ? "No" : "Yes") << endl;
    }

    return 0;
}


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

using namespace std;
mt19937_64 rng(58);

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int x;
    cin >> x;
    int lcm = 360 * x / gcd(360, x);
    cout << lcm / x << endl;
}

Measured memory_bytes: 3576
MOD = 1000000007

class Factorial():
    def __init__(self,n,mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n+1)]
        self.inv = [0 for _ in range(n+1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i+1] = self.factorial[i]*(i+1)%mod
        self.inv[n] = pow(self.factorial[n],mod-2,mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i+1]*(i+1)%mod
    def fact(self,m): #階乗
        return self.factorial[m]
    def invfact(self,m): #階乗の逆数
        return self.inv[m]
    def perm(self,m,k): #順列
        if m < k: return 0
        return self.factorial[m]*self.inv[m-k]%self.mod
    def comb(self,m,k): #組み合わせ 0<=k<=m<=n 重複組み合わせはcomb(m+k-1,k)
        return self.factorial[m]*self.inv[k]*self.inv[m-k]%self.mod



N,K = map(int,input().split())


F = Factorial(200010,MOD)
ans = 0

for i in range(min(K+1,N)):
    ans += F.comb(N-1,N-i-1)*F.comb(N,i)

print(ans%MOD)

Measured memory_bytes: 55372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,m,cur,ans=0;

struct store{int cost,num;}a[maxn];
bool comp(store x1, store x2){return x1.cost<x2.cost;}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m;
	rep(n) cin >> a[i].cost >> a[i].num;
	sort(a,a+n,comp);
	cur=m;
	rep(n){
		if(cur<a[i].num){
			ans+=cur*a[i].cost;
			break;
		}
		else{
			ans+=a[i].num*a[i].cost;
			cur-=a[i].num;
		}
	}
	print1(ans);
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // ans: 連続部分列の和がmod mで0になるi, jのパターン数
        long ans = 0;
        
        // 式変形
        // ・連続部分列の和がmod 0になるi, j
        // -> 累積和(mod m)が0になるi, j
        // -> s[j+1] - s[i] = 0 (mod m)
        // -> s[j+1] = s[i] のパターン数
        
        // s: 累積和 (mod m)
        long[] s = new long[n+1];
        for (int i = 0; i < n; i++) {
            s[i+1] = (s[i] + array[i]) % m;
        }
        
        // i, jのパターン数を数え上げる
        Map<Long, Integer> map = new HashMap<Long, Integer>();
        for (int i = 0; i <= n; i++) {
            long key = s[i];
            int cnt = map.getOrDefault(key, 0);
            
            ans += cnt;
            map.put(key, ++cnt);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 53512
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <cassert>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;

ll root(const ll n)
{
    if (n == 1) {
        return 1;
    } else if (n == 0) {
        return 0;
    }
    ll inf = 0;
    ll sup = n;
    while (inf < sup - 1) {
        const ll mid = (inf + sup) / 2;
        const ll sq = mid * mid;
        if (sq < n) {
            inf = mid;
        } else if (sq > n) {
            sup = mid;
        } else {
            return mid;
        }
    }
    return inf;
}

int main()
{
    ll A;
    cin >> A;
    ll inf = 0;
    ll sup = 100000;
    while (inf < sup - 1) {
        const ll mid = (inf + sup) / 2;
        const ll calc = mid * (mid + 1) / 2;
        if (calc < A) {
            inf = mid;
        } else if (calc > A) {
            sup = mid;
        } else {
            sup = mid;
            inf = mid;
        }
    }
    const ll l = sup;
    ll area = 2 * A - l;
    auto sq = [=](const ll x, const ll y) {
        return (l - x) * (l - x) - 2 * (l - y);
    };
    auto up_add = [=](const ll x, const ll y) {
        return 0;
        //        return 2 * x;
    };
    auto right_add = [=](const ll x, const ll y) {
        return 2 * y - 2 * x - 1;
    };

    ll x = 0;
    ll y = 1;
    string s = ")";
    for (int i = 0; i < 2 * l - 1; i++) {
        if (area <= sq(x, y)) {
            s.push_back('(');
            area -= right_add(x, y);
            x++;
        } else {
            s.push_back(')');
            area -= up_add(x, y);
            y++;
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3300
n=int(input())
s=[input() for i in range(n)]
for i in range(n):
    s[i]=''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))


Measured memory_bytes: 19476
unittest
{
	assert( [ "4 5", "1 2", "3 4", "1 3", "2 3", "1 4" ].solve == "0\n0\n4\n5\n6" );
	assert( [ "6 5", "2 3", "1 2", "5 6", "3 4", "4 5" ].solve == "8\n9\n12\n14\n15" );
	assert( [ "2 1", "1 2" ].solve == "1" );
}



import std.conv;
import std.format;
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 = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto abs = new long[ 2 ][ m ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	
	// 逆順で不便さを計算
	auto anss = new long[ m ];
	auto f = n * ( n - 1 ) / 2;
	auto uft = UnionFindTree( n );
	foreach_reverse( i, ab; abs )
	{
		anss[ i ] = f;
		if( uft.same( ab[ 0 ], ab[ 1 ] ) ) continue;
		f -= uft.weight( ab[ 0 ] ) * uft.weight( ab[ 1 ] );
		uft.unite( ab[ 0 ], ab[ 1 ] );
	}
	return anss.to!( string[] ).join( "\n" );
}

// UnionFind木
struct UnionFindTree
{
	long[] ps;
	long[] rs;
	long   rn;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
		rn = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	auto unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
		rn--;
	}
	
	auto weight( long i )
	{
		return -ps[ root( i ) ];
	}
	
	auto toString()
	{
		return ps.to!( string );
	}
}


Measured memory_bytes: 11244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  string S, T;
  int len;
  cin >> len >> S >> T;
  string res = "";
  for (int i = 0; i < len; i++) {
    res += S[i];
    res += T[i];
  }
  cout << res << endl;
  return 0;
}

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

int main()
{
    int n;
    int x, y;
    int b, p;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        cin >> b >> p;

        int a1 = x * b + y * p;
        int a2 = (a1 + max(0, 5-b)*x + max(0, 2-p)*y) / 10 * 8;

        cout << min(a1, a2) << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
main = do
  getLine
  ns <- map read . words <$> getLine
  print . solve $ ns

solve :: [Int] -> Int
solve = fst . foldl step (1,(0, 0, 0))
  where
    step :: (Int, (Int, Int, Int)) -> Int -> (Int, (Int, Int, Int))
    step (0, x) _ = (0, x)
    step (n, (a, b, c)) d
      | a == d && a == b && b == c = (3 * n `mod` modulo, (a+1, b, c)) 
      | a == d && a == b           = (2 * n `mod` modulo, (a+1, b, c)) 
      | a == d                     = (n,                  (a+1, b, c)) 
      | b == d && b == c           = (2 * n `mod` modulo, (a, b+1, c)) 
      | b == d                     = (n,                  (a, b+1, c)) 
      | c == d                     = (n,                  (a, b, c+1))
      | otherwise                  = (0,                  (0, 0, 0))
 

modulo = 10^9 +7 :: Int

Measured memory_bytes: 45436
from collections import Counter
N = int(input())
S = list(input())
WL = [0]*(N+1)
for i in range(0,N):
    if S[i] == 'W':
        WL[i+1] = WL[i] + 1
    else:
        WL[i+1] = WL[i]
T = S[::-1]
ER = [0]*(N+1)
for i in range(0,N):
    if T[i] == 'E':
        ER[i+1] = ER[i] + 1
    else:
        ER[i+1] = ER[i]
ans = N
for i in range(N):
    ans = min(ans,WL[i]+ER[N-i-1])
print(ans)

Measured memory_bytes: 22708
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n; cin >> n;
    int ans = 800*n - 200*(n/15);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> strength(3 * n);
    for (size_t i = 0; i < 3 * n; ++i) cin >> strength[i];
    sort(strength.begin(), strength.end(), greater<int>());
    unsigned long long sum = 0;
    for(size_t i = 0, j = 1; i < n; j += 2, ++i) {
        sum += strength[j];
    }
    cout << sum << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<pair<ll,ll>> XL(N); rep(i,N) cin >> XL[i].first >> XL[i].second;
  vector<pair<ll,ll>> RL(N);
  rep(i,N){
    RL[i] = {XL[i].first+XL[i].second, XL[i].first-XL[i].second};
  }
  sort(all(RL));
  ll now = -1e17;
  int ans = 0;
  rep(i,sz(RL)){
    if(now <= RL[i].second){
      ans++;
      now = RL[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
//import java.io.File;
//import java.util.Scanner;
import java.util.Stack;

class Main{
  public static void main(String[] args) throws Exception{
    //Scanner scan = new Scanner(new File("in.txt"));
    //Scanner scan = new Scanner(System.in);
    MyScanner scan = new MyScanner();

    int input1 = scan.nextInt();
    Stack<Integer> st = new Stack<>();
    int stc = 0;
    int answer = 0;

    for(int incount = 0; incount < input1; incount++) {
      int input2 = scan.nextInt();
      boolean flag = true;

      while(!st.isEmpty()) {
        if(st.peek() > input2) {
          st.pop();
          answer++;
          stc--;
        }else break;
      }
      if(!st.isEmpty()) {
        if(st.peek() < input2) {
          st.push(input2);
          stc++;
        }
      }
      if(st.isEmpty()) {
        stc++;
        st.push(input2);
      }

      /*
      for(int j = 0; j < ite; j++) {
        System.out.print(arr[j]+",");
      }
      System.out.println(" answer -> "+answer);
      */
    }
    System.out.println(answer+stc);
  }
}

class MyScanner{
  StringBuilder sb;
  MyScanner() {sb = new StringBuilder();}

  int nextInt() throws Exception{
    sb.delete(0,2147483647);
    while(true) {
      int c = System.in.read();
      //System.out.println("c:"+c);
      if(c == ' ' || c == '\n' || c == '\r' || c < 16) {
        //System.out.println("return");
        return Integer.parseInt(sb.toString());
      }
      sb.appendCodePoint(c);
      //System.out.println(sb.toString());
    }
  }
}

Measured memory_bytes: 40124
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=[0]*26
P=[]
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  P.append([])
  for j in range(26):
    P[i].append(j)
  P[i].sort(reverse=True,key=lambda x:X[x]+S[i][x])
SC,SC2=0,0
X=[0]*26
for i in range(D):
  SC+=S[i][P[i][0]]
  for j in range(26):
    X[j]+=C[j]
  X[P[i][0]]=0
  SC-=sum(X)
YY=[]
for i in range(D):
  for k in range(25):
    SC2=SC
    YY=XX[:]
    SC2-=S[i][P[i][0]]
    SC2+=S[i][P[i][k+1]]
    for j in range(26):
      X[j]=0
    YY[P[i][0]],YY[P[i][k+1]]=0,0
    for j in range(D):
      if j==i:
        Z=P[j][k+1]
      else:
        z=P[j][0]
      X[P[i][0]]+=C[P[i][0]]
      X[P[i][k+1]]+=C[P[i][k+1]]
      X[Z]=0
      YY[P[i][0]]+=X[P[i][0]]
      YY[P[i][k+1]]+=X[P[i][k+1]]
    if SC2-sum(YY)>SC-sum(XX):
      P[i].insert(0,P[i][k+1])
      del P[i][k+2]
      XX=YY[:]
      SC=SC2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 84464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll mp = 0;
  if (a >= 0)
  {
    mp = max(b * d, a * d);
  }
  else if (b > 0 and a < 0)
  {
    vector<ll> tmp{b * d, 0, a * c};
    mp = *max_element(tmp.begin(), tmp.end());
  }
  else if (b <= 0)
  {
    mp = max(a * c, b * c);
  }
  cout << mp << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

int main(){
ll a,b,c;
  cin >> a >> b >> c;
  if(b>a){swap(a,b);}
  
  if(c>b+a && (c-a-b)*(c-a-b)-4*a*b>0){cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}


Measured memory_bytes: 256
/*
https://blog.csdn.net/litble/article/details/83118814

图论神啊，好题好题好题！！！
i 向 pi 连条边，构成的图简化以后就都是 “i 向 ai 连条边” 这个图了！！！

注意：是由一个环和若干条指向环的链组成的基环内向树，至于为什么是链，详见样例4

现在手上只有 a，那么就**倒推**有多少种可能图吧
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int mod = 1e9 + 7, N = 1e5 + 10;
typedef long long ll;
int n, a[N], deg[N], vis[N], cir[N], L[N], sum[N];
ll ans, f[N];

void calc(int x) {
    int now = 0, fr = 0, ed = 0, l = 0;
    // fr: 第一个脚的位置  ed: 上一个脚的位置  l: 第一个脚的长度  now: 当前节点是从 x 开始走环走到的第几个点
    while (cir[x]) {
        ++now, cir[x] = 0;
        if (L[x]) {
            if (!fr) ed = fr = now, l = L[x];
            else {
                int tmp = (L[x] < now - ed) + (L[x] <= now - ed);
                ans = 1ll * ans * tmp % mod, ed = now;
            }
        }
        x = a[x];
    }
    if (!fr) ++sum[now];
    else {
        int tmp = (l < now - ed + fr) + (l <= now - ed + fr);
        ans = 1ll * ans * tmp % mod;
    }
}

void solve() {
    rep(i, 1, n) {
        if (deg[i]) continue;
        int x = i, len = 0; while (!cir[x]) ++len, x = a[x];
        L[x] = len;
    }
    ans = 1;
    rep(i, 1, n) if (cir[i]) calc(i);

    // 计算每种长度的简单环的方案
    rep(i, 1, n) {
        f[0] = 1;
        rep(j, 1, sum[i]) {
            if (i > 1 && (i & 1)) f[j] = f[j - 1] * 2 % mod;
            else f[j] = f[j - 1];
            if (j > 1) f[j] = (f[j] + f[j - 2] * (j - 1) % mod * i % mod) % mod;
        }
        ans = 1ll * ans * f[sum[i]] % mod;
    }
}

int main() {
    cin >> n;
    rep(i, 1, n) scanf("%d", &a[i]), ++deg[a[i]];
    rep(i, 1, n) {
        if (vis[i]) continue;
        int x = i;
        while (!vis[x]) vis[x] = i, x = a[x];
        if (vis[x] != i) continue;
        while (!cir[x]) cir[x] = 1, x = a[x];
    }
    rep(i, 1, n)
        if ((!cir[i] && deg[i] > 1) || (cir[i] && deg[i] > 2)) return puts("0"), 0;
    solve();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
int main() 
{ 
  fastio();
ll int T;//cin>>T;
T=1;while(T--)
{
ll int n,m,i,x;double pi=3.14159265358979323846;
cin>>m>>n;
for(i=0;i<n;i++)
{cin>>x;
m-=x;}
if(m<0)cout<<-1<<endl;
else
  cout<<m<<endl;





}

       
    return 0; 
} 


Measured memory_bytes: 3604
def mov(c,x):
    if ord('a')<=ord(c)<=ord('z'):
        return chr(ord('a')+(ord(c)-ord('a')+x)%26)
    else:
        return c

while True:
    try:
        s=raw_input()
        flag=False
        for i in xrange(26):
            t=''.join([mov(c,i) for c in s])
            #print t
            ts=t[:-1].split()
            if ('this' in ts) or ('that' in ts) or ('the' in ts ):
                flag=True
                break
        if flag:
            print t
    except EOFError: break

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define REP(i,a,b) for(long long i=a; i<b;i++)
#define N 1000000007
#define MAX 100007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define PI 3.14159265358979323
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector< pair<ll,ll> > vpi;
const long double pi=4*atan(1.0);
vpi vii;
//ll tab[100002],n;

ll Xor(ll x, ll y)
{
   return (x | y) & (~x | ~y);
}

ll dx[8]={0,1,0,-1,1,-1,1,-1};
ll dy[8]={1,0,-1,0,1,-1,-1,1};

ll number_divisors(ll n)
{
   ll d;
    ll i;
    d=0;
    for(i = 1 ; i*i<n  ;++i)
        if(n%i == 0)
            {d+=2;}

    if(i*i == n)
        d++;

}

ll countDivisibles(ll A, ll B, ll M)
{

    if (A % M == 0)
        return (B / M) - (A / M) + 1;
    return (B / M) - (A / M);
}
bool ch (ll i,ll j,ll n, ll m)
{
    return (i>=0 && i<n && j>=0 && j<m);
}
vi cost,aux;
vector<ll> v1[MAX];
ll z[MAX],mini=1000000005,out=0;
void dfs(ll s)
{   if (z[s]) return;
 z[s] = 1;
 aux.PB(s);
 for (ll u=0;u<v1[s].size();u++)
    { dfs(v1[s][u]);}

 }

 // Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

// Function to find gcd of array of
// numbers
ll findGCD(ll arr[], ll n)
{
    ll result = arr[0];
    for (ll i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

int main()
{
//freopen("input.txt","r",stdin);
ll a,b,t,sum=0,cnt;
cin>>a>>b>>t;
cnt=a;
while (t>=cnt){
    sum+=b;
    cnt+=a;
}
cout<<sum;

       return 0;
}


Measured memory_bytes: 2560
N=int(input())
count=0
for i in range(1,N+1):
    if(i%3==0 and i%5==0):
        a=1
    elif(i%3==0):
        a=1
    elif(i%5==0):
        a=1
    else:
        count=count+i
        
print(count)


Measured memory_bytes: 65524
import sys
from collections import deque
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = deque(A)
left = 0
left += B.popleft()
right = 0
while B != deque():
    if right < left:
        right += B.pop()
    else:
        left += B.popleft()
print(abs(left - right))

Measured memory_bytes: 26124
import sys
S = input()
T = input()

dict_1 = {}
dict_2 = {}

for i in range(len(S)):
    if dict_1.setdefault(S[i],T[i]) != T[i]:
        print("No")
        sys.exit()
    if dict_2.setdefault(T[i],S[i]) != S[i]:
        print("No")  
        sys.exit()  
print("Yes")

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

int main() {
	int n, i;
	cin >> n;
	vector<int> a(n);
	for (int& j : a) cin >> j;
	for (int j = 1; j <= *min_element(a.begin(), a.end()); ++j) {
		for (i = 0; i < n; ++i) {
			if (a[i] % j) break;
		}
		if (i == n) cout << j << endl;
	}
}


Measured memory_bytes: 3096
N, K = map(int, input().split())
l = list(map(int, input().split()))

ans=0
for i in range(N):
  a=0
  for j in range(i+1,N):
    if l[i] > l[j]:
      a += 1
  b=0
  for j in range(i):
    if l[i] > l[j]:
      b += 1
      
  ans += a * K * (K + 1) // 2
  ans %= 10**9+7
  ans += b * (K - 1) * K // 2
  ans %= 10**9+7
print(ans)


Measured memory_bytes: 3188