akhauriyash/Code-Regression huggingface dataset:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
n,m=map(int,input().split())
uf1=UnionFind(n)

for i in range(m):
    x,y,z=map(int,input().split())
    x,y=x-1,y-1
    uf1.union(x,y)

for i in range(n):uf1.find(i)  
ans=set()
for i in uf1.par:
     ans.add(i)
print(len(ans)) 

Measured memory_bytes: 95180
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a,b,c;
cin>>a>>b>>c;
cout<<seinomi(c-(a-b))<<endl;
}









Measured memory_bytes: 256
#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> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    string s; cin>>s;
    int n = s.size();
    int a=0; int b=0;
    REP(i,n){
        if(s.at(i)=='A'){
        a = i;
        break;
        }
    }
    for(int i=n-1; i>0; i--){
        if(s.at(i)=='Z'){
        b = i;
        break;
        }
    }
    cout<<b-a+1<<endl;
}



Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	static Scanner src = new Scanner(System.in);
	public static void main(String[] args) {
		int a = src.nextInt();
		int b = src.nextInt();
		int c = src.nextInt();
		int k = src.nextInt();
		int sum = 0;
		for(int i = 0; i < k; i++) {
			if(a != 0) {
				sum += 1;
				a--;
			}else if(b != 0) {
				b--;
			}else if(c != 0) {
				sum -= 1;
				c--;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 36236
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, K = MAP()
ans = 1

def count(i, N):
	if i == 1:
		return N+1
	else:
		return (N*(N+1)/2 - (N-i)*(N-i+1)/2) - (i-1)*i/2 + 1


for i in range(K, N+1):
	ans += count(i, N)

print(int(ans%(10**9+7)))

Measured memory_bytes: 10052
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] array = s.split("");
        int countA=1;
        int countB=0;
        String B="";
        for(int i=1;i<array.length;i++)
          if(array[0].equals(array[i]))countA++;
          else if(B=="")B=array[i];
        for(int i=0;i<array.length;i++)
          if(B.equals(array[i]))countB++;
       
       // 出力
		//System.out.println(countA + " " + countB);
      if(countA==countB&& countB == 2)System.out.println("Yes");
      else System.out.println("No");
	}
}

Measured memory_bytes: 23508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


int main(){
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    LL ans = 0;
    for(LL w = 0; w <= k && w <= n; ++w){
        for(LL left = 0; left <= w; ++left){
            vector<LL> tmp;
            for(LL i = 0; i < left; ++i){
                tmp.push_back(a[i]);
            }
            for(LL i = 0; i < w-left; ++i){
                tmp.push_back(a[n-1-i]);
            }
            sort(tmp.begin(), tmp.end());
            LL total = accumulate(tmp.begin(), tmp.end(), 0);
            ans = max<LL>(ans, total);
            for(LL i = 0; i < k-w && i < tmp.size(); ++i){
                total -= tmp[i];
                ans = max<LL>(ans, total);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, m := io.NextInt(), io.NextInt()
	a := io.NextInts(m)
	for i := range a {
		n -= a[i]
	}
	if n < 0 {
		io.Println(-1)
	} else {
		io.Println(n)
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2364
import java.util.Scanner;

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

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

        int max = 1;
        int min = 1000000000;
        for (int i = 0; i < n; i++) {
            if (max < a[i]) {
                max = a[i];
            }

            if (min > a[i]) {
                min = a[i];
            }
        }

        System.out.println(max - min);
    }
}

Measured memory_bytes: 23636
use proconio::input;

fn main() {
    input! {
        n: usize,
        p: [usize; n*n],
    }
    let mut seats: Vec<Vec<_>> = (0..n).map(|_i| (0..n).map(|_j| true).collect()).collect();
    let mut table: Vec<Vec<_>> = (0..n)
        .map(|i| {
            (0..n)
                .map(|j| i.min(j).min(n - i - 1).min(n - j - 1))
                .collect()
        })
        .collect();
    let mut result = 0;
    for pi in p {
        let (i, j) = ((pi - 1) % n, (pi - 1) / n);
        seats[i][j] = false;
        result += table[i][j];
        let mut queue = std::collections::VecDeque::new();
        queue.push_back((i, j));
        while !queue.is_empty() {
            let (ii, jj) = queue.pop_front().unwrap();
            if 0 < ii && table[ii - 1][jj] > table[ii][jj] {
                let prev = table[ii - 1][jj];
                table[ii - 1][jj] = table[ii][jj] + seats[ii][jj] as usize;
                if prev > table[ii - 1][jj] {
                    queue.push_back((ii - 1, jj));
                }
            }
            if ii < n - 1 && table[ii + 1][jj] > table[ii][jj] {
                let prev = table[ii + 1][jj];
                table[ii + 1][jj] = table[ii][jj] + seats[ii][jj] as usize;
                if prev > table[ii + 1][jj] {
                    queue.push_back((ii + 1, jj));
                }
            }
            if 0 < jj && table[ii][jj - 1] > table[ii][jj] {
                let prev = table[ii][jj - 1];
                table[ii][jj - 1] = table[ii][jj] + seats[ii][jj] as usize;
                if prev > table[ii][jj - 1] {
                    queue.push_back((ii, jj - 1));
                }
            }
            if jj < n - 1 && table[ii][jj + 1] > table[ii][jj] {
                let prev = table[ii][jj + 1];
                table[ii][jj + 1] = table[ii][jj] + seats[ii][jj] as usize;
                if prev > table[ii][jj + 1] {
                    queue.push_back((ii, jj + 1));
                }
            }
        }
    }

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


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

int main() {
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A+3);

    int ans = 0;
    ans += (A[2] - A[0]) / 2;
    if((A[2] - A[0]) % 2 == 0) A[0] = A[2];
    else A[0] = A[2] - 1;
    ans += (A[2] - A[1]) / 2;
    if((A[2] - A[1]) % 2 == 0) A[1] = A[2];
    else A[1] = A[2] - 1;

    if(A[0] == A[1] && A[1] != A[2]) ans += 1;
    else if(A[0] != A[1]) ans += 2;

    cout << ans << endl;
}

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

int main(){
    int m=0,n=0,c=0,i,j;
    char a;
    while(cin>>i>>a>>j){
        m+=(i*j);
        n+=j;
        c++;
    }
    double am=1.0*n/c;
    if(am*10-int(am/10)>4)am=am+1;
    cout<<m<<endl<<int(am)<<endl;
}

Measured memory_bytes: 1160
// ABC 153-F
// 2020.1.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 200005
typedef struct { int X, H; } T;
T a[MAX]; int N;

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];
	
	T *tmp = malloc(n * sizeof(T));	
	for (k = 0; k < 4; ++k) {
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].X >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].X >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].X >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].X >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
//for (i = 0; i < n; ++i) printf("[%d] %d,%d\n", i, a[i].X, a[i].H);
}

// 見つからなければ、一つ小さい要素を返す
int bs(int l, int x) {
	int m, r = N+1;

    while (l < r) {
        m = (l+r) >> 1;
        if (a[m].X <= x) l = m + 1; else r = m;
    }
	return l-1;
}

int imos[MAX];

int main()
{
	int i, j, A, D, h, t;
	ll ans;
	
	N = in(), D = in() << 1, A = in();
	for (i = 1; i <= N; ++i) a[i].X = in(), a[i].H = in();
	Usort(a+1, N);
	
	ans = 0, j = 1;
	for (i = 1; i <= N; ++i) {
		imos[i] += imos[i-1];
		h = a[i].H - imos[i];
		if (h > 0) {
			t = (h-1)/A + 1;
			ans += t, t *= A;
			j = bs(j, a[i].X + D);
			imos[i] += t, imos[j+1] -= t;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n][m], b[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    
    int c[n];
    for (int i = 0; i < n; i++) {
        c[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += (a[i][j] * b[j]);
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long a,b=-1;
  string c;
  cin>>c>>a;
  for(int i=0;i<c.size();i++){
    if(i+1>=a&&b==-1) b=i;
    if(c[i]!='1'&&b==-1) b=i;
  }
  cout<<c[b]<<"\n";
}

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

const int maxn = 1e5 + 10;
char s[maxn];
struct Point {
    int l, r;
} G[maxn];

int main() {
    int len, k;
    scanf("%d%d", &len, &k);
    scanf("%s", s);
    int l = 0;
    int cnt = 0;
    s[len] = '0';
    G[0].l = G[0].r = 0;
    cnt = 1;
    for (int i = 0; i <= len; i++) {
        if (s[i] == '1') {
            if (!l) G[cnt++].l = i;
            l++;  
        } else {
            if (l) G[cnt-1].r = i - 1;
            l = 0;
        }   
    }
    G[cnt].l = G[cnt].r = len - 1;
    cnt++;
    int ans = 0;
    if (k + 1 >= cnt) {
        printf("%d\n", len);
        return 0;
    }
    for (int i = 0; i < cnt; i++) {
        int temp = i + k;
        if (temp >= cnt) break;
        ans = max(ans, G[temp].r - G[i].l + 1);
    }
    ans = min(ans, len);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 768
sx, sy, tx, ty = map(int, input().split())
sx, sy, tx, ty = 0, 0, tx + (0 - sx), ty + (0 - sy)
answer = []

# first go & forth
for i in range(ty) :
    answer.append("U")
for i in range(tx) :
    answer.append("R")
for i in range(ty) :
    answer.append("D")
for i in range(tx) : 
    answer.append("L")

# second go & forth
answer.append("L")

for i in range(ty + 1) :
    answer.append("U")
for i in range(tx + 1) :
    answer.append("R")

answer.append("D")
answer.append("R")

for i in range(ty + 1) :
    answer.append("D")
for i in range(tx + 1) :
    answer.append("L")
answer.append("U")

print("".join(answer))

Measured memory_bytes: 3188
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)*}
  };
}

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, usize1) => {
      read_value!($next, usize) - 1
  };

  // 3
  // 1 2
  // 1 3
  // 1 4
  // のようなタイプ
  ($next:expr, [ $t:tt ]) => {{
      let len = read_value!($next, usize);
      (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
  }};

  ($next:expr, $t:ty) => {
      $next().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    v: [u64;n]
  }

  let mut sum: u64 = 0;
  let trait_num = (10 as u64).pow(9) + 7;

  let mut bit_array = [0; 60];

  for i in 0..n {
    for d in 0..60 {
      // d桁目をマスクした値
      bit_array[d] += (v[i] & (2 as u64).pow(d as u32)) >> d;
    }
  }

  for d in 0..60 {
    sum += (bit_array[d] * (n as u64 - bit_array[d]) % trait_num) * ((1 << d) % trait_num);
  }

  println!("{}", sum % trait_num);
}


Measured memory_bytes: 8444
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<int> num(n); for (auto& a : num) std::cin >> a;
	std::sort(num.begin(), num.end());
	std::vector<int> under1000;
	std::vector<bool> is_dividable(1000001, false);
	for (const auto a : num) {
		if (std::distance(std::lower_bound(num.begin(), num.end(), a), std::upper_bound(num.begin(), num.end(), a)) > 1) {
			is_dividable[a] = true;
		}
		if (a <= 1000) {
			under1000.push_back(a);
		}
		else {
			for (auto i = a << 1; i < is_dividable.size(); i += a) {
				is_dividable[i] = true;
			}
		}
	}
	std::sort(under1000.begin(), under1000.end());
	under1000.erase(std::unique(under1000.begin(), under1000.end()), under1000.end());
	int count{ 0 };
	for (const auto a : num) {
		if (is_dividable[a]) continue;
		for (const auto d : under1000) {
			if (a <= d) break;
			if (a % d == 0) {
				--count;
				break;
			}
		}
		++count;
	}
	std::cout << count << '\n';
}

Measured memory_bytes: 5192
r,c = map(int, input().split())

mat = []
for row in range(r):
    row_index = list(map(int, input().split()))
    mat.append(row_index)


new_r = [0]*c
mat.append(new_r)

for i in range(c):
    for j in range(r):
        mat[r][i] += mat[j][i]

for i in range(r+1):
    m = 0
    for j in range(c):
        m += mat[i][j]
        print((mat[i][j]), end=' ')
    print(m)





Measured memory_bytes: 6228
X,Y,Z,K= map(int,input().split())
A = sorted(list(map(int,input().split())), reverse=True)
B = sorted(list(map(int,input().split())), reverse=True)
C = sorted(list(map(int,input().split())), reverse=True)



ab_list = []

for i in range(X):
    for j in range(Y):
        ab_list.append(A[i]+B[j])

ab_list2 = sorted(ab_list,reverse = True)[:min(X*Y,K)]
abc_list = []

count = 0
count2 = 0

for i in range(min(X*Y,K)):
    for j in range(Z):
        abc_list.append(ab_list2[i]+C[j])


abc_list2 = sorted(abc_list,reverse = True)[:K]

for i in range(K):
    print(abc_list2[i])


    
    


    




    

Measured memory_bytes: 149504
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int M = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'I') x++;
        else if(S[i] == 'D') x--;
        M = max(M,x);
    }
    cout << M << endl;
}


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

using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int m[n] = {0};
  int minM = 1 << 30;
  int result = 0;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    minM = min(minM, m[i]);
    x -= m[i];
    result++;
  }

  while (x > 0) {
    if (x >= minM) {
      result++;
    }
    x -= minM;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int H, W;
  cin >> H >> W;
  string a[H];
  for(int i = 0;i < H;i++) cin >> a[i];
  
  int w[W] = {};
  for(int i = 0;i < W;i++){
    int cnt = 0;
    for(int j = 0;j < H;j++){
  if(a[j].at(i) == '.')
    cnt++;
    }
    if(cnt == H) w[i] = 1;
  }
  
  int h[H] = {};
    for(int i = 0;i < H;i++){
    int cnt = 0;
    for(int j = 0;j < W;j++){
  if(a[i].at(j) == '.')
    cnt++;
    }
    if(cnt == W) h[i] = 1;
  }
  
  for(int i = 0;i < H;i++){
    if(h[i] == 1) cout << "";
    else for(int j = 0;j < W;j++){
    if(w[j] == 1) cout << "";
      else cout << a[i].at(j);
      
      if(j == W - 1) cout << endl; 
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
#define INF (1<<26)

int N,M,a,b,si,ti;
vector<int> G[MAX_N];
int sd[MAX_N],td[MAX_N];
int sc[MAX_N],tc[MAX_N];

void calc(int si,int d[MAX_N],int c[MAX_N]){
  for(int i=0;i<MAX_N;i++)d[i]=INF,c[i]=0;

  queue<int> Q;
  d[si]=0;
  c[0]++;
  Q.push(si);
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      if(d[pos]+1<d[to]){
	d[to]=d[pos]+1;
	c[d[to]]++;
	Q.push(to);
      }
    }
  }
}

int main(){
  scanf("%d %d %d %d",&N,&M,&si,&ti);
  for(int i=0;i<M;i++){
    scanf("%d %d",&a,&b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  calc(si,sd,sc);
  calc(ti,td,tc);
 
  int total=sd[ti];
  long long ans=0,A,B;
  for(int i=0;i<=N;i++){
    if(total-2-i<0)continue;
    A=sc[i];
    B=tc[total-2-i];
    ans+=A*B;
  }
  cout<<ans<<endl;
  return 0;
}

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

const int N = 200000 + 10;

int n, x;
int ans[N];

int main() {
  scanf("%d%d", &n, &x);
  if (x == 1 || x == 2 * n - 1) return puts("No"), 0;
  puts("Yes");
  ans[n] = x;
  static bool flag[N];
  flag[x] = true;
  if (x > 2) {
    ans[n - 1] = 1;
    ans[n + 1] = 2 * n - 1;
    ans[n + 2] = 2;
    flag[1] = flag[2] = flag[2 * n - 1] = true;
  } else {
    ans[n - 1] = 2 * n - 1;
    ans[n + 1] = 1;
    ans[n + 2] = 2 * n - 2;
    flag[1] = flag[2 * n - 2] = flag[2 * n - 1] = true;
  }
  for (int i = 1, j = 1; i < 2 * n; ++i) {
    if (!ans[i]) {
      while (flag[j]) ++j;
      ans[i] = j;
      flag[j] = true;
    }
  }
  for (int i = 1; i < 2 * n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 2560
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  op,dummy:char;
  a,b:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(dummy);
    Read(op);
    Read(dummy);
    Readln(b);

    if op='+' then   
      Writeln(a+b)
    else
      Writeln(a-b);    

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
--https://www.lua.org/pil/11.4.html
List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

----------

local n,q=io.read("*n","*n")
local edge={}
local counter={}
for i=1,n do
    counter[i]=0
    edge[i]={}
end
for i=1,n-1 do
    local a,b=io.read("*n","*n")
    edge[a][b]=false
    edge[b][a]=false
end
for i=1,q do
    local p,x=io.read("*n","*n")
    counter[p]=counter[p]+x
end

local que=List.new()
List.pushright(que,1)

while true do
    local a=List.popleft(que)
    if a then
        for b,_ in pairs(edge[a]) do
            if not edge[a][b] and not edge[b][a] then
                counter[b]=counter[b]+counter[a]
                edge[a][b]=true
                edge[b][a]=true
                List.pushright(que,b)
            end
        end
    else
        break
    end
end

print(table.concat(counter," "))

Measured memory_bytes: 46728
/* 
   AOJ 1180
   Recurring Decimals
   2015/6/2
 */

#include<stdio.h>
#include<stdlib.h>


int first_appearance, recurring_num, diff, second_appearance, stock[21] = {0};
int *num;

void descending_insertion(int *a, int pos, int value)
/* 降順ソート */
{
  int i;
  for(i = pos - 1; i >= 0 && a[i] < value; i--)
    {
      a[i + 1] = a[i];
    }
  a[i + 1] = value;
}

void ascending_insertion(int *a, int pos, int value)
/* 昇順ソート */
{
  int i;
  for(i = pos - 1; i >= 0 && a[i] > value; i--)
    {
      a[i + 1] = a[i];
    }
  a[i + 1] = value;
}

void sort(int *a, int left, int right, int sw)
/*
 sw == 0なら昇順ソート
 sw == 1なら降順ソート
 */
{
  int i;
  if(sw == 0)
    {
      for(i = 0; i < right; i++)
	{
	  ascending_insertion(a, i, a[i]);
	}
    }
  else
    {
      for(i = 0; i < right; i++)
	{
	  descending_insertion(a, i , a[i]);
	}
    }
}

int pow_ten(int exp)
{
  int i, ret = 1;
  for(i = 0; i < exp - 1; i++)
    {
      ret = ret * 10;
    }
  return ret;
}

int calc_diff_of_max_and_min(int digit)
{
  int i, max = 0, min = 0;
  int *p = num;
  sort(p, 0, digit, 1);
  for(i = 0; i < digit; i++)
    {
      max = max + num[i] * pow_ten(digit - i);
    }
  sort(p, 0, digit, 0);
  for(i = 0; i < digit; i++)
    {
      min = min + num[i] * pow_ten(digit - i);
    }

  return max - min;
}


void create_num_box(int number, int digit)
{
  int i, rest = number;

  num = malloc(digit * sizeof(int));

  for(i = 0; i < digit; i++)
    {
      num[i] = rest / pow_ten(digit - i);

      rest = rest % pow_ten(digit - i);
    }
}

int is_there_num(int num, int position)
{
  int i;
  for(i = 0; i < 21 && i < position; i++)
    {
      if(stock[i] == num)
	{
	  first_appearance = i;
	  return 1;
	}
    }
  return 0;
}

void search(int num, int digit)
{
  int i;
  for(i = 0; ; i++)
    {
      if(i <= 20)
	{
	  stock[i] = num;
	}
      if(is_there_num(num, i))
	{
	  recurring_num = num;
	  diff = i - first_appearance;
	  break;
	}
      create_num_box(num, digit);
      num = calc_diff_of_max_and_min(digit);
    }
}

int main(void)
{
  int num, digit;
  while(1)
    {
      scanf("%d %d", &num, &digit);

      if(num == 0 && digit == 0)
	{
	  break;
	}

      search(num, digit);

      printf("%d %d %d\n", first_appearance, recurring_num, diff);

    }
  return 0;
}

Measured memory_bytes: 624
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 16;

int R[MAX][MAX];
int f[5][MAX][1<<MAX];
int bio[5][MAX][1<<MAX];
int cookie, n;

int solve(int h, int w, int s) {
  if (bio[h][w][s] == cookie) return f[h][w][s];
  bio[h][w][s] = cookie;

  int cnt = 0;
  REP(i, n) 
    if (s&(1<<i)) cnt++;
  if (cnt == 1) return f[h][w][s] = (s>>w) & 1;

  int nh = 0;
  while (cnt > 1) nh++, cnt = (cnt + 1) / 2;
  if (nh > h) return f[h][w][s] = 0;

  f[h][w][s] = 0;
  for (int s1 = s; s1 > 0; s1 = s & (s1 - 1))
    if ((s1 & s) == s1) {
      if (!(s1 & (1<<w))) continue;
      if (s1 == s) continue;

      int s2 = s ^ s1;

      REP(i, n)
        if (s2 & (1<<i))
          if (R[w][i]) f[h][w][s] += solve(h-1, w, s1) * solve(h-1, i, s2);
    }
  return f[h][w][s];
}

int main(void) {
  int m;
  while (scanf("%d %d", &n, &m) == 2) {
    if (n == 0 && m == 0) break;

    --m;
    REP(i, n) REP(j, n) scanf("%d", &R[i][j]);

    cookie++;
    int h = 0, tmp = n;
    while (tmp > 1) tmp = (tmp + 1) / 2, h++;
    printf("%d\n", solve(h, m, (1<<n) - 1));
  }
  
  return 0;
}

Measured memory_bytes: 20112
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
s = 0
for i in range(N):
    a = A[i]
    s += a
    s %= MOD
t = s*s
for i in range(N):
    a = A[i]
    t -= a*a
    t %= MOD
t %= MOD
if t % 2 == 0:
    print(t // 2)
else:
    print((t+MOD)//2)

            








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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, c;
  cin >> a >> b >> c;
  ll g = __gcd(a, b);
  if (c % g == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class BIT {
    int n;
    VL dat;
public:
    void init(int in) {
        n = in + 1;
        dat.clear();
        dat.resize(n + 1, 0);
    }
    ll sum(int i) {
        ll ret = 0;
        while (i >= 0) {
            ret += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return ret;
    }
    void add(int i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    init();
    int n;
    cin >> n;
    VI a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = (((ll)n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


Measured memory_bytes: 2560
package main

import (
  "fmt"
)

func main() {

  var N int
  fmt.Scan(&N)
  var S string
  fmt.Scan(&S)
  d := make(map[byte]int)
  for i := 0; i < N; i++ {
    d[S[i]]++
  }

  ans := 1
  for _, v := range d {
    ans *= 2 + v-1
    ans %= 1000000007
  }
  fmt.Println(ans-1)
}

Measured memory_bytes: 1280
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var l = sc.IntArray();
        Array.Sort(l);
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (l[i] == l[j]) continue;
                for (int k = j + 1; k < n; k++)
                {
                    if (l[k] == l[j] || l[k] == l[i]) continue;
                    if (l[i] + l[j] > l[k]) ans++;
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>

using namespace std;

class Solver {
public:
	static void solve() {
		int max = 300000;
		vector<bool> prime(max + 10, true);
		for (int i = 2; i <= max; i++) {
			if (!prime[i])continue;

			for (int j = 2; i * j <= max; j++) {
				prime[i * j] = false;
			}
		}
		vector<int> primeCnts(max + 10, 0);
		for (int i = 2; i <= max; i++) {
			primeCnts[i] = primeCnts[i - 1];
			if (prime[i])primeCnts[i] ++;
		}

		int n;
		cin >> n;
		vector<int> res;
		while (n > 0) {
			res.emplace_back(primeCnts[2 * n] - primeCnts[n]);

			cin >> n;
		}

		for (int i = 0; i < res.size(); i++) {
			cout << res[i] << endl;
		}
	}
};

int main() {
	Solver::solve();
}


Measured memory_bytes: 3952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct Segtree {
    int n;

    vi dat;

    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        dat.resize(2 * n);
        for (int i = 0; i < 2 * n - 1; ++i) dat[i] = 0;
    }

    void update(int a, int x) {
        a += n - 1;
        dat[a] += x;
        while (a > 0) {
            a = (a - 1) / 2;
            dat[a] += x;
        }
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];

        int lsum = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int rsum = query(a, b, k * 2 + 2, (l + r) / 2, r);

        return lsum + rsum;
    }
};

signed main()
{
    int N, Q; cin >> N >> Q;

    Segtree seg;
    seg.init(N);

    rep(i, Q) {
        int type, x, y;

        cin >> type >> x >> y;
        -- x;

        if (type % 2 == 0) {
            seg.update(x, y);
        } else {
            -- y;
            cout << seg.query(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 2060
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      sum = 500*i + 100*j + 50*k
      if X==sum:
        count+=1

print(str(count))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);
    int a,b;
    cin>>a>>b;
    cout<<(b+a-3)/(a-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
using namespace std;

int main(){
  long long n; cin >> n;
  long long a, b;
  a = 1;
  b = 1;
  long long shortest = 100000000000000;
  r_rep_ll(i, 1, pow(n, 0.5) + 1){
    if(n % i == 0){
      b = n/i;
      shortest = min(shortest, i + b - 2);
    }
  }
    // while (a*b <= 1000000000000){
    //   if(a*b == n){
    //     shortest = a + b - 2;
    //     break;
    //   }else if(a*b > n){
    //     break;
    //   }
    //   b += 1;
    // }
  cout << shortest << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll a(int L) {  // レベルLバーガーの厚さ

    if(L == 0) {
        return 1;
    }

    return 2*a(L-1) + 3;
}

ll p(int L) {  // レベルLバーガーに含まれるパティの数

    if(L == 0) {
        return 1;
    }

    return 2*p(L-1) + 1;
}

ll f(int L, ll x) {  // レベルLバーガーの下からx層に含まれるパティの数

    if(L == 0) {
        return 1;
    }

    if(x == 1) {
        return 0;
    }
    else if(x <= a(L-1) + 1) {
        return f(L-1, x-1);
    }
    else if(x == a(L-1) + 2) {
        return p(L-1) + 1;
    }
    else if(x <= 2*a(L-1) + 2) {
        return  p(L-1) + 1 + f(L-1, x - a(L-1) - 2);
    }
    else if(x == a(L)) {
        return p(L);
    }
}

int main() {
    int n;
    ll X;
    cin >> n >> X;

    cout << f(n, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 1000000;

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;
}
// 法mでのaの逆元を計算
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;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main(){
    int N; cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    for(int i=0;i<N;i++){
        cin >> s[i] >> t[i];
    }
    string X; cin >> X;
    bool f=false;
    int sum=0;
    for(int i=0;i<N;i++){
        if(f) sum += t[i];
        if(s[i] == X){
            f=true;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 888