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

const int MAX = 3000;
int MOD;
long long fac[MAX], finv[MAX], inv[MAX];
long long modpow[MAX][MAX];

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

    for(int i=0; i<MOD; ++i) {
        modpow[i][0] = 1;
        for(int j=1; j<MOD; ++j) {
            modpow[i][j] = (modpow[i][j - 1] * i) % MOD;
        }
    }
}

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

int main() {
    int p;
    cin >> p;
    MOD = p;
    COMinit();

    vector<int> b(p, 0);
    for(int i=0; i<p; ++i) {
        int a;
        cin >> a;
        if(a == 0) continue;

        b[0] = (b[0] + 1) % p;
        for(int k=0; k<p; ++k) {
            b[k] += COM(p - 1, k) * modpow[i][p - 1 - k] * ((p - k) % 2 ? -1 : 1);
            b[k] = (b[k] + p) % p;
        }
    }

    for(int i=0; i<p; ++i) {
        cout << b[i] << (i + 1 == p ? '\n' : ' ');
    }
}

Measured memory_bytes: 70656
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)

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

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) Scan() (ok bool) {
	ok = me.baseScanner.Scan()
	return
}
func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			panic(err)
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, fa)
		}
	}
	if n > 1 {
		facts = append(facts, factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

type kv struct {
	key   int
	value int
}

func toInt(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan()
	r.getInt()
	r.ScanAndSplit()
	a := r.nextStringArray().toInts()

	ok := 0
	for _, v := range a {
		if v%2 == 1 {
			ok++
		}
	}

	fmt.Fprintln(stdout, []string{"NO", "YES"}[toInt(ok%2 == 0)])

}



Measured memory_bytes: 5248
import sys
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
for n in sys.stdin:
    a=int(n.strip())
    b=a
    while 1:
        a+=1
        if is_prime(a):
            max_a=a
            break
    while 1:
        b-=1
        if is_prime(b):
            min_b=b
            break
    print min_b,max_a

Measured memory_bytes: 4228
program sample
  implicit none
  integer :: n,i
  integer,allocatable :: a1(:),a2(:),s(:)
  read(*,*) n
  allocate(a1(n))
  allocate(a2(n))
  allocate(s(n))
  read(*,*) a1
  read(*,*) a2

  do i=1,n
     s(i)=sum(a1(1:i))+sum(a2(i:n))
  enddo
  write(*,*) maxval(s)
  
end program sample

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

int N, A[200000];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  if(A[0] != 0){
    cout << -1 << endl;
    return 0;
  }

  long long ans = 0;
  int now_height = 0;
  for(int i = N - 1; i >= 0; i--){
    if(A[i] < now_height){
      cout << -1 << endl;
      return 0;
    }
    if(A[i] > now_height){
      ans += A[i];
      now_height = A[i];
    }
    if(now_height > 0){
      now_height--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
long double dp[301][301][301];

long double FindExpectedTurns( int Ones , int Twos , int Threes , int N ){
    if( dp[Ones][Twos][Threes] >= 0 || ( Ones == 0 && Twos == 0 && Threes == 0 ) ) return dp[Ones][Twos][Threes];
    long double Temp = ( Ones + Twos + Threes );
    dp[Ones][Twos][Threes] = ( N / Temp );
    if( Ones > 0 ) dp[Ones][Twos][Threes] += ((long double)Ones / Temp) * FindExpectedTurns( Ones - 1 , Twos , Threes , N );
    if( Twos > 0 ) dp[Ones][Twos][Threes] += ((long double)Twos / Temp ) * FindExpectedTurns( Ones + 1 , Twos - 1 , Threes , N );
    if( Threes > 0 ) dp[Ones][Twos][Threes] += ((long double)Threes / Temp) * FindExpectedTurns( Ones , Twos + 1 , Threes - 1 , N );
    return dp[Ones][Twos][Threes];
}

int main(){
    int N , i , Num , Ones , Twos , Threes;
    Ones = Twos = Threes = 0;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i ){
        scanf( "%d" , &Num );
        if( Num == 1 ) ++Ones;
        else if( Num == 2 ) ++Twos;
        else ++Threes;
    }

    int Max = Ones + Twos + Threes;

    for( i = 0 ; i <= Max ; ++i ){
        for( int j = 0 ; j <= Max ; ++j ){
            for( int k = 0 ; k <= Max ; ++k )
                dp[i][j][k] = -20;
        }
    }

    dp[0][0][0] = 0;
    printf( "%0.15Lf\n" , FindExpectedTurns( Ones , Twos , Threes , N ) );
    return 0;   
}

Measured memory_bytes: 426496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point p1 = new Point(0.0, 0.0);
		Point p2 = new Point(100.0, 0.0);
		System.out.printf("%.8f %.8f\n", p1.getX(), p1.getY());
		kock(n, p1, p2);
		System.out.printf("%.8f %.8f\n", p2.getX(), p2.getY());
		sc.close();
	}

	static void kock(int n, Point p1, Point p2) {
		if(n == 0) {
			return;
		}

		//p1, p2からs,t,uを算出
		double s_x = (2 * p1.getX() + p2.getX()) / 3;
		double s_y = (2 * p1.getY() + p2.getY()) / 3;
		double t_x = (p1.getX() + 2 * p2.getX()) / 3;
		double t_y = (p1.getY() + 2 * p2.getY()) / 3;
		double u_x = (t_x - s_x) * Math.cos(Math.toRadians(60)) - (t_y - s_y) * Math.sin(Math.toRadians(60)) + s_x;
		double u_y = (t_x - s_x) * Math.sin(Math.toRadians(60)) + (t_y - s_y) * Math.cos(Math.toRadians(60)) + s_y;
		Point s = new Point(s_x, s_y);
		Point u = new Point(u_x, u_y);
		Point t = new Point(t_x, t_y);

		kock(n-1, p1, s);
		System.out.printf("%.8f %.8f\n", s.getX(), s.getY());
		kock(n-1, s, u);
		System.out.printf("%.8f %.8f\n", u.getX(), u.getY());
		kock(n-1, u, t);
		System.out.printf("%.8f %.8f\n", t.getX(), t.getY());
		kock(n-1, t, p2);
	}
}

class Point{
	private double x, y;
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}
	public double getX() {return x;}
	public double getY() {return y;}
}



Measured memory_bytes: 43472
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10


    x,k,d = LMIIS()
    sign = -1 if x < 0 else 1
    absX = abs(x)
    if k*d <= abs(x):
        print(absX-k*d)
        return
    num = absX // d
    k -= num
    if k & 1:
        num += 1
    print(abs(absX-num*d))

     
    



    
main()

Measured memory_bytes: 65096
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	final int INF = 1 << 24;
	final double EPS = 1.0e-08;
	C [] data;
	class C{
		int x,y,r,c;
		public C(int x, int y, int r, int c) {
			this.x = x;
			this.y = y;
			this.r = r;
			this.c = c;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner (System.in);
		int n,len,ans;
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			data = new C[n];
			for(int i=0; i < n; i++){
				data[i] = new C(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			len = 1 << n;
			boolean [] dp = new boolean[len];
			dp[0] = true;
			ans = 0;
			for(int j = 0; j < len; j++){
				if(! dp[j]) continue;
				ArrayList<Integer> checked = new ArrayList<Integer>();
				for(int k = 0; k < n; k++){
					if((j & (1 << k)) != 0) continue;
					if(isOVL(k,j)) continue;
					
					for(int l = 0; l < checked.size(); l++){
						int pair = checked.get(l);
						if(! issameC(k,pair)) continue;
						int num;
						num = j | (1 << k);
						num = num | (1 << pair);
						dp[num] = true;
						int res = Integer.bitCount(num);
						ans = Math.max(ans, res);
					}
					//store
					checked.add(k);
				}
			}
//			//TODO debug
//			for(int i= 0; i < len; i++){
//				for(int j = 0; j < n+1; j++){
//					if(dp[i][j]){
//						System.out.print("1 ");
//					}
//					else{
//						System.out.print("0 ");
//					}
//				}
//				System.out.println();
//			}
			//System.out.print("ANS= ");
			System.out.println(ans);
		}
	}
	
	private boolean isOVL(int a,int num) {
		if(a == 0) return false;
		int ax = data[a].x;
		int ay = data[a].y;
		int ar= data[a].r;
		int ix,iy,ir,rr;
		double dis;
		for(int i = a-1; i >= 0; i--){
			if(((1 << i) & num) != 0) continue;
			ix = data[i].x;
			iy = data[i].y;
			ir = data[i].r;
			dis = Point2D.Double.distance(ax, ay, ix, iy);
			rr = ir + ar;
			if(dis + EPS < rr)return true;
		}
		return false;
	}

	private boolean issameC(int a, int b) {
		if(data[a].c == data[b].c) return true;
		return false;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 29000
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define PRINT(message) cout<<message<<endl //10^5:配列の最大のrange(素数列挙などで使用)

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素
int D, G;
int answer = std::numeric_limits<int>::max();
vector<int> p, c;

unordered_map<int, int> mp;

int main(){
    ll A, B ,C ,X, Y;

    cin >> A >> B >> C >> X >> Y;
    ll answer=0;
    if(A+B <= 2*C){
        answer = X*A + Y*B;
        PRINT(answer);
        return 0;
    }
    
    ll more = X>Y?A:B;
    ll tmp1 = 2*min(X,Y)*C + (max(X,Y)-min(X,Y))*more;
    ll tmp2 =  2*max(X,Y)*C;

    PRINT(min(tmp1, tmp2));


    return 0;
}

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

int main()
{
	int a,b,c,d;
    std::cin >> a >> b >> c >> d;
    
    int left = a + b;
    int right = c + d;
    
    if(right == left){
        std::cout << "Balanced" << std::endl;
    }else if(right > left){
        std::cout << "Right" << std::endl;
    }else if(right < left){
        std::cout << "Left" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
a,b,h,m = map(int,input().split())
import math
h_pi = 30 * h + 0.5 * m
m_pi = 6 * m
theta =max(h_pi,m_pi) - min(h_pi,m_pi)
ans = a**2 + b**2 -2 * a * b * math.cos(math.radians(theta))
print(math.sqrt(ans))

Measured memory_bytes: 9508
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    cout << (a == b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double c = x / (a * a);
  double rad;

  if(c <= b / 2){
    double y = 2 * a * c / b;
    rad = atan(b / y);
  }else{
    double z = 2 * c - b;
    rad = atan((b - z) / a);
  }

  cout << setprecision(12) << rad * 180 / M_PI << endl;
  return 0;
}


Measured memory_bytes: 256
var
  b:string;
  i,a:longint;
begin
  readln(b);
  a:=0;
  for i:=1 to length(b) do
    if b[i]='C' then begin a:=i; break; end;
  if a=0 then begin writeln('No'); exit; end;
  for i:=a+1 to length(b) do
    if b[i]='F' then begin writeln('Yes'); exit; end;
  writeln('No');
end.

Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)
 
int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
 
static inline constexpr int digitsum(int x) {
  return (x < 10) ? x : (x % 10) + digitsum(x / 10);
}
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
 
  int answer = 0;
  REP1(i, N) {
    const int x = digitsum(i);
    if (x >= A && x <= B) {
      answer += i;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  int k;
  cin>>a>>b>>c;
  cin>>k;
  int x = k;
  if(b>a && c>b)
  {
    cout<<"Yes";
    return 0;
  }
 	for(int i=0;i<x;i++)
      c = c*2;
  if(b>a && c>b)
  {
 	cout<<"Yes";
    return 0;
      
  }
  //cout<<a<<" " << b << " "<<c <<endl;
  while(k--)
  {

    b = b*2;
    c = c/2;
   // cout<<a<<" " << b << " "<<c <<endl;
    if(b>a && c>b)
    {
      cout<<"Yes";
      return 0;
    }
  
  }
    cout<<"No";
    return 0;
}

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

int main(){

    int N;
    cin>>N;
    vector<int>V(N);
    int ans=0;


    for(int i=0;i<N;i++)
        cin>>V[i];

    for(int i=0;i<N;i++){
        int tmp;cin>>tmp;
        if(V[i]-tmp>0)
            ans+=V[i]-tmp;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	int n;
	string s;
	cin >> s >> n;

	REP(i, s.size()) {
		if(s[i] != 'a' && 'z' - s[i] + 1 <= n) {
			n -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	if(n > 0) s[s.size()-1] += n%26;
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 512
N=int(input())
d={}

for i in input().split():
	x=int(i)
	if x not in d:d[x]=1
	else:d[x]+=1

cnt=0
ans=1
for t in sorted(d.items(),reverse=True):
	if t[1]>=2:
		ans*=t[0]
		cnt+=1
	if cnt==1 and t[1]>=4:
		ans*=t[0]
		cnt+=1
	if cnt>=2:
		break

print(ans if cnt>=2 else 0)

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

int main(void) {
    double x1, y1, x2, y2;
    
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
    
    return 0;
}




Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;
typedef long long ll;


vector<int> g[100010];
vector<bool> vis(100010, false);
int check(int v) {
    bool f = true;
    int ret;
    for(int i=0;i<g[v].size();i++) {
        if(!vis[g[v][i]]) {
            ret = g[v][i];
            f = false;
            break;
        }
    }
    if(f) return -1;
    else return ret;
}


int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    for(int i=0;i<m;i++) {
        cin >> a >> b;
        a--; b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    deque<int> dq;
    dq.push_front(a);
    dq.push_back(b);

    vis[a] = true;
    vis[b] = true;

    while(true) {
        int fr = check(dq.front());
        int bk = check(dq.back());
        //cout << "fr :" << fr << " " << "bk :" << bk << endl;
        if(fr < 0  && bk < 0)
            break;
        if(fr >= 0) {
            dq.push_front(fr);
            vis[fr] = true;
        }

        bk = check(dq.back());
        if(bk >= 0) {
            dq.push_back(bk);
            vis[bk] = true;
        }
    }
    cout << dq.size() << endl;
    for(int i=0;i<dq.size();i++) {
        if(i != 0)
            cout << " ";
        cout << dq[i] + 1;
    }

}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define RS(n) sort(n.begin(), n.end());reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main(){
  lli A,B,C=0,D=0,E=0,F=INF,G=INF,H=0,N,M,K,S;
  cin >> N;
  vector<string>P(N);vector<lli>Q(0,0);
  rep(i,0,N){
  cin >> P[i];
  Sort(P[i]);
  }
  Sort(P);
  rep(i,1,N)if(P[i-1]!=P[i])Q.pb(i);
  Q.pb(N);
  A=Q.size();
  for(int i=A-1;i>0;i--)Q[i]=Q[i]-Q[i-1];
  rep(i,0,A)C+=Q[i]*(Q[i]-1)/2;
  Out(C);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll h, w;
    cin >> h>>w;
    vector<vector<char>>a(h, vector<char>(w));
    vector<ll>c(26);
    rep(i, h) {
        rep(j, w) {
            cin>>a[i][j];
            c[a[i][j]-'a']++;
        }
    }
    if (h==1||w==1) {
        ll co=0;
        rep(i, 26) {
            if (c[i]%2==1) {
                co++;
            }
        }
        if (co==1&&h*w%2==1) {
            cout<<"Yes"<<endl;
        }
        else if (co==0&&h*w%2==0) {
            cout<<"Yes"<<endl;
        }
        else {
            cout<<"No"<<endl;
        }
    }
    else {
        ll co=0;
        ll co4=0;
        rep(i, 26) {
            if (c[i]%2==1) {
                co++;
            }
            if (c[i]>=4) {
                co4+=c[i]/4;
            }
        }
        if (co==1&&h*w%2==1&&co4==h/2*(w/2)) {
            cout<<"Yes"<<endl;
        }
        else if (co==0&&h*w%2==0&&co4==h/2*(w/2)) {
            cout<<"Yes"<<endl;
        }
        else {
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 3616
n = int(input())
nums = list(map(int, input().split()))

nums.sort()

ans= 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a, b, c = nums[i], nums[j], nums[k]
            if a < b < c:
                if a + b > c:
                    ans += 1
                # if i + j >= k:
                #     ans += 1
print(ans)


Measured memory_bytes: 67888
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll n;
    cin>>n;
    ll x;
    ll cnt=0;
    ll it=1;
    while(n--)
    {
        cin>>x;
        if(it%2==1&&x%2==1)
        {
            cnt++;
        }
        it++;
    }
    cout<<cnt;
}

Measured memory_bytes: 5936
#57 ABC137E
#ベルマンフォード

n,m,p=map(int,input().split())

abc=[list(map(int,input().split())) for _ in range(m)]
abc=[[a,b,p-c] for a,b,c in abc]
def BF(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    neg=[False for _ in range(num_v)]
    for i in range(num_v-1):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                neg[edge[1]-1]=True
            if neg[edge[0]-1]==True:
                neg[edge[1]-1]=True
    return dist,neg
dis,neg=BF(abc,n,1)
#print(dis,neg)
print(-1 if neg[-1] else max(0,-dis[-1]))

Measured memory_bytes: 48888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b; cin >> a >> b;
  cout << 6 - a - b << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, sum = 0;
    cin >> N;
    char *S = new char[N + 1];
    cin >> S;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            sum++;
        }
    }
    cout << sum << endl;
}

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


int main() {
	string st; cin >> st;
	vector<int>nums(26);
	vector<int>chs(10);
	for (auto c : st) {
		if (isdigit(c)) {
			chs[c - '0']++;
		}
		else {
			nums[c - 'a']++;
		}
	}
	int ans = st.size();
	int rest = 1000;
	while (rest--) {
		for (int l = 0; l < 25; ++l) {
			int x = l;
			while (x<26) {
				if (nums[x]) {

				}
				else {
					break;
				}
				x++;
			}
			if (x - l>=3) {
				ans -= (x - l - 3);
				for (int k = l; k < x; ++k) {
					nums[k]--;
				}
				break;
			}
		}
		for (int l = 0; l < 9; ++l) {
			int x = l;
			while (x<10) {
				if (chs[x]) {

				}
				else {
					break;
				}
				x++;
			}
			if (x - l >= 3) {
				ans -= (x - l - 3);
				for (int k = l; k < x; ++k) {
					chs[k]--;
				}
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

void min_self(long long &x,long long y)
{
    x=min(x,y);
}
long long inf=1e18+1;
int main()
{
    int  n;
    int w;
    scanf("%d %d",&n,&w);
    vector<int>weight(n+1),value(n+1);
    for( int i=0;i<n;i++)
    {
        scanf("%d%d",&weight[i],&value[i]);
    }
    int sum_value=0;
    for(int x:value)
    {   
        sum_value+=x;
    }
    vector<long long>dp(sum_value+1,inf);
    dp[0]=0;
    for(int item=0;item<n;item++)
    {
        for(int value_already=sum_value-value[item];value_already>=0;value_already--)
        {
            min_self(dp[value_already+value[item]],dp[value_already]+weight[item]);
        }
    }
    long long answer=0;
    for(int long long i=0;i<=sum_value;i++)
    {
        if(dp[i]<=w)
        {
            answer=max(answer, i);
        }
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if ( a+b > 24 ) 
			System.out.println((a+b)-24);
		else if ( a+b == 24 )
			System.out.println(0);
		else
			System.out.println(a+b);
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		string[] str2 = Console.ReadLine().Split();
		int count = 0;
		for(var i=0;i<N;i++){
			int N1 = int.Parse(str2[i]);
			while(N1 % 2 == 0){
				N1 /= 2;
				count += 1;
			}
		}
		Console.WriteLine(count);
	}
}

Measured memory_bytes: 11744
#ifdef debug
#include <time.h>
#include "/home/majiao/mb.h"
#endif


#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define MAXN ((int)1e5+7)
#define ll long long int
#define QAQ (0)

using namespace std;



int main() {
#ifdef debug
	freopen("test", "r", stdin);
	clock_t stime = clock();
#endif
	string str;
	cin >> str;
	cout << (str=="ABC" ? "ARC" : "ABC");







#ifdef debug
	clock_t etime = clock();
	printf("rum time: %lf 秒\n",(double) (etime-stime)/CLOCKS_PER_SEC);
#endif 
	return 0;
}



Measured memory_bytes: 3624
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


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

graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    # undirected, 0-indexed
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)

query = []
for _ in range(Q):
    p, x = map(int, input().split())
    query.append([p - 1, x])

# 方針
# 1. 各クエリに対し、頂点p_jのカウンターにx_jを足す
# (この段階では部分木に含まれるノードには操作を行わない)
# 2. クエリを全て処理したあと、深さ優先順に各ノードvのカウンタを以下のように更新する
# count[v] = count[v] + 親ノードのカウンタ
# 毎回部分木に対して処理を行うのだとO(N^2)の計算量となり遅いので、上記のように工夫して更新する


def bfs(v, parent):
    for v_adj in graph[v]:
        if v_adj == parent:
            continue
        count[v_adj] += count[v]
        bfs(v_adj, v)


count = [0] * N
for p, x in query:
    count[p] += x
# pprint(count)

v = 0
bfs(0, -1)

print(*count)


Measured memory_bytes: 258760
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)

struct Dict {
	string word;
	int count;
	Dict(string word, int count) :
		word(word), count(count) {}

	bool operator<(const Dict& other) const {
		return (count == other.count ? word < other.word : count > other.count);
	}
};

void solve() {
	int N;
	cin >> N;
	
	map<string, int> s_map;
	REP(i, N) {
		string s;
		cin >> s;
		s_map[s] += 1;
	}

	vector<Dict> S;
	for (auto& p : s_map) {
		S.emplace_back(Dict(p.first, p.second));
	}

	sort(S.begin(), S.end());
	int max_counter = S[0].count;
	REP(i, S.size()) {
		if (max_counter == S[i].count) cout << S[i].word << endl;
	}
}

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

}

Measured memory_bytes: 28140
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 1e5 + 5;
int n, m, k;
int in[N], mx;
vector<pii> g[N];
int cnt = 1;
void dfs(int u, int fa, int d){
    for(auto x : g[u]){
        int v = x.first;
        if(v == fa) continue;
        in[x.second] = d;
        d++; d = (d-1)%mx+1;
        dfs(v, u, d);
    }
}

int main(){
    scanf("%d", &n);
    rep(i,1,n-1){
        int x, y;
        scanf("%d%d", &x, &y);
        g[x].pb({y,i}); g[y].pb({x,i});
    }
    int rt;
    rep(i,1,n) if(g[i].size() > mx){
        mx = g[i].size();
        rt = i;
    }
    dfs(rt,0,1);
    printf("%d\n", mx);
    rep(i,1,n-1) printf("%d\n", in[i]);
    return 0;
}
/*

*/


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
int32_t main()
{
    int n;
    cin >> n;
    vector<int> arr(n), dp(n);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    dp[1] = abs(arr[0] - arr[1]);
    dp[2] = min(abs(arr[0] - arr[2]), dp[1] + abs(arr[2] - arr[1]));
    for (int i = 3; i < n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
    }
    cout << dp[n - 1] << endl;
}


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

using namespace std;

bool is_atgc(const char c)
{
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

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

    string b;
    cin >> b;

    int len = b.size();
    int max_pstr = 0;
    int count = 0;

    for (int i = 0; i < len; i++)
    {
        if (is_atgc(b[i]))
            count++;
        else
        {
            max_pstr=max(count, max_pstr);
            count = 0;
        }
    }

    max_pstr=max(count, max_pstr);

    cout << max_pstr << endl;

    return 0;
}


Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;


int main(){

    int N;
    cin >> N;
    int result = 0;
    int sum = 0;
    int max = 0;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        sum += a;
        if(a > max){
            max = a;
        }
    }

    result = sum - (max / 2);

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		long long n,i,j;
		scanf("%lld",&n);
		for(i=1;i<=3500;i++){
				for(j=1;j<=3500;j++){
						if(4*i*j-n*(i+j)>0){
						if(n*i*j%(4*i*j-n*(i+j))==0){
								printf("%lld %lld %lld\n",i,j,n*i*j/(4*i*j-n*(i+j)));
								return 0;
						}
						}
				}
		}
}


Measured memory_bytes: 128
# 素因数分解 O(√N)
def prime_decomposition(n):
    i = 2
    prime2exponent = {}  # key:prime --> value:its exponent
    while i*i <= n:
        while n % i == 0:
            n //= i
            if i in prime2exponent:
                prime2exponent[i] += 1
            else:
                prime2exponent[i] = 1
        i += 1
    if n > 1:
        if n in prime2exponent:
            prime2exponent[n] += 1
        else:
            prime2exponent[n] = 1
    return prime2exponent


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


N = int(input())

ans = 0
p2e = prime_decomposition(N-1)
temp = 1
for v in p2e.values():
    temp *= (v+1)
temp -= 1
ans += temp
#print(temp)
#rint(p2e)

divisors = make_divisors(N)
#print(divisors)
for div in divisors:
    cur = N
    if div == 1:
        continue
    while cur % div == 0:
        cur //= div
        #print(cur,div)
    if cur % div == 1:
        ans += 1
print(ans)



Measured memory_bytes: 3316
#include <stdio.h>

int main() {
	int N, K;
	int A[101] = { 0 };
	int n;
	scanf("%d %d", &N, &K);
	int i;
	for (i = 0; i < K; i++) {//K種類
		int d = 0;//それを持ってる人数
		scanf("%d", &d);
		int t=0;
		for (t = 0; t < d; t++) {
			scanf("%d", &n);//持ってる名前
			A[n] = A[n] + 1;

			}

		}
	int nnn = 0;
	int c = 1;
	for (c = 1; c < N+1; c++) {
		if (A[c] == 0) {
			nnn = nnn + 1;
		}
	}
	printf("%d", nnn);
	return 0;
}


Measured memory_bytes: 1732
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}
main()
{
//	fast();
 
	int n, k;
    cin>>n>>k;
    vector<int> dp(k + 1);
    // dp[i] - the number of ways such that we used i candies so far
    dp[0] = 1;
    for(int child = 0; child < n; ++child) {
        int up_to;
        cin>>up_to;
        vector<int> fake(k + 1);
        for(int used = k; used >= 0; --used) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if(L <= R) {
               add_self(fake[L], tmp);
                if(R + 1 <= k) {
                   sub_self(fake[R+1],tmp);
                }
            }
            //~ for(int i = L; i <= R; ++i) {
                //~ add_self(dp[i], tmp);
            //~ }
        }
        int prefix_sum = 0;
        for(int i = 0; i <= k; ++i) {
           add_self(prefix_sum, fake[i]);
        add_self(dp[i], prefix_sum);
        }
    }
    
    cout<<dp[k];
 
	
}
 
 

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
v2 a;
vl b;
v3 m;
v2 mem;
ll ans;

ll dfs(ll x,ll y){
  if(x == 0 && y == 0) return 0;
  if(mem[x][y]) return mem[x][y];
  mem[x][y] = 1000000000;
  return mem[x][y] = max({
    dfs(m[x][y][0],m[x][y][1]),
    dfs(m[x][y][1],m[x][y][0]),
    dfs(m[y][x][0],m[y][x][1]),
    dfs(m[y][x][1],m[y][x][0]),
  })+1;
}

int main(){
  cin >> n;
  a = v2(n+1,vl(n+1));
  for(ll i = 1;i <= n;i++){
    for(ll j = 1;j <= n-1;j++){
      cin >> a[i][j];
    }
  }
  for(ll i = 1;i <= n;i++) a[i][0] = i;
  m = v3(n+1,v2(n+1,vl(2)));
  mem = v2(n+1,vl(n+1));
  for(ll i = 1;i <= n;i++){
    for(ll j = 1;j <= n-1;j++){
      m[i][a[i][j-1]][0] = i;
      m[i][a[i][j-1]][1] = a[i][j];
    }
  }
  for(ll i = 1;i <= n;i++){
    ans = max(ans,dfs(i, i));
  }
  if(ans >= 1000000000) cout << -1 << endl;
  else cout << ans-1 << endl;



}


Measured memory_bytes: 109952
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;
  vector<ll> point = {R, S, P};
  string T;
  cin >> T;
  queue<ll> hand;
  //r 0, s 1, p 2
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    char now = T[i];
    ll rsp;
    if (now == 'r') {
      rsp = 2;
    }
    else if (now == 's') {
      rsp = 0;
    }
    else {
      rsp = 1;
    }
    if (hand.size() < K) {
      hand.push(rsp);
      ans += point.at(rsp);
    }
    else {
      ll before = hand.front();
      hand.pop();
      if (before == 3) {
        ans += point.at(rsp);
        hand.push(rsp);
        continue;
      }
      if (before == rsp) {
        hand.push(3);
      }
      else {
        hand.push(rsp);
        ans += point.at(rsp);
      }
    }
  }
  cout << ans << "\n";
}


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

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    int y = 0;
    int z = 0;
    int x;
    for(x = 0; x <= 20000; x++) {
      z = (5000*N-Y+5000*x)/4000;
      y = N-x-z;
      if(x+y+z == N && y >= 0 && z >= 0 && 10000*x+5000*y+1000*z==Y) {
        break;
      }
    }
    if(x + y + z == N && 10000*x+5000*y+1000*z==Y) {
      System.out.println(x + " " + y + " " + z); 
    }
    else
      System.out.println("-1 -1 -1");
  }
}


Measured memory_bytes: 21844
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N;
    cin >> N;
    ll ans = 0;
    if(N%2 == 1) cout << ans << endl;
    else{
        ll num=5;
        while(N/num){
            ans += N/(2*num);
            num *= 5;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    while(cin >>n,n){
        int pw;
        scanf(" %d", &pw);

        vector<int> vw(n),pf(n),vf(n),th(n);
        rep(i,n) scanf(" %d %d %d %d", &vw[i], &pf[i], &vf[i], &th[i]);

        auto f = [&](double W){
            double cost = W*pw;
            rep(i,n){
                double F = (th[i]-W*vw[i])/vf[i];
                F = max(0.0,F);
                cost += F*pf[i];
            }
            return cost;
        };

        double l = 0, r = 10000;
        rep(_,100){
            double m1 = (2*l+r)/3, m2 = (l+2*r)/3;
            if(f(m1) > f(m2)) l = m1;
            else r = m2;
        }
        printf("%.10f\n", f(l));
    }
    return 0;
}



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

using namespace std;

char a[15][15], pc[15], pr[15];
int n, m;
inline bool mp_r(int x);
inline bool mp_c(int x);

bool mp_c(int x) {
  if (x>m) 
    return mp_r(1);
  if (pc[x])
    return mp_c(x+1);

  int t = 0;
  for (int i = x; i <= m; ++i) 
    if (!pc[i]) ++t;
  for (int i = x; i <= m; ++i) {
    if (pc[i]) continue;
    pc[x] = i; pc[i] = x;
    if (((t & 1) || (i != x)) && mp_c(x+1))
      return true;
    pc[x] = 0; pc[i] = 0;
  }

  return false;
}

bool mp_r(int x) {
  if (x>n) 
    return true;
  if (pr[x])
    return mp_r(x+1);

  int t = 0;
  for (int i = x; i <= n; ++i)
    if (!pr[i]) ++t;
  for (int i = x; i <= n; ++i) {
    if (pr[i]) continue;
    bool ok = true;
    for (int j = 1; j <= m; ++j) 
      ok &= (a[x][j] == a[i][pc[j]]);
    if (((t & 1) || (i != x)) && ok) {
      pr[x] = i; pr[i] = x;
      if (mp_r(x+1)) return true;
      pr[x] = 0; pr[i] = 0;
    }
  }
  
  return false;
}

int main() {
  cin >> n >> m;
  for(int i=1;i<=n;++i) scanf("%s", a[i]+1);

  if (mp_c(1)) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];

  vector<int> o(N);
  iota(ALL(o), 0);

  sort(ALL(o), [&](int l, int r){
      return A[l]+B[l] > A[r]+B[r];
      });

  int ans = 0;
  REP(i, N){
    if(i%2 == 0) ans += A[o[i]];
    else ans -= B[o[i]];
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

void eratosthenes(vector<int> &n){	
	n[1] = 1;
	for (int i = 2;i <= (120000/2); i++){
		n[i * 2] = 1;
	}
	int p = 3;
	while(p * p <= 120000){
		for (int i = p; i <= (120000/p); i++){
			n[i * p] = 1;
		}
		p++;
		while(n[p] == 1)p++;
	}
	return;
}

bool isPrime(int n){
	if (n < 2) return false;
	if (n == 2) return true;
	for (int i = 2; i <= sqrt(n) + 1; i++){
		if (n % i == 0) return false;
	}
	return true;
}
		
int main(){
	vector<int> era(120000);
	eratosthenes(era);
	vector<int> Primelist(120001);
	int index = 1;
	for (int i = 1; i <= era.size(); i++){
		if (era[i] == 0){
			Primelist[index] = i;
			index++;
		}
	}
	while(1){
		int n,p; cin >> n >> p;
		if (n + p == -2) break;
		index = 1;
		while(n >= Primelist[index]){
			index++;
		}
		
		vector<int> list(120000);
		for (int i = 1; i <= p; i++){
			for (int j = i; j <= p; j++){
				list[(i-1) * p + j] = Primelist[index + i - 1] + Primelist[index + j - 1];
			}
		}
		sort(list.begin(),list.end());
		index = 0;
		while(list[index] == 0){
			index++;
		}
		cout << list[index + p - 1] << endl;
		
	}

return 0;
}

Measured memory_bytes: 4104