akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
 
signed main()
{
    int n, m;
    cin >> n >> m;
    std::vector<int> s(n);
    std::vector<int> t(m);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    std::vector<int> sumarray(n, 0);
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
job_list = []
for i in range(n):
    a, b = map(int, input().split())
    job_list.append((a, b))
job_list.sort(key=lambda x: x[1])

time = 0
for a, b in job_list:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 73304
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn pow(b: u64, p: usize) -> u64 {
    if p == 0 {
        1
    } else if p == 1 {
        b
    } else if p % 2 == 0 {
        pow(b * b, p / 2)
    } else {
        pow(b * b, p / 2) * b
    }
}

fn main() {
    let mut sc = Scanner::new();
    let x: u64 = sc.cin();
    let mut ans = 0;
    for p in 2..15 {
        for b in 1..100 {
            if pow(b, p) <= x {
                ans = max!(ans, pow(b, p));
            } else {
                break;
            }
        }
    }
    put!(ans);
}

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

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


Measured memory_bytes: 4352
#include<stdio.h>
#define INF 1000000
#define N 2000000

void insert(int *, int);
void increase(int *, int, int);
int extractmax(int *);
void maxHeapify(int *, int);

int n=0;
int S[N];

int main()
{

  int i=0, k, j, max[N];
  char com[10];


  while(1){
    scanf("%s", com);
    
    if(com[0] == 'i'){
      scanf("%d", &k);
      insert(S, k);
    }

    else if(com[1] == 'x'){
      max[i] = extractmax(S);
      i++;
    }

    else if(com[1] == 'n') break;

  }

  for(j = 0; j < i; j++){
    printf("%d\n", max[j]);
  }

  return 0;

}

void insert(int *S, int k)
{
  n += 1; 
  S[n] = -INF;
  increase(S, n, k);
}

void increase(int *S, int i, int key)
{

  int temp;

  S[i] = key;

  while(i > 1 && S[i/2] < S[i]){
    temp = S[i];
    S[i] = S[i/2];
    S[i/2] = temp;
    i = i/2;
  }
}

int extractmax(int *S)
{
  int max;

  max = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(S, 1);

  return max;
}

void maxHeapify(int *A, int i)
{

  int l, r, largest;
  int temp;

  l = 2*i;
  r = 2*i+1;
  
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= n && A[r] > A[largest]) largest = r;

  /* iの子の方が値が大きい場合 */
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest); // 再帰的に呼び出し
  }
}

Measured memory_bytes: 7080
from collections import defaultdict
n, m = map(int, input().split())
ns = list(map(int, input().split()))
ns = [0] + ns
dic = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
cnt = 0
for i in range(1, n+1):
    if dic[i]:
        if ns[i] > max(ns[j] for j in dic[i]):
            cnt += 1
    else:
        cnt += 1
print(cnt)
        

Measured memory_bytes: 104396
# -*- coding: utf-8 -*-
N, M = map(int, raw_input().split())
x = []
for i in xrange(M):
    x.append(map(int, raw_input().split()))
hako=[]
for i in xrange(N+1):
    if i==1:
        hako.append([1,1])
    else:
        hako.append([0,1])
for move in x:
    hako[move[0]][1]=hako[move[0]][1]-1
    hako[move[1]][1]=hako[move[1]][1]+1
    if hako[move[0]][0]==1:
        hako[move[1]][0]=1
    if hako[move[0]][1]==0:
        hako[move[0]][0]=0
s=0
for i in xrange(N+1):
    s=s+hako[i][0]
print s

Measured memory_bytes: 29444
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100000

int n;
vector<int> G[MAX_N];

int dfs(int now){
    if(G[now].size() == 0) return 0;
    map<int, int> cnt;
    REP(i,G[now].size()){
        cnt[dfs(G[now][i]) + 1]++;
    }
    int res = 0;
    for(auto i : cnt){
        if(i.second == 0) continue;
        cnt[i.first + 1] += i.second - 1;
        res = i.first;
    }
    return res;
}

signed main(){
    cin >> n;
    int a;
    REP(i,n - 1){
        cin >> a;
        a--;
        G[a].emplace_back(i + 1);
    }
    cout << dfs(0) << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 1000005
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[MAX_N];

void solve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2,(int)sqrt(MAX_N))
	{
		if (prime[i] == true)
		{
			for (int j = 2; j*i <= MAX_N; j++){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n)
	{
		if (n==0)break;
		
		int ans = 0;
		solve();
		FOR(i,n+1,2*n+1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2144
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
x_list = list(range(0, n + 1))
ans = 0
min_total = sum(x_list[0 : k - 1])
max_total = sum(x_list[n + 1 - (k - 1) : n + 1])
for i in range(k, n + 2):
    min_total += x_list[i - 1]
    max_total += x_list[n + 1 - i]
    ans += max_total - min_total + 1
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 18404
#pragma GCC optimize("O3")

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

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;}
// endmacro

int main(){
  ios; cfs(15);
  LL(a,b,c,k);
  ll t=(k<=a)?k:a;
  k-=(a+b);
  if(k>0) t-=k;
  cout<<t<<endl;
  ret;
}

Measured memory_bytes: 3640
import java.util.Scanner;

/**
 * A
 */
public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == b + c) {
            System.out.println("Yes");
        } else if (b == a + c) {
            System.out.println("Yes");
        } else if (c == b + a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
n = gets.to_i

h = {}
1.upto(100) do |x|
  1.upto(100) do |y|
    1.upto(100) do |z|
      a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      h[a] ||= 0
      h[a] += 1
    end
  end
end

1.upto(n) do |a|
  puts h[a] || 0
end

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

fn main() {
    let n = get!(usize);
    let ss = get!(i32; n);
    if let Some(x) = ss.iter().filter(|s| **s%10 != 0).min() {
        let s: i32 = ss.iter().sum();
        println!("{}", if s%10 == 0 { s - x } else { s });
    } else {
        println!("0");
    }   
}

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

int main() {
  int N,D,X;
  cin >> N >> D >> X;
 
  int count = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    int day = 0;
    while (day < D) {
      count++;
      day += x;
    }
  }
  
  cout << X + count << endl;
  
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
string s;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    int countr=0;
    int countb=0;
    for(int i=0;i<n;i++){
        if(s.substr(i,1)=="B"){
            countb++;
            }
        else{
            countr++;
        } 
    }
    if(countr>countb) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







using P = pair<ll, ll>;

int main() {
    ll n, m, r;
    cin >> n >> m >> r;
    vector<vector<P>> g(n);
    REP(i, m){
        ll s, t, d;
        cin >> s >> t >> d;
        g[s].push_back({t, d});
    }
    
    vector<ll> dist(n, INF);
    dist[r] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, r});
    while(!que.empty()){
        auto tmp = que.top(); que.pop();
        ll d = tmp.first, now = tmp.second;
        if(dist[now] < d) continue;
        
        for(auto &x : g[now]){
            ll v = x.first, c = x.second;
            if(dist[v] > dist[now] + c){
                dist[v] = dist[now] + c;
                que.push({dist[now] + c, v});
            }
        }
    }
    REP(i, n){
        if(dist[i] != INF) cout << dist[i] << endl;
        else cout << "INF" << endl;
    }
}



Measured memory_bytes: 19444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			int ans = INF;
			for (int i = 1; i < n; i++) {
				int tmp = 0;

				int b = n - i;

				char[] si = String.valueOf(i).toCharArray();
				char[] bi = String.valueOf(b).toCharArray();

				for (int j = 0; j < si.length; j++) {
					tmp += si[j]-'0';
				}
				for (int j = 0; j < bi.length; j++) {
					tmp += bi[j]-'0';
				}

				ans = Math.min(ans, tmp);
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 35344
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			String a = stdIn.next();
			String b = stdIn.next();
			for(int j = a.length()-1; j >= 0; j--) {
				if(a.charAt(j) == 'J') {
					b = J(b);
					continue;
				}
				if(a.charAt(j) == 'C') {
					b = C(b);
					continue;
				}
				if(a.charAt(j) == 'E') {
					b = E(b);
					continue;
				}
				if(a.charAt(j) == 'A') {
					b = A(b);
					continue;
				}
				if(a.charAt(j) == 'P') {
					b = M(b);
					continue;
				}
				if(a.charAt(j) == 'M') {
					b = P(b);
					continue;
				}
				
			}
			System.out.println(b);
		}
		
	}
	
	public static String J(String a) {
		String b1 = a.substring(a.length()-1, a.length());
		String b2 = a.substring(0, a.length()-1);
		return b1 + b2;
	}
	
	public static String C(String a) {
		String b1 = a.substring(0, 1);
		String b2 = a.substring(1, a.length());
		return b2 + b1;
	}
	
	public static String E(String a) {
		String b1 = "";
		String b2 = "";
		String b3 = "";
		if(a.length() % 2 == 1) {
			b1 = a.substring(0, a.length()/2);
			b2 = a.substring(a.length()/2, a.length()/2 + 1);
			b3 = a.substring(a.length()/2+1, a.length());
		}
		else {
			b1 = a.substring(0, a.length()/2);
			b3 = a.substring(a.length()/2, a.length());
		}
		return b3 + b2 + b1;
	}
	
	public static String A(String a) {
		String b1 = "";
		for(int i = a.length()-1; i >= 0; i--) {
			b1 += String.valueOf(a.charAt(i));
		}
		return b1;
	}
	
	public static String P(String a) {
		String b1 = "";
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i) == '0') {
				b1 += "1";
			}
			else if(a.charAt(i) == '1') {
				b1 += "2";
			}
			else if(a.charAt(i) == '2') {
				b1 += "3";
			}
			else if(a.charAt(i) == '3') {
				b1 += "4";
			}
			else if(a.charAt(i) == '4') {
				b1 += "5";
			}
			else if(a.charAt(i) == '5') {
				b1 += "6";
			}
			else if(a.charAt(i) == '6') {
				b1 += "7";
			}
			else if(a.charAt(i) == '7') {
				b1 += "8";
			}
			else if(a.charAt(i) == '8') {
				b1 += "9";
			}
			else if(a.charAt(i) == '9') {
				b1 += "0";
			}
			else {
				b1 += String.valueOf(a.charAt(i));
			}
		}
		return b1;
	}
	public static String M(String a) {
		String b1 = "";
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i) == '0') {
				b1 += "9";
			}
			else if(a.charAt(i) == '1') {
				b1 += "0";
			}
			else if(a.charAt(i) == '2') {
				b1 += "1";
			}
			else if(a.charAt(i) == '3') {
				b1 += "2";
			}
			else if(a.charAt(i) == '4') {
				b1 += "3";
			}
			else if(a.charAt(i) == '5') {
				b1 += "4";
			}
			else if(a.charAt(i) == '6') {
				b1 += "5";
			}
			else if(a.charAt(i) == '7') {
				b1 += "6";
			}
			else if(a.charAt(i) == '8') {
				b1 += "7";
			}
			else if(a.charAt(i) == '9') {
				b1 += "8";
			}
			else {
				b1 += String.valueOf(a.charAt(i));
			}
		}
		return b1;
	}
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
if(S == "Sunny")
  cout << "Cloudy" << endl;
else if(S == "Cloudy")
  cout << "Rainy" << endl;
else if(S == "Rainy")
  cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,ss, sss;
	cin >> s >> ss;
	int a, b;
	cin >> a >> b;
	cin >> sss;
	if(s == sss){
		a--;
		cout << a << "\n" << b;
		}
		else
		{
			b--;
			cout << a << "\n" << b;
		}
		
		}

Measured memory_bytes: 256
def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    x=a[n-1]
    m=x
    y=0
    for i in range(n-1):
        if abs(a[i]-x//2) < m:
            m=abs(a[i]-x/2)
            y=a[i]
    print(x,y)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	fast();
	ull n = 1e18 * 2;
	int t;
	t = 1;
	while (t--){
		ll a, b, c;
		cin >> a >> b >> c;
		if (c>=a&&c<=b) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    ll X;
    cin >> X;
    ll aa = floor(pow(X, 1.0 / 5.0));
    while (1)
    {
        ll bx = pow(aa, 5) - X;
        ll bb = floor(pow(abs(bx), 1.0 / 5.0));
        if (bx < 0)
        {
            bb *= -1;
        }

        if (pow(aa, 5) - pow(bb, 5) == X)
        {
            cout << aa << " " << bb << endl;
            return;
        }

        aa--;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4104
def identify(N: int, M: int, PY: list) -> list:
    _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]
    _PY.sort(key=lambda x: x[2])
    _PY.sort(key=lambda x: x[1])

    now_p = 0
    now_o = 1
    ids = []
    for i, p, _ in _PY:
        if p != now_p:
            now_p = p
            now_o = 1
        ids.append((i, '{p:06}{o:06}'.format(p=p, o=now_o)))
        now_o += 1

    return [i for _, i in sorted(ids, key=lambda x: x[0])]


if __name__ == "__main__":
    N, M = map(int, input().split())
    PY = [tuple(int(s) for s in input().split()) for _ in range(M)]
    for ans in identify(N, M, PY):
        print(ans)


Measured memory_bytes: 43980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, sum = 0;
    cin >> N;
    vint s(N);
    rep(i, N)
    {
        cin >> s[i];
        sum += s[i];
    }
    sort(all(s));
    if (sum % 10)
    {
        cout << sum;
        return 0;
    }
    else
    {
        rep(i, N)
        {
            if (s[i] % 10)
            {
                cout << sum - s[i];
                return 0;
            }
        }
    }
    cout << 0;
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7')cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] value = new int[N];
		for(int i = 0; i < N; i++)
		{
			value[i] = sc.nextInt();
		}

		value =  sort(value, N);

		double alchemyResult = ((double)value[0] + (double)value[1]) / 2;

		for(int i = 2; i < N; i++)
		{
			alchemyResult = (alchemyResult + (double)value[i]) / 2;
		}

		System.out.println(alchemyResult);
		sc.close();
	}

	private static int[] sort(int[] a, int N) {
		for(int i = 0; i < N; i++) {
			for(int j = N-1; 0 <= j; j--)
			{
				if(i == j) break;
				if(a[j] < a[j-1])
				{
					int temp = a[j];
					a[j] = a[j-1];
					a[j-1] = temp;
				}
			}
		}
		return a;
	}
}

Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 3){
    if (s[i] == '1') ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if(N%2==0) {
			System.out.println(N);
		}else {
			System.out.println(N*2);
		}
	}
}


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

namespace MathCal {
  typedef long long LL;
  const LL mod = 1e9 + 7;
  const int N = 1e6 + 5;

  LL fac[N], inv[N];

  inline LL Pow(LL x, LL exp) {
    LL res = 1;
    for (; exp; exp >>= 1, x = x * x % mod)
      if (exp & 1) res = res * x % mod;
    return res;
  }
  inline void Init() {
    for (int i = fac[0] = 1; i < N; i ++) fac[i] = fac[i - 1] * i % mod;
    inv[N - 1] = Pow(fac[N - 1], mod - 2);
    for (int i = N - 1; i; i --) inv[i - 1] = inv[i] * i % mod;
  }
  inline LL C(int x, int y) {
    return y > x ? 0 : fac[x] * inv[y] % mod * inv[x - y] % mod;
  }
}
using namespace MathCal;

int n;

int main() {
  Init();
  scanf("%d", &n);
  LL ans = 0;
  for (int i = 1; i <= n / 2; i ++)
    ans += C(n - 3 - (i - 1), i) * fac[i] % mod * fac[n - i - 1] % mod;
  ans %= mod;
  ans = (fac[n - 1] * (n - 1) - ans) % mod;
  ans = (ans + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

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

    //vvi dp(n, vi(3, 0));
    //vi = vector<int>
    // vvi = vector< vi >
    vector<vector<int>> dp(n+1, vector<int>(3, 0));

    rep(i, n) {
        dp[i+1][0] = max(dp[i+1][0], dp[i][1] + a[i]);
        dp[i+1][0] = max(dp[i+1][0], dp[i][2] + a[i]);
        dp[i+1][1] = max(dp[i+1][1], dp[i][0] + b[i]);
        dp[i+1][1] = max(dp[i+1][1], dp[i][2] + b[i]);
        dp[i+1][2] = max(dp[i+1][2], dp[i][0] + c[i]);
        dp[i+1][2] = max(dp[i+1][2], dp[i][1] + c[i]);
    }

    std::cout << max({dp[n][0], dp[n][1], dp[n][2]}) << std::endl;


    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,m,a[1010],b[1010];
vector<int>v[1010];
int dp[1010][5000];
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];
		rep(j,b[i]){
			int c;
			cin>>c;
			c--;
			v[i].pb(c);
		}
	}
	rep(i,1010)rep(j,5000)dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,m){
		rep(j,(1<<n)){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			int k=j;
			for(int c:v[i]){
				k|=(1<<c);
			}
			dp[i+1][k]=min(dp[i+1][k],dp[i][j]+a[i]);
			
		}
	}
	if(dp[m][(1<<n)-1]==INF)puts("-1");
	else cout<<dp[m][(1<<n)-1]<<endl;
	return 0;
}


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

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

const int M = 100010;
int a[M][3], dp[M][3];

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

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

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j != k) chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[n][j]);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
//#include <search.h>
#include <algorithm>
//#include <vector>
using namespace std;
int main()
{
  int k,s,sum=0;
  scanf("%d %d",&k,&s);
  for(int i=0;i<=k;++i){
    for(int j=0;j<=k;++j){
           if(s-(i+j)<=k && s-(i+j)>=0){
               // cout<<s-(i+j)<<" "<<i<<" "<<j<<endl;
                sum+=1;
               // break;
          }
  }
}
  cout<<sum;
return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n  = s.length();
        int left = n/2-(n%2 ^ 1);
        int right = n/2;
        int width = -n%2;
        char mod = s.charAt(left);
        while(left >= 0 & right < n){
            if (s.charAt(right)!=mod | s.charAt(left)!=mod) {
                break;
            } else {
                width+=2;
            }
            left--;
            right++;
        }
        int k = n/2 + width/2 + n%2;
        System.out.println(k);
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define ld double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-22
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int n;
int f[30], g[30];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    FOR(i,0,25) g[i] = 1000000000;
    FOR(i,1,n) {
        string s;
        cin >> s;
        ms(f, 0);
        FOR(j,0,s.length()-1) f[s[j]-'a']++;
        FOR(j,0,25) g[j] = min(g[j], f[j]);
    }
    //FOR(i,0,25) cout << g[i] << " ";
    FOR(i,0,25)
        while (g[i]) {
            g[i]--;
            cout << char(i+'a');
        }
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

const MOD: i64 = 1e+9 as i64 + 7;
const FACT_MAX: usize = 300000;
static mut FACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
static mut RFACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
fn init_fact() {
    unsafe {
        if FACTORIAL[0] == 0 {
            FACTORIAL[0] = 1;
            for i in 1..FACT_MAX + 1 {
                FACTORIAL[i] = (FACTORIAL[i - 1] * i as i64) % MOD;
            }
            RFACTORIAL[FACT_MAX] = inv_mod(FACTORIAL[FACT_MAX], MOD);
            for i in (0..FACT_MAX).rev() {
                RFACTORIAL[i] = RFACTORIAL[i + 1] * (i as i64 + 1) % MOD;
            }
        }
    }
}
#[allow(dead_code)]
fn fact(n: usize) -> i64 {
    init_fact();
    unsafe { FACTORIAL[n] }
}
#[allow(dead_code, unused_comparisons)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m || m < 0 {
        return 0;
    }
    init_fact();
    unsafe { FACTORIAL[n] * RFACTORIAL[m] % MOD * RFACTORIAL[n - m] % MOD }
}

fn main() {
    let mut n = read::<usize>();
    let mut m = read::<usize>();
    if n < m {
        std::mem::swap(&mut n, &mut m);
    }
    let mut ans = 1;
    ans = (ans * fact(n)) % MOD;
    ans = (ans * fact(m)) % MOD;
    if n == m {
        ans = (ans * 2) % MOD;
    } else if n != m + 1 {
        ans = 0;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8956
import sys
def input():
    return sys.stdin.readline().strip()

n, u, v = map(int, input().split())
u, v = u-1, v-1

tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

from queue import Queue

# 青木君によるWFS
aoki = [-1 for _ in range(n)]
aoki[v] = 0
todo = Queue()
todo.put(v)
while not todo.empty():
    i = todo.get()
    for j in tree[i]:
        if aoki[j] == -1:
            todo.put(j)
            aoki[j] = aoki[i] + 1

# 高橋君によるWFS
taka = [-1 for _ in range(n)]
taka[u] = 0
todo = Queue()
todo.put(u)
while not todo.empty():
    i = todo.get()
    for j in tree[i]:
        if taka[j] == -1:
            if taka[i] + 1 < aoki[j]:
                todo.put(j)
            taka[j] = taka[i] + 1

# search
ans = 0
for i in range(n):
    if taka[i] != -1:
        if aoki[i] - 1 > ans:
            ans = aoki[i] - 1

print(ans)

Measured memory_bytes: 76956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, k, ans = 0;

int main() {
	cin >> n >> k;
	rep(i, n) {
		int num;
		cin >> num;
		ans += 2 * min(num, k - num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final int n = in.nextInt();
            final int d = in.nextInt();
            int ans = in.nextInt();
            for (int i = 0; i < n; i++) ans += 1 + ((d - 1) / in.nextInt());
            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//二次元累積和
template <typename T>
struct cumulative_sum_2d {
    vector<vector<T>> data;
    //コンストラクタ
    cumulative_sum_2d(vector<vector<T>> &v) {
        data = vector<vector<T>>(v.size() + 1, vector<int>(v[0].size() + 1, 0));
        for (int i = 0; i < (int)v.size(); i++) {
            for (int j = 0; j < (int)v[0].size(); j++) {
                data[i + 1][j + 1] =
                    data[i + 1][j] + data[i][j + 1] - data[i][j] + v[i][j];
            }
        }
    }
    //[a,b)×[c,d)の和を計算
    long long int sum(int a, int b, int c, int d) {
        return data[b][d] - data[b][c] - data[a][d] + data[a][c];
    }
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> train(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        train[l - 1][r - 1]++;
    }
    cumulative_sum_2d<int> cum(train);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << cum.sum(x - 1, y, x - 1, y) << endl;
    }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int n,d,c=0;
    cin>>n>>d;
    while(n--)
    {
    	long double x,y;
    	cin>>x>>y;
    	long double dis=sqrt(((x*x)+(y*y)));
    	if(dis<=d)
    	c++;
	}
	cout<<c<<endl;
	return 0;
}

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

A.sort()
B.sort()
C.sort()
 
def is_ok(mid, array, n):  return array[mid] > n
 
def binary_search(left, right, array, n):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, array, n):  right = mid
        else:  left = mid
    return right
 
ans = 0
BtoC = [N - binary_search(-1, N, C, B[i]) for i in range(N)]
for i in range(1, N):  BtoC[-i - 1] += BtoC[-i]
for i in range(N):  
    ret = binary_search(-1, N, B, A[i])
    if ret != N:  ans += BtoC[binary_search(-1, N, B, A[i])]
print(ans)

Measured memory_bytes: 105700
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;

int a[maxn],dp[maxn];

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	dp[2] = abs(a[1] - a[2]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i-2] -a[i]));
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    string s;cin>>s;
    if(s[0]==s[1] &&s[0]!=s[2]&& s[2]==s[3])cout<<"Yes";
    else if(s[0]==s[2]&&s[2]!=s[1]&&s[1]==s[3])cout<<"Yes";
    else if(s[0]==s[3]&&s[1]==s[2]&&s[3]!=s[2])cout<<"Yes";
    else cout<<"No";
}

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

public class Main{


    static int gcd(int x, int y){return y==0?x:gcd(y, x%y);}
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int a=0, n = in.nextInt();
        for (int l = 0; l < n; ++l){
            a=gcd(a, in.nextInt());
        }
        System.out.println(a);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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: 36280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  if(A % 2 == 0){
  cout << A*A/4;
  }else{
    int D;
    D = A / 2;
  cout << D * (D+1);
  }
}


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

using namespace std;

int main(){

    int N;
    cin >> N;

    map <char, int> M;
    for (int i = 0; i < N; i++){
        string S;
        cin >> S;

        map <char, int> m;
        
        for (int j = 0; j < S.length(); j++){
            m[S[j]]++;
        }

        if (i == 0){
            M = m;
        }else{
            for (int j = 'a'; j <= 'z'; j++){
                if (m[j] < M[j]){
                    M[j] = m[j];
                }
            }
        }
    }

    for (int i = 'a'; i <= 'z'; i++){
        if (M[i] > 0){
            for (int j = 0; j < M[i]; j++){
                char a = i;
                cout << a;
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256