akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd
n,k = map(int,input().split( ))
a = list(map(int, input().split( )))

#ボールは消費しない
g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
    #print(g)

if k%g==0 and k<=max(a):##
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 88172
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
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(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;
ll NN = 1000000000+7;
int main(){
    ll N,K;
    cin >>N>>K;
    ll ans;
    ans =0;
    rep2(i,K,N+2){
        ans += (N+1-i)*i +1;
        ans %= NN;
    }
    cout <<ans << endl;;

}

Measured memory_bytes: 3628
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

fn main() {
    let n: usize = read();
    let max = 55555;
    let mut isprime = vec![true; max];
    let mut ans: Vec<usize> = vec![];
    for i in 2..max {
        if isprime[i] {
            let mut j = i * 2;
            while j < max {
                isprime[j] = false;
                j += i;
            }
            if i % 5 == 1 {
                ans.push(i);
            }
        }
    }

    for i in 0..n {
        if i >= 1 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}


Measured memory_bytes: 4352
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 101010;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int h,w,k,mn;
    cin >> h >> w >> k;
    mn = h+w;
    string t[10];
    for (int i = 0;i < h;++i) cin >> t[i];
    for (int s = 0;s < (1<<(h-1));++s) {
        int sum[10],ans = 0,idx[10],c = 0;
        for (int i = 0;i < 10;++i) sum[i] = 0;
        for (int i = 0;i < 10;++i) idx[i] = 0;
        for (int i = 0;i < h;++i) {
            idx[i] = c;
            if ((s>>i)&1) {c++;ans++;}
        }
        for (int i = 0;i < w;++i) {
            bool f = false;
            for (int j = 0;j < h;++j) {
                if (t[j][i] == '1') {
                    sum[idx[j]]++;
                    if (sum[idx[j]] > k) f = true;
                }
            }
            if (f) {
                f = false;
                ans++;
                for (int j = 0;j < h;++j) sum[j] = 0;
                for (int j = 0;j < h;++j) {
                    if (t[j][i] == '1') {
                        sum[idx[j]]++;
                        if (sum[idx[j]] > k) f = true;
                    }
                }   
            }
            if (f) {
                ans = 1000000;
                break;
            }
        }
        mn = min(mn,ans);
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u64,
        k: u64,
    }
    println!("{}",
        k * (k-1).pow((n-1) as u32));
}


Measured memory_bytes: 4352
class PriorityQueue
  def initialize
    @heap = []
  end

  def push value
    @heap.push value
    update_heap_to_up
  end

  def empty?
    @heap.empty?
  end

  def shift
    min, last = @heap[0], @heap.pop
    unless @heap.empty?
      @heap[0] = last
      update_heap_to_down
    end
    min
  end

  alias pop shift

  private

  def update_heap_to_up
    index    = @heap.size - 1
    up_value = @heap[index]
    while 0 <= (parent_index = (index - 1) / 2)
      parent_value = @heap[parent_index]
      break if parent_value <= up_value

      @heap[index] = parent_value
      index        = parent_index
    end
    @heap[index] = up_value
  end

  def update_heap_to_down
    index      = 0
    down_value = @heap[0]
    size       = @heap.size
    while (child_index = 2 * index + 1) < size
      # 右の子がいて、右の子が小さければ、右の子を使う
      child_index += 1 if child_index + 1 < size and @heap[child_index + 1] < @heap[child_index]
      child_value = @heap[child_index]
      break if down_value <= child_value

      @heap[index] = child_value
      index        = child_index
    end
    @heap[index] = down_value
  end
end

MAX_V = 50 # 制約の最大値。
MAX_S = MAX_V * 50 + 5
INF   = Float::INFINITY

#　頂点
Edge = Struct.new(:to, :a, :b)
#　両替所
Exchange = Struct.new(:v, :s, :x) do
  include Comparable
  def <=>(other)
    self.x <=> other.x
  end
end

g    = Array.new(MAX_V) { Array.new { Edge.new } }
dist = Array.new(MAX_V) { Array.new(MAX_S + 5) { INF } }

def input
  gets.split.map &:to_i;
end

# メイン
n, m, s = input
#　都市の入力
m.times do
  u, v, a, b = input
  u          = u.pred
  v          = v.pred
  g[u] << Edge.new(v, a, b)
  g[v] << Edge.new(u, a, b)
end

# プライオリティキューのライブラリを利用
# require 'pqueue'
# 銀貨は最大でもMAX_S
s = [s, MAX_S].min
# プライオリティーキュー
q = PriorityQueue.new
# 入力用ラムダ
push = lambda { |v, s, x|
  return if s < 0
  return if dist[v][s] <= x

  dist[v][s] = x
  q.push(Exchange.new(v, s, x))
}

c = []
d = []
n.times do |i|
  cc, dd = input
  c[i]   = cc
  d[i]   = dd
end
push.call(0, s, 0)
until q.empty?
  hoge = q.pop
  v    = hoge.v; s = hoge.s; x = hoge.x
  next if dist[v][s] != x

  ns = [s + c[v], MAX_S].min
  push.call(v, ns, x + d[v])

  g[v].each do |e|
    push.call(e.to, s - e.a, x + e.b)
  end
end


(1 ... n).each do |i|
  ans = INF
  (0 ... (MAX_S + 5)).each do |j|
    ans = [ans, dist[i][j]].min
  end
  puts ans
end


Measured memory_bytes: 21520
#include <algorithm>
    #include <climits>
    #include <cmath>
    #include <iomanip>
    #include <iostream>
    #include <limits>
    #include <map>
    #include <memory>
    #include <numeric>
    #include <queue>
    #include <set>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <vector>
     
    constexpr long long MOD = 1000000007;
     
    int main()
    {
      int N, M;
      std::cin >> N >> M;
      std::vector<long long> S(N), T(M);
      for (auto& val: S)
        std::cin >> val;
      for (auto& val: T)
        std::cin >> val;
      std::vector<std::vector<long long>> dp(N, std::vector<long long>(M, 0));
      std::vector<std::vector<long long>> acc(N, std::vector<long long>(M, 0));
      dp[0][0] = S[0] == T[0] ? 1 : 0;
      acc[0][0] = dp[0][0] + 1;
      for (int i = 1; i < N; ++i)
      {
        dp[i][0] = S[i] == T[0] ? 1 : 0;
        acc[i][0] = (acc[i - 1][0] + dp[i][0]) % MOD;
      }
      for (int j = 1; j < M; ++j)
      {
        dp[0][j] = S[0] == T[j] ? 1 : 0;
        acc[0][j] = (acc[0][j - 1] + dp[0][j]) % MOD;
      }
     
      for (int i = 1; i < N; ++i)
      {
        for (int j = 1; j < M; ++j)
        {
          if (S[i] == T[j])
          {
            dp[i][j] = acc[i - 1][j - 1];
            acc[i][j] = (acc[i][j - 1] + acc[i - 1][j]) % MOD;
          }
          else
          {
            dp[i][j] = 0;
            acc[i][j] = ((acc[i][j - 1] + acc[i - 1][j]) - acc[i - 1][j - 1]) % MOD;
            if (acc[i][j] < 0)
              acc[i][j] += MOD;
          }
        }
      }
      std::cout << acc.back().back() % MOD << std::endl;
      return 0;
    }
     

Measured memory_bytes: 62976
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }

int a[1000][1000], dp[1000][1000];
int main() {
	int h, w, n;
	while (reader(&h, &w, &n), h) {
		rep(i, h)rep(j, w) {
			reader(&a[i][j]);
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] >> 1;
				else dp[i][j] += (dp[i - 1][j] + 1) >> 1;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) >> 1;
				else dp[i][j] += dp[i][j - 1] >> 1;
			}
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if (dp[x][y] & 1)a[x][y] = !a[x][y];
			if (a[x][y])y++;
			else x++;
		}
		writer(x + 1, ' '); writer(y + 1, '\n');
	}
}

Measured memory_bytes: 10712
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0) continue;
    if ( color[v] == WHITE )
      dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs() {
  int u;
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;

  for ( u = 0; u < n; u++ )
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( u = 0; u < n; u++ )
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

int main() {
  int u, v, k, i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ ) M[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2056
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;



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

	ll S = 0;
	unordered_map<ll, ll> cnt;
	ll A;
	for (int i=0; i<N; i++) {
		cin >> A;
		S += A;
		cnt[A]++;
	}

	int Q;
	cin >> Q;
	ll B, C;
	for (int i=0; i<Q; i++) {
		cin >> B >> C;
		ll cnt_B = cnt[B];
		ll cnt_C = cnt[C];
		S -= B * cnt_B;
		S += C * cnt_B;
		cnt[B] = 0;
		cnt[C] = cnt_B + cnt_C;

		cout << S << endl;
	}



	return 0;
}

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

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

string s;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> s;
    cout << s << (s[s.length()-1] == 's' ? "es" : "s") << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define N 5010
using namespace std;
char in[N+N],out[N];
int id[N],nid[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",in);
	for(int i=n;i<n+n;i++) in[i]=in[i-n];
	reverse(in+n,in+n*2);
	if(k>1) reverse(in,in+n*2);
	for(int i=0;i<=n;i++){
		id[i]=i;
	}
	for(int i=n-1;i>=0;i--){
		int cnt[26]={};
		for(int j=0;j<=n;j++){
			cnt[in[j+i]-'a']++;
		}
		for(int j=1;j<26;j++) cnt[j]+=cnt[j-1];
		for(int j=n;j>=0;j--){
			int cur=in[id[j]+i]-'a';
			nid[--cnt[cur]]=id[j];
		}
		for(int j=0;j<=n;j++) id[j]=nid[j];
	}
	for(int i=0;i<n;i++) out[i]=in[id[0]+i];
	int pl=1;
	for(int i=1;out[i]==out[i-1];i++) pl++;
	char *rem=out+pl;
	while(k>1&&pl<n){
		pl*=2;
		k--;
	}
	for(int i=0;i<min(n,pl);i++) putchar(out[0]);
	rem[max(n-pl,0)]=0;
	puts(rem);
	return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;
map<ll, ll> a;
ll dp[(ll)1e5 + 1];

signed main() {
    cin >> N >> M;
    REP(i, M) a[IN()]++;
    dp[0] = 1;
    if(a[1] == 0) dp[1] = 1;
    REP(i, N) {
        if(a[i + 2] == 0) {
            (dp[i + 2] = dp[i + 1] % MOD + dp[i] % MOD) %= MOD;
        }
    }
    cout << dp[N] << "\n";
}


Measured memory_bytes: 7296
package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	v := make([][]int, n)
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			v[u-1] = append(v[u-1], nextInt())
		}
	}

	for _, vvs := range v {
		for j := 1; j <= n; j++ {
			if j > 1 {
				fmt.Fprint(w, " ")
			}
			p := sort.SearchInts(vvs, j)
			if p < len(vvs) && vvs[p] == j {
				fmt.Fprint(w, 1)
			} else {
				fmt.Fprint(w, 0)
			}
		}
		fmt.Fprintln(w)
	}

	w.Flush()
}



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

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    int type[N];
    
    REP(init,4){
        type[0] = init % 2;
        type[1] = init / 2;
        
        FOR(i,2,N){
            if( type[i-1] == 0 ){
                // 左が羊
                
                type[i] = s[i-1] == 'o' ? type[i-2] : 1 - type[i-2];
                
            }else{
                // 左が狼
                
                type[i] = s[i-1] == 'x' ? type[i-2] : 1 - type[i-2];
            }
        }
        
        char c0;
        if( type[0] == 0 ){
            c0 = type[1] == type[N-1] ? 'o' : 'x';
        }else{
            c0 = type[1] != type[N-1] ? 'o' : 'x';
        }
        
        char c1;
        if( type[N-1] == 0 ){
            c1 = type[N-2] == type[0] ? 'o' : 'x';
        }else{
            c1 = type[N-2] != type[0] ? 'o' : 'x';
        }
        
        if( c0 == s[0] && c1 == s[N-1]){
            REP(i,N)
                cout << (type[i] == 0 ? 'S' : 'W') ;
            cout << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
    
    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
  string s;
  cin >> s;
// 7654321
  string date[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int datenum[] = {7,6,5,4,3,2,1};
  for(int i=0; i<7; i++){
    if( date[i] == s ){
      cout << datenum[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 888
from heapq import heappush, heappop
from collections import defaultdict

N = int(input())

def primeFactorization(N):
    primes = defaultdict(int)
    R = int(N**(0.5)) + 1
    for num in range(2, R):
        while N % num == 0:
            N //= num
            primes[num] += 1
    if N > 1 :
        primes[N] = 1
    return primes

primes = primeFactorization(N).keys()

que = []
for p in primes:
    heappush(que, (p, p))

ans = 0
while que and N > 0:
    z, p = heappop(que)
    if N % z == 0:
        ans += 1
        N //= z

        heappush(que, (z * p, p))

print(ans)


Measured memory_bytes: 9724
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  int ans = 0;
  rep(i, N) if(h[i] >= K) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
   int H,N;
   cin>>H>>N;
   int sum=0;
   for(int i=0;i<N;i++){
       int A;
       cin>>A;
       sum+=A;
   }
   if(H-sum<=0){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}


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

int main(){
  int a,b;
  string s;
  int check = 1;
  cin >> a >> b >> s;
  for(int i=0;i<a+b+1;i++){
    if(i < a || i > a){
      if(s[i] == '-'){
        check = 0;
      }
    }
    if(i == a){
      if(s[i] != '-'){
        check = 0;
      }
    }
  }
  if(check == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
#define int long long
#define pb push_back 

int n;
vector<int> h;
int dp[100001];
int v[100001];

int s1(int i){
	if(i==n-1){
		return abs(h[n]-h[i]);
	}
	if(i==n-2){
		return min(abs(h[n]-h[n-2]), abs(h[n]-h[n-1])+abs(h[n-1]-h[n-2]));  //If I remove this if statement it works
	}
	if(i==n){
		return 0;
	}
	if(v[i]){
		return dp[i];
	}

	v[i]=1;

	int thing1 = abs(h[i+1]-h[i])+ s1(i+1);
	int thing2 = abs(h[i+2]-h[i])+ s1(i+2);

	dp[i] = min(thing2, thing1);
	return dp[i];

}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	h.resize(n+1);
	h[0]=0;	
	for(int i=1; i<=n; i++){
		cin>>h[i];
	}		

	cout<<s1(1)<<'\n';
}


Measured memory_bytes: 7296
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int ans = 0;
		int[] length = new int[n]; 
		
		for(int i = 0; i < n; i++) {
			length[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				for(int k = j + 1; k < n; k++) {
					if(length[i] != length[j]
							&& length[i] != length[k]
							&& length[j] != length[k]
							&& length[i] + length[j] > length[k]
							&&	length[j] + length[k] > length[i]
							&& length[k] + length[i] > length[j]) {
						ans++;
					}
				}
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}




Measured memory_bytes: 36840
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans = -1000000000000000010;
	if (ans < a * c) {
		ans = a * c;
	}
	if (ans < a * d) {
		ans = a * d;
	}
	if (ans < b * c) {
		ans = b * c;
	}
	if (ans < b * d) {
		ans = b * d;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){   
    ll h;
    cin>>h;
    ll cmp = 2,ans = 1;
    while(cmp <= h){
        cmp *= 2;
        ans = ans * 2 + 1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

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

int main(){
    int N;cin >> N;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    for (int i = 0; i < N; i++)
    {
        string buf; cin >> buf;
        if (buf.compare("AC")==0) {
            ac++;
        } else
        if (buf.compare("WA")==0) {
            wa++;
        } else
        if (buf.compare("TLE")==0) {
            tle++;
        } else
        if (buf.compare("RE")==0) {
            re++;
        } 
    }
//             AC x 
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
//AC x 3
//WA x 1
//TLE x 2
//RE x 0

}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll n;
  cin>>n;

  map<string, ll> cnt;
  string s;
  for (ll i=0; i<n; i++) {
    cin>>s;
    cnt[s]++;
  }

  cout<<"AC x "<<cnt["AC"]<<endl;
  cout<<"WA x "<<cnt["WA"]<<endl;
  cout<<"TLE x "<<cnt["TLE"]<<endl;
  cout<<"RE x "<<cnt["RE"]<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3656
n = int(input())
a = sorted(list(map(int,input().split())))
c0 = a.count(0)
ans = 'No'
if c0==n:
    ans = 'Yes'
if len(set(a))==2:
    c = a.count(a[-1])
    if c==n*2/3 and c0==n/3:
        ans = 'Yes'
if len(set(a))==3:
    s = 0
    f = True
    for i in set(a):
        s ^= i
        if a.count(i)!=n/3:
            f = False
    if f and s==0:ans='Yes'
print(ans)


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

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    if (A > K)
    {
        cout << A - K << ' ' << B << endl;
    }
    else if (A + B > K)
    {
        cout << 0 << ' ' << A + B - K << endl;
    }
    else
    {
        cout << 0 << ' ' << 0 << endl;
    }
}

Measured memory_bytes: 256
a, b, o, ab = 0, 0, 0, 0
while True:
    try:
        n, abo = map(str, raw_input().split(","))
        if abo == "A":
            a += 1
        elif abo == "B":
            b += 1
        elif abo == "O":
            o += 1
        else:
            ab += 1
    except:
        break
    
print a
print b
print ab
print o

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	cout<<N*N*N<<endl;
}

Measured memory_bytes: 256
S = int(input())
if S <= 10**9:
	print(0,0,1,0,0,S)
	exit()

def search(n):
	l = 0
	r = 10**9
	while r - l > 1:
		p = (l+r)//2
		square = p*p
		if square == n:
			return p
		if square < n:
			l = p
		else:
			r = p
	return r

b = search(S)
tmp = b*b - S
if tmp % 2 == 0:
	print(0,0,b,2,tmp//2,b)
elif tmp <= 10**9:
	print(0,0,b,1,tmp,b)
else:
	print(0,0,b,1,tmp-b,b-1)

Measured memory_bytes: 3064
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A,B,C,K=pin()
    ans=K
    if A<K:ans=A
    K-=(A+B)
    if K<0:print(ans);return
    print(ans-K)
#%%submit!
resolve()


Measured memory_bytes: 62024
a = []
while True:
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    a.append([x, y])

for i in range(len(a)):
    print("#" * a[i][1])
    for j in range(1, a[i][0]-1):
        print("#" + "."*(a[i][1]-2) + "#")
    print("#" * a[i][1])
    print("")



Measured memory_bytes: 5624
import java.io.*;

public class Main
{
    public static void main (String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        String str1 = br.readLine();
        String[] str2 = str1.split(" ", 0);
        int i[] = new int[3];
        String result;

        for(int j=0; j<3; j++) {
        	i[j] = Integer.parseInt(str2[j]);
        	//System.out.println(i[j]);
        }

       	if(i[0] == i[1]+i[2]) { result = "Yes"; }
       	else if(i[1] == i[2]+i[0]) { result = "Yes"; }
       	else if(i[2] == i[0]+i[1]) { result = "Yes"; }
       	else { result = "No"; }

       	System.out.println(result);
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   long long n;
   int padding =0;
   vector<long> a(5);
   cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
   if(n% *min_element(ALL(a)) !=0 )  padding =1;
   cout << n/ *min_element(ALL(a)) + 4 + padding << endl; 
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,ans=1,m;
  scanf("%lld",&n);
  long long A[n+1];
  for(int i=0;i<n;i++){
    scanf("%lld",&A[i]);
    if(A[i]==0){
        printf("0\n");return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(1000000000000000000/ans < A[i] ){
        printf("-1\n");
        return 0;
    }
    ans=A[i]*ans;
  }
  printf("%lld\n",ans);
  
  return 0;
}

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

int main(){
    string s,t,u ;
    int a,b ;
    cin >> s >> t ;
    cin >> a >> b ;
    cin >> u ;

    if (s == u)
    {
        a -- ;
    }else if (t == u)
    {
        b -- ;
    }
    
    

    cout << a << " " << b << endl ;
}

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

int main(){
  int n;
  int ans =0;
  cin >> n;
  
    if(n>=200){
      ans += 100;
      n -= 900;
    }
    else{
      ans += 900;
      n -= 100;
    }
    if(n>=20){
      ans += 10;
      n -= 90;
    }
    else{
      ans += 90;
      n -= 10;
    }
     if(n>=2){
       ans +=1;
     }
     else{
       ans +=9;
     }
      cout << ans <<endl;
    }

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

int main()
{
  string S, T;
  cin >> S >> T;
  
  bool imp = false;
  
  for(int i = 0; i < S.size(); i++)
  {
    if(S.at(i) != T.at(i))
    {
      imp = true;
      break;
    }
  }
  
  if(imp) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#define N 20

int calc(int, int);
int n, A[N];

int main(){

  int q, i, num;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &num);
    if(calc(num, 0) == 1 ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int calc(int num, int a){

  if(num == 0) return 1;
  if(a == n || num < 0) return 0;

  if(calc(num - A[a], a + 1) == 1 || calc(num, a + 1) == 1) return 1;
  return 0;

}

Measured memory_bytes: 580
a = int(input())
b = list(input())
c = list(input())
d = a * 2
for i in range(1, a + 1):
    bb = ""
    for j in range(a-i, a):
        bb += b[j]
    cc = ""
    for j in range(0, i):
        cc += c[j]
    if bb == cc:
        d = min(d, a * 2 - i)
print(d)


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

int main(){
  int a,s,m,h;
  scanf("%d", &a);
  h = a / 3600;
  m = a % 3600 / 60;
  s = a % 3600 % 60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char before = str.charAt(0);
		boolean result = false;
		for (int i = 1; i < 4; i++) {
			if (before == str.charAt(i)) {
				result = true;
				break;
			}
			before = str.charAt(i);
		}
		if (result) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long int ll;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
#define pos std::pair<int,int>
const int INF = 1LL << 30;
const int INF_ = 0 - INF;
const ll LLINF = 1LL << 60;
int main() {
	ll n,m;
	std::cin >> n >> m;
	std::cout << pow(2, m)*((n - m) * 100 + 1900 * m);
	return 0;
 
}

Measured memory_bytes: 256
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> S(N);
  for (auto& e : S)cin >> e;
  unordered_map<string, int> m;
  int M = 0;
  for (auto& e : S)
    M = max(M,++m[e]);
  vector<string> ans;
  for(auto&p:m)if(p.second==M)ans.push_back(p.first);
 	sort(begin(ans), end(ans));
 	for(auto&e:ans)cout<<e<<"\n";
}


Measured memory_bytes: 26948
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<queue>
using namespace std;
vector<int>adj[200009];
int p[200009];
bool vis[200009]={0};
int cnt=0;
int main()
{
    int n,m;
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    queue<int>Q;
    Q.push(1);
    vis[1]=true;
    while( !Q.empty())
    {
        int i=Q.front();
        Q.pop();
        for(int x : adj[i]) if(!vis[x]){ p[x]= i ; vis[x]=true; Q.push(x) ;}
    }
    for(int i=2;i<=n;i++) {if(!vis[i]) { cout<<"No" ; return 0; }}
        cout<<"Yes\n";
        for(int i=2;i<=n;i++) cout<<p[i]<< " ";
    
}


Measured memory_bytes: 12868
from bisect import bisect_left

N, M = map(int, input().split())
S = input()

reach = []
for i, s in enumerate(S) :
    if s == '0' :
        reach.append(i)

def solve() :
    ret = []
    cur = N
    while cur != 0 :
        i = bisect_left(reach, cur - M)
        if reach[i] == cur :
            return [-1]
        ret.append(cur - reach[i])
        cur = reach[i]
    
    ret.reverse()
    return ret
    
print(*solve())

Measured memory_bytes: 51488
n = int(input())
h_list = input().split()
h_list = [int(one) for one in h_list]

st_dict = dict()

for i,one in enumerate(h_list):
    st_dict[i+1] = one

tmp = sorted(list(st_dict.items()),key=lambda x:x[1])

out_str = ""
for one in tmp:
    out_str += "{} ".format(one[0])
print(out_str[:-1])

Measured memory_bytes: 26972
#include <stdio.h>

int main(void){
  int i,j=0;
  scanf("%d",&i);
   
  int a,b,c;
  
  a=i%10;
  b=i%100;
  c=i/100;
  
  if(a==7){
    j++;
  } else if(70<=b && b<80){
   j++;
  } else if(c==7){
    j++;
  } 
  
  if(j==1){
    printf("Yes\n");
  } else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1644
X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()], reverse=True)
l = sorted(p[:X] + q[:Y])

i = 0
ans = 0
for a in l:
    if i < C and r[i] <= a:
        ans += a
    elif i < C and r[i] > a:
        ans += r[i]
        i += 1
    else:
        ans += a

print(ans)

Measured memory_bytes: 22720
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

enum int m = 1_000_000_007;

void main() {
  int nt;
  string s;
  readf (" %s", &s);
  auto z = s.splitter;
  immutable n = z.front.to!int;
  z.popFront ();
  string t = z.front;
  auto c = new int[26];
  foreach (i; 0 .. n) {
    int k = t[i].to!int - 97;
    ++c[k];
  }
  debug stderr.writeln (c);
  int r = 1;
  foreach (i; 0 .. 26) {
    long x = r.to!long * (c[i] + 1);
    r = (x % m).to!int;
  }
  r = (r + m - 1) % m;
  writeln (r);
}


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

namespace ABC178
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3]);
            var max = new long[4] { a * c, a * d, b * c, b * d }.Max();
            Console.WriteLine(max);
        }
    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int n=s.length(), d[n];
	for(int i=0; i<n; i++) d[i]=0;

	int cnt=1, lp=0;
	for(int i=1; i<n; i++){
		if(s[i]==s[i-1]) cnt++;
		else{
			if(s[i]=='L'){
				d[i]+=cnt/2;
				d[i-1]+=(cnt+1)/2;
				lp=i;
			}else{
				d[lp]+=(cnt+1)/2;
				d[lp-1]+=cnt/2;
			}
			cnt=1;
		}
	}
	d[lp]+=(cnt+1)/2;
	d[lp-1]+=cnt/2;

	for(int i=0; i<n; i++) cout << d[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  double a;
  int i;

  while ( scanf ( "%lf", &a ) == 1 )
  {
    double res = a;
    int divisor = 1, multiple = 1;

    for ( i = 2; i <= 10; ++i )
    {
      if ( i % 2 )  divisor *= 3;
      else          multiple *= 2;

      res += a * multiple / divisor;
    }

    printf ( "%.6f\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        int D = scanner.nextInt();
        int T = scanner.nextInt();
        int S = scanner.nextInt();

        System.out.println(S * T >= D ? "Yes" : "No");
    }
}

Measured memory_bytes: 27052
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		
		int[]T = new int[N];
		
		
		
		for(int i = 0;i<N;i++){
			T[i] = scan.nextInt();	
		}
		
		
		
		int M = scan.nextInt();
		
		int[]P = new int [M];
		int[]X = new int [M];
		
		for(int i = 0;i<M;i++){
			P[i] = scan.nextInt();//M種類の中からi番目の物を飲んだらP[i]番の問題を解く
			X[i] = scan.nextInt();//P[i]番目の問題はX[i]秒かかる
		}
		
		
		
		int souwa = 0;
		
		
		for(int i = 0;i<M;i++){//M種類のドリンクごとの合計タイムを列挙
			
			
			for(int j = 0;j<N;j++){
				if(P[i]==j+1){//p[i]番目の問題をT[ｊ]びょうからX[i]秒にチェンジ
					souwa += X[i];
					
				}else{
					souwa += T[j];
				}
			}
			
			
			System.out.println(souwa);
			
			souwa=0;
		}
		
		
		
		
		
		
		
		
		
	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int K;
    cin >> K;
    cout << ceil(K, 2) * (K / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[100001];
int main() {
	int n,res=0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &arr[i]);
	}
	for (int i = 1; i < n; ++i) {
		if (arr[i] == i) { swap(arr[i], arr[i + 1]); ++i; ++res; }
	}
	if (arr[n] == n) ++res;
	printf("%d", res);
}

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

int main() {
  string a,b; cin>>a>>b;
  string c=a+b;
  int x=stoi(c);
  for(int i=1; i*i<=x; i++){
    if(i*i==x){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main(void){
  string l1, l2;
  
  cin >> l1 >> l2;
  
  reverse(l2.begin(), l2.end());
  
  if(l1 == l2) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int a[3];
    for (size_t i = 0; i < 3; i++) {
      in >> a[i];
    }
    sort(a, a + 3);
    out << a[0] + a[1] << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int p[20],c[20],ok[20];
    int D,G;
    int Gnow,numnow,ans,i,j,k;
    ans=1e9;
    scanf("%d%d",&D,&G);
    for(i=1;i<=D;i++)
    {
        scanf("%d%d",&p[i],&c[i]);
    }
    for(i=0;i<(1<<D);i++)
    {
        Gnow=0;numnow=0;
        int temp=i;
        for(j=1;j<=D;j++)
        {
            if(temp%2==1)ok[j]=1;
            else ok[j]=0;
            temp=temp>>1;
            //printf("%d",ok[j]);
        }
        //printf("\n");
        for(j=1;j<=D;j++)
        {
            if(ok[j]==1)
            {
                Gnow+=c[j]+p[j]*100*j;
                numnow+=p[j];
            }
        }
        bool flag=true;
        for(j=D;j>=1;j--)
        {
            if(Gnow>=G)break;
            if(ok[j]==1)continue;
            for(k=1;k<=p[j];k++)
            {
                Gnow+=100*j;
                numnow++;
                if(Gnow>=G){flag=false;break;}
            }
            if(!flag)break;
        }
        if(Gnow>=G && numnow<ans)ans=numnow;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long int N, M;
  cin >> N >> M;
  long int maxi = 1;
  for(long int i=1;i*i<=M;i++){
    if(M % i == 0 && i <= M / N){
      maxi = max(i,maxi);
      if(M / i <= M / N) maxi = max(M / i,maxi);
    }
  }
  cout << maxi << endl;
}

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

signed main(){
  
  int a, b, k;
  cin>>a>>b>>k;
  
  int c = min( a, k );
  
  a -= c;
  k -= c;
  b -= min( b, k );
  
  cout<<a<<' '<<b<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main() {
    long long a,b,k;
    cin>>a>>b>>k;
    if(a-k>=0)cout<<a-k<<" "<<b<<endl;
    else cout<<0<<" "<<max(b-k+a,(long long) 0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){int n,m,p; cin>>n>>p; n=1,m=p+1; while(n<m) cout<<n++<<" "<<m--<<endl; n=p+2,m=2*p+1; while(n<m) cout<<n++<<" "<<m--<<endl;}

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

using namespace std;

struct team{
	int id;
	int bl;
	int an;
	int pn;
};

int main()
{
	int n, m, u[1001];
	team t[301], s;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(u, u+1001, 0);
		for(int i = 0; i < n; i++){
			cin >> t[i].id >> t[i].bl >> t[i].an >> t[i].pn;
		}
		
		for(int i = n-1; i >= 0; i--){
			for(int j = 1; j <= i; j++){
				if(t[j-1].id > t[j].id){
					s = t[j];
					t[j] = t[j-1];
					t[j-1] = s;
				}
			}
		}
		
		for(int i = n-1; i >= 0; i--){
			for(int j = 1; j <= i; j++){
				if(t[j-1].pn > t[j].pn){
					s = t[j];
					t[j] = t[j-1];
					t[j-1] = s;
				}
			}
		}
		
		for(int i = n-1; i >= 0; i--){
			for(int j = 1; j <= i; j++){
				if(t[j-1].an < t[j].an){
					s = t[j];
					t[j] = t[j-1];
					t[j-1] = s;
				}
			}
		}
		
		m = 0;
		for(int i = 0; i < n && m < 26; i++){
			if(u[t[i].bl] == 0){
				u[t[i].bl]++;
				cout << t[i].id << endl;
				m++;
			} else if(u[t[i].bl] == 1 && m < 20){
				u[t[i].bl]++;
				cout << t[i].id << endl;
				m++;
			} else if(u[t[i].bl] == 2 && m < 10){
				u[t[i].bl]++;
				cout << t[i].id << endl;
				m++;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
//#include<string.h>

typedef struct Tree{
  int key;
  struct Tree *r,*l,*p;
} Tree;

Tree *root;

void insert(int k){
  Tree *a = NULL;
  Tree *b = root;
  Tree *t;

  t = malloc(sizeof(Tree));

  t->key = k;
  t->l = NULL;
  t->r = NULL;

  while(b != NULL){
    a = b;
    if(t->key < b->key){
      b = b->l;
    }else{
      b = b->r;
    }
  }

  t->p = a;

  if(a == NULL){
    root = t;
  }else{
    if(t->key < a->key){
      a->l = t;
    }else{
      a->r = t;
    }
  }
}

void ino(Tree *t){
  if(t == NULL) return;
  ino(t->l);
  printf(" %d",t->key);
  ino(t->r);
}

void pre(Tree *t){
  if(t == NULL) return;
  printf(" %d",t->key);
  pre(t->l);
  pre(t->r);
}

int main(){
  int n,x,i;
  char order[10];

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%s",order);

    if(order[0]/*(strcmp(order,"insert")) == 0*/ == 'i'){
      scanf("%d",&x);
      insert(x);

    }else if(order[0]/*(strcmp(order,"print")) == 0*/ == 'p'){
      ino(root);
      printf("\n");
      pre(root);
      printf("\n");
    }

  }
  return 0;
}

Measured memory_bytes: 24040