akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    public static void main(String[] defargs) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[][] gyoretu = new int[n][m];
		int[] beku = new int[n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				gyoretu[i][j] = scanner.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			int b = scanner.nextInt();
			for (int j=0; j<n; j++) {
				beku[j] += gyoretu[j][i]*b;
			}
		}
		for (int C : beku) {
			System.out.println(C);
		}
	}
}



Measured memory_bytes: 40516
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int p[N];
  REP(i, N) {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  REP(i, N) {
    if(p[i] == i) {
      if(i != N - 1) {
        int tmp = p[i];
        p[i] = p[i + 1];
        p[i + 1] = tmp;
      }
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	final static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	static String line = "";
	static int a = 0;
	static String op = "";
	static int b = 0;

	// TODO ?????????????????????????????????????????????
	public static void main(String[] args) throws Exception {
		boolean qFlag = true;
		syokika();
		while (qFlag) {
			if (op.equals("?")) {
				qFlag = false;
			} else
				switch (op) {
				case ("+"):
					System.out.println(a + b);
					syokika();
					break;
				case ("-"):
					System.out.println(a - b);
					syokika();
					break;
				case ("*"):
					System.out.println(a * b);
					syokika();
					break;
				case ("/"):
					System.out.println(a / b);
					syokika();
					break;
				}
		}
	}

	private static void syokika() throws IOException {
		a = 0;
		op = "";
		b = 0;
		line = br.readLine();
		String[] hikakuStr = line.split("[\\s]+");
		a = Integer.parseInt(hikakuStr[0]);
		op = hikakuStr[1];
		b = Integer.parseInt(hikakuStr[2]);
	}
}

Measured memory_bytes: 24476
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

const ll MAX_N = 55555;
ll prime[MAX_N];	//i番目の素数
bool is_prime[MAX_N + 1];	//is_prime[i]がtrueならばiは素数

							//n以下の素数の数を返す
ll sieve(ll n) {
	ll p = 0;
	REP(i, n + 1) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	FOR(i, 2, n + 1) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main() {
	ll n;

	cin >> n;

	sieve(55555);

	ll count = 0;
	ll a = 0;
	vector<ll> ans;

	while (count < n) {
		if (prime[a] % 5 == 1) {
			count++;
			ans.push_back(prime[a]);
		}
		a++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

/*void swap(int a,int b)
{
  int tmp;
  tmp=a;
  a=b;
  b=tmp;
  }*/
void maxHeapify(int i)
{
  int l,r,largest,tmp;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i])largest =l;
  else largest =i;
  if(r<=H&&A[r]>A[largest])largest=r;
  if(largest!=i)
    {
      tmp=A[i];
      A[i]=A[largest];
      A[largest]=tmp;
      maxHeapify(largest);
    }
}

int extract()
{
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}
void increaseKey(int i,int key)
{
  int tmp;
  if(key<A[i])return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i])
    {
      tmp=A[i];
      A[i]=A[i/2];
      A[i/2]=tmp;
      i=i/2;
    }
}
void insert(int key)
{
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main()
{
  int key;
  char com[10];
  while(1)
    {
      scanf("%s",com);
      if(com[0]=='e'&&com[1]=='n')break;
      if(com[0]=='i')
	{
	  scanf("%d",&key);
	  insert(key);
	}
      else
	{
	  printf("%d\n",extract());
	}
    }
  return 0;
}



Measured memory_bytes: 5648
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

# N = int(sys.stdin.readline())
# P = [int(sys.stdin.readline()) for _ in range(N)]
#
# P = np.array(P, dtype=int)
#
# ans = 0
# while np.all(P % 10 == 0):
#     P //= 10
#     ans += 1
# print(ans)

R, G, B, N = list(map(int, sys.stdin.readline().split()))

ans = 0
for r in range(0, N + 1, R):
    for g in range(0, N + 1 - r, G):
        b = N - r - g
        if b == 0 or b > 0 and b % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 13664
from collections import deque
N,M,P,*L = map(int, open(0).read().split())
INF = 10**9
Els = []
dic = [[] for i in range(N+1)]
rdic = [[] for i in range(N+1)]
for a,b,c in zip(*[iter(L)]*3):
  dic[a].append((b,c-P))
  rdic[b].append((a,c-P))
  Els.append((a,b,-c+P))
ok1 = [False]*(N+1)
ok1[1] = True
q = deque([1])
while q:
  v = q.popleft()
  for p,c in dic[v]:
    if not ok1[p]:
      ok1[p] = True
      q.append(p)

ok2 = [False]*(N+1)
ok2[N] = True
q = deque([N])
while q:
  v = q.popleft()
  for p,c in rdic[v]:
    if not ok2[p]:
      ok2[p] = True
      q.append(p)

ok = [a&b for a,b in zip(ok1,ok2)]

dist = [INF]*(N+1)
dist[1] = 0
cnt = 0
while True:
  end = True
  for a,b,c in Els:
    if ok[a] and ok[b] and dist[a]!=INF and dist[b]>dist[a]+c:
      end = False
      dist[b] = dist[a]+c
  if end:
    print(max(0,-dist[N]))
    break
  cnt += 1
  if cnt>2*M:
    print(-1)
    break

Measured memory_bytes: 48868
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1130;
const int MAX_K = 17;

bool p[MAX_N];
vector<int> vp;

void make_p(){
  REP(i, MAX_N) p[i] = true;
  p[0] = p[1] = false;
  for(int i = 2; i < MAX_N; ++i){
    if(!p[i]) continue;
    vp.push_back(i);
    for(int j = i + i; j < MAX_N; j += i) p[j] = false;
  }
}

int main() {
  make_p();
  int N, K, dp[MAX_N][MAX_K];
  memset(dp, 0, sizeof(dp));
  REP(i, vp.size()){
    int p = vp[i];
    for(int k = MAX_K - 2; k >= 0; --k){
      REP(n, MAX_N){
        if(p + n >= MAX_N) break;
        dp[n + p][k + 1] += dp[n][k];
      }
    }
    dp[p][1] += 1;
  }
  while(cin >>N >>K && K) cout <<dp[N][K] <<endl;
  return 0;
}

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

int n;
ll h, w, ans[10];
map<pll, int> mp;

int main(){
	scanf("%lld%lld%d", &h, &w, &n);
	for(int i = 0, x, y; i < n; i++){
		scanf("%d%d", &x, &y);
		for(int tx = max(1, x - 2); tx <= min(int(h) - 2, x); tx++){
			for(int ty = max(1, y - 2); ty <= min(int(w) - 2, y); ty++){
				mp[{tx, ty}]++;
			}
		}
	}
	for(auto &i : mp) ans[i.second]++;
	ans[0] = (h - 2) * (w - 2);
	for(int i = 1; i < 10; i++) ans[0] -= ans[i];
	for(int i = 0; i < 10; i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int x,n; cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  int ans = -1, d = 1<<30;
  for(int i = -1; i <= 101; i++){
    bool flg = false;
    for(int j: p){
      if(i == j) flg = true;
    }
    if(flg) continue;
    if(d > abs(i-x)){
      d = abs(i-x);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
const int maxn = 63;
int odd[maxn], even[maxn];

int main()
{
    int n;
    ll k;
    scanf("%d%lld", &n, &k);
    for(int i = 0; i < n; i++){
        ll x;
        scanf("%lld", &x);
        for(int j = maxn-1; j >= 0; j--){
            if(x>>j&1)odd[j]++;
            else even[j]++;
        }
    }
    long long ans = 0, val = 0;
    for(int i = maxn-1; i >= 0; i--){
        //printf("i=%d, (%d,%d)\n", i, even[i], odd[i]);
        if(even[i] > odd[i]){
            if(val+(1LL<<i) <= k){
                ans += 1LL*even[i]*(1LL<<i);
                val += 1LL<<i;
            }
            else ans += 1LL*odd[i]*(1LL<<i);
        }
        else ans += 1LL*odd[i]*(1LL<<i);
        //printf("val=%lld\n", val);
    }
    printf("%lld\n", ans);
    return 0;
}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
struct UnionFind {
  vector<ll> data;
  ll num;
  UnionFind(ll size) : data(size, -1) ,num(size){ }
  bool unite(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
	  num--;
    }
    return x != y;
  }
  bool find(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m,k;cin>>n>>m>>k;
  vector<ll>cnt(n,1);
  UnionFind uf(n);
  rep(i,0,m){
    ll a,b;cin>>a>>b;a--;b--;
    cnt[a]++;cnt[b]++;
    uf.unite(a,b);
  }
  rep(i,0,k){
    ll c,d;cin>>c>>d;c--;d--;
    if(uf.find(c,d)){
      cnt[c]++;
      cnt[d]++;
    }
  }
  vector<ll>ret(n);
  rep(i,0,n)ret[i]=uf.size(i)-cnt[i];
  debug(ret,n);
  return 0;
}

Measured memory_bytes: 3200
import java.util.*;
import java.math.*;
public class Main{
	static long mod=1000000007;
	static long[] fact;
	static long[] inv;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		fact=new long[n+1];
		fact[0]=1;
		fact[1]=1;
		for(int i=2; i<=n; i++){
			fact[i]=(fact[i-1]*i)%mod;
		}
		inv=new long[n+1];
		inv[n]=pow(fact[n],mod-2);
		for(int i=n-1; i>=0; i--){
			inv[i]=(inv[i+1]*(i+1))%mod;
		}
		int k=sc.nextInt();
		long mod=1000000007;
		long[] a=new long[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextLong();
		}
		Arrays.sort(a);
		long ans=0;
		for(int i=n-1; i>=0; i--){
			ans+=a[i]*comb(i,k-1);
			ans-=a[i]*comb(n-1-i,k-1);
			ans=(ans+mod)%mod;
		}
		System.out.println(ans);
	}
	static long comb(int t,int y){
		if(t<y){
			return 0;
		}
		long re=1;
		re*=fact[t];
		re*=inv[y];
		re%=mod;
		re*=inv[t-y];
		return re%mod;
	}
	static long pow(long p,long q){
		long res=1;
		while(q>0){
			if((q & 1)==1){
				res*=p;
				res%=mod;
			}
			q>>=1;
			p*=p;
			p%=mod;
		}
		return res;
	}
}


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

long search(long A[], long n, long key){
	long i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main(){
	long n, A[10001], q, key, sum = 0;
	cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
	cin >> q;
	for (long i = 0; i < q; i++){
		cin >> key;
		sum += search(A, n, key);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1236
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = str(input())
T = str(input())
leng = len(S)
ans = 0
for i in range(leng):
    if S[i]!=T[i]:
        ans += 1
print(ans)

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

#define MAX 100000

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}
int right(int i) {
    return 2 * i + 1;
}

int main(void) {
    int H;
    int A[MAX + 1] = {};
    
    cin >> H;
    for(int i = 1; i <= H; ++i) cin >> A[i];
    
    for(int i = 1; i <= H; ++i) {
        printf("node %d: key = %d, ", i, A[i]);
        if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
        if(left(i) <= H) printf("left key = %d, ", A[left(i)]);
        if(right(i) <= H) printf("right key = %d, ", A[right(i)]);
        cout << endl;
    }
    
    return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

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

//---------------------------------------------------------------
// 1 <= K <= 5 なので、処理範囲を制限してみる
//---------------------------------------------------------------

string S;
int K;
vector<string> v;

signed main(){
	cin >> S;
	cin >> K;
	
//	cout << S.size() << endl;
	// 部分文字列の作成
	int ee = min(int(S.size() + 1), 6);	// 切り出す文字数　→　５文字までとする
	REP(i, 1, ee) {						
		REP(j, 0, S.size() - i + 1) {	// 切り出す先頭位置
			v.pb(S.substr(j, i));
		}
	}
//	cout << v.size() << endl;
	sort(v.begin(), v.end());			// ソート
//	cout << v.size() << endl;
//	REP(i, 0, v.size()) {
//	    cout << v[i] << endl;
//	}
	int cnt = 0;
	string sv = "";
	REP(i, 0, v.size()) {
		if(v[i] != sv) {
			cnt++;
			sv = v[i];
		}
		if(cnt == K) {
			cout << v[i] << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	
	return 0;
}


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

int main() {
  int a, b;
  double x;
  cin >> a >> b;
  x = (a + b) / 2.0;

  if ( int(x*10) % 10 > 0 ) {
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 2e18
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, K;
llint a[205], b[205];
map<vector<llint>, vector<P>> mp;

llint get(llint l, llint r)
{
	if(l <= 0) return 0;
	llint ret = 0;
	for(int i = 60; i >= 0; i--){
		if( (l&(1LL<<i)) != (r&(1LL<<i)) ){
			if(l > ret) ret += (1LL<<i);
			return ret;
		}
		ret += (l&(1LL<<i));
	}
	return ret;
}
llint count(llint x)
{
	llint ret = 0;
	for(;x;x>>=1) ret += x&1LL;
	return ret;
}

int main(void)
{
	cin >> n >> K;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint lim = inf;
	for(int i = 1; i <= n; i++) lim = min(lim, a[i]);
	
	vector<llint> vec;
	for(int i = 0; i <= min(K, 60LL); i++){
		llint R = (1LL<<i);
		vec.clear();
		for(int j = 1; j <= n; j++) vec.push_back(a[j]%R);
		vec.push_back(-1), vec.push_back(R-1);
		sort(vec.begin(), vec.end());
		vec.erase(unique(vec.begin(), vec.end()), vec.end());
		
		//cout << "i = " << i << endl;
		//for(int j = 0; j < vec.size(); j++) cout << vec[j] << " "; cout << endl;
		
		for(int j = 0; j < vec.size(); j++){
			if(vec[j] >= min(lim, R-1)) continue;
			for(int k = 1; k <= n; k++){
				b[k] = a[k];
				b[k] >>= i;
				if(a[k]%R <= vec[j]) b[k]--;
			}
			
			llint mn = inf;
			for(int k = 1; k <= n; k++){
				mn = min(mn, b[k]);
			}
			vector<llint> sig;
			for(int k = 1; k <= n; k++) sig.push_back(b[k]-mn);
			llint bit = count(get(vec[j]+1, min(lim, vec[j+1])));
			llint rem = K - i - bit;
			
			if(rem < 0) continue;
			mp[sig].push_back(make_pair(b[1] - min(mn, rem), 0));
			mp[sig].push_back(make_pair(b[1], 1));
			
			/*cout << "\tj = " << j << endl;
			cout << "\t";
			for(int k = 0; k < sig.size(); k++) cout << sig[k] << " "; cout << endl;
			cout << "\t" << b[1] << " " << rem << " " << mn << endl;*/
		}
	}
	
	llint ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		sort(it->second.begin(), it->second.end());
		
		/*for(int i = 0; i < it->second.size(); i++){
			cout << it->second[i].first << " " << it->second[i].second << " ";
		}
		cout << endl;*/
		
		llint num = 0, pre;
		for(int i = 0; i < it->second.size(); i++){
			P r = it->second[i];
			if(r.second == 0){
				if(num == 0) pre = r.first;
				num++;
			}
			else{
				num--;
				if(num == 0){
					ans += (r.first - pre + 1) % mod;
					ans %= mod;
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

struct edge{int next,v,w,u;}vs[500001];
int ee=1,S,T;
int h[60001],st[60001];
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline void addedge(int u,int v,int w){vs[++ee].v=v;vs[ee].u=u;vs[ee].next=st[u];vs[ee].w=w;st[u]=ee;}
void insert(int u,int v,int w){addedge(u,v,w);addedge(v,u,0);}
bool bfs(){
    memset(h,-1,sizeof(h));
    queue <int> q;q.push(0);h[0]=1;
    while(!q.empty()){
        int lx=q.front();q.pop();
        for(int i=st[lx];i;i=vs[i].next)
            if(vs[i].w&&h[vs[i].v]==-1){
                q.push(vs[i].v);
                h[vs[i].v]=h[lx]+1;
            }
    }
    return h[T]!=-1;
}
int dfs(int x,int f){
    if(x==T) return f;
    int w,used=0;
    for(int i=st[x];i;i=vs[i].next)
        if(vs[i].w&&h[vs[i].v]==h[x]+1){
            w=dfs(vs[i].v,min(f-used,vs[i].w));
            vs[i].w-=w;vs[i^1].w+=w;
            used+=w;if(used==f)return f;
        }
    if(!used)h[x]=-1;
    return used;
}

char sd[200]; int H,W,ans,sx,sy,ex,ey;
signed main()
{
	H=read(); W=read(); S=0; T=H+W+1;
	for(int i=1;i<=H;i++)
	{
		scanf("%s",sd);
		for(int j=1;j<=strlen(sd);j++)
		{
			if(sd[j-1]=='o')
			{
				addedge(i,j+H,1); addedge(j+H,i,1);
			}
			if(sd[j-1]=='S')
			{
				insert(0,i,inf); insert(0,j+H,inf);
				sx=i; sy=j;
			}
			if(sd[j-1]=='T')
			{
				insert(i,H+W+1,inf); insert(j+H,H+W+1,inf);
				ex=i; ey=j;
			}
		}
	}
	//	if(ex==sx||ey==sy) {printf("-1\n"); return 0;}
	//for(int i=2;i<=ee;i++) printf("%d %d %d\n",vs[i].u,vs[i].v,vs[i].w);
	while(bfs()) ans+=dfs(S,inf);
	if(ans>H*W+100) printf("-1\n");
	else cout << ans << endl; return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int mod = 1000000007;
int a[3];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	ll a = t1 * a1 + t2 * a2;
	ll b = t1 * b1 + t2 * b2;
	if (a < b)
	{
		swap(a, b);
		swap(a1, b1);
		swap(a2, b2);
	}
	ll c = a - b;
	if (c == 0)
	{
		cout << "infinity" << endl;
		return 0;
	}
	if (a1 > b1)
	{
		cout << 0 << endl;
		return 0;
	}
	ll d = t1 * (b1 - a1) / c;
	cout << 2 * d + 1 - (t1 * (b1 - a1) % c == 0) << endl;
	/*
	cout << a << endl;
	cout << b << endl;
	cout << c << endl;
	cout << t1 * (b1 - a1) / c << endl;
	cout << b / c << endl;
	*/
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;

int main() {
  int n,k,x,a,b,sum;
  sum = 0;
  cin >> n >> k;
  rep(i,n) {
    cin >> x;
    a = x-0;
    b = k-x;
    if(a<b) {
      a *= 2;
      sum += a;
    } else {
      b *= 2;
      sum += b;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<int> v;
  int query; cin >> query;

  for (int i = 0; i < query; ++i) {
    int op; cin >> op;
    if (op == 0) {
      int x; cin >> x;
      v.emplace_back(x);
    } else if (op == 1) {
      int p; cin >> p;
      cout << v[p] << '\n';
    } else {
      v.pop_back();
    }
  }

  return 0;
}


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

int main()
{
	string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A'){ cnt++;}
    }
    
    if(cnt==s.length() || cnt==0)
    {
        //cout<<cnt<<endl;
		cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

ans = 0

a = 0
b = 0
c = 0

BB = []
j = 0
for i in range(n) :
    while j < n and A[j] < B[i] :
        j += 1
    BB.append(j)

for i in range(n-1) :
    BB[i+1] += BB[i]

j = 0
for i in range(n) :
    while j < n and B[j] < C[i] :
        j += 1
    if 0 <= j-1 < n :
        ans += BB[j-1]
    
print(ans)


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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

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

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

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


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

    int X;
    cin >> X;

    if (X == 3 || X == 5 || X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  vector<int> v[n];
  int c[n];mem(c);
  while(m--) {
    int x,y;
    cin >> x >> y;
    v[x].pb(y);
    c[y]++;
  }
  queue<int> que;
  rep(i,n) {
    if(!c[i]) que.push(i);
  }
  while(!que.empty()) {
    int x=que.front();que.pop();
    pr(x);
    rep(i,v[x].size()) {
      int y=v[x][i];
      c[y]--;
      if(!c[y]) que.push(y);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1904
#include <string>
#include <iostream>

using namespace std;

string ring(string s,int no,int l){
    string r;
    for (int i=0;i<l;i++){
        r+=s[(no+i)%s.size()];
    }
    return r;
}

int main(){
    string s,p;
    cin>>s>>p;
    int i;
    for (i=0;i<s.size();i++){
        if (p==ring(s,i,p.size())) break;
    }
    if (i<s.size()){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 1184
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	int p;
	int maxp = 0;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> p;
		sum += p;
		maxp = max(maxp, p);
	}
	sum -= maxp / 2;
	cout << sum << endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    reverse(vec.begin(), vec.end());
    for(int i = 0; i < N-1; i++){
        if(vec.at(i) >= vec.at(i+1)) continue;
        else if(vec.at(i) == vec.at(i+1) -1){
            vec.at(i+1)--;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

map<int, int> mp;
int n, ans;

int main(){
//	freopen("input.inp", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		++mp[x];
		if (mp[x] >= x){
			mp[x] = -n;
			ans += x;
		}
	}
	cout << n - ans;
	return 0;
}

Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static string S { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            S = CR.GetText();

            return S[2] == S[3] && S[4] == S[5] ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <utility>
#include <map>
using namespace std;
typedef pair<int, char> P;
P bCards[36];
P sCards[36];
P iCards[36];
void bubbleSort(int n){
    for(int i=0; i<n; ++i){
        int x = bCards[i].first;
        for(int j=n-1; j>i; --j){
            if(bCards[j].first < bCards[j-1].first){
                swap(bCards[j], bCards[j-1]);
            }
        }
    }
}
void selectionSort(int n){
    for(int i=0; i<n; ++i){
        int idx = i;
        for(int j=i+1; j<n; ++j){
            if(sCards[idx].first > sCards[j].first){
                idx = j;
            }
        }
        swap(sCards[i], sCards[idx]);
    }
}
bool isStable(int N){
    for(int i=0; i<N; ++i){
        if(sCards[i] != bCards[i]) return false;
    }
    return true;
}
int main(){
    int N; cin >> N;
    for(int i=0; i<N; ++i){
        string card; cin >> card;
        char suit = card[0]; 
        int num = stoi(card.substr(1));
        iCards[i].second = bCards[i].second = sCards[i].second = suit;
        iCards[i].first = bCards[i].first = sCards[i].first = num;
    }
    bubbleSort(N);
    selectionSort(N);
    for(int i=0; i<N; ++i){
        if(i) cout << " ";
        cout << bCards[i].second << bCards[i].first;
    }
    cout << endl;
    cout << "Stable" << endl;
    for(int i=0; i<N; ++i){
        if(i) cout << " ";
        cout << sCards[i].second << sCards[i].first;
    }
    cout << endl;
    if(isStable(N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;  

    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int n;
int a[N],m[N];

int32_t main()
{
	fast;

	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int x = a[1], par = 1;
	for(int i=2;i<=n;i++)
	{
		if(par)
			x-=a[i];
		else
			x+=a[i];
		par = !par;
	}
	m[1] = x/2;
	for(int i=2;i<=n;i++)
		m[i] = a[i-1]-m[i-1];
	for(int i=1;i<=n;i++)
		cout<<m[i]*2<<" ";
	return 0;
}

Measured memory_bytes: 6272
n = gets.to_i
lists = []
(0..n-1).each do |i|
  inputs = gets.split.map(&:to_i)
  lists << inputs
end
length = 0
(0..n-2).each do |i|
  k = i + 1
  while k < n do
    length += ((lists[i][0] - lists[k][0])**2 + (lists[i][1] - lists[k][1])**2) ** 0.5
    k += 1
  end
end
puts length * 2 / n


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n, m, d[3];
vector< vector< int > > edge;

set< int > nextStep(set< int >& cur) {
	set< int > ret;
	for (int v : cur) for (int u : edge[v]) ret.insert(u);
	return ret;
}

void solve() {
	set< int > target = {n-1};
	for_(i,0,n) {
		set< int > cand[3];
		for_(j,0,3) {
			cand[j] = target;
			for_(t,0,d[j]) cand[j] = nextStep(cand[j]);
		}
		
		for_(v,0,n) {
			bool flag = true;
			for_(j,0,3) flag &= (cand[j].count(v) == 1);
			if (flag) target.insert(v);
		}
		
		if (target.count(0)) {
			cout << i+1 << endl;
			return;
		}
	}
	puts("IMPOSSIBLE");
}

int main() {
	cin >> n >> m;
	for_(i,0,3) cin >> d[i];
	
	edge.assign(n, vector< int >());
	for_(i,0,m) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		edge[v].push_back(u);
	}
	
	solve();
}

Measured memory_bytes: 3196
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

vector<vector<int> > edge;
vector<pii> tree;
v_bool used;
map<pii, int> ans;
int ans_size = -1;

void dfs(int root, int root_color, int parent)
{
    int color = 1;
    if(ans_size < (int)edge[root].size()) {
        ans_size = edge[root].size();
    }

    for(auto e : edge[root]) {
        if(used[e]) { continue; }
        if(parent == e) { continue; }        
        if(color == root_color) { color++; }
        if(root > e) { 
            ans[pii(e, root)] = color;
        } else {
            ans[pii(root, e)] = color;
        }
        dfs(e, color++, root);
    }
    used[root] = true;
}

int main(void)
{
    int n; cin >> n;
    edge.assign(n, v_int());
    used.assign(n, false);

    irep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        tree.push_back(pii(a, b));
    }

    used[0] = true;
    dfs(0, -1, -1);

    cout << ans_size << endl;
    for(auto t : tree) {
        cout << ans[t] << endl;
    }

    return 0;
}
/** atcoder **/


Measured memory_bytes: 15864
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int a,b;
	int c = 0;

	while( cin >> a >> b && a ){
		c++;
		int count = 0;
		if( c > 1 ) cout << endl;
		for( int i = a;i <= b;i++ ){
			if( !(i % 4) ){
				if( !(i % 400) ){count++; cout << i << endl; continue;}
				else if( !(i%100) ) continue;
				cout << i << endl;
				count++;
			}
		}
		if( count == 0 ) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#define M 0

int seg[500000];

int min(int x, int y) {
    return (x < y ? x : y);
}

void init(void) {
    for(int i=0; i<500000; i++)
        seg[i] = M;
}

void update(int i) {
    seg[i] = seg[2*i+1] + seg[2*i+2];
    if(i) update((i-1)/2);
}

int find(int x, int y, int l, int r, int i) {
    if(r<x || y<l) return 0;
    if(x<=l && r<=y) return seg[i];
    return find(x,y,l,(l+r)/2,i*2+1) + find(x,y,(l+r)/2+1,r,i*2+2);
}


int main(void) {
    int n,q;
    scanf("%d%d",&n,&q);
    init();
    for(int i=0; i<q; i++) {
        int c,x,y;
        scanf("%d%d%d",&c,&x,&y);
        if(c) {
            printf("%d\n", find(x,y,0,(1<<18)-1,0));
        } else {
            seg[x+(1<<18)-1] += y;
            update((x+(1<<18)-1-1)/2);
        }
    }
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> v(2*M);
  vector<int> x(N);
    
  for(int i=0;i<2*M;i++){
    cin >> v.at(i);
    x.at(v.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
  cout << x.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	vector<P<int>> a;
	int prev = -1;
	rep(i, n) {
		int b;
		cin >> b;
		if (prev != b) a.push_back(make_pair(b, 1));
		else a[a.size() - 1].second++;
		prev = b;
	}
	int ans = 0;
	rep(i, a.size()) {
		if (a[i].second != 1) {
			ans += a[i].second / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# DP(配るDP)
N = int(input())

dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    a, b, c = map(int, input().split())
    dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + a)
    dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + a)
    dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + b)
    dp[i + 1][2] = max(dp[i + 1][2], dp[i][1] + b)
    dp[i + 1][0] = max(dp[i + 1][0], dp[i][2] + c)
    dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + c)
print(max(dp[N]))


Measured memory_bytes: 22776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
    ll n,l;cin>>n>>l;
    ll a[100010];
    rep(i,0,n)cin>>a[i];
    ll last=-1;
    rep(i,0,n-1){
        if(a[i]+a[i+1]>=l){
            last=i;
            break;
        }
    }
    if(last==-1)cout<<"Impossible"<<endl;
    else{
        cout<<"Possible"<<endl;
        rep(i,0,last)cout<<i+1<<endl;
        for(ll i=n-2;i>=last;i--)cout<<i+1<<endl;
    }
}

    









Measured memory_bytes: 4412
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
int main() {
	int H, W;	cin >> H >> W;
	vector<string> A(H);
	int num = 0;
	for (int i = 0; i < H; ++i) {
		cin >> A[i];
		for (int j = 0; j < W; ++j)if (A[i][j] == '#')++num;
	}
	if (num == H + W - 1)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = (1 << 18) + 50;
const int maxw = 100000;
const int INF = LLONG_MAX/4;


int X,n;
int P[maxn];
int32_t main() {
	FAST
	cin >> X >> n;
	for (int i =0;i<n;i++) {
		int x; cin >> x;
		P[x] = 1;
	}
		
	pi ans = pi(INF,0);
	for (int i = -100;i<200;i++) {
		if (P[i]) continue;
		ans = min(ans,pi(abs(X - i),i));
	}
	
	cout << ans.s;
}









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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};

string s;
string t="AKIHABARA";

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>s;
    bool can=true;
    int now=0;
    if(t.size()<s.size()){
        cout<<"NO"<<endl;
        return 0;
    }
    rep(i,0,t.size()){
        if(t[now]=='A' && t[now+1]==s[i]){
            now++;
        }
        if(t[now]!=s[i])can=false;
        now++;
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll x,y; cin >> x >> y;
    if(abs(x-y) <= 1) {
        cout<<"Brown";
    }
    else {
        cout<<"Alice";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m;
int main() {
    cin >> n >> m;
    vector<int> a(n, 0);
    int total = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        total += a.at(i);
    }

    // cout << total << endl;

    int anslen = (total + 4*m - 1) / (4*m);
    // cout << anslen << endl;

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(a.at(i) >= anslen) ans++;
    }

    if(ans >= m) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import re
while True:
    name,typ=raw_input().split()
    if name=="EndOfInput" and typ=="X":break
    if "_" in name:
        L=name.split("_")
    else:
        L=re.findall("[A-Z][a-z]*",name[0].upper()+name[1:])

    if typ=="D":
        print "_".join(map(lambda s:s.lower(),L))
    elif typ=="U":
        print "".join(map(lambda s:s.capitalize(),L))
    else:
        print L[0].lower()+"".join(map(lambda s:s.capitalize(),L[1:]))

Measured memory_bytes: 4236
#!/usr/bin/env python3
import sys

def solve(S: str):
    from collections import Counter
    c = Counter(S)
    return 2 * min(c["0"], c["1"])

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9508