akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li cnt[100100];
li d[100100];

int main() {
    li n;
    cin >> n;
    li mad = 0;
    rin{
        cin >> d[i];
        mad = max(mad, d[i]);
        cnt[d[i]]++;
    }
    if (d[0] != 0 || cnt[0] != 1) {
        puts("0");
        return 0;
    }

    li res = 1;
    li parent_num = 1;
    repp(i, 1, mad + 1) {
        if (cnt[i] == 0) {
            puts("0");
            return 0;
        }
        // res *= parent_num^child_num
        rep(j, cnt[i]) {
            res = (res * parent_num) % MOD;
        }
        parent_num = cnt[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
def solve(i, m):
    if m == 0: return True

    if i < n and min(A[i:]) <= m <= sum(A[i:]):
        r1 = solve(i + 1, m-A[i])
        if r1: return r1
        r2 = solve(i + 1, m)
        if r2: return r2


n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

for i in M:
    print "yes" if solve(0, i) else "no"

Measured memory_bytes: 6468
// abc112_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> x(N), y(N), h(N);
    REP(i, N) cin >> x[i] >> y[i] >> h[i];

    REP(cx, 101) REP(cy, 101){

        int H=0;
        REP(i, N){
            if (h[i] != 0){
                H = abs(cx-x[i]) + abs(cy-y[i]) + h[i];
                break;
            }
        }

        bool is_valid = true;
        REP(i, N){
            int tmp = max(H - abs(cx-x[i]) - abs(cy-y[i]), 0);
            if (tmp != h[i]){
                is_valid = false;
                break;
            }
        }
        if (is_valid){
            print(cx, cy, H);
            return 0;
        }
    }

    return 0;
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  long long count = 0;
  count += (N / K) * (N / K) * (N / K);
  if (K % 2 == 0){
    count += ((N + (K / 2)) / K) * ((N + (K / 2)) / K) * ((N + (K / 2)) / K);
  }
  cout << count << endl;
} 

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	for i := A; i <= min(B, A+K-1); i++ {
		fmt.Println(i)
	}
	for i := max(A+K, B-K+1); i <= B; i++ {
		fmt.Println(i)
	}
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

int n , k ;
long long arr[MAX] ;


bool check(long long x)
{
	long long cnt = 0 ;
	for(int i = 0 ; i < n ; ++i)
		cnt += (arr[i] - 1) / x ;
	return (cnt <= k) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	long long l = 1 , r = 1e9 ;
	long long ans = r ;
	while(l <= r)
	{
		long long mid = (l + r) >> 1 ;
		if(check(mid))
			ans = mid , r = mid-1 ;
		else
			l = mid+1 ;
	}
	return cout<<ans<<"\n" , 0 ;
}

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

int main() {
    //a matrix of 10*3*4 initialized by 0
    int n,m;
    int i,j,k;
    cin >> n >> m; 
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    vector<int> c(n,0);
    for ( i = 0; i < n; i++){
        for ( j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for ( i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for ( i = 0; i < n; i++){
        for ( j = 0; j < m; j++){
            c[i] +=  a[i][j]*b[j];
        }
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define N 100001
#define pb push_back
vector< int> v[100001];

int cvr[N], c, n, nxt[N];

int bfs2n(int p, int x){
	if(x == n){
		nxt[p] = x;
		return 1;
	}
	int ret = 0;
	for(int i = 0; i < v[x].size(); i++){
		if(v[x][i] != p){
			ret += bfs2n(x, v[x][i]);
		}
	}
	if(ret){
		nxt[p] = x;
		ret++;
		// cout << x << endl;
	}
	return ret;
}

int noc(int p, int x, int y){
	int ret = 1;
	for(int i = 0; i < v[x].size(); i++){
		if(v[x][i] != p && v[x][i] != y){
			ret += noc(x, v[x][i], 0);
		}
	}
	return ret;
}

int main(){
	cin >> n;
	for(int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	int d = bfs2n(0, 1), cnt = 0, prev = 0, cur = 1;
	// cout << "dist " << d << endl;
	for(int i = 0; i < (d+1)/2; i++){
		cnt += noc(prev, cur, nxt[cur]);
		// cout << "cur " << cur << "  count = " << cnt << endl;
		prev = cur;
		cur = nxt[cur];
	}
	// cout << cnt << endl;
	if(cnt > n-cnt){
		cout << "Fennec\n";
	}else cout << "Snuke\n";
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);
vvb V;

typedef pair<int, int> P;
typedef pair<int, P> PP;
int H, W;

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

bool check(int y, int x) {
	if (y < 0 || y >= H)return false;
	if (x < 0 || x >= W)return false;
	return true;
}


int bfs() {
	queue<PP> QP;
	vvi dist(H, vi(W, INF));
	QP.push(PP(1, P(0, 0)));//(最短距離,P(Y座標,X座標))
	dist[0][0] = 1;
	while (!QP.empty()) {
		PP pp = QP.front(); QP.pop();
		P p = pp.second;
		REP(i, 4) {
			int py = p.first + dy[i];
			int px = p.second + dx[i];
			if (!check(py, px))continue;
			if (!V[py][px])continue;
			if (dist[py][px] != INF)continue;
			if (py == H - 1 && px == W - 1)return pp.first + 1;
			dist[py][px] = pp.first + 1;
			QP.push(PP(pp.first + 1, P(py, px)));
		}
	}
	return -1;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	V = vvb(H, vb(W, false));
	int cnt = 0;
	REP(i, H) {
		string S;
		cin >> S;
		REP(j, W) {
			if (S[j] == '#')cnt++;
			else V[i][j] = true;
		}
	}
	int result = bfs();
	if (result == -1)cout << -1 << endl;
	else cout << H * W - cnt - result << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    ll pa = 0, pb = 0, pc = 0;
    ll turn = 0;
    ll winner = -1;
    while(1){
        if(turn == 0){
            if(pa == sa.size()){
                winner = 0;
                break;
            }else{
                if(sa[pa] == 'a'){
                    turn = 0;
                }else if(sa[pa] == 'b'){
                    turn = 1;
                }else{
                    turn = 2;
                }
                pa++;
            }
        }else if(turn == 1){
            if(pb == sb.size()){
                winner = 1;
                break;
            }else{
                if(sb[pb] == 'a'){
                    turn = 0;
                }else if(sb[pb] == 'b'){
                    turn = 1;
                }else{
                    turn = 2;
                }
                pb++;
            }
        }else{
            if(pc == sc.size()){
                winner = 2;
                break;
            }else{
                if(sc[pc] == 'a'){
                    turn = 0;
                }else if(sc[pc] == 'b'){
                    turn = 1;
                }else{
                    turn = 2;
                }
                pc++;
            }
        }
    }

    if(winner == 0){
        cout << "A" << endl;
    }else if(winner == 1){
        cout << "B" << endl;
    }else{
        cout << "C" << endl;
    }

    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <queue>
#include <limits>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T = int>
class Dinic {
public:
	struct Edge {
		Edge(int a, T b){to = a;cap = b;}
		int to;
		T cap;
	};

	Dinic(int nn) {
		edges.resize(nn);
		this->n = nn;
	}

	T maxFlow(int src, int sink) {
		T ans = 0;
		while(bfs(src, sink)) {
			T flow;
			pt = std::vector<int>(n, 0);
			while(flow = dfs(src, sink)) {
				ans += flow;
			}
		}
		return ans;
	}

	void addEdge(int from, int to, T cap = 1) {
		edges[from].push_back(list.size());
		list.push_back(Edge(to, cap));
		edges[to].push_back(list.size());
		list.push_back(Edge(from, 0));
	}
//private:
	int n;
	std::vector<std::vector<int> > edges;
	std::vector<Edge> list;
	std::vector<int> h, pt;

	T dfs(int on, int sink, T flow = 1e9) {
		if(flow == 0) {
			return 0;
		} if(on == sink) {
			return flow;
		}
		for(; pt[on] < edges[on].size(); pt[on]++) {
			int cur = edges[on][pt[on]];
			if(h[on] + 1 != h[list[cur].to]) {
				continue;
			}
			T got = dfs(list[cur].to, sink, std::min(flow, list[cur].cap));
			if(got) {
				list[cur].cap -= got;
				list[cur ^ 1].cap += got;
				return got;
			}
		}
		return 0;
	}

	bool bfs(int src, int sink) {
		h = std::vector<int>(n, n);
		h[src] = 0;
		std::queue<int> q;
		q.push(src);
		while(!q.empty()) {
			int on = q.front();
			q.pop();
			for(auto a : edges[on]) {
				if(list[a].cap == 0) {
					continue;
				}
				int to = list[a].to;
				if(h[to] > h[on] + 1) {
					h[to] = h[on] + 1;
					q.push(to);
				}
			}
		}
		return h[sink] < n;
	}
};

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m;
	std::cin >> n >> m;
	std::vector< std::vector<int> > a(n);
	for(int i = 0; i < n; i++) {
		a[i].resize(m);
		for(int j = 0; j < m; j++) {
			std::cin >> a[i][j];
			a[i][j]--;
		}
	}
	// find M perfect matches
	for(int rep = 0; rep < m; rep++) {
		Dinic<int> graph(n+n+2);
		int src = n+n;
		int sink = src+1;
		for(int i = 0; i < n; i++) {
			for(int j = rep; j < m; j++) {
				graph.addEdge(i, n+(a[i][j]/m), 1);
			}
		}
		for(int i = 0; i < n; i++) {
			graph.addEdge(src, i, 1);
			graph.addEdge(n+i, sink, 1);
		}
		//std::cout << "got flow " << graph.maxFlow(src, sink) << "!\n";
		assert(graph.maxFlow(src, sink) == n);
		int id = 0;
		for(int i = 0; i < n; i++) {
			for(int j = rep; j < m; j++) {
				if(graph.list[id].cap == 0) {
					std::swap(a[i][j], a[i][rep]);
				}
				id += 2;
			}
		}
	}
	// print
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			std::cout << a[i][j]+1 << (j + 1 == m ? '\n' : ' ');
		}
	}
	// sort columns
	for(int j = 0; j < m; j++) {
		std::vector<int> ha(n);
		for(int i = 0; i < n; i++) {
			ha[i] = a[i][j];
		}
		std::sort(ha.begin(), ha.end());
		for(int i = 0; i < n; i++) {
			a[i][j] = ha[i];
		}
	}
	// print
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			std::cout << a[i][j]+1 << (j + 1 == m ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    char b; cin>>b;
    if(b=='A') cout<<'T'<<endl;
    else if(b=='T') cout<<'A'<<endl;
    else if(b=='C') cout<<'G'<<endl;
    else cout<<'C'<<endl;
    return 0;
}

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

int main() {
  int N, ans=10000, s1=0, s2=0, s3=0;
  cin >> N;
  vector<int> W(N);
  for (int i=0; i<N; i++) cin >> W.at(i);
  for (int t=1; t<N; t++) {
    for (int i=0; i<=t; i++) s1 += W.at(i);
    for (int i=t+1; i<N; i++) s2 += W.at(i);
    s3 = s1 - s2;
    if (s3 <0) s3 *= -1;
    if (s3 < ans) ans = s3;
    s1 = 0;
    s2 = 0;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    int K;  cin >> K;
    ll tmp=0, cnt=0;
    while(tmp >= 0){
        tmp = (tmp*10+7)%K;
        cnt++;
        if(tmp==0){
            cout << cnt;
            return 0;
        }
        if(cnt >= 2000000){
            cout << -1;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int a = 9;
  int b = 900;
  int c = 90000;
  
  if (n == 100000) {
    cout << a + b + c << endl;
  }
  else if (n >= 10000) {
    cout << n - 10000 + 1 + a + b << endl;
  }
  else if (n >= 1000) {
    cout << a + b << endl;
  }
  else if (n >= 100) {
    cout << n - 100 + 1 + a << endl;
  }
  else if (n >= 10) {
    cout << a << endl;
  }
  else {
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

L = []
n = []

N = int(input())
for i in range(N):
	A = int(input())
	L.append(A)
	n.append(A)

L = sorted(L)
if L[-1] == L[-2]:
	for i in range(N):
		print(L[-1])
else:
	for i in range(N):
		if n[i] == L[-1]:
			print(L[-2])
		else:
			print(L[-1])

Measured memory_bytes: 14936
#bubble_sort
n = int(input())
a = list(map(int, input().split()))
cnt = 0
frag = 1
while frag:
    frag = 0
    for i in reversed(range(1, n)):
        if a[i-1] > a[i]:
            a[i-1],a[i] = a[i], a[i-1]
            cnt += 1
            frag = 1
print(*a)
print(cnt)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep_a(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

   int k;
   cin>>k;

   vector<long long>a;
   for(int i=1;i<=9;i++)
    a.push_back(i);

   while(1){

    if(k <= a.size()){
     cout<<a[k-1]<<endl;
    return 0;
    }

     k -= a.size();
     vector<long long>old;
     swap(old,a);

     for(long long x:old){
         for(int i=-1;i<=1;i++){
             long long d = x%10+i;
             if(d<0 || d>9)
                continue;
             long long nx = x*10 + d;
             a.push_back(nx);
         }
     }

   }

return 0;
 }



Measured memory_bytes: 4680
#include<stdio.h>
int main(){
  int a,b,c,d;
  d=0;
  scanf("%d %d %d",&a,&b,&c);
  if(a<1 && b>10000 && c>10000){
    printf("error\n");
  }
    for(a;a<=b;a++){
      if(c%a==0){
	d++;
      }
    }
    printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
li = []
for _ in range(n):
    x0, y0, h0 = list(map(int, input().split()))
    li.append((h0, x0, y0))

li.sort(reverse=True)
# all search
from itertools import product
for x, y in product(range(0, 101), repeat=2):
    h0, x0, y0 = li[0]
    h = h0 + abs(x0 - x) + abs(y0 - y)
    ok = True
    for h0, x0, y0 in li[1:]:
        if h0 != max(0, h - abs(x - x0) - abs(y - y0)):
            ok = False
            break
    if ok:
        break

print(x, y, h)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
//#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int main(){
  int n,a;
  cin>>n;
  map<int,int> D,T;
  rep(i,n){
    cin>>a;
    D[a]++;
  }
  int m;
  cin>>m;
  vector<int> b(m);
  rep(i,m){
    cin>>b[i];
    T[b[i]]++;
  }
  rep(i,m){
    a=b[i];
    if(T[a]>D[a]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 19840
from collections import deque
import sys

n, q, *args = map(int, open(0).read().split())
ab = args[:(n-1)*2]
px = args[(n-1)*2:]

tree = [[] for _ in range(n+1)]
for a, b in zip(*[iter(ab)]*2):
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * (n+1)
for p, x in zip(*[iter(px)]*2):
    counter[p] += x

# pop, appendまたはQueueライブラリだと間に合わない
queue = deque([[0,1]])
while queue:
    parent, node = queue.popleft()
    for leaf in tree[node]:
        if leaf == parent:
            continue
        counter[leaf] += counter[node]
        queue.append([node, leaf])

print(*counter[1:])


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
おなじindexのものは違う値
それぞれの列で重複は許さない
まずAの並べ方がmCn * n!通り
Bも同様だが、このうちAと一致するようなものを数え上げる

1 2
2 1

2 1
1 2

i) n == m のとき
閉路の作り方に等しい？
n!

ii) n + 1 == m のとき
同じ場合 -> m * n!
一個違う場合 -> 

わからない、、、
*/

/*

包除原理でとく
全体からAi==Biである要素がk個であるものを引いたり足したりする

[Ai==Biであるものの求め方]
M個からN個選ぶけど、そのうちAi==Biであるものを|S|とする。
|S|の並べ方はM_P_|S|通りとなる。
残りの整数の並べ方はM-|S|_P_N-|S|通りであり、AとBそれぞれ自由に決められるので、その二錠

(M!/(M - k)!) * ((M - k)!/(N - k)!)^2

MCk * k! * NCk = M!/(M - k)! * NCk
M-kCN-k * (N - k)!
*/

int mod = 1e9 + 7;

int	main(void)
{
	int n, m;
	cin >> n >> m;
	vector<long long> fac(2e6 + 2, 1);
	for (int i = 2; i < 2e6 + 2; i++) fac[i] = fac[i - 1] * i % mod;
	vector<long long> inv(1e6 + 2, 1);
	for (int i = 2; i < 1e6 + 2; i++) inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
	vector<long long> finv(1e6 + 2, 1);
	for (int i = 2; i < 1e6 + 2; i++) finv[i] = finv[i - 1] * inv[i] % mod;
	long long all = 1;
	all *= fac[m] * finv[m - n] % mod;
	all %= mod;
	all *= fac[m] * finv[m - n] % mod;
	all %= mod;
	long long dup = 0;
	for (int i = 1; i <= n; i++)
	{
		long long add = 1;
		add *= fac[m] * finv[m - i] % mod;
		add %= mod;
		add *= fac[m - i] * finv[m - n] % mod;
		add %= mod;
		add *= fac[m - i] * finv[m - n] % mod;
		add %= mod;
		add *= fac[n] * finv[i] % mod;
		add %= mod;
		add *= finv[n - i];
		add %= mod;
		if (i % 2) dup += add;
		else dup += mod - add;
		dup %= mod;
	}
	cout << (mod + all - dup) % mod << endl;
	return (0);
}


Measured memory_bytes: 34308
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

#define MOD 1000000007


int main(){

  ll n,sum=0;
  cin >> n;

  std::vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
    sum+=a.at(i);

  }


ll tsum=0;
  for(ll i=0;i<n;i++){



      tsum+=(a.at(i)%MOD)*((sum-a.at(i))%MOD)%MOD;

      sum-=a.at(i);
  }



  cout << tsum%MOD << endl;


  }


Measured memory_bytes: 4840
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};
struct edge {
    int to;
    LL cost;
    edge(int to, LL cost): to(to), cost(cost) {}
};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr LL INF = 1LL << 60;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

template <typename T = pair<LL, LL>>
void Dijkstra(int s, vector<vector<edge>> g, vector<LL> &d) {
    int numv = d.size();
    priority_queue<T, vector<T>, greater<T>> q;
    for (int i = 0; i < numv; ++i) d[i] = INF;
    d[s] = 0;
    q.emplace(0,s);

    while (!q.empty()) {
        T p = q.top(); q.pop();
        int v = p.second; // vertex
        //dump(v);
        if (d[v] < p.first) continue;
        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.emplace(d[e.to], e.to);
            }
        }
    }
}

void solve() {
    int n;
    cin >> n;
    vector<vector<edge>> es(n);
    int u,v,w;
    REP(i,0,n-1) {
        cin >> u >> v >> w;
        es[u-1].pb(v-1,w);
        es[v-1].pb(u-1,w);
    }
    VLL d(n);
    Dijkstra(0,es,d);
    //REP(i,0,n) dump(d[i]);
    REP(i,0,n) cout << (d[i] % 2 == 0 ? 0 : 1) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 15488
package main

import(
	"fmt"
)

func main(){
	var ids, idt string
	fmt.Scan(&ids, &idt)
	if len(ids)+1 == len(idt) && idt[0:len(idt)-1] == ids {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

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

using namespace std;

#define PROBLEM "C"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long
#define MAXN 100005

int main()
{
	#ifdef DBG
	freopen(PROBLEM TESTC ".in", "r", stdin);
	freopen(PROBLEM ".out", "w", stdout);
	#endif

	int N,K,Q;
	int p[MAXN];
	int who[MAXN];
	while(cin >> N >> K >> Q)
	{
		memset(p,0,sizeof(p));
		for(int i = 0; i <= N; i++)
			p[i] = Q;

		for(int i = 1; i <= Q; i++)
		{
			int win;
			cin >> win;
			p[win] -= 1;
		}


		for(int i = 1; i <= N; i++)
		{
			if(K - p[i] > 0)
				cout << "Yes\n";
			else
				cout << "No\n";
		}
	}

	return 0;
}

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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;

ll N, D;
ll X[200010], Y[200010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> D;
	rep(i, N) {
		cin >> X[i] >> Y[i];
	}
	ll cnt = 0;
	rep(i, N) {
		if (X[i] * X[i] + Y[i] * Y[i] <= D * D) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6788
#include <stdlib.h> 
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std; 

int main()
{
	int a,b,c,k,count,sum;
	count = 0;	
	sum = 0;
	
	cin>>a>>b>>c>>k;
	
	while(count <= k)
	{
		for(int j = 0; j < a; j++)
		{
			if(count == k) break;
			sum = sum + 1;
			count++; 
		}
		
		for(int l = 0; l < b ; l++)
		{
			if(count == k) break;
			sum = sum + 0;
			count++;
		}
		
		for(int m = 0; m < c; m++)
		{
			if(count == k) break;
			sum = sum - 1;
			count++;
		}
		break;
	}
	
	cout<<sum;
}


Measured memory_bytes: 3548
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}
int n;
char c[6];
inline void putsaidai() {
	for (int i = n - 1; i >= 0; i--) *di++ = c[i];
	*di++ = '\n';
}

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


	int N = getint();
	int A[200000];
	
	int saidai = 0;
	int niban = 0;
	rep(i, N) {
		A[i] = getint();
		if (niban < A[i]) {
			niban = A[i];
			if (niban > saidai) swap(niban, saidai);
		}
	}

	int kari = saidai;
	while (kari) {
		*(c + n) = '0' + kari % 10;
		kari /= 10;
		n++;
	}

	rep(i, N) {
		if (A[i] == saidai) putint(niban);
		else putsaidai();
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b;
  for(int i;i<1001 ; i++){
    c++;
    d=c*0.08;
    e=c*0.1;
    if(d==a&&e==b)
      break;
  }
  if(c==1001)
    cout<<-1<<endl;
  else
    cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();

		String[] str = s.split(" ");
		int[] x = new int[str.length];
		
        for(int i = 0; i < str.length; i++){
            x[i] = Integer.parseInt(str[i]);
        }
        
        System.out.println(x[0] * x[1]);
    }
}

Measured memory_bytes: 35868
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 1000001
  

int32_t main()
{



   string s;
   cin >> s;
   if(s.length()%2 == 1)
   {
    cout << "No";
    return 0;
   }


   for(int i = 0; i< s.length() - 1; i++)
   {
    if(s[i] == 'h' and s[i+1] == 'i')
    {
      i++;
      continue;
    }
    else
    {
      cout << "No";
      return 0;
    }
   }

   cout << "Yes";


  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
while True:
    N = int(input())
    A = int(input())
    if (N >= 1 and N <= 10000) and (A >= 0 and A <= 1000):
        break

if (N / 500) > 0:
    x = N % 500
    if A >= x:
        print('Yes')
    else:
        print('No')
else:
    if A >= N:
        print('yes')
    else:
        print('No')

Measured memory_bytes: 3060
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <utility>

namespace n91 {

void main_() {
  const u64 n = scan<u64>();
  std::cout << (n - static_cast<u64>(1)) * n / static_cast<u64>(2) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
# 2019/08/08
from bisect import bisect_left,bisect_right

n=int(input())
x=list(map(int,input().split()))
xx=sorted(x)
mid=n//2

ans=[]
for i in range(n):
    if bisect_left(xx,x[i])<mid:
        ans.append(xx[mid])
    else:
        ans.append(xx[mid-1])
print(*ans,sep='\n')

Measured memory_bytes: 25224
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, P):
    revp = [-1] * (N + 1)
    for i, p in enumerate(P):
        revp[p] = i

    segt = [[(v, 0) for v in P]]
    while len(segt[-1]) > 1:
        base = segt[-1]
        if len(base) % 2 == 1:
            base.append((0, 0))
        new = []
        for i in range(len(base) // 2):
            a, b = base[2 * i]
            c, d = base[2 * i + 1]

            arr = [a, b, c, d]
            arr.sort()
            new.append((arr[-1], arr[-2]))
        segt.append(new)

    dprint('segt', segt)

    def get12(i, j):
        if j - i <= 0:
            return (0, 0)

        segi = 0
        top = []

        while True:
            if j - i <= 0:
                break

            seg = segt[segi]

            if j - i == 1:
                top.extend(seg[i])
                break

            if i % 2 == 1:
                top.extend(seg[i])
                i += 1
            if j % 2 == 1:
                top.extend(seg[j - 1])
                j -= 1

            i //= 2
            j //= 2
            segi += 1

        top.sort()
        return top[-1], top[-2]

    cache = [dict() for _ in range(N)]

    stk = [(0, N)]
    while stk:
        item = stk.pop()
        if len(item) == 2:
            i, j = item
            if j in cache[i]:
                continue

            a, b = get12(i, j)
            ai = revp[a]
            bi = revp[b]
            li, ri = (ai, bi) if ai < bi else (bi, ai)
            ri += 1

            sc = b * (li - i + 1) * (j - ri + 1)

            want = [(i, ri - 1), (li + 1, j), (li + 1, ri - 1)]
            req = []
            for c, d in want:
                if not (d - c < 2 or d in cache[c]):
                    req.append((c, d))
            if not req:
                left, right, mid = [0 if d - c < 2 else cache[c][d]
                                    for c, d in want]
                cache[i][j] = left + right - mid + sc
                continue

            stk.append((i, j, want, sc))
            for r in req:
                stk.append(r)
            continue

        i, j, want, sc = item
        left, right, mid = [0 if d - c < 2 else cache[c][d]
                            for c, d in want]
        cache[i][j] = left + right - mid + sc

    return cache[0][N]


def main():
    N = int(inp())
    P = [int(e) for e in inp().split()]
    print(solve(N, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115012
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vll pas(5);
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i,5){
        cin >> pas[i];
    }
    sort(ALL(pas));
    ans += n/pas[0] + ((n%pas[0]>0)?(1):(0));
    ans += 4;
    cout << ans << endl;
     

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
import numpy as np
a,b,x = map(int,input().split())
max_volume = b*a**2
if x == max_volume/2:
    print(45.0000000000)
    
if x > max_volume/2:
    rad = np.arctan(2*(max_volume - x)/a**3)
    print(np.rad2deg(rad))

if x < max_volume/2:
    rad = np.arctan(2*x/(a*b**2))
    print(90-np.rad2deg(rad))

Measured memory_bytes: 12464
<?php

fscanf(STDIN, '%d', $N);
$highestA = 0;
$lowestScore = 0;
//O(N)
for($i=0; $i<$N; $i++){
    list($A, $B) = fscanf(STDIN,'%d %d\n');
    if ($highestA < $A){
        $highestA = $A;
        $lowestScore = $B;
    }
}

echo $highestA + $lowestScore;

Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    def build(self, lis):
        self.value = lis
        for i, x in enumerate(lis):
            self.add(i+1, x)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
    
    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += i & -i
    
    def get_sum(self, i, j):
        return self.sum(j) - self.sum(i)


def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    bit = FenwickTree(n)
    bit.build(a)
    
    for i in range(q):
        a, b, c = map(int, input().split())
        if a == 0:
            bit.add(b+1, c)
        else:
            print(bit.get_sum(b, c))
    
    
if __name__ == "__main__":
    main()

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

res = []
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            s = i**2 + j**2 + k**2 + i*j + j*k + k*i
            res.append(s)

from collections import Counter
count = Counter(res)

for l in range(1,n+1):
    print(count[l])

Measured memory_bytes: 49484
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, k;
int a[N];
bool vis[N];

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int take = min(k, 200000LL);
	k -= take;
	int cur = 1;
	while(take > 0)
	{
		cur = a[cur];
		take--;
	}
	if(k == 0)
	{
		cout << cur;
		return 0;
	}
	int len = 0;
	while(!vis[cur])
	{
		vis[cur] = 1;
		len++;
		cur = a[cur];
	}
	k %= len;
	while(k > 0)
	{
		cur = a[cur];
		k--;
	}
	cout << cur;
	return 0;
}

Measured memory_bytes: 5412
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        char x; cin>>x;
        if(isupper(x)) cout<<'A';
        else cout<<'a';
    }   
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI s(N); rep(i, 0, N) cin >> s[i];
sort(ALL(s));
int sum = accumulate(ALL(s), 0);
if (all_of(ALL(s), [](int i){return i % 10 == 0;})){
    cout << "0\n";
    return 0;
}

rep(i, 0, N)
    if (sum % 10) {
        cout << sum << endl;
        return 0;
    }
    else if (s[i] % 10) sum -= s[i];

cout << sum << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <array>

using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()
#define bootstrap ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);


void solve() {
    // DP
    int num;
    cin >> num;
    if (num < 3) {
        cout << 0 << endl;
        return;
    }
    long mod = 1000000007;
    array<long, 2000> dp;
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    for(int i = 3; i <= num ; i ++) {
        dp[i] = + 1;
        for (int j = 3; j <= i - 3; ++j) {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
        //cout <<dp[i]  << endl;
    }
    cout << dp[num];;
}

int main() {
    bootstrap
    solve();
}


Measured memory_bytes: 3656
s = input()
 
posA = 0
posZ = 0
 
for i in range(len(s)):
  if s[i] == "A":
    posA = i
    break
for j in range(len(s)):
  if s[-j-1] == "Z":
    posZ = len(s) - 1 - j
    break
 
print(posZ - posA + 1)

Measured memory_bytes: 9100
T=int(input())

X=[]
for _ in range(T):
    N,A,B,C,D=map(int,input().split())

    M={0:0,1:D}
    S={2:A,3:B,5:C}
    
    def f(N):
        if N in M:
            return M[N]
        
        R=D*N
        for k in S:
            p,q=N//k*k,(N+k-1)//k*k
            R=min(R,
                  D*abs(N-p)+S[k]+f(p//k),
                  D*abs(N-q)+S[k]+f(q//k)
                  )

        M[N]=R
        return R

    X.append(f(N))
print("\n".join(map(str,X)))


Measured memory_bytes: 94796
N=int(input())
C=input()
NR=0
NW=0
ans=0
for i in range(N):
  if C[i]=="W":
    NW+=1
  else:
    NR+=1
if NW==N or NR==N:
  print(0)
else:
  for i in range(NR):
    if C[i]=="W":
      ans+=1
  print(ans)

Measured memory_bytes: 9280
fun main(args: Array<String>) {
    val (A, B) = listOfInt()
    val a1 = Math.floor(A / 0.08).toInt()
    val b1 = Math.floor(B / 0.1).toInt()
    val s: Int
    val e: Int
    if (a1 < b1) {
        s = a1 - 1; e = b1 + 1
    } else {
        s = b1 - 1; e = a1 + 1
    }
    for (n in s .. e) {
        val t1 = Math.floor(n.toDouble() * 0.08).toInt()
        val t2 = Math.floor(n.toDouble() * 0.1 ).toInt()
        if (t1 == A && t2 == B) {
            println(n)
            return
        }
    }
    println(-1)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


Measured memory_bytes: 37924
#include <bits/stdc++.h>
using namespace std; 
const int INF = 1<<29;


int N, K;
vector<int> G[5000];
bool taxi[5000];
int d[5000][5001];
int c[5000];
int r[5000];
priority_queue<int, vector<int>, greater<int> > que;

int main(){
    scanf("%d%d", &N, &K);
    for(int x = 0; x < N; x++){
        scanf("%d%d", c+x, r+x);
    }
    fill(taxi, taxi+5000, false);
    for(int x = 0; x < K; x++){
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int x = 0; x < N; x++){
        fill(d[x], d[x]+5001, INF);
    }
    d[0][r[0]] = c[0];
    que.push(0);
    while(!que.empty()){
        int s = que.top(); que.pop();
        for(int i = 0; i < G[s].size(); i++){
            int e = G[s][i];
            bool updated = false;
            for(int l = 1; l <= 5000; l++){
                if(d[s][l] < d[e][l-1]){
                    updated = true;
                    d[e][l-1] = d[s][l];
                }
                if(d[s][l] + c[e] < d[e][r[e]]){
                    updated = true;
                    d[e][r[e]] = d[s][l] + c[e];
                }
            }
            if(updated) que.push(e);
        }
    }
    int ret = INF;
    for(int x = 0; x <= 5000; x++){
        ret = min(ret, d[N-1][x]);
    }
    printf("%d\n", ret);
    return 0;
}

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

using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;
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; }

const long long INF = 1LL<<60;
const int MOD = 1000000007;
int n;
ll a[3010];
ll dp[3010][3010]={0};

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

    for (int i = n-1; i >= 0; --i)
    {
        for (int j = i; j < n; ++j)
        {
            if((n-i-j-1)%2==0){
                dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1] + a[j]);
            }else{
                dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
            }
        }
    }

cout << dp[0][n-1];

return 0;
}




Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
constexpr ll INF = static_cast<ll>(1e18);

ll nc2(int n){
	return (n*(n-1)/2);
}

int main(){
  ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	ci2(a,b);
	ll ans=0;
	if(a>=2){
		ans+=nc2(a);
	}
	if(b>=2){
		ans+=nc2(b);
	}
	co(ans);
}


Measured memory_bytes: 256