akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 	class Sort implements Comparator<Integer> 
	{ 
	    public int compare(Integer a, Integer b) 
	    { 
	    	if(a < 0)
	    		a *= -1;
	    	if(b < 0)
	    		b *= -1;
	    	return a.compareTo(b);
	    } 
	}
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(long a[],long key)
	{
		int l=0,r=a.length-1;
		int i=-1;
 
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid]<key)
				l=mid+1;
 
			else{
				i=mid;	
				r=mid-1;
			}
			
		}
		return i;
	}
	int lowerBound(Pair[] a , long key)
	{
		int l = 0, r = a.length- 1;
		int i = -1;
 	
		while(l<=r)
		{
			int mid=(l+r)/2;
 
			if(a[mid].f<key)
			{
				i=mid;
				l=mid+1;	
			}
 
			else
				r=mid-1;
			
		}
		return i;
	}
 
	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}
	
 
	int mod= 1000000007;
	long gcd(long x ,long y)
	{
		if(y==0)
			return x;
		return gcd(y,x%y);
	}
 
	// ArrayList a[];
	// int vis[],cnt=0;
	// void dfs(int ver)
	// {
	// 	ArrayList<Integer> l=a[ver];
	// 	if(l.size()==1)
	// 		cnt++;
	// 	for(int v:l)
	// 	{
	// 		if(vis[v]==0){
	// 			vis[v]=vis[ver]+1;
	// 			dfs(v);
	// 		}
	// 	}
	// }
 
 	int countSetBits(long n) 
    { 
        int count = 0; 
        while (n > 0) { 
            n &= (n - 1); 
            count++; 
        } 
        return count; 
    }

	void solve() throws IOException{
		int n = nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = nextInt();

		Arrays.sort(a);
		long sum = a[n - 1];
		int ind = 0;
		for(int i = n - 2; i >= n / 2; i--)
		{
			sum += 2 * a[i];
			ind = i;
		}
		if(n % 2 == 1)
			sum -= a[ind];
		out.println(sum);
	}
 	
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
 
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Main().run();
	}
  
}


Measured memory_bytes: 55796
/*
  AUTHOR:SOURABH
  CREATED:30:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pii , null_type, less< pii >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,h1,m1,h2,m2,k;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>h1>>m1>>h2>>m2>>k;
        cout<<m2+h2*60-(m1+h1*60)-k;
    }
    return 0;
}














Measured memory_bytes: 3640
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

/* 採点コード
	vector<int> t(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}
	vector<int> last(26, 0);

	int v = 0;
	rep(i, D) {
		v += s[i][t[i]];
		last[t[i]] = i+1;
		rep(j, 26) {
			v -= c[j] * (i + 1 - last[j]);
		}
		cout << v << endl;
	}
	*/

int main(void) {
	srand(time(NULL));
	int D; cin >> D;
	vector<int> c(26, 0);
	rep(i, 26)cin >> c[i];
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep(i, D)rep(j, 26)cin >> s[i][j];

	vector<int> t(D, 0);
	rep(i, D) {
		rep(j, 26) {
			if (s[i][t[i]] <= s[i][j])t[i] = j;
		}
	}
	vector<int> ans = t;
	ll best = 0;

	auto start = clock();
	while (clock() - start < 1500) {
		int idx = rand() % D;
		t[idx] = rand() % 26;

		//採点
		vector<int> last(26, 0);
		ll v = 0;
		rep(i, D) {
			v += s[i][t[i]];
			last[t[i]] = i + 1;
			rep(j, 26) {
				v -= c[j] * (i + 1 - last[j]);
			}
		}
		//採点

		if (best <= v) {
			ans = t;
		}
	}

	for (auto x : ans) {
		cout << x + 1 << endl;
	}

	//テスト時得点確認用
	if(false){
		vector<int> last(26, 0);

		t = ans;

		int v = 0;
		rep(i, D) {
			v += s[i][t[i]];
			last[t[i]] = i + 1;
			rep(j, 26) {
				v -= c[j] * (i + 1 - last[j]);
			}
		}

		cout << v << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3712
from sys import stdin 
a = [0]
n = int(stdin.readline())
for _ in xrange(n):
 a.append(int(stdin.readline()))
ans = -1
cur = 0
x = 1
s = set()
while True:
 if x in s:
  break
 if x==2:
  ans = cur
  break
 s.add(x)
 cur+=1
 x = a[x]
print ans

Measured memory_bytes: 11988
#include <stdio.h>

int main (void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
		return 0;
	}

Measured memory_bytes: 580
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int d[100];
int main() {
    int n,a,b,c; scanf("%d%d%d%d",&n,&a,&b,&c);
    for (int i=0; i<n; i++) scanf("%d",&d[i]);
    sort(d, d+n);
    int sum=c, res=0;
    for (int i=n-1; i>=0; i--) {
        sum+=d[i];
        res=max(res, (int)floor(sum/(a+(n-i)*b)));
    }
    printf("%d\n",res);
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := a
  
  if a == b {
  	ans = c
  }
  if a == c {
    ans = b
  }
  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1832
//by rng_59
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

const int MAXN = 0;

int main(void) {
	double a,b;
	cin >> a >> b;
	for(int i=1; i<=1000000; i++) {
		if(int((double)i*0.08)==a && int((double)i*0.1)==b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int t[2][n+1];
    rep(i, 0, n+1){
        t[0][i] = 0;
        t[1][i] = 0;
    }
    rep(i, 0, m){
        int a, b;
        scanf("%d %d", &a, &b);
        if(a == 1){
            t[0][b] = 1;
        }
        if(a == n){
            t[1][b] = 1;
        }
        if(b == 1){
            t[0][a] = 1;
        }
        if(b == n){
            t[1][a] = 1;
        }
    }
    int f = 0;
    rep(i, 1, n+1){
        if(t[0][i]==1 && t[1][i]==1){
            f = 1;
            break;
        }
    }
    printf(f ? "POSSIBLE" : "IMPOSSIBLE");

    return 0;
}

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

int h, w;
char grid[500][500];
char tempgrid[500][500];

int rowCheck() {
    for (int i = 0;  i < h; i++) {
        bool rowWhite = true;
        for  (int j = 0; j < w; j++)
            if (grid[i][j] == '#')
                rowWhite = false;
        
        if (rowWhite == true)
            return i;
    }
    return -1;
}
int colCheck() {
    for (int j = 0;  j < w; j++) {
        bool colWhite = true;
        for  (int i = 0; i < h; i++)
            if (grid[i][j] == '#')
                colWhite = false;
        
        if (colWhite == true)
            return j;
    }
    return -1;
}


int main() {
    ios::sync_with_stdio(false);
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        cin >> grid[i];
    
    while (rowCheck() != -1) {
        int delrow = rowCheck();
        if (delrow == -1)
            break;
        for (int i = 0; i < h; i++) {
            for (int j = 0;  j < w; j++)
                if (i < delrow)
                    continue;
                else
                    grid[i][j] = grid[i+1][j];
        }
        h--;
    }
    
    while (colCheck()!= -1) {
        int delcol = colCheck();
        //cout << "delcol: " << delcol << endl;
        if (delcol == -1)
            break;
        for (int j = 0; j < w; j++) {
            for (int i = 0;  i < h; i++)
                if (j < delcol)
                    continue;
                else
                    grid[i][j] = grid[i][j+1];
        }
        w--;
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            cout << grid[i][j];
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
from itertools import count


def main():
    H = int(input())
    for i in count():
        if 2 ** i > H:
            print(2**i-1)
            exit()


def test():
    for H in range(1, 101):
        monster = [H]
        ans = 0
        while len(monster) > 0:
            tmp = list()
            for m in monster:
                if m != 1:
                    tmp.extend([m//2]*2)
                ans += 1
            monster = tmp
        print(ans)


def test2():
    H = 10 ** 12
    ans = 0
    while H > 1:
        H //= 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    sm = 0
    xd = defaultdict(int)
    for k in d:
        if d[k] >= 2:
            xd[k] = (d[k] * (d[k] - 1)) // 2
        sm += xd[k]
    for e in a:
        d[e] -= 1
        sm -= xd[e]
        x = 0
        if d[e] >= 2:
            x = (d[e] * (d[e] - 1)) // 2
        print(sm + x)
        sm += xd[e]
        d[e] += 1


    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


Measured memory_bytes: 34608
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int lB=0;
		double sum;
		boolean ok=false;
		if(b / 100 > 0) {
			lB = 3;
		} else if(b / 10 > 0) {
			lB = 2;
		} else {
			lB = 1;
		}
		sum = a * (int)Math.pow(10, lB) + b;
		for(int i=0; i<500;i++) {
			if(sum==i*i) {
				System.out.println("Yes");
				ok=true;
				break;
			}
		}
		if(ok==false) {
		System.out.println("No");
		}

	}

}

Measured memory_bytes: 21844
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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> PII;
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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;

	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n-1);

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

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

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

	int ans = 0;
	ans += accumulate(b.begin(), b.end(),0);

	for (int i = 0; i < n - 1; i++) {
		if ((a[i]+1) == (a[i + 1]))ans += c[a[i]];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias P = Tuple!(long, "a", long, "b");

void main()
{
    auto hwn = readln.split.to!(long[]);
    auto H = hwn[0];
    auto W = hwn[1];
    auto N = hwn[2];

    int[P] ps;
    foreach (i; 0..N) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0];
        auto b = ab[1];
        foreach (j; a-1..a+2) {
            foreach (k; b-1..b+2) {
                if (1 < j && j < H && 1 < k && k < W) {
                    ++ps[P(j, k)];
                }
            }
        }
    }
    long[10] rs;
    long x;
    foreach (_, n; ps) {
        ++x;
        ++rs[n];
    }
    rs[0] = (H-2) * (W-2) - x;
    foreach (r; rs) writeln(r);
}

Measured memory_bytes: 82764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    int a,b,tmp;
    cin >> a >> b;
    tmp = max(a+b,a-b);
    tmp = max(a*b,tmp);
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut ans = 0;
    for a in 1..n {
        ans += (n - 1) / a;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2156
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

module WeightedGraph
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  (*
   * HashtblやMapを用いているとプリム法と大差ない計算時間になってしまうため，
   * より汎用的な実装が欲しければそちらを当たること
   *)
  val kruskal :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 最小全域木に含まれる辺のリスト
       畳み込む関数と初期値まで与えられて初めて計算を開始するので，
       最小全域木に対して色々な操作をしたい場合は，
       一度リストにして覚えておくとよい．
       最小全域木の重さの和だけ欲しいとか一回しか使わない場合は，
       直接畳み込む関数と初期値を与えるとdeforestationになっていい感じ． *)
    (int * int * Weight.t) church_list
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let kruskal n es =
    { fold = fun f init ->
      let uf = UnionFind.make n in
      List.fold_left (fun acc (u, v, w) ->
        let c = UnionFind.find uf u in
        let d = UnionFind.find uf v in
        if UnionFind.Class.compare c d = 0
        then acc
        else (UnionFind.unite uf c d; f (u, v, w) acc)) init @@
      List.sort (fun (_, _, w) (_, _, w') -> Weight.compare w w') @@
      es.fold (fun x xs -> x :: xs) [] }
end
 
module Int = struct
  type t = int
  let compare = compare
end
 
module G = WeightedGraph (Int)
 
let () =
  let n = Scanf.scanf "%d\n" @@ fun n -> n in
  let xys = Array.to_list @@ Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  let xedges =
    List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, x' - x) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  let yedges =
    List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, y' - y) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  Printf.printf "%d\n" @@
  (G.kruskal n { G.fold = fun f acc -> List.fold_right f xedges @@ List.fold_right f yedges acc }).G.fold (fun (_, _, d) -> ( + ) d) 0


Measured memory_bytes: 34816
#include <cstdio>
#include <vector>
using namespace std;

typedef struct edge {
  int dest;
  int len;
} edge;
vector<edge> adj[100001];
vector<int> ans(100001);

void dfs(int cur, int color) {
  ans[cur] = color;
  for(auto& e : adj[cur]) {
    if(ans[e.dest]) continue;
    if(e.len % 2) dfs(e.dest, 3-color);
    else dfs(e.dest, color);
  }
}

int main() {
  int N;
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    int a, b, w;
    scanf("%d%d%d", &a, &b, &w);
    adj[a].push_back({b,w});
    adj[b].push_back({a,w});
  }
  dfs(1, 1);
  for(int i = 1; i <= N; i++)
    printf("%d\n", ans[i]-1);
}
    

Measured memory_bytes: 8448
using System;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
            //using (var sr = new InputReader(new StreamReader("input.txt")))
            {
                var task = new Task();
                using (var sw = Console.Out) {
                    //using (var sw = new StreamWriter("output.txt")) {
                    task.Solve(sr, sw);
                    //Console.ReadKey();
                }
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var input = sr.ReadArrayOfInt32();
            var n = input[0];
            var k = input[1];
            var array = sr.ReadArrayOfInt64();
            Array.Sort(array, (x, y) => -x.CompareTo(y));
            sw.WriteLine(array.Take(k).Sum());
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose) {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll dp[10005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h,n;
    cin>>h>>n;
    vector<p2> v(n);
    for(ll i=0;i<n;i++)
    cin>>v[i].first>>v[i].second;
    for(ll i=1;i<=h;i++)
    dp[i]=pow(10,17);
    for(ll i=0;i<=h;i++)
    for(ll j=0;j<n;j++)
    dp[i]=min(dp[i],dp[max(ll(0),i-v[j].first)]+v[j].second);
    cout<<dp[h];
} 


Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();
    let (x, y) = (line[0], line[1]);

    let diff = (x.abs()-y.abs()).abs();
    let mut ans = std::i64::MAX;

    //B not first, not last
    if x + diff == y{
        ans = cmp::min(ans, diff);
    }

    //B not first, last
    if x + diff == -y{
        ans = cmp::min(ans, diff+1);
    }

    if -x + diff == y{
        ans = cmp::min(ans, diff+1);
    }

    if -x + diff == -y{
        ans = cmp::min(ans, diff+2);
    }
    println!("{}", ans);
}


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

using namespace std;
using ll = long long;

int main(void)
{
    ll     n, x, y, ans = 0;
    double d;

    cin >> n >> d;
    for (int i = 0; i < n; ++i)
    {
        cin >> x >> y;
        double cur_dist = sqrt(x * x + y * y);
        if (cur_dist <= d)
            ans++;
    }

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


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

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

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

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

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

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

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

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

int main(){
    int n;
    cin >> n;
    vi a(n), s;
    rep(i, n) cin >> a[i];
    s = a;
    sort(rall(s));
    rep(i, n) {
        if (a[i] == s[0]) cout << s[1] << endl;
        else cout << s[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
akasaka
'''

def solve(s):
	n = len(s)
	a = s[:((n-1)//2)]
	b = s[((n+3)//2)-1:]
	# print(a,b)
	return 'Yes' if(s == s[::-1] and a == a[::-1] and b == b[::-1]) else 'No'
	

s = input()
ans = solve(s)
print(ans)


Measured memory_bytes: 4972
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

M,D = inpl()

ans = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d1,d2 = int(str(d)[0]), int(str(d)[1])
        if d1 >= 2 and d2 >= 2 and m == d1*d2:
            #print(m,d)
            ans += 1

print(ans)


Measured memory_bytes: 43244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ChessBoard chess = new ChessBoard();
		try (Scanner stdin = new Scanner(System.in)) {
			int h, w;
			while (stdin.hasNext()) {
				h = Integer.parseInt(stdin.next());
				w = Integer.parseInt(stdin.next());
				if (h < 0 || h > 300 || w < 0 || w > 300) {
					throw new RuntimeException("Input Error:Range 0 to 300");
				}
				if (h == 0 && w == 0) {
					break;
				}
				chess.draw(h, w);
				System.out.println("");
			}
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
}

abstract class AbstractDiagram {
	abstract void draw(int height, int width);
}

class ChessBoard extends AbstractDiagram {
	@Override
	void draw(int h, int w) {
		StringBuilder sb = new StringBuilder();
		for (int r = 1; r <= h; r++) {
			for (int c = 1; c <= w; c++) {
				if ((r % 2 == 1 & c % 2 == 1) || (r % 2 == 0 & c % 2 == 0)) {
					sb.append('#');
				} else {
					sb.append('.');
				}
			}
			System.out.println(sb);
			sb.setLength(0); // sb clear
		}
	}
}

Measured memory_bytes: 27464
#include <iostream>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int w,h;
int island[50][50];
int visited[50][50];
const int dx[] = {0,-1,-1,-1,0,1,1,1};
const int dy[] = {-1,-1,0,1,1,1,0,-1};

void umeru(int x, int y){
	
	visited[y][x] = 1;
	//printf("%d,%d\n",x,y);
	REP(k,8){
		int tx = x + dx[k];
		int ty = y + dy[k];
		if( tx<0 || ty<0 || tx>=w || ty>=h )continue;
		if( island[ty][tx]==0 || visited[ty][tx]==1 )continue;
		umeru(tx,ty);
	}
	return;
}
int main(){
	while(cin>>w>>h,w|h){
		int ans = 0;
		memset(visited,0,sizeof(visited));
		REP(i,h)REP(j,w)cin>>island[i][j];
		REP(i,h)REP(j,w)if( island[i][j] && !visited[i][j] ){
			umeru(j,i);
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var w;
var count= 0;
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var x = lines[0];
  for(var i = 0; i<x.length;i++){
     w =  x.slice(i,i+1);
     count = count + parseInt(w[0]);
  }
  if(count % 9 == 0){
    console.log('Yes');
  }else if (count % 9 != 0){
    console.log('No');
  }
});

Measured memory_bytes: 33616
#include <stdio.h>

int main(void){
	int t,n,s,f;
	
	while (scanf("%d", &t), t){
		scanf("%d", &n);
		while (n--){
			scanf("%d %d", &s, &f);
			t -= (f-s);
		}
		if (t<=0) puts("OK");
		else printf("%d\n", t);
	}
	return 0;
}
	
	

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

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

typedef int VAL;
struct WeightedUnionFind {
  int n;
  vector<int> rank, par;
  vector<VAL> diff_weight;
  WeightedUnionFind() {}
  WeightedUnionFind(int n) : n(n), rank(n, 1), par(n), diff_weight(n) { iota(par.begin(), par.end(), 0); }

  int root(int x) {
    if (x == par[x]) return x;
    int r = root(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = r;
  }

  bool merge(int x, int y, VAL w) {
    int X = root(x), Y = root(y), W = w;
    W += weight(x);
    W -= weight(y);
    if (X == Y) return diff(x, y) == w;
    if (rank[X] < rank[Y]) swap(X, Y), W = -W;
    rank[X] += rank[Y];
    par[Y] = X;
    diff_weight[Y] = W;
    return true;
  }

  VAL weight(int x) {
    root(x);
    return diff_weight[x];
  }

  VAL diff(int x, int y) {
    return weight(y) - weight(x);
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return rank[root(x)];
  }
};

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

  vector<int> L(m), R(m), D(m);
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--, R[i]--;
  }

  WeightedUnionFind uf(n);
  for (int i = 0; i < m; i++) {
    if (!uf.merge(L[i], R[i], D[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int d,g;
int p[22],c[22];
int main(){
    int ans=1e9;
    scanf("%d%d",&d,&g);g/=100;
    for(int i=0;i<d;i++) scanf("%d%d",&p[i],&c[i]),c[i]/=100;
    for(int i=0;i<(1<<d);i++){
        int tmp=0;
        int score=0;
        for(int j=0;j<d;j++) if((i>>j)&1){
            tmp+=p[j]; score+=((j+1)*p[j]+c[j]);
        }
        if(score>=g) ans=min(ans,tmp);
        for(int j=0;j<d;j++) if(!((i>>j)&1)){
            for(int k=1;k<p[j];k++){
                score+=((j+1)*k);
                if(score>=g) ans=min(ans,tmp+k);
                score-=((j+1)*k);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,i,j,figure1[36],mini=0,temp=0,s[36],n,te=0,stable=0,figure2[36],c_s[36];
  char ma[36],T,c_ma[36];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf(" %c%d",&ma[i],&figure1[i]);
  }
  for(n = 0 ; n < N ; n++){
    s[n] = n;
  }
  for(i = 0 ; i < N ; i++){
    figure2[i] = figure1[i];
    c_s[i] = s[i];
    c_ma[i] = ma[i];
  }
  /*BubbleSort*/
  for(i = 0 ; i < N ; i++){
    for(j = N-1 ; j > i ; j--){
      if(figure1[j] < figure1[j-1]){
	temp = figure1[j];
	T = ma[j];
	te = s[j];

	figure1[j] = figure1[j-1];
	ma[j] = ma[j-1];
	s[j] = s[j-1];

	figure1[j-1] = temp;
	ma[j-1] = T;
	s[j-1] = te;
      }
    }
  }
  for(i = 0 ; i < N ; i++){
    printf("%c%d",ma[i],figure1[i]);
    if(i < N-1){
      printf(" ");
      if(figure1[i] == figure1[i+1]){
	if(s[i] > s[i+1]){
	  stable = 1;
	}
      } 
    }
    else printf("\n");
  }
  if(stable == 1){
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  stable = 0;
  
  /*SelectionSort*/
  for(i = 0 ; i < N ; i++){
    mini = i;
    for(j = i+1 ; j < N ; j++){
      if(figure2[j] < figure2[mini]){
	mini = j;
      }
    }
    temp = figure2[i];
    T = c_ma[i];
    te = c_s[i];

    figure2[i] = figure2[mini];
    c_ma[i] = c_ma[mini];
    c_s[i] = c_s[mini];

    figure2[mini] = temp;
    c_ma[mini] = T;
    c_s[mini] = te;
  }
  for(i = 0 ; i < N ; i++){
    printf("%c%d",c_ma[i],figure2[i]);
    if(i < N-1){
      printf(" ");
      if(figure2[i] == figure2[i+1]){
	if(c_s[i] > c_s[i+1]){
	  stable = 1;
	}
      } 
    }
    else printf("\n");
  }
  if(stable == 1){
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    vector<vector<int>> t(N, vector<int>(N + 1));
    for (int i = 0; i < N; i++){
      for (int j = 0; j <= N; j++){
        cin >> t[i][j];
      }
    }
    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    for (int i = 1; i < (1 << N); i++){
      for (int j = 0; j < N; j++){
        if (i >> j & 1){
          int p = i - (1 << j);
          int T = t[j][0];
          for (int k = 0; k < N; k++){
            if (p >> k & 1){
              T = min(T, t[j][k + 1]);
            }
          }
          dp[i] = min(dp[i], dp[p] + T);
        }
      }
    }
    cout << dp[(1 << N) - 1] << endl;
  }
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long sum=0;
	rep(i,0,n+1)
		sum+=i;
	rep(i,1,n+1){
		if(i%3==0 && i%5==0)
			sum-=i;
		else if(i%3==0)
			sum-=i;		
		else if(i%5==0)
			sum-=i;
	}
	cout<<sum<<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(100010, 0);
    rep(i, N) {
        int a;
        cin >> a;
        vec[a] += 1;
        vec[a + 1] += 1;
        vec[a + 2] += 1;
    }
    int ans = 0;
    rep(i, 100010) {
        ans = max(ans, vec[i]);
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
    static BufferedReader in;
    static StringTokenizer st;

    public static void solve() throws IOException {
        int n = nextInt();
        double[] arr = new double[n];
        st = new StringTokenizer(in.readLine());
        for(int i = 0;i<n;i++)
            arr[i] = Double.parseDouble(st.nextToken());

        double[] dp = new double[n+1];

        dp[0] = 1;
        for(int coin = 0; coin < n; coin++){

            for(int i = coin+1;i>=0;i--){
                dp[i] = (i ==0?0 : dp[i-1]*arr[coin]) + dp[i]*(1-arr[coin]);
//                System.out.println(Arrays.toString(dp));
            }
//            System.out.println("A bout ends here");
        }

        double answer=  0;

        for(int i = (n+1)/2;i<=n;i++){
            answer+=dp[i];
        }

        System.out.println(answer);

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



Measured memory_bytes: 22996
#abc114c
import itertools

a=raw_input()
n=int(a)
res=0
for i in xrange(1,len(a)+1):
 for s in itertools.product('753',repeat=i):
  m=int("".join(s))
  if len(set(s))==3 and m<=n:
   res+=1
print res


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int& x: a) {
        cin >> x;
    }
    int vmax = *max_element(a.begin(), a.end());
    int vmin = *min_element(a.begin(), a.end());
    if (vmax - vmin >= 2) {
        cout << "No\n";
        return 0;
    }
    int cnt1 = 0, cnt2 = 0;
    for (int x: a) {
        if (x == vmin) {
            cnt1++;
        } else {
            cnt2++;
        }
    }
    if (vmin != vmax) {
        vmax -= cnt1;
        vmin -= cnt1 - 1;
        n -= cnt1;
        cout << (vmin > 0 && n >= 2 * vmax ? "Yes\n": "No\n");
    } else {
        cout << (vmax == n - 1 || n >= 2 * vmax ? "Yes\n": "No\n");
    }
    
    
    
}


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

const ll INF = (ll)(1e18);

int main(void){
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = INF;
  ll m = max(x, y);
  REP(i, m+1){
    ll t = 2*c*i;
    if(x-i > 0) t += a*(x-i);
    if(y-i > 0) t += b*(y-i);
    chmin(ans, t);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> A(N + 1);
  vector<int> B(N + 1);
  vector<int> C(N + 1);
  
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
  }
  
  for(int i = 0;i < N;i++){
    cin >> B.at(i);
  }
  
  for(int i = 0;i < N - 1;i++){
    cin >> C.at(i);
  }
  
  int ans = 0;
  
  for(int i = 0;i < N;i++){
    ans += B.at(A.at(i) - 1);
    if(i != 0){
      if(A.at(i - 1) + 1 == A.at(i)){
      ans += C.at(A.at(i - 1) - 1);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
from numpy import linalg as LA

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

def rotation(x, t, deg = False):
    if deg == True:
        t = np.deg2rad(t)
    a = np.array([[np.cos(t), -np.sin(t)], [np.sin(t),  np.cos(t)]])
    ax = np.matmul(a, x)        
    return ax
vec_a, vec_b = np.array([[A], [0]]), np.array([[B], [0]])

rot_a = rotation(vec_a,  -(360 * H) / 12 - 30 * (M / 60), True)
rot_b = rotation(vec_b, -(360 * M) / 60, True)
# print(rot_a)
# print(rot_b)
# print(rot_a - rot_b)

print(LA.norm(rot_a - rot_b))


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

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

  int n;
  cin >> n;
  int a = n * 100 / 108;
  if (int(a * 1.08) == n)
    cout << a << '\n';
  else if (int((a+1) * 1.08) == n)
    cout << a+1 << '\n';
  else
    cout << ":(" << '\n';
}

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

using namespace std;
int main() {
    int n, i, j, p_num=1;
    vector<int> prime = {2}, a;
    cin >> n;
    for(i=3; n > 0; i++) {
        for(j=0; j<p_num; j++) {
            if(i % prime[j] == 0) break;
            if(j == p_num-1) {
                prime.push_back(i);
                p_num++;
                if(i % 5 == 1) {
                    a.push_back(i);
                    n--;
                }
            }
        }
    }
    
    for(int v : a) cout << v << " ";
    cout << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (a, b) = (line[0], line[1]);
    let mut s = read_as_string().chars().collect::<Vec<char>>();
    if s[a] != '-'{
        println!("No");
        return;
    }
    s.remove(a);

    if s.into_iter().all(|c| c.is_numeric()){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endN "\n"

bool solve(){
  ll n,k;cin>>n>>k;
  ll ans=k;
  rep(i,n-1)ans*=k-1;
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


Measured memory_bytes: 256
int main(int argc, const char * argv[]) {
  int a[1000],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n",a[i]);
  insertion(a,n);
}

void insertion(int *a,int n){
  int i,j,k,v;
  for(i=1;i<n;i++){
    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
        
    for(k=0;k<n-1;k++)
      printf("%d ",a[k]);
    printf("%d\n",a[k]);
  }
}


Measured memory_bytes: 2084
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	vector<int> abc(3);
	for(int i=0; i<3; i++)
		cin >> abc[i];

	sort(abc.begin(), abc.end());

	int ret;
	if(abc[0] == abc[1])
		ret = abc[2];
	else
		ret = abc[0];

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1000000007;
const int N = 1010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

ll dp[1001][1001];

int main() {
    fact[0] = invf[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
    }

    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    dp[a-1][n] = 1;
    FOR(x,a,b) REP(j,n+1){
        dp[x][j] = (dp[x][j] + dp[x-1][j]) % mod;
        ll tmp = dp[x-1][j];
        REP(y,c) tmp = (tmp * nCr(j-y*x, x)) % mod;
        for (int y = c; y <= d && x * y <= j; y++){
            dp[x][j-x*y] = (dp[x][j-x*y] + tmp * invf[y]) % mod;
            tmp = (tmp * nCr(j-y*x, x)) % mod;
        }
    }

    // FOR(x,a,b){
    //     REP(j,n+1) cout << dp[x][j] << " ";
    //     cout << endl;
    // }

    cout << dp[b][0] << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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 MAX = 5000;
const int mod = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

void combInit(){
    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;
    }
}

long long comb(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(){
    ll s; cin >> s;
    combInit();
    ll res = 0;
    for(ll i = 1; s - 3 * i >= 0; i++){
        res += comb(s - 2 * i - 1, s - 3 * i);
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3732
n = int(input())
s = list(input())
t = list(input())


ans = 0
for i in range(n):
    ans = 0
    if t[n - i - 1] == s[-1]:
        for j in range(n - i - 1):
            if s[n - 1 - j] == t[n - i - 1 - j]:
                continue
            else:
                ans = 1
        if ans == 0:
            print(len(s + t[n - i :]))
            break
    else:
        ans = 1
if ans == 1:
    print(len(s + t))

Measured memory_bytes: 38256