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

int main()
{
  long long n, ans = 1, l = 1e18;
  cin >> n;
  for(int i = 0; i < n; ++i)
  {
    long long temp;
    cin >> temp;
    if(temp == 0){
      cout << 0 << endl;
      return 0;
    }
    if(ans < 0 || l/ans < temp)
    {
      ans = -1;
    }
    else ans *= temp;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3648
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    L = LI()
    ans = 0

    for i in range(0, N-2):
        for j in range(i+1, N-1):
            for k in range(j+1,N):
                if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                    LS = [L[i],L[j],L[k]]
                    if 2*max(LS) < L[i]+L[j]+L[k] :
                        ans += 1

    
    print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
int sum =1;
int i =1;
while(i<n)
	{
		while(i<n && s[i]==s[i-1]) i++;
		if(i<n) sum++;
		i++;
	}
   cout<<sum;
   return 0;
   
}


Measured memory_bytes: 512
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W, N] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    b_list = []
    b_set = set([])
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]) - 1, int(input_raw[1]) - 1]
        #b_list.append((a, b))
        b_set.add((a, b))

    black_count = {}
    for i in range(10):
        black_count[i] = 0



    already_set = set([])
    for m in b_set:
        for x in range(0, -3, -1):
            for y in range(0, -3, -1):
                square_upper_left_x = m[1] + x
                square_upper_left_y = m[0] + y
                if ((square_upper_left_y, square_upper_left_x) not in already_set and
                    square_upper_left_x + 2 < W and
                    square_upper_left_y + 2 < H and
                    square_upper_left_x >= 0 and
                    square_upper_left_y >= 0):
                        already_set.add((square_upper_left_y, square_upper_left_x))
                        count = 0
                        for i in range(3):
                            for j in range(3):
                                if (square_upper_left_y + j, square_upper_left_x + i) in b_set:
                                    count += 1
                        black_count[count] += 1
    s = 0L
    for i in range(1, 10):
        s += black_count[i]
    print (H -2) * (W - 2) - s
    for i in range(1, 10):
        print black_count[i]




if __name__ == '__main__':
    main()


Measured memory_bytes: 144156
import sys

[n] = [int(x) for x in sys.stdin.readline().split(" ")]

ais = [int(h) for h in sys.stdin.readline().split(" ")]

a_is = sorted([(i + 1, a) for i, a in enumerate(ais)], key=lambda ai: ai[1])

result = [str(i) for i, a in a_is]

print(" ".join(result))


Measured memory_bytes: 25280
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int NMAX = 1e5;

int n;
vector<int> graph[NMAX + 5];

int leafs[NMAX + 5];
int dp[NMAX + 5];

void dfs(int nod,int tata){
	bool have = false;
	
	if(graph[nod].size() == 1 && graph[nod][0] == tata){
		dp[nod] = 1;
		leafs[nod] = 1;
		return;
	}
	
	for(auto it:graph[nod]){
		if(it == tata){
			continue;
		}
		dfs(it,nod);
		leafs[nod] += leafs[it];
		dp[nod] += dp[it];
		have |= (leafs[it] == 1);
	}
	
	dp[nod] -= (have && graph[nod].size() != 1 + (tata != 0));
}

int main(){
	
	scanf("%d",&n);
	
	for(int i = 1;i < n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x++;y++;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	for(int i = 1;i <= n;i++){
		if(graph[i].size() > 2){
			dfs(i,0);
			printf("%d",dp[i]);
			return 0;
		}
	}
	
	printf("%d",1);
	
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
#define eps 1e-14;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a = vector<int>();
    for (int i = 0; i < 3 * n; i++) {
        int k;
        scanf("%d", &k);
        a.push_back(k);
    }
    
    sort(a.begin(), a.end());
    long sum = 0;
    int j = a.size() - 2;
    for (int i = 0; i < n; i++) {
        sum += a[j];
        j -= 2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    ll n;
    cin >> n;
    ll now = 0;
    vector<tuple<ll, ll, ll>> work(n);
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        work[i] = make_tuple(b, a, i);
    }
    sort(work.begin(), work.end());
    bool ok = true;
    for(auto itr = work.begin(); itr != work.end(); itr++){
        now += get<1>(*itr);
        if(now > get<0>(*itr)) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
using namespace std;

void updateRank(int *a,int in){
    int tmp;
    for(int ii=0;ii<3;ii++){
        if(a[ii] < in){            
            tmp = a[ii];
            a[ii] = in;
            
            for(int jj=ii+1;jj<3;jj++){
                int tmp2;
                tmp2 = a[jj];
                a[jj] = tmp;
                tmp = tmp2;
            }
            break;
        }
    }
}
int main(){
    
    int out[3];
    for(int ii=0;ii<10;ii++){
        int in;
        cin >> in;
        updateRank(out,in);
    }
    
    for(int ii=0;ii<3;ii++){
        cout << out[ii] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%lld%lld", &a, &b)
#define getIII(a,b,c) scanf("%lld%lld%lld", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
pll m[200005];
ll x[200005],h[200005],bit[200005];
int n;
int lowbit(int x){
        return x&(-x);
}
ll query(int x){
        ll ans=0;
        while(x>0){
                ans+=bit[x];
                x-=lowbit(x);
        }
        return ans;
}
void add(int x,ll v){
        while(x<=n){
                bit[x]+=v;
                x+=lowbit(x);
        }
}
int main(){
        ll d,a;
        while(~scanf("%d%lld%lld",&n,&d,&a)){
                F(i,0,200005) bit[i]=0;
                F(i,0,n){
                        ll x1,h1;
                        getII(x1,h1);
                        m[i].first=x1;
                        m[i].second=h1;
                }
                sort(m,m+n);
                F(i,0,n) x[i]=m[i].first,h[i]=m[i].second;
                F(i,1,n){
//                      printf("%d\n",h[i]-h[i-1]);
                        add(i,h[i]-h[i-1]);
                }
//              F(i,0,n) printf("%lld ",query(i)+h[0]);
//              puts("");
                ll ans=0;
                F(i,0,n){
                        int H=query(i)+h[0];
                        if(i==0) H=h[0];
                        if(H<=0) continue;
                        ll times=H/a+(H%a!=0);
                        ans+=times;
                        ll atk=times*a;
                        int j=upper_bound(x,x+n,x[i]+2*d)-x;
//                      printf("i:%d j:%d\n",i,j);
                        if(i!=0) add(i,-atk);
                        else h[0]-=atk;
                        add(j,atk);
//                      F(j,0,n) printf("%lld ",query(j)+h[0]);
//                      puts("");
                }
                printf("%lld\n",ans);
        }
}

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

int main()
{
    int n,ans=0;
  cin >> n;
  int a[n+1][3],dp[n+1][3]={0};

  for(int i=0;i<n;i++){
    cin>>a[i][0];
    cin>>a[i][1];
    cin>>a[i][2];
  }
   dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
   for(int i=1;i<n;i++){
     for(int j=0;j<3;j++){
        dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
     }
  }
    ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 2560
package main

import (
	"fmt"
)

func main() {
	var A, B, X int
	fmt.Scan(&A, &B, &X)
	if A > X {
		fmt.Println("NO")
	} else if A+B > X {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

int main(){
    int n,m,c[20],dp[50001],i=0,j=0;
    cin >> n >> m;
    for(i;i<m;i++){
        cin >> c[i];
    }
    sort(c,c+m);
    for(i=0;i<=n;i++){
        dp[i] = 100000;
    }
    dp[0]=0;
    for(i=0;i<m;i++){
        dp[c[i]]=1;
    }
    for(i=1;i<n+1;i++){
        for(j=0;j<m;j++){
            if(c[j]>=i) break;
            dp[i]=min(dp[i],dp[i-c[j]]+1);
        }
    }
    cout<< dp[n] << endl;
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	llong n;
	cin>>n;
	
	if(n<2 or n%2){
		cout<<0<<endl;
		return 0;
	}
	
	llong num=10;
	llong sum=0;
	while(num<=n){
		sum+=floor((long double)n/num);
		num*=5;
	}
	
	cout<<sum<<endl;
}


Measured memory_bytes: 256
//written by libra9z
#define LOCAL_TIME
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,int> plli;
typedef pair <int,pii> pipii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector <vector<int> > mat;
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rRep(i,a,b) for (int i=(a);i>=b;i--)
#define repit(it,a) for ((__typeof(a.begin())) it=a.begin();it!=a.end();it++)
#define repx(x,a) for (auto x:a)
#define pb push_back
#define mp make_pair()
#define eb emplace_back
#define X first
#define Y second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl
#define Debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")\n"
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n"
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define get1(x,a) x>>a
#define get2(x,a,b) x>>a>>b
#define get3(x,a,b,c) x>>a>>b>>c
#define getn(x,n,v) rep(i,n) x>>v[i]
#define put1(x,a) x<<a
#define put2(x,a,b) x<<a<<" "<<b
#define put3(x,a,b,c) x<<a<<" "<<b<<" "<<c
#define putn(x,n,v) rep(i,n) x<<v[i]<<" ";
#define eaq(n,x) __typeof(x) n=x;
#define RET(p,x) return p<<x<<endl,0;
const ll h1=999999937;
const ll h2=1000000009;
const int inf=2e9;
const ll mod=1000000007;
const int dx[]={1,0,-1,0,1,0,-1,0};
const int dy[]={0,1,0,-1,1,0,-1,0};
const double pi=3.141592653589793;
const bool multitests=false,alotoftests=false;
ifstream fin("input.txt");ofstream fout("output.txt");
stringstream sinout;
char c[4];
string s="+-";
int val(int x,int y,char c)
{
	if (c=='+') return x+y;
	if (c=='-') return x-y;
	return -1;
}
int value(string x)
{
	int a[4]={x[0]-'0',x[2]-'0',x[4]-'0',x[6]-'0'};
	char ope[3]={x[1],x[3],x[5]};
	int ans=val(a[0],a[1],ope[0]);
	ans=val(ans,a[2],ope[1]);
	ans=val(ans,a[3],ope[2]);
	return ans;
}
bool solve(int __test)
{
	char c[4];
	cin>>c[0]>>c[1]>>c[2]>>c[3];
	for (auto x:s)
	{
		for (auto y:s)
		{
			for (auto z:s)
			{
				string t="";
				t+=c[0];
				t+=x;
				t+=c[1];
				t+=y;
				t+=c[2];
				t+=z;
				t+=c[3];
				if (value(t)==7)
				{
					cout<<t<<"=7\n";
					return false;
				}
			}
		}
	}
	return false;
}
signed main()
{
	int __tests,__test=1;
	(multitests==true)?((alotoftests==false)?scanf("%d",&__tests):__tests=inf):__tests=1;
	for (;(alotoftests==true && multitests==true)?(!solve(__test)):(__test<=__tests);++__test)
	{
		if (!(multitests==true && alotoftests==true))
		{
			solve(__test);
		}
	}
	#ifdef LOCAL_TIME
	eprintf("\n\nSystem Time : %d ms",clock());
	#endif
	fin.close();fout.close();
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int x,y,z; scanf("%d%d%d",&x,&y,&z);
	int n=x+y+z;
	vector<lint> a(n),b(n),c(n);
	rep(i,n) scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);

	{
		vector<tuple<lint,lint,lint>> t(n);
		rep(i,n) t[i]={a[i],b[i],c[i]};
		sort(t.begin(),t.end(),[&](const auto& x,const auto& y){
			return get<0>(x)-get<1>(x)<get<0>(y)-get<1>(y);
		});
		rep(i,n) tie(a[i],b[i],c[i])=t[i];
	}

	vector<lint> res1(n,-INF);
	lint sum=0;
	priority_queue<lint> Q;
	rep(i,y){
		sum+=b[i];
		Q.emplace(c[i]-b[i]);
	}
	res1[y-1]=sum;
	for(int i=y;i<y+z;i++){
		sum+=b[i];
		Q.emplace(c[i]-b[i]);
		sum+=Q.top(); Q.pop();
		res1[i]=sum;
	}

	vector<lint> res2(n,-INF);
	sum=0;
	Q=priority_queue<lint>();
	for(int i=n-1;i>=n-x;i--){
		sum+=a[i];
		Q.emplace(c[i]-a[i]);
	}
	res2[n-x]=sum;
	for(int i=n-x-1;i>=n-x-z;i--){
		sum+=a[i];
		Q.emplace(c[i]-a[i]);
		sum+=Q.top(); Q.pop();
		res2[i]=sum;
	}

	lint ans=-INF;
	rep(i,n-1) ans=max(ans,res1[i]+res2[i+1]);
	printf("%lld\n",ans);

	return 0;
}


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

int main(){
 int N;
 cin >> N;
 
 int cnt = 0;
 int P[N];
 for(int i=0; i<N; i++){
  int p[3];
  cin >> p[0] >> p[1] >> p[2];

  sort(p, p+3);

  P[i] = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
 }

 for(int I=0; I<N; I++){
  for(int i=I+1; i<N; i++){
   if(P[i]==P[I]){
    cnt++;
    P[i] = cnt;
   }
  }
 }

 cout << cnt << endl;

 return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    ll n,a[5];
    cin >> n;
    ll m = 100000000000000000LL;
    rep(i,0,5){
        cin >> a[i];
        m = min(a[i],m);
    }
    if(n <= m) cout << 5 << endl;
    else if(n%m != 0) cout << n/m+5<< endl;
    else cout << n/m +4 << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#define N 44

int Fib[N];

void fib(int n){
  int i;
  Fib[0] = 1;
  Fib[1] = 1;
  for(i=2; i<=n; i++) Fib[i] = Fib[i-1] + Fib[i-2];
}

int main(){
  int n;

  scanf("%d",&n);
  fib(n);
  printf("%d\n",Fib[n]);

  return 0;
}

Measured memory_bytes: 2748
#include<stdio.h>
int main(void){
    int r;
    scanf("%d",&r);
    char str[100];
    scanf("%s",str);
    //printf("%s\n",str);
    int flag = 1;
    for(int i=0;i<r/2;i++){
        if(str[i]!=str[i+r/2]){
            flag = 0;
        }
    }
    if(flag==0||r%2==1){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=[[]for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    s[a-1].append(b-1)
k=[-1]*n
def dfs(v):
    if k[v]!=-1:
        return k[v]
    k[v]=r=max(dfs(q)for q in s[v])+1 if s[v] else 0
    return r
print(max(dfs(t)for t in range(n)))

Measured memory_bytes: 106648
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, x;
int a[200];
signed main() {
	cin >> n >> x;
	int t = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		t += a[i];
		if (t > x) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << n + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,sum;
    double s;
    while(scanf("%d %d",&a,&b)!=EOF)
	{
        s=(a+b)/2.0;
        sum=round(s);
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int p;
   scanf("%d",&p);
   if(p%10==2||p%10==4||p%10==5||p%10==7||p%10==9){
      printf("hon");
   }else if(p%10==0||p%10==1||p%10==6||p%10==8){
      printf("pon");
   }else if(p%10==3){
      printf("bon");
   }

   return 0;
}

Measured memory_bytes: 1692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			long ans = 0;
			for (int i = 1; i <= n; i++) {
				if (i % 2 == 0) continue;
				int count = 0;

				for (int j = 1; j <= i; j++) {
					if (i % j == 0) count++;
				}

				if (count == 8) ans++;
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    bool possible = true;
    vector<vector<int>> v(n);
    vector<int> ret(n * n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        v[i] = {a, i + 1};
        if (ret[a] != 0)possible = false;
        ret[a] = i + 1;
    }
    sort(v.begin(), v.end());

    vector<int> count(n + 1);
    for (int i = 0; i < n; i++)count[i + 1] = i;
    vector<int> extra;

    int index = 0;
    for (int i = 0; i < n * n; i++) {
        if (ret[i] != 0) {
            if (count[ret[i]] != 0)possible = false;
            for (int j = 0; j < n - ret[i]; j++)extra.push_back(ret[i]);
            continue;
        }
        while (index < n && count[v[index][1]] == 0) index++;
        if (index < n) ret[i] = v[index][1], count[v[index][1]]--;
        else {
            if (extra.empty())possible = false;
            else ret[i] = extra.back(), extra.pop_back();
        }
    }

    if (possible) {
        cout << "Yes" << endl;
        for (int i = 0; i < n * n; i++) {
            if (i > 0)cout << " ";
            cout << ret[i];
        }
        cout << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i = 1; i <= (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

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

  int k; cin >> k;

  ll ans = 0;
  rep(i, k) {
    rep(j, k) {
      rep(m, k) {
	ans += gcd(i, gcd(j, m));
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pp pair<ll,ll>
#define fore(i,n) for(ll i=0;i<n;i++)
#define vi vector<ll>
using namespace std;
const ll mod=998244353;
ll power(ll a,ll b)
{
if(b==0)
return 1;
else if(b==1)
{
return a;
}
else if(b&1)
{
return (a%mod * power((a%mod * a%mod)%mod,b/2)%mod)%mod;
}
else
{
return power((a%mod * a%mod)%mod,b/2)%mod;
}
}
 
void solve()
{
    int n;
    cin>>n;
   map<string,int> mp;
   string s;
   for(int i=0;i<n;i++)
   {
       cin>>s;
       mp[s]++;
   }
   cout<<"AC"<<" x "<<mp["AC"]<<endl;
   cout<<"WA"<<" x "<<mp["WA"]<<endl;
   cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
   cout<<"RE"<<" x "<<mp["RE"]<<endl;

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

  
solve();
 
}

Measured memory_bytes: 3576
#include <stdio.h>
#define MAX 200000
typedef long long l;

int L[MAX/2+2], R[MAX/2+2];

l merge(int A[], int n, int left, int mid, int right){
	int i, j, k;
	l cnt=0;
	int n1 = mid - left;
	int n2 = right - mid;
	
	for(i = 0; i < n1; i++)L[i] = A[left+i];
	for(i = 0; i < n2; i++)R[i] = A[mid+i];
	
	L[n1] = 2000000000, R[n2] = 2000000000;
	i = j = 0;
	for(k = left; k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}


l mergesort(int A[], int n, int left, int right){
	int mid;
	l v1, v2, v3;
	if(left+1 < right){
		mid = (left + right) / 2;
		v1 = mergesort(A, n, left, mid);
		v2 = mergesort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1+v2+v3;
	}
	else return 0;
}

int main(void){
	int A[MAX], n, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)scanf("%d", &A[i]);
	
	l ans = mergesort(A, n, 0, n);
	printf("%lld\n", ans);
	
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    int u[n],l[n];
    vector<pair<int,int>> v;
    rep(i,n){
        char c;
        cin>>c;
        u[i]=(c=='y');
        cin>>l[i];
        if(u[i])v.emplace_back(l[i],i);
    }
    vector<int> used(n);
    sort(v.begin(),v.end());
    int ans=0;
    for(auto p : v){
        if(used[p.second])continue;
        ++ans;
        for(int i = p.second; i>=0;--i){
            if(!u[i]&&l[i]>=p.first)break;
            used[i]=true;
        }
        for(int i = p.second; i<n;++i){
            if(!u[i]&&l[i]>=p.first)break;
            used[i]=true;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int x;
    cin >> x;
    string week;

    switch(x % 7){
        case 0: week = "thu"; break;
        case 1: week = "fri"; break;
        case 2: week = "sat"; break;
        case 3: week = "sun"; break;
        case 4: week = "mon"; break;
        case 5: week = "tue"; break;
        default: week = "wed"; break;
    }
    cout << week << endl;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  ll ans = 0;
  for (int i=0; i<n; i++) {
    if ((i+1)%2 && a[i]%2) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
S=input()
K=int(input())
l=len(S)
a=0
s=S[0]
b,c=-1,-1
for i in range(1,l):
    if s!=S[i]:
        b=i
        a+=i//2
        break
s=S[-1]
if b!=-1:
    for i in range(l-2,-1,-1):
        if s!=S[i]:
            c=i
            a+=(l-i-1)//2
            break
if b==-1:
    print(l*K//2)
else:
    t=1
    s=S[b]
    for i in range(b+1,c+1):
        if S[i]==s:
            t+=1
        else:
            a+=t//2*K
            t=1
            s=S[i]
    a+=t//2*K
    if S[0]==S[-1]:
        a+=(b+l-c-1)//2*(K-1)
    else:
        a+=b//2*(K-1)
        a+=(l-i-1)//2*(K-1)
    print(a)

Measured memory_bytes: 3064
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	
    	String S=sc.next();
    	
    	if(S.contains("9")) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    }
}


Measured memory_bytes: 21972
import numpy as np
import heapq as hq
N = int(input())
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])

Profit = []
for i in range(1,2**10): #営業時間帯についてbit全探索
    Open = np.array([int(x) for x in format(i, '010b')]).T #2進数を縦ベクトルに変換
    c = np.dot(F, Open) #店別に被る時間帯の個数をベクトルとして算出
    hq.heappush(Profit, -sum(P[i, c[i]] for i in range(N))) #-1倍した利益をProfitにpush。
print(-Profit[0]) #heapから最小値を取得
        

Measured memory_bytes: 27220
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  itn n,a[1200000],b[1000000]={};
  itn q[10000000];
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  for(int i=n-1;i>=0;i--){
    if(a[i]!=a[i+1])
    q[i]=b[i]+q[i+1];
    else q[i]=q[i+1];
  }
  for(int i=1;i<=n;i++){
    cout<<b[i]<<"\n";
  }
}

Measured memory_bytes: 13044
#include <cstdio>
using namespace std;
typedef long long ll;
int N, A[100001];
int main() {
  scanf("%d", &N);
  ll ans = 0LL;
  for(int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    ans += A[i];
  }
  for(int i = 1; i <= N; ++i) {
    if(i%2 == 0) ans -= 2*A[i];
  }
  printf("%ld", ans);
  for(int i = 2; i <= N; ++i) {
    ans = 2*A[i-1]-ans;
    printf(" %ld", ans);
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    vector<ll> idx;
    ll n = len(s);
    rep(i, n - 1) {
        if ((s[i] == 'R') && (s[i + 1] == 'L')) {
            idx.push_back(i);
        }
    }
    vector<ll> ans(n, 0);
    rep(i, n) {
        auto it = lower_bound(all(idx), i);
        if (s[i] == 'R') {
            ll d = *it - i;
            if (d % 2 == 0) ans[*it]++;
            else ans[*it + 1]++;
        }
        else {
            it--;
            ll d = i - *it;
            if (d % 2 == 0) ans[*it]++;
            else ans[*it + 1]++;
        }
    }
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


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

using fint64 = int_fast64_t;
struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
Combination com(MOD);
int main() {
	int k; cin >> k;
	string _s; cin >> _s;
	int s = _s.size();
	int n = k + s;
	mint ans = 0;
	mint _25 = 25, _26 = 26;
	for(int i = 1; n - i - (s - 1) >= 0; ++i) {
		ans += _25.pow(n - i - (s - 1)) * _26.pow(i - 1) * com.C(n - i, s - 1);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 122444
#include <iostream>
using namespace std;
 
int round(double);
 
int main(){
 
	int N;
	cin >> N;
	int n;
	int A=0,B=0;
 
	for(int i=0; i<N; i++){
		cin >> n;
		A += n*n;
		B += n;
	}
 
	double x = (double)B/N;
 
//	cout << x << endl;
//	cout << round(x) << endl;
 
	int modify = round(x);
	
	cout << N*modify*modify - 2* modify * B + A << endl;
 
	return 0;
}
 
int round(double x){
	double fraction = x - (int)x;
 
	if(fraction >= 0.5)
		return (int)x + 1;
	else
		return (int)x;
}	


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
int g_[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int N;
        scanf("%d",&N);
        for(int i=1;i<=N;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {g_[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;g_[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {g_[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;g_[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",g_[i][j]);
                else printf("%d\n",g_[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

if sum(A) < x:
    print(N-1)
    exit()

A = [1] + A
ans = 0
while A[-1] <= x:
    x -= A[-1]
    A.pop()
    ans += 1
print(ans)

Measured memory_bytes: 9080
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
ll INF = 1LL << 60;
const ll sqrtN = 512; //* 512*512=262144 > 10^5

//* reference: https://kujira16.hateblo.jp/entry/2016/12/15/000000
//* Range Sum Query (RSQ) implemented using sqrt decomposition
struct RSQ{ 
    ll N, K; //* N length of data, K number of buckets
    vll data;
    vll bucketSum;
    //* allocate memory with zeros
    void init(ll n){
        N = n;
        K = (n + sqrtN - 1) / sqrtN; //* number of buckets = ceil(n/sqrtN)
        data.assign(K * sqrtN, 0);
        bucketSum.assign(K, 0);
    }
    //* constructor
    RSQ(ll n){ init(n);}
    //* constructor with init vector data
    RSQ(ll n, vll &a){
        init(n);
        REP(i, n){
            data[i] = a[i];
        }
        REP(k, K){
            ll sum = 0;
            for(ll j = k * sqrtN; j < (k + 1)* sqrtN; j++){
                sum += data[j];
            }
            bucketSum[k] = sum;
        }
    }
    //* update (add(i, x) -> a[i]+= x)
    void add(ll i, ll x){
        ll k = i / sqrtN; //* corresponding bucket
        data[i] += x;
        ll sum = 0;
        for(ll j = k * sqrtN ; j < (k + 1)*sqrtN; j ++){
            sum += data[j];
        }
        bucketSum[k] = sum;
    }
    //* getSum(s, t)-> return a[s]+a[s+1]+...+a[t-1]
    //* [x, y)
    ll getSum(ll x, ll y){
        ll sum = 0;
        REP(k, K){
            ll l= k * sqrtN, r = (k+1) * sqrtN; //* bucket [l, r)
            if(r <= x || y <= l) //* no intersection
                continue;
            if(x <= l && r <= y) {//* [l, r) in [x, y)
                sum += bucketSum[k]; //* use bucket data
            }
            else{ //* has intersection on boundary
                for(ll i = max(l, x); i < min(r, y); i++){
                    sum += data[i];
                }
            }
        }
        return sum;
    }
};

void solveRSQ(){
    ll N, Q;
    cin >> N >> Q;
    RSQ st(N);
    REP(q, Q){
        ll com;
        cin >> com;
        if(com){
            ll x, y;
            cin >> x >> y;
            cout << st.getSum(x-1, y)<<endl;
        }
        else{
            ll i, x;
            cin >> i >> x;
            st.add(i-1, x);
        }
    }

}

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


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=a[n/2]-a[n/2-1];
    cout<<ans;
}

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


int main()
{
    long long n,m,i,j,sum=0;
    cin>>n>>m;
    long long assgnmt[m+5];
    for(i=0;i<m;i++)
    {
        cin>>assgnmt[i];
        sum+=assgnmt[i];
    }
    if(m>n)
        cout<<"-1"<<endl;
    if(n-sum < 0)
        cout<<"-1"<<endl;
    else
    {
        cout<<n-sum<<endl;
    }
    

}

Measured memory_bytes: 3660
n,m,k = map(int,input().split())
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = [a]
  B = [b]
  la = 1
  lb = 1
  while a != pre[a]:
    a = pre[a]
    A.append(a)
    la += 1
  while b != pre[b]:
    b = pre[b]
    B.append(b)
    lb += 1
  #print(a,b)
  if a != b:
    if la > lb:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
    else:
      pre[a] = b
      for aa in B:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
root = [10**6 for _ in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n):
  if root[i] < 10**6:
    cnt[root[i]] += 1
    continue
  I = int(i)
  J = [I]
  while I != pre[I]:
    I = pre[I]
    J.append(I)
  for x in J:
    root[x] = I
  cnt[I] += 1
#print(pre)
#print(root)
#print(cnt)
ans = []
for i in range(n):
  ans.append(cnt[root[i]]-num[i])
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

Measured memory_bytes: 111904
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int x = 0;
    int y = 0;

      x = 800 * N;
      y = N / 15 * 200;
      System.out.println(x - y);

  }
}


Measured memory_bytes: 22608
s = input()
k = int(input())
import collections
co = collections.Counter(list(s))
n = len(s)
if len(co.values())==1:
    print(n*k//2)
    exit()
prev = ""
cnt = 0
for i in range(n):
    if s[i] == prev:
        cnt+=1
        prev=""
    else:
        prev=s[i]
bf = 0
af = 0
if s[0] == s[-1]:
    for i in range(n):
        if s[i] ==s[0]:
            bf+=1
        else:break
    for i in range(n):
        if s[-i-1] ==s[-1]:
            af+=1
        else:break
cnt = cnt - (bf//2 + af//2)
print(cnt*k + (bf+af)//2 *(k-1) +bf//2 + af//2)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> r,g,b;
    rep(i,n){
        char s;cin>>s;
        switch(s){
            case 'R':
                r.push_back(i);
                break;
            case 'G':
                g.push_back(i);
                break;
            default:
                b.push_back(i);
                break;
        }
    }
    int rs=r.size(),gs=g.size(),bs=b.size();
    ll res=0;
    rep(i,rs)rep(j,gs){
        int R=r[i],G=g[j];
        if((R+G)%2==0){
            int k=(upper_bound(b.begin(),b.end(),(R+G)/2)-b.begin())-(lower_bound(b.begin(),b.end(),(R+G)/2)-b.begin());
            if(k)res--;
        }
        if(R<G){
            int buf=G-R;
            int k=(upper_bound(b.begin(),b.end(),G+buf)-b.begin())-(lower_bound(b.begin(),b.end(),G+buf)-b.begin());
            if(k)res--;
            k=(upper_bound(b.begin(),b.end(),R-buf)-b.begin())-(lower_bound(b.begin(),b.end(),R-buf)-b.begin());
            if(k)res--;
        }else{
            int buf=R-G;
            int k=(upper_bound(b.begin(),b.end(),R+buf)-b.begin())-(lower_bound(b.begin(),b.end(),R+buf)-b.begin());
            if(k)res--;
            k=(upper_bound(b.begin(),b.end(),G-buf)-b.begin())-(lower_bound(b.begin(),b.end(),G-buf)-b.begin());
            if(k)res--;
        }
        res+=bs;
    }
    cout<<res<<endl;
}

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

template<class T> inline T gcd(T a, T b) {
    if (b == 0) return a;
    return  gcd(b, a % b);
}

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;
    string s, t;
    cin >> s >> t;

    ll ans = 0;
    if (s[0] != t[0]) ans = -1;
    else {
        ll L = (max(N, M) / gcd(N, M)) * min(N, M);

        map<ll, char> tmpS;
        tmpS[0] = s[0];
        for (ll i = 1; i < N; i++)
            tmpS[(L / N) * i] = s[i];

        map<ll, char> tmpT;
        tmpT[0] = t[0];
        for (ll i = 1; i < M; i++)
            tmpT[(L / M) * i] = t[i];

        bool ok = true;
        for (auto i : tmpS) {
            if (tmpT.count(i.first))
                if (tmpT[i.first] != i.second) {
                    ok = false;
                    break ;
                }
        }

        if (ok) ans = L;
        else ans = -1;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }

  vector<P> group;
  for (int i = 0; i < N; i++)
  {
    if (h[i] == 0) {
      group.push_back(P(i, 1));
      continue;
    }
    int cnt = 1;
    int j = i;
    while (h[i] <= h[i + 1] && i < N - 1)
    {
      cnt++;
      i++;
    }
    group.push_back(P(j, cnt));
  }
  
  int ans = 0;
  bool zero = true;
  for (int i = 0; i < group.size(); i++) {
    if (group[i].second == 1 && h[group[i].first] == 0)
    {
      zero = true;
      continue;
    }
    if (zero)
    {
      ans += h[group[i].first + group[i].second - 1];
      zero = false;
    } else {
      ans += h[group[i].first + group[i].second - 1] - h[group[i].first];
    } 
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int len = s.length();
    string init("es");
    string add("s");

    if(s[len - 1]=='s')
    {
        s.append(init);
    }
    else
    {
        s.append(add);
    }
    cout << s << endl;
    return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;

	cout << ( (k == 1) ? 0 : n - k ) << endl;

	return 0;
}


Measured memory_bytes: 256