akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

import scala.collection.immutable.NumericRange

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val a,b,x = s.nextLong
    def f(n: Long): Long = if (n < 0L) 0L else n / x + 1L
    (f(b) - f(a - 1L)).toString
  }

  val tests = List(
    "4 8 2" -> "3",
    "0 5 1" -> "6",
    "9 9 2" -> "0",
    "1 1000000000000000000 3" -> "333333333333333333"
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25536
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N,K;cin >> N >> K;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >>retu.at(i);
    sort(retu.begin(),retu.end());
    int ans = 0;
    for(int i = 0;i<K;i++){
        ans += retu.at(i);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
    char ch[200001];
  	int n, aux = 0, aux2 = 0;
  	cin >> n;
	for (int i = 0; i < n; i++)
        cin >>ch[i];
	for (int i = 0; i < n; i++)
		if(ch[i] == 'W')
            aux++;
	for (int i = n-aux; i < n; i++)
		if(ch[i] != 'W')
            aux2++;
	cout << aux2 <<endl;
	return 0;
}

Measured memory_bytes: 3828
/* Coached by rainboy */
#include <stdio.h>

#define A 55555

int main() {
	static char composite[A + 1];
	static int aa[A];
	int a, b, k, n, i;

	k = 0;
	for (a = 2; a <= A; a++) {
		if (composite[a])
			continue;
		if (a % 10 == 1)
			aa[k++] = a;
		for (b = a + a; b <= A; b += a)
			composite[b] = 1;
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		printf("%d ", aa[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int num = sc.nextInt() + sc. nextInt();
			int d = 1;
			while(num >= tene(d)){
				d++;
			}
			
			System.out.println(d);
		}
	}

	private static int tene(int digit){
		int t = 1;
		
		for(int i = 0; i < digit; i++){
			t=t*10;
		}
		
		return t;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
 ll N;
 cin >> N;
 vector<string> S(N);

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

 int ACc = 0;
 int WAc = 0;
 int TLEc = 0;
 int REc = 0;

 for(int i = 0; i < N; i++){
   if(S[i] == "AC"){
     ACc++;
   }
   else if(S[i] == "WA"){
     WAc++;
   }
   else if(S[i] == "TLE"){
     TLEc++;
   }
   else if(S[i] == "RE"){
     REc++;
   }
 }

 cout << "AC x " << ACc << endl;
 cout << "WA x " << WAc << endl;
 cout << "TLE x " << TLEc << endl;
 cout << "RE x " << REc << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<vector<int>> A;
vector<int> B;
//=============================
void input()
{
    cin >> N >> M;
    A.resize(N);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        A[a].push_back(b);
        A[b].push_back(a);
    }
}
//=============================
void dfs(int now, int visited, int &ans)
{
    // if (visited>>now & 1){
    //     return;
    // }
    visited += (1 << now);
    debug(visited);
    if (visited == (1 << N) - 1)
    {
        ans++;
        return;
    }
    for (auto x : A[now])
    {
        if (visited >> x & 1)
            continue;
        dfs(x, visited, ans);
    }
}
//=============================
void solve()
{
    int ans = 0;
    dfs(0, 0, ans);
    cout << ans << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int pow = (int) Math.pow(2, ((int) (Math.log(n) / Math.log(2))) + 1);

        int[] ha = new int[n];
        long[] ba = new long[n];
        for (int i = 0; i < n; i++) {
            ha[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            ba[i] = in.nextInt();
        }

        long[] tree = new long[2 * pow];

        long ans = ba[0];
        for (int i = 0; i < n; i++) {
            long v = max(1, 1, pow, 1, ha[i], tree);
            ans = Math.max(v + ba[i], ans);
            update(1, 1, pow, ha[i], v + ba[i], tree);
        }

        out.println(ans);
        out.close();
    }

    static void update(int v, int tl, int tr, int pos, long val, long[] tree) {
        if (tl == tr) {
            tree[v] = val;
        } else {
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                update(v * 2, tl, tm, pos, val, tree);
            else
                update(v * 2 + 1, tm + 1, tr, pos, val, tree);
            tree[v] = Math.max(tree[v * 2], tree[v * 2 + 1]);
        }
    }

    static long max(int v, int tl, int tr, int l, int r, long[] tree) {
        if (l > r)
            return 0;
        if (l == tl && r == tr) {
            return tree[v];
        }
        int tm = (tl + tr) / 2;
        return Math.max(max(v * 2, tl, tm, l, Math.min(r, tm), tree), max(v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1), r, tree));
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

Measured memory_bytes: 75488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int dec1 = 0, dec2 = 0;
    rep(s.size() - 1, i) {
        if (s[i] == 'R' && s[i + 1] == 'L') dec2 += 2;
    }
    if (s[0] == 'L') dec1++;
    if (s[s.size() - 1] == 'R') dec1++;
    if (dec1 == 2) {
        dec2 += 2;
        dec1 = 0;
    }
    int times = min(k, dec2);
    dec2 -= times * 2;
    times = min(k - times, dec1);
    dec1 -= times;
    cout << min(n - 1, n - (dec1 + dec2)) << endl;
    return 0;
}

Measured memory_bytes: 512
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var b05 = Math.Min(a[0] * 2, a[1]);
        var b10 = Math.Min(b05 * 2, a[2]);
        var b20 = Math.Min(b10 * 2, a[3]);
        var n = int.Parse(Console.ReadLine().Trim());
        long res;
        if (n % 2 == 0) res = b20 * n / 2;
        else res = b20 * (n - 1) / 2 + b10;
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0
a_max = max(A + [0])
a_min = min(A + [0])
cnt = 0
S = []
if a_max + a_min >= 0:
  k = A.index(a_max)
  while A[0] < a_max:
    A[0] += a_max
    cnt += 1
    S += [[k + 1, 1]]
  for i in range(N - 1):
    while A[i + 1] < A[i]:
      A[i + 1] += A[i]
      cnt += 1
      S += [[i + 1, i + 2]]
else:
  k = A.index(a_min)
  while A[-1] > a_min:
    A[-1] += a_min
    cnt += 1
    S += [[k + 1, N]]
  for i in range(N - 1, 0, -1):
    while A[i - 1] > A[i]:
      A[i - 1] += A[i]
      cnt += 1
      S += [[i + 1, i]]
print(cnt)
for s in S:
  print(s[0], s[1])

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

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


Measured memory_bytes: 3112
import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();
    HashSet<String> strings = new HashSet<>();
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      strings.add(s);
    }
    out.println(strings.size());
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

int main(){
    string s1, s2;
    int cnt = 0;
    cin >> s1;
    s2 = "CODEFESTIVAL2016";
    for(int i=0;i<s1.size();i++){
        if (s1.at(i) != s2.at(i)){
            cnt += 1;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 22996
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
rsort($a);
$ans=0;
$i=0;
while($i<$n){
  if($i%2==0){
    $ans+=$a[$i];
  }else{
    $ans-=$a[$i];
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int N;
  long A[100005],B[100005],C[100005];
  long count;
  long sum = 0;
  A[0] = 0;
  cin >> N;

  for(int i=0;i<N;++i){
    cin >> A[i+1];
  }

  for(int i=0;i<N+1;++i){
    if(i!=N){
      B[i] = abs(A[i+1] - A[i]);
    }else{
      B[i] = abs(A[0] - A[N]);
    }
    sum =  sum + B[i];
  }

  for(int i=0;i<N;++i){
    if(i!=N-1){
      C[i] = abs(A[i+2]-A[i]);
    }else{
      C[i] = abs(A[0]-A[i]);
    }
  }

  for(int i=0;i<N;++i){
    count = sum - B[i] - B[i+1] + C[i];
    cout << count << endl;
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/

using namespace std;

ll freqs[30],freqt[30];

string s,t;

vector<ll>v[30];

int main()
{
    cin >> s >> t;
    for (ll i=0;i<s.length();i++)
    {
        freqs[s[i]-'a']++;
        v[s[i]-'a'].pb(i);
    }
    for (ll i=0;i<t.length();i++)
    {
        freqt[t[i]-'a']++;
    }
    for (ll i=0;i<26;i++)
    {
        if (freqt[i])
        {
            if (freqs[i]==0){cout << -1 << endl; return 0;}
            continue;
        }
    }
    ll pos=v[t[0]-'a'][0],ans=pos+1;
    for (int i=1;i<t.length();i++)
    {
        auto it=upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),pos);
        if (it==v[t[i]-'a'].end())
        {
            ans+=(s.length()-pos-1);
            pos=v[t[i]-'a'][0];
            ans+=pos+1;
        }
        else
        {
            ans+=*it-pos;
            pos=*it;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
    int N,c=0;
    cin >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
        if(p[i]!=i+1){
            c++;
        }
    }
    if(2<c){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int score;
    int sum;
    int max, min;
    cin >> n;
    while(n){
        sum = 0;
        max = 0;
        min = 1000;
        for(int i=0;i<n;++i){
            cin >> score;
            sum += score;
            if(score > max){
                max = score;
            }
            if(score < min){
                min = score;
            }
        }
        sum = sum - max - min;
        cout << sum/(n-2) << endl;
        cin >> n;
    }
}

Measured memory_bytes: 1160
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let V: usize = sc.get();
    let E: usize = sc.get();
    let mut dist = vec![vec![-1; V]; V];
    for _ in 0..E {
        let s: usize = sc.get();
        let t: usize = sc.get();
        let d: i64 = sc.get();
        dist[s][t] = d;
    }
    let mut dp = vec![vec![INF; V]; 1<<V];
    dp[0][0] = 0;
    for S in 1..1<<V {
        for v in 0..V {
            if ((S>>v) & 1) == 0 {
                continue;
            }
            for u in 0..V {
                if dist[u][v] == -1 {
                    continue;
                }
                dp[S][v] = min(dp[S][v], dp[S & !(1<<v)][u] + dist[u][v]);
            }
        }
    }
    let ans = dp[(1<<V)-1][0];
    println!("{}", if ans != INF { ans } else { -1 });
}



Measured memory_bytes: 9024
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000003LL)
typedef long long Int;

int cnt[256], pos[256];
int buf[60000];
void _bsort(vector<int>::iterator begin, vector<int>::iterator end, int d) {
    memset(cnt, 0, sizeof(cnt));
    for(vector<int>::iterator it=begin; it!=end; it++) cnt[(*it>>d)&255]++;
    pos[0] = 0;
    rep(i, 255) pos[i+1] = pos[i]+cnt[i];
    for(vector<int>::iterator it=begin; it!=end; it++) {
        buf[pos[(*it>>d)&255]++] = *it;
    }
    int ix = 0;
    for(vector<int>::iterator it=begin; it!=end; it++) *it = buf[ix++];
}
void radix_sort(vector<int>::iterator begin, vector<int>::iterator end) {
    rep(i, 2) _bsort(begin, end, i*8);
}

int n, mi, memo[60000*4], cs[60000][2];
vector<int> g[60000];
bool has[60000];

void add(int p, int q) {
    if (p > q) swap(p, q);
    g[p].push_back(q);
}

int pre(int p, int q) {
    if (p+1 == q) return -1;
    const int k = mi++;
    has[k] = false;
    if (g[p].back() == q) {
        has[k] = true;
        g[p].pop_back();
    }
    const int r = g[p].back();
    rep (b, 4) memo[k*4|b] = -1;
    cs[k][0] = pre(p, r);
    cs[k][1] = pre(r, q);
    return k;
}

int rec(int k, int x, int y) {
    if (k == -1) return x == y;
    const int sig = k*4|x*2|y;
    if (memo[sig] != -1) return memo[sig];
    const int p = cs[k][0], q = cs[k][1];
    Int ans = 0;
    rep (i, 2) ans = (ans + (Int)rec(p, x, i)*rec(q, 1-i, y)) % MOD;
    if (x && y && has[k]) {
        rep (i, 2) ans = (ans + (Int)rec(p, 0, i)*rec(q, 1-i, 0)) % MOD;
    }
    return memo[sig] = ans;
}

int main() {
    for (;;) {
        int m, a, b;
        scanf("%d%d", &n, &m);
        if (n == 0) return 0;
        rep (i, n) g[i].clear();
        rep (_, m) {
            scanf("%d%d", &a, &b);
            add(a-1, b-1);
        }
        rep (i, n) add(i, (i+1)%n);
        rep (i, n) radix_sort(g[i].begin(), g[i].end());
        mi = 0;
        pre(0, n-1);
        printf("%d\n", (int)rec(0, 1, 1));
    }
}

Measured memory_bytes: 10360
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,N_;
  cin>>N;
  if(N==0){
    cout<<0<<endl;
    return 0;
  }
  N_=N;
  ll num=1;
  while(N_!=0){
    N_/=4;
    num++;
  }
  N_=N;
  FORi(num){
    N_+=2*pow(4,i);
  }
  bitset<64> bit(N_);
  string S;
  FORi(num){
    ll tm =bit[i*2]+bit[i*2+1]*2;
    if(tm==0){
      S+="01";
    }else if(tm==1){
      S+="11";
    }else if(tm==2){
      S+="00";
    }else{
      S+="10";
    }
  }
  reverse(S.begin(),S.end());
  if(S[0]=='0')S.erase(0,1);
  if(S[0]=='0')S.erase(0,1);
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.*;
 
public class Main {
    public static void main(String args[]){
        int n;
        int sides[] = new int[3];
        boolean judge = false;
        String line;
        String tmp[];
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            line = reader.readLine();
            n = Integer.parseInt(line);
            for(int i = 0; i < n; i++){
                line = reader.readLine();
                tmp = line.split(" ");
                for(int j = 0; j < sides.length; j++){
                    sides[j] = Integer.parseInt(tmp[j]);
                    sides[j] *= sides[j];
                }
                for(int j = 0; j < sides.length; j++){
                    if(sides[j%3] == sides[(j+1)%3] + sides[(j+2)%3]) {
                        judge = true;
                        break;
                    }else
                        judge = false;
                }
                Answer(judge);
            }
        }catch(IOException e){
            System.exit(0);
        }
    }
 
    static void Answer(boolean j){
        if(j) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 25948
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int L, l;
    cin >> L;

    l = L * 1000000;

    double hen = l / 3;

    double Hen = hen / 1000000;

    double x = Hen * Hen * Hen;

    cout << fixed << setprecision(6) << x << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
using namespace std;
typedef long long ll;

int modulo = 1000000007; // 10^9 + 7


// 階乗
ll factorial(int N) {
	ll ans = 1;
	for (int i = 1; i <= N; i++) {
		ans *= i;
		ans = ans % modulo;
	}
	return ans;
}

int main() {
	int N, M; cin >> N >> M;

	if (abs(N - M) > 1) cout << 0 << endl;
	else {
		ll combi;
		combi = (factorial(N) * factorial(M)) % modulo;
		if (N != M) cout << combi << endl;
		else cout << (combi * 2) % modulo;
	}

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC = sorted(BC, key = lambda x : x[1], reverse=True)

n = 0
for b, c in BC:
    n += b
    A += [c] * b

    if n >= N:
        break

A = sorted(A, reverse=True)
print(sum(A[:N]))

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

ll N, M, Q, ans = 0, sum = 0;
vector<ll> Z(11), A(55), B(55), C(55), D(55);
void dfs(ll d, ll p) {
    for (int i = p; i <= M; i++)
    {
        Z[d] = i;
        if(d < N - 1) dfs(d + 1, i);
        if(d == N-1) {
            sum = 0;
            rep(j, Q) if(Z[B[j]-1] - Z[A[j]-1] == C[j]) sum += D[j];
            ans = max(ans, sum);
        }
    }
}

int main() {
    cin >> N >> M >> Q;
    rep(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    double ans = 0;
    if(x > a*a*b / 2){
        //ans = 2.0 * (b/a - x/a/a/a);
        ans = 2*b/a - 2*x/a/a/a;
        ans = atan(ans);
        ans *= 180.000/M_PI;
    }
    else{
        //ans = atan(a*b*b / (2*x)) + M_PI/2;
        ans = atan(a*b*b / (2*x));
        //cout << a*b*b / (2*x) << endl;
        //ans = atan2(a*b*b, 2*x);
        ans *= 180.0/M_PI;
    }

    printf("%.20lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
primes = Array.new(50000, true)
primes[0, 2] = [false, false]
2.upto(50000 - 1){|x|
    if primes[x]
        m = 2
        while x * m <= 999_999
            primes[x * m] = false
            m += 1
        end
    end
}

while true
    n = gets.to_i
    break if n == 0
    sum = 0
    2.upto(n/2){|x| sum += 1 if primes[x] && primes[n - x]}
    puts sum
end


Measured memory_bytes: 15812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  string s; cin>>s;
  int mode = 0;
  bool ok=(s.size()>=5);
  for(char c:s){
    if(!ok){break;}
    switch(mode){
      case 0:
        if(c=='A'){ mode=1;}
        else if(c=='K'){ mode=2;}
        else{ ok=false;}
        break;
      case 1:
        if(c=='K'){mode=2;}
        else{ ok=false;}
        break;
      case 2:
        if(c=='I'){mode=3;}
        else{ok=false;}
        break;
      case 3:
        if(c=='H'){mode=4;}
        else{ok=false;}
        break;
      case 4:
        if(c=='A'){mode=5;}
        else if(c=='B'){mode=6;}
        else{ok=false;}
        break;
      case 5:
        if(c=='B'){mode=6;}
        else{ok=false;}
        break;
      case 6:
        if(c=='A'){mode=7;}
        else if(c=='R'){mode=8;}
        else{ok=false;}
        break;
      case 7:
        if(c=='R'){mode=8;}
        else{ok=false;}
        break;
      case 8:
        if(c=='A'){mode=9;}
        else{ok=false;}
        break;
      default:
        ok=false; break;
    }
  }
  cout << (ok && mode>=8?LINY:LINN);
}


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

typedef long long ll;
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int> a, b;
    for(ll i=0;i<n;i++){
        ll aa,bb;
        cin>>aa>>bb;
        a.push_back(aa);
        b.push_back(bb);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==0){
        ll bmid=b[n/2-1]+b[n/2],amid=a[n/2-1]+a[n/2];
        cout<<bmid-amid+1<<endl;
    }
    else{
        cout<<b[(n+1)/2-1]-a[(n+1)/2-1]+1<<endl;
    }
}

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

    solve();

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vl v(n);
	REP(i, n)cin >> v[i];
	ll ans = INF * INF;
	REP(i, n - k + 1) {
		ll tmp = 0;
		if (abs(v[i]) < abs(v[i + k - 1])) {
			tmp = abs(v[i]) + v[i + k - 1] - v[i];
		}
		else {
			tmp = abs(v[i + k - 1]) + v[i + k - 1] - v[i];
		}
		ans = min(ans, tmp);
		

	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    unsigned long long n;
    cin >> n;
    while(n)
    {
        if(n % 10 == 9)
        {
            cout << "Yes\n";
            return 0;
        }
        n /= 10;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  int counter = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++)
  {
    if (c % i == 0)
      counter++;
  }

  cout << counter << endl;

  return 0;
}


Measured memory_bytes: 3096
n, m = map(int, input().split())

A = []
B = []

for i in range(n):
    a = list(map(int, input().split()))
    A.append(a)

for i in range(m):
    b = int(input())
    B.append(b)

for i in range(len(A)):
    print(sum([x * y for (x, y) in zip(A[i], B)]))



Measured memory_bytes: 6020
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vpii a(n);
  rep(i,n){
    int k;
    cin >> k;
    a[i] = make_pair(k,i+1);
  }
  sort(a.begin(),a.end());
  rep(i,n){
    int p = a[i].second;
    cout << p << endl;
  }
  
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1000005;

int n,last[N],f[N],a[N],cnt;
struct edge{int to,next;}e[N*2];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs1(int x,int fa)
{
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		dfs1(e[i].to,x);
		if (!f[e[i].to]&&a[e[i].to]<a[x]) f[x]=1;
	}
}

void dfs2(int x,int fa)
{
	if (fa&&a[fa]<a[x]&&!f[fa]&&!f[x]) f[x]=1;
	for (int i=last[x];i;i=e[i].next)
		if (e[i].to!=fa) dfs2(e[i].to,x);
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
	}
	dfs1(1,0);
	dfs2(1,0);
	for (int i=1;i<=n;i++) if (f[i]) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 6528
macro_rules! input {
    ($t:ty) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty ;) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ; $n:expr) => {
        (0..$n).map(|_|
            input!($t)
        ).collect::<Vec<_>>()
    };
}

fn main(){
    let n = input!(usize);
    let k = input!(usize);
    let x = input!(usize);
    let y = input!(usize);
    let ans;
    if n<=k{
        ans = x*n;
    }else{
        ans = x*k + y*(n-k);
    }
    println!("{}", ans)
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	for(ll h = 1; h <= 3500; ++h){
		for(ll n = 1; n <= 3500; ++n){
			ll a = N*h*n;
			ll b = 4*h*n - N*n - N*h;
			if(b <= 0) continue;
			if(a%b != 0) continue;
			ll w = a / b;
			cout << h << " " << n << " " << w << endl;
			return 0;
		}
	}
	return 0;
}


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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main()
{
	map<string,int> anko;
	int n; cin>>n;
	rep(i,n){
		string s; cin>>s;
		anko[s]++;
	}
	
	int max=0;
	for(auto &x:anko){
		int a=x.second;
		if(a>max) max=a;
	}
	for(auto &x:anko) if(x.second==max) cout<<x.first<<endl;
	return 0;
}

Measured memory_bytes: 25216
#include<stdio.h>
int main()
{
    int A,B,i,c,d,e,f,s=0;
    scanf("%d %d",&A,&B);
    for(i=A;i<=B;i++)
    {
        c=i%10;
        d=i/10%10;
        e=i/1000%10;
        f=i/10000%10;
        if(c==f&&d==e)
            s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  l=[0]*1001

  n=I()

  for i in range(2,n+1):
    x=getPrimeList(i)
    for j in x:
      l[j]+=1

  sm=1
  for i in l:
    sm*=i+1

  return sm%mod

print(main())


Measured memory_bytes: 6484
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	string s;
	int n,c=0;
	cin>>n;
	cin>>s;
	for0(i,n-2){
		if(s.substr(i,3)=="ABC") c++;
		}
	cout<<c<<nw;
	
	return 0;
}

Measured memory_bytes: 256
import Debug.Trace


solve :: Int -> Bool -> String
solve n False
    | n == 0 = []
    | mod n 2 == 0 = "0" ++ solve (div n 2) True
    | otherwise = "1" ++ solve (div (n-1) 2) True
solve n True
    | n == 0 = []
    | mod n 2 == 0 = "0" ++ solve (div n 2) False 
    | otherwise = "1" ++ solve (div (n+1) 2) False

main :: IO ()
main = do
    n <- read <$> getLine
    -- print n
    putStrLn $ if n == 0 then "0" else reverse (solve n False)


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

using namespace std;

int main()
{
    unsigned long long int n;
    scanf("%llu", &n);

    int name[100000], i;
    for (i = 0; n; i++)
    {
        n--;
        name[i] = n % 26;
        n /= 26;
    }
    for (int j = i - 1; j >= 0; j--)
        printf("%c", name[j] + 'a');

    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
   int n;
   get(n);
   int n1=n;
   int a[n+1];
   repp(i,1,n+1){
    int  x;
    get(x);
    a[x]=i;
   }
   rep1(i,n+1) pr2(a[i],"");
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


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

using namespace std;

priority_queue < int > Q;


int k , t;

int main()
{
    int x , ans = 0  , y;
    bool ok;
    cin >> k >> t;
    for(int i = 1 ; i <= t ; i++)
        cin >> x , Q.push(x);
    while(k > 0)
    {
        x = Q.top();
        Q.pop();
        ok = false;
        if(Q.size() == 0)
            ok = 1;
        else
        {
            y = Q.top();
            Q.pop();
        }
        if(ok)
        {
            --k;
            ans++;
            if(x - 1 > 0)
                Q.push(x - 1);
        }
        else
        {
            k -= 2;
            if(x - 1 > 0)
                Q.push(x - 1);
            if(y - 1 > 0)
                Q.push(y - 1);
        }
    }
    cout << max(0 , ans - 1)  << "\n";
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    int a = -1;
    int b;

    int A, B;
    for (int i = 0; i < N; i++)
    {
        gc(A);
        gc(B);

        a = max(a, A);
        if (a == A) b = B;
    }

    printf("%d\n", a + b);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(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;}
 
int main(){
    int a, b; cin>>a>>b;
    int ans = a-b*2;
    if(ans<0) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

const int MAX_PRIME = 1000010;
bool isPrime[MAX_PRIME];

void calcPrimes() {
	for (int i = 2; i < MAX_PRIME; i++) isPrime[i] = true;
	for (int i = 2; i < MAX_PRIME; i++) {
		if (!isPrime[i]) continue;
		for (int j = i * i; j < MAX_PRIME; j += i) isPrime[j] = false;
	}
}

signed main() {
	calcPrimes();

	int N;
	cin >> N;

	vector<int> primes;
	REP(i, 2, 100) if (isPrime[i]) primes.push_back(i);

	vector<int> cnt(primes.size());

	REP(i, 1, N) {
		int num = i;
		rep(j, primes.size()) {
			int tmp = 0;
			while (num % primes[j] == 0) {
				tmp++;
				num /= primes[j];
			}
			cnt[j] += tmp;
		}
	}

	rep(i, primes.size()) {
		cerr << primes[i] << ":" << cnt[i] << endl;
	}

	int ret = 0;
	rep(i, primes.size()) {
		rep(j, primes.size()) {
			rep(k, primes.size()) {
				if (i == j || j <= k || k == i) continue;
				if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ret++;
			}
		}
	}

	rep(i, primes.size()) {
		rep(j, primes.size()) {
			if (i == j) continue;
			if (cnt[i] >= 4 && cnt[j] >= 14) ret++;
			if (cnt[i] >= 2 && cnt[j] >= 24) ret++;
		}
	}

	rep(i, primes.size()) {
		if (cnt[i] >= 74) ret++;
	}

	cout << ret << endl;
}


Measured memory_bytes: 1280
from sys import stdin

s = stdin.readline().rstrip()

li = [0]*len(s)

kisuu = 0
gusuu = 0

for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "R":
        if i % 2 == 0:
            gusuu += 1
        else:
            kisuu += 1
    elif s[i] == "R" and s[i+1] == "L":
        if i % 2 == 0:
            gusuu += 1
            li[i] = gusuu
            li[i+1] = kisuu
            gusuu = 0
            kisuu = 0
        else:
            kisuu += 1
            li[i] = kisuu
            li[i+1] = gusuu
            gusuu = 0
            kisuu = 0

s = s[::-1]
li = li[::-1]

for i in range(len(s)-1):
    if s[i] == "L" and s[i+1] == "L":
        if i % 2 == 0:
            gusuu += 1
        else:
            kisuu += 1
    elif s[i] == "L" and s[i+1] == "R":
        if i % 2 == 0:
            gusuu += 1
            li[i] += gusuu
            li[i+1] += kisuu
            gusuu = 0
            kisuu = 0
        else:
            kisuu += 1
            li[i] += kisuu
            li[i+1] += gusuu
            gusuu = 0
            kisuu = 0

print(*li[::-1])

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

#define i64 long long int

bool chk(int a, int b, int c) {
	if(a>=c || b>=c) return false;
	
	// 2sqrt(a*b) ? c - a - b
	i64 rem = c - a - b;
	if(rem<0) return false;
	
	// l && rem^2
	i64 l = 4LL*a*b;
	
	return rem*rem>l;
}

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	
	puts(chk(a, b, c) ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n, m, t, a[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
		cout << n*(n - 1) / 2 << endl;
}
/*
2

13

1
*/

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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.assign(n+1,0);
    hash2.assign(n+1,0);
    mpow1.assign(n+1,1);
    mpow2.assign(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)/2;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}


Measured memory_bytes: 384
# 最大値を見つけ、それを２で割るをチケットがなくなるまで繰り返す
# 普通にやると、最大値の選定でO(n)、それをチケット数分だけ繰り返すのでO(n*m)。
# 間に合わないので、優先度付きキューを用いる
import math
import heapq

n, m = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    tmp = heapq.heappop(a) * (-1)
    tmp = math.floor(tmp / 2) * (-1)
    heapq.heappush(a, tmp)

print(sum(list(map(lambda x: x*(-1), a))))

Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> S[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(x=1;x<=10000;x++) if(x*(x-1)/2==N) break;
	if(x>10000) return _P("No\n");
	
	int nex=1;
	FOR(i,x) {
		FOR(j,x-1-i) {
			S[i].push_back(nex);
			S[i+1+j].push_back(nex);
			nex++;
		}
	}
	
	cout<<"Yes"<<endl;
	cout<<x<<endl;
	FOR(i,x) {
		cout<<S[i].size();
		sort(ALL(S[i]));
		FORR(c,S[i]) cout<<" "<<c;
		cout<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4736