akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_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)*}
    };
}
 
#[allow(unused_macros)]
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)*}
    };
}
 
#[allow(unused_macros)]
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, 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")
    };
}
 
fn main() {
    input! {
        x: u64,
        y: u64,
    }

    let mut q = y / x;
    let mut count = 0;

    while q != 1 {
        q = q / 2;
        count = count + 1;
    }

    println!("{}", count+1);
}


Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident $($r:tt)*) => {
        let mut $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident $($r:tt)*) => {
        let $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().unwrap()
    };
}

use std::io::{stdout, Write, BufWriter};

fn main() {
    input! {n, m, q, lr: [(usize1, usize1); m], pq: [(usize1, usize1); q]};
    let mut t = vec![];
    for _ in 0..n {
        t.push(vec![0; n+1])
    }
    for (l, r) in lr {
        t[l][r+1] += 1
    }
    for i in 0..n {
        for j in 1..(n+1) {
            t[i][j] += t[i][j-1];
        }
    }
    let stdout = stdout();
    let mut out = BufWriter::new(stdout.lock());
    for (p, q) in pq {
        let mut res = 0;
        for i in p..(q+1) {
            res += t[i][q+1];
            res -= t[i][p];
        }
        writeln!(out, "{}", res).unwrap();
    }
}


Measured memory_bytes: 14328
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	string str;
	cin>> str ;
	for(ll i=0;i<str.length() ; i++){
		if(str[i]=='7'){
			cout<<"Yes"<<endl;
			return 0 ;
		}
	}
	cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3592
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100

int main() {
	static char s[N + 1], cc[N * 2 + 1], *t = cc;
	int n, h, i, x, y;

	scanf("%d%s", &n, s);
	x = y = 0;
	for (i = 0; i < n; i++) {
		x += (s[i] == '(' ? 1 : -1);
		if (y > x)
			y = x;
	}
	for (h = 0; h < -y; h++)
		t += sprintf(t, "(");
	t += sprintf(t, "%s", s);
	for (h = 0; h < x - y; h++)
		t += sprintf(t, ")");
	printf("%s\n", cc);
	return 0;
}


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

void foo(vector<vector<int>> &vec, vector<vector<int>> &dp, int n) {
  //int n = vec.size();
  dp[1][0] = vec[1][0];
  dp[1][1] = vec[1][1];
  dp[1][2] = vec[1][2];
  int mx = 0;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = vec[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = vec[i][1] + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = vec[i][2] + max(dp[i-1][0], dp[i-1][1]);
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
  return;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> vec(n + 1, vector<int>(3, 0));
  vector<vector<int>> dp(n + 1, vector<int>(3, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> vec[i][j];
    }
  }
  foo(vec, dp, n);
  return 0;
}


Measured memory_bytes: 13972
#include<bits/stdc++.h>
typedef short ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF (30000)
ll gcd (ll a,ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b,a % b);
}

ll n,ma,mb,a[100],b[100],c[100];
ll dp[2][2500][2500];

int main(){

	cin >> n;

	cin >> ma >> mb;

	REP(i,n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	REP(k,2){
		REP(i,1001) {
			REP(j,1001) {
				dp[k][i][j] = INF;
			}
		}
	}
	dp[0][0][0] = 0;

	REP(i,n) {
		REP(k,1001) {
			REP(l,1001) {
				dp[(i + 1) & 1][k + a[i]][l + b[i]] = min(dp[(i + 1) & 1][k + a[i]][l + b[i]],(short)(dp[i & 1][k][l] + c[i]));
				dp[(i + 1) & 1][k][l] = min(dp[(i + 1) & 1][k][l],dp[i & 1][k][l]);
			}
		}
	}
	
	ll ans = INF;
	FOR(i,1,1001) {
		FOR(j,1,1001) {
			ll g = gcd(i,j);

			if(i / g == ma && j / g == mb) {
				ans = min(ans,dp[n & 1][i][j]);
			}
		}
	}
	if(ans < INF) {
		cout << ans << endl;
	}else {
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 14592
import * as fs from 'fs'

const reader = (data: string) => data.split(' ').map(t => parseInt(t, 10))

function Main(input) {
  const [A, B] = reader(input)
  const bool = A <= 9 && B <= 9
  console.log(bool ? A * B : -1)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template<typename T, size_t N>
struct fenwick {
  T c[N];
  fenwick() {
    fill(c + 1, c + N, 0);
  }
  void add(int x, T y) {
    for (; x < N; x += x & -x) {
      c[x] += y;
    }
  }
  T query(int x) {
    T ret = 0;
    for (; x; x -= x & -x) {
      ret += c[x];
    }
    return ret;
  }
};

const int N = 5e5 + 10;

int main() {
  int n, m;
  cin >> n >> m;
  fenwick<int64, N> A;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    A.add(i, x);
  }
  while (m--) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 0) {
      A.add(x + 1, y);
    } else {
      cout << A.query(y) - A.query(x) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    deque<int> ans;
    ans.push_back(a[0]);
    for(int i = 1; i < n; i++){
        if(i%2 == 1) ans.push_front(a[i]);
        else ans.push_back(a[i]);
    }    
    if(n%2 == 1) reverse(ans.begin(),ans.end());
    for(int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3840
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n - 2):
    for j in range(n):
        if i + j*2 < n:
            if s[i] != s[i + j]:
                if s[i] != s[i + j*2]:
                    if s[i + j] != s[i + j*2]:
                        ans -= 1
        else:
            break

print(ans)

Measured memory_bytes: 68060
#include <stdio.h>
#include <string.h>

int main(void) {
    char s[30];
    bool b[256] = {0};
    scanf("%s", s);
    int l = strlen(s);
    for (int i = 0; i < l; i ++) {
        char c = s[i];
        if (b[c]) {
            printf("no\n");
            return 0;
        }
        b[c] = true;
    }
    printf("yes\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
 int a[101];

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        cout << "x";
    

}


Measured memory_bytes: 256
def nto6str(num):
    s =list('000000')
    numS = str(num)
    L_numS = len(numS)
    for i in range(L_numS):
        s[i*(-1)-1] = numS[i*(-1)-1]
    ans = ''.join(s)
    return ans

N,M =list(map(int,input().split()))
Lis = []
for i in range(M):
    a=list(map(int,input().split()))
    a.append(i)
    Lis.append(a)
b = sorted(Lis)
pref = 0
city = 0
for i in range(M):
    if b[i][0] != pref:
        pref = b[i][0]
        city = 1
    b[i][1] = city
    city +=1
for i in range(M):
    b[i][0] = nto6str(b[i][0])
    b[i][1] = nto6str(b[i][1])
c = sorted(b,key = lambda x:x[2])
for i in range(M):
    print(''.join(c[i][0:2]))


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

int main() {
    int n, i;
    cin >> n;
    vector<int> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<>());
    vector<long long> b;
    for (i = 0; i < n; i++) {
        b.push_back(a[i]);
        if (i) b.push_back(a[i]);
    }
    long long ans = 0;
    for (i = 0; i < n-1; i++) ans += b[i];
    cout << ans;
}

Measured memory_bytes: 8180
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	int f[100001] = {};
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		f[i + 1] = a;
		if (f[a] == i + 1)ans++;
	}
	cout << ans << endl;
}

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

int main() {
    int n,q,ans=0;
    ll s[100005],t[50005];
    cin >> n;
    for(int i=0;i<n;i++) cin >> s[i];
    cin >> q;
    for(int i=0;i<q;i++) cin >> t[i];
    for(int i=0;i<q;i++) {
        if(*lower_bound(s, s+n, t[i]) == t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
#include<chrono>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;


int main() {
	cin >> N >> K;
	if (N%K)cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
ID,LEFT,RIGHT = 0,1,2
n = int(input())

preorder_list = []
def preorder(node):
  preorder_list.append(node[0][ID])
  if node[0][LEFT] != -1:
    preorder(nodes[node[0][LEFT]])
  if node[0][RIGHT] != -1:
    preorder(nodes[node[0][RIGHT]])

inorder_list = []
def inorder(node):
  if node[0][LEFT] != -1:
    inorder(nodes[node[0][LEFT]])
  inorder_list.append(node[0][ID])
  if node[0][RIGHT] != -1:
    inorder(nodes[node[0][RIGHT]])

postorder_list = []
def postorder(node):
  if node[0][LEFT] != -1:
    postorder(nodes[node[0][LEFT]])
  if node[0][RIGHT] != -1:
    postorder(nodes[node[0][RIGHT]])
  postorder_list.append(node[0][ID])

nodes = [[] for _ in range(n)]
for i in range(n):
  id, left, right = list(map(int, input().split()))
  nodes[id].append({ID:id, LEFT:left, RIGHT:right})

id_list = [0 for _ in range(n)]
for node in nodes:
  if node[0][LEFT] != -1:
    id_list[node[0][LEFT]] += 1
  if node[0][RIGHT] != -1:
    id_list[node[0][RIGHT]] += 1

root_id = -1
for i,v in enumerate(id_list):
  if v == 0:
    root_id = i
    break


preorder(nodes[root_id])
print ('Preorder')
print (' '+' '.join(map(str, preorder_list)))
inorder(nodes[root_id])
print ('Inorder')
print (' '+' '.join(map(str, inorder_list)))
postorder(nodes[root_id])
print ('Postorder')
print (' '+' '.join(map(str, postorder_list)))



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

typedef long long int ll;
typedef pair<int, int> P;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll MAXN = 1e9;
int n, k; vector<vector<int> > sum;

int func(int i, int j) {
	return sum[i][j] - sum[i - k][j] - sum[i][j - k] + sum[i - k][j - k];
}

int main() {
	cin >> n >> k;
	int t = 2 * k;
	int f = 4 * k;
	sum.resize(4 * k + 5, vector<int>(4 * k + 5, 0));
	for (int i = 0; i < n; i++) {
		int x, y; char c;
		cin >> x >> y >> c;
		x %= t; y %= t;
		if (c == 'B') x += k;
		x %= t;
		sum[x][y]++;
		sum[x + t][y]++;
		sum[x][y + t]++;
		sum[x + t][y + t]++;
	}

	for (int i = 1; i < f; i++) {
		for (int j = 1; j < f; j++) {
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i < t; i++) {
		for (int j = 0; j < t; j++) {
			int tmp = func(i + k, j + k) + func(i + 2 * k, j + 2 * k);
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  unsigned long N,a=0;
  cin >> N;

  for(unsigned long i=1;i<=N;i++){
    if(i%3==0&&i%5==0){
      a=a;
    }
    else if(i%3==0){
      a=a;
    }
    else if(i%5==0){
      a=a;
    }
    else{
      a=a+i;
    }
    
  }
  cout << a << endl; 
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int,VI,greater<VI>> pq;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


int main(void){
    ll N,M; cin >> N >> M;
    vector<ll> a(N); REP(i,N) cin >> a[i];
    vector<int> edge[N];
    REP(i,M){
        int x,y; cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    if(N < 2*(N-M-1)){
        cout << "Impossible" << endl;
        return 0;
    }

    if(N-1 == M){
        cout << 0 << endl;
        return 0;
    }

    VI done(N,0);
    vector<ll> forest[N-M];
    int ptr = 0;
    REP(i,N){
        if(done[i]) continue;
        stack<int> stk;
        stk.push(i);
        while(stk.size()){
            int node = stk.top(); stk.pop();
            if(done[node]) continue;
            done[node] = 1;
            forest[ptr].push_back(a[node]);
            for(int n : edge[node]) stk.push(n);
        }
        ptr++;
    }

    ll ans = 0;
    REP(i,N-M){
        SORT(forest[i]); REVERSE(forest[i]);
        ans += forest[i].back();
        forest[i].pop_back();
    }

    vector<ll> aa = forest[0];
    REP(i,N-M-1){
        aa.insert(aa.end(), forest[i+1].begin(), forest[i+1].end());
    }
    SORT(aa);
    REP(i,2*(N-M-1)-(N-M)){
        ans += aa[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9752
H,W,K = gets.split.map(&:to_i)
C = []
num_black = 0
H.times do |h|
    C.push gets.strip
    num_black += C[-1].count('#')
end

num_to_erase = num_black - K
# puts num_to_erase

ans = 0
(2**H).times do |h|
    (2**W).times do |w|
        c = Marshal.load(Marshal.dump(C))
        erased = 0
        H.times do |i|
            if h[i] == 1
                erased += c[i].count('#')
                c[i] = 'x' * W
            end
        end
        W.times do |j|
            if w[j] == 1
                H.times do |k|
                    if c[k][j,1] == "#"
                        erased += 1
                    end
                    c[k][j,1] = "x"
                end
            end
        end

        # p c
        # puts "---- #{erased}"
        if erased == num_to_erase
            ans += 1
        end
    end
end
puts ans

Measured memory_bytes: 14312
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,ma,mb,a[40],b[40],c[40];
    int dp[410][410];
    REP(i,410)REP(j,410)dp[i][j]=1e9;
    dp[0][0]=0;
    cin>>n>>ma>>mb;
    REP(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    REP(i,n){
        for(int j=400-a[i];j>=0;j--){
            for(int k=400-b[i];k>=0;k--){
                dp[j+a[i]][k+b[i]]=min(dp[j+a[i]][k+b[i]],dp[j][k]+c[i]);
            }
        }
    }
    int ans=1e9;
    for(int i=1;ma*i<=400&&mb*i<=400;i++){
        ans=min(ans,dp[ma*i][mb*i]);
    }
    if(ans==1e9){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}
ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
#define all(x) (x).begin(), (x).end()

void solve()
{
    ll ans = 0;
    string s;
    cin >> s;
    for (char c : s)
        ans += (c - '0');

    if (ans % 9 == 0)
        cout << "Yes"
             << "\n";
    else
        cout << "No\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    ll t;
    // cin >> t;
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int n, l, r, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l >> r;
        sum += r - l  + 1;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = int(n*(n+1)/2)

n3 = n//3
l3 = n-n%3
s3 = int(n3*(3+l3)/2) if n>=6 else 3

n5 = n//5
l5 = n-n%5
s5 = int(n5*(5+l5)/2) if n>=10 else 5

n15 = n//15
l15 = n-n%15
s15 = int(n15*(15+l15)/2) if n>=30 else 15

if n<3:
  print(s)
elif n<5:
  print(s-s3)
elif n<15:
  print(s-s3-s5)
else:
  print(s-s3-s5+s15)


Measured memory_bytes: 9156
#include<stdio.h>
#include<math.h>

void print_info(int array[][10]);

int main (void)
{
	int input,sum,count;
	int i,j,k;
	do
	{
		scanf("%d %d",&input,&sum);
		count = 0;
		if(input == 0 && sum == 0)
		{
			break;
		}
		for(i = 1 ; i <= input ; i++ )
		{
			for(j = i+1 ; j <= input ; j++)
			{
				for(k = j+1 ; k <= input ; k++)
				{
					if(i + j + k == sum && i != j && i != k && j != k)
					{
						count++;
					}
				}
			}
		}
		printf("%d\n",count);
	}while(1);
	
	return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int h,ans=1;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>h;
	while(h)
	{
		ans*=2;
		h/=2;
	}
	cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,a=0,b=0,x;
    vector<ll>v;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(ll i=0;i<n;i+=2)
    {
        a+=v[i];
    }
    for(ll i=1;i<n;i+=2)
    {
        b+=v[i];
    }
    cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pip = pair<int, pii>;

#define INF 1e9

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m;
  cin >> n >> m;
  vi mincost(n, INF);
  vvi edge(n);
  vector<bool> used(n, 0);
  vi from(n, INF);
  for(int i = 0 ; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  mincost[0] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> q;
  q.push({0, 0});
  while(!q.empty()){
    auto now = q.top(); q.pop();
    if(used[now.second]) continue;
    for(auto e : edge[now.second]){
      if(!used[e]){
        q.push({now.first+1, e});
        if(mincost[e] > now.first+1){
          mincost[e] = now.first+1;
          from[e] = now.second;
        }
      }
    }
    used[now.second] = 1;
  }

  cout << "Yes" << endl;
  for(int i = 1; i < n; i++){
    cout << from[i]+1 << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 11336
struct Rin{}
impl Rin{
    fn input(&self)->String{
        let mut x=String::new();
        std::io::stdin().read_line(&mut x).ok();
        x
    }
    fn inputs(&self)->String{
        let s=self.input().trim().to_string();
        s
    }
    fn inputn(&self)->i32{
        let n:i32=self.input().trim().parse().unwrap();
        n
    }
    fn inputvs(&self)->Vec<String>{
        let vs=self.input().trim().split(' ').map(|x|x.to_string()).collect();
        vs
    }
    fn inputvn(&self)->Vec<i32>{
        let vn=self.input().trim().split(' ').map(|x|x.to_string().parse().unwrap()).collect();
        vn
    }
}

fn main(){
    let r=Rin{};
    let s=r.inputs();
    let t=r.inputs();
    if s==t[..t.len()-1]{
        println!("Yes");
    }else{
        println!("No");
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int cnt = 1;
  REP(i, N - 1) {
    if(S[i] != S[i + 1]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////
int N, Q, K;
vector<pair<int,ll>>G[100100];
int main() {
	cin >> N;
	for (int i = 0; i < N-1; ++i) {
		int a, b; ll c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	cin >> Q >> K;
	K--;
	vector<ll>d(N + 1,-1);
	d[K] = 0;
	queue<int>q;
	q.push(K);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto p : G[v]) {
			int sv;
			ll c;
			sv = p.first;
			c = p.second;
			if (d[sv] < 0) {
				d[sv] = d[v] + c;
				q.push(sv);
			}
		}
	}
	for (int i = 0; i < Q; ++i) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << d[x] + d[y] << endl;
	}
	return 0;
}


Measured memory_bytes: 9984
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll cnt = 0;
    for(ll i = 1; i <= N; ++i) {
        ll sum = 0;
        ll tmp = i;
        while(tmp > 0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if (A <= sum & sum <= B) {
            cnt += i;
        }
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll Mod = 998244353;
const ll Inf = 2242545357980376863LL;
const ll Log = 20;
const int Maxn = 1e5 + 10;
const int sig = 27;

const int Base = 101;

ll cnt[Maxn];
ll d[Maxn];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> d[i];
		cnt[d[i]] ++;
	}
	if(d[1] != 0 || cnt[0] != 1) return cout << 0, 0;
	ll ans = 1;
	for(int i= 2; i <= n; i++) ans = (ans * cnt[d[i] - 1]) % Mod;
	cout << ans;
	return 0;
}
/*
abacabacca

*/


Measured memory_bytes: 1792
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 100005

int main()
{
    jaldi;
    
    long double r;
    cin >> r;
    long double pi = 3.1415926535;
    cout << fixed << setprecision(10) << (double)2*pi*r;
    
    return 0;
}


Measured memory_bytes: 3804
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, x, y = sc.nextInt

    val aPrice = min(a, c * 2)
    val bPrice = min(b, c * 2)
    val abPrice = min(a + b, c * 2)
    val abFlg = a != aPrice || b != bPrice || (a + b) != abPrice

    val payment =
      if (abFlg) {
        val abPayment = abPrice * min(x, y)
        val notAbPayment =
          if (x == y) 0
          else if (x < y) (y - x) * bPrice
          else (x - y) * aPrice
        abPayment + notAbPayment
      } else {
        x * aPrice + y * bPrice
      }

    println(payment)

  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, x, y = sc.nextInt

    var minPayment = Long.MaxValue
    for (abNum <- 0 until max(x, y) * 2) {
      val payment = (c * 2 * abNum) + (a * max(0, x - abNum)) + b * max(0, y - abNum)
      minPayment = min(minPayment, payment)
    }
    println(minPayment)

  }
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
  ll B, W; cin >> B >> W;
  ll N = B+W;
  ll ok[N]={}, dame[N]={};
  ok[W] = 1; dame[B] = 1;
  COMinit();
  for(int i=W+1; i<N; i++){
    ok[i]+=(ok[i-1]*2); ok[i]%=mod;
    ok[i]+=COM(i-1, W-1); ok[i]%=mod;
  }
  for(int i=B+1; i<N; i++){
    dame[i]+=(dame[i-1]*2); dame[i]%=mod;
    dame[i]+=COM(i-1, B-1); dame[i]%=mod;
  }
  ll bunsi=1, bunbo=2;
  //rep(i, N){
    //cout << ok[i] << " " << dame[i] << endl;
  //}
  rep(i, N){
    bunsi+=ok[i]; bunsi%=mod;
    bunsi-=dame[i]; if(bunsi<0) bunsi+=mod; bunsi%=mod;
    //cout << bunsi << " " << bunbo << endl;
    cout << bunsi*modinv(bunbo, mod)%mod << endl;
    bunsi = bunbo; bunbo*=2; bunbo%=mod;
  }
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

const int N=301;
const int MXN=1000001;
const int inf=1e9;
const ll INF=1e18;

vi a[N];
int ans[N][N];


int main(){
  boost;

  int n,m,k;
  cin>>n>>m>>k;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      char c;
      cin>>c;
      if(c=='#'){
        a[i].pb(j);
      }
    }
  }
  int cur=1;
  for(int i=1;i<=n;i++){
    int j=1;
    for(int k=0;k<sz(a[i]);k++){
      while(j<=a[i][k])ans[i][j]=cur,j++;
      if(k==sz(a[i])-1){
        while(j<=m)ans[i][j]=cur,j++;
      }
      cur++;
    }
  }
  int w=0;
  for(int i=1;i<=n;i++){
    if(sz(a[i])==0&&w){
      for(int j=1;j<=m;j++){
        ans[i][j]=ans[i-1][j];
      }
    }
    if(sz(a[i])>0&&!w)w=i;
  }
  for(int i=w-1;i>=1;i--){
    for(int j=1;j<=m;j++){
      ans[i][j]=ans[i+1][j];
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cout<<ans[i][j]<<" ";
    }
    cout<<"\n";
  }
  return 0;
}




Measured memory_bytes: 1792
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(A[K-1])

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

const int CARRY=4;
const int INF=1e8;
int main(){
    int n;
    while(cin>>n,n){
        vector<int> p(n+2),t(n+2);
        p[0]=0; t[0]=0;
        for(int i=0;i<n;i++){
            cin>>p[i+1]>>t[i+1];
        }
        p[n+1]=0; t[n+1]=INF;
        vector<vector<int>> dp(n+2,vector<int>(CARRY,INF));
        dp[0][0]=0;
        for(int i=0;i<=n;i++){
            for(int k=0;k<CARRY;k++){
                if(k+1<CARRY && abs(p[i]-p[i+1])*(k+1)<=t[i+1]-t[i]){
                    dp[i+1][k+1]=min(dp[i+1][1],dp[i][k]+abs(p[i+1]-p[i]));
                }
                if(p[i]*(k+1)+p[i+1]<=t[i+1]-t[i]){
                    dp[i+1][1]=min(dp[i+1][1],dp[i][k]+p[i]+p[i+1]);
                }
            }
        }
        int res=*min_element(dp[n+1].begin(),dp[n+1].end());
        if(res==INF){
            for(int i=0;i<=n;i++){
                if(*min_element(dp[i].begin(),dp[i].end())==INF){
                    cout<<"NG"<<" "<<i<<endl;
                    break;
                }
            }
        }
        else{
            cout<<"OK"<<" "<<res<<endl;
        }
    }
    return 0;
}


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

public class Hello{
    public static void Main(){
        string[]array=Console.ReadLine().Split(' ');
        var N=int.Parse(array[0]);
        var X=int.Parse(array[1]);
        
        var list=new List<int>();
        string[]array1=Console.ReadLine().Split(' ');
        for(var i=0;i<N;i++){
            list.Add(int.Parse(array1[i]));
        }
        
        var temp_y=0;
        var count=1;
        
        var y=0;
        for(var i=0;i<N;i++){
            y=temp_y+list[i];
            if(y>X){
                break;
            }
            count++;
            temp_y=y;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
from sys import stdin
from sys import setrecursionlimit
from collections import Counter
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    cA = Counter(A)

    diff = {}
    total = 0
    for key in cA:
        v = cA[key]
        total += (v * (v - 1)) // 2
        diff[key] = (v - 1) * (v - 2) // 2 - (v * (v - 1)) // 2

    for ai in A:
        print(total + diff[ai])
        # cA[ai] -= 1
        # count = 0
        # for key in cA:
        #     v = cA[key]
        #     count += (v * (v - 1)) // 2
        # cA[ai] += 1
        # print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 90848
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

class BIT {
public:
    // 要素数N、値vで初期化
    BIT(ll N, ll v) : V_NUM(N) {
        data.resize(N);
        fill(data.begin(), data.end(), v);
    }

    // [1, i]の総和を求める
    ll query(ll i) {
        ll ret = 0;
        while (i > 0) {
            ret += data[i];
            i -= (i & -i);
        }
        return ret;
    }

    // data[i]にv可算
    void update(ll i, ll v) {
        while (i < V_NUM) {
            data[i] += v;
            i += (i & -i);
        }
    }

    ll V_NUM;
    vector<ll> data;
};

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    
    // 各始点についてBITを構築
    vector<BIT> bit(N + 1, BIT(N + 1, 0));

    for (ll i = 0; i < M; ++i) {
        ll L, R;
        cin >> L >> R;
        for (ll j = 1; j <= L; ++j) {
            // 始点がL以下の区間にRを追加
            bit[j].update(R, 1);
        }
    }

    for (ll i = 0; i < Q; ++i) {
        ll p, q;
        cin >> p >> q;
        
        // 始点がpより後の区間で、終点がqより前の区間の数
        cout << bit[p].query(q) << endl;
    }
    
    return 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> a(N);
  //a.resize(N);
  for (int i=0;i<N;++i) cin>>a[i];
  
  int ans=0;
  for (int i=1;i<N;++i){
    if (a[i]==a[i-1]){
      a[i]=-1;
      ++ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
int a[maxn];
int n;
int check(int m){
    for (int i= 1;i <= n;i++){
        m -= m % a[i];
    }
    return m;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(false);
    //int n;
    cin >> n;
    for (int i = 1;i <= n;i++){
        cin >> a[i];
    }
    int lo = 2,hi = 1e16,m,found = -1;
    while(lo <= hi){
        m = (lo + hi) / 2;
        int cm = m;
        cm = check(cm);
        if (cm >= 2){
            found = m;
            hi = m - 1;
        }else lo = m + 1;
    }
    if (found == -1 || check(found) != 2){
        cout << -1 << endl;
        return 0;
    }
    lo = found,hi = 1e16;
    int st = found;
    while(lo <= hi){
        m = (lo + hi ) / 2;
        int cm = check(m);
      //  cout << m << ' ' << cm << endl;
        if (cm == 2){
            found = m;
            lo = m + 1;
        }else hi = m -1;
    }
    cout << st <<' ' << found << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define SIZE 22

int main() {
    char line[SIZE];
    fgets(line, SIZE, stdin);
    line[strlen(line) - 1] = '\0';
    int last = strlen(line) - 1;
    for (int i = 0; i <= last / 2; i++) {
        char tmp;
        tmp = line[i];
        line[i] = line[last - i];
        line[last - i] = tmp;
    }
    printf("%s\n", line);
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  auto ok = [&](){
    rep(i,n) if(vec[i]>=n) return false;
    return true;
  };

  long mn = *min_element(all(vec));
  long ans = 0;

  rep(i,n){
    long x = (vec[i]-mn)/(n+1);
    ans += x;
    vec[i] -= (n+1)*x;
  }

  rep(i,n) vec[i] += ans;

  mn = *min_element(all(vec));

  if(mn-n>0){
    ans += (mn-n)*n;
    rep(i,n) vec[i] -= (mn-n);
  }

  while(!ok()){
    int x = 0;
    rep(i,n) if(vec[i] > vec[x]) x = i;
    rep(i,n) vec[i] +=1;
    vec[x] -= n+1;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * Main.cpp
 *
 *  Created on:
 *      Author: KC
 */
/*
 ID: chancha4
 PROG: packrec
 LANG: C++
 */
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <math.h>
#include <vector>
#include <time.h>
#include<stack>
#include <set>
#include <limits>
#include<map>
#include<utility>

using namespace std;

int n = 10;
int e[11];

bool solve(int lv, int topa, int counta, int topb, int countb){
    bool boola;
    bool boolb;
    if(lv == n) return ((counta + countb) == n) ;

    if(topa < e[lv]) boola = solve(lv + 1, e[lv], counta + 1, topb, countb);
    else boola = false;

    if(topb < e[lv]) boolb = solve(lv + 1, topa , counta, e[lv], countb + 1);
    else boolb = false;

    return (boola || boolb);


}
int main(){
    int T;
    scanf("%d", &T);
    for(int i = 0; i < T; i++){
        for(int j = 0; j < 10; j++) scanf("%d", e + j);
        bool res = solve(0, 0, 0, 0, 0);
        if(res) puts("YES");
        else puts("NO");

    }
}

Measured memory_bytes: 1168
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct Edge {
    int to;
    int idx;
    Edge(int t, int i) : to(t), idx(i) {}
};

vector<vector<Edge>> E(1e5 + 1);
vector<int> color(1e5 + 1);


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vi A(N), B(N);
    REP(i, N - 1) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;

        E[A[i]].eb(B[i], i);
        E[B[i]].eb(A[i], i);
    }

    queue<pair<int, int>> q;
    q.emplace(0, 0);
    vector<bool> used(N);

    int c_max = 0;
    while(!q.empty()) {
        auto p = q.front(); q.pop();
        used[p.fi] = true;

        int no = p.se;
        int c = 1;
        for(auto e: E[p.fi]) {
            if (used[e.to]) continue;

            if (c == no) c++;

            color[e.idx] = c;
            q.emplace(e.to, c);
            ++c;

        }
        c_max = max(c, c_max);
    }

    print(c_max - 1);
    REP(i, N - 1) print(color[i]);
    
}


Measured memory_bytes: 10396