akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let s: Vec<char> = sc.chars();

    for (p, q) in vec![(true, true), (true, false), (false, true), (false, false)] {
        let mut xs = vec![true; n];
        xs[0] = p;
        xs[1] = match s[0] {
            'o' => !(q ^ xs[0]),
            _ => q ^ xs[0],
        };
        for i in 2..n {
            xs[i] = match s[i - 1] {
                'o' => !(xs[i - 2] ^ xs[i - 1]),
                _ => xs[i - 2] ^ xs[i - 1],
            };
        }
        let p0 = match s[n - 1] {
            'o' => !(xs[n - 2] ^ xs[n - 1]),
            _ => xs[n - 2] ^ xs[n - 1],
        };
        if xs[n - 1] == q && p == p0 {
            put!(xs
                .iter()
                .map(|&b| if b { 'S' } else { 'W' })
                .collect::<String>());
            return;
        }
    }

    put!(-1);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};


int32_t main(){
 	fastIO;
	int a,b;
	cin>>a>>b;
	if(b>=a){
		cout<<"unsafe"<<endl;
	}
	else
		cout<<"safe"<<endl;
}		



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, ans= 0;
    cin >> n;

    string s;
    cin >> s;

    for (int i=0; i<n-2; i++){
        if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') ans++;
    }

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

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges    [][]Edge // Edge[i][j]: 頂点iのj番目の辺
	Pred     []int    // 遷移元
	Cost     []int    // 始点からの最小コスト
	RouteNum []int    // 始点から各頂点への最短経路数
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges:    make([][]Edge, n),
		Pred:     make([]int, n),
		Cost:     make([]int, n),
		RouteNum: make([]int, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
		g.Pred[i] = -1
		g.Cost[i] = 1 << 60
		g.RouteNum[i] = 0
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	g := NewGraph(n)
	for i := 0; i < n-1; i++ {
		u, v, w := nextInt()-1, nextInt()-1, nextInt()
		g.AddEdge(u, v, w)
		g.AddEdge(v, u, w)
	}

	color := make([]int, n)
	color[0] = 1
	for i := 1; i < n; i++ {
		color[i] = -1
	}

	q := make([]int, 0)
	q = append(q, 0)
	for len(q) > 0 {
		cur := q[0]
		for _, e := range g.Edges[cur] {
			if color[e.to] < 0 {
				if e.cost%2 == 0 {
					color[e.to] = color[cur]
				} else {
					color[e.to] = 1 - color[cur]
				}
				q = append(q, e.to)
			}
		}
		q = q[1:]
	}

	for _, c := range color {
		puts(c)
	}
}


Measured memory_bytes: 15488
# -*- coding: utf-8 -*-

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N=INT()
A=LIST()

A2=[0]*N
B=[]
for i in range(N-1, -1, -1):
    if A[i]!=A2[i]:
        B.append(i+1)
        div=divisor_set(i+1)
        for num in div:
            A2[num-1]=1-A2[num-1]
        
print(len(B))
print(*B)


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end(),greater<int>());
  int sum=0;
  for(int i=0;i<n-1;i++){
   sum+=a.at(i+1); 
  }
  if(a.at(0)<sum){
   cout<<"Yes"<<endl; 
  }else{
   cout<<"No"<<endl; 
  }
}

Measured memory_bytes: 256
import numpy as np

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

# trains[L][r]: L から r まで行く電車の本数 (1 <= L <= r <= N)
trains = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for m in range(M):
    L, r = map(int, input().split())
    trains[L][r] += 1

cumsum = np.cumsum(trains, axis=0).cumsum(axis=1)


def solve(L, r):
    # 二次元累積和
    # https://qiita.com/drken/items/56a6b68edef8fc605821#4-%E4%BA%8C%E6%AC%A1%E5%85%83%E7%B4%AF%E7%A9%8D%E5%92%8C
    return cumsum[r][r] - cumsum[r][L - 1] - cumsum[L - 1][r] + cumsum[L - 1][L - 1]


for q in range(Q):
    print(solve(*map(int, input().split())))


Measured memory_bytes: 18592
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;

typedef long long int ll;

int main(){

    ll n,ans=0;
    cin >> n;

    /*vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);*/

    ll a[n];
    ll b[n];
    ll c[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    for(int i = 0;i < n;i++){
        cin >> c[i];
    }

    /*sort(a.begin(),a.end());
    sort(c.begin(),c.end());*/

    sort(a,a+n);
    sort(c,c+n);

    for(int j = 0;j < n;j++){
        /*int i = a.lower_bound(b[j])-1;
        int k = n-c.upper_bound(b[j]);*/
        ll i = lower_bound(a,a+n,b[j])-a;
        ll k = n-(upper_bound(c,c+n,b[j])-c);
        //cout << i << " " << k << endl;

        ans = ans+i*k;
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n; cin >> n;
    vec<int> dp(n + 1, 1 << 29);
    dp[0] = 0;
    loop (n, i) {
        dp[i + 1] = dp[i] + 1;
        loop (8, j) if (i + 1 - pow(6, j) >= 0) {
            dp[i + 1] = min(dp[i + 1], dp[i + 1 - pow(6, j)] + 1);
        }
        loop (8, j) if (i + 1 - pow(9, j) >= 0) {
            dp[i + 1] = min(dp[i + 1], dp[i + 1 - pow(9, j)] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K+1]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)


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

#define MAX_N 24

int n, m;
long double x[MAX_N], y[MAX_N], z[MAX_N];
long double dist[MAX_N][MAX_N];
int power[MAX_N];

vector<int>vec;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			long double X = (x[i] - x[j])*(x[i] - x[j]);
			long double Y = (y[i] - y[j])*(y[i] - y[j]);
			long double Z = (z[i] - z[j])*(z[i] - z[j]);
			dist[i][j] = X + Y + Z;
		}
	}
	power[0] = 1;
	for (int i = 1; i < MAX_N; i++) {
		power[i] = power[i - 1] * 2;
	}
	for (int i = 0; i < power[n]; i++) {
		int sum1 = 0;
		for (int j = 0; j < n; j++) {
			int v = power[j];
			int w = (i / v) % 2;
			if (w == 1) {
				sum1 += 1;
			}
		}
		if (sum1 == m) {
			vec.push_back(i);
		}
	}
	long double res = 0;
	for (int i = 0; i < vec.size(); i++) {
		int c[MAX_N] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
		for (int j = 0; j < n; j++) {
			c[j] = (vec[i] / power[j]) % 2;
		}
		vector<int>vec2;
		int cnt3 = 0;
		for (int j = 0; j < n; j++) {
			if (c[j] == 1) {
				vec2.push_back(j);
			}
		}
		long double sum2 = 0;
		for (int j = 0; j < vec2.size(); j++) {
			for (int k = j + 1; k < vec2.size(); k++) {
				sum2 += dist[vec2[j]][vec2[k]];
			}
		}
		res = max(res, sum2);
	}
	cout << fixed << setprecision(15) << res << endl;
	return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int S, W;
  cin >> S >> W;
  if(S>W)
  {
    cout << "safe" << endl;
  }
  else
  {
    cout << "unsafe" << endl;
  }
  return 0;
}


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

int main(){
    int N, tmp;
    long long ans=0;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++)
	cin >> a[i];
    sort(a.begin(), a.end());

    for(int i=0; i<N; i++){
	for(int j=i+1; j<N; j++){
	    tmp = a[i]+a[j];
	    for(int k=j+1; k<N; k++){
		if(tmp >a[k])
		    ans++;
		else
		    break;
	    }
 	}
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
from math import pi, cos, sqrt

A, B, H, M = map(int, input().split())

angleM = 2*pi*M/60
angleH = 2*pi*(H+M/60)/12
angle = abs(angleM-angleH)
#print('angleM:', angleM, '/ angleH:', angleH)
#print('angle:', angle)

ans = A**2 + B**2 - 2*A*B*cos(angle)
print(sqrt(ans))


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

const ll INF = 1e9+7;

ll kai(ll x) {
    ll ret = 1;
    while (x > 0) {
        ret = ret * x % INF;
        x--;
    }
    return ret;
}

int main() {
    ll Min, Max;
    cin >> Min >> Max;
    if (Min > Max) {
        swap(Min, Max);
    }

    ll ans = 1;
    if (Min == Max) {
        ans = kai(Min);
        ans = ans * kai(Max) % INF;
        ans = ans * 2 % INF;
    } else if (Max - Min == 1) {
        ans = kai(Max);
        ans = ans * kai(Min) % INF;
    } else {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    mt19937 mt(random_device{}());
    uniform_int_distribution<long> uid(-2000000, 2000000);
    unsigned long ans{0};
    for(unsigned long i = 0; i < 300; ++i){
        long x{uid(mt)}, y{uid(mt)};
        long a{0}, b{0};
        for(const auto& engine : eng)if(x * engine.first + y * engine.second >= 0){
            a += engine.first;
            b += engine.second;
        }
        if(ans < a * a + b * b)ans = a * a + b * b;
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

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

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

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

int main() {
    int N;
    char S[300100];

    int ans;
    int tmp = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        if (i > 0 && S[i] == 'E') tmp++;
    }

    ans = tmp;

    for (int i = 1; i < N; i++) {
        if (S[i] == 'E') tmp--;
        if (S[i - 1] == 'W') tmp++;
        if (tmp < ans) ans = tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int b=0,num1=1000000,num2=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='F') num2=i+1;
        if(s[i]=='C'&&!b) num1=i+1,b=1;
    }
    if(num2>num1) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

#define int long long

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

int N;
int x[100], y[100];

double norm(double d) {
    if (d > M_PI) {
        d -= 2 * M_PI;
    }
    if (d < -M_PI) {
        d += 2 * M_PI;
    }
    return d;
}
double dist(double s, double t) {
    double res = s - t;
    if (res < 0) {
        res += 2 * M_PI;
    }
    return res;
}

bool is_aida(double s, double t, double a) {
    if (t >= 114513) {
        return true;
    }
    if (s >= t) {
        return s >= a && a >= t;
    } else {
        return (s >= a && t >= a) || (s <= a && t <= a);
    }
}

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    double ans[100];
    for (int i = 0; i < N; i++) {
        double start_min = 0, end_min = 114514;
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }
            double cur = atan2(y[i] - y[j], x[i] - x[j]);
            double s = norm(cur + M_PI / 2);
            double t = norm(cur - M_PI / 2);
            if (!is_aida(start_min, end_min, s) &&
                !is_aida(start_min, end_min, t) && !is_aida(s, t, start_min) &&
                !is_aida(s, t, end_min)) {
                start_min = end_min = 0;
                break;
            }
            if (is_aida(start_min, end_min, s)) {
                start_min = s;
            }
            if (is_aida(start_min, end_min, t)) {
                end_min = t;
            }
        }
        ans[i] = dist(start_min, end_min);
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] / (2 * M_PI) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			Price p = new Price();
			p.feeCalculation(scan);
			System.out.println(p.getPrice());
		}
	}
}

class Price{
	private int pasta;
	private int juice;
	private int lunchPrice;
	
	public Price(){
		pasta = 0;
		juice = 0;
		lunchPrice = 0;
	}
	
	public void feeCalculation(Scanner scan){
		pasta = Math.min(scan.nextInt(),scan.nextInt());
		pasta = Math.min(pasta,scan.nextInt());
		juice = Math.min(scan.nextInt(),scan.nextInt());
		lunchPrice = pasta + juice - 50;
	}
	
	public int getPrice(){
		return lunchPrice;
	}
}

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

using namespace std;

int const maxn = 101;
int const maxk = 101010;

int n;
int w[maxn];
bool dp[maxk];

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

    int k;
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (w[j] <= i) {
                dp[i] |= !dp[i-w[j]];
            } 
        }
    }
    if (dp[k]) {
        cout << "First\n";
    }
    else {
        cout << "Second\n";
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

double x,h;

int main(){
	while(cin>>x>>h){
		if(!x)return 0;
		printf("%.6f\n",x*x+2.0*x*sqrt(x*x/4.0+h*h));
	}
}

Measured memory_bytes: 0
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cnt = 0;
		int plug = 1;
		for(;;){
			if (plug >= b) break;
			plug = plug + a - 1;
			cnt++;
		}
		out.println(cnt);
	}
}

Measured memory_bytes: 21972
N = input()

if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
  print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
  print("pon")
elif N[-1] == "3":
  print("bon")

Measured memory_bytes: 9132
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;

vector<vector<ll> > mul(vector<vector<ll> > &a, vector<vector<ll> > &b, int n){
    vector<vector<ll> > res(n,vector<ll>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                res[i][j]+=a[i][k]*b[k][j];
                res[i][j]%=MOD;
            }
        }
    }
    return res;
}

vector<vector<ll> > pow(vector<vector<ll> > &a,int n, ll k){
    vector<vector<ll> > res(n,vector<ll>(n,0));
    for(int i=0;i<n;i++) res[i][i]=1;
    while(k>0){
        if(k&1) res=mul(res,a,n);
        a=mul(a,a,n);
        k>>=1;
       
    }
    return res;
}

int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<vector<ll> > G(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>G[i][j];
        }
    }
    G=pow(G,n,k);
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans+=G[i][j];
            ans%=MOD;
        }
    }
    cout<<ans<<endl;

}

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

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
string st;
int a;
map<char, vector<int>>mp;

long long int getnum() {
	long long int num = 0;
	while (isdigit(st[a])) {
		num = num * 10 + st[a] - '0';
		a++;
	}
	return num;
}
vector<int>getexpr();
vector<int> connectAmida(const vector<int>& x, const vector<int>& y)
{
	int n = x.size();
	vector<int> ans(n);
	for (int i = 0; i<n; ++i)
		ans[i] = y[x[i]];
	return ans;
}
vector<int> repeatAmida(int a, const vector<int>& x)
{
	int n = x.size();
	vector<int> len(n, 0);
	for (int i = 0; i<n; ++i) {
		int j = i;
		do {
			j = x[j];
			++len[j];
		} while (j != i);
	}

	vector<int> ans(n);
	for (int i = 0; i<n; ++i) {
		int j = i;
		for (int k = 0; k<a%len[i]; ++k)
			j = x[j];
		ans[i] = j;
	}
	return ans;
}
vector<int>getelem() {
	long long int num = 1;
	vector<int>v;
	if (isdigit(st[a])) {
		num = getnum();
	}
	if (st[a] == '(') {
		a++;
		v = getexpr();
		a++;
	}
	else {
		char c = st[a];
		a++;
		v = mp[c];
	}
	auto ans=repeatAmida(num, v);
	//map<int,vector<int>>memo;
	//vector<int>start(v.size());
	//iota(start.begin(), start.end(), 0);
	//memo[0] = start;
	//vector<int>now(start);
	//for (int i = 0; i < num; ++i) {
	//	vector<int>next(v.size());
	//	//2 3 4 1 0 v
	//	//1 0 3 4 2 now
	//	for (int j = 0; j < now.size(); ++j) {
	//		next[j] = v[now[j]];
	//	}
	//	if (i&&memo[0] == next) {
	//		return memo[num%(memo.size())];
	//	}
	//	else {
	//		memo[i+1] = next;
	//		now = next;
	//	}
	//}
	return ans;
}
vector<int> getexpr() {
	vector<int>v=getelem();
	while (1) {
		if (a == st.size()||st[a]==')')return v;
		else {
			assert(st[a] == '+');
			a++;
			vector<int>nv=getelem();
			v = connectAmida(v, nv);
			//vector<int>next(v.size());
			////2 3 4 1 0 v
			////1 0 3 4 2 now
			//for (int j = 0; j < v.size(); ++j) {
			//	next[j] = nv[v[j]];
			//}
			//v = next;
		}
	}
	
}
void solve(const string &ast) {
	st = ast;
	a = 0;
	vector<int>v=getexpr();
	assert(a == st.size());
	assert(!v.empty());
	vector<int>ans(v.size());
	for (int i = 0; i < v.size(); ++i) {
		ans[v[i]] = i;
	}
	v = ans;
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i]+1;
		if (i != v.size() - 1)cout << " ";
		else cout << endl;
	}
}

int main() {
	int N, K; cin >> N >> K;
	for (int i = 0; i < K; ++i) {
		char P;int  H; cin >> P >> H;
		vector<int>nums(N);
		iota(nums.begin(), nums.end(), 0);
		for (int i = 0; i < H - 1; ++i) {
			for (int j = 0; j < N - 1; ++j) {
				int g; cin >> g;
				if (g)swap(nums[j], nums[j + 1]);
			}
		}
		vector<int>change(N);
		for (int i = 0; i < N; ++i) {
			change[nums[i]] = i;
		}
		mp[P] = change;
	}
	int E; cin >> E;
	while (E--) {
		string ast; cin >> ast;
		solve(ast);
	}
	return 0;
}

Measured memory_bytes: 3168
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define Di 3.1415926
#include<math.h>
#include<string>
#include<stack>
#define INF 0x3f3f3f3f
using namespace std;
ll  gcd(ll a,ll b)
{
    return a%b? gcd(b,a%b):b;
}
int a[200];
int main()
{    int m,sum=0,i,couts=0;
     scanf("%d",&m);
      for(i=0;i<m;i++)
      {
          scanf("%d",&a[i]);
          sum+=a[i];
      }
      int num=sum/(m);
      int maxs=0;
      int mins=INF,ss=0;
      if(num<0)
      {

          int couts=abs(sum%m)+1;
            i=0;
        while(i<couts)
        {
            int s=num-i;
             int ss=0;
            for(int j=0;j<m;j++)
          {
             ss+=pow(abs(s-a[j]),2);
          }
          if(ss<mins)
            mins=ss;

           i++;
         }
        cout<<mins<<endl;
         return 0;
      }
     for(i=num;i<=num+sum%m;i++)
     {     ss=0;

         for(int j=0;j<m;j++)
         {
             ss+=pow(abs(i-a[j]),2);
         }

         if(mins>ss)
          mins=ss;
     }

    printf("%d\n",mins);


 return 0;
}


Measured memory_bytes: 256
n,m= map(int, input().split())
h=list(map(int, input().split()))
B=[0]*m
A=[0]*m
t=[[] for i in range((n+1))]
an=0
for i in range(m):
    A[i],B[i] = list(map(int, input().split()))

for i in range(m):
    t[A[i]].append(B[i])
    t[B[i]].append(A[i])
for i in range(1,n+1):
    k=0
    for j in range(len(t[i])):
        if h[i-1]<=h[t[i][j]-1]:
            k=1
    if k==0:
        an+=1

print(an)

Measured memory_bytes: 30968
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

typedef long long ll;

bool pcom(const pair<ll, ll>& firstp, const pair<ll, ll> secondp){
  return firstp.second < secondp.second;
}

int main(){
  ll n;
  cin >> n;
  vector<pair<ll, ll> > p;

  for(ll i = 0; i < n ;i++){
    long long a,b;
    cin >> a >> b;
    p.push_back(make_pair(a,b));
  }
  sort(p.begin(), p.end(), pcom);
  long long now = 0;
  for(ll i = 0; i < n ;i++){
    now += p[i].first;
    if(now > p[i].second){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    ll n;
    cin>>n;
    ll A[n];
    ll pre[n+1];
    // pre[0] = 0;
    loop(i,0,n){
        cin>>A[i];
    }
    pre[0] = 0;
    loop(i,1,n+1){
        pre[i] = pre[i-1]+A[i-1];
    }
    ll dp[410][410];
    init(dp, 0);
    loopr(i,n+1,1){
        loop(j,1,n+1){
            if(i>=j){
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = LONG_MAX;
            loop(k,i,j){
                dp[i][j] = min(dp[i][j], pre[j]-pre[i-1] + dp[i][k] + dp[k+1][j]);
            }
        }
    }
    // loop(i,0,n+1){
    //     loop(j,0,n+1){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 1664
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)2e5 + 5;

int arr[MAXN];

bool u[MAXN];

int n, x;

void solve() {
    scanf("%d %d", &n, &x);

    if (n == x) {
        printf("Yes\n");

        for (int i = 1; i <= 2 * n - 1; ++i) {
            printf("%d\n", i);
        }

        return;
    }

    if (2 * n - 1 < 5) {
        printf("No\n");
        return;
    }

    arr[n] = x;
    u[x] = 1;

    if (x == 1 || x == 2 * n - 1) {
        printf("No\n");
        return;
    }

    if (x >= 3) {
        arr[n + 1] = x + 1;
        u[x + 1] = 1;

        arr[n - 1] = x - 1;
        u[x - 1] = 1;

        arr[n + 2] = x - 2;
        u[x - 2] = 1;
    }
    else {
        arr[n + 1] = x - 1;
        u[x - 1] = 1;

        arr[n - 1] = x + 1;
        u[x + 1] = 1;

        arr[n + 2] = x + 2;
        u[x + 2] = 1;
    }

    for (int i = 1, p = 1; i <= 2 * n - 1; ++i) {
        if (arr[i]) {
            continue;
        }

        while (u[p]) {
            ++p;
        }

        arr[i] = p;
        u[p] = 1;
    }

    printf("Yes\n");

    for (int i = 1; i <= 2 * n - 1; ++i) {
        printf("%d\n", arr[i]);
    }
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

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

    ll x,k,d;
    cin>>x>>k>>d;
    if(x<=0) {
        x*=-1;
    }

    ll ans=0;
    ans = x/d;

    if(ans>=k){
        fin(x-k*d);
    }

//    ans = min(x-d*ans,d*(ans+1)-x);

    if((k-ans)%2==0){
        fin(x-d*ans);
    }else{
        fin(d*(ans+1)-x);
    }


    return 0;
}




Measured memory_bytes: 3640
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

K = get_int
S = gets.chomp

if S.length > K
  puts "#{S[0...K]}..."
else
  puts S
end


Measured memory_bytes: 14404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int a = sc.nextInt();

		if ((h % a) != 0) {
			System.out.println((h / a) + 1);
		} else {
			System.out.println((h / a));
		}

		sc.close();
	}
}

Measured memory_bytes: 26960
using System;

namespace code_festival_2017_quala_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            str += "    ";
            if (str.Substring(0, 4) == "YAKI")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std ;
const int N=3e3+1;  
string s , t ; 
int Dp[N][N];
int calc(int i , int j ){
    if(i == s.size()  or  j==t.size())return 0 ; 
   
    int &ret = Dp[i][j]; 
    if(ret!=-1)return ret ; 
    if(s[i]==t[j]) ret =max(ret , 1+calc(i+1,j+1));
    else {
        ret  = max(ret , calc(i,j+1));
        ret = max(ret , calc(i+1,j));
    } 
    return ret ; 

}
void printing (int i,int j ){
    
    if(i == s.size() or  j==t.size())return  ; 
   
    if(s[i]==t[j]){
        cout<<s[i];
        printing(i+1,j+1);
    }
    else if (calc(i,j)==calc(i+1,j))
    { 
        printing(i+1,j);
    }
    else {
    printing(i,j+1);
    return ;
        
    } 
}
int main (){ 

    cin>>s>>t ; 
    memset(Dp,-1,sizeof Dp);
   calc(0,0);
   printing(0,0);
    return 0 ; 
}

Measured memory_bytes: 39064
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, m;
    readlnTo(n, m);
    auto from1 = new bool[](n);
    auto fromN = new bool[](n);
    foreach(i; iota(m)) { 
        long a, b;
        readlnTo(a, b);
        --a;
        --b;
        if(a == 0) { 
            from1[b] = true;
        }
        if(b == n-1) {
            fromN[a] = true;
        }
    }
    foreach(i; iota(n)) {
        if(from1[i] && fromN[i]) {
            writeln("POSSIBLE");
            return;
        }
    }
    writeln("IMPOSSIBLE");
}



Measured memory_bytes: 2428
<?php 
fscanf(STDIN, "%s", $s);
$array = str_split($s);
for($i = 0 ; $i < count($array) - 1 ; $i++){
    if($array[$i] === $array[$i + 1]){
        $answer =  'Bad';
    }
    
}
if($answer){
    echo $answer;
}else{
    echo 'Good';
}
?>

Measured memory_bytes: 4728
s = gets.split("").map { |i| i.to_i } 

min_s = 1000000
(s.length - 3).times do |i|
	num = (753 - (s[i]*100 + s[i+1]*10 + s[i+2])).abs
	min_s = num if  num < min_s
end

puts min_s



Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int a, b, c; cin >> a >> b >> c; bool poor = false;
  if(a==b || b==c || a==c){
    poor=true;
  }
  if(a==b && b==c){
    poor=false;
  }
  if(poor){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    set<int> a;
    for(int i = 0; i < s.length(); i++){
        if(a.count(s[i]) != 0){
            cout << "no" << endl;
            return 0;
        } else {
            a.insert(s[i]);
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vector<pair<string,pair<ll,ll>>> a(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i).first >> a.at(i).second.first ;
		a.at(i).second.first *= -1 ;
		a.at(i).second.second = i+1 ;
	}
	sort(all(a)) ;
	for(int i=0;i<n;i++){
		cout << a.at(i).second.second << endl ;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
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(){
  ll n,k;
  cin>>n>>k;
  vector<pll> p(n);
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    p[i]=mp(a,b);
  }
  sort(all(p));
  ll cu=0;
  rep(i,n){
    cu+=p[i].S;
    if(cu>=k){
      COUT(p[i].F);
      break;
      
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using llf = long double;
using pi = pair<llf, llf>;
const llf eps = 1e-9;

deque<pi> dq;
int n, l;
llf dap;

int main(){
	scanf("%d %d",&n,&l);
	for(int i=0; i<n; i++){
		int t, v; 
		scanf("%d %d",&t,&v);
		if(i > 0){
			llf l = v;
			while(dq.size() && l > eps){
				auto w = dq.back();
				dq.pop_back();
				auto dx = min(l, w.second);
				dap -= w.first;
				w.first -= (w.first / w.second) * dx;
				dap += w.first;
				w.second -= dx;
				l -= dx;
				if(w.second > eps){
					dq.push_back(w);
					break;
				}
			}
		}
		dap += 1ll * t * v;
		llf sum = 1ll * t * v;
		llf len = v;
		while(dq.size() && sum / len < dq[0].first / dq[0].second){
			sum += dq[0].first;
			len += dq[0].second;
			dq.pop_front();
		}
		dq.emplace_front(sum, len);
		printf("%.10Lf\n", dap / l);
	}
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


typedef long double D;
const D PI = acos(-1.0);
const D EPS = 1e-10;
class P { public:
  D x, y;
  P(D x=0, D y=0) : x(x), y(y) {}

  P& operator+=(const P& o) { x += o.x; y += o.y; return *this; }
  P& operator-=(const P& o) { x -= o.x; y -= o.y; return *this; }
  P& operator*=(const P& o) { return *this = {x*o.x - y*o.y, x*o.y + y*o.x}; }
  P& operator*=(const D& r) { x *= r; y *= r; return *this; }
  P& operator/=(const D& r) { x /= r; y /= r; return *this; }
  P operator-() const { return {-x, -y}; }

  D norm() const { return x*x + y*y; }
  D abs() const { return sqrt(norm()); }
  D arg() const { return atan2(y, x); }
  bool isZero() const { return std::abs(x) < EPS && std::abs(y) < EPS; }
  /** 象限 */
  int orth() const { return y >= 0 ? (x >= 0 ? 1 : 2) : (x < 0 ? 3 : 4); }
  static P polar(const D& rho, const D& theta = 0) { return {rho * cos(theta), rho * sin(theta)}; }
};
std::ostream &operator<<(std::ostream &os, P const &p) { return os << "(" << p.x << ", " << p.y << ")"; }
P operator+(const P& p, const P& q) { return P(p) += q; }
P operator-(const P& p, const P& q) { return P(p) -= q; }
P operator*(const P& p, const P& q) { return P(p) *= q; }
P operator*(const P& p, const D& r) { return P(p) *= r; }
P operator/(const P& p, const D& r) { return P(p) /= r; }
P operator*(const D& r, const P& p) { return P(p) *= r; }
P operator/(const D& r, const P& p) { return P(p) /= r; }
D crs(const P& a, const P& b){ return a.x*b.y - a.y*b.x; }
D dot(const P& a, const P& b){ return a.x*b.x + a.y*b.y; }
int signum(D x) {return x > EPS ? +1 : x < -EPS ? -1 : 0;}
bool operator<(const P& a, const P& b) {
  return a.arg() < b.arg();
}

int main2() {
  int N; cin >> N;
  vector<P> p(N);
  REP(i, N) {
    int x, y; cin >> x >> y;
    p[i] = P(x, y);
  }
  sort(ALL(p));

  double ans = 0;
  REP(i, N) {
    P s;
    REP(k, N) {
      s += p[(i + k) % N];
      chmax(ans, (double)s.abs());
    }
  }
  printf("%.12f\n", ans);

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))


int main() {
	int n,min=1000,max=0;
	scanf("%d", &n);
	rep(i, n) {
		int j; scanf("%d", &j);
		max = M(max, j);
		min = m(min, j);
	}
	printf("%d", max - min);

}

Measured memory_bytes: 128
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 

	int a,b,c;
	cin>>a>>b>>c;
	int s=a+b+c;
	if(s>=22)
	{
		cout<<"bust";
	}
	else
	{
		cout<<"win";
	}
	
	
// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String U = sc.next();

        System.out.println(solve(S, T, A, B, U));
    }

    private static String solve(String S, String T, int A, int B, String U) {

        if (S.equals(U)) {
            A--;
        } else {
            B--;
        }

        return A + " " + B;
    }
}

Measured memory_bytes: 23508
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val news = sc.next().toList.distinct
  val ret = news.forall(_ match {
    case 'N' => news.contains('S')
    case 'S' => news.contains('N')
    case 'E' => news.contains('W')
    case 'W' => news.contains('E')
  })
  if (ret) print("Yes") else print("No")
}



Measured memory_bytes: 55564
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	s := readString()
	t := readString()
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	// move := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if s[i] == t[j] {
				dp[i+1][j+1] = dp[i][j] + 1
			} else {
				dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
			}
		}
	}

	i, j := n, m
	var ans string
	for i > 0 && j > 0 {
		if dp[i][j] == dp[i-1][j] {
			i--
		} else if dp[i][j] == dp[i][j-1] {
			j--
		} else {
			ans = string(s[i-1]) + ans
			i--
			j--
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 80640
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: u128,
        mut b: String
    };
    b.retain(|c| c != '.');
    println!("{}", a * b.parse::<u128>().unwrap() / 100);
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int K, S;
	cin >> K >> S;
	
	int ans = 0;
	for(int X = 0; X <= K; X++){
		for(int Y = 0; Y <= K; Y++){
			int Z = S - X - Y;
			if(0 <= Z && Z <=K) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256