akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val T, X = ni()
    val ans = T.toDouble / X
    out.println(f"$ans%.10f")
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, d, x;
  cin >> n >> d >> x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x += (d + a - 1) / a;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main() {
  int n;
  cin >> n;
  map<string, int> count;
  int MAX = 0;
  rep(i, n) {
    string s;
    cin >> s;
    count[s]++;
    if(count[s] > MAX) {
      MAX = count[s];
    }
  }
  vector<string> ans;
  for(auto i=count.begin();i!=count.end();i++) {
    if(i->second == MAX) {
      ans.emplace_back(i->first);
    }
  }

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

  rep(i, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 26868
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

map<int, int> mp1, mp2;
int dp[2010][2010];
int S[2010], T[2010];
int N, M;
void solve() {
    rep(i, N + 1) dp[i][0] = 1;
    rep(i, M + 1) dp[0][i] = 1;
    rep(i, N) {
        rep(j, M) {
            if (S[i] == T[j]) {
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % mod; 
            } else {
                dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + mod) % mod;
            }
        }
        mp1[S[i]] = i + 1;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, N) {
        cin >> S[i];
    }

    rep(i, M) {
        cin >> T[i];
    }
    solve();
    cout << dp[N][M] << endl;

    return 0;
}


Measured memory_bytes: 31744
S = input()
flg = True
for i, v in enumerate(list(S)):
    if (i+1) % 2 == 0:
        if v == 'R':
            flg = False
            break
    else:
        if v == 'L':
            flg = False
            break
print('Yes' if flg is True else 'No')

Measured memory_bytes: 2940
N,A,B,C,D = map(int,input().split())
S = list(input())

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,min(D+1,N)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
        
        
        


Measured memory_bytes: 4984
#define deb 123321
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e7+69, INF=2e9+6969;

int h1,h2,m1,m2,k;

int main()
{
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	int x=h1*60+m1;
	int y=h2*60+m2;
	printf("%d\n", (y-k-x+1440)%1440);
	return 0; 
}


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]AOJ 0009 素数
            var primes = GetPrimeNumbers(999999).ToList();
            primes.Add(2);
            primes.Add(3);
            primes.Add(5);
            primes.Add(7);

            while (true)
            {
                string s = Console.ReadLine();

                if (s == null)
                {
                    break;
                }
                else
                {
                    int n = int.Parse(s.TrimEnd());
                    Console.WriteLine(primes.Count(x => x <= n));
                }
            }
        }

        static IEnumerable<int> GetPrimeNumbers(int n)
        {
            var lib = new Library.Factorization();

            for(int i = 11; i <= n; i++)
            {
                if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0)
                {
                    var factors = lib.GetFactors(i);

                    if (factors.Count == 1)
                    {
                        yield return i;
                    }
                }                
            }
        }
    }
}

namespace Library
{
    class Factorization
    {
        private List<long> factors;

        public List<long> GetFactors(long n)
        {
            //[summary]ある数を素因数分解する

            //別の数を素因数分解することもあるので、最初にかならず初期化
            factors = new List<long>();

            if (n < 2)
            {
                //2より小さい数を受け取った場合
                factors.Add(n);
            }
            else
            {
                Factoring(n);
            }

            return factors;
        }

        private void Factoring(long n)
        {
            //[summary]平方根以下の素数で総当りで割って行く
            //以下リンクを参考に実装
            //https://qiita.com/gushwell/items/561afde2e00bf3380c98

            //"GetFactors"以外から呼び出されることもあるので、かならず初期化
            factors = new List<long>();

            //平方根を求める
            long sqrt = (long)Math.Sqrt(n);

            //2,3,5で割る(割れなくなるまで割り続ける)
            n = DevideWith(n, 2);
            n = DevideWith(n, 3);
            n = DevideWith(n, 5);

            var primes = new List<int> { 7, 11, 13, 17, 19, 23, 29, 31 };
            long i = 0;

            //平方根以下の素数(候補)で総当りで割る
            while (n > 1)
            {
                foreach (var p in primes)
                {
                    if (p + i > sqrt)
                    {
                        //1が素因数に追加されることを防止
                        if (n > 1)
                        {
                            factors.Add(n);
                        }

                        return;
                    }
                    else
                    {
                        n = DevideWith(n, p + i);
                    }
                }

                i += 30;
            }
        }

        private long DevideWith(long n, long d)
        {
            while (n % d == 0)
            {
                factors.Add(d);
                n /= d;
            }

            return n;
        }
    }
}



Measured memory_bytes: 22992
N, K = map(int, input().split())

if K % 2 == 1:
    ans = (N // K) ** 3
else:
    a = N // K
    b = 0
    for i in range(1, N+1):
        if i % K == K // 2:
            b += 1
    ans = a ** 3 + b ** 3

print(ans)

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

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i*i + 2*i <= N; i++) {
    if ((N - i)%i == 0) {
      ans += (N - i)/i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n, ans = 0;
    cin >> n;
    for(long i = 1; i <= n; i++)
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

constexpr int M = 1000 * 1000 * 1000 + 7;

ll dp[2001][2001];

void init(int n) {
    for (int i = 1; i <= n; ++i) {
        dp[i][1] = 1;
    }
    for (int j = 2; j <= n; ++j) {
        ll sum = 1;
        for (int i = j ; i <= n; ++i) {
            dp[i][j] = sum;
            sum += dp[i][j - 1];
            sum %= M;
        }
    }
}

ll count(int balls, int positions) {
    return dp[balls][positions];
}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    if (n == k) {
        cout << 1 << endl;
        for (int i = 2; i <= k; ++i) {
            cout << 0 << endl;
        }
        return 0;
    }
    init(n);
    for (int i = 1; i <= k; ++i) {
        if (i > n - k + 1) {
            cout << 0 << endl;
            continue;
        }
        ll first = count(k, i);
        ll second = 2 * count(n - k, i) % M;
        second += count(n - k, i + 1);
        second += count(n - k, i - 1);
        second %= M;
        cout << first * second % M << endl;
    }
    return 0;
}


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

int main() {
  long long x, a;
  cin >> x;
  a = (x/11)*2;
  if (x%11==0) a += 0;
  else if (x%11<=6) a += 1;
  else a += 2;
  if (x <= 6) a = 1;
  else if (x <= 11) a = 2;
  cout << a << endl;
}




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

int main(){
    string n;
    cin >> n;
    int s = n.size();
    ll total = 0;
    rep(i,s){
        int d = n.at(i) - '0';
        total += d;
    }
    if(total % 9) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3720
#define ll long long int
#include <bits/stdc++.h>
using namespace std;

int main(){
  ll N,M = 1000001;
  int i,j,ct;
  ll w=0,x;

  vector<ll> c(M,0);
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x;
    c[x] = 1;
    w = gcd(w,x);
  }

  if (w>1){
    cout << "not coprime" << endl;
    return 0;
  }
  
  for(i=2;i<M;i++){
    ct = 0;
    for(j=i;j<M;j+=i)
      ct += c[j];
    if (ct>1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "pairwise coprime" << endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  
  if (s.length() % 2) {
   	cout << "No" << endl; 
  } else {
   	for (int i = 0; i * 2 < s.length(); i++)
      if (s[i] != s[i + s.length() / 2]) {
        cout << "No" << endl;
        return 0;
      }
   	cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MN 101000

int a[MN];

int main()
{
	int ans = 1e9;
	int n, k; scanf("%d%d", &n, &k);
	int s = 0;
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] <= 0) s = i; 
	}
	for(int i = 1; i <= s; i++)
	{
		int cnt = s - i + 1;
		int sum = 0 - a[i];
		if(cnt < k)
		{
			if(s + k - cnt > n) continue;
			sum += a[s + k - cnt] - a[i];
		}
		ans = std::min(ans, sum);
	}
	if(s == 0 || a[s] < 0) s++;
	for(int i = s; i <= n; i++)
	{
		int cnt = i - s + 1;
		int sum = a[i] - 0;
		if(cnt < k)
		{
			if(s - (k - cnt) <= 0) continue;
			sum += a[i] - a[s - (k - cnt)];
		}
		ans = std::min(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9+7

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

    int r,g,b;
    cin >> r >> g >> b;
    if((g*10+b)%4==0) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 892
/**
 *      AGC 25 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-11 00:54:33
**/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int digitssum(int x){
    int digitssum = 0;
    while (x > 0){
        digitssum += (x % 10);
        x /= 10;
    }
    return digitssum;
}

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

    int N; cin >> N;    
    int answer = 100000;

    for (int i = 1; i < N / 2  + 1; ++i) {
        if (digitssum(i) + digitssum(N - i) < answer){
            answer = digitssum(i) + digitssum(N - i);
        }        
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6) #for deep recursion
     
    N, Q = list(map(int, input().split()))
    edges = [list(map(int, input().split())) for _ in range(N-1)]
    operations = [list(map(int, input().split())) for _ in range(Q)]
     
    counts = [0] * N
    for op in operations:
        p, x = op
        counts[p-1] += x
        
    all_connected_vertices = {i: [] for i in range(1, 1+N)}
    for a, b in edges:
        all_connected_vertices[a].append(b)
        all_connected_vertices[b].append(a)
        
    def dfs(point, pre):
        connected_vertices = all_connected_vertices[point]
        for c in connected_vertices:
            if c == pre:
                continue
            counts[c-1] += counts[point-1]
            dfs(c, point)
        
    dfs(1, -1)
        
    print(*counts)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 357944
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
int N, M;

int main() {
  fastio;
  cin >> N >> M;
  vector<int> H(N, 0); // heights of ith hill
  rep(i, N) {
    cin >> H[i];
  }
  vector<int> indeg(N, 0);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if (H[a] > H[b]) {
      indeg[b]++;
    } else if (H[a] < H[b]) indeg[a]++;
    else {
      indeg[a]++; indeg[b]++;
    }
  }

  int res = 0;
  for (auto a : indeg) {
    if (!a) res++;
  }
  cout << res << endl;

  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 3976
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    print(c,a,b)
if __name__ == '__main__':
    do()

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

int main() {
  int N,M,x=0,y=1,i,j;
  cin >>N ;
  M=N;
 
 for(i=7;i>=0;i--){
    for(j=i;j>0;j--){
      y*=10;
    }
    x+=M/y;
    M=M%y;
    y=1;
  }

  
  if(N%x==0){
    cout <<"Yes";
  }
  else{
    cout <<"No";
  }
    
}



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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

const int MAXN = 210000;

int n, h;
vector<int> eds[MAXN];
vector<int> beds[MAXN];
int was[MAXN];

void dfs1(int v) {
    was[v] = 1;
    for (int u: eds[v]) {
        if (!was[u])
            dfs1(u);
    }
}

int main() {
    scanf("%d%d", &n, &h);
    ++h;
    for (int i = 0; i < n; ++i) {
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if (c == 0) {
            eds[a].push_back(i + 2 * h);
        }
        else {
            eds[c + h].push_back(i + 2 * h);
        }
        if (d == 0) {
            eds[i + 2 * h].push_back(b + h);
        }
        else {
            eds[i + 2 * h].push_back(d);
        }
    }
    int g = 2 * h + n;
    for (int i = 0; i < g; ++i)
        for (int u: eds[i])
            beds[u].push_back(i);
    for (int i = 0; i < h; ++i) {
        if (eds[i].size() < beds[i].size()) {
            cout << "NO\n";
            return 0;
        }
        while (eds[i].size() > beds[i].size()) {
            eds[g].push_back(i);
            beds[i].push_back(g);
        }
    }
    for (int i = h; i < 2 * h; ++i) {
        if (eds[i].size() > beds[i].size()) {
            cout << "NO\n";
            return 0;
        }
        while (eds[i].size() < beds[i].size()) {
            beds[g].push_back(i);
            eds[i].push_back(g);
        }
    }
    dfs1(g);
    for (int i = 2 * h; i < 2 * h + n; ++i) {
        if (!was[i]) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}




Measured memory_bytes: 18900
H,W = map(int,input().split())
L = [list(map(str,input().split())) for i in range(H)]
A = [chr(i) for i in range(ord("A"),ord("Z")+1)]
for y in range(H) :
    for x in range(W) :
        if L[y][x] == "snuke" :
            ans = A[x]+str(y+1)
            print(ans)
            

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c=b,d=0;
	while(c){
		d++;
		c/=10;
	}
	c=1;
	for(int i=1;i<=d;i++)c*=10;
	a*=c;a+=b;//cout<<a;
	int q=sqrt(a);
	if(q*q==a)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long int LI;

int main(){
	
	int a,b;
	cin >> a >> b;
	
	if(a==b) cout << 2*a << endl;
	else cout << 2*max(a,b)-1 << endl;
	
	return 0;
	
}


Measured memory_bytes: 256
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const [n, ...p] = input.map(x => Number(x)); // 改行が変換されてできた0が交じるが問題ないので無視
  p.sort((x, y) => y - x);
  p[0] /= 2;
  const ans = p.reduce((x, y) => x + y);
  console.log(ans);
};

main(receive);

Measured memory_bytes: 7372
import java.util.*;

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

        int x = sc.nextInt();
        int y = sc.nextInt();
        int t = x * 4;

        boolean yes = false;

        for (int i = 0; i < x; i++) {
            if(t>y) t -= 2;
            if (y == t) {
                System.out.println("Yes");
                yes = true;
            }
            if (t <= y) break;
        }

        if (!yes) System.out.println("No");
    }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    double a[1000];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        a[i] = 1.0/a[i];
    }
    double ans = 0;
    for(int i=0; i<n; i++){
        ans += a[i];
    }
    cout << fixed << setprecision(10);
    cout << 1.0/ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  long long x[n],y[m],vertical=0,horizontal=0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> y[i];
  }
  for (int i = 1; i < m; i++) {
    vertical+=((y[i]-y[i-1])*i)%N*(m-i);
    vertical%=N;
  }
  for (int i = 1; i < n; i++) {
    horizontal+=((x[i]-x[i-1])*i)%N*(n-i);
    horizontal%=N;
  }
  cout << (vertical*horizontal)%N;
}

Measured memory_bytes: 5096
package main

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

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	N := Int(s)
	if N%111 == 0 {
		fmt.Println(N)
		return
	}
	fmt.Println(N + (111 - N%111))
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  if((N%10)*1111==N) cout<<"Yes"<<endl;
  else if((N%10)*111==(N%1000)) cout<<"Yes"<<endl;
  else if((N/10)==(N/1000)*111) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  readLine
  if (readLine
        .split(" ")
        .forall(s => {
          val i = s.toInt
          (i % 2 != 0) || (i % 3 == 0 || i % 5 == 0)
        })) {
    println("APPROVED")
  } else {
    println("DENIED")
  }
}


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

int main(){
  
  int N, K, i;
  long long Sum = 0;
  cin >> N >> K;
  vector<long long> H(N);
  
  for (i = 0; i < N; i++) cin >> H.at(i); 

  sort(H.begin(), H.end());
  
  if(K >= N) {
    cout << 0 << endl;
    return 0;
  }
  
  for (i = 0; i < (N - K); i++){
    Sum += H.at(i);
  }
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    vector<vector<ll>> A(n);
    rep(i, n){
        vector<ll> tmp(n - 1);
        rep(j, n - 1){
            cin >> tmp[j];
            tmp[j] --;
        }
        reverse(tmp.begin(), tmp.end());
        A[i] = tmp;
    }

    vector<pll> can;

    // A[i][-1] = j, and A[j][-1] = i, then can match
    rep(i, n){
        ll j = A[i].back();
        if(A[j].back() == i){
            can.emplace_back(min(i, j), max(i, j));
        }
    }

    ll cnt = 0;
    while(!can.empty()){
        // 初めに試合を処理する、そのために unique を取る
        unordered_set<ll> candidate;
        sort(can.begin(), can.end());
        can.erase(unique(can.begin(), can.end()), can.end());
        for(auto& p : can){
            ll i, j; tie(i, j) = p;
            A[i].pop_back();
            A[j].pop_back();
            candidate.insert(i);
            candidate.insert(j);
        }

        // 次に行える試合を見る
        vector<pll> next;
        for(auto i : candidate){
            if(A[i].empty()){
                continue;
            }
            ll j = A[i].back();
            if(A[j].empty()){
                continue;
            }
            if(A[j].back() == i){
                next.emplace_back(min(i, j), max(i, j));
            }
        }

        swap(can, next);
        cnt ++;
    }


    rep(i, n){
        if(!A[i].empty()){
            cout << -1 << endl;
            return;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 8192
import math
A, B, H, M = map(int, input().split())
pi = math.pi
m = M/60
h = H/12 + m/12
theta = 2 * pi *(max(h,m) - min(h,m))
print(math.sqrt((A * math.sin(theta))**2 + (B - A * math.cos(theta))**2))

Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, Q; // Nは工事の回数
    cin >> N >> Q;
    vector<tuple<int, int, int>> stx(N); //時刻，時刻，座標
    REP(i, N) { cin >> get<1>(stx[i]) >> get<2>(stx[i]) >> get<0>(stx[i]); }
    sort(stx.begin(), stx.end()); //座標でソートする
    set<pair<int, int>> d;
    for(int i = 0; i < Q; ++i) {
        int x;
        cin >> x; //時刻
        d.emplace(x, i);
    }
    vector<long long> res(Q, -1);
    REP(i, N) {
        //工事ごとに探索
        auto first =
            d.lower_bound(make_pair(get<1>(stx[i]) - get<0>(stx[i]), 0));
        auto end =
            d.upper_bound(make_pair(get<2>(stx[i]) - get<0>(stx[i]) - 1, Q));
        for(auto it = first; it != end; ++it) {
            res[it->second] = get<0>(stx[i]);
        }
        d.erase(first, end);
    }
    for(int i = 0; i < Q; ++i) {
        cout << res[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    ll minus_num = 0;
    vector<ll> A(N);
    for(int i = 0; i < N;i++){
        cin >> A[i];
        if(A[i] < 0) minus_num++;
        A[i] = abs(A[i]);
    }
    res = accumulate(A.begin(),A.end(),0LL);

    if(minus_num%2 == 1){
        res -= *min_element(A.begin(), A.end())*2;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2)  return EOF; }
  return *p1++;
}

inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=3000005;

struct modi{  
  int x,y,r;  
}Stk[N]; int pnt;  
int fat[N],rnk[N],size[N];  
  
inline int Fat(int u){  
  return u==fat[u]?u:Fat(fat[u]);  
}

int cot[N];
int flag=0;

inline int Merge(int x,int y){  
  x=Fat(x); y=Fat(y); if (x==y) return 0;  
  if (rnk[x]>rnk[y]) swap(x,y);  
  Stk[++pnt].x=x; Stk[pnt].y=y; Stk[pnt].r=0;  
  if (rnk[x]==rnk[y]) rnk[y]++,Stk[pnt].r=1;  
  fat[x]=y; cot[size[y]]--; cot[size[x]]--; size[y]+=size[x]; cot[size[y]]++;
  if (size[y]>3) flag=1;
  return 1;  
}

inline void Back(int t){  
  for (;pnt>t;pnt--){
    int x=Stk[pnt].x,y=Stk[pnt].y;
    fat[Stk[pnt].x]=Stk[pnt].x;  
    if (Stk[pnt].r) rnk[Stk[pnt].y]--;
    cot[size[y]]--; size[y]-=size[x]; 
    cot[size[y]]++; cot[size[x]]++; 
  }  
}

const ll P=1e9+9;

ll fac[N],inv[N],iinv[N];

int tot;
int us[20],vs[20],ws[20];
int n,m;

inline ll Pow(ll a,int b){
  ll ret=1;
  for (;b;b>>=1,a=a*a%P)
    if (b&1)
      ret=ret*a%P;
  return ret;
}

inline void Pre(int n){  
  fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
  inv[0]=1; for (int i=1;i<=n/3;i++) (inv[i]=inv[i-1]*6)%=P;
  for (int i=1;i<=n/3;i++) inv[i]=Pow(inv[i],P-2);
  iinv[1]=1; for (int i=2;i<=n;i++) iinv[i]=(P-P/i)*iinv[P%i]%P;  
  iinv[0]=1; for (int i=1;i<=n;i++) iinv[i]=iinv[i]*iinv[i-1]%P;  
}

inline ll Calc(int a,int b,int c){
  if (b>a) return 0;
  return fac[a]*inv[(a-b)/3]%P*iinv[(a-b)/3]%P;
}

int main(){
  read(n); read(m); n*=3;
  Pre(n);
  tot=0;
  for (int i=1;i<=n;i++) fat[i]=i,size[i]=1;
  flag=0; cot[1]=n;
  for (int i=1;i<=m;i++){
    ++tot;
    read(us[tot]),read(vs[tot]),read(ws[tot]);
    if (ws[tot]==0)
      Merge(us[tot],vs[tot]),tot--;      
  }
  if (flag){
    printf("0\n");
    return 0;
  }
  ll Ans=Calc(cot[1],cot[2],cot[3]);
  int tmp=pnt;
  for (int i=1;i<(1<<tot);i++){
    flag=0; int c=0;
    for (int j=1;j<=tot;j++)
      if (i>>(j-1)&1)
	Merge(us[j],vs[j]),c++;   
    if (!flag){
      if (c&1)
	(Ans+=P-Calc(cot[1],cot[2],cot[3]))%=P;
      else
	(Ans+=Calc(cot[1],cot[2],cot[3]))%=P;
    }
    Back(tmp);
  }
  printf("%lld\n",Ans);
  return 0;
}

Measured memory_bytes: 80620
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var h = o.l();
  var dp = [0];
  dp[1] = Math.abs(h[1] - h[0]);
  for(var i = 2; i < n; i++){
    var t1 = dp[i-2] + Math.abs(h[i] - h[i-2]);
    var t2 = dp[i-1] + Math.abs(h[i] - h[i-1]);
    dp[i] = t1 > t2 ? t2 : t1;
  }
  return dp[n-1];
}

Measured memory_bytes: 27584
#include<iostream>
using namespace std;
unsigned long long n,x1=2,x2=1,x;
unsigned long long fbnq(int,int);
int main()
{
	long long shu;
	cin>>shu;
	shu++;
	if(shu>=3)
	{
		cout<<fbnq(shu,3)<<"\n";
	    x1=1;
		x2=1;
	}
	else
	{
		cout<<3-shu<<"\n";
	} 

}
unsigned long long fbnq(int k,int gs)
{
	if(gs==k)return x1+x2; 
	unsigned long long m=x1+x2;
	x1=x2;
	x2=m;
	return fbnq(k,gs+1);
}

Measured memory_bytes: 256
#include<stdio.h>
int min(int a,int b){
	if(a<b)return a;
	else return b;
}
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		int ans=1;
		for(int i=1;i<=min(a,b);i++){
			if(a%i==0&&b%i==0)ans=i;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=(int)1e9+7,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

int n,a[N],b[N],cnt,tot;

int main() {
	qr(n);
	for(int i=1;i<=n;i++) qr(a[i]);
	for(int i=1;i<=n;i++) qr(b[n-i+1]);
//	for(int l=1,r=1,L=1,R;l<=n;l=++r) {
//		r=l; while(a[r+1]==a[l]) r++;
//		if(a[l]==b[L]) {
//			R=L;
//			while(b[R+1]==b[R]) R++;
//			if(R-L+1+r-l+1>n) puts("No"),exit(0);
//			L=R+1;
//		}
//	}
//	reverse(b+1,b+n+1);
	int l=1,r=n,st=0,ed=-1;
	for(int i=1;i<=n;i++)
		if(a[i]==b[i]) {
			if(!st) st=i;
			ed=i;
		}
	for(int j=st;j<=ed;j++) {
		if(a[l]^b[j]&&b[l]^b[j]) swap(b[j],b[l++]);
		else if(a[r]^b[j]&&b[r]^b[j]) swap(b[j],b[r--]);
		else puts("No"),exit(0);
	}
	puts("Yes");
	for(int i=1;i<=n;i++) pr1(b[i]);
	return 0;
}


Measured memory_bytes: 5188
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
namespace loquat {
class disjoint_set {
public:
	using value_type = size_t;
private:
	std::vector<value_type> m_parents;
	std::vector<value_type> m_ranks;
public:
	explicit disjoint_set(size_t n)
		: m_parents(n)
		, m_ranks(n)
	{
		for(size_t i = 0; i < n; ++i){
			m_parents[i] = i;
		}
	}
	value_type find(size_t x){
		if(m_parents[x] == x){ return x; }
		m_parents[x] = find(m_parents[x]);
		return m_parents[x];
	}
	value_type unite(size_t x, size_t y){
		x = find(x);
		y = find(y);
		if(x == y){ return x; }
		if(m_ranks[x] < m_ranks[y]){
			m_parents[x] = y;
			return y;
		}else if(m_ranks[x] > m_ranks[y]){
			m_parents[y] = x;
			return x;
		}else{
			m_parents[y] = x;
			++m_ranks[x];
			return x;
		}
	}
};
}
using namespace std;
using ll = long long;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	loquat::disjoint_set ds(n);
	for(int i = 0; i < m; ++i){
		int u, v;
		cin >> u >> v;
		ds.unite(u, v);
	}
	vector<vector<ll>> weights(n);
	for(int i = 0; i < n; ++i){
		weights[ds.find(i)].push_back(a[i]);
	}
	int num_trees = 0;
	for(int i = 0; i < n; ++i){
		if(!weights[i].empty()){ ++num_trees; }
		sort(weights[i].begin(), weights[i].end());
	}
	if(num_trees == 1){
		cout << 0 << endl;
		return 0;
	}
	vector<ll> remains;
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		if(weights[i].empty()){ continue; }
		answer += weights[i][0];
		for(int j = 1; j < weights[i].size(); ++j){
			remains.push_back(weights[i][j]);
		}
	}
	if(remains.size() < num_trees - 2){
		cout << "Impossible" << endl;
		return 0;
	}
	sort(remains.begin(), remains.end());
	for(int i = 0; i < num_trees - 2; ++i){
		answer += remains[i];
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 8064
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	x := nextInts(m)
	sort.Sort(sort.IntSlice(x))
	blanks := make([]int, m-1)
	for i := range blanks {
		blanks[i] = x[i+1] - x[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(blanks)))
	ans := 0
	for i := n - 1; i < m-1; i++ {
		ans += blanks[i]
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

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

func min(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func max(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 2944
import java.util.*;
public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveC();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
	String s;
	if (A>=9 || B>=9){
	    s = ":(";
	}
	else{
	    s = "Yay!";
	}
    	System.out.println(s);
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int D = sc.nextInt();
    	int N = sc.nextInt();
	int p = 1;
	
	for (int i=0;i < D;i++){
	    p *=100;
	}	
	
	System.out.println(p*N);
    }
    private void solveC() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	long[] a = new long[n];
	
	for(int i=0; i < n; i++){
	    a[i] = sc.nextLong();
	}

	int cnt = 0;

	for(int i=0; i < n; i++){
	    if(a[i]%2 == 0){		
		while(a[i]%2 ==0){
		    a[i]/=2;
		    cnt++;
		}
	    }
	}

	System.out.println(cnt);
    }
}

Measured memory_bytes: 34848
r,D,zero=list(map(int,input().split()))
one=r*zero-D
two=r*one-D
three=r*two-D
four=r*three-D
five=r*four-D
six=r*five-D
seven=r*six-D
eight=r*seven-D
nine=r*eight-D
ten=r*nine-D
print(one)
print(two)
print(three)
print(four)
print(five)
print(six)
print(seven)
print(eight)
print(nine)
print(ten)


Measured memory_bytes: 3064
#include<stdio.h>

#define NUM 100000

int main(){
  int i,j,n,p=0,r,x,y;
  int A[NUM];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  r=n;
  x=A[r-1];
  i=p-1;
 

  for(j=0;j<r-1;j++){
    if(A[j]<=x){
      i=i+1;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[r-1];
  A[r-1]=y;
  
    
  
  
  for(j=0;j<=i;j++){
    printf("%d",A[j]);
    if(j!=i+1){
      printf(" ");
    }
  }
  printf("[%d]",A[j]);
  printf(" ");
  for(i=j+1;i<n;i++){
    printf("%d",A[i]);
    if(i+1!=n){
      printf(" ");
    }
  }
  

  printf("\n");




  return 0;
}



Measured memory_bytes: 2128
n=io.read("*n")
a={}
counter=0
for i=1,n do
    a[i]=io.read("*n")
    if a[i]~=2 then
        counter=counter+1
    end
end
if counter==n then
    print(-1)
    return
end

i=1
a_pushed={}
while i~=2 do
    if not a_pushed[i] then
        a_pushed[i]=1
    else
        print(-1)
        return
    end
    j=a[i]
    i=j
end

moves=0
for k,v in pairs(a_pushed) do
    moves=moves+v
end
print(moves)

Measured memory_bytes: 6508
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<ll, pair<int, int> > P;
ll llabs(ll x){
  return x > 0 ? x : -x;
}

int main(){
  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  bool ok = false;
  FOR(k,0,N){
    if(A+k*C-(N-1-k)*D<=B && B<=A+k*D-(N-k-1)*C){
      ok = true;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }

    ll g = A[0];
    REP(i, N) {
        g = gcd(g, A[i]);
    }

    REP(i, N) {
        if (K > A[i])
            continue;

        if ((A[i] - K) % g == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  for (int i=0;i<S.size();i++){
    if (S[i]=='B' and i>0){
      S.erase(S.begin()+i-1,S.begin()+i+1);
      i-=2;
    }
    else if(S[i]=='B' and i==0){
      S.erase(S.begin());
      i--;
    }
  }
  cout << S;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int n, l;
  cin >> n >> l;
  vecstr s(n);
  REP(i,n)cin >>s[i];
  sort(all(s));
  REP(i,n) cout << s[i] ;
  cout <<endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,v,p;
ll m;
const int Maxn=1e5+5;
ll a[Maxn];
bool check(ll x,int mid){
	for(int i=1;i<=p;i++){
		if(a[i]==x){
			return true;
		}
	}
	if(x+m<a[p])return false;
	if(v-1<=p-1)return true;
	ll sum=0;
	for(int i=p;i<=n;i++){
		if(i==mid)continue;
		sum+=min(m,x+m-a[i]);
	}
	return sum>=m*ll(v-p);
}
int main(){
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
//	for(int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<endl;
	int l=1,r=n+1;
	while(r-l>1){
		int mid=(l+r)/2;
//		cout<<l<<' '<<r<<' '<<mid<<endl;
		if(check(a[mid],mid))l=mid;
		else r=mid;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1152
import sys

N, M = map(int, sys.stdin.readline().split())

A = list(map(int, sys.stdin.readline().split()))
action_list = []
B = []
for i in range(M):
    temp_B, temp_C = map(int, sys.stdin.readline().split())
    action_list.append([temp_B, temp_C])
    B.append(temp_B)
action_list.sort(key = lambda x:x[1])
action_list.reverse()

current_list = A
current_list.sort()

k = 0
ans_sum = 0
count = 0
action_count = 0
if sum(B) < N:
    times = sum(B)
else:
    times = N
for i in range(times):
    if current_list[i] < action_list[k][1]:
        ans_sum += action_list[k][1]
        count += 1
        action_count += 1
        if action_count == action_list[k][0]:
            k += 1
            action_count = 0
    else:
        break
    if count > N:
        break

ans_sum += sum(current_list[count:])
print(ans_sum)

Measured memory_bytes: 26464