akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int w, h;
vector<string> data;
vector<vector<string> > str;

string get_large(const string& a, const string& b){
  if(a.size() != b.size())
    return (a.size() > b.size()) ? a : b;
  for(int i=0; i<a.size(); ++i){
    if(a[i] != b[i]) return (a[i] > b[i]) ? a : b;
  }
  return a;
}

string dfs(int i, int j){
  if(!(i>=0 && i<h)) return string();
  if(!(j>=0 && j<w)) return string();
  if(!(data[i][j]>='0' && data[i][j]<='9')) return string();
  if(str[i][j].empty())
    str[i][j] = data[i][j] + get_large(dfs(i+1, j), dfs(i, j+1));
  return str[i][j];
}

string solve(){
  string ans = "0";
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(data[i][j]>='1' && data[i][j]<='9' &&
	 str[i][j].empty()) ans = get_large(ans, dfs(i, j));
    }
  }
  return ans;
}

int main(){
  while(1){
    cin >> w >> h;
    if(!w && !h) break;
    data = vector<string>(h);
    str = vector<vector<string> >(h, vector<string>(w));
    for(int i=0; i<h; ++i) cin >> data[i];
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1352
#include <stdio.h>
int main(){
	int n,h,w;
	int re=0;
	int a[1005];
	int b[1005];
	scanf("%d%d%d",&n,&h,&w);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]>=h&&b[i]>=w){re++;}
	}
	printf("%d",re);
}

Measured memory_bytes: 128
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())
P = {'s':r, 'p':s, 'r':p}
 
mx = r*T.count('s')+s*T.count('p')+p*T.count('r')
if len(T)<k:
    print(mx)
else:
    for i in range(n-k):
        if T[i]==T[i+k]:
            mx -= P[T[i]]
            T[i+k] = '_'
print(mx)

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

int cyandy(int N, int &ans, int &count) {
	if (N == 0) return 0;
	return cyandy(N - 1, ans += count, ++count);
}

int main() {
	int N = 0;
	cin >> N;

	int count = 0;
	int ans = 0;
	cyandy(N, ans,count);

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    int n,d,cnt=0;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        double dis=sqrt((1.0*x*x)+(1.0*y*y));
        if(d-dis>=0) cnt++;

    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX=100001;
typedef pair<int,int> P;
struct Edge{int from,to,color;};
int main()
{
  int n,k=0,i,j,a,b,c,cx;
  vector<int> v[N_MAX];
  Edge e[N_MAX];
  P p;
  queue<P> q; // edge index, parent color
  cin >> n;
  for(i=0;i<n-1;i++){
    cin >> a >> b;
    v[a].push_back(i);
    v[b].push_back(i);
    e[i].from=a;
    e[i].to=b;
    e[i].color=0;
  }
  for(i=0;i<n;i++)
    k=max(k,(int)v[i].size());
  q.push(P(1,0));
  while(!q.empty()){
    p=q.front(); q.pop();
    a=p.first;
    cx=p.second;
    for(i=0,c=1;i<v[a].size();i++){
      j=v[a][i];
      if(c==cx) c++;
      if(e[j].color==0){
        e[j].color=c;
        if(e[j].from==a){
          q.push(P(e[j].to,c));
        }else{
          q.push(P(e[j].from,c));
        }
        c++;
      }
    }
  }
  cout << k << endl;
  for(i=0;i<n-1;i++)
    cout << e[i].color << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll fastpow(ll _x, ll _n)
{
    ll ret = 1;
    while (0 < _n)
    {
        if ((_n % 2) == 0)
        {
            _x *= _x;
            _n >>= 1;
        }
        else
        {
            ret *= _x;
            --_n;
        }
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    for (ll i = 0; i < 61; i++)
    {
        ll temp = 0;
        for (ll k = 0; k < n; k++)
        {
            if (a[k] & (1LL << i))
            {
                temp++;
            }
        }
        ans += (((temp * (n - temp)) % 1000000007) * (fastpow(2LL, i) % 1000000007)) % 1000000007;
        ans %= 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  vector<int> v(4,0);
    r(i,4) cin>>v.at(i);
  sort(v.begin(),v.end());
  if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9)cout << "YES"<<endl;
  else cout <<"NO"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::cout << *std::max_element(A.begin(), A.end()) - *std::min_element(A.begin(), A.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
   string s;
   cin>>s;
   cout<<s[0]<<SZ(s)-2<<s[SZ(s)-1];	

   return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 51;

int dp[MAXN][MAXN];

int a[MAXN], b[MAXN];

ll ans;

void rec_sol(vector<ll> &v) {
	int mx = 0;
	REP(i, 0, SZ(v)) {
		int mn = INF;
		REP(j, 0, MAXN) {
			if (v[i] & (1ll << j)) {
				mn = min(mn, dp[j][b[i]]);
			}
		}
		mx = max(mx, mn);
	}
	
	if (mx == 0) {
		return;
	}
	
	/*REP(i, 0, SZ(v)) {
		REP(j, 0, MAXN) {
			if (v[i] & (1ll << j)) {
				printf("%d ", j);
			}
		}
		putchar('\n');
	}
	printf("%d\n", mx);
	printf("**********************\n");*/
	
	ans |= (1ll << mx);
	
	REP(i, 0, SZ(v)) {
		ll mask = 0ll;
		REP(j, 0, MAXN) {
			if ((v[i] & (1ll << j)) && dp[j][b[i]] <= mx) {
				int tmp = j % mx;
				if (dp[tmp][b[i]] < mx) {
					mask |= (1ll << tmp);
				}
				if (dp[j][b[i]] < mx) {
					mask |= (1ll << j);
				}
			}
		}
		v[i] = mask;
	}
	
	rec_sol(v);
}

void solve(){
	REP(i, 0, MAXN) {
		REP(j, 0, MAXN) {
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	REP(d, 1, MAXN) {
		REP(i, 0, MAXN) {
			REP(j, 0, MAXN) {
				if (i % d == j && dp[i][j] == INF) {
					dp[i][j] = d;
					REP(k, 0, MAXN) {
						if (dp[j][k] < INF) {
							dp[i][k] = min(dp[i][k], d);
						}
					}
				}
			}
		}
	}
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &a[i]);
	}
	REP(i, 0, n) {
		scanf("%d", &b[i]);
	}
	
	int mx = 0;
	REP(i, 0, n) {
		mx = max(mx, dp[a[i]][b[i]]);
	}
	if (mx == INF) {
		printf("-1\n");
		return;
	}
	
	vector<ll> vv(n);
	REP(i, 0, n) {
		vv[i] = (1ll << a[i]);
	}
	rec_sol(vv);
	
	printf("%lld\n", ans);
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(){

  int n; cin >> n;
  vector<int> num(n);
  rep(i,n) cin >> num[i];

  int cnt = 0;
  bool even = true;
  while(1){
    rep(i,n){
      if(num[i] % 2 != 0){
        even = false;
        break;
      }
    }
    if(!even) break;

    rep(i,n) num[i] /= 2;
    cnt++;
  }

  cout << cnt << endl;

  return 0;

}

Measured memory_bytes: 256
x = raw_input().split(" ")
num_operations = int(x[0])
kth_integer = int(x[1])
field = {}
for p in range(0, num_operations):
 line = raw_input().split(" ")
 a = int(line[0])
 b = int(line[1])
 if a in field:
  field[a] += b
 else:
  field[a] = b
ks = field.keys()
ks.sort()
out = field.keys()[-1]
for k in ks:
 kth_integer -= field[k]
 if (kth_integer <= 0):
  out = k
  break
print (out)


Measured memory_bytes: 12076
n = int(input())
b = list(map(int, input().split()))

ans = []
while True:
    flag = False
    if len(b) == 0:
        break

    for i in range(len(b)):
        if i+1 == b[i]:
            idx = i
            flag = True
    if flag:
        tmp = b.pop(idx)
        ans.append(tmp)
    else:
        ans = [-1]
        break

print('\n'.join(map(str, reversed(ans))))


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

ll ans = 0;

void merge(vector<int>& v, int left, int mid, int right)
{
  int n1 = mid - left, n2 = right - mid;
  vector<int> L(v.begin() + left, v.begin() + left + n1);
  vector<int> R(v.begin() + mid, v.begin() + mid + n2);
  L.push_back(INF);
  R.push_back(INF);
  for (int i = 0, j = 0, k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      v[k] = L[i];
      ++i;
    }
    else {
      v[k] = R[j];
      ++j;
      ans += n1 - i;
    }
  }
}

void mergeSort(vector<int>& v, int left, int right)
{
  if (left + 1 >= right) { return; }
  int mid = (left + right) / 2;
  mergeSort(v, left, mid);
  mergeSort(v, mid, right);
  merge(v, left, mid, right);
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  mergeSort(A, 0, n);
  fprintf(stdout, "%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3388
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    
    long long sum = 0;
    for(int i = 0; i < M; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    long long ans = N - sum;
    
    if(ans < 0){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    
    
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
const int mod=1e9+7;
using namespace std;
ll dp[100005][2];
int n;
vector <int> vec[100005];

int dfs(int x,int c,int p)
{
	if(dp[x][c]!=-1) return dp[x][c];
	dp[x][c]=1;
	for(int i=0;i<vec[x].size();i++)
	{
		if(vec[x][i]==p) continue;
		if(c==1) dp[x][c]*=dfs(vec[x][i],0,x);
		if(c==0) dp[x][c]*=(dfs(vec[x][i],0,x)+dfs(vec[x][i],1,x))%mod;
		dp[x][c]%=mod;
	}
	return dp[x][c];
}

int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n;
	int x,y;
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	cout<<(dfs(0,0,-1)+dfs(0,1,-1))%mod<<endl;
//	for(int i=0;i<n;i++)
//	{
//		cout<<dp[i][0]<<'-'<<dp[i][1]<<endl;
//	}
	return 0;
}

Measured memory_bytes: 17024
#include<bits/stdc++.h>
#define S second
#define INF (1e9)
#define N 105
using namespace std;

typedef pair<int,int> P;

int n, m, d[N][N];
int used[N], ans=0;

vector<P> idx;

set<vector<int> > memo;

void dfs(int x,vector<int> G){
  
  if(x>=2){

    int sum=0;

    for(int i=0;i<G.size();i++){
      
      int mincost=INF;
      
      for(int j=0;j<G.size();j++){
      
	if(G[i]!=G[j])
	  mincost=min(mincost,d[G[i]][G[j]]);
      
      }

      if(mincost!=INF) sum+=mincost;
    
    }
  
    ans=max(ans,sum);

  }
  
  sort(G.begin(),G.end());
  
  if(memo.count(G)) return ;
  memo.insert(G);
  
  for(int i=0;i<n;i++){

    if(used[idx[i].S]) continue;

    used[idx[i].S]=1;
    
    int mincost=INF;

    vector<int> nG=G;

    nG.push_back(idx[i].S);
    
    for(int j=0;j<nG.size();j++)
      
      if(idx[i].S!=nG[j]&&used[nG[j]])
	mincost=min(mincost,d[idx[i].S][nG[j]]);
    
    if(!x||(mincost&&mincost!=INF)) dfs(x+1,nG);
    
    used[idx[i].S]=0;
    
  }
  
}

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

  int a, b , f;

  for(int i=0;i<n;i++) idx.push_back(P(0,i));
  
  for(int i=0;i<m;i++){
    
    cin>>a>>b>>f;
    
    d[a-1][b-1]=d[b-1][a-1]=f;
    
    idx[a-1].first++;
    idx[b-1].first++;
  }

  //  sort(idx.begin(),idx.end());
  
  vector<int> init;
  
  dfs(0,init);

  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4888
#include <iostream>
using namespace std;
int h, w;
char a[101][101];

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        bool brise = true;
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                brise = false;
            }
        }

        if(brise == true){
            for(int j = 0; j < w; j++){
                a[i][j] = '!';
            }
        }
    }
    for(int i = 0; i < w; i++){
        bool brise = true;
        for(int j = 0; j < h; j++){
            if(a[j][i] == '#'){
                brise = false;
            }
        }

        if(brise == true){
            for(int j = 0; j < h; j++){
                a[j][i] = '!';
            }
        }
    }
     for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] != '!'){
                cout << a[i][j];
            }
        }cout << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,W;
	scanf("%d%d",&n,&W);
	int dp[100005] = {};
	for(int i=0; i<100005; i++)
		dp[i] = 1000000005;
	dp[0] = 0;
	for(int i=0; i<n; i++)
	{
		int v,w;
		scanf("%d%d",&w,&v);
		for(int j=100000; j>=v; j--)
			dp[j] = min(dp[j], dp[j-v]+w);
	}
	for(int i=100000; i>=0; i--)
		if(dp[i]<=W)
		{
			printf("%d\n",i);
			break;
		}
	return 0;
}

Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> xs[i];
    }
    int ans = 1e9;
    for (int p = 0; p <= 100; p++)
    {
        int tmp = 0;
        for (int x : xs)
        {
            tmp += (p - x) * (p - x);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <memory>
#include <limits>
#include <vector>

int main() {
  int h, n;
  std::cin >> h;
  std::cin >> n;

  std::vector<int> atks(n), mps(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> atks[i];
    std::cin >> mps[i];
  }

  // dp[(敵のHP)] = そのHPを倒せるMPの最小値
  std::vector<int> dp(h + 1, std::numeric_limits<int>::max());

  for (int i = 0; i <= h; ++i) {
    for (int m = 0; m < n; ++m) {
      if (atks[m] >= i)
        dp[i] = std::min(dp[i], mps[m]);
      else
        dp[i] = std::min(dp[i], dp[i - atks[m]] + mps[m]);
    }
  }

  std::cout << dp[h] << std::endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text.RegularExpressions;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            int secretNumber = 0;
            Regex regPattern = new Regex("[0-9]+");
            while((input = Console.ReadLine()) != null) {
                foreach(int value in (from Match q in regPattern.Matches(input) select int.Parse(q.Value))) {
                    secretNumber += value;
                }
            }
            Console.WriteLine(secretNumber);
        }
    }
}

Measured memory_bytes: 11184
N, K = map(int,input().split())
listMap = [int(i) for i in input().split()]
minMin = float("inf")

if N == 1:
    minMin = listMap[0]

for j in range(N - (K - 1)):
    L = j
    R = j + (K - 1)
    sumL = abs(listMap[L]) + abs(listMap[L] - listMap[R])
    sumR = abs(listMap[R]) + abs(listMap[R] - listMap[L])
    sum = min(sumL, sumR)
    if sum < minMin:
        minMin = sum

print(minMin)

Measured memory_bytes: 14224
#include <stdio.h>

int main(void){
    int n,i,j,card;
    int state[4][13]={};
    char kind;
    char label[4]="SHCD";
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf(" %c",&kind);
        scanf("%d",&card);
        switch(kind){
            case 'S':state[0][card-1]=1;break;
            case 'H':state[1][card-1]=1;break;
            case 'C':state[2][card-1]=1;break;
            case 'D':state[3][card-1]=1;break;
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(state[i][j]==0)
                printf("%c %d\n",label[i],j+1);
        }
    }
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <ii, int> iii;

const int siz = 1e5 + 10;
const int SIZ = 1e5 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e12;
const string file = "2";



int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int x;
    cin >> x;

    cout << (int)(x ^ 1) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

//蟻本，螺旋本参考
//DisjointSet
//整数配列に対応
class UnionFindTree {
public:
    vector<int> rank, p;

    UnionFindTree() {}

    UnionFindTree(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; ++i) {
            makeSet(i);
        }
    }

    void makeSet(int x)
    {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x)
    {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

    int maxUnion()
    {
        int size = p.size();
        int r = 0;
        REP(i,size) {
            r = max(r, (int)count(p.begin(), p.end(), i));
        }
        return r;
    }
};

int n, m;
vector<bool> used;
multimap<int, pair<int, int>> d;

void solve()
{
    int cnt = 0;
    used.resize(n, false);
    UnionFindTree uf(n);
    REP(i,m) {
        int s, t, c;
        cin>>s>>t>>c;
        d.insert({c, {s-1, t-1}});
    }

    for (auto itr : d) {
        //cout<<"_"<<itr.first<<"_"<<itr.second.first<<","<<itr.second.second<<endl;
        if (!uf.same(itr.second.first,itr.second.second)) {
            uf.unite(itr.second.first,itr.second.second);
            cnt++;
        }

        if (cnt == n / 2) {
            cout<<itr.first<<endl;
            d.clear();
            return;
        }
    }
}

int main()
{
    while (cin>>n>>m, n != 0) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3312
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const double pi=acos(-1);
const ll P = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;
ll lcm(ll a,ll b){return a*b/gcd(a,b);};
const int maxn = 200 + 10;
ll a[maxn];
const int L = 63;
ll d[L];
bool add(ll x){
    for(int i = L - 1; i >= 0; i--) if(x & 1ll << i){
        if(d[i] == -1){d[i] = x; return true;}
        x ^= d[i];
    }
    return false;
}

int main(){
//    Fast;
    int t; scanf("%d", &t); while(t--){
        memset(d, -1, sizeof d);
        
        int n; scanf("%d", &n);
        for(int i = 0; i < n; i++) scanf("%lld", a + i);
        char s[maxn]; scanf("%s", s);
        int flag = 0;
        for(int i = n - 1; i >= 0; i--){
            if(add(a[i]) && s[i] == '1'){
                flag = 1;
                break;
            }
        }
        printf("%d\n", flag);
    }
    return 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < 2 * b) {
            System.out.println("0");
        } else {
            System.out.println(a - (2 * b));
        }
    }
}


Measured memory_bytes: 23764
# include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e5 + 21;
int n, m, cnt;
int a[MAXN], b[MAXN];
 
int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
        if(a[i] & 1) 
        	cnt++;
    }
  
    if(m == 1) {
    	if(a[1] == 1)
        	cout << 1 << '\n' << 1 << '\n' << 1 << '\n';
		else 
          cout << a[1] << '\n' << 2 << '\n' << a[1] - 1 << ' ' << 1 << '\n';
		return 0;
	}
    if(cnt > 2) 
      cout << "Impossible";
    else {
        int p = 1;
		for (int i = 1; i <= m; i++) {
			if((a[i] % 2) && p == 1) {
             	swap(a[i], a[1]);
              	p++;
            }
			else if((a[i] % 2) && p == 2) 
            	swap(a[i], a[m]);
		}
        for (int i = 1; i <= m; i++)
        	cout << a[i] << ' ';
        cout << '\n';
       	cout << m - (a[m] == 1) << '\n';
        cout << a[1] + 1 << ' ';
        for (int i = 2; i < m; i++)
        	cout << a[i] << ' ';
        if(a[m] > 1) 
          cout << a[m] - 1 << ' ';
    }
    return 0;
}

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

using LL = long long;
const int MAXN = 3010;

int A[MAXN];
LL dp[MAXN][MAXN];
int N;

int main() {
	cin >> N;
	for(int i=1; i<=N; i++) cin >> A[i];
	
	memset(dp, 0, sizeof(dp));
	for(int i=N; i>0; i--) {
		for(int j=i; j<=N; j++) {
			if(i==j) dp[i][j] = A[i];
			dp[i][j] = max(A[j]-dp[i][j-1], A[i]-dp[i+1][j]);
		}
	}
	
	cout << dp[1][N] << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll T, X; cin >> T >> X;
    cout << (double) T / (double) X << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int a,b;
    cin >> a >> b;
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else if(a < 0){
        if((b - a + 1) % 2 == 0){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else{
        cout << "Positive" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int dis = 0;
    rep(i, n) {
        int temp = a[(i+1)%n] - a[i];
        if (temp<0) temp += k;
        dis = max(dis, temp);
    }
    int ans = k - dis;
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double r = Double.parseDouble(br.readLine());
		String area = String.format("%5f", Math.pow(r, 2) * Math.PI);
		String circumference = String.format("%5f", (r * 2) * Math.PI);
		System.out.println(area + " " + circumference);
	}
}

Measured memory_bytes: 24644
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
=end

class Dl
  def initialize()
    @lst = []
  end

  def lst
    @lst
  end

  def exe(cmd, val)
    if cmd=="insert" then
      @lst.unshift(val)
    elsif cmd=="delete" then
      0.upto(@lst.length-1).each{|i|
        if @lst[i]==val then
          @lst.delete_at(i)
          break
        end }
    elsif cmd=="deleteFirst" then
        @lst.shift
    elsif cmd=="deleteLast" then
        @lst.pop
    end

  end

end

class Main
  def initialize()
    #fh = open("x.txt")
    fh = STDIN
    cmd=[]
    val=[]
    n = fh.gets.chomp.to_i
    0.upto(n-1){|i| cmd[i],val[i] = fh.gets.chomp.split}

    dl = Dl.new()
    0.upto(cmd.length-1).each{|i|
      dl.exe(cmd[i], val[i]) }

    puts dl.lst().join(" ")
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 286600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

int main() {

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            int money = i * 4 + j * 7;
            if(money == N){
                ans++;
            }
        }
    }

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

}

































Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
double A=0.8,x,y,b,p,a,h;
int n;
cin >> n;
for(int i=0;i<n;i++){
cin >> x >> y >> b >> p;
if(5<=b&&2<=p){
x=x*A;
y=y*A;
cout << x*b+y*p << endl;
}else{
a=x*b+y*p;
if(b<5&&p<2){
h=x*A*5+y*A*2;
}else if(b<5&&2<=p){
h=x*A*5+y*A*p;
}else if(5<=b&&p<2){
h=x*A*b+y*A*2;
}
if(a<h){
printf("%g\n",a);
}else if(a>=h){
printf("%g\n",h);
}
}
}
return(0);
}


Measured memory_bytes: 3332
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, K = MAP()
A = LIST()
B = LIST()
A_ruiseki = A
B_ruiseki = B
for i in range(N-1):
    A_ruiseki[i+1] += A_ruiseki[i]

for i in range(M-1):
    B_ruiseki[i+1] += B_ruiseki[i]
ans = 0
for i in range(N):
    a_idx = 0
    # b_idx = 0
    amari = K
    if K - A_ruiseki[i] >= 0:
        a_idx = i + 1
        amari = amari - A_ruiseki[i]
        b_idx = bisect(B_ruiseki, amari)
        total = a_idx + b_idx
        ans = max(ans, total)
#  only b case
b_idx = bisect(B, K)
# print(b_idx)
ans = max(ans, b_idx)
print(ans)


Measured memory_bytes: 41108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char ui[5];
double xi;

int main(){

int N;

scanf("%d",&N);

int i;

double ans=0;

for(i=0;i<N;i++){
scanf("%lf %s",&xi,ui);
if(strcmp(ui, "JPY") == 0){
ans+=xi;
}
else{
ans+=380000.0*xi;
}
}

printf("%.6f\n",ans);

return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    printf("%lld\n", 48-N);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: HEX
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string x, y;
  cin >> x >> y;

  if (x[0] < y[0]) puts("<");
  else if (x[0] > y[0]) puts(">");
  else puts("=");
  return 0;
}


Measured memory_bytes: 256
/*
*    AUTHOR:    mkbaloch
*    CREATED:   26.01.2020 17:48:10
*/

#include<bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define repn(i, n) for(int i=0; i<(int)n; i++)
#define all(x) x.begin(), x.end()

using namespace std;

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

  #ifdef DEBUG
    auto start = chrono::high_resolution_clock::now();
  #endif

  //-------Start-------//
  
  int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	ll ans = 0;
	for(int i = 0; i < n; i++) cin >> arr[i];
	sort(all(arr));
	for(int i = 0; i<(n - k); i++) ans += arr[i];
	cout << ans << endl;

  //-------End---------//

  #ifdef DEBUG
    auto end = chrono::high_resolution_clock::now();
    auto dur = chrono::duration_cast<chrono::microseconds>(end - start);
    cout << "Execution time: " << setprecision(6) << ((long double)dur.count() / 1e6) << " seconds" << endl; 
  #endif

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>

using ll = long long;

int main(){
  ll n,m,a[100001]={0}, wa[100001]={0};
  std::cin>>n>>m;
  ll sum=0, ans=0;
  std::map<int, int> p{{0,1}};
  for(int i=0;i<n;++i){
    std::cin>>a[i];
    sum += a[i];
    wa[i+1]=sum;
    p[wa[i+1]%m]++;
  }

  for(auto it: p){
    ll pi = it.second;
    ans += pi* (pi-1)/2;
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 3968
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int

	fmt.Scan(&k)
	fmt.Scan(&s)

	length := len(s)
	if length <= k {
		fmt.Println(s)
		return
	}
	for i := 0; i < k; i++ {
		c := s[i]
		//fmt.Println(reflect.TypeOf(c))
		fmt.Printf("%c",c)
	}
	fmt.Print("...")
}

Measured memory_bytes: 1820
/* ****Tciitb**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;



int main() {
  io
  
  ll n;
  cin>>n;
  string x;
  cin>>x;
  ll ans=-1;
  rep(i,1,x.length())
  {
     string z1="",z2="";
     ll a1[26]={0},a2[26]={0};
     rep(j,0,i)
     {
       z1+=x[j];
       a1[x[j]-'a']++;
     }
     rep(j,i,x.length())
     {
      z2+=x[j];
      a2[x[j]-'a']++;
     }
     ll c1=0,c2=0;
     rep(j,0,26)
     {
       if(a1[j]!=0 && a2[j]!=0)
        c1++;
     }
     ans=max(c1,ans);

     
  }
  cout<<ans;

  }
  

  


  




Measured memory_bytes: 256
A = []

for i in range(3):
  A00 = input().rstrip().split(' ')
  A0 = int(A00[0])
  A1 = int(A00[1])
  A2 = int(A00[2])
  A.append([A0, A1, A2])

N = int(input())
b = []

for i in range(N):
  B = int(input())
  b.append(B)

#flag_a = [[0, 0, 0],["","",""],["","",""]]
flag_A = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if A[j][k] == b[i]:
        flag_A[j][k] = 1

if flag_A[0][0] == 1 and flag_A[0][1] == 1 and flag_A[0][2] == 1:
  print("Yes")
elif flag_A[1][0] == 1 and flag_A[1][1] == 1 and flag_A[1][2] == 1:
  print("Yes")
elif flag_A[2][0] == 1 and flag_A[2][1] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][0] == 1 and flag_A[1][0] == 1 and flag_A[2][0] == 1:
  print("Yes")
elif flag_A[0][1] == 1 and flag_A[1][1] == 1 and flag_A[2][1] == 1:
  print("Yes")
elif flag_A[0][2] == 1 and flag_A[1][2] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][0] == 1 and flag_A[1][1] == 1 and flag_A[2][2] == 1:
  print("Yes")
elif flag_A[0][2] == 1 and flag_A[1][1] == 1 and flag_A[2][0] == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3192
N, K = map(int, input().split())
A = []

for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  A.append(a)

ref = A[0]

for i in range(1, K):
  ref = list(set(ref) & set(A[i])) + list(set(ref) ^ set(A[i]))

len = len(ref)

print(N - len)

Measured memory_bytes: 9200
import numpy as np
H, W, K=map(int,input().split())
C=np.zeros((H,W))

for i in range(H):
    c=input()
    for j in range(len(c)):
        if c[j]=="#":
            C[i][j]=1
CH=[]
CW=[]

for i in range(2**H):
    cl=[]
    for j in range(H):
        if bin(i)[-j-1]=="1":
            cl.append(j)
        elif bin(i)[-j-1]=="b":
            break
    CH.append(cl)

for i in range(2**W):
    cl=[]
    for j in range(W):
        if bin(i)[-j-1]=="1":
            cl.append(j)
        elif bin(i)[-j-1]=="b":
            break
    CW.append(cl)

ans=0
for i in range(len(CH)):
    for j in range(len(CW)):
        count=0
        for k in range(len(CH[i])):
            for l in range(len(CW[j])):
                count+=C[CH[i][k]][CW[j][l]]
        if count==K:
            ans+=1
print(ans)
            

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

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef pair<int, int> P;
typedef unsigned int uint;
typedef unsigned long long ull;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};

const int inf = 1000000009;
const double eps = 1e-8;
// Range Sum Query
template<typename T>
class SegmentTree {
private:
    int n;
    T dat[(1<<18)-1];
public:
    SegmentTree(int& n_) {
	n = 1;
	while (n < n_) n *= 2;
	n_ = n;
	for (int i = 0; i < 2*n-1; i++) dat[i] = 0;
    }

    // add a to node k
    void add(int k, T a) {
	k += n - 1;
	dat[k] += a;
	while (k > 0) {
	    k = (k - 1) / 2;
	    dat[k] = dat[k*2+1] + dat[k*2+2];
	}
    }
    
    // call query(a, b, 0, 0, n)
    T query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return 0;

	if (a <= l && r <= b) return dat[k];
	else {
	    T vl = query(a, b, k*2+1, l, (l+r)/2);
	    T vr = query(a, b, k*2+2, (l+r)/2, r);
	    return vl + vr;
	}
    }
};

void solve(int n, int q) {
    SegmentTree<ll> st(n);
    for (int i = 0; i < q; i++) {
	int com, x, y;
	scanf("%d%d%d", &com, &x, &y);
	x--;
	if (com == 0) {
	    st.add(x, y);
	} else {
	    y--;
	    printf("%lld\n", st.query(x, y+1, 0, 0, n));
	}
    }
}

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    */

    int n, q;
    scanf("%d%d", &n ,&q);
    solve(n, q);
}

Measured memory_bytes: 3224
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])

Measured memory_bytes: 120812
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
    
  int main(){
      lint n;
      cin>>n;
      lint a=1000000000;
      cout<<0<<" "<<0<<" ";
      lint x=n/a+1;
      lint y=a-(n-(x-1)*a);
      if(x==(a+1)){
          cout<<a<<" "<<0<<" "<<0<<" "<<a<<endl;
      }else{
          cout<<a<<" "<<1<<" "<<y<<" "<<x<<endl;
      }

     }
  
      
      
    

  
          
  

Measured memory_bytes: 256
N = int(input())
A =list(map(int,input().split()))

P = set()
ans = 0
for a in A:
    if a // 400 < 8:
         P.add(a // 400)
    else: ans += 1

if ans == 0: print(len(P),len(P))
elif len(P)==0: print(1,ans)
else: print(len(P),len(P)+ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int fact(int x){
  int res = 1;
  for(int i=0; i<x; i++){
    res *= 2;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  cout << (100*(n-m)+1900*m)*fact(m) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<setprecision(9)<<(w*h)/2.0<<" ";
  if(w/2==x && h/2==y)
  {
   cout<<"1";
  }
  else
    cout<<"0";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

bool ans(){
    char a;
    cin>>a;
    return a=='Y';
}

void solve(int l){
    ll a = 1;
    rep(i,0,l-1) a*=10;
    ll b = a*10;
    while(a+1 != b){
        ll m = (a+b)/2;
        cout<<"? "<<m<<"0"<<endl;
        if(ans()) b = m;
        else a = m;
    }
    cout<<"! "<<b<<endl;
    exit(0);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    rep(l,1,11){
        cout<<"? ";
        cout<<1;
        rep(i,0,l-1) cout<<0;
        cout<<endl;
        if(!ans()) solve(l-1);
    }
    // of the form 1000...;
    for(int l = 9; l>0; --l){
        cout<<"? ";
        rep(i,0,l) cout<<9;
        cout<<endl;
        if(!ans()){
            cout<<"! 1";
            rep(i,0,l) cout<<0;
            cout<<endl;
            return 0;
        }
    }
    cout<<"! 1"<<endl;
    return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int h, w;
char s[51][51];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                bool flag = false;
                for(int k = 0; k < 4; k++){
                    if(i+dx[k] >= 0 && h > i+dx[k] && j+dy[k] >= 0 && j+dy[k] < w){
                        if(s[i+dx[k]][j+dy[k]] == '#'){
                            flag = true;
                        }
                    }
                }
                if(!flag){
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
"""
"""
A, B, C, K = map(int, input().split())
sum = 0

if A >= 1:
    if K - A >= 0:
        sum += A
        K -= A
    else:
        sum += K
        K = 0
if B >= 1 and K >= 1:
    if K - B >= 0:
        K -= B
    else:
        K = 0

if C >= 1 and K >= 1:
    if K - C >= 0:
        sum -= C
        K -= C
    else:
        sum -= K
        K = 0

print(sum)


Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){

  string s;
  cin>>s;
  bool a=false,A=false,n=false;
  rep(i,s.size()){
    if(isdigit(s[i]))n=true;
    else if(isupper(s[i]))A=true;
    else if(islower(s[i]))a=true;
  }
  if(s.size()>=6&&n&&A&&a)cout<<"VALID"<<endl;
  else cout<<"INVALID"<<endl;
  

}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(64<=N&&N<=100){
    cout<<"64"<<endl;
  }
   if(32<=N&&N<64){
     cout<<"32"<<endl;
   }
  if(16<=N&&N<32){
     cout<<"16"<<endl;
   }
  if(8<=N&&N<16){
     cout<<"8"<<endl;
   }
  if(4<=N&&N<8){
     cout<<"4"<<endl;
   }
  if(2<=N&&N<4){
     cout<<"2"<<endl;
   }
  if(1<=N&&N<2){
     cout<<"1"<<endl;
   }
}

Measured memory_bytes: 3600
A, B = map(int, input().split())

common_divisors = []
for n in range(1, int(min(A, B) ** 0.5) + 1):
    if (A % n == 0) & (B % n == 0):
        common_divisors.append(n)

    if A % n == 0:
        x = A // n
        if B % x == 0:
            common_divisors.append(x)


# ある自然数の素数判定
def is_prime(n):
    if n == 1:
        return False

    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    else:
        return True


ans = 0
for cd in common_divisors:
    ans += is_prime(cd)

print(ans + 1)


Measured memory_bytes: 3268
package main

import (
	"fmt"
)

func main() {
	var n, m, d int
	fmt.Scanf("%d%d%d", &n, &m, &d)
	ans := (m - 1) * (n - d)
	if d != 0 {
		ans *= 2
	}
	fmt.Printf("%.99f\n", float64(ans)/float64(n*n))
	return
}


Measured memory_bytes: 512