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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

// 右づめでの10進数xをdigits桁のN進数vectorにしてを返す
vector<int> baseNumber(int N, int digits, int x) {
  vector<int> ret(digits, 0);
  // 商
  int quotient = x;
  int counter = 0;
  while (quotient > 0) {
    // 余り
    int remainder = quotient % N;
    quotient /= N;
    ret[counter] = remainder;
    counter++;
  }

  reverse(All(ret));

  return ret;
};

void Print(vector<int> &v) {
  for (int n: v) {
    cout << n;
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> S(N+1);

  vector<PI> inp(M);
  int P, Y;
  rep(i, 0, M) {
    cin >> P >> Y;
    inp[i].first = P;
    inp[i].second = Y;
    S[P].pb(Y);
  }

  rep(i, 0, N+1) {
    if (!S[i].empty()) {
      sort(All(S[i]));
    }
  }

  rep(i, 0, M) {
    auto PY = inp[i];

    int p = PY.first;
    int y = PY.second;
    auto vec_p = baseNumber(10, 6, p);

    auto vec_y = baseNumber(10, 6, lbidx(S[p], y) + 1);
    Print(vec_p);
    Print(vec_y);
    cout << endl;
  }

  return 0;
};


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int x,y;
 cin >>x>>y;
if(y%2==0)
{
if(y>=2*x && y<=4*x) cout<< "Yes";
else cout<< "No";
}

else cout<<"No";

    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long takahashi = sc.nextLong();
		long aoki = sc.nextLong();
		long count = sc.nextLong();
		long takahashiHozon = takahashi;

		if(takahashi  >= count ) {
			takahashi -= count;
		}else {
			takahashi = 0;
			aoki -= (count -takahashiHozon);
			if(aoki < 0) {
				aoki = 0;
			}
		}

		System.out.println(takahashi + " " + aoki);

	}
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		int x0 = 9, y0 = 9;
		// int count = 0;
		int[] count = new int[500];
		int dataset = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// StringBuffer sb = new StringBuffer(new String(br.readLine()));
		// int x = Character.getNumericValue(sb.charAt(0));
		// int y = Character.getNumericValue(sb.charAt(2));

		for (dataset = 0; dataset < 500; dataset++) {

			int k = 0;
			String str = br.readLine();
			String box[] = str.split(" ");
			int x = Integer.parseInt(box[0]);
			int y = Integer.parseInt(box[1]);

			if (x == 0 && y == 0) {
				break;
			} else {

				boolean[][] can = new boolean[x][y];
				boolean[][] black = new boolean[x][y];

				for (int j = 0; j < y; j++) {

					StringBuffer sb = new StringBuffer(new String(br.readLine()));
					for (int i = 0; i < x; i++) {
						if (sb.charAt(i) == '#') {
							black[i][j] = false;
						} else {
							if (sb.charAt(i) == '@') {
								x0 = i;
								y0 = j;
							}
							black[i][j] = true;
						}
					} // iのループ
				} // jのループ

				can[x0][y0] = true;

				int px = x0;
				int py = y0;

				do {
					for (int j = 0; j < y; j++) {
						for (int i = 0; i < x; i++) {
							if (can[i][j]) {
								px = i;
								py = j;

								if (py > 0) {
									if (black[px][py - 1]) {// 上
										can[px][py - 1] = true;
									}
								}

								if (py < y - 1) {
									if (black[px][py + 1]) {// 下
										can[px][py + 1] = true;
									}
								}

								if (px > 0) {
									if (black[px - 1][py]) {// 左
										can[px - 1][py] = true;
									}
								}

								if (px < x - 1) {
									if (black[px + 1][py]) {// 右
										can[px + 1][py] = true;
									}
								}
							}

						}
					}
					k++;
				} while (k < x * y);

				for (int j = 0; j < y; j++) {
					for (int i = 0; i < x; i++) {
						if (can[i][j]) {
							count[dataset]++;
						}
					}
				}
			}
		}
		for (dataset = 0; dataset < 500; dataset++) {
			if (count[dataset] == 0) {
				break;
			}
			System.out.println(count[dataset]);
		}

	}// main

}// class



Measured memory_bytes: 31124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main() {
    ll a, b;
    cin >> a >> b;
    ll p = 2;
    ll a1 = 0, b1 = 0;
    if(((b+1)/2) % 2 == 1)
    b1 = 1;
    for(int i = 0; b >= p; i++){
        ll st = (b + 1) / p, rem = (b + 1) % p;
        if(st % 2 == 0){
        b1 += p * 0;
        }
        else{
            if(rem % 2 == 1)
            b1 += p * 1;
            else
            b1 += p * 0;
        }
        p = p << 1;
    }
    if(a == 0){
        cout << b1;
        return 0;
    }
    p = 2;
    a--;
    if(((a+1)/2) % 2 == 1)
    a1 = 1;
    for(int i = 0; a >= p; i++){
        ll st = (a + 1)/ p, rem = (a+1) % p;
        if(st % 2 == 0){
        a1 += p * 0;
        }
        else{
        if(rem % 2 == 1)
        a1 += p * 1;
        else
        a1 += p * 0;
        }
        p = p << 1;
    }
    cout << (a1 ^ b1) << endl;
   
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = list(map(int, input().split()))
h_list = list(map(int, input().split()))


def calc_deg(h):
    return t - h * 0.006


ans = 0
min_diff = 1e6
for i, h in enumerate(h_list, 1):
    diff = abs(calc_deg(h) - a)
    if diff < min_diff:
        min_diff = diff
        ans = i

print(ans)


Measured memory_bytes: 3060
let to_z x = if x = -0. then 0. else x;;
let read_str u = read_line u |> Str.split (Str.regexp_string " ")
           |> List.map (fun x-> float_of_string x) |> List.nth;;
let () =
  let fl = read_str () in
  let x0, y0, x1, y1 = fl 0, fl 1, fl 2, fl 3 and
      n = read_int () in
  let rec read i =
    let fl2 = read_str () in
    let x2, y2 = fl2 0, fl2 1 in
    let p1_sqr = ( (x1-.x0)**2. +. (y1-.y0)**2. ) and
        in_p = ((x1-.x0)*.(x2-.x0)+.(y1-.y0)*.(y2-.y0)) in
    let xt,yt = in_p*.(x1-.x0)/.p1_sqr +. x0,in_p*.(y1-.y0)/.p1_sqr +. y0 in
    Printf.printf "%.10f %.10f\n" (to_z xt) (to_z yt);
    if i > 0 then read (i-1)
  in read (n-1);;

Measured memory_bytes: 4552
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,q = inpl()
abc = [inpl() for _ in range(q)]
q = deque()
q.append([1])
res = 0

while q:
    now = q.popleft()
    if len(now) == n:
        ans = 0
        for i,x in enumerate(abc):
            a,b,c,d = x
            b -= 1; a -= 1
            if now[b] - now[a] == c:
                ans += d
        res = max(ans, res)
        continue
    for i in range(now[-1], m+1):
        q.append(now + [i])
print(res)

Measured memory_bytes: 89356
/* Just_Do_It ___________ICARUS__________________*/
                     
    #include <bits/stdc++.h>
    using namespace std;
           
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(ll i=a;i<n;i++)
    #define per(i,n,a) for (ll i=n;i>a;i--)
    #define te ll t; std::cin >> t; while(t--)
    #define SZ 200010
    //# define M_PIl  3.141592653589793238462643383279502884L 
    /*   Proceed with CAUTION   */
     
     vector<ll> g[SZ];
     ll in[SZ],num[SZ][2];

    int main(){
        fastio;
        ll n,m; string s;
        cin>>n>>m>>s;
        s = '0'+s;
        while(m--){
        	ll x,y;
        	cin>>x>>y;
        	g[x].push_back(y);
        	g[y].push_back(x);
        	++num[x][s[y]=='B'];
        	++num[y][s[x]=='B'];
        }
        queue<ll> q;
        rep(i,1,n+1) if(num[i][0]==0 || num[i][1]==0) q.push(i), in[i]=1;
        while(!q.empty()){
        	ll x = q.front(); q.pop();
        	for(auto i:g[x]){
        		if(!in[i] && !--num[i][s[x]=='B']){
        			q.push(i);
        			in[i]=1;
        		}
        	}
        }
        rep(i,1,n+1) if(!in[i]) return puts("Yes"),0;
        puts("No");
        }



Measured memory_bytes: 17428
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

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

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

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

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N, K;
    char S[51];

    scanf("%zu %zu\n%s", &N, &K, S);

    S[K - 1] = tolower(S[K - 1]);

    puts(S);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void) {

  int arr[999] = {0};
  int k;
  int a,b;
  int height;
  int ans_a, ans_b;

  arr[0] = 1;
  for (k = 1; k < 999; k++) {
    arr[k] = arr[k-1] + k + 1;
  }

  scanf("%d %d", &a, &b);

  height = b - a;
  ans_b = arr[height-1];
  ans_a = arr[height-2];

  printf("%d\n", ans_a-a);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

const uint64_t M = 26;

int main()
{
  uint64_t D;
  cin >> D;

  vector<int64_t> c(M);
  cin >> c;

  vector<vector<int64_t>> s(D, vector<int64_t>(M));
  N_TIMES(d, D) {
    cin >> s[d];
  }

  vector<int64_t> t(D);
  cin >> t;
  N_TIMES(d, D) { --t[d]; }

  auto calc_score = [&](const vector<int64_t> &t) {
    vector<int64_t> last(M, 0);
    int64_t S = 0;
    N_TIMES(d, D) {
      S += s[d][t[d]];
      last[t[d]] = d + 1;
      N_TIMES(m, M) {
        if (t[d] == m) { continue; }
        S -= c[m] * ((d + 1) - last[m]);
      }
    }
    return S;
  };

  int64_t S = calc_score(t);

  uint64_t Q;
  cin >> Q;

  N_TIMES(i, Q) {
    uint64_t d, q;
    cin >> d >> q;
    --d; --q;

    t[d] = q;
    cout << calc_score(t) << endl;
  }

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int maxPrefix = 0, prefix[s.size() + 1];
  prefix[0] = 0;
  for (int i = 1; i <= s.size(); ++i) {
    if (s[i - 1] == '1') {
      prefix[i] = prefix[i - 1] + 1;
    } else {
      prefix[i] = prefix[i - 1] - 1;
    }
    maxPrefix = max(maxPrefix, prefix[i]);
  }
  auto solve = [&](int maxPrefix) {
    int capacity[s.size() + 1];
    for (int i = s.size(), j = numeric_limits<int>::max(); i > 0; --i) {
      j = min(j, maxPrefix - prefix[i]);
      capacity[i] = j / 2;
    }
    int sum = 0, result = 0, tempMinPrefix = 0, count = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '1') {
        ++sum;
      } else if (s[i] == '0') {
        --sum;
      } else if (capacity[i + 1] > count) {
        ++sum;
        ++count;
      } else {
        --sum;
      }
      result = min(result, sum);
    }
    return result;
  };
  cout << min(maxPrefix - solve(maxPrefix), maxPrefix + 1 - solve(maxPrefix + 1));
  return 0;
}

Measured memory_bytes: 11828
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

  int main()
  {



        int x,a;
        cin>>x>>a;

        if(x<a)
        {
           cout<<0;
        }
        else
        {
           cout<<10;
        }

        cout<<endl;
     
          
  }



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
     SPEED;
    int n;
    set<int>d;
    cin>>n;
    rep(i,n){
      int D;
        cin>>D;
      d.insert(D);
    }
    cout<<d.size();
    return 0;
}


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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  q *= 4;
  h *= 2;
  lol ans = min({q * 2, h * 2, s * 2, d}) * (n / 2);
  ans += min({q, h, s}) * (n % 2);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+100);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int ct=0;
    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]) {
            ct++;
            A[i+1]=A[i]+100;
            if(i<N && A[i+2]==A[i+1])A[i+1]+=1;
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define BS 12345678891
#define bsize 256

#define ldouble long double

using namespace std;

long long INF = 1e9;
const int N = 500031;

int n;
long long ar[N],s,per_step;
long long used_steps[N];

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

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

	for (int i=1;i<=n;i++)
	{
		per_step+=i;
	}

	long long total_steps=s/per_step;
	if (s%per_step)
	{
		cout<<"NO"<<endl;
		return 0;
	}

	int ok=1;

	long long used_steps=0;

	for (int i=0;i<n;i++)
	{
		long long prv=ar[(i+n-1)%n];
		long long here=ar[i];
		long long should_be=prv+total_steps;
		long long ohead=should_be-here;
		if (ohead<0||ohead%n)
		{
			ok=0;
		}
		used_steps+=ohead/n;
	}

	if (used_steps==total_steps&&ok==1)
	{
		cout<<"YES"<<endl;
	}
	else
		cout<<"NO"<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back
#define SQ(a) (a)*(a)
 
using namespace std;


int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    for(int t = 1;t<=T;t++)
    {
    	int n;
    	cin>>n;
        string s;
        cin>>s;
        int rcount = 0;
        int wcount = 0;
        for(int i = 0;i<s.length();i++)
        {
        	if(s[i] == 'R')
        		rcount++;
        	else
        		wcount++;
        }
        int rcountl = 0;
        int wcountl = 0;
        int rcountr = rcount;
        int wcountr = wcount;
        int ans = s.length();
        for(int i = 0;i<s.length();i++)
        {
        	if(s[i] == 'W')
        	{
        		ans = min(ans,max(rcountr,wcountl));
        		wcountl++;
        		wcountr--;
        	}
        	else
        	{
        		ans = min(ans,max(rcountr-1,wcountl));
        		rcountl++;
        		rcountr--;
        	}
        	//cout<<ans<<" ";
        }   
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3772
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a >= 13)
                out.println(b);
            else if (a >= 6 && a <= 12)
                out.println(b / 2);
            else
                out.println(0);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(int args, char *argv[])
{
  int N;
  cin >> N;
  vector<int> a;

  for (int i = 0; i < N; i++)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end());

  int x, y;
  x = 0;
  y = 0;

  for (int i = 0; i < a.size(); i++)
  {
    if (i % 2 == 0)
    {
      x += a[a.size() - 1 - i];
    }
    else
    {
      y += a[a.size() - 1 - i];
    }
  }

  cout << x - y << endl;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int k;
    scanf("%d", &k);
    char tmp = s[k - 1];
    for(int i = 0; i < n; i++){
        if(s[i] != tmp){
            s[i] = '*';
        }
    }
    printf("%s\n", s);
    return 0; 
}

Measured memory_bytes: 128
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

from collections import deque
q = deque()
q.append((0, 0))
d = [10**6]*N
d[0] = 0
while q:
    temp = q.popleft()
    v = temp[0]
    r = temp[1]
    for t in E[v]:
        if d[t] == 10**6:
            d[t] = r+1
            q.append((t, r+1))

num = N-1
for k in range((d[N-1]-1)//2):
    for v in E[num]:
        if d[v] == d[N-1]-k-1:
            num = v
            break
used = [0]*N
used[num] = 1
q = deque([0])
while q:
    temp = q.pop()
    for v in E[temp]:
        if used[v] == 0:
            used[v] = 1
            q.append(v)

if sum(used)-1 > N-sum(used)+1:
    ans = "Fennec"
else:
    ans = "Snuke"
print(ans)

Measured memory_bytes: 26164
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val inputs = readInputLine().split(" ").map { it.toInt() }
    
    var sum = 0
    
    for (a in inputs) {
        sum += a
    }
    
    var i = 0
    var distance = Int.MAX_VALUE
    
    for ((index, a) in inputs.withIndex()) {
        val newDistance = Math.abs(a * n - sum)
        if (newDistance < distance) {
            distance = newDistance
            i = index
        }
    }
    
    println(i)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37932
import math

a, b, x = map(int, input().split())

PI = math.acos(-1)
ans = 0

def radianToDegree(p):
    return math.degrees(p)

if (a*a*b)/2 <= x:
    ans = math.atan(2 * (a * a * b - x) / (a * a * a))
else:
    ans = PI/2 - math.atan((2*x) / (a*b*b))

print(radianToDegree(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()

{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;
	int start_index,last_index;
	cin>>s;
	for(int i=0;i<s.size();i++)

	{
		if(s[i]=='A')
		{
			start_index=i;
			break;
		}
	}
	
		for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='Z')
		{
          last_index=i; 
          break;
		}
	}
	cout << last_index-start_index+1<<"\n";
	
	
	
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

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

const int MAX_N = 100100;
ll N;
vector<ll> A;
int main() {
  cin >> N;
  A.resize(N);
  ll sum = 0;

  for (auto &val : A){
    cin >> val;
    sum += val;
  }
  ll val = N * (N + 1) / 2;
  if (sum % val != 0){
    cout << "NO" << endl;
    return 0;
  }
  vector<ll> diff;
  for (int i = 0; i < N; i++){
    ll x = A[i];
    ll y = A[(i + 1) % N];
    diff.emplace_back(y - x);
  }
  ll res = sum / val;
  int up = 0;
  for (int i = 0; i < N; i++){
    ll tmp = diff[i] - res;
    if (tmp > 0){
      cout << "NO" << endl;
      return 0;
    }
    if (abs(tmp) % N != 0){
      cout << "NO" << endl;
      return 0;
    }
    up += abs(tmp) / N;
    if (up > res){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>
long a[100000];

int main(int argc, char const *argv[]){
	long long x,y,p;
	scanf("%lld %lld\n",&x,&y);
	if(x>y){
		p=x-y;
	}else{
		p=y-x;
	}
	if(p>=2) printf("Alice\n");
	else printf("Brown\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n;
  string s;
  cin >> s;
  n = s.size();
  vi ans(n);
  rep(i,2){
    int cnt = 0;
    rep(j,n){
      if (s.at(j) == 'R') cnt++;
      else {
        ans.at(j) += cnt / 2;
        ans.at(j-1) += (cnt + 1) / 2;
        cnt = 0;
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(j,n){
      if (s.at(j) == 'L') s.at(j) = 'R';
      else s.at(j) = 'L';
    }
  }
  rep(i,n) printf("%d ", ans.at(i));
  printf("\n");
  return 0;
}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int arr[3][3];
bool vis[3][3]={0};

int main()
{
    fastio();
    int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n,greater<int>()); int alice=0,bob=0;
    for(int i=0;i<n;i++)
    {
        if(i%2) bob+=arr[i];
        else alice+=arr[i];
    }
    cout<<alice-bob;
    return 0;
}

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


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

    int N;
    cin >> N;
    int H[N];
    rep(i,N){
        cin >> H[i];
    }
    int ans=0;

    int i=0;
    int count=0;
    while(i<N-1){
        if(H[i]>=H[i+1]){
            count++;
        }
        else{
            ans=max(ans,count);
            count=0;
        }
        i++;
    }
    ans=max(ans,count);
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int H[N];
  REP(i,N)cin>>H[i];
  bool f=true;
  for(int i=N-2;i>=0;i--){
    if(H[i]>H[i+1])H[i]--;
    if(H[i]>H[i+1])f=false;
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    N, K = input_ints()
    A = input_int_list_in_line()

    for i in range(N-K):
        if A[i] < A[i+K]:
            print('Yes')
        else:
            print('No')


def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 31588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> A(n);
    if(a+b>n+1 || a*b<n){cout<<-1<<endl; return 0;}
    else if(a+b==n+1){
        for(int i=0;i<a;i++){A[i]=n-a+i+1;}
        for(ll i=a;i<n;i++){A[i]=n-a-(i-a);}
    }
    else{
        ll bef=n+1;
        for(ll i=0,t=0;i<n;t++){
            ll dist=min(n-i-(b-t-1),a);
            for(ll t=0;t<dist;t++){A[i+t]=bef-dist+t;}
            bef-=dist;
            i+=dist;
        }
    }
    for(int i=0;i<n;i++){
        cout<<A[i];
        if(i+1!=n){cout<<" ";}
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 4480
class Dice

  def initialize( given_ary )
    @ary = given_ary
  end

  def topface( val )
    4.times do
      self.roll( "E" )
      if self.top == val
        return
      end
    end
    3.times do
      self.roll( "N" )
      if self.top == val
        return
      end
    end
  end

  def frontface( val )
    4.times do
      tmp = @ary[1]
      @ary[1] = @ary[2]
      @ary[2] = @ary[4]
      @ary[4] = @ary[3]
      @ary[3] = tmp
      if @ary[1] == val
        return
      end
    end
  end

  def checkall( givendice )
    4.times do
      self.roll( "E" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    3.times do
      self.roll( "N" )
      4.times do
        tmp = @ary[1]
        @ary[1] = @ary[2]
        @ary[2] = @ary[4]
        @ary[4] = @ary[3]
        @ary[3] = tmp
        if identical( givendice )
          return true
        end
      end
    end
    return false
  end

  def roll( direction )
    case direction.downcase
    when "e"
      tmp = @ary[0]
      @ary[0] = @ary[3]
      @ary[3] = @ary[5]
      @ary[5] = @ary[2]
      @ary[2] = tmp
    when "w"
      tmp = @ary[0]
      @ary[0] = @ary[2]
      @ary[2] = @ary[5]
      @ary[5] = @ary[3]
      @ary[3] = tmp
    when "s"
      tmp = @ary[0]
      @ary[0] = @ary[4]
      @ary[4] = @ary[5]
      @ary[5] = @ary[1]
      @ary[1] = tmp
    when "n"
      tmp = @ary[0]
      @ary[0] = @ary[1]
      @ary[1] = @ary[5]
      @ary[5] = @ary[4]
      @ary[4] = tmp
    end
  end

  def top
    @ary[ 0 ]
  end

  def front
    @ary[ 5 ]
  end

  def right
    @ary[ 2 ]
  end

  def vals
    @ary
  end

  def compare( givendice )
    4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end
    3.times do
      self.roll( "N" )
      if identical( givendice )
        return true
      end
      4.times do
      self.roll( "E" )
      if identical( givendice )
        return true
      end
    end

    end
    false

  end

  def identical( givendice )
    @ary.zip( givendice.vals ).map{ | x, y | ( x - y ).abs }.inject(:+) == 0
  end

end


dice1 = Dice.new( gets.split.map(&:to_i) )
dice2 = Dice.new( gets.split.map(&:to_i) )
puts ( dice1.checkall( dice2 ) )? "Yes": "No"

Measured memory_bytes: 8812
#include<bits/stdc++.h>
using namespace std;
#define ff first.first
#define fs first.second
#define se second
int main(void)
{
	int h,w,n;
	char map[1001][1001];
	char map2[1001][1001];
	int xx,yy;
	int i,j,k,min,cnt,sx,sy;
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	
	cin>>h>>w>>n;
	
	for(i=0;i<h;i++) cin>>map[i];
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(map[i][j]=='S')
				sx=i,sy=j;
		}	
	}
	
	cnt=1,min=0;
	
	for(i=1;i<=n;i++){
	
		typedef pair<int,int>P;
		typedef pair<P,int>PP;
		queue<PP> que;
		
		for(j=0;j<h;j++)	strcpy(map2[j],map[j]);
		
		que.push(PP(P(sx,sy),0));
		
		while(!que.empty()){
				
			PP q=que.front(); 
				que.pop();

			if(map2[q.ff][q.fs]-'0'==i){
				min+=q.se;
				sx=q.ff,sy=q.fs;
				break;
			}	
			
			else{
				if(map2[q.ff][q.fs]!='X'){
					map2[q.ff][q.fs]='X';
					
					for(k=0;k<4;k++){
					
						xx=q.ff+dx[k];
						yy=q.fs+dy[k];
						
						if(map2[xx][yy]!='X'
							&&xx>=0&&yy>=0&&xx<h&&yy<w){
							que.push(PP(P(xx,yy),q.se+1));
						}	
					}
				}	
			}	
		}
	}	
	cout<<min<<endl;
	
	return 0;
}			


Measured memory_bytes: 5068
import java.io.*;

public class Main {

  static boolean checkKaibun(String str){
    StringBuilder t = new StringBuilder(str);
    return (str.equals(t.reverse().toString()));
  }

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String s = br.readLine();

    br.close();

    int n = s.length();
    boolean ok = checkKaibun(s);
    ok &= checkKaibun(s.substring(0, (n-1)/2));
    ok &= checkKaibun(s.substring((n+1)/2));

    System.out.println(ok ? "Yes" : "No");
    
  }
}

Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, k;
    cin >> n >> k;
    int max_num = 0;
    if ( n % 2 == 1 ) max_num = ( n + 1 ) / 2;
    else              max_num = n / 2; 
    if ( max_num >= k ) cout << "YES" << endl;
    else                cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main() {
    int n;
    string s;
    cin >> n >> s;
    int a = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') ++a;
        else ++b;
    }   
    if (a > b) {
        cout << "Yes\n";
    }   
    else {
        cout << "No\n";
    }   
}   

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {

  def pow(x:Long, y:Long, z:Long):Long = {

    def multi(m:Long, n:Long) = { ( (m%z) * (n%z) ) % z }

    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => multi(m, odd)
        case _ =>
          pow2(multi(m,m), n/2, (if(n%2==1) multi(odd, b) else odd), multi(b,b))
      }
    }
    pow2(x, y, 1, x)
  }

  def main(args: Array[String]) = {
    val l = readLine().split(" ").map(_.toLong)
    val (m, n) = (l(0), l(1))
    println(pow(m,n,1000000007))
  }
}

Measured memory_bytes: 43720
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int L = scan.nextInt();
		
		String[] moji = new String[N];
		
		for(int i = 0;i<N;i++){
			moji[i] = scan.next();
		}
		
		Arrays.sort(moji);
		
		StringBuilder sb = new StringBuilder();
		
		for(int j = 0;j<N;j++){
			sb.append(moji[j]);
		}
		
		System.out.println(sb.toString());
		
		
		
		
	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define int long long
const int N = 3e5 + 2334;
int sum[N], sub[N], pos[N];
int ans, n, L;

inline int get(int *s, int l, int r) {
  if (l > r) return 0;
  return s[r] - s[l - 1];
}

inline int doit() {
  int ans = 0;
  rep (i, n) sum[i] = sum[i - 1] + pos[i], sub[i] = sub[i - 1] + L - pos[i];
  for (int cut = 1; cut <= n; cut ++) {
    int now = 2 * pos[cut - 1];
    int res_num = n - cut + 1;
    int id = res_num & 1 ? res_num / 2 + 1 : res_num / 2;
    id += cut - 1;
    // cout << id << " " << now << " " << (get(sum, cut, id - 1) + get(sub, id, n)) * 2 << " " << res_num << "\n";
    if (res_num & 1) {
      now += get(sum, cut, id - 1) * 2
        + get(sub, id, n) * 2 - (L - pos[id]);
    } else {
      now += get(sum, cut, id) * 2
        + get(sub, id + 1, n) * 2 - pos[id];
    }
    // cout << cut << " " << now << "\n";
    ans = max(ans, now);
  }
  return ans;
}

signed main(void) {
  read(L); read(n);
  rep (i, n) read(pos[i]);
  ans = max(ans, doit());
  rep (i, n) pos[i] = L - pos[i];
  reverse(pos + 1, pos + n + 1);
  ans = max(ans, doit());
  cout << ans << "\n";
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int ans=0;
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    ans+=x;
    if(ans>N){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << N-ans << endl;
}

Measured memory_bytes: 3548
#ifndef ___Class_RMQ
#define ___Class_RMQ

#include <vector>
#include <algorithm>

template <typename Type, class Calculate> class RMQ
{
private:

	int size;

	std::vector<Type> value;

	Type _query(int a, int b, int k, int l, int r)
	{
		if (r <= a || b <= l) { return val; }
		if (a <= l && r <= b) { return value[k]; }

		Type vl = _query(a, b, 2 * k, l, (l + r) / 2);
		Type vr = _query(a, b, 2 * k + 1, (l + r) / 2, r);

		return Calculate()(vl, vr);
	}

public:

	Type val;

	RMQ(int size_, int val_) : val(val_)
	{
		for (size = 1; size < size_;) { size <<= 1; }

		value = std::vector<Type>(size * 2, val);
	}

	void update(int i, const Type& x)
	{
		i += size; value[i] += x;

		while (i > 1) { i = i / 2; value[i] = Calculate()(value[2 * i], value[2 * i + 1]); }
	}

	Type query(int s, int t) { return _query(s, t, 1, 0, size); }
};

#endif


// ------ main ------ //

#include <cstdio>
#include <functional>

#pragma warning(disable: 4996)

int n, q, com, x, y;

int main()
{
	scanf("%d", &n);
	scanf("%d", &q);

	RMQ<long long, std::plus<long long> > r(n, 0);

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &com);
		scanf("%d", &x);
		scanf("%d", &y);

		if (com == 0)
		{
			r.update(x - 1, y);
		}
		if (com == 1)
		{
			printf("%lld\n", r.query(x - 1, y));
		}
	}

	return 0;
}

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

class Box{
public:
  Box();
  void input_v(int i,int v);
  void input_c(int i,int c);
  void cal(int n);
  int output() const;
private:
  char mv[100];
  char mc[100];
  char mmargin[100];
  int mans;
};

Box::Box():mans(0){};

void Box::input_v(int i,int v){
  mv[i]=v;
}

void Box::input_c(int i,int c){
  mc[i]=c;
}

void Box::cal(int n){
  for(int i=0;i<n;i++){
    mmargin[i]=mv[i]-mc[i];
    if(mmargin[i]>0) mans += mmargin[i];
  }
}

int Box::output() const {
  return mans;
}

int main()
{
  int i,n,v,c;
  cin >> n;
  Box box;

  for(i=0;i<n;i++){
    cin>>v;
    box.input_v(i,v);
  }

  for(i=0;i<n;i++){
    cin>>c;
    box.input_c(i,c);
  }

  box.cal(n);

  cout<<box.output()<<endl;

}


Measured memory_bytes: 256
import bisect

N = int(input())

L = []
for i in range(N):
    a,b = map(int, input().split())
    L.append([b,a])
L.sort()

Sum = 0

for i in range(N):
    Sum = Sum + L[i][1]
    if Sum <= L[i][0]:
        continue
    else:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 35620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	int n, r;
	cin >> n >> r;
	if (n >= 10)
		cout << r << "\n";
	else
		cout << r + (10 - n) * 100 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<pii> v, w;
	REP(i, n)
	{
		int a, b; cin >> a >> b;
		v.emplace_back(a, b);
	}
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		w.emplace_back(a, b);
	}
	REP(i, n)
	{
		int res = -1, dist = 1e9;
		REP(j, m)
		{
			int d = abs(v[i].first - w[j].first) + abs(v[i].second - w[j].second);
			if (d < dist)
			{
				res = j + 1;
				dist = d;
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_F

0-1 ???????????¶???????????? II
????????? vi ????????? wi ??§??????????????? N ??????????????¨???????????? W ??????????????¶?????????????????????????¬?????????¶?????????????????????????????????????????§???????????¶???????????\????????????

???????????????????????????????¨??????§???????????????????????????
???????????????????????????????????? W ????¶?????????????
?????????????¨?????????§???????±??????????????????????

??\???
???????????????????????´??°???N???W???????????????????????§?????????????????????????????? ?¶???? N ?????§ i ???????????????????????? vi ??¨?????? wi ????????????????????§?????????????????????

??????
?????????????¨?????????§??????????????????????????????????????????

??¶?´?
1 ??? N ??? 100
1 ??? vi ??? 100
1 ??? wi ??? 10,000,000
1 ??? W ??? 1,000,000,000
??\?????????

??\?????? 1
4 5
4 2
5 2
2 1
8 3
????????? 1
13

??\?????? 2
2 20
5 9
4 10
????????? 2
9
 */
public class Main {
    public static class Solver {
        public int solve(int W, List<Integer> values, List<Integer> weights) {
            int V = values.stream().reduce((res, ele) -> res + ele).get();
            int[] dp = new int[V + 1];
            for (int i = 1; i <= V; ++i) {
                dp[i] = Integer.MAX_VALUE;
            }
            for (int i = 1; i <= values.size(); ++i) {
                for (int j = V; j >= 0; --j) {
                    int v = values.get(i - 1);
                    int w = weights.get(i - 1);
                    if (j - v >= 0 && dp[j - v] != Integer.MAX_VALUE) {
                        dp[j] = Math.min(dp[j], dp[j - v] + w);
                    }
                }
            }
            int ret = 0;
            for (int i = 0; i <= V; ++i) {
                if (dp[i] == Integer.MAX_VALUE || dp[i] > W) {
                    continue;
                }
                if (i > ret) {
                    ret = i;
                }
            }
            return ret;
        }
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> weights = new ArrayList<>();
        List<Integer> values = new ArrayList<>();
        List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                .collect(Collectors.toList());
        final int N = NW.get(0);
        final int W = NW.get(1);
        for (int i = 0; i < N; ++i) {
            List<Integer> collect = Stream.of(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                    .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new Solver().solve(W, values, weights));
    }
}

Measured memory_bytes: 33268
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 1000000000
int change(int c[],int n, int m)
{
  int table[n+1];
  for(int j=0;j<=n;j++) table[j]=INF;
  table[0]=0;
  for(int i = 0; i < m; i++)
    for(int j = c[i] ; j <= n; j++)
      table[j] = min(table[j],table[j-c[i]]+1);
      
  return table[n];
}

int main(){
  int n, m;
  cin >> n >> m;
  int data[m];
  for(int i = 0; i < m; i++) cin >> data[i];
  cout << change(data,n,m) << endl;
  return 0;
}


Measured memory_bytes: 3272