akhauriyash/Code-Regression huggingface dataset:
pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

#[allow(dead_code)]
impl  Scanner{
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   fn next_string(&mut self) -> Vec<char> {
       let s : String = self.next();
       return s.chars().collect::<Vec<char>>();
   }
   fn next_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let _n:i64  = scan.next();
    let k:i64  = scan.next();
    let c:i64  = scan.next();
    let s = scan.next_string();

    let mut a :Vec<i32> = Vec::with_capacity(k as usize);
    let mut b: Vec<i32> = Vec::with_capacity(k as usize);
    let mut sleep = 0;

    for day in 0..s.len(){
        if sleep > 0{
            sleep -= 1;
            continue;
        }
        if s[day] == 'o'{
            a.push(day as i32);
            sleep = c;
        }
        if a.len() == k as usize{
            break;
        }
    }
    sleep = 0;
    for day in (0..s.len()).rev() {
        if sleep > 0{
            sleep -= 1;
            continue;
        }
        if s[day] == 'o'{
            b.push(day as i32);
            sleep = c;
        }
        if b.len() == k as usize{
            break;
        }
    }
    b.sort();

    for i in 0..k{
        let idx = i as usize;
        if a[idx] == b[idx] {
            println!("{}", a[idx] + 1);
        }
    }
}


Measured memory_bytes: 9724
#include <stdio.h>
#include <stdlib.h>
#define Yes()       printf("Yes\n")
#define No()        printf("No\n")

char s[51][51]={0};

int check(int h, int w){
    if     ( h<0 || w<0 )   return 0;
    else if( s[h][w]=='.' ) return 1;
    else                    return 0;
}

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0; i<h; i++){ scanf("%s", s[i]); }
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if( s[i][j]=='#'
            &&  check(i-1,j)    //上
            &&  check(i+1,j)    //下
            &&  check(i,j-1)    //左
            &&  check(i,j+1) )  //右
            {
                No();
                return 0;
            }
        }
    }
    Yes();
    return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main()
{
	int MOD = pow(10, 9)+7;
	int N; cin >> N;
	vector<ll> data(N);
	for (int i = 0; i < N; i++)cin >> data[i];
	ll sum=0;
	ll ans=0;
	for (int i = 0; i < N; i++)sum += data[i];
	sum %= MOD;
	ll temp;
	for (int i = 0; i < N; i++) {
		sum -= data[i];
		if (sum < 0)sum += MOD;
		ans += sum * data[i];
		ans %= MOD;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 4364
from collections import deque


def solve(n, ab_list):
    g = [[] for _ in range(n + 1)]
    for a, b in ab_list:
        g[a].append(b)
        g[b].append(a)
    # start from 1
    d_list = [-1] * (n + 1)
    d_list[1] = 0
    queue = deque([1])
    while len(queue) > 0:
        p = queue.popleft()
        for q in g[p]:
            if d_list[q] == -1:
                d_list[q] = d_list[p] + 1
                queue.append(q)
    # print(d_list)
    cnt_2 = [0] * 6
    for i in range(1, n + 1):
        cnt_2[d_list[i] % 2] += 1

    if cnt_2[0] <= cnt_2[1]:
        min_01 = 0
    else:
        min_01 = 1

    min_sum = cnt_2[min_01]
    if min_sum <= n // 3:
        res_list = [0] * n
        list_3 = [3 * (k + 1) for k in range(min_sum)]
        list_other = [k for k in range(1, n + 1) if k % 3 != 0] + [3 * (k + 1) for k in range(min_sum, n // 3)]
        for i in range(1, n + 1):
            if d_list[i] % 2 == min_01:
                res_list[i - 1] = list_3.pop()
            else:
                res_list[i - 1] = list_other.pop()
    else:
        res_list = [0] * n
        add_1 = min_sum - (n + 2) // 3
        list_1 = [k + 1 for k in range(n) if k % 3 == 0] + [3 * (k + 1) for k in range(add_1)]
        list_2 = [k + 1 for k in range(n) if k % 3 == 1] + [3 * (k + 1) for k in range(add_1, n // 3)]
        for i in range(1, n + 1):
            if d_list[i] % 2 == min_01:
                res_list[i - 1] = list_1.pop()
            else:
                res_list[i - 1] = list_2.pop()

    return " ".join([str(r) for r in res_list])


def main():
    n = int(input())
    ab_list = [list(map(int, input().split())) for _ in range(n - 1)]
    res = solve(n, ab_list)
    print(res)


def test():
    # print(solve(5, [[1, 2], [1, 3], [3, 4], [3, 5]]))
    assert solve(5, [[1, 2], [1, 3], [3, 4], [3, 5]]) == "3 4 1 5 2"


if __name__ == "__main__":
    # test()
    main()


Measured memory_bytes: 92508
#include <iostream>
using namespace std;
int main (){
	int n;
	long long a;
	long long min = 1000000;
	long long max = -1000000;
	long long sum = 0;

	cin >> n ;

	for (int i =0 ;i <n ; i++){
		cin  >> a;
		if( a < min) min = a;
		if( a > max) max = a;
		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
	
}

Measured memory_bytes: 1168
program main
  implicit none
  integer i,N
  real(8) ans,a,b
  read(*, *) N
  !read(*, *) (L(i), i = 1,N)
  if (mod(N,2) == 0) then
    ans = 0.5
  else
  	a = N+1
    b = 2*N
    ans = a/b
  end if
  write(*, *) ans
end program main


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    if((n*m)%2==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
		 int N=sc.nextInt();
		 int L=sc.nextInt();
		 ArrayList<String> S=new ArrayList<>();
		 for(int i=0;i<N;i++) {
			 S.add(sc.next());
		 }
		 Collections.sort(S);
		 
		 for(int i=0;i<N;i++)
			 System.out.print(S.get(i));
	     sc.close();
	 }
}


Measured memory_bytes: 21844
N,*xls=$<.read.split.map(&:to_i)

count = 0
r = nil
xls.each_slice(2).to_a.sort.each do |x,l|
    if r.nil?
        r = x+l
    elsif x-l < r
        count += 1
        r = [r,x+l].min
    else
        r = x+l
    end
end

puts N-count


Measured memory_bytes: 32744
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int a, b; cin >> a >> b;
  cout << (a-1)*(b-1) << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using ll = long long;

int main(){
    ll A, B, K;
    std::cin >> A >> B >> K;
    if(K > A){
        ll rest = K - A;
        A = 0;
        B = std::max(0LL, B - rest);
    }else{
        A -= K;
    }
    std::cout << A << " " << B << std::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++)

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    int n,m; cin >> n >> m;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }

    vector<bool> G(n,true);

    rep(i,m){
        int a,b; cin >> a >> b;
        if(h[a-1] > h[b-1]){
            G[b-1] = false;
        }else if(h[b-1] > h[a-1]){
            G[a-1] = false;
        }else{
            G[a-1] = false;
            G[b-1] = false;
        }
    }

    int cnt = 0;
    rep(i,n){
        if(G[i]){
            cnt++;
        }
    }

    cout << cnt << endl;

}




Measured memory_bytes: 3788
n = int(input())

keta = len(str(n))

if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(n - 90)
elif keta == 4:
    print(909)
elif keta == 5:
    print(n - 9090)
elif keta == 6:
    print(90909)


Measured memory_bytes: 2940
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
#define MAX 200005
int main()
{
	ll n;
	cin>>n;
	ll a[n+1];
	ll count=0;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
		if(i%2!=0&&a[i]%2!=0)
			count++;
	}
	cout<<count<<endl;

}






Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<int> s = a;
  sort(s.rbegin(),s.rend());
  for(int i=0;i<n;i++){
    int ans = s[0];
    if(s[0]==a[i]) ans = s[1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a >= 10 || b >= 10) cout << -1 << endl;
  else cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {


		int A = 0;
		int B = 0;
		int C = 0;
		int X = 0;
		int difference = 0;
		int judge = 0;
		Scanner scanner = new Scanner(System.in);

		A = scanner.nextInt();
		B = scanner.nextInt();
		C = scanner.nextInt();
		X = scanner.nextInt();

		for(int i = 0; i <= A; i++) {
			for(int j = 0; j <= B; j++) {
				difference = (X -(500*i + 100*j))/50;
				if(difference >= 0 && difference <= C) {
					judge++;
				}
			}
		}
		System.out.println(judge);
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a[5],b[5],c[5][5],i,j,k;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  for(i=0;i<=c[0][0];i++){
    int res=0;
    a[0]=i;
    b[0]=c[0][0]-a[0],b[1]=c[0][1]-a[0],b[2]=c[0][2]-a[0];
    a[1]=c[1][0]-b[0],a[2]=c[2][0]-b[0];
  for(j=0;j<3;j++){
    for(k=0;k<3;k++){
      if(a[j]+b[k]!=c[j][k] || a[j]<0 || b[k]<0){
        res=1;
      }
    }
  }
    if(res==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define SIZE 1
using namespace std;
typedef long long int LL;
typedef long double LD;

string S;
set<string> s;

void initialize() {
	s.clear();
	s.insert("dream");
	s.insert("dreamer");
	s.insert("erase");
	s.insert("eraser");
}

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

	cin >> S;
	int idx = 0;
	initialize();
	for (int i = S.length() - 1; i >= 0; i--) {
		bool initial = false;
		for (string _s : s) {
			if (_s[_s.length() - idx - 1] == S[i]) {
				if (_s.length() - 1 == idx) {
					idx = 0;
					initialize();
					initial = true;
					break;
				}
			} else {
				s.erase(_s);
			}
		}
		if (!initial) {
			if (s.size() == 0) {
				cout << "NO" << endl;
				return 0;
			}
			idx++;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


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

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

auto solve() {
    int N, M;
    cin >> N >> M;
    vi A(M);
    for (auto &&e:A) cin >> e;
    sort(all(A));

    map<int, int> costs = {
            {1, 2},
            {2, 5},
            {3, 5},
            {4, 4},
            {5, 5},
            {6, 6},
            {7, 3},
            {8, 7},
            {9, 6},
    };

    auto dp = vector<vi>(N + 1, vi(M, -1));
    REP(k, M) dp[0][k] = 0;

    REP(i, N) {
        if (dp[i][0] == -1) continue;

        REP(j, M) {
            int next = i + costs[A[j]];
            if (next > N) continue;

            vi tmp(M, 0);
            REP(k, M) tmp[k] = dp[i][k];
            tmp[j]++;

            bool update = false;
            int t1 = accumulate(all(tmp), 0);
            int t2 = accumulate(all(dp[next]), 0);

            if(t1 > t2) {
                update = true;
            }
            if(!update) {
                RREP(k, M) {
                    if (dp[next][k] < tmp[k]) {
                        update = true;
                        break;
                    } else if (dp[next][k] > tmp[k]) {
                        update = false;
                        break;
                    }
                }
            }

            if (update) {
                REP(k, M) dp[next][k] = tmp[k];
            }
        }
    }

    RREP(i, M) {
        int c = dp[N][i];
        REP(_t, c) cout << A[i];
    }
    cout << endl;
}


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

//    cout << (solve() ? "First" : "Second") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
    solve();

    return 0;
}


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

using namespace std;

const int N = 2e5+7;

int n;
long long res;
int d[N];
long long c[N];

int f(int a, long long t) {
    if (t == 0) return 0;
    if (t == 1) return a;

    res += t/2+2*a/10*t/2;
    int tmp = f(2*a%10+2*a/10, t/2);
    if (t&1) {
        tmp += a;
        ++res;
    }
    if (tmp >= 10) {
        tmp = tmp%10+tmp/10;
        ++res;
    }
    return tmp;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> d[i] >> c[i];
        d[i] = f(d[i], c[i]);
    }
    for (int i = 2, cur = d[1]; i <= n; ++i) {
        cur += d[i];
        ++res;
        if (cur >= 10) {
            ++res;
            cur = cur%10+cur/10;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
    int A, P;
    int slice = 0, pie = 0;

    scanf("%d %d", &A, &P);

    while (A>0){
        slice += 3;
        A--;
    }

    slice += P;

    while (slice >= 2){
        slice -= 2;
        pie++;
    }

    printf("%d", pie);

    return 0;
}


Measured memory_bytes: 1728
use std::collections::VecDeque;
use std::io::{BufRead, BufReader};
fn main() {
    let mut input = BufReader::new(std::io::stdin())
        .lines()
        .filter_map(|e| e.ok());
    let line: Vec<_> = input
        .next()
        .unwrap()
        .split_whitespace()
        .map(|e| e.to_string())
        .collect();
    let quontum: u64 = line[1].parse().unwrap();
    let mut queue: VecDeque<(String, u64)> = input
        .map(|e| {
            let mut e = e.split_whitespace();
            let name = e.next().unwrap().to_string();
            let time = e.next().unwrap().parse().ok().unwrap();
            (name, time)
        })
        .collect();
    let mut tic = 0;
    while !queue.is_empty() {
        let (name, count) = queue.pop_front().unwrap();
        if count <= quontum {
            println!("{} {}", name, tic + count);
            tic += count;
        } else {
            queue.push_back((name, count - quontum));
            tic += quontum;
        }
    }
}



Measured memory_bytes: 7068
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)			
    {
       
    }*/
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    ans-=min(c,k);
    cout<<ans;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
int a[100010];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

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

Measured memory_bytes: 3852
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    vector <int> cnt(31);
    forn (i, 0, n)
        forn (j, 0, sz(cnt))
            if ((a[i] >> j) & 1)
                cnt[j]++;
    forn (i, 0, n) {
        int ans = 0;
        forn (j, 0, sz(cnt))
            if (((a[i] >> j) & 1) != cnt[j] % 2)
                ans += (1 << j);
        cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

double fact(double x);

int main(void) {
	double n;
	while(1) {
		cin >> n;
		if(cin.eof())		break;
		
		printf("%.0f\n", fact(n));
	}
	
	return 0;
}

double fact(double x) {
	if(x == 0) {
		return 1;
	}
	return x * fact(x - 1);
}

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

int main(){
  int N , A[3][3] , B[10];
  bool a[3][3]= {false};//定義づけ
  for(int i =0;i<3;i++){
    for(int j =0;j<3;j++){
      cin >> A[i][j] ;
    }
  }
  cin >> N ;
  for(int i =0;i<N;i++) cin >> B[i];//入力終了
  
  for(int i =0;i<N;i++){
    for(int j =0;j<3;j++){
      for(int k =0;k<3;k++){
        if(B[i]==A[j][k]) a[j][k] = true;
      }
    }  
  }
    bool ans = false;//フラグ
  
  if(a[0][0]&&a[0][1]&&a[0][2]) ans = true;
  if(a[1][0]&&a[1][1]&&a[1][2]) ans = true;
  if(a[2][0]&&a[2][1]&&a[2][2]) ans = true;
  if(a[0][0]&&a[1][0]&&a[2][0]) ans = true;
  if(a[0][1]&&a[1][1]&&a[2][1]) ans = true;
  if(a[0][2]&&a[1][2]&&a[2][2]) ans = true;
  if(a[0][0]&&a[1][1]&&a[2][2]) ans = true; 
  if(a[0][2]&&a[1][1]&&a[2][0]) ans = true;
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }



Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
using namespace std;

//fixed << setprecision(10)
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

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

	int count = 1;
	rep(i, n-1) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>

int main(void){
	int nA = 0, nB = 0, nO = 0, nAB = 0;
	while( 1 ){
		int id;
		char bloodType[4] = "";
		
		if( 2 != scanf("%d,%s%*c", &id, bloodType) ) break;

		if( strcmp(bloodType, "A") == 0 ) nA++;
		else if( strcmp(bloodType, "B") == 0 ) nB++;
		else if( strcmp(bloodType, "AB") == 0 ) nAB++;
		else if( strcmp(bloodType, "O") == 0 ) nO++;
	}
	printf("%d\n%d\n%d\n%d\n",
		nA,
		nB,
		nAB,
		nO);
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		for(int i = 0; i < n; i++) {
			ints[i] = sc.nextInt();
		}

		Arrays.sort(ints);
		long sum = 0;

		for (int i = 0; i < n; i++) {
			sum += ints[i];
		}

		System.out.print(ints[0] + " " + ints[n-1] + " " +  sum);
		System.out.println();
		sc.close();
	}

}


Measured memory_bytes: 41188
#include <bits/stdc++.h>
using namespace std;
#define maxn 5005

#define ll long long
#define ull unsigned long long
#define mod 1000000007

#define base 131

typedef pair<int, int> P;

int n;
char s[maxn];
ull h[maxn], power[maxn];

ull cal(int l, int r) { return h[r] - power[r - l + 1] * h[l - 1]; }

bool C(int m)
{
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + m; j <= n - m + 1; j++)
        {
            if (cal(i, i + m - 1) == cal(j, j + m - 1))
                return 1;
        }
    }
    return 0;
}

int main()
{
    cin >> n;
    scanf("%s", s + 1);

    power[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        power[i] = power[i - 1] * base;
        h[i] = h[i - 1] * base + s[i];
    }
    int l = 0, r = n + 1;
    while (r - l > 1)
    {
        int m = (l + r) / 2;
        if (C(m))
            l = m;
        else
            r = m;
    }
    printf("%d\n", l);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
src = list(map(int,input().split()))

tmp1 = tmp2 = 0
ans1 = ans2 = 0
for i,a in enumerate(src):
    tmp1 += a
    tmp2 += a
    if i%2:
        if tmp1 <= 0:
            ans1 += 1 - tmp1
            tmp1 = 1
        if tmp2 >= 0:
            ans2 += tmp2 + 1
            tmp2 = -1
    else:
        if tmp2 <= 0:
            ans2 += 1 - tmp2
            tmp2 = 1
        if tmp1 >= 0:
            ans1 += tmp1 + 1
            tmp1 = -1
print(min(ans1,ans2))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
int ans=0;
int PureLastA=0;
int PureFirstB=0;
int ABDouble=0;
int N;
string sent[10005];
int main(int argc,char const* argv[])
{
  cin >> N;
  for (int i = 0; i < N; ++i)
    {
      cin >> sent[i];
    }
  for (int i = 0; i < N; ++i)
    {
      int ssize=int(sent[i].size());
      if(sent[i][0]=='B' && sent[i][ssize-1]!='A') PureFirstB++;
      else if(sent[i][0]!='B' && sent[i][ssize-1]=='A') PureLastA++;
      else if(sent[i][0]=='B' && sent[i][ssize-1]=='A') ABDouble++;
      for(int j=0;j<ssize-1;j++)
	{
	  if(sent[i][j]=='A' && sent[i][j+1]=='B')
	    {
	      ans++;
	    }
	}
    }
  if(PureLastA>0)
    {
      if(ABDouble>0)
	{
	  PureLastA--;
	  ans+=ABDouble;
	  if(PureFirstB>0)
	    {
	      ans++;
	      PureFirstB--;
	    }
	}
      ans+=min(PureLastA,PureFirstB);
    }
  else
    {
      ans+=max(0,ABDouble-1);
      if(ABDouble>0)
	{
	  if(PureFirstB>0)
	    {
	      ans++;
	    }
	}
    }
  //cout << ans << ' ' << PureFirstB << ' ' << PureLastA << ' ' << ABDouble<< endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
  int a,b,c,d;
  scanf("%d%d",&a,&b);
  
  if(a<b)
    {
    c=a;
    a=b;
    b=c;
    }
    
	  d=a%b;
	  while(d!=0)
	  {
	      
	  
	  a=b;
	  b=d;
	  d=a%b;
	}
      printf("%d\n",b);
  
  return 0;
}



Measured memory_bytes: 2140
// https://atcoder.jp/contests/arc099/tasks/arc099_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, k: usize,
        a: [i32; n]
    };

    let mut total = n;
    for i in 0..n {
        if a[i] == 1 {
            for (left,right) in vec![(i, n-i-1), (n-i-1, i)] {
                let pw = left % (k - 1);
                let left = left - pw;
                let right = if pw >= 1 { right - (k - 1 - pw) } else { right };
                let mut t = left  / (k - 1) + (right + k - 2) / (k - 1);
                if pw >= 1 {
                    t += 1;
                }
                total = min(total, t);
            }
            break;
        }
    }

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


Measured memory_bytes: 4352
from collections import Counter

(N,) = [int(x) for x in input().split()]
S = input()


count = 0
for j in range(1, N):
    x = S[j]

    leftCount = Counter(S[j + 1 :])
    del leftCount[x]
    rightCount = Counter(S[:j])
    del rightCount[x]

    for k1, v1 in leftCount.items():
        for k2, v2 in rightCount.items():
            if k1 != k2:
                count += v1 * v2

    symmetricCount = 0
    for l in range(1, N):
        if j - l >= 0 and j + l < N:
            y = S[j - l]
            z = S[j + l]
            if x != y and y != z and x != z:
                symmetricCount += 1
        else:
            break

    count -= symmetricCount
print(count)


Measured memory_bytes: 72020
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
  return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
  if(m1 != m2)cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int D, N;
	cin >> D >> N;
	for (int i = 1;; i++) {
		int a = i;
		int k = 0;
		while (a % 100 == 0) {
			a /= 100;
			k++;
		}
		if (k == D)N--;
		if (N == 0) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
d = []
d.append(0)
for i in range(1,n+1):
    d.append(d[i-1] + l[i-1])
    if d[i] > x:
        print(len(d) - 1)
        exit()
print(n+1)


Measured memory_bytes: 2940
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
struct node{
	int num, key, vis;
};
node a[MAXN + 5];
bool operator < (node a, node b) {
	return a.key < b.key;
}
set<node>Set[MAXN + 5];
int fa[MAXN + 5];
int Find(int x) {
	if( fa[x] == x ) return x;
	return fa[x] = Find(fa[x]);
}
int main() {
	int N, M, cnt = 0;
	scanf("%d%d", &N, &M);
	for(int i=0;i<N;i++) {
		scanf("%d", &a[i].key);
		a[i].num = fa[i] = i;
	}
	int ned = ((N-1) - M) * 2;
	if( ned > N ) {
		printf("Impossible\n");
		return 0;
	}
	for(int i=1;i<=M;i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		fa[Find(u)] = Find(v);
	}
	for(int i=0;i<N;i++)
		Set[Find(i)].insert(a[i]);
	long long ans = 0;
	for(int i=0;i<N;i++) {
		if( Find(i) == i ) {
			if( cnt == ned ) continue;
			ans += Set[i].begin()->key;
			a[(*Set[i].begin()).num].vis = true;
			cnt++;
		}
	}
	sort(a, a+N);
	for(int i=0;i<N;i++) {
		if( cnt == ned ) break;
		if( a[i].vis ) continue;
		cnt++;
		ans += a[i].key;
	}
	printf("%lld\n", ans);
}

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

int main(void){
  int x,y,f;
  
  cin >> x >> y;
  f = 0;
  for (int i=0; i<=x; i++){
    if (2*i+4*(x-i)==y) f=1;
  }
  cout << (f?"Yes":"No") << endl;
  
  return 0;
}

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

int n,q,cnt,h[200005],nex[200005<<1],to[200005<<1],ans[200005];

void addedge(int x,int y)
{
	nex[++cnt] = h[x];
	to[cnt] = y;
	h[x] = cnt;
}

void dfs(int x,int f)
{
	ans[x] += ans[f];
	for(int i=h[x];i;i=nex[i])
		if(to[i]!=f)
			dfs(to[i],x);
}

int main()
{
	cin>>n>>q;
	for(int i=1,x,y;i<n&&cin>>x>>y;i++)
	{
		addedge(x,y);
		addedge(y,x);
	}
	while(q--)
	{
		int x,v;
		cin>>x>>v;
		ans[x] += v;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';cout<<endl;
	
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int x = 0;
    for (char c : s) 
    {
        x += (c - '0');
    }
    x %= 9;
    if (x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;  
}

Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;

int main(){
    ios::sync_with_stdio(false);
    int x,y,w;
    cin>>w>>x>>y;
    int a,b;
    a=min(x,y);
    b=max(x,y);
    if(a+w>=b) cout<<0<<endl;
    else cout<<b-a-w<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 2e5+5;
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; 
}     
int n,a[MAXN],ans;
bool cmp(int x,int y)
{
	return x>y;
}
signed main() 
{ 
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i*2<=n;i++)
	{
		ans+=a[i]*2;
	}
	ans-=a[1];
	if(n%2==1 && n>1)
		ans+=a[(n+1)/2];
	cout<<ans<<endl;
	return 0;
} 


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    int n;
    cin >> n;
    int a;
    llint cnt = 0;
    llint ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ans = (ans % MOD + (a * (cnt % MOD)) % MOD) % MOD;
        cnt += a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static int cnt=0;
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        a = bubble(a, n);
        outPut(a, n);
        System.out.println(cnt);
	}
	
	public static int[] bubble(int[] a, int n) {
		boolean flag = true;
		int tmp;
		while(flag) {
			flag = false;
			for(int j = n-1; j > 0; j--) {
				if(a[j] < a[j-1]) {
					tmp = a[j];
					a[j] = a[j-1];
					a[j-1] = tmp;
					cnt++;
					flag = true;
				}
			}
		}
		return a;
	}
	public static void outPut(int[] a, int n) {
		for(int i = 0; i < n-1; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println(a[n-1]);
	}
}


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

void main(){
	auto a=readln.split.to!(int[]),n=a[0],k=a[1];
	if(n%k>0)writeln(1);
	else if(n%k==0)writeln(0);
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::string> s(n);
    for(int i = 0; i < n; i++){
        std::cin >> s[i];
    }
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == "AC"){
            ac += 1;
        }
        else if(s[i] == "WA"){
            wa += 1;
        }
        else if(s[i] == "TLE"){
            tle += 1;
        }
        else if(s[i] == "RE"){
            re += 1;
        }
    }
    std::cout << "AC x " << ac << std::endl << "WA x " << wa << std::endl << "TLE x " << tle << std::endl << "RE x " << re << std::endl;
}

Measured memory_bytes: 6376
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
using pii = pair<int,int>;
using vi = vector<int>;
constexpr int INF = 0x7fffffff;

constexpr int beki2(int n){
    int p = 1;
    while (p < n) p <<= 1;
    return p;
}

struct SegTree
{
    vi dat;
    const int N;

    SegTree(int n): N(beki2(n)), dat(N*2+1, INF) {}

    void update(int i, int v)
    {
        dat[i+=N-1] = v;
        while (i > 0) {
            i = (i-1) / 2;
            dat[i] = min(dat[i*2+1], dat[i*2+2]);
        }
    }

    int query(int a, int b, int k, int l, int r) 
    {
        if (r <= a || b <= l) return (INF);
        if (a <= l && r <= b) return (dat[k]);
        int mid = (l+r) / 2;
        return min(
                query(a,b, k*2+1, l, mid),
                query(a,b, k*2+2, mid, r)
        );
    }

    int query(int a, int b) { return query(a,b, 0, 0, N); }
};

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

   int n, q;
   cin >> n >> q;
   SegTree seg(n);

   int com, x, y;
   while (q--) {
       cin >> com >> x >> y;
       if (com == 0) {
           seg.update(x, y);
       } else {
           outl( seg.query(x, y+1) );
       }
   }
}




Measured memory_bytes: 35840
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c = map(int, readline().split())
if a + b < c and (c - b - a) ** 2 > 4 * a * b:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n = int(input())
h_list = list(map(int, input().split()))
dp = [0, abs(h_list[1] - h_list[0])]
for i in range(2, n):
    dp.append(min(dp[i - 2] + abs(h_list[i - 2] - h_list[i]), dp[i - 1] + abs(h_list[i - 1] - h_list[i])))
print(dp[-1])

Measured memory_bytes: 13980
<?php
$str = trim(fgets(STDIN));
if(substr($str, 0, 1) == "A"){
	$str2 = substr($str, 2, -1);
	if(substr_count($str2, "C") == 1){
		$str = substr($str , 1, strlen($str)-1);
		$str = str_replace("C", "", $str);
		if(ctype_lower($str)){
			echo "AC";
		}else{
			echo "WA";
		}
	}else{
		echo "WA";
	}
}else{
	echo "WA";
}


Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int N;
int main(){
  cin >> N;
  vector<int> d(N, 0);
  for(int i=0; i<N; ++i){
    cin >> d[i];
  }
  sort(d.begin(),d.end(), greater<int>());
  int counter = N;
  for(int i=0; i<N; ++i){
    if ( d[i] - d[i+1] == 0 && i != N-1) counter -= 1;
  }
  
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,sum=0;
  cin>>a>>b>>c;
  sum=a+b+c;
  if(sum==17)
  {cout<<"YES"<<endl;
  }
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makes(s);
	makei(w);
	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

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

    for (int i = 1; i <= 3500; i++)
        for (int j = i; j <= 3500; j++) {
            int a = i, b = j;
            int num = n * a * b;
            int deno = 4 * a * b - n * a - n * b;
            if (deno and num % deno == 0 and num / deno > 0) {
                cout << a << " " << b << " " << num/deno << endl;
                return;
            }
        }
}

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

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

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a), greater<int>());
	int ans = 0;
	ans += a[0] / 2;
	rep1(i, n - 1) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
	string s;
	int ans = 700;
	cin >> s ;
	for (int i = 0;i < 3;i++) {
		if (s[i] == 'o')
			ans += 100;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int mod = 1e9 + 7;

int main() {

	int n, m, l;
	bool state[100010];
	int pattern[100010];

	cin >> n >> m;

	for (int i = 0; i < n+5; i++) {
		state[i] = true;
	}

	pattern[0] = 1;

	for (int i = 1; i < n+5; i++) {
		pattern[i] = 0;
	}

	for (int i = 0; i < m; i++) {
		cin >> l;
		state[l] = false;
	}

	for (int i = 0; i < n +5; i++) {
		if (state[i + 1]) {
			pattern[i + 1] += pattern[i];
			pattern[i + 1] %= mod;
		}
		if (state[i + 2]) {
			pattern[i + 2] += pattern[i];
			pattern[i + 2] %= mod;
		}
	}

	cout << pattern[n] << endl;

	return 0;
}

//1,1,2,0,2,2,4
//1,1,2,3,5,8,13,21,34,55,89
//1,0,1,1,2


Measured memory_bytes: 768