akhauriyash/Code-Regression huggingface dataset:
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

int32_t N;
int64_t A[300];
int64_t used[70];
std::string S;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int Q;
    in >> Q;
    while (Q--)
    {
        in >> N;
        fill_all(used, 0);
        for (size_t i = 0; i < N; i++)
        {
            in >> A[i];
        }
        in >> S;

        for (int i = N - 1; i >= 0; i--)
        {
            if (S[i] == '1')
            {
                auto target = A[i];
                for (int mask_j = 61; mask_j >= 0; mask_j--)
                {
                    int64_t mask = (int64_t)(1) << mask_j;
                    if ((target & mask) != 0) {
                        target ^= used[mask_j];
                    }
                }
                if (target != 0) {
                    out << "1\n";
                    goto NEXT_CASE;
                }
            }
            else
            {
                int updated_j = -1;
                for (int mask_j = 61; mask_j >= 0; mask_j--)
                {
                    int64_t mask = (int64_t)(1) << mask_j;
                    if ((A[i] & mask) != 0) {
                        if (used[mask_j] != 0) {
                            A[i] ^= used[mask_j];
                        }
                        else {
                            updated_j = mask_j;
                            used[mask_j] = A[i];
                            break;
                        }
                    }
                }
                if (updated_j != -1) {
                    for (int mask_j = 61; mask_j > updated_j; mask_j--)
                    {
                        int64_t mask = (int64_t)(1) << mask_j;
                        if ((used[mask_j] & mask) != 0) {
                            used[mask_j] ^= used[updated_j];
                        }
                    }
                }
            }
        }
        out << "0\n";

    NEXT_CASE:;
    }

    return 0;
}
#endif


Measured memory_bytes: 3128
#include<stdio.h>
#include<string.h>

bool flag1,flag2;
char str[128];

int main(void){
	scanf("%s",str);
	for(int i=0,len=strlen(str);i<len;i++){
		if(str[i]=='C')
			flag1=true;
		if(flag1&&str[i]=='F')
			flag2=true;
	}
	puts(flag2?"Yes":"No");
	return 0;
}

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

int main() {
  string S,T,U;
  int A,B;
  
  cin >> S >> T >> A >> B >> U;
  
  if (S == U) A--;
  if (T == U) B--;
  
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
// see: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    let list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    input!{ k: usize}

    println!("{}", list[k-1]);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

bool check_right_tri(int a,int b,int c){

  int max = std::max({a,b,c});

  if(max == a && a*a == b*b + c*c)
    return true;
  else if(max == b && b*b == a*a + c*c)
    return true;
  else if(max ==c && c*c == a*a + b*b)
    return true;
  else return false;
}

int main(){
  const int min = 1;
  const int max = 1000;
  const int data_max = 1000;
  int a,b,c,N;
  std::cin >> N;

  for(int i = 0; i < N; ++i){
    std::cin >> a >> b >> c;
    if(check_right_tri(a,b,c))
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1152
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [(int_of_string b)]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let (n,k) = match split (read_line ()) with
        [n;k] -> (n,k)
      | _ -> raise Not_found
  in
  let ws = Array.init n (fun _ -> read_int ()) in
  let l = Array.fold_left (fun x y->max x y) 0 ws and
       r = 100000*100000
  in
  let rec search ((i,j,s,p):int*int*int*int) =
    if i=n || j=k then i
    else
      if s+ws.(i) <= p then
        search ((i+1), j, (s+ws.(i)), p)
      else
        search (i,(j+1),0,p)
  in
  let rec loop (left:int) (right:int) =
    if left < right then
      let mid = (left+right)/2 in
      if search (0,0,0,mid) >= n then loop left mid
      else loop (mid+1) right
    else right
  in
  Printf.printf "%d\n" (loop l r)
;;

Measured memory_bytes: 5708
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"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n,m,e,a;

console.log(main());
function main(){
  n = o.a();
  m = o.a();
  e = xArray("[]",n);
  for(var i = 0; i < m; i++){
    var t = o.l(); t[0]--, t[1]--;
    e[t[0]].push(t[1]);
  }
  var s = o.a()-1;
  var g = o.a()-1;
  a = xArray(0,3,n);
  a[0][s] = 1;
  var q = [s], ans = 0;
  while(q.length){
    ans++;
    for(var i = 0; i < 3; i++){
      q = solve(q,i);
    }
    if(a[0][g])return ans;
  }
  return -1;
}

function solve(q,i){
  var r = [], j = (i+1)%3;
  while(q.length){
    var p = q.pop();
    for(var v of e[p]){
      if(a[j][v])continue;
      r.push(v);
      a[j][v] = 1;
    }
  }
  return r;
}

Measured memory_bytes: 68956
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int64_t N;
cin >> N;
set<string> sina;
for (int64_t i = 0;i < N;i++) {
  string a;
  cin >> a;
  sina.insert(a);
}
cout << sina.size() << endl;



return 0;
}

Measured memory_bytes: 19180
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut p = (0..n)
        .map(|_| (sc.read::<f64>(), sc.read::<f64>()))
        .collect::<Vec<_>>();
    p.sort_by(|&(x1, y1), &(x2, y2)| y1.atan2(x1).partial_cmp(&y2.atan2(x2)).unwrap());

    let mut ans = 0.0;
    for from in 0..n {
        let (mut cur_x, mut cur_y) = (0.0, 0.0);
        for i in 0..n {
            let (x, y) = p[(from + i) % n];
            cur_x += x;
            cur_y += y;
            let d = cur_x * cur_x + cur_y * cur_y;
            if ans < d {
                ans = d;
            }
        }
    }

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

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
a, b = map(int, input().split())

if a > 0:
    ans = 'Positive'
elif b < 0:
    tmp = b - a + 1
    if tmp % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
else:
    ans = 'Zero'

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;

int main(){
    string s;
    cin >> s;

    int l = (int)s.size();
    int min_dist = 1e9;
    for(int i=0; i<=l-3; ++i){
        string t = s.substr(i,3);
        int a = ((int)t[0]-'0')*100 + ((int)t[1]-'0')*10 + ((int)t[2]-'0');
        int dist = abs(753 - a);
        if(min_dist>dist) min_dist = dist;
    }
    cout(min_dist);
    return 0;
}

Measured memory_bytes: 256
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int a,b; cin >> a >> b;

    vector<int> x(45);

    if((b-a+1) % 4 == 0) x.at(1) = 0;
    if((b-a+1) % 4 == 1) x.at(1) = b % 2;
    if((b-a+1) % 4 == 2) x.at(1) = 1;
    if((b-a+1) % 4 == 3) x.at(1) = abs(b%2-1);

    int m = 2;

    int s,t,u,v;

    for(int i = 2;i < 45;i ++){
        m *= 2;
        s = 0; t = 0; u = 0; v = 0;
        if(a % m >= m / 2){
            s = 1;
            t = (m-1) - a % m + 1;
        }
        if(b % m >= m / 2){
            u = 1;
            v = b % m - m % 2 +1;
        }

        if((t + v) % 2 == 1) x.at(i) = 1;

    }

    int ans = 0;

    for(int i = 1;i < 45;i ++){
        ans += x.at(i) * pow(2,i-1);
    }

    cout << ans << endl;
}

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

int modpow(int x, int n, int m) {
if (n == 0) return 1%m;
long long u = modpow(x,n/2,m);
u = (u*u)%m;
if (n%2 == 1) u = (u*x)%m;
return u;
}

  
int main()
{
 
    long long int n,a,b,c;
    cin>>n;
    int m=1000000007;
    if(n==1|| n==0)  cout<<"0"<<endl;
    if(n==2)  cout<<"2"<<endl;
   if(n>=3) {
 
        a= modpow(10, n, m);
        b= modpow(9, n ,m);
        c=modpow(8, n, m);
 
      cout<< (a %1000000007+c %1000000007-(2*b)%1000000007 +1000000007)%1000000007<<endl;
        }
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

var N int
var A []int

func main() {
	fmt.Scanf("%d", &N)

	A = make([]int, N+2)

	for i := 1; i < N+1; i++ {
		fmt.Scanf("%d", &A[i])
	}

	s := make([]int, N+2)
	for i := 1; i < N+2; i++ {
		s[i] = s[i-1] + Abs(A[i-1]-A[i])
	}

	for i := 1; i < N+1; i++ {
		ans := s[i-1] + (s[N+1] - s[i+1]) + Abs(A[i-1]-A[i+1])
		fmt.Println(ans)
	}
}

func Abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}


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

int main(void){
    // Your code here!
   ll N,Y;
   cin >> N >> Y;
   bool l = 0;
   for(int i = 0; i <= N; i++){
       if(l == 1)break;
       for(int j = 0; j <= N - i; j++){
           if(l == 1)break;
           if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y && 0 <= N - i - j){
               cout << i << " " << j << " " << N - i - j << endl;
               l = 1;
               break;
           }
       }
   }
   if(l == 0)cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
	  Scanner scan = new Scanner(System.in);
	  
	  int a = scan.nextInt();
	  int b = scan.nextInt();
	  int c = scan.nextInt();
	  int yaku = 0;
	  for(int i = a;i <= b;i++){
		  if(c%i==0) yaku++;
	  }
	  
	  System.out.println(yaku);
	  
	    }
}

Measured memory_bytes: 17360
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

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

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1000005
using namespace std;
const int mod = 1e9+7;

int n, f[N];

void upd(int &x, int y){ x += y; if(x >= mod) x -= mod; }

int main(){
	scanf("%d", &n);
	f[1] = n; f[2] = 1LL * n * n % mod;
	int sum = 0;
	for(int i = 3; i <= n; i++){
		f[i] = f[i - 1];
		upd(f[i], sum);
		upd(f[i], 1LL * (n - 1) * (n - 1) % mod);
		upd(f[i], n - i + 2);
		upd(sum, f[i - 2]);
	}
	printf("%d\n", f[n]);
}


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

using namespace std;

int main(void){
    int N;
    string S;
    cin >> N >> S;
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < N / 2; i++){
        if(S[i] != S[i + N / 2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int n,a;
  cin >> n;
  cin >> a;
  int b;
  b = n%500;
  if ( b<=a ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

#define INF (1 << 29)

int H, W;

int main()
{
	cin >> H >> W;

	vector<string> S(H);

	vector<vector<int> > Data(H, vector<int>(W, 0));

	vector<vector<int> > dp(H, vector<int>(W, INF));

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

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			Data[i][j] = S[i][j] - 48;
		}
	}

	dp[0][0] = Data[0][0];

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (i != 0)
			{
				if (dp[i][j] > dp[i - 1][j] + Data[i][j])
				{
					dp[i][j] = dp[i - 1][j] + Data[i][j];
				}
			}
			if (j != 0)
			{
				if (dp[i][j] > dp[i][j - 1] + Data[i][j])
				{
					dp[i][j] = dp[i][j - 1] + Data[i][j];
				}
			}
		}
	}

	cout << dp[H - 1][W - 1] << endl;

	return 0;
}

// Time : O ( H * W )

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 分割数は、写像12相のうち以下に相当する
//  ・玉の区別をしない
//  ・箱の区別をしない
//  ・箱に入る玉の数に制限はない
// cf: http://drken1215.hatenablog.com/entry/2018/01/16/222843

// 定義
//  P(n,k): 区別のないn個の玉を、区別のないk個の箱に、中身が0個以上になるように分ける方法
//  Q(n,k): 区別のないn個の玉を、区別のないk個の箱に、中身が1個以上になるように分ける方法

// PとQの関係
//  Q(n,k) = P(n-k,k)

// Pの初期化
//  P(0,?) = P(?,1) = 1

// Pの漸化式
//  P(n,k) = P(n,k-1) + P(n-k,k)  if n >= k > 1
//  P(n,k) = P(n,n)               if n < m

// Qの初期化
//  Q(?,1) = Q(?,?) = 1

// Qの漸化式
//  Q(n,k) = Q(n-1,k-1) + Q(n-k,k)  if n >= k >= 2


class PartitionNumber {
    vector <vector<ll>> P, Q;

    void initP(int N) {
        for (int k = 0; k <= N; k++) P[0][k] = P[k][1] = 1;
        for (int n = 1; n <= N; n++) {
            for (int k = 2; k <= n; k++) P[n][k] = (P[n][k - 1] + P[n - k][k]) % MOD;
            for (int k = n + 1; k <= N; k++) P[n][k] = P[n][n];
        }
    }

    void initQ(int N) {
        for (int n = 0; n <= N; n++) Q[n][1] = Q[n][n] = 1;
        for (int n = 2; n <= N; n++) {
            for (int k = 2; k <= n; k++) Q[n][k] = (Q[n - 1][k - 1] + Q[n - k][k]) % MOD;
        }
    }

public:
    PartitionNumber(int N) : P(N + 1, vector<ll>(N + 1, 0)), Q(N + 1, vector<ll>(N + 1, 0)) {
        initP(N);
        initQ(N);

    }

    ll p(int n, int k) { return P[n][k]; }

    ll q(int n, int k) { return Q[n][k]; }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_J&lang=jp
void AOJ_DPL_5_J() {
    int n, k;
    cin >> n >> k;
    PartitionNumber pn(1000);
    cout << pn.p(n, k) << "\n";
}


// verified
//   https://yukicoder.me/problems/no/269
void yuki269() {
    int N, S, K;
    cin >> N >> S >> K;
    S -= K * N * (N - 1) / 2;
    if (S < 0) cout << 0 << '\n';
    else {
        PartitionNumber pn(S);
        cout << pn.p(S, N) << "\n";
    }
}

int main() {
    AOJ_DPL_5_J();
    //yuki269();
    return 0;
}


Measured memory_bytes: 18720
X,K,D=map(int,input().split())
if X>=0:
    if X-K*D>X%D:
        print(abs(X-K*D))
    else:
        if (K-X//D)%2==0:
            print(X%D)
        else:
            print(abs(X%D-D))
else:
    if X+K*D<X%D:
        print(abs(X+K*D))
    else:
        if (K+X//D)%2==0:
            print(X%D)
        else:
            print(abs(X%D-D))

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main {

	static boolean[] vis = new boolean[60];

    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	sc.close();
    	if(N == 25){
    		System.out.println("Christmas");
    	}else if(N == 24){
    		System.out.println("Christmas Eve");
    	}else if(N == 23){
    		System.out.println("Christmas Eve Eve");
    	}else{
    		System.out.println("Christmas Eve Eve Eve");
    	}
    }
}

Measured memory_bytes: 21204
h, w = map(int, input().split())
a = [''] * h

for i in range(h):
    a[i] = input()
    
row = [False] * h
cal = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            cal[j] = True
            
for i in range(h):
    if row[i]:
        for j in range(w):
            if cal[j]:
                print(a[i][j], end='')
        print()

Measured memory_bytes: 8992
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    const int MOD = 1e9 + 7;
    vector<vector<long long>> dp(N, vector<long long>(3));
    dp[0][0] = 8;
    dp[0][1] = 2;
    for(int i = 1; i < N; i++){
        dp[i][2] = (dp[i - 1][2] * 10 % MOD + dp[i - 1][1]) % MOD;
        dp[i][1] = (dp[i - 1][1] * 9 % MOD + dp[i - 1][0] * 2 % MOD) % MOD;
        dp[i][0] = dp[i - 1][0] * 8 % MOD;
    }
    cout << dp[N - 1][2] << endl;
}

Measured memory_bytes: 57804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> s(N);
    REP(i,N)s[i] = in();
    sort(ALL(s));
    int sum = 0;
    REP(i,N)sum += s[i];
    if(sum % 10 != 0){
        cout << sum << "\n";
    }else{
        int when = 0;
        REP(i,N){
            if(s[i] % 10 != 0){
                when = i;
                break;
            }
            if(i == N-1)when = -1;
        }
        if(when == -1){
            cout << 0 << "\n";
        }else{
            cout << sum - s[when] << "\n";
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		int x = sc.nextInt();
            for(int i=2;i<=Math.sqrt(x);i++){
              if(x%i==0){
                x++;
                i=1;
              }
            }

    		System.out.println(x);
    	}
    }

Measured memory_bytes: 25296
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		Set<String> ss = new HashSet<String>();

		for ( int i=0; i<n; i++ ) {
			String s = sc.next();
			ss.add(s);
		}

		System.out.println(ss.size());

	}
}

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

int calced;

int prime[400000];
int count;

void make_prime( int end ) {

	if ( end >= calced ) {
		for ( int i=calced; i<=end; i++ ) {
			if ( i % 7 == 1 || i % 7 == 6 ) {
				bool pass = true;

				int now = (int)sqrt((double)i)+1;

				for ( int j=0; j<count; j++ ) {
					if ( prime[j] > now )
						break;
					if ( i%prime[j] == 0 ) {
						pass = false;
						break;
					}
				}
				if ( pass ) {
					prime[count] = i;
					count++;
				}
			}
		}
	}
	calced = end+1;
}

void view_prime(int end ) {

	cout << end << ':';

	for ( int i=0; i<count ; i++ ) {
		if ( end % prime[i] == 0 ) {
			cout << ' ' << prime[i];
		}
	}
	cout << endl;
}

int main () {
	
	for ( int i=0; i<300000; i++ ) {
		prime[i] = 100000000;
	}



	calced = 7;
	prime[0] = 6;
	count = 1;

	

	make_prime( 300000 );

	while ( true ) {
		int input;
		cin >> input;
		if ( input == 1 )
			break;
		view_prime(input);
		
		for ( int i=0; i<count-1 ;i++ ) {
			if ( prime[i] == prime[i+1] ) {
				cout << prime[i] << endl;
			}
		}
	}

}

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string.h>
using namespace std;

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int kaibun(int number);

int main() {
	int n, l;
	vector<string> s;
	string temp;

	cin >> n >> l;


	for(int i= 0; i < n ; i++){
		cin >> temp;
		s.push_back(temp);
	}

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

	for(int j=1; j<n ;j++){
		copy(s[j].begin(), s[j].end() , back_inserter(s[0]));
	}

	cout << s[0];

}

Measured memory_bytes: 256
from itertools import permutations
import math

N = int(input())
P = list(map(str, input().split()))
Q = list(map(str, input().split()))

np = int(''.join(P))
nq = int(''.join(Q))

lst = []
lstn = ['1', '2', '3', '4', '5', '6', '7', '8']

for i in permutations(lstn[:N]):
    lst.append(int(''.join(i)))
lst.sort()

for i in range(0, math.factorial(N)):
    if lst[i] == np: np = i
    if lst[i] == nq: nq = i

print(abs(np - nq))

Measured memory_bytes: 4784
from collections import deque


def do_code():
    num = int(input())
    matrix = [[2] * (num + 1) for _ in range(num + 1)]
    honests = [set() for _ in range(num + 1)]
    unkinds = [set() for _ in range(num + 1)]
    # 人iは1〜Nのためインデックス0は使わずに1~Nで使うようにする
    for n in range(1, num + 1):
        u = set()
        h = set()
        ans = int(input())
        for a in range(ans):
            x, y = map(int, input().split(" "))
            if y == 1:
                h.add(x)
            else:
                u.add(x)
        honests[n] = h
        unkinds[n] = u
    count = 0
    for n in range(1, 2 ** num):
        honest_set = set()
        for j in range(num):
            t = 2 ** j
            if n & t == t:
                honest_set.add(j + 1)
        th = set()
        tu = set()
        queue = deque(honest_set)
        visited = set()
        while len(queue) > 0:
            t = queue.popleft()
            if t in visited:
                continue
            visited.add(t)
            queue.extend(honests[t])
            th |= honests[t]
            tu |= unkinds[t]
        if not th.isdisjoint(tu):
            # 正直者と仮定した人の証言を集めた場合にhonest && unkindな人がいる＝矛盾
            continue
        if not honest_set.isdisjoint(tu):
            continue
        honest = max(len(th), len(honest_set))
        count = max(count, honest)
    print(count)


if __name__ == '__main__':
    do_code()


Measured memory_bytes: 9344
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		WriteLine(N % N.ToString().Sum(c => c - '0') == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
 
int main(){
  int N,K;
  cin>>N>>K;
  int ans=0;
  while(N>0){
    N/=K;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	H, _ := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()
	sum := 0
	for _, v := range A {
		sum += v
	}
	if sum >= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6144
class String
	def del_neg
		s, t = self, nil
		loop {
			t = s.gsub(/-\d/){|x| (2+x.to_i).to_s}
			break if s == t
			s = t	
		}
		t
	end

	def del_or
		gsub(/(\d)\+(\d)/){|x| [$1, $2].max.to_s}
	end

	def del_and
		gsub(/(\d)\*(\d)/){|x| [$1, $2].min.to_s}
	end

	def del_par
		gsub(/\((\d)\)/){|x| $1.to_s}
	end

	def calc
		s = dup
		until s.size == 1
			s = s.del_neg
			s = s.del_or
			s = s.del_and
			s = s.del_par
		end
		s.to_i
	end
end


loop {
	s = gets.chomp
	break if s == ?.
	p (0..2).to_a.repeated_permutation(3).count{|a|
		exp = s.tr("PQR", a.join)
		exp.calc == 2
	}
}

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

int main()
{
	int R, G, B;
	cin >> R >> G >> B;
	int RGB = 100*R + 10*G + B;
	if(RGB%4 == 0){
	cout << "YES" << endl;
	}
	else
	{
	cout << "NO" << endl;
	}	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, K;
	int i;
	int asumikana = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;
	for (i = 0; i < N; i++) {
		int x;
		int tomatuharuka, igutiyuka;
		if (scanf("%d", &x) != 1) return 1;
		tomatuharuka = x;
		igutiyuka = K - x;
		asumikana += (tomatuharuka < igutiyuka ? tomatuharuka : igutiyuka) * 2;
	}
	printf("%d\n", asumikana);
	return 0;
}


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

#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ff              first
#define ss              second
#define SQ(x)           ((x)*(x))
#define LCM(x,y)        (((x)/gcd((x),(y)))*(y))
#define PI              acos(-1)
#define SZ(x)           x.size() - 1
#define waa             printf("Ripon\n")
#define mem(a,b)        memset(a,b,sizeof(a))
#define rep(i,a,n)      for(int i=(int)(a);i<=(int)(n);i++)
#define per(i,n,a)      for(int i=(int)(n);i>=(int)(a);i--)
#define SC              scanf
#define PF              printf
#define all(v)          v.begin(), v.end()
#define allr(v)         v.rbegin(), v.rend()
int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int dy[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int kx[] = { -2, -2, -1, 1, 2, 2, 1, -1 };
int ky[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
int overlap(int rs,int re,int qs,int qe){ if(rs>qe or re<qs) return 0; else if(qs<=rs and re<=qe) return 1; else return 2;} // 0 no, 1 total, 2 partial
//--------------------------//
void pvec(auto v){
    for (auto x:v){
        cout<<x<<" ";
    }
    cout<<endl;
}
//------------done with useless stuff--------------//


struct DATA{};
#define TC 0
#define mod 10000007
#define N 1000000
int n,m;
string str;
vector<int> v;



void solve(int T) {

    cin>>n;
    int sum = 0;
    rep(i,1,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=x;
    }

    int flr = sum/n;
    int cel = sum/n+ (bool)sum%n;

    int res1,res2;
    res1 = res2 = 0;

    rep(i,0,SZ(v)){
        int x = v[i];
        res1+=((x-flr) * (x-flr));
    }
    rep(i,0,SZ(v)){
        int x = v[i];
        res2+=((x-cel) * (x-cel));
    }

    cout<<min(res1,res2)<<endl;
}


int main(){

    ios_base::sync_with_stdio(0);cin.tie(nullptr);
	#ifdef RIPON
	    freopen("file.txt","r",stdin);
	#endif

    int T=1;
    if(TC) cin>>T;
    for(int t=1;t<=T;t++)   solve(t);
    return 0;
}



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

using ll = long long;

bool works(vector<pair<int,int> > g, ll mask){
	for(pair<int,int> a : g){
		set<int> p;
		p.insert(a.first);
		for(ll b = 50; b >= 1; b--){
			if(1 & (mask >> b)){
				vector<int> x;
				for(int q : p){
					x.push_back(q % b);
				}
				for(int q : x){
					p.insert(q);
				}
			}
		}
		if(!p.count(a.second)) return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<pair<int,int> > a(n);
	for(int i = 0; i < n; i++) cin >> a[i].first;
	for(int i = 0; i < n; i++) cin >> a[i].second;

	ll cmask = 0;
	if(!works(a, (1ll << 51) - 1)){
		cout << -1 << '\n';
		return 0;
	}
	for(int B = 50; B >= 1; B--){
		if(works(a, cmask ^ ((1ll << B) - 2))) continue;
		cmask ^= (1ll << B);
	}
	cout << cmask << '\n';
}

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


int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=c-a,y=d-b;
  for(int i=0; i<x; i++)cout<<"R";
  for(int i=0; i<y; i++)cout<<"U";
  for(int i=0; i<x; i++)cout<<"L";
  for(int i=0; i<y+1; i++)cout<<"D";
  for(int i=0; i<x+1; i++)cout<<"R";
  for(int i=0; i<y+1; i++)cout<<"U";
  cout<<"LU";
  for(int i=0; i<x+1; i++)cout<<"L";
  for(int i=0; i<y+1; i++)cout<<"D";
  cout<<"R";
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[233];

int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		if(i && a[i]==a[i-1])
		{
			a[i]=-i;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;




int main()
{
	int N;
	double p;
	string u;
	double sum = 0.0;

	cin >> N;

	for (int ni = 0; ni < N; ni++){
		cin >> p >> u;
		if (u == "BTC"){
			p *= 380000;
		}
		sum += p;
	}


	printf("%f",sum);


	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<int> s(m), c(m);
    for(int i=0; i<m; i++) cin>>s[i]>>c[i], s[i]--;

    for(int i=0; i<=999; i++){
        string t = to_string(i);
        if(t.size() != n) continue;

        bool valid = true;
        for(int j=0; j<m; j++){
            if(t[s[j]] - '0' != c[j]) valid = false;
        }

        if(valid){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

  int a,b,c,d;

  cin >> a >> b >> c ;

  if(a > b){
    d = a;
    a = b;
    b = d;
  }

  if(b > c){
    d = b;
    b = c;
    c = d;
  }

  if(a > b){
    d = a;
    a = b;
    b = d;
  }
  cout <<a<<" "<<b<<" "<<c<< "\n";
  
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin>>a[i];
  sort(a.begin(),a.end());
  double mid=a[n-1]*0.5;
  auto k=upper_bound(a.begin(),a.end(),mid);
  printf("%d ",a[n-1]);
  if(abs(mid-*k)<abs(mid-*(k-1))) cout<<*k; else cout<<*(k-1);
  return 0;
}

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

int main(){
    int A,B,X;
    cin >> A >> B >> X;

    X -=  A;
    bool is_exist = false;
    for(int i = 0; i <= B;i++) {
        if(X == i) {
            is_exist = true;
            break;
        }
    }
    if(is_exist){
        cout << "YES" <<endl;
    } else {
        cout << "NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
queue = []
n.times do
  name, time = gets.split
  queue << { name: name, time: time.to_i}
end
current = 0
loop do
  break if queue.empty?

  data = queue.shift
  current += [q, data[:time]].min
  if data[:time] <= q
    puts data[:name] + ' ' + current.to_s
  else
    queue << { name: data[:name], time: data[:time] - q }
  end
end


Measured memory_bytes: 32244
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j;
char mp[52][52];
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++) for (j=1;j<=m;j++) cin>>mp[i][j];
	for (i=1;i<=n;i++) for (j=1;j<=m;j++) if (mp[i][j]=='#')
	{
		if (mp[i-1][j]=='#') continue;
		if (mp[i+1][j]=='#') continue;
		if (mp[i][j-1]=='#') continue;
		if (mp[i][j+1]=='#') continue;
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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


int main(){
  int n, d;
  cin >> n >> d;
  ll x[n], y[n];
  rep(i, n) cin >> x[i] >> y[i];
  int cnt =0;
  rep(i, n){
    ll xx = x[i]*x[i];
    ll yy = y[i]*y[i];
    if(abs(x[i]) > d || abs(y[i]) > d) continue;
    else if(sqrt(xx + yy) <= d) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	int a, b;
	a = b = 0;
	bool h = true;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "A") {
			a++;
		} else {
			a--;
		}
		if (a < 0) {
			h = false;
		}
	}
	if (a > 0) {
		h = false;
	}
	if (h) {
		cout << "YES" << endl;
 	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
n,m = map(int,input().split())
data = []
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data.append((a,b))
data = sorted(data,key=lambda x:x[1])
cnt = 0
dis = -1
for i in range(m):
    a,b = data[i]
    if(dis < a):
        cnt += 1
        dis = b - 1
print(cnt)

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

vl kmp(string &&s, string &r){
	vl vet(s.size() + 1, -1);
	ll t = -1;
	for(int i = 0; i < s.size(); ++i){
		while (t > -1 && s[i] != s[t]){
			t = vet[t];
		}
		vet[i+1] = ++t;
	}
	vl res;
	res.insert(res.begin(), vet.begin() + r.size() + 1, vet.end());
	res[0] = -1;
	return res;
}

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

	ll n, a, res = 0;
	cin >> n;
	vl vet(n);
	for(int i = 0; i < n; ++i){
		cin >> vet[i];
	}
	sort(vet.rbegin(), vet.rend());
	for(int i = 0; i < n; ++i){
		if(i%2 == 0){
			res += vet[i];
		} else{
			res -= vet[i];
		}	
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    set<string> s;
    map<string,ll> m;
    ll maxm =-1;
    rep(i,0,n){
        string a;
        cin >>a;
        m[a]++;
        maxm = max(maxm,m[a]);
    }
    for(auto i:m){
        if (i.S == maxm) s.insert(i.F);
    }
    for( auto i:s) cout << i << endl;
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 33280
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}
/*		START		*/
$HW = getq(1);
$MAP = array();
$ans = "Yes\n";
for ($i=0; $i < $HW[0]; $i++) { 
	$MAP[$i] = getq();
}
for ($i=0; $i < $HW[0]; $i++) { 
	for ($j=0; $j < $HW[1]; $j++) { 
		if($MAP[$i][$j]=="#"){
			$flag=0;
			if(isset($MAP[$i-1][$j])){
				if($MAP[$i-1][$j]=="#"){$flag++;}
			}
			if(isset($MAP[$i+1][$j])){
				if($MAP[$i+1][$j]=="#"){$flag++;}
			}
			if(isset($MAP[$i][$j+1])){
				if($MAP[$i][$j+1]=="#"){$flag++;}
			}
			if(isset($MAP[$i][$j-1])){
				if($MAP[$i][$j-1]=="#"){$flag++;}
			}
			if($flag==0)$ans = "No\n";
		}
	}
}
echo $ans;
?>

Measured memory_bytes: 4604
N = int(input())
W = list(map(int, input().split()))
a = [0] * (N - 1)
s = sum(W)
a[0] = s - 2 * W[0]

for i in range(1, N - 1):
    a[i] = a[i - 1] - 2 * W[i]

for i in range(N - 1):
    a[i] = abs(a[i])

print(min(a))

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


int main(void) {
	int n, m, count = 0;
	cin >> n;
	int a[n] = {0};
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> m;
	
	int b[m] = {0};
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}
	
	for(int i = 0; i < m; i++) {
		for(int j = 0; j < n; j++){
			if(b[i] == a[j]) {
				count++;
				break;
			}
		}
	} 
	cout << count << endl;
	return 0;
}
 


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

using namespace std;

#define int long long
#define fi first
#define se second
#define inf 1e9
const int mod=(int)1e9+7;


void test_case(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<pair<int,int> > arr;
	for(int i=0;i<a;i++){
		int p;
		cin>>p;
		arr.push_back({p,0});
	}
	for(int i=0;i<b;i++){
		int p;
		cin>>p;
		arr.push_back({p,1});
	}
	for(int i=0;i<c;i++){
		int p;
		cin>>p;
		arr.push_back({p,2});
	}
	sort(arr.rbegin(),arr.rend());
	int ans=0,apple=x+y;
	for(int i=0;i<(int)arr.size();i++){
		if(apple==0)break;
		if(arr[i].se==0&&x>0){
			ans+=arr[i].fi,x--;
			apple--;
		}
		if(arr[i].se==1&&y>0){
			ans+=arr[i].fi,y--;
			apple--;
		}
		if(arr[i].se==2){
			ans+=arr[i].fi;
			apple--;
		}
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


ll mod_pow(ll m, ll n, ll mod) {
    if (n == 0) {
        return 1;
    }

    ll rv = mod_pow(m * m % mod, n/2, mod);

    if (n % 2) {
        return (rv * m) % mod;
    } else {
        return rv;
    }
}


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

    ll N;
    ll C;
    cin >> N >> C;

    vector<ll> A;
    vector<ll> B;

    A.resize(N+1);
    B.resize(N+1);

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


    vector< vector<ll> > T;
    T.resize(401);

    // (i-1)^1, (i-1)^2, (i-1)^3
    // (i  )^1, (i  )^2, (i  )^3
    // (i+1)^1, (i+1)^2, (i+1)^3

    for (ll i = 0; i < 401; ++i) {
        T[i].resize(401);

        T[i][0] = 1;

        for (ll j = 1; j < 401; ++j) {
            T[i][j] = mod_pow(i, j, MOD);
        }
    }


    vector< vector<ll> > U;
    U.resize(N+1);

    for (ll i = 0; i <= N; ++i) {
        U[i].resize(C+1);

        for (ll j = 0; j <= C; ++j) {
            U[i][j] = 0;

            for (ll x = A[i]; x <= B[i]; ++x) {
                U[i][j] = (U[i][j] + T[x][j]) % MOD;
            }
        }
    }


    //for (ll i = 0; i <= N; ++i) {
    //    for (ll j = 0; j <= C; ++j) {
    //        cout << U[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    //cout << endl;


    vector< vector<ll> > dp; // N, C
    dp.resize(N+1);
    for (ll i = 0; i <= N; ++i) {
        dp[i].resize(C+1);
    }

    dp[0][0] = 1;
    for (ll j = 1; j <= C; ++j) {
        dp[0][j] = 0;
    }

    for (ll j = 0; j <= C; ++j) {
        dp[1][j] = U[1][j];
    }

    for (ll i = 2; i <= N; ++i) {
        for (ll j = 0; j <= C; ++j) {
            dp[i][j] = 0;

            for (ll k = 0; k <= j; ++k) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-k] * U[i][k]) % MOD;
            }
        }
    }


    //for (ll i = 0; i <= N; ++i) {
    //    for (ll j = 0; j <= C; ++j) {
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}


    cout << dp[N][C] << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    vector<int> idx(n + 1, -1);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        idx[a] = i;
    }

    set<int> ids;
    ids.insert(-1);
    ids.insert(n);

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int aim = idx[i];
        auto r = ids.lower_bound(aim);
        auto l = prev(r, 1);
        ans += 1LL * (aim - *l) * (*r - aim) * i;
        ids.insert(aim);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	int i;
	while(cin >> n){
		i=n;
		string s[n];
		cin.ignore();
		while(n--){
			getline(cin,s[n]);
			int ix=0;
			while( ( ix =s[n].find("Hoshino") ) >=0 ){
				s[n].replace(ix,7,"Hoshina");
			}
		}
		while(i--){
			cout << s[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3176
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  int[] a; readA(n, a);

  auto b = new bool[](k+1);
  foreach (i; 1..k+1)
    b[i] = a.any!(ai => i-ai >= 0 && !b[i-ai]);

  writeln(b[$-1] ? "First" : "Second");
}


Measured memory_bytes: 380