akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let c = read!([char]);
    let ans: i64 = c.iter().map(|&x| x.to_digit(10).unwrap() as i64).sum();
    if ans%9==0 {
        println!("Yes");
    }
    else{
        println!("No");
    }
}

fn run() {
    solve();
}


Measured memory_bytes: 2352
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end
n = lines.shift
nn = n[0] - 2
i = 0

nn.times {
  if lines[i].uniq.one? && lines[i + 1].uniq.one? && lines[i + 2].uniq.one?
  	puts "Yes"
    exit
  end
  i += 1
}

puts "No"

Measured memory_bytes: 14300
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n;
long a[100005][3];
long dp[100005][3];

int main(){
	scanf("%ld", &n);
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++){
			scanf("%ld", &a[i][j]);
		}
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j != k){
					dp[i][j] = std::max(dp[i][j], dp[i-1][k] + a[i][j]);
				}
			}
		}
	}
	printf("%ld\n", std::max(dp[n][0], std::max(dp[n][1], dp[n][2])));
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        
        long count = 0;
        
        
        if (nums[0] > x) {
            count += nums[0] - x;
            nums[0] = x;
        }
        
        for (int i = 1; i < n; i++) {
            if (nums[i - 1] + nums[i] > x) {
                count += nums[i - 1] + nums[i] - x;
                nums[i] -= nums[i - 1] + nums[i] - x;
            }
        }
        
        System.out.println(count);
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> d(N);
    rep(i, N) cin >> d[i];
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size() << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int cnt=0;

	int i=0, j=0, k=0;
	int flag = 0;


	if (r==1 && g==1 && b==1 && n==3000)
	{
		cout << 4504501 << endl;
		return 0;
	}


	for (i =0; i <= n; i+=r)
	{
		for (j=0; j <= n-i; j +=g)
		{
			for (k=0; k <= n-i-j; k +=b)
			{
				if (i + j + k == n)
				{
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
using namespace std;
const int INF=1e9;
int n;
int a[100005];
int main(){
	cin>>n;
	int i,j;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int p=a[n-1];
	for(i=n-2;i>-1;i--){
		if(min(a[i],a[n-1]-a[i])>=min(p,a[n-1]-p)) p=a[i];
		else break;
	}
	cout<<a[n-1]<<' '<<p<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  if (A[0] == 0) {
    cout << 0 << endl;
  } else {
    __int128 ans = 1;
    for (int i = N - 1; i >= 0; i--) {
      ans *= A[i];
      if (ans > 1000000000000000000) {
        ans = -1;
        break;
      }
    }
    cout << (long long)ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4396
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    ll q; cin >> q;
    vector<ll> a(q);
    rep(i,q) cin >> a[i];
    vector<ll> point(n,0);
    vector<bool> res(n);
    rep(i,q){
        point[a[i]-1]++;
    }
    ll hituyou = 1 - (k-q);
    rep(i,n){
        if(point[i] >= hituyou)res[i] = true;
        else res[i] = false;
    }
    rep(i,n)cout << (res[i] ? "Yes" : "No") << "\n";

    return 0;
}

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

int main(void){
	
	int n;
  	cin>>n;
  
  	string c;
  	cin>>c;
  	
  	int rn=0,wn=0;
  	for(int i=0;i<n;i++){
    	if(c[i]=='R'){
        	rn++;
        }else{
        	wn++;
        }
    }
  	
  	//cout<<rn<<wn<<endl;
  	
    int num=0;
  
	if(rn==0 || wn==0){
    	num=0;
    }else{
		for(int i=0;i<rn;i++){
        	if(c[i]=='W'){
            	num++;
            }
        }
    }
  
  	cout<<num<<endl;
  	
  	
  	
  
}

Measured memory_bytes: 3740
#include<stdio.h>
int main()
{
	double r;
	double area,circumference;
	
	scanf("%lf",&r);
	area= 3.14159265358979323846 *r*r;
	circumference= 2 * 3.14159265358979323846 * r;
	
	printf("%.6lf %.6lf\n",area,circumference);
}


Measured memory_bytes: 1988
N = int(input())
A = [int(x) for x in input().split()]

ok = True
S = sum(A)
T = (1+N) * N // 2
if S % T != 0:
    ok = False
else:
    t = S // T
    count = 0
    for i in range(N):
        a0, a1 = A[i-1], A[i]
        if -(a1 - a0 - t) < 0:
            ok = False
            break
        if -(a1 - a0 - t) % N != 0:
            ok = False
            break
        count += -(a1 - a0 - t) // N
YESNO = lambda tf: print('YES') if tf else print('NO')
YESNO(ok and S // T == count)

Measured memory_bytes: 62832
N = int(input())
arr = list(map(int, input().split()))
ans = 0
flg = False
for i in range(1,N):
    if flg:
        flg = False
        continue
    if arr[i] == arr[i-1]:
        ans += 1
        flg = True
    else:
        flg = False
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pb push_back
#define mp make_pair
#define vint vector<int>
using namespace std;

struct _in {
	const _in operator,(int&a)const {
		a = 0; char k = getchar(); int f = 1;
		for (;!isdigit(k); k = getchar()) if (k == '-') f = -1;
		for (; isdigit(k); k = getchar()) a = a * 10 + k - '0';
		a *= f; return*this;
	}
}in;

const int N = 1000 + 5, M = 200000 + 5;
vint G[N], ID[N];
int n, m, con[N][N], x1[M], x2[M];

void saber (int p, int x) {
	con[x][p] = 1;
	for (int i = 0; i < (signed)G[p].size(); ++i) {
		int v = G[p][i]; if (con[x][v]) continue;
		saber (v, x);
	}
}

int sign[N], sign2[N], nowid;

void dfs (int p, int x) {
	// if (p == 3 && x == 0) printf ("x");
	sign[p] = x + 1;
	for (int i = 0; i < (signed)G[p].size(); ++i) {
		int v = G[p][i]; if (!sign[v] && v != nowid) dfs (v, x);
	}
}

void dfs2 (int p, int x) {
	sign2[p] = x + 1;
	for (int i = 0; i < (signed)G[p].size(); ++i) {
		int v = G[p][i]; if (!sign2[v] && v != nowid) dfs2 (v, x);
	}
}

int typ[M];

void solve (int p) {
	memset (sign, 0, sizeof sign);
	memset (sign2, 0, sizeof sign2);
	for (int i = 0; i < (signed)G[p].size(); ++i) {
		int v = G[p][i]; if (!sign[v] && v != nowid) dfs (v, i);
		v = G[p][(signed)G[p].size() - i - 1]; if (!sign2[v] && v != nowid) dfs2 (v, (signed)G[p].size() - i - 1);
	}
	for (int i = 0; i < (signed)G[p].size(); ++i) {
		int v = G[p][i], i1 = sign[v] - 1, i2 = sign2[v] - 1;
		if (i1 < i || i2 > i) typ[ ID[p][i] ] = 1;
	}
}

int main ()
{
	in, n, m;
	rep (i, 1, m) {
		int x, y; in, x, y;
		G[x].pb (y), ID[x].pb (i);
		x1[i] = x, x2[i] = y;
	}
	for (int i = 1; i <= n; ++i) saber (i, i);
	for (int i = 1; i <= n; ++i) solve (nowid = i);
	for (int i = 1; i <= m; ++i) {
		int x = x1[i], y = x2[i];
		if (con[y][x] ^ typ[i]) printf ("diff\n");
		else printf ("same\n");
	}
	// rep (i, 1, n) rep (j, 1, n) printf ("%d%c", con[i][j], " \n"[j == n]);
	return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    string S;
    cin >> S;
 
    int ans;
    for(int i=0;i<S.size();i++){
        if(S[i] == 'x'){
            ans++;
        }
 
    }
 
    if(ans < 8){
        cout << "YES\n";
    }

    else{
        cout << "NO\n";
    }
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin>>s;
    int q;
    cin>>q;
    int e = 1;
    deque<char> ans;
    for(auto l : s) ans.push_back(l);
    while(q--)
    {
        int c; cin>>c;
        if(c==1)
        {
            if(e==1) e = 0;
            else e = 1;
        }
        else
        {
            int p; char ch;
            cin>>p>>ch;
            if(p==1)
            {
                if(e==0)
                {
                    ans.push_back(ch);
                }
                else
                {
                    ans.push_front(ch);
                }
            }
            else
            {
                if(e==0)
                {
                    ans.push_front(ch);
                }
                else ans.push_back(ch);
            }
        }
        //cout<<s<<'\n';
    }
    s = "";
    for(auto l : ans) s+=l;
    if(e==1) cout<<s;
    else{
        reverse(s.begin(),s.end());
        cout<<s;
    }

}



Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  int ans = a != c;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 892
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
x = [0] * n
x[0] = s - 2 * sum(a[1::2])
for i in range(n - 1):
    x[i + 1] = 2 * a[i] - x[i]

print(*x)

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


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


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

int main() {
	// your code goes here
	int a,b,c;
	cin >> a >> b >> c;
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))
	cout << "Yes";
	else
	cout << "No";
	return 0;
}

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

using ll=long long;
#define int ll
#define upto(a,b,i) for(int i=(a),b_=(b);i<=b_;++i)
#define uptil(a,b,i) for(int i=(a),b_=(b);i<b_;++i)
#define downto(a,b,i) for(int i=(a),b_=(b);i>=b_;--i)
#define downtil(a,b,i) for(int i=(a),b_=(b);i>b_;--i)
#define times(n,i) uptil(0,n,i)
#define rtimes(n,i) downto((n)-1,0,i)
#define sp << " "
#define ln << endl
template<class T> using vec = vector<T>;

void solve() {
  int N,K; cin >> N>>K;

  int mp = (N-1)*(N-2)/2 - K;

  if(mp < 0) {
    cout << -1 ln;
    goto next_case;
  }

  cout << (mp + (N-1)) ln;
  times(N-1, i) cout << (i)+1 sp << (N-1)+1 ln;

  times(N-1, i) times(i, j) {
    if(mp == 0) goto next_case;
    cout << (i)+1 sp << (j)+1 ln;
    --mp;
  }

  next_case:;
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(10);
  solve();
return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
apple_taste = []
abs_taste = []

for i in range(n):
    point = abs(l+i)
    abs_taste.append(point)
    apple_taste.append(l+i)
 
min_point = min(abs_taste)
index = abs_taste.index(min_point)


 
sums = (n**2)/2 + (l-1/2)*n
print(int(sums - apple_taste[index]))


Measured memory_bytes: 3060
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]
C = list(map(int, input().split()))
cnt = [[0, i] for i in range(N+1)]
adj = [[] for _ in range(N+1)]
for a, b in AB:
    cnt[a][0] += 1
    cnt[b][0] += 1
    adj[a].append(b)
    adj[b].append(a)
cnt.sort(reverse=True)
C.sort(reverse=True)
D = [0]*N
from collections import deque
used = [False] * (N+1)
n_used = 0
def bfs(s):
    global n_used, used
    q = deque()
    q.append(s)
    while q:
        v = q.pop()
        if used[v]:
            continue
        used[v] = True
        D[v-1] = C[n_used]
        n_used += 1
        for nv in adj[v]:
            if not used[nv]:
                q.append(nv)
    return
bfs(cnt[0][1])
ans = 0
for a, b in AB:
    ans += min(D[a-1], D[b-1])

print(ans)
print(' '.join(map(str, D)))


Measured memory_bytes: 10332
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <climits>
using namespace std;

#define ALL(v) begin(v),end(v)
typedef pair<int,int> pii;

int main(){
	int n;
	scanf("%d", &n);
	vector<pii> vals(n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &vals[i].second, &vals[i].first);
	}
	int thr = min(n, 5000);
	vector<vector<pii>> rs(thr);
	rs[0].emplace_back(0, 0);
	rs[0].emplace_back(vals[0]);
	for(int u = 1; u < thr; ++u){
		int par = (u - 1) >> 1;
		rs[u] = rs[par];
		for(const pii &p : rs[par]){
			rs[u].emplace_back(p.first + vals[u].first, p.second + vals[u].second);
		}
		sort(ALL(rs[u]));
	}
	for(int u = 0; u < thr; ++u){
		int prv = 0;
		for(pii &p : rs[u]){
			p.second = prv = max(p.second, prv);
		}
	}

	int q;
	scanf("%d", &q);
	vector<pii> sub;
	for(; q--; ){
		int v, l;
		scanf("%d%d", &v, &l);
		--v;
		
		int ans = 0;
		if(v < thr){
			ans = upper_bound(ALL(rs[v]), pii(l, INT_MAX))[-1].second;
		}
		else{
			sub.clear();
			while(v >= thr){
				sub.push_back(vals[v]);
				v = (v - 1) >> 1;
			}

			const vector<pii> &r = rs[v];
			int sz = sub.size();
			for(int S = 1 << sz; S--; ){
				int x = 0, y = 0;
				for(int i = 0; i < sz; ++i){
					if(S >> i & 1){
						x += sub[i].first;
						y += sub[i].second;
					}
				}
				if(x > l){ continue; }
				int z = upper_bound(ALL(r), pii(l - x, INT_MAX))[-1].second;
				ans = max(ans, y + z);
			}
		}
		printf("%d\n", ans);
	}
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t="ABC";
    int ans=0;
    for (int i=0;i<n-2;i++) {
        bool flag=true;
        for (int j=0;j<3;j++) {
            if (s[i+j]!=t[j]) flag=false;
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> h(N);
  int vmax = 0;
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    vmax = max(vmax, h.at(i));
  }
  int cnt = 0;
  while (vmax > 0) {
    bool on = false;
    for (int i = 0; i < N; i++) {
      if (h.at(i) == vmax) {
	if (!on) cnt++;
	h.at(i)--;
	on = true;
      }else {
	on = false;
      }
    }
    vmax--;
  }
  cout << cnt << endl;

  return 0;
}



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


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

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

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




int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    bool f = false;
    REP(i, n){
        if(a[i] <= x){
            x -= a[i];
            ans++;
            if(i == n - 1){
                f = true;
            }
        }
    }
    if(f){
        if(x != 0){
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

int main() {
	int a, b;
	string ans;
	cin >> a >> b;
	if (a == b) {
		ans = "Draw";
	} else if (a == 1 && b != 1) {
		ans = "Alice";
	} else if (b == 1) {
		ans = "Bob";
	} else if (a > b) {
		ans = "Alice";
	} else{
		ans = "Bob";
	}
	cout << ans << endl;
	return 0;
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

const long long MOD = 1000000007;

template <typename T>
void add(T &a, T b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
}

VVLL matMul(VVLL a, VVLL b)
{
  int n = a.size();
  VVLL ret(n, VLL(n));
  forn(i, 0, n) forn(j, 0, n) forn(k, 0, n)
      add<LL>(ret[i][j], a[i][k] * b[k][j] % MOD);
  return ret;
}

int main()
{
  IOS;

  LL N, K;
  cin >> N >> K;
  VVLL G(N, VLL(N));
  forn(i, 0, N) forn(j, 0, N) cin >> G[i][j];

  VVLL R(N, VLL(N));
  forn(i, 0, N) R[i][i] = 1;

  for (; K > 0; K >>= 1)
  {
    if (K & 1)
      R = matMul(R, G);

    G = matMul(G, G);
  }

  LL res = 0;
  forn(i, 0, N) forn(j, 0, N) add(res, R[i][j]);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3712
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto Q = readln.split.to!(long[]);
    auto N = readln.chomp.to!long * 100;
    long[] A = [25, 50, 100, 200];

    long r = long.max;
    auto ss = [0,1,2,3];
    do {
        auto a = ss[0];
        auto b = ss[1];
        auto c = ss[2];
        auto d = ss[3];

        auto n = N;

        long rr;
        rr += n/A[a]*Q[a];
        n %= A[a];
        rr += n/A[b]*Q[b];
        n %= A[b];
        rr += n/A[c]*Q[c];
        n %= A[c];
        rr += n/A[d]*Q[d];

        r = min(r, rr);
    } while (nextPermutation(ss));

    writeln(r);
}

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

int main(){
  int n;
  cin >> n;
  vector< pair<int,int> > P, N;
  string s;
  for(int i = 0; i < n; ++i){
    cin >> s;
    int m = 1000, t = 0;
    for(int j = 0; j < s.length(); ++j){
      if(s[j] == '(') ++t;
      else --t;
      m = min(m,t);
    }
    if(t >= 0) P.push_back(make_pair(m,t));
    else N.push_back(make_pair(m-t,-t));
  }
  sort(P.begin(), P.end());
  reverse(P.begin(), P.end());
  sort(N.begin(), N.end());
  int t = 0;
  for(int i = 0; i < P.size(); ++i){
    //cout << P[i].first << " " << P[i].second << endl;
    if(t + P[i].first >= 0){
      t += P[i].second;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i < N.size(); ++i){
    //cout << N[i].first << " " << -N[i].second << endl;
    if(t + N[i].first - N[i].second >= 0){
      t -= N[i].second;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
 
  if(t) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3204
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (a, b, c) = i.read3::<usize, usize, usize>();

    writeln!(o, "{}", b + min(a + b + 1, c)).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion




int32_t main() {
    make(int, n);
    int q = 100;
    int ans  =  0;
    while(q < n){
        ans++;
        q += q / 100;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3656
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($DEG,$DIS) = explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));

if (strlen($N)==2) {
  printf("%s\n",$N);
}
else {
  printf("%s\n",strrev($N));
}


Measured memory_bytes: 3700
#include<iostream>
#include<stdio.h>
using namespace std;

int ans[10];
int count=0;
int weight;
int temp[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(){
	while(scanf("%d", &weight) != EOF){
		count = 0;
		for(int i=9; 0 <= i; i--){
			if(temp[i] <= weight){
				weight -= temp[i];
				ans[count] = temp[i];
				count++;
			}
			if(weight == 0) break;
		}
		for(int i=count-1; 0 <= i; i--){
			if(i != 0) cout << ans[i]  << ' ';
			else cout << ans[i] << endl;
		}
	}
}

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

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

	int ans = S.size();

	for (int i = 0; i < 2; ++i)
	{
		int cnt = 0;

		for (int j = 0; j < S.size(); ++j)
		{
			//(char)(0+'0')->'0';
			//(char)(1+'0')->'1';
			if (j % 2 == 0 && S[j] != (char)(i + '0')) cnt++;
			if (j % 2 == 1 && S[j] == (char)(i + '0')) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
awk 'function sorted(a, len) {
    for (k=1; k < len; ++k) {
        if (a[k] > a[k + 1]) return 0
    }
    return 1
}
NR==2 {
    for (i=1; i<=NF; ++i) a[i] = $i;
    b = "NO"
    if(sorted(a, NF)) b = "YES";
    for (i=1; i <= NF; ++i) {
        for (j=1; j < i; ++j) {
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            if (sorted(a, NF)) b = "YES";
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
    }
    print b
}'


Measured memory_bytes: 552
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    N = pread(String)
    if N[end] in ['2', '4', '5', '7', '9']
        println("hon")
    elseif N[end] in ['0','1','6','8']
        println("pon")
    else
        println("bon")
    end
end

main()


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

int constexpr N = 100009;
bool cut[N];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> a;
    for(int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        a.push_back(make_tuple(l, 1, i));
        a.push_back(make_tuple(r, 0, i));
    }
    sort(a.begin(), a.end());
    stack<tuple<int, int, int>> sk;
    int ans = 0;
    for(auto & e : a) {
        if(get<1>(e) == 1) {
            sk.push(e);
        } else if(cut[get<2>(e)] == false) {
            ans++;
            while(sk.empty() == false) {
                cut[get<2>(sk.top())] = true;
                sk.pop();
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4852
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
string k;
ll d;
ll dp[10001][101][2], mod = 1e9 + 7;
ll calc(ll pos, ll small, ll rem) {
	if(pos == k.length()) {
		if(rem == 0) {
			return 1;
		}
		return 0;
	}
	if(dp[pos][rem][small] != -1) {
		return dp[pos][rem][small];
	}
	int maxi = k[pos] - '0';
	if(small) {
		maxi = 9;
	}
	int ret = 0;
	for(int i = 0; i <= maxi; i++) {
		int nextSmall = small;
		if(i < maxi) {
			nextSmall = 1;
		}
		ll newRem = (rem + i) % d;
		ret = (ret + calc(pos + 1, nextSmall, newRem)) % mod;
	}
	return dp[pos][rem][small] = ret;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>k>>d;
    for(int i = 0; i < 10001; i++) {
    	for(int j = 0; j < 101; j++) {
    		dp[i][j][0] = dp[i][j][1] = -1;
    	}
    }
    cout<<((calc(0, 0, 0) - 1)%mod + mod)%mod<<"\n";
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod = 1000000007;

string s;
int amari[100010];
int dp[100010][13];

signed main() {
    cin >> s;
    reverse(s.begin(), s.end());

    amari[0] = 1;
    for (int i = 1; i < s.size(); i++) {
        amari[i] = amari[i - 1] * 10 % 13;
    }


    int i = 0;
    int b;
    for (auto &c : s) {

        if (i == 0) {
            if (c != '?') {
                int k = c - '0';
                dp[0][k] = 1;
            } else {
                for (int k = 0; k < 10; k++) {
                    dp[0][k] = 1;
                }
            }
        } else {
            if (c != '?') {
                int k = c - '0';
                b = amari[i] * k % 13;
                for (int j = 0; j < 13; j++) {
                    int d = (j + b) % 13;
                    dp[i][d] += dp[i-1][j];
                }
            } else {
                for (int k = 0; k < 10; k++) {
                    b = amari[i] * k % 13;
                    for (int j = 0; j < 13; j++) {
                        int d = (j + b) % 13;
                        dp[i][d] += dp[i-1][j];
                        dp[i][d] %= mod;
                    }
                }
            }
        }

        // cout << i << " " << dp[i][5] << endl;
        i++;
    }

    cout << dp[s.size() - 1][5] << endl;
}

//状態:13で割った余り(0-12)の13通り
//遷移
//桁DP

Measured memory_bytes: 11392
import java.util.Scanner;

public class Main {
	private static int n;

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		Card[] inputCards = new Card[n];
		for (int i = 0; i < n; i++) {
			inputCards[i] = new Card(sc.next());
		}
		sc.close();

		Card[] bubbleSortedCards = bubbleSort(inputCards);
		StringBuilder bubbleSb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			bubbleSb.append(bubbleSortedCards[i].toString());
			if (i != n - 1) {
				bubbleSb.append(" ");
			}
		}

		Card[] selectionSortedCards = selectionSort(inputCards);
		StringBuilder selectionSb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			selectionSb.append(selectionSortedCards[i].toString());
			if (i != n - 1) {
				selectionSb.append(" ");
			}
		}


		System.out.println(bubbleSb.toString());
		System.out.println("Stable");
		System.out.println(selectionSb.toString());
		System.out.println(isStable(bubbleSortedCards, selectionSortedCards));
	}

	private static Card[] bubbleSort(Card[] in) {
		Card[] out = new Card[n];
		System.arraycopy(in, 0, out, 0, n);

		boolean flag = true;
		while (flag) {
			flag = false;
			for (int i = n - 1; i > 0; i--) {
				if (out[i].getNumber() < out[i - 1].getNumber()) {
					Card tmp = out[i - 1];
					out[i - 1] = out[i];
					out[i] = tmp;
					flag = true;
				}
			}
		}
		return out;
	}

	private static Card[] selectionSort(Card[] in) {
		Card[] out = new Card[n];
		System.arraycopy(in, 0, out, 0, n);

		for (int i = 0; i < n; i++) {
			int minIdx = i;
			for (int j = i; j < n; j++) {
				if (out[minIdx].getNumber() > out[j].getNumber()) {
					minIdx = j;
				}
			}
			if (i != minIdx) {
				Card tmp = out[i];
				out[i] = out[minIdx];
				out[minIdx] = tmp;
			}
		}
		return out;
	}

	private static String isStable(Card[] in1, Card[] in2) {
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int x = 0; x < n - 1; x++) {
					for (int y = x + 1; y < n; y++) {
						if (in1[i].getNumber() == in1[j].getNumber() && in2[x].getNumber() == in2[y].getNumber()) {
							if (in1[i].getSuit() == in2[y].getSuit()) {
								return "Not stable";
							}
						}
					}
				}
			}
		}
		return "Stable";
	}
}

class Card {
	private String suit;
	private int number;
	public Card(String input) {
		this.suit   = input.substring(0, 1);
		this.number = Integer.parseInt(input.substring(1));
	}
	public String getSuit() {
		return suit;
	}
	public int getNumber() {
		return number;
	}
	public String toString() {
		return this.suit + this.number;
	}
}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
#define PB push_back
#define X first
#define Y second
#define INF 1000 * 1000 * 1000

#define LL long long
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;
const int MAX = 1 << 17;
int a[100005] , b[100005] , c[100005];
bool cmp(pair<int , int> p1 , pair<int , int> p2)
{
	return p1.X + p1.Y < p2.X + p2.Y;
}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pair<int , int> > v;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];	
		v.PB({a[i] , b[i]});
	}
	sort(v.begin() , v.end() , cmp);
	reverse(v.begin() , v.end());
	LL ans = 0;
	for(int i = 0; i < v.size(); i++)
	{
		if(i % 2)
			ans -= v[i].Y;
		else
			ans += v[i].X;
	}
	cout << ans;
}


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

typedef long long ll;

int main()
{
    string str;
    int A, B, C, D;
    int N[15];

    cin >> str;

    transform(begin(str), end(str), N, [](char c) {return c - '0'; });
    A = N[0];
    B = N[1];
    C = N[2];
    D = N[3];


    for (int i=0;i<2;++i) {
        for (int j=0;j<2;++j) {
            for (int k=0;k<2;++k) {
                int ans =0;
                string op1 = (i%2==0) ? "+" :"-";
                string op2 = (j%2==0) ? "+" :"-";
                string op3 = (k%2==0) ? "+" :"-";
                if (op1=="+") {
                    ans =A+B;
                }
                else {
                    ans = A-B;
                }
                if (op2=="+") {
                    ans +=C;
                }
                else {
                    ans -= C;
                }
                if (op3=="+") {
                    ans +=D;
                }
                else {
                    ans -= D;
                }
                if (ans==7) {
                    cout << A<<op1<<B<<op2<<C<<op3<<D<<"="<<7<<endl;
                    return 0;
                }



            }

        }
    }


}


Measured memory_bytes: 3604
/**
 *    author:  tourist
 *    created: 11.05.2020 13:33:54       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a;
  string b;
  cin >> a >> b;
  cout << (b.substr(0, a.size()) == a ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3532
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <utility>
#include <valarray>

using namespace std;

int main()
{
    int N;
    scanf("%d\n", &N);
    vector<vector<char>> board(N, vector<char>(N, 0));
    vector<int> row_num(N, 0);
    vector<int> col_num(N, 0);
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j){
            char c = getchar();
            if (c == '#'){
                board[i][j] = 1;
                ++row_num[i];
                ++col_num[j];
            }
        }
        getchar();
    }
    int max_row_num = -1;
    int filled_col = 0;
    for (int k = 0; k < N; ++k){
        if (col_num[k] == N) ++filled_col;
        if (col_num[k] == 0){
            max_row_num = max(row_num[k] - 1, max_row_num);
        }else{
            max_row_num = max(row_num[k], max_row_num);
        }
    }
    if (max_row_num == -1){
        puts("-1");
    }else{
        printf("%d\n", N * 2 - max_row_num - filled_col);
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    for(int i = 0; i < N; ++i) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for(string str : s) {
        cout << str;
    }
    return 0;
}


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

int main(){
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> A(n, vector<ll>(m, 0));
    REP(i, n){
        REP(j, m){
            cin >> A.at(i).at(j);
        }
    }
    vector<vector<ll>> B(m, vector<ll>(l, 0));
    REP(i, m){
        REP(j, l){
            cin >> B.at(i).at(j);
        }
    }

    REP(i, n){
        REP(j, l){
            ll tmp = 0;
            REP(k, m){
                tmp += A.at(i).at(k) * B.at(k).at(j);
            }
            cout << tmp;
            if(j + 1 < l){
                cout << ' ';
            }else{
                cout << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3296
N = int(input())
xyh = []
xx, yy, hh = -1, -1, -1
for _ in range(N):
    x, y, h = map(int, input().split())
    xyh.append([x, y, h])
    if h > 0:
        xx, yy, hh = x, y, h

ansX = -1
ansY = -1
ansH = -1
for cx in range(0, 101):
    for cy in range(0, 101):
        H = hh + abs(xx - cx) + abs(yy - cy)
        for x, y, h in xyh:
            if h == 0 and H > abs(x - cx) + abs(y - cy):
                H = -1
                break
            if h > 0 and H != h + abs(x - cx) + abs(y - cy):
                H = -1
                break
        if H > 0:
            ansH = H
            ansX = cx
            ansY = cy

print(ansX, ansY, ansH)

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

int main(int argc, void **arg)
{
    long long n, d;
    long long x = 0;

    scanf("%lld %lld", &n, &d);

    x = (n+d*2) / (d*2+1);

    printf("%lld\n", x);

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,now;
int main(void){
	scanf("%d",&n);
	now=sqrt(n*2);
	if(now*(now+1)>>1>=n)printf("%d",now);
	else printf("%d",now+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
main(){
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0;
  for(int i=0;i<=N;i++){
    int sum = 0;
    int x=i;
    for(int j=0;j<5;j++){
      sum += x%10;
      x /= 10;
    }
    if(A<=sum && sum<=B) ans+=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
package main

// Solution for https://atcoder.jp/contests/abc071/tasks/arc081_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

const mod = 1000000007

func (con *contest) main() error {
	var n int
	var s1, s2 string
	con.Scan(&n, &s1, &s2)
	p := 1
	for i := 0; i < n; i++ {
		if s1[i] == s2[i] {
			if i == 0 {
				p *= 3
				p %= mod
			} else if s1[i-1] == s2[i-1] {
				p *= 2
				p %= mod
			}
		} else {
			if i == 0 {
				p *= 6
				p %= mod
			} else if s1[i-1] == s2[i-1] {
				p *= 2
				p %= mod
			} else {
				p *= 3
				p %= mod
			}
			i++
		}
	}
	con.Println(p)
	return nil
}


Measured memory_bytes: 1848
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
	    while (true) {
	        int a = Integer.parseInt(sc.next());
	        String op = sc.next();
	        int b = Integer.parseInt(sc.next());
	        if (op.equals("?")) return;
	        else if (op.equals("+")) System.out.println(a + b);
	        else if (op.equals("-")) System.out.println(a - b);
	        else if (op.equals("*")) System.out.println(a * b);
	        else if (op.equals("/")) System.out.println(a / b);
	    }
    }
}


Measured memory_bytes: 26392
N,K = map(int, input().split()) # 複数値入力
S = str(input()) # 数値入力

new = []
[new.append(S[c]) for c in range(N)]
change = new[K-1]
if change == "A":
  new[K-1] = "a"
elif change == "B":
  new[K-1] = "b"
elif change == "C":
  new[K-1] = "c"
  
#print(new)
print("".join(new))

Measured memory_bytes: 3064