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

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};
// Module for v1.15.1
use std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead

// Functions

// Main
fn main(){

    input!{
        N: usize,
        K: usize
    }

    let mut ans = 0.0;

    let mut m = 0;
    let mut a = vec![(K,m); 1];
    let mut Kf = K as f64;
    while Kf > 1.0{
        Kf = (Kf/2.0).ceil();
        m += 1;
        a.push( (Kf.ceil() as usize, m) );
    }

    a.reverse();
    for i in 0..a.len(){
        let w;
        if i == a.len()-1{
            w = N - a[i].0 + 1;
            ans += w as f64 / (2_i32.pow(a[i].1)) as f64;   
            //println!("c {} {} : {} : {}", w, a[i].1, a[i].0, w as f64 / (2_i32.pow(a[i].1)) as f64);
            break;
        }else if a[i+1].0 > N{
            w = N - a[i].0 + 1;
            ans += w as f64 / (2_i32.pow(a[i].1)) as f64;   
            //println!("c {} {} : {} : {}", w, a[i].1, a[i].0, w as f64 / (2_i32.pow(a[i].1)) as f64);
            break;
        } else{
            w = a[i+1].0 - a[i].0;
            ans += w as f64 / (2_i32.pow(a[i].1)) as f64;  
            //println!("c {} {} : {} : {}", w, a[i].1, a[i].0, w as f64 / (2_i32.pow(a[i].1)) as f64);
        }
    }

    //println!("{:?}", a);
    println!("{}", ans / N as f64);
}

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

int main() {
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  string s; cin >> s;
  string ans = "Yes";
  bool space = false;
  for (int i = a; i <= max(c,d); i++) {
    if (a < i && i <= c) {
      if (s[i] == '#' && s[i+1] == '#') {ans = "No"; break;}
    }
    if (b <= i && i <= d) {
      if (s[i] == '#' && s[i+1] == '#') {ans = "No"; break;}
      if (s[i] == '.' && s[i-1] == '.' && s[i+1] == '.') space = true;
    }
  }
  if (c > d && !space) ans = "No";
  cout << ans << endl;
  return 0;
}

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

struct node{
	int key;
	node *parent,*left,*right;
	node():left(nullptr),right(nullptr){}
};

node*insert(node*root,int key){
	node*z=new node;
	z->key=key;
	node*x=root,*y=nullptr;
	while(x!=nullptr){
		y=x;
		if(z->key<x->key)x=x->left;
		else x=x->right;
	}
	if(y==nullptr)root=z;
	else if(z->key<y->key)y->left=z;
	else y->right=z;
	z->parent=y;
	return root;
}

node*search(node*z,int key){
	while(z!=nullptr&&key!=z->key){
		if(key<z->key)z=z->left;
		else z=z->right;
	}
	return z;
}

void find(node*root,int key){
	cout<<(search(root,key)!=nullptr?"yes"s:"no"s)<<"\n"s;
}

node*getmin(node*x){
	while(x->left!=nullptr)x=x->left;
	return x;
}

node*getsuccessor(node*x){
	node*u;
	if(x->right!=nullptr)u=getmin(x->right);
	else{
		node*y=x->parent;
		while(y!=nullptr&&y!=y->left)y=y->parent;
		u=y;
	}
	return u;
}

node*delnode(node*root,int key){
	node*z=search(root,key),*y,*x;
	if(z->left==nullptr||z->right==nullptr)y=z;
	else y=getsuccessor(z);
	if(y->left!=nullptr)x=y->left;
	else x=y->right;
	if(x!=nullptr)x->parent=y->parent;
	if(y->parent==nullptr)root=x;
	else if(y==y->parent->left)y->parent->left=x;
	else y->parent->right=x;
	if(y!=z)z->key=y->key;
	return root;
}

void inorder(node*z){
	if(z==nullptr)return;
	inorder(z->left);
	cout<<" "s<<z->key;
	inorder(z->right);
}

void preorder(node*z){
	if(z==nullptr)return;
	cout<<" "s<<z->key;
	preorder(z->left);
	preorder(z->right);
}

void print(node*root){
	inorder(root);
	cout<<"\n"s;
	preorder(root);
	cout<<"\n"s;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int m;
	cin>>m;
	node *root=nullptr;
	string com;
	for(int i=0,k;i<m;++i){
		cin>>com;
		if(com=="print"s)print(root);
		else{
			cin>>k;
			if(com=="insert"s)root=insert(root,k);
			else if(com=="find"s)find(root,k);
			else root=delnode(root,k);
		}
	}
}


Measured memory_bytes: 21808
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ll long long
#define int long long
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';

using namespace std;

const int N = (int)(1e6) + 322;
const int MAXN = (int)(1e7) + 100;
const int inf = (int)(1e18) + 322;
const int mod = 998244353;
const double eps = 1e-6;
#define endl "\n" // remove


signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin >> n >> k;
    n %= k;
    cout << min(k - n, n);
    return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

a,v = iim()
b,w = iim()
t = ii()
if v <= w:
    print('NO')
elif abs(a-b) <= (v-w)*t:
    print('YES')
else:
    print('NO')

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

int main () {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool left = false, right = false;
      for(int j = 0; j < i; j++) {
        if (s.at(j) == c) left = true;
      }
      for(int j = i; j < n; j++) {
        if (s.at(j) == c) right = true;
      }
      if (left && right) count++;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int dp[100][21];
int main(){
  int n, i, j, first, num, ans;
  scanf("%d", &n);
  scanf("%d", &first);
  dp[0][first] = 1;
  for(i = 1;i < n - 1;i++){
    scanf("%d", &num);
    for(j = 0;j <= 20;j++){
      if(j + num <= 20){
	dp[i][j] += dp[i - 1][j + num];
      }
      if(j - num >= 0){
	dp[i][j] += dp[i - 1][j - num];
      }
    }
  }
  scanf("%d", &ans);
  printf("%lld\n", dp[n - 2][ans]);
  return 0;
}

Measured memory_bytes: 616
from collections import deque

N, Q = map(int, input().split())

cnt = {a: 0  for a in range(1, N + 1)}
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

for j in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

# BFS
visited = set()
queue = deque()
queue.append(1)
while len(queue) > 0:
    a = queue.popleft()
    visited.add(a)
    for b in adj[a]:
        if b in visited:
            continue
        cnt[b] += cnt[a]
        queue.append(b)

print(' '.join(map(str, (cnt[a] for a in range(1, N + 1)))))

Measured memory_bytes: 110948
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
 
    string S;
    cin >> S;
    
    int ans = 0;
    int count = 0;
    
    for(int i = 0; i <= S.size(); i++){
        
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            count++;
        }
        else{
        ans = max(ans, count);
        count = 0;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>

#define FILE_NAME "A"
#define SZ(x) ((int) x.size())
#define pb push_back
#define ppb pop_back
#define x first
#define y second
#define mkp make_pair
#define show(x) cout << (#x) << ": " << x << endl

using namespace std;
// using namespace __gnu_pbds;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
template<typename T> using Array = vector<T>;
template<typename T> using Matrix = Array<Array<T>>;
using Graph = Matrix<int>;

// template<typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T> bool relax(T& r, const T& x) {
    if (x < r) {
        r = x;
        return true;    
    }
    return false;
}

template<typename T> bool heavy(T& h, const T& x) {
    if (h < x) {
        h = x;
        return true;            
    }
    return false;
}

const int DX[8] = {-1, +1, +0, +0, +1, -1, +1, -1};
const int DY[8] = {+0, +0, -1, +1, +1, -1, -1, +1};

/************************************************************
* find_by_order(k) = iterator to (k)-th greatest element    *
* order_of_key(k) = counts number of strictly less elements *
*************************************************************/                                                           

signed main() {
#ifdef LOCAL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int cnt = 0;
    ll ans = 0;
    for (int i = 0; i < (int) s.size(); i++)
        if (s[i] == 'W')
            ans += i - cnt, cnt++;
    cout << ans;   
    return false;
}

Measured memory_bytes: 720
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long x,t;
	cin >> x >> t;
	
	if(x-t >= 0)
		P(x-t);
	else
		P(0);
	ret 0;
}

Measured memory_bytes: 764
using System;

namespace _048_Class
{
	class Program
	{
		static void Main ( string[] args )
		{
			double[] weightArray = { 48, 51, 54, 57, 60, 64, 69, 75, 81, 91, double.MaxValue };

			string[] message = { "light fly", "fly", "bantam", "feather", "light", "light welter", 
								 "welter", "light middle", "middle", "light heavy", "heavy" };

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				double inputNum = double.Parse (inputStr);

				int index = 0;
				while (weightArray[index] < inputNum)
				{
					index++;
				}

				Console.WriteLine (message[index]);
			}
		}
	}
}

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

constexpr int INF = (1<<30)-1;

bool solve() {
    int N, M;
    int C[16];

    cin >> N >> M;
    if (N == 0) return (false);
    for (int i = 0; i < M; i++) cin >> C[i];

    vector<vector<int>> dp(20005, vector<int>(256, INF));
    dp[0][128] = 0;
    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        for (int j = 0; j < 256; j++) {
            for (int k = 0; k < M; k++) {
                int nn = max(0, min(255, j + C[k]));
                int &next = dp[i + 1][nn];
                next = min(next, dp[i][j] + (nn-v)*(nn-v));
            }
        }
    }
    cout << *min_element(begin(dp[N]), end(dp[N])) << endl;
    return (true);
}
int main() {
    while (solve());
    return (0);
}


Measured memory_bytes: 23612
n,q=gets.split.map(&:to_i)
s = gets.chomp
sum=Array.new(n+1,0)
n.times do |i|
  sum[i+1] += sum[i]
  sum[i+1] += 1 if s[i,2] == 'AC'
end
q.times do
  l,r = gets.split.map(&:to_i)
  puts sum[r-1]-sum[l-1]
end


Measured memory_bytes: 3324
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += (b - a) // 2

if cnt < 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 4596
NN = input()
AA = int(NN[0:2])
BB = int(NN[2:])

count1 = 0
count2 = 0
if AA > 12 or AA == 00:
  count1 +=1
if BB > 12 or BB == 00:
  count2 +=1
if count1 == 0 and count2 == 0:
  print('AMBIGUOUS')
elif count1 ==1 and count2 == 0:
  print('YYMM')
elif count1 ==0 and count2 == 1:
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int add(int a, int b){return  a + b > mod ? a + b - mod : a + b;}
int mul(int a, int b){return a * b >= mod ? a * b % mod : a * b;} 
int main(){
    //FL;
    FIN;
    int n;
    cin >> n;
    int aux = n / 1000 +(n % 1000 != 0);
    
    cout << aux * 1000 - n << '\n';
    EjecuteTime;
    return 0;
}       

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

int n;
int v[100010];
int c[2][100010];
int vmax[2];
int idx[2];
int cmax[2];
int idx2[2];
int cmax2[2];

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}

	for (int i = 0; i < n; ++i) {
		c[i & 1][v[i]]++;
		vmax[i & 1] = max(vmax[i & 1], v[i]);
	}

	for (int i = 0; i < 2; ++i) {
		auto it = max_element(c[i], c[i] + vmax[i] + 1);
		idx[i] = distance(c[i], it);
		cmax[i] = *it;
	}

	int ans = 0;

	if (idx[0] == idx[1]) {
		for (int i = 0; i < 2; ++i) {
			c[i][idx[i]] = 0;
			auto it = max_element(c[i], c[i] + vmax[i] + 1);
			idx2[i] = distance(c[i], it);
			cmax2[i] = *it;
		}

		int a[2] = {};
		a[0] += (n + 1) / 2 - cmax2[0];
		a[0] += n / 2 - cmax[1];
		a[1] += (n + 1) / 2 - cmax[0];
		a[1] += n / 2 - cmax2[1];
		ans = min(a[0], a[1]);
	}
	else {
		ans += (n + 1) / 2 - cmax[0];
		ans += n / 2 - cmax[1];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
n = input()

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if (a+b+c+d) == 7:
    print(a, "+" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a+b+c-d) == 7:
    print(a, "+" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a+b-c+d) == 7:
    print(a, "+" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a+b-c-d) == 7:
    print(a, "+" ,b, "-" ,c, "-", d, "=7", sep="")
elif (a-b+c+d) == 7:
    print(a, "-" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a-b+c-d) == 7:
    print(a, "-" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a-b-c+d) == 7:
    print(a, "-" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a-b-c-d) == 7:
    print(a, "-" ,b, "-" ,c, "-", d, "=7", sep="")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int main() {
   int d, t, s;
   cin >> d >> t >> s;
   if(d<=t*s) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
    return 0;
}

Measured memory_bytes: 3584
n = int(raw_input())
value = []
for i in xrange(n):
    a, b, c = map(int, raw_input().split())
    value.append((a, b, c))
dp1 = [0 for i in xrange(n)]
dp2 = [0 for i in xrange(n)]
dp3 = [0 for i in xrange(n)]
dp1[0] = value[0][0]
dp2[0] = value[0][1]
dp3[0] = value[0][2]
for i in xrange(1, n):
    a, b, c = value[i]
    dp1[i] = max(dp2[i-1], dp3[i-1]) + a
    dp2[i] = max(dp1[i-1], dp3[i-1]) + b
    dp3[i] = max(dp2[i-1], dp1[i-1]) + c
res = max([dp1[n-1], dp2[n-1], dp3[n-1]])
print res


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

int main()
{
    string cmd;
    int num;
    priority_queue<int> Q;
    while (cin >> cmd && cmd != "end")
    {
        if (cmd == "insert")
        {
            cin >> num;
            Q.push(num);
        }
        else if (cmd == "extract")
        {
            int n=Q.top();
            Q.pop();
            cout << n << endl;
        }
    }
}


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

class Solve {
private:
	int r, n;
	int buildings[40]{};

	bool is_safe(double time)
	{
		for (int i{20 - r}; i < 20 + r; i++)
		{
			double height[2]{sqrt(r * r - (-20 + i) * (-20 + i)) - r + time, sqrt(r * r - (-20 + i + 1) * (-20 + i + 1)) - r + time};
			if (buildings[i] < height[0] || buildings[i] < height[1])
				return false;
		}
		return true;
	}
public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d%d", &r, &n);
		if (r == 0 && n == 0)
		{
			is_last_query = true;
			return;
		}

		for (int n_i{}; n_i < n; n_i++)
		{
			int l, r, h;
			scanf("%d%d%d", &l, &r, &h);
			for (int b_i{20 + l}; b_i < 20 + r; b_i++)
				buildings[b_i] = std::max(buildings[b_i], h);
		}

		double safe{0}, out{20};
		while (safe + 1e-4 < out)
		{
			double mid{(safe + out) / 2};
			if (is_safe(mid)) safe = mid;
			else out = mid;
		}
		printf("%lf\n", out);
		return;
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, M;
string S, T;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin >> N >> M >> S >> T;
    ll g = gcd(N, M);
    ll l = N * M / g;
    bool judge = true;
    for(ll i = 0; (l / M) * i < N; i++) {
        if(S[(l / M) * i] != T[(l / N) * i]) {
            judge = false;
            break;
        }
    }
    cout << (judge ? l : -1) << "\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
		cin >> a[i];
    }
    int dp[n];
    dp[0] = 0, dp[1] = abs(a[1] - a[0]);
    for(int i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }

    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 4308
#include <iostream>
using namespace std;
#define MAX_N 110
#define MAX_V 100100
typedef long long ll;
const ll INF = 1LL << 60;
int N, W;
int w[MAX_N];
int v[MAX_N];
ll dp[MAX_N][MAX_V];


int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
    for (int i = 0; i < MAX_N; i++) {
        for (int j = 0; j < MAX_V; j++) dp[i][j] = INF;
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < MAX_V; j++) {
            if (j < v[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }
    ll ans = 0; 
    for (int j = 0; j < MAX_V; j++) {
        if (dp[N][j] <= W) ans = j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 86272
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInts(n)
	m := nextInt()
	t := nextInts(m)
	sort.Sort(sort.IntSlice(d))
	sort.Sort(sort.IntSlice(t))

	di := 0
	for i := range t {
		for di < n && d[di] < t[i] {
			di++
		}
		if di == n {
			fmt.Println("NO")
			return
		}
		if d[di] > t[i] {
			fmt.Println("NO")
			return
		}
		di++
	}
	fmt.Println("YES")
}


Measured memory_bytes: 6784
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
    val k = readLine()!!.toInt()
    val max = Math.max(a, Math.max(b, c))
    val r = max * Math.pow(2.toDouble(), k.toDouble()).toInt() - max + a + b + c
    println(r)
}


Measured memory_bytes: 35948
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		long n,min = 0,max = 0,sum = 0,work;
		n = sc.nextInt();
		min = max = sum = work = sc.nextInt();
		for(int i = 0; i < n - 1; i++){
			work = sc.nextInt();
			if(work > max){
				max = work;
			}
			if(work < min){
				min = work;
			}
			sum += work;
		}
		
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 41152
if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [list(input()) for i in range(H)]

    SS = [[0 for i in range(W+2)] for j in range(H+2)]


    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                # pass
                SS[i+1][j+1] = 1

    answer = S.copy()

    dx = [0,1,2,0,2,0,1,2]
    dy = [0,0,0,1,1,2,2,2]

    for i in range(H):
        for j in range(W):
            if answer[i][j] ==  '.':
                tmp = 0
                for k in range(8):
                    x = j + dx[k]
                    y = i + dy[k]
                    tmp += SS[y][x]
                answer[i][j] = str(tmp)

    for i in range(H):
        print("".join(answer[i]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
long long int a[100000][2];
long long int dp[100][100000];

long long int maxi(long long int a,long long int b)
{
    if(a>b)
        return a;
    return b;
}

long long int find(int i,int j,int n,int w)
{
    if(i >= n)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    long long int x = 0;
    if((a[i][0]+j)<=w)
        x = maxi(find(i+1,j,n,w),(a[i][1] + find(i+1,j+a[i][0],n,w)));
    else
        x=find(i+1,j,n,w);

    return dp[i][j] = x;
}


int main()
{
    long long int n,w;
    cin>>n>>w;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<n;i++)
        for(int j=0;j<2;j++)
            cin>>a[i][j];
    cout<<(long long int)find(0,0,n,w)<<"\n";
    return 0;
}


Measured memory_bytes: 78336
N,K = map(int,input().split())
Ni = (N-1)*(N-2)//2
if Ni < K:
    print(-1)
    exit()
M = N-1+Ni-K
print(M)
for i in range(2,N+1):
    print(1,i)
for i in range(2,N):
    for j in range(i+1,N+1):
        if Ni-K <= 0:
            exit()
        print(i,j)
        Ni -= 1

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

int main()
{
    string s;
    cin >> s;
    int res[4];
    for (int i = 0; i < 4; i++)
    {
        res[i] = 0;
    }
    int cnt = stoi(s);
    for (int i = 0; i < cnt; i++)
    {
        cin >> s;
        if (s == "P")
        {
            res[0] = 1;
        }
        else if (s == "W")
        {
            res[1] = 1;
        }
        else if (s == "G")
        {
            res[2] = 1;
        }
        else if (s == "Y")
        {
            res[3] = 1;
        }
    }
    int su = 0;
    for (int i = 0; i < 4; i++)
    {
        su += res[i];
    }
    if (su == 3)
    {
        cout << "Three" << endl;
    }
    else if (su == 4)
    {
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,i,j;
    scanf("%d%d",&n,&m);
    getchar();
   char a[n][m];
   int flag=1;
   for(i=0;i<n;i++)
   {
       for(j=0;j<m;j++)
       {
           scanf("%c",&a[i][j]);
       }
       getchar();
   }

    if(a[0][0]=='#'&&!(a[0][1]=='#'||a[1][0]=='#'))
    {
       // printf("1\n");
        flag=0;
    }


      if(a[n-1][0]=='#'&&!(a[n-1][1]=='#'||a[n-2][0]=='#'))
       {
          // printf("2\n");
           flag=0;
       }

      if(a[0][m-1]=='#'&&!(a[0][m-2]=='#'||a[1][m-1]=='#'))
       {
       //printf("3\n");
               flag=0;
       }

      if(a[n-1][m-1]=='#'&&!(a[n-1][m-2]=='#'||a[n-2][m-1]=='#'))
       {
           //printf("4\n");
           flag=0;
       }

        for(j=1;j<m-1;j++)
        {
            if(a[0][j]=='#'&&!(a[0][j-1]=='#'||a[0][j+1]=='#'||a[1][j]=='#'))
            {
               // printf("5\n");
                flag=0;
                break;
            }
            if(a[m-1][j]=='#'&&!(a[m-1][j-1]=='#'||a[m-1][j+1]=='#'||a[m-2][j]=='#'))
                {
                   // printf("6\n");
                    flag=0;
                    break;
                }
        }
       for(i=1;i<n-1;i++)
       {
           if(a[i][0]=='#'&&!(a[i+1][0]=='#'||a[i-1][0]=='#'||a[i][1]=='#'))
           {//printf("7\n");
               flag=0;break;
           }
           if(a[i][m-1]=='#'&&!(a[i+1][m-1]=='#'||a[i-1][m-1]=='#'||a[i][m-2]=='#'))
              {//printf("8\n");
                  flag=0;break;
              }
       }
       for(i=1;i<n-1;i++)
       {
           for(j=1;j<m-1;j++)
           {
               if(a[i][j]=='#'&&!(a[i][j-1]=='#'||a[i][j+1]=='#'||a[i-1][j]=='#'||a[i+1][j]=='#'))
               {//printf("9\n");
                   flag=0;
                   break;
               }
           }
       }
       if(n==1&&m==1)
        flag=0;
       if(flag==0)
       printf("No\n");
       else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int totalCaseCount = inpt[0];
        int caseMCount = inpt[1];

        long tryCount = (long)Math.Pow(2, caseMCount);

        long ans = (1900 * caseMCount + 100 * (totalCaseCount - caseMCount)) * tryCount;
        Console.WriteLine(ans);
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




10 2




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

string a;

ll memo[N][2][2];
ll solve(int indx,int rem,bool mustlower){
	if(indx==0){
		if(mustlower){
			if(rem){
				return 0;
			}
			else{
				return 1;
			}
		}	
		else{
			if(rem){
				return 0;
			}
			else{
				return 3;
			}
		}
	}

	ll &ret = memo[indx][rem][mustlower];

	if(~ret)return ret;

	ret = 0;

	if(a[indx]=='1'){
		if(rem){
			
			return 0;
		}
		else{

			ret+=(2*solve(indx-1,0,mustlower)%MOD);// 01 10
			ret%=MOD;

			ret+=(solve(indx-1,0,0)+solve(indx-1,1,0))%MOD;// 00 11
			ret%=MOD;

		}
	}
	else{
		if(rem){
			return 0;	
		}
		else{

			ret+=(2*solve(indx-1,0,1)%MOD);//01 10
			ret%=MOD;

			ret+=(solve(indx-1,0,mustlower)+solve(indx-1,1,mustlower))%MOD; //00 11
			ret%=MOD;
		}

	}

	return ret;
}
int main()
{	

 	
 	cin>>a;

 	reverse(all(a));

 	while(a.back()=='0')a.pop_back();


 	reverse(all(a));
 	memset(memo,-1,sizeof(memo));
 	cout<<solve(sz(a)-1,0,0)<<"\n";


}

Measured memory_bytes: 17664
//Bismillah hirrahmanir Rahim
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);

const int m = 10e6;
using namespace std;

int main(){
  ll a,b,c,d,n,k;
  string s,s1;
  cin>>s>>s1;
    if(s>s1){
    cout<<"No"<<endl;
    return 0 ;
  }
   a= s.size() ;
 string sum = s1.substr(0,a);
  if(s==sum){
cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
A, B, C, D = map(int, input().split())

if A<=C and D<=B: 
    print(D-C)
    exit()

if C<=A and B<=D: 
    print(B-A)
    exit()


if (A<=C and C<= B and B<=D): 
    print(B-C)
    exit()

if C<=A and A<=D and D<=B: 
    print(D-A)
    exit()

if B<=C or D<=A: 
    print(0)
    exit()

Measured memory_bytes: 9140
#include <stdio.h>

int main( void ){
    int n,tou_buff,floor_buff,room_buff,person_buff;
    int room[5][4][11];
    int i,j,k;

    for( i = 1; i < 5; i++ ){
        for( j = 1; j < 4; j++ ){
            for( k = 1; k < 11; k++ ){
                room[i][j][k] = 0;
            }
        }
    }
    
    scanf( "%d",&n );
    for( i = 0; i < n; i++ ){
        scanf( " %d %d %d %d", &tou_buff, &floor_buff, &room_buff, &person_buff );
        room[tou_buff][floor_buff][room_buff] += person_buff;
    }

    for( i = 1; i < 5; i++ ){
        for( j = 1; j < 4; j++ ){
            for( k = 1; k < 11; k++ ){
                printf( " %d",room[i][j][k] );
            }
            printf( "\n" );
        }
        if( i < 4 ) printf( "####################\n");
    }
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int p[10];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p, p + n);

    int sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        sum += p[i];
    }
    sum += p[n - 1] / 2;
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a[3];
	int av=0,c=0;
	for(int i=0;i<3;i++)
	{
		cin >> a[i];
		if(a[i]==5)
		{
			av++;
		}
		if(a[i]==7)
		{
			c++;
		}
	}
	if(av==2 && c==1)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
    for (int i = 1; i <= 5; ++i){
        int xi; cin >> xi;
        if (xi == 0) cout << i << endl;
    }
    return 0;
}

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

int H, W;
string s[60];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (s[i][j] == '#')
            {
                bool found = false;
                for (int k = 0; k < 4; k++)
                {
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if (0 <= x && x < W && 0 <= y && y < H && s[y][x] == '#')
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

int main()
{
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<int> c(q),x(q),y(q);
  rep(i,q){
    cin >> c[i];
    if(c[i]==1){
      char cc;
      cin >> x[i] >> cc;
      x[i]--;
      int yy = cc - 'a';
      y[i] = yy;
    }
    else{
      cin >> x[i] >> y[i];
      x[i]--;
    }
  }

  auto f = [&](int a,int b){return a|b;};
  int id=0;
  vector<int> vec(n);
  rep(i,n){
    int kk=(int)s[i]-'a';
    vec[i] = 1<<kk;
  }
  SegTree<decltype(f),int> seg(f,id);
  seg.init(n);
  seg.build(vec);
  rep(i,q){
    if(c[i]==1) seg.update(x[i],(1<<y[i]));
    else cout << __builtin_popcount(seg.query(x[i],y[i],0,0,seg.size)) << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 8964
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <random>
#include <algorithm>
#include <chrono>
#include <map>
#define tNow chrono::duration_cast<msec>(chrono::system_clock::now().time_since_epoch())
#define INF (1 << 30)
using namespace std;

typedef chrono::milliseconds msec;

int d, lastVal = -INF, bestVal = -INF, times = 0, groups = 0, updates = 0, positiveUpdates = 0;
vector<int> c(27), cur, ans;
vector< vector<int> > s;

int calc() {
    int sum = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= d; ++i) {
        sum += s.at(i).at(cur.at(i));
        last.at(cur.at(i)) = i;
        for (int j = 1; j <= 26; ++j) sum -= c.at(j) * (i - last.at(j));
    }
    return sum;
}

void update(int curVal) {
    lastVal = curVal;
    if (bestVal < curVal) {
        bestVal = curVal;
        ans = cur;
        ++positiveUpdates;
    }
    ++updates;
}

int main() {
    random_device r;
    msec st = tNow;
    msec lm = st + chrono::milliseconds(1980);
    cin >> d;
    s = vector< vector<int> >(d + 1, vector<int>(27));
    cur.resize(d + 1);
    for (int i = 1; i <= 26; ++i) cin >> c.at(i);
    for (int i = 1; i <= d; ++i) for (int j = 1; j <= 26; ++j) cin >> s.at(i).at(j);
    mt19937 m(r());
    for (int i = 1; i <= d; ++i) cur.at(i) = m() % 26 + 1;
    update(calc());
    // cur = {0, 1, 17, 13, 14, 13};
    // update(calc());
    // cout << bestVal << endl;
    // for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;

    while (tNow < lm) {
        ++groups;
        mt19937 m(r());
        for (int i = 0; i < 100; ++i) {
            int changeAt = m() % d + 1, changeTo = m() % 26 + 1, changedFrom = cur.at(changeAt);
            if (changedFrom == changeTo) continue;
            cur.at(changeAt) = changeTo;
            int curVal = calc();
            if (m() % max(1, (lastVal - curVal) / 10) == 0) update(curVal);
            else cur.at(changeAt) = changedFrom;
            ++times;
        }
    }

    for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;
    msec ed = tNow;
    #ifdef ___DEBUG
    cout << "Best Value: " << bestVal << endl;
    cout << "Best Score: " << max(bestVal + 1000000, 0) << endl;
    cout << "Tried: " << times << "times, " << groups << "groups\n";
    cout << "Updated: " << updates << "times\n";
    cout << (ed - st).count() << "ms\n";
    #endif
    return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main(){

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	int k = 1;

	rep(i, n) {
		if (a[i] == k) k++;
	}
	
	if (k == 1) k = n + 2;

	cout << n - k + 1 << endl;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> ac(N);
  vector<int> wa(N);
  
  for(int i=0;i<M;i++){
    int p;
    string s;
    cin>>p>>s;
    if(ac.at(p-1)==0){
      if(s=="AC") ac.at(p-1)=1;
      else wa.at(p-1)+=1;
    }
  }
  int suma=0;
  int sumw=0;
  for(int i=0;i<N;i++){
    suma+=ac.at(i);
    if(ac.at(i)==1) sumw+=wa.at(i);
  }
  
  cout<<suma<<" "<<sumw<<endl;
    
  

}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int data[5];
  int i,j = 0;

  for(i=0;i<5;i++)
  {
    scanf("%d",&data[i]);
  }

  for(i=0;i<5;i++)
  {
    if(data[i]==j)
    {
      printf("%d",i+1);
    }
  }

return 0;
}

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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, X;

   cin >> N >> X;

   vector<ll> a(N);

   for (int i = 0; i < N; i++) {
     cin >> a.at(i);
   }

   sort(a.begin(), a.end());

   int ans;
   for (int i = 0; i < N; i++) {
     if (X >= a.at(i)) {
       ans++;
       X -= a.at(i);
     }
   }

   if (ans == N && X > 0) ans--;
   cout << ans << endl;
  }


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

const long long M = 9999999999971;
const long long MC = 100013;
const int N = 100010;

map<long long, int> H;
long long pw[N];

int dp[N];
long long sz[N];
vector<int> adj[N];
void dfs(int u, int pr) {
	for (auto v: adj[u]) {
		if (v == pr) continue;
		dp[v] = dp[u] + 1;
		dfs(v, u);
		sz[u] = (sz[u] + sz[v]) % M;
	}
	sz[u] = (sz[u] * MC + 1) % M;
}

int main() {

//	freopen("in.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	for (int i = 0; i <= 100000; i++) pw[i] = (i == 0) ? 1LL : (pw[i-1] * MC % M);

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) H[sz[i]] ++;
	long long ans = 0;
	for (auto it: H) {
		int v = it.second;
		ans += 1LL * v * (v-1) / 2;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 23032
n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort()
a = h[n-1] + 1
for i in range(n-k+1):
	if h[i+k-1] - h[i] < a:
		a = h[i+k-1] - h[i]
print(a)

Measured memory_bytes: 7384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class DominatorTree {
    int n;
    void unite(int x, int y){
        uf_par[y] = x;
    }

    int compress(int x){
        if(uf_par[x] == x) return x;
        int r = compress(uf_par[x]);
        if(semi[m[x]] > semi[m[uf_par[x]]]) m[x] = m[uf_par[x]];
        return uf_par[x] = r;
    }

    int eval(int x){
        compress(x);
        return m[x];
    }


    void dfs(int x, int &cur){
        semi[x] = cur;
        ord[cur++] = x;
        for (auto &&i : G[x]) {
            if(!~semi[i]){
                par[i] = x;
                dfs(i, cur);
            }
        }
    }
public:
    DominatorTree(int n) : n(n), G(n), Grev(n), idom(n), semi(n), ord(n), par(n), uf_par(n), m(n), tmp(n), U(n) {}

    vector<vector<int>> G, Grev, tmp;
    vector<int> semi, ord, par, uf_par, m, U, idom;

    void add_edge(int a, int b){
        G[a].emplace_back(b);
        Grev[b].emplace_back(a);
    }
    void build(int root){
        for (int i = 0; i < n; ++i) uf_par[i] = i, m[i] = i, semi[i] = -1, idom[i] = -1;
        int cur = 0;
        dfs(root, cur);
        for (int i = n-1; i >= 0; --i) {
            int a = ord[i];
            for (auto &&b : Grev[a]) {
                if(~semi[b]){
                    int c = eval(b);
                    semi[a] = min(semi[a], semi[c]);
                }
            }
            tmp[ord[semi[a]]].emplace_back(a);
            for (auto &&b : tmp[par[a]]) U[b] = eval(b);
            tmp[par[a]].clear();
            unite(par[a], a);
        }
        for (int i = 1; i < n; ++i) {
            int a = ord[i], b = U[a];
            if(semi[a] == semi[b]) idom[a] = semi[a];
            else idom[a] = idom[b];
        }
        for (int i = 1; i < n; ++i) {
            int a = ord[i];
            idom[a] = ord[idom[a]];
        }
        idom[root] = -1;
    }

};

int main() {
    int n, m;
    cin >> n >> m;
    DominatorTree G(n);
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G.add_edge(s, t);
    }
    G.build(0);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        x--;
        if(!G.idom[x]) printf("%d\n", x+1);
        else printf("%d\n", G.idom[x]+1);
    }
    return 0;
}


Measured memory_bytes: 22316
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size(),i,j;
	int dp[n+1][m+1];
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			if(i==0||j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;	
			}
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans="";
	i=n,j=m;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	for(i=ans.size()-1;i>=0;i--)
	cout<<ans[i];
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


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

int main() {
  int a,b,c ;
  double x ;
  cin >> a >> b ;
  x=(a+b)/2.0 ;
  c=x ;
  if ( c==x )
    cout << c << endl;
  else
    cout << c+1 << endl;
}

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

int main(){
  int N,K;
  cin >>N >>K;
  int min=1;
  for(int i=0; i<N; i++){
    if(min<K)
      min *= 2;
    else
      min += K;
  }
  cout <<min <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  cout << string(s.begin(), s.end()-8) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n ,sum=0;
    int ard[55];
    cin>>n;
    for(int i =1; i<=n; i++)cin>>ard[i];
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            if(i!=j)
            {
                sum += ard[i]*ard[j];
            }
        }
    }
    cout<<sum/2;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> P(N);
	for (int64_t i = 0; i < N; i++)
	{
		std::cin >> P[i];
	}

	std::vector<int64_t> min_P(N);
	min_P[0] = P[0];

	int64_t ans = 1;
	for (int64_t i = 1; i < N; i++)
	{
		if (P[i] <= min_P[i - 1]) ans++;
		min_P[i] = std::min(min_P[i - 1], P[i]);
	}

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 6360
var
i,j,c,d,e,b,n,m,max:longint;
s,s1:string;
begin
readln(n);
readln(s);
for i:=1 to length(s) do
 begin
if s[i]='I' then inc(e)
else
dec(e);
if e>max then max:=e;
end;
writeln(max);
end.

Measured memory_bytes: 128