akhauriyash/Code-Regression huggingface dataset:
let n = read_int () in
let judge i =
    let rec loop i flag =
        if i = 0 then (flag = 7) else
            let flag = match i mod 10 with
            | 3 -> flag lor 1
            | 5 -> flag lor 2
            | 7 -> flag lor 4
            | _ -> flag
            in
            loop (i / 10) flag
    in
    loop i 0
in
let rec loop i acc =
    if i > n then acc else
        let acc = if judge i then acc + 1 else acc in
        let acc = loop (i * 10 + 3) acc in
        let acc = loop (i * 10 + 5) acc in
        let acc = loop (i * 10 + 7) acc in
        acc
in
loop 0 0 |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main(){
    int H, W;
    while (true){
        cin >> H >> W;
        if (H == 0 && W == 0)break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))

ans = 0
isExit = 0
while isExit != 1:
    for i in range(N):
        if A[i] % 2 == 1:
            isExit = 1
        A[i] //= 2
    if isExit == 0:
        ans += 1 

print(ans)


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

int main(){
  int tile=0;
  string S;
  cin >> S;
  
  for(int i=0; i<S.length(); i++){
    if(i%2 == 0 && S[i] == '1') tile++;
    if(i%2 == 1 && S[i] == '0') tile++;
  }
  
  int other=S.length();
  other-=tile;
  
  cout << min(tile,other) << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll n; cin >> n;
  ll a = n/500;
  ll b = (n%500)/5;
  cout << a*1000 + b*5 << endl;
  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++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main()
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    }
    else {
      while (x != 0) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        else
          x = x / 10;
      }
    }
  }
  cout << endl;
}



Measured memory_bytes: 3092
using System;
class Program
{
  static void Main(string[] args)
  {
    // 入力値を取得
    int n = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] array = new int[n-1];
    for (int i = 0; i < n-1; i++){
      array[i] = int.Parse(input[i]);
    }
    
    int sum = 0;
    for (int j = 0; j < n-1; j++)
    {
      if (j == 0)
      {
        sum += array[j];
      }
      else
      {
        sum += (array[j] <= array[j-1]) ? array[j] : array[j-1];
      }
    }
    sum += array[n-2];
    Console.WriteLine(sum);
  }
}

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

int main() {
	int cups[3] = {0};
	cups[0] = 1;
	char c[5];
	while(scanf("%s", c) != EOF){
		int l = c[0] - 'A', r = c[2] - 'A';
		swap(cups[l], cups[r]);
	}
	for(int i = 0; i < 3; ++i){
		if(cups[i]){
			printf("%c\n", i + 'A');
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1124
// Problem : D - Median of Medians
// Contest : AtCoder Regular Contest 101
// URL : https://atcoder.jp/contests/arc101/tasks/arc101_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using ll = long long;
using namespace std;
#define cerr if(1)cerr
#define size(x) (int)x.size()
 
const int N = 1e5 + 1, inf = 1e9;																																																																																								void read(int&n){n=0;while(1){char c=getchar();if(c==' '||c=='\n')break;n=(n<<1)+(n<<3)+c-'0';}}void read(ll&n){n=0;while(1){char c=getchar();if(c==' '||c=='\n')break;n=(n<<1)+(n<<3)+c-'0';}}void write(int n){if(n>9)write(n/10),putchar(n%10+'0');else putchar(n+'0');}void write(ll n){if(n>9)write(n/10),putchar(n%10+'0');else putchar(n+'0');}template<class F,class... Ts>void read(F&f,Ts&...ts){read(f);read(ts...);}template<class F,class... Ts>void write(F&f,Ts&...ts) {write(f);putchar(' ');write(ts...);}template<class...Ts>void writeln(const Ts&...ts){write(ts...);putchar('\n');}

int n, r[N], a[N], _cnt[2 * N + 1];
int* cnt = _cnt + N;
vector<int> v;

bool wrong(int k) {
	ll ans = 0;
	for (int i = -n; i <= n; i++) {
		cnt[i] = 0;
	}
	k++;
	int now = 1, sum = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] >= k) {
			sum++;
			now += cnt[sum];
		} else {
			now -= cnt[sum];
			sum--;
		}
		cnt[sum]++;
		ans += now;
		now++;
	}
	return 1ll * n * (n + 1) / 2 - ans >= 1ll * n * (n + 1) / 4 + 1;
}
 
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		v.push_back(a[i]);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (int i = 1; i <= n; i++) {
		int ma = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
		r[ma] = a[i];
		a[i] = ma;
	}
	int ans = 0;
	for (int j = log2(n); j >= 0; j--) {
		ans += 1 << j;
		if (wrong(ans)) {
			ans -= 1 << j;
		}
	}
	write(r[ans + 1]);
}

Measured memory_bytes: 2296
let () =
  let n,x = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec aux res prev = function
      [] -> res
    | hd :: tl -> 
      let sum = prev+hd in
      if sum<=x then aux res hd tl else
        let d = sum-x in
        aux (res+d) (hd-d) tl 
  in
  Printf.printf "%d\n" @@
  aux 0 0 a_lst


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

int main() {
  int n;
  cin>>n;
  vector<int> d(n),f(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  for(int i=0;i<n;i++){
    cin>>f[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(d[i]-f[i]>0){
      ans+=d[i]-f[i];
    }
  }
  cout<<ans<<endl;
}
           

Measured memory_bytes: 256
#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;


int main(){
    int n;
    cin >> n;
    bool ok = true;
    vector<string> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    REP(i, n){
        bool fin = false;
        if (i != 0){
            if (a[i][0] != a[i - 1][a[i - 1].size() - 1]){
                ok = false;
                break;
            }
            REP(j, i -1){
                if (a[j] == a[i]){
                    ok = false;
                    fin = true;
                    break;
                }
            }
        }
    if (fin) break;
    }
    
    if(ok) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		Set<Integer> waters = new HashSet<>();
		Set<Integer> sugers = new HashSet<>();
		for(int i = 0 ; 100 * a * i <= f ; i++) {
			for(int j = 0 ; 100 * a * i + 100 * b * j <= f ; j++) {
				waters.add(100 * a * i + 100 * b * j);
			}
		}
		for(int i = 0 ; i * c <= f ; i++) {
			for(int j = 0 ; i * c + j * d <= f ; j++) {
				sugers.add(i * c + j * d);
			}
		}
		int wa = 1, su = -1;
		for(int water : waters) {
			for(int suger : sugers) {
				if(suger + water <= f && su * water < suger * wa && e * water >= 100 * suger) {
					wa = water;
					su = suger;
				}
			}
		}
		System.out.println(su + wa + " " + su);
	}
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    for (Int i = 1; i <= n; i++) {
        Int res = 0;
        for (Int a = 1; a * a <= i; a++) {
            for (Int b = 1; a * a + b * b + a * b <= i; b++) {
                for (Int c = 1; a * a + b * b + c * c + a * b + b * c + c * a <= i; c++) {
                    if (a * a + b * b + c * c + a * b + b * c + c * a == i) res++;
                }
            }
        }
        print(res);
    }
    return 0;
}

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

using ll = long long;

constexpr ll INF = 1e18;

map<string, set<pair<ll, ll>>> arr;
map<string, ll> arr_size;

bool program(string const& s, int& p);
bool declaration(string const& s, int& p);
bool assignment(string const& s, int& p);
ll expression(string const& s, int& p);
string array_name(string const& s, int& p);
ll number(string const& s, int& p);

bool program(string const& s, int& p) {
    if(s.find('=') == string::npos) {
        return declaration(s, p);
    } else {
        return assignment(s, p);
    }
}

bool declaration(string const& s, int& p) {
    string name = array_name(s, p);
    arr_size[name] = number(s, ++p);
    return false;
}

bool assignment(string const& s, int& p) {
    string name = array_name(s, p);
    ll idx = expression(s, ++p);
    if(arr_size[name] <= idx) {
        return true;
    }
    p += 2; // equal
    ll val = expression(s, p);
    if(val == INF) {
        return true;
    }
    auto it = arr[name].lower_bound(make_pair(idx, -1));
    if(it != arr[name].end() && it->first == idx) {
        arr[name].erase(it);
    }
    arr[name].insert(make_pair(idx, val));
    return false;
}

ll expression(string const& s, int& p) {
    if(isdigit(s[p])) {
        return number(s, p);
    }
    string name = array_name(s, p);
    ll idx = expression(s, ++p);
    if(arr_size[name] <= idx) {
        return INF;
    }
    auto it = arr[name].lower_bound(make_pair(idx, -1));
    if(it == arr[name].end() || it->first != idx) {
        return INF;
    }
    ++p;
    return it->second;
}

string array_name(string const& s, int& p) {
    string res;
    while(isalpha(s[p])) {
        res += s[p++];
    }
    return res;
}

ll number(string const& s, int& p) {
    ll res = 0;
    while(isdigit(s[p])) {
        res *= 10;
        res += s[p++] - '0';
    }
    return res;
}

int main() {
    string s;
    vector<string> v;
    while(getline(cin, s)) {
        if(s[0] == '.') {
            if(v.size() == 0) {
                break;
            }
            int res = 0;
            for(int i=0; i<v.size(); ++i) {
                int p = 0;
                if(program(v[i], p)) {
                    res = i+1;
                    break;
                }
            }
            cout << res << endl;
            v.clear();
            arr.clear();
            arr_size.clear();
            continue;
        }
        v.push_back(move(s));
    }
}


Measured memory_bytes: 3216
x, n = map(int, input().split())
if n > 0:
    l = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if not (x - i) in l:
            ans = x - i
            break
        elif not x + i in l:
            ans = x + i
            break
    print(ans)
else:
    print(x)

Measured memory_bytes: 9124
use std::io::*;
use std::str::FromStr;
use std::clone::Clone;

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")
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,  
    size: Vec<usize>
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut vec = vec![0; n];
        for i in 0..n {
            vec[i] = i;
        }
        UnionFind {
            par: vec, 
            rank: vec![0; n], 
            size: vec![1; n]
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.find(p);
            self.size[x] = self.size[pp];
            self.par[x] = pp;
            pp
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let p_x = self.find(x);
        let p_y = self.find(y);
        if p_x != p_y {
            self.size[p_x] += self.size[p_y];
            self.size[p_y] = self.size[p_x];
            if self.rank[p_x] < self.rank[p_y] {
                self.par[p_x] = p_y;
            } else {
                self.par[p_y] = p_x;
                if self.rank[p_x] == self.rank[p_y] {
                    self.rank[p_x] += 1;
                }
            }
        }
    }

    fn are_same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}

#[derive(Clone)]
struct Edge {
    from: usize, 
    to: usize, 
    cost: u32
}

fn main() {
    let V: usize = read();
    let E: usize = read();
    let mut edges: Vec<Edge> = vec![
        Edge{ from: 0, to: 0, cost: 0 }; E
    ];

    for i in 0..E {
        edges[i].from = read();
        edges[i].to = read();
        edges[i].cost = read();
    }
    edges.sort_by(
        |e1, e2| { e1.cost.cmp(&e2.cost) }
    );

    let mut uf = UnionFind::new(V);
    let mut ans = 0;
    for edge in &edges {
        if !uf.are_same(edge.from, edge.to) {
            uf.unite(edge.from, edge.to);
            ans += edge.cost;
        }
    }

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


Measured memory_bytes: 9140
// 6/17 振り返り
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;

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

    ll res = 0;

    ll r, g, b;
    r = g = b = 0;

    // for (int i = 0; i < N; i++) {
    //     for (int j = i + 1; j < N; j++) {
    //         for (int k = j + 1; k < N; k++) {
    //             if (j - i == k - j) continue;
    //             if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) res++;
    //         }
    //     }
    // }

    for (auto s : S) {
        if (s == 'R') r++;
        else if (s == 'G') g++;
        else b++;
    }

    res = r * g * b;
    // cout << res << endl;

    // for (int delta = 1; delta <= (N + 1) / 2; delta++) {
    //     for (int i = 0; i + 2 * delta < N; i++) {
    //         // cout << "here?" << endl;
    //         int j = i + delta;
    //         int k = j + delta;
    //         // printf("i, j, k = %d, %d, %d\n", i, j, k);
    //         if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) res--;
    //     }
    // }

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = 2 * j - i;
            if (k < N) {
                if ((S[i] != S[j]) && (S[j] != S[k]) && (S[k] != S[i])) res--;
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3616
n, k = map(int, input().split())
mod = 10**9 + 7
def setFact(n, mod):
    global fact
    fact = [1]
    global ifact
    ifact = [1] * (n+1)
    for i in range(1, n+1):
        fact.append(fact[i-1]*i%mod)
    ifact[-1] = pow(fact[-1], mod-2, mod)
    for i in range(2, n+2):
        ifact[-i] = ifact[-i+1]*(n-i+2) %mod
def combination(n, k , mod):
    global fact
    global ifact
    if k < 0 or k > n:
        return 0
    else:
        return fact[n] * ifact[n-k] * ifact[k] % mod
setFact(n, mod)
ans = 0
for i in range(min(n+1, k+1)):
    ans += combination(n,i,mod) *combination(n-1,i, mod) %mod
    ans %= mod
print(ans)

Measured memory_bytes: 54256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),count=0;
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
            for(int j=n-1;j>i;j--){
                if(a[j-1]>a[j]){
                    int k=a[j-1];
                    a[j-1]=a[j];
                    a[j]=k;
                    count++;
                }
            }
        }
        System.out.print(a[0]);
        for(int i=1;i<n;i++){
            System.out.print(" "+a[i]);
        }
        System.out.println("\n"+count);
    }
}


Measured memory_bytes: 26336
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pc _putchar_nolock
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define inf (ll)9223372036854775807
#define sz(x) (int)x.size()
using namespace std;
using ll=long long int;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
void input(vector<int>&a,int n)
{
   rep(i,0,n-1)
   cin>>a[i];
}
int ce(int a,int b)
{
	if(a%b==0) return a/b; 
	return a/b+1; 
}
void solve()
{
 int n; cin>>n; map<string,int>g;
 while(n--)
 {
 	string s; cin>>s; g[s]++; 
 }
 cout<<"AC x "<<g["AC"]<<"\n"; 
 cout<<"WA x "<<g["WA"]<<"\n";
 cout<<"TLE x "<<g["TLE"]<<"\n";
 cout<<"RE x "<<g["RE"]<<"\n";
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  while(t--)
  {
	 solve();
  }
  return 0;
}


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

int n, q;
vector<vector<int>> g;
vector<int> sum;

void dfs(int now = 0, int par = -1);

int main() {
  cin >> n >> q;
  g.resize(n);
  sum.assign(n, 0);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    sum[--a] += b;
  }
  dfs();
  for (int i = 0; i < n; ++i) cout << sum[i] << " \n"[i == n - 1];
  return 0;
}

void dfs(int now, int par) {
  if (par >= 0) sum[now] += sum[par];
  for (auto to : g[now])
    if (to != par) dfs(to, now);
}

Measured memory_bytes: 24272
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector <int> dp(n,0);

    for(int i = 0; i < n; i++){
        if(i==0){
            dp[i]=0;
        }else if(i==1){
            dp[i] = abs(h[i]-h[i-1]);
        }else{
            int cost1 = abs(h[i]-h[i-1])+dp[i-1];
            int cost2 = abs(h[i]-h[i-2])+dp[i-2];
            dp[i] = min(cost1,cost2);
        }
    }
    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 4068
#pragma GCC optimze(3)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define Int const int
struct Seg_Tree{
	int Min,lazy;
}tree[MAXN<<2];
int N,Q,cnt,ans;
int a[MAXN],sum1[MAXN],sum0[MAXN];
vector < int > S[MAXN]; 
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
inline void push_down(Int root){
	tree[lson].lazy+=tree[root].lazy,
	tree[rson].lazy+=tree[root].lazy,
	tree[lson].Min+=tree[root].lazy,
	tree[rson].Min+=tree[root].lazy,
	tree[root].lazy=0;
}
inline void Insert(Int root,Int l,Int r,Int Pos,Int k){
	if(l==Pos && r==Pos){
		tree[root].Min=min(tree[root].Min,k);
		return ;
	}if(tree[root].lazy) push_down(root);
	if(Pos<=Mid) Insert(lson,l,Mid,Pos,k);
	else Insert(rson,Mid+1,r,Pos,k);
	tree[root].Min=min(tree[lson].Min,tree[rson].Min);
}
inline void Update(Int root,Int l,Int r,Int L,Int R,Int k){
	if(l>=L && r<=R){
		tree[root].lazy+=k,tree[root].Min+=k;
		return ;
	}if(tree[root].lazy) push_down(root);
	if(R<=Mid) Update(lson,l,Mid,L,R,k);
	else if(L>Mid) Update(rson,Mid+1,r,L,R,k);
	else Update(lson,l,Mid,L,R,k),Update(rson,Mid+1,r,L,R,k);
	tree[root].Min=min(tree[lson].Min,tree[rson].Min);
}
inline int Query(Int root,Int l,Int r,Int L,Int R){
	if(l>=L && r<=R) return tree[root].Min;
	if(tree[root].lazy) push_down(root);
	if(R<=Mid) return Query(lson,l,Mid,L,R);
	else if(L>Mid) return Query(rson,Mid+1,r,L,R);
	else return min(Query(lson,l,Mid,L,R),Query(rson,Mid+1,r,L,R));
}
int main(){
	N=read();for(register int i=1;i<=N;i++) 
	    a[i]=read(),sum1[i]=sum1[i-1]+(a[i]==1),sum0[i]=sum0[i-1]+(a[i]==0);
	Q=read();for(register int i=1;i<=Q;i++){
		int x=read(),y=read();
		S[x].push_back(y); 
	}for(register int i=0;i<600005;++i) tree[i].Min=1e9;
	Insert(1,0,N,0,0);
	for(register int i=1;i<=N;i++){
		for(register int j=0;j<S[i].size();j++) Insert(1,0,N,S[i][j],Query(1,0,N,0,S[i][j]));
		Update(1,0,N,0,i-1,a[i]?1:-1);
	}printf("%d",Query(1,0,N,0,N)+sum0[N]);
	return 0;
}

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

class Eratosthenes{ //NMAX変更しておｋ
    private:
        const static int NMAX = 200010;
        vector<bool> prime;
    
    public:
        Eratosthenes(){
            prime.resize(NMAX,true);//一旦全部trueとする(true=素数)
            prime[0] = false;
            prime[1] = false;
            for(int i=2;i*i<=NMAX;i++){
                if(prime[i]){
                    for(int j=2;i*j<=NMAX;j++) prime[i*j] = false;
                }
            }
        }

        inline vector<bool> get_prime(){ return prime; }
};
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    Eratosthenes e;
    vector<bool> Prime = e.get_prime();
    while(!Prime[x]) x++;
    cout << x << endl;
}

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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = end - 1; begin <= i; i--)		// repeat reverse

#endif

int main(void)
{
	string s; cin >> s;
	vector<ll> v(200);

	for (const auto& e : s)
		v[(ll)e]++;



	ll count = 0;
	for (const auto& e : v)
	{
		if (e == 2)
			count++;
	}



	if (count == 2)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ins(morty);
		int tmp =0;
		int rick = 0;
		FOR(i,0,morty.size()){
			if(morty[i] == 'A')tmp++;
			else{
				if(i<morty.size()-1 and morty[i] == 'B' and morty[i+1]== 'C'){
					rick+=tmp;
					i++;
				}
				else{
					tmp = 0;
				}
			}
			
		}
		out(rick);










	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 720
# 190915 D
import heapq
if __name__ == "__main__":
    N = list(map(int,input().split()))
    M = N[1]
    N = N[0]
    A = list(map(int,input().split()))
    for i in range(len(A)):
        A[i] = (-1) * A[i]
    heapq.heapify(A)
    for i in range(M):
        tmpa = heapq.heappop(A)
        heapq.heappush(A,int(tmpa / 2))
    print(-1*sum(A))
    

Measured memory_bytes: 14224
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val (a, b, c) = readLineInts()
    println(a * b / 2)
}

Measured memory_bytes: 38244
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    s, t = map(int, input().split())
    G[s].append(t)


def topological_sort(g):
    topological_list = []
    visited = set()

    def dfs(n):
        for e in g[n]:
            if e not in visited:
                dfs(e)
        topological_list.append(n)
        visited.add(n)

    for i in range(len(g)):
        if i not in visited:
            dfs(i)

    return topological_list[::-1]


print(*topological_sort(G), sep="\n")



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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        int a=Integer.parseInt(s[0]),b=Integer.parseInt(s[1]),h=Integer.parseInt(s[2]),m=Integer.parseInt(s[3]);
        double hr=0.5*(h*60+m),min=6*m,angle=Math.abs(hr-min);
        angle=Math.min(360-angle,angle);
        double d=Math.cos(Math.toRadians(angle));
        double ans=Math.sqrt(-2.0*a*b*d+a*a+b*b);
        System.out.print(ans);
    }
}


Measured memory_bytes: 33284
/*#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long>v[100009];
long long mod = 1000000007;
long long dp[100009][3];
void dfs(int node,int p){
	dp[node][0] = dp[node][1] = 1;
	for(int i=0;i<v[node].size();i++){
		int u = v[node][i];
		if(u == p)continue;
		dfs(u,node);
		dp[node][0] = (dp[node][0] * (dp[u][0] + dp[u][1])%mod)%mod;
		dp[node][1] = (dp[node][1] * dp[u][0])%mod;
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0,0);
	cout<<dp[0][0] + dp[0][1]<<endl;
}*/
#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long>v[100009];
long long dp[100009][3];
long long mod=1000000007;
long long bt(int node,int p,int t){
	long long &ret=dp[node][t];
	if(ret!=-1)return ret;
	ret=1;
	for(int i=0;i<v[node].size();i++){
		int u=v[node][i];
		if(u==p)continue;
		if(t==1)ret=(ret%mod*bt(u,node,0)%mod)%mod;
		else if(t==0)ret=(ret%mod*(bt(u,node,1)%mod+bt(u,node,0)%mod)%mod)%mod;
	}
	return ret%mod;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cout<<(bt(0,0,0)%mod+bt(0,0,1)%mod)%mod<<endl;
}


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

namespace ABC161
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_C();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var i = Ex.ReadIntArray();
            Ex.Cw($"{i[2]} {i[0]} {i[1]}");
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var l1 = Ex.ReadIntArray();
            var arr = Ex.ReadIntArray();
            // N 種類の商品
            var n = l1[0];
            // M個を選べる
            var m = l1[1];
            // 総投票数の1/4M未満である
            ulong d = 0;
            foreach (var v in arr) d += (ulong)(v / 4.0 / m);
            var c = arr.Count(v => d < (ulong)v);
            Ex.Cw(m <= c);
        }
        public void Cw(bool b)
        {
            if (b) Ex.Cw("Yes");
            else Ex.Cw("No");
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
            var l1 = Ex.ReadLongArray();
            // Nの初期値
            var n = l1[0];
            // Kの差の絶対値で置き換える
            var k = l1[1];

            var a = n % k;
            Ex.Cw(Math.Min(a, Math.Abs(a - k)));
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {

        }
    }
    public static class Ex
    {
        public static void Cw(object s)
        {
            Console.WriteLine(s);
        }
        public static void Cw(bool b)
        {
            if (b) Cw("Yes");
            else Cw("No");
        }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(s => int.Parse(s)).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(s => long.Parse(s)).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i, j, cnt=0;
	int p[200000];
	
	scanf("%d", &n);
	
	lop(i, n){
		scanf("%d", &p[i]);
	}
	
	int min=300000;
	lop(i, n){
		if(p[i]<=min){
			cnt++;
			min=p[i];
		}
	}
	
	printf("%d", cnt);
	
return 0;
}

Measured memory_bytes: 896
def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    tmp = [[] for i in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        tmp[a-1].append(b-1)
        tmp[b-1].append(a-1)

    ans = 0
    # print(tmp)
    for i, aa in enumerate(tmp):
        hh = h[i]
        if len(aa) == 0:
            ans += 1
            continue
        flg = True
        for j, h2 in enumerate(aa):
            h2 = h[h2]
            if hh > h2:
                continue
            else:
                flg = False
                break
        if flg :
            ans += 1
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 29428
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    //int a[n];
    int mi=1000000;
    int ma=-1000000;
    long num=0;
    for(int i=0; i<n; i++){
        int m;
        cin>>m;
        num+=m;
        if(ma<m)    ma=m;
        if(mi>m)    mi=m;
    }
    cout<<mi<<" "<<ma<<" "<<num<<endl;
    return 0;
}


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

int main() {
  int n;
  string s;
  string t;

  cin >> n;
  cin >> s;
  cin >> t;

  for (int i = 0; i < n; i++) {
      cout << s.at(i);
      cout << t.at(i);
  }

  cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace my_originalprogram
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = x[0];
            int b = x[1];
            int c = x[2];
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 18228
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	int ans=1e18;
	for(int i=1;i*i<=n;++i){
		if(n%i==0){
			int j=n/i;
			ans=min(ans,i-1+j-1);
		}
	}  
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod = pow(10, 9) + 7;
long long pow_mod(long long a, long long b) {
    if (b == 0) return 1;
    long long k = pow_mod(a, b/2);
    long long kk = k * k % mod;
    if (b & 1) {
        return  kk * a % mod;
    }
    else {
        return kk;
    }
}
int MA = pow(10, 6);
vector<bool> pf(MA + 1, true);
vector<long long> P;
int main () {
    pf[0] = pf[1] = false;
    for (int i = 2; i <= MA; i++) {
        if (pf[i]) {
            P.push_back(i);
            for (int j = i + i; j <= MA; j+=i) {
                pf[j] = false;
            }
        }
    }
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += pow_mod(A[i], mod-2);
        ans %= mod;
    }
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        long long k = A[i];
        for (auto p: P) {
            if (pf[k]) {
                mp[k] = max(mp[k], 1);
                break;
            }
            int c = 0;
            while (k % p == 0) {
                c++;
                k /= p;
            }
            mp[p] = max(mp[p], c);
            if (k == 1) break;
        }
    }
    for (auto x: mp) {
        ans *= pow_mod(x.first, x.second);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
typedef std::vector<int> IntVector;
typedef std::list<int> IntList;

using namespace std;
  
int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;

  
  
  cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define subset(i,S) for (int i=(S); i; i=(i-1)&(S))
using namespace std;

const int maxn = 16;
int f[1<<maxn][maxn], cost[1<<maxn], w[maxn][maxn];
int n, m, a, b, c, S, total;

void init() {
	rep (i, 1, (1<<n)-1) 
		rep (x, 0, n-1) if (i>>x&1)
			rep (y, x+1, n-1) if (i>>y&1)
				cost[i] += w[x][y];
}

int main() {
	scanf("%d%d", &n, &m);
	rep (i, 1, m) {
		scanf("%d%d%d", &a, &b, &c); a--; b--;
		w[a][b] = w[b][a] = c; total += c;
	}
	init();
	memset(f, -1, sizeof f);
	f[1][0] = 0;
	rep (i, 1, (1<<n)-1)
		rep (j, 0, n-1) if ((i>>j&1) && ~f[i][j]) {
			S = (((1<<n)-1)^i)|(1<<j);
			subset (s, S) f[i|s][j] = max(f[i|s][j], f[i][j] + cost[s]);
			rep (k, 0, n-1) if (!(i>>k&1) && w[j][k]) f[i|(1<<k)][k] = max(f[i|(1<<k)][k], f[i][j] + w[j][k]);
		}
	printf("%d\n", total - f[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 4480
parse_input(type=String, x=readline()) = begin
  type == String && return x
  parse(type, x)
end
parse_inputs(type=String) = parse_input.(type, split(readline()))

function solve()
  d, t, s = parse_inputs(Int)
  d/s <= t && return "Yes"
  "No"
end

println(solve())


Measured memory_bytes: 178964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,m,c,b[22],a[22][22],kari,ans=0;
  cin>>n>>m>>c;
  fr(i,m) cin>>b[i];
  fr(i,n) fr(j,m) cin>>a[i][j];
  fr(i,n){
    kari=c;
    fr(j,m) kari+=b[j]*a[i][j];
    if(kari>0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;


ll dp[1005][1005];

void solve(){
    int h,w;
    cin>>h>>w;
    vector<string>v(h);
    rep(i,h){
        cin>>v[i];
    }
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(v[i][j]!='#'){
                if(i!=0)dp[i][j]+=dp[i-1][j];
                if(j!=0)dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

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


int main(){

  int M;
  char N[100];
  scanf("%s",N);

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */
  M = strlen(N);
  int i;
  int counter;
  counter = 0;
  for (i=0;i<(M-1)/2;i++){
   if(N[i] != N[M-1-i]){
     printf("No");
     return(0);
   }
  }
   if(M == 3){
     printf("Yes");
     return(0);
  }
   else if(M == 5){
     if(N[0]==N[1] && N[3]==N[4]){
     printf("Yes");
       return(0);
     }
     else{
       printf("No");
       return(0);
     }
   }
 else if(M==7){
     if(N[0]==N[2] && N[4]==N[6]){
  printf("Yes");
       return(0);
     }
     else{
       printf("No");
       return(0);
     }
   }
 else{}
  
  if(((M-1)/2)%2 == 1){
  int A,B;
  A = (M-1)/2;
  B = (M+3)/2;
  for (i=0;i<(A-1)/2;i++){
   if(N[i] != N[A-1-i]){
     counter=1;;
   }
   else{}
  }
  
  for (i=B-1;i<M-(A+3)/2;i++){
   if(N[i] != N[M-1-i]){
     counter=1;;
   }
  else{}
  }

  if(counter == 0){
    printf("Yes");
       return(0);
  }
  else{
    printf("No");
       return(0);
  }
  }
  else{
int A,B;
  A = (M-1)/2;
  B = (M+3)/2;
  for (i=0;i<A/2;i++){
   if(N[i] != N[A-1-i]){
     counter=1;;
   }
   else{}
  }
  
  for (i=B-1;i<M-A/2;i++){
   if(N[i] != N[M-1-i]){
     counter=1;;
   }
  else{}
  }

  if(counter == 0){
    printf("Yes");
       return(0);
  }
  else{
    printf("No");
       return(0);
  }
  }


  





 return(0);
 }


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

signed main(){
	int N,M,X; cin>>N>>M>>X;
	set<int> A;
	for(int i=0;i<M;i++){
		int a; cin>>a; A.insert(a);
	}
	int ans1=0,ans2=0;
	for(int i=X;i>=0;i--){
		ans1+=A.count(i);
	}
	for(int i=X;i<N;i++){
		ans2+=A.count(i);
	}
	cout<<min(ans1,ans2)<<endl;

}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().strip().split()))

Alice = 0
Bob = 0

for i in range(N):
    maxa = max(a)
    a.remove(maxa)
    if i % 2 == 0:
        Alice += maxa
    else:
        Bob += maxa

ans = Alice - Bob
print(ans)

Measured memory_bytes: 3060
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <math.h>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vlu = vector<lu>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l      INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l      e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
  e8 = 10 * e7, e9 = 10 * e8, l0 = 0, l1 = 1, l2 = 2;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)

void solve(istream &in, ostream &out);
void solve_brute(istream &, ostream &);
bool interactive_judge(istream &, istream &, ostream &);
bool generate_random(l, ostream &);
bool solution_checker(istream &, istream &, istream &, ostream &);
int  main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _judge = interactive_judge;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7;  // end of template

void solve(istream &in, ostream &out) {
  l m, d;
  in >> m >> d;
  l z = 0;
  F(i, 1, d + 1) {
    l a = i % 10;
    l b = i / 10;
    if (a > 1 and b > 1) {
      if (a * b <= m) z++;
    }
  }
  out << z << lf;
}


Measured memory_bytes: 256
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c] = input.trim().split(" ");
  return a == b ? c : a == c ? b : a;
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29456
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct Task {
    int A, B;

    Task(int _A, int _B){
        A = _A;
        B = _B;
    }
};

bool cmp(const Task &a, const Task &b){
    return a.B < b.B;
}

int main() {
    int N;

    cin >> N;

    vector<Task> tasks;

    int A, B;

    for(int i = 0; i < N; i++){
        cin >> A >> B;
        // この時点でおわ
        if(A > B){
            cout << "No" << endl;
            return 0;
        }
        tasks.push_back(Task(A, B));
    }

    sort(tasks.begin(), tasks.end(), cmp);

    int sum = 0;

    for(int i = 0; i < N; i++){
        sum += tasks[i].A;
        if(sum > tasks[i].B){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
using namespace std;
int sumDig(int num) {
    int ans = 0;
    while (num > 0) {
        ans += num % 10;
        num /= 10;
    }
    return ans;
}
int main() {
    int N;
    cin >> N;
    int ans = N + 1;
    for (int i = 1; 2 * i <= N; i++) {
        ans = min(ans, sumDig(i) + sumDig(N - i)); 
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,p=2,x;
    cin>>a>>b;
    if(b==1)
    {
        cout<<"0";
        return 0;
    }
    if(b>a)
    {
    if(b-a<a-1)
    {
        x=(b-a)/(a-1)+2;
        cout<<x;
    }
    else if((b-a)/(a-1)>0&&(b-a)%(a-1)!=0)
    {
        x=(b-a)/(a-1)+2;
        cout<<x;
    }
    else if((b-a)/(a-1)>0&&(b-a)%(a-1)==0)
    {
         x=(b-a)/(a-1)+1;
        cout<<x;
    }
    }
    else if(b<=a)
    {
        cout<<"1";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e5+1;
vector<int>gp[maxn];
ll dp[2][maxn];
int n;
void dfs(int n,int p)
{
	for(auto& u : gp[n])
	{
		if(u==p)continue;
		dfs(u,n);
	}
	if(gp[n].size()==1&&gp[n][0]==p)
	{
		dp[0][n]=1;
		dp[1][n]=1;
	}	
	else
	{
		dp[0][n]=dp[1][n]=1;
		for(auto& u : gp[n])
		{
			if(u==p)continue;
			dp[1][n]=(dp[1][n]*dp[0][u])%mod;
			dp[0][n]=(dp[0][n]*((dp[0][u]+dp[1][u])%mod))%mod;
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;cin>>x>>y;
		gp[x].push_back(y);
		gp[y].push_back(x);
	}
	dfs(1,-1);
	cout<<(dp[0][1]+dp[1][1])%mod<<endl;
	return 0;
}

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

int main () {
    int N;
    cin >> N;
    string S;
    for (int i = 0; i < N ; i++) {    
        cin >> S;
        if (S == "Y") {
            break;
        }    
    }
    if (S == "Y") {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    } 
    
}

Measured memory_bytes: 256