akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main() {
    ll a,n,ans = INF;
    cin >> n;
    rep(i,5){
        cin >> a;
        chmin(ans,a);
    }
    PRINT((n-1)/ans+5);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main()
{
	std::vector<int>result;
	for (int d; std::cin >> d;)
	{
		result.push_back(0);
		for (int i = d; i < 600; i += d)
		{
			result.back() += i * i * d;
		}
	}
	for (auto i : result)
	{
		std::cout << i << std::endl;
	}
	return 0;
}


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

int main(){
    int a,b;
    while(cin>>a>>b){
        for ( int i = 0; i < a; i++ ){
            for ( int j = 0; j < b; j++ ){
		if(i==0||i==a-1||j==0||j==b-1){
		cout<<"#";
		}else{
		cout<<".";
		}
            }
            cout << endl;
        }
        if(a==0&&b==0){
            return 0;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

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

    long long total = 0;
    int i = 1;
    while(1){
        total += i;
        if(x <= total) break;
        else i++;
    }
    cout << i << endl;


    return 0;
}

Measured memory_bytes: 256
s = input()
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    print(i+1, i+2)
    break
  if i < len(s) - 2:
    if s[i] == s[i+2]:
      print(i+1, i+3)
      break
  if i == len(s) - 2:
    print(-1, -1)

Measured memory_bytes: 3188
typedef struct{double x,y,k;}w;w p[101],b;m,v[100],n,j;z(w*c,w*d){return c->k>d->k?-1:c->k<d->k;}double o(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(i){double k,t;for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;*p=b;p[100].x=b.x;p[100].y=b.y+1;for(i=1;i<n;i++){k=o(0,i,100);t=(p[i].x-b.x)*(p[i].x-b.x)+(p[i].y-b.y)*(p[i].y-b.y);k*=k/t;if(b.x>p[i].x)k=-k;p[i].k=k;}qsort(p+1,n-1,sizeof(w),z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

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

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N+1);
  for (int i = 0; i < N+1; i++) cin >> A.at(i);
  vector<long long> num_vertex(N+1, 1);
  num_vertex.at(N) = A.at(N);
  for (int i = N-1; i > 0; i--) num_vertex.at(i) = num_vertex.at(i+1) + A.at(i);
  long long from_root = 1;
  bool exist_ans = true;
  int index = -1;
  for (int i = 1; i < N+1; i++)
  {
    from_root = 2*(from_root - A.at(i-1));
    if (from_root <= 0)
    {
      exist_ans = false;
      break;
    }
    if (from_root < num_vertex.at(i)) num_vertex.at(i) = from_root;
    else
    {
      index = i;
      break;
    }
    if (i == N) exist_ans = false;
  }
  if (N == 0)
  {
    if (A.at(0) != 1) cout << -1 << endl;
    else cout << 1 << endl;
  }
  else if (exist_ans)
  {
    if (index != -1)
    {
      for (int i = index; i > 0; i--)
      {
        if (num_vertex.at(i) < num_vertex.at(i-1) - A.at(i-1))
        {
          num_vertex.at(i-1) = num_vertex.at(i) + A.at(i-1);
        }
        else break;
      }
    }
    long long ans = 0;
    for (int i = 0; i < N+1; i++)
    {
      ans += num_vertex.at(i);
    }
    cout << ans << endl;
  }
  else cout << -1 << endl;
}


Measured memory_bytes: 4792
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
out = [0] * N
L = []
for i in range(N-1):
  for j in range(i+1, N):
    out[min(j-i, abs(i-X)+1+abs(j-Y))] += 1
for i in range(1, N):
  print(out[i])

Measured memory_bytes: 46044
package main

import "fmt"

func main() {
	var n, q int
	fmt.Scan(&n, &q)
	var str string
	fmt.Scan(&str)
	arr := make([]int, n)
	flg := false
	count := 0
	for j, i := range str {
		s := string(i)
		if s == "A" {
			flg = true
		} else if s == "C" && flg {
			count++
			flg = false
		} else {
			flg = false
		}
		arr[j] = count
	}
	for i := 0; i < q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(arr[r - 1] - arr[l - 1])
	}
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s,t;
    while(cin >> s) {
        t = "";
        for(auto c : s) {
            if(c == '0' || c == '1')
                t.push_back(c);
            else if(!t.empty())
                t.pop_back();
        }
        cout << t << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#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;
  vector<pair<int,int> > v;
  REP(i,N){
    int A;
    cin>>A;
    v.push_back(make_pair(A,i+1));
  }
  sort(ALL(v));
  REP(i,N)cout<<v[i].second<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1780
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    d = defaultdict(lambda : 0)
    alp = list("abcdefghijklmnopqrstuvwxyz")
    f = {}
    for i in range(26):
        f[alp[i]] = i+1
    for i in range(2*n):
        s[i] = f[s[i]]
    for i in range(n>>1):
        s[i],s[n-i-1] = s[n-i-1],s[i]
    k = 27
    m = 1<<n
    p = [1<<j for j in range(n)]
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j]
            else:
                b *= k
                b += s[j]
        d[(r,b)] += 1
    ans = 0
    for i in range(m):
        r = 0
        b = 0
        for j in range(n):
            if i&p[j]:
                r *= k
                r += s[j+n]
            else:
                b *= k
                b += s[j+n]
        ans += d[(r,b)]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 102028
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N, a[100], cnt=0;
    cin >> N;
    REP(i,N){
        cin >> a[i];
        if((i+1)%2==1 && a[i]%2==1){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;  
}


Measured memory_bytes: 3632
n, k = map(int, input().split())
s = input()

cnt = [0, 0]
for i in range(n - 1):
    if s[i] == s[i+1]:
        cnt[0] += 1
    else:
        cnt[1] += 1

print(cnt[0] + min(2 * k, cnt[1]))


Measured memory_bytes: 3316
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  !assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  !numberOfElements <- VM.replicate n 1

  !rank <- VM.replicate n (0 :: Int)

  let getRoot !i xs = do
        !j <- VM.read assocs i
        if i == j
          then forM_ xs (\l -> VM.write assocs l i) >> return i
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify i j = do
        !i' <- getRoot i []
        !j' <- getRoot j []
        if i' == j'
          then return 0
          else do
          !ri <- VM.read rank i'
          !rj <- VM.read rank j'
          !k <- case compare ri rj of
                  EQ -> do VM.write rank i' (ri + 1)
                           return i'
                  LT -> return j'
                  GT -> return i'
          VM.write assocs i' k
          VM.write assocs j' k
          !n1 <- VM.read numberOfElements i'
          !n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  !result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

main = do
  [n,m] <- map read . words <$> getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    [a,b] <- map read . words <$> getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 7036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    char ss[128];
    ss['A'] = 'T';
    ss['T'] = 'A';
    ss['C'] = 'G';
    ss['G'] = 'C';
    cout << ss[c] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   priority_queue<int> pq;
   int x, y, a , b, c;
   cin >> x >> y >> a >> b >> c;
   vector<int> ad(a);
   vector<int> bd(b);
   vector<int> cd(c);
   long long sum = 0;
   for(int i = 0; i < a; i++)
      cin >> ad[i];
   for(int i = 0; i < b; i++)
      cin >> bd[i];
   for(int i = 0; i < c; i++)
      cin >> cd[i];
   sort(ad.rbegin(), ad.rend());
   sort(bd.rbegin(),bd.rend());
   for(int i = 0; i < x; i++)
      pq.push(ad[i]);
   for(int i=0; i < y; i++)
      pq.push(bd[i]);
   for(int i = 0; i < c; i++)
      pq.push(cd[i]);
   for(int i = 0; i< x+y; i++)
   {
      sum += pq.top();
      pq.pop();
   }


   cout << sum << endl;



}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  int N, ans = 0;
  cin >> N;
  
  vector<int> p(N);
  
  for (int i = 0 ; i < N ; i++)
    cin >> p.at(i);
  
  sort(p.begin(),p.end());
  
  for (int i = 0 ; i < p.size() ; i++){
    if (i == p.size() - 1){
      ans += p.at(i) / 2;
      //cout << "half: " << p.at(i) << endl;
    }
    else{
      ans += p.at(i);
      //cout << "teika:" << p.at(i) << endl;
    }
  }
  
  cout << ans << endl;
    
  
}

Measured memory_bytes: 256
import numpy as np
from collections import defaultdict
from functools import reduce

s = input()
N = len(s)
old_idx = 0
res = 0

lis = []

i = 0
while i < N:
    if s[i] == 'A':
        cnt = 1
        while i + cnt < N and s[i+cnt] == 'A':
            cnt += 1
        lis.append((s[i], cnt))
        i += cnt
    else:
        lis.append((s[i], 1))
        i += 1

lisN = len(lis)

i = 0
while i < lisN-2:
    if lis[i][0] == 'A' and lis[i+1][0] == 'A':
        lis[i+1] = ('A', lis[i][1]+lis[i+1][1])
        # print(lis)
    if lis[i][0] == 'A' and lis[i+1][0] == 'B' and lis[i+2][0] == 'C':
        res += lis[i][1]
        lis[i+2] = ('A', lis[i][1])
        lis[i] = ('B', 1)
        lis[i+1] = ('C', 1)
        # print(lis)

    i += 1

print(res)


Measured memory_bytes: 26852
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    double ps[n];
    for (int i = 0; i < n; i++) {
        cin >> ps[i];
    }
    double dp[n + 1][n + 1] = {};
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - ps[i - 1]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - ps[i - 1]) + dp[i - 1][j - 1] * ps[i - 1];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dp[n][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 70656
# ABC154D

def f(n, k, p):
    p = [(i+1)/2 for i in p]
    sums = sum(p[:k])
    mx = sums
    for i in range(k, n):
        sums = sums - p[i - k] + p[i]
        # print(f"sums = {sums}")
        if sums > mx:
            mx = sums
    print(mx)

n, k = map(int, input().split())
p = list(map(int, input().split()))
f(n, k, p)


Measured memory_bytes: 32156
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 文字列 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 1以外の数字・位置 - 取得
	char lcNum;
	int liNNo;
	for (i = 0; ; i++) {
		if (lc1Buf[i] != '1') {
			lcNum = lc1Buf[i];
			liNNo = i + 1;
			break;
		}
	}

	// 出力位置 - 取得
	long long llONo;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld", &llONo);

	// 結果 - セット
	if (llONo < (long long)liNNo) {
		sprintf(lc1Out, "1\n");
	}
	else {
		sprintf(lc1Out, "%c\n", lcNum);
	}

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
def round_up_the_mean(a: int, b: int) -> int:
    return (a + b) // 2 if (a + b) % 2 == 0 else (a + b) // 2 + 1


if __name__ == "__main__":
    a, b = map(int, input().split())
    ans = round_up_the_mean(a, b)
    print(ans)


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



int main(){
  string S;
  cin >> S;

  long ans = 0;
  long b_n = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'B'){
      b_n++;
    } else {
      ans += b_n;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {

    ll N;
    cin >> N;
    ll count = 0;
    ll currentIndex = 1;
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp != currentIndex){
            currentIndex--;
            count++;
        }
        currentIndex++;
    }
    if(count == N){
        cout << "-1" << endl;
        return 0;
    }
    cout << count << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
int mod_pow(int x, int n, int mod) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = ((ll)res * x)%mod;
		x = ((ll)(x)*x)%mod;
		n >>= 1;
	}
	return res;
}
signed main() {
	int n, c;
	scanf("%d %d", &n, &c);
	vector<ll> a(n+1), b(n+1);
	REP(i, n) {
		scanf("%lld", &a[i]);
	}
	REP(i, n) {
		scanf("%lld", &b[i]);
	}

	ll dp[402][402] = {};
	dp[0][0] = 1;
	ll table[401][401] = {};
	REP(i, n) {
		REP(j, 401) {
			rep(l, a[i], b[i] + 1) {
				table[i][j] += mod_pow(l, j, MODU);
				table[i][j] %= MODU;
			}
		}
	}
	REP(i, n) {
		REP(j, c+1) {
			REP(k, j+1) {
					dp[i + 1][j] += dp[i][k] * table[i][j-k];
					dp[i + 1][j] %= MODU;
				
			}
		}
	}
	printf("%lld\n", dp[n][c]);
	return 0;
}

Measured memory_bytes: 2816
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back
#define FILE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1e9 + 7;


int main(){
    char x;
    cin>>x;
    cout<< (char)(x+1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

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

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

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

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

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

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {

  string s;
  cin >> s;
  ll a = 0;
  for(int i = 0;i < s.size();i++){
     if(s[i] == '1') a++;
  }
  cout << a << endl;
    
/*
  ll n,k;
  cin >> n >> k;
  vector<ll> x(n+1);
  vector<ll> sub(n);
  for(int i = 0;i < n;i++){
      cin >> x[i];
  }
  if(n == 1){
      cout << abs(x[0]) << endl;
      return;
  } 
  x[n] = 0;
  sort(x.begin(),x.end());
  for(int i = 0;i < n;i++){
      sub[i] = x[i+1]-x[i];
  }
  vector<ll> right(n);
  right[0] = sub[0];
  for(int i = 1;i < n;i++){
      right[i] = right[i-1]+sub[i];
  }

  ll ans = right[k-1];
  for(int i = 0;i < n-k;i++){
      ans = min(ans,right[i+k]-right[i]);
  }
  cout << ans << endl;
  */
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int m=s.nextInt();
		int k=s.nextInt();

		UF uf=new UF(n);
		HashMap<Integer,HashSet<Integer>>map=new HashMap<>(n);
		for(int i=0;i<m;++i) {
			int a=s.nextInt()-1;
			int b=s.nextInt()-1;
			map.computeIfAbsent(a,o->new HashSet<>(1)).add(b);
			map.computeIfAbsent(b,o->new HashSet<>(1)).add(a);
			uf.connect(a,b);
		}
		for(int i=0;i<k;++i) {
			int a=s.nextInt()-1;
			int b=s.nextInt()-1;
			map.computeIfAbsent(a,o->new HashSet<>(1)).add(b);
			map.computeIfAbsent(b,o->new HashSet<>(1)).add(a);
		}

		HashSet<Integer>empty=new HashSet<>(0);
		StringJoiner sj=new StringJoiner(" ");
		for(int i=0;i<n;++i) {
			int sum=uf.groupSize(i)-1;
			for(int o:map.getOrDefault(i,empty)) {
				if(uf.isConnected(i,o))
					--sum;
			}
			sj.add(String.valueOf(sum));
		}
		System.out.println(sj);
	}
}
class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int p,int c){
		p=root(p);
		c=root(c);
		if(p==c)
			return false;
		if(a[p]>a[c]){
			int buf=c;
			c=p;
			p=buf;
		}
		a[p]+=a[c];
		a[c]=p;
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

Measured memory_bytes: 203636
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

long a[100000] = {};

int main()
{
	int n;
	long max1 = 0, max2 = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	//
	//
	//
	for (int i = 0; i < n; i++)
	{
		if (a[i] == a[i + 1])
		{
			if (max1 < a[i] && max2 < a[i])
			{
				max1 = a[i];
			}
			else if (max1 >= a[i] && a[i] > max2)
			{
				max2 = a[i];
			}
			i++;
		}
	}
	ans = max1 * max2;
	cout << ans;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N;
vector<ll> A, B, C;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  sort(B.begin(), B.end());
  C.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  sort(C.begin(), C.end());

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll b = B[i];
    ll a_pos = lower_bound(A.begin(), A.end(), b) - A.begin();
    ll c_pos = upper_bound(C.begin(), C.end(), b) - C.begin();
    if (a_pos == 0 || c_pos == N) {
      continue;
    }
    ans += (a_pos * (N - c_pos));
  }

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

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

int main() {
    string s;
    cin >> s;
    int res = 0;
    for(int i = 0; i < (int)((s.size() / 2) + (s.size() % 2)); i++){
        if(s[i] != s[s.size() - 1 - i]) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


/*
           1) long long vs int overflow
           2) read question carefully
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a;i <= b; i++)

#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap 
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not



*/
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int inf = 1e9 + 7;

int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n , m;
    cin >> n >> m;
    map<int,bool> ac;
    map<int, int> pen;
    for(int i = 0; i < m; i++){
        int pn; string ver;
        cin >> pn >> ver;
        if(ac.count(pn)) continue;
        else{
            if(ver != "AC"){
                pen[pn]++;
            } else{
                ac[pn] = 1;
            }
        }
    }
    int c = ac.size(), pena = 0;
    for(auto x : ac){
        int pn = x.fi;
        pena += pen[pn];
    }
    cout << c << " " << pena << '\n';
}

Measured memory_bytes: 9600
a,b,c,d,e,f=map(int, input().split())
x,y,z=100*a,0,0
for i in range(31):
    for j in range(31):
        mizu=(a*i+b*j)*100
        if mizu==0 or mizu>f:break
        for k in range(int((f-mizu)//c)+1):
            for l in range(int((f-mizu)//d)+1):
                sato=c*k+d*l
                noudo=100*sato/(mizu+sato)
                if mizu+sato>f or mizu/100*e<sato:break
                if noudo>z: z,x,y = noudo,mizu+sato,sato
print(x,y)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  string n;
  cin >> n;
  cout << "ABC" + n << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner stdIn=new Scanner(System.in);
        int a=stdIn.nextInt();
        int b=stdIn.nextInt();
        int c=stdIn.nextInt();
        if(a<b&&b<c){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  int A[N+2] = {};
  int64_t ans1 = 0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    ans1 += abs(A[i] - A[i-1]);
  }
  ans1 += abs(A[N+1]-A[N]);
  for(int i=1;i<=N;i++){
    int64_t ans = ans1;
    ans -= abs(A[i]-A[i-1]) + abs(A[i+1]-A[i]);
    ans += abs(A[i+1] - A[i-1]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
#include<stdio.h>
main(){
  int s=0;
  int H=0;
  int M=0;
  scanf("%d",&s);
  while(s>3599){
    s=s-3600;
    H++;
  }
  while(s>59){
    s=s-60;
    M++;
  }
  printf("%d:%d:%d\n",H,M,s);
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int A[N];
	rep(i, N) cin >> A[i];
	int B[N];
	rep(i, N) B[i] = A[i] - i - 1;
	sort(B, B + N);
	int ans = 0;
	rep(i, N) ans += abs(B[i] - B[(N - 1) / 2]);

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#![allow(non_snake_case, dead_code)]

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

struct UnionFind {
    size: usize,
    pos: Vec<isize>,
}
impl UnionFind {
    fn new(n: usize) -> Self {
        let size = n;
        let pos = vec![-1; n + 1];
        UnionFind { size, pos }
    }
    fn find(&mut self, x: usize) -> usize {
        if self.pos[x] < 0 {
            x
        } else {
            let v = self.pos[x] as usize;
            self.pos[x] = self.find(v) as isize;
            self.pos[x] as usize
        }
    }
    fn unite(&mut self, x: usize, y: usize) -> Result<(), ()> {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            return Err(());
        };
        if self.pos[x] > self.pos[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.pos[x] += self.pos[y];
        self.pos[y] = x as isize;
        Ok(())
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
    fn size(&mut self, x: usize) -> usize {
        let x = self.find(x);
        -self.pos[x] as usize
    }
}


fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let W: usize = sc.read();
        let H: usize = sc.read();
        if W == 0 { break; };
        let mut g = vec![vec![0i32; W]; H];
        for i in 0..H {
            for j in 0..W {
                g[i][j] = sc.read();
            }
        }
        let mut uf = UnionFind::new(H*W);
        for i in 0..H {
            for j in 0..W {
                if g[i][j] == 0 { continue; };
                if j < W - 1 && g[i][j+1] > 0 {
                    uf.unite(i*W + j, i*W + j + 1).ok();
                }
                if i + 1 < H && g[i+1][j] > 0 {
                    uf.unite(i*W + j, i*W + j + W).ok();
                }
                if i + 1 < H && j + 1 < W && g[i+1][j+1] > 0 {
                    uf.unite(i*W + j, i*W + j + 1 + W).ok();
                }
                if i > 0 && j + 1 < W && g[i-1][j+1] > 0 {
                    uf.unite(i*W + j, i*W + j + 1 - W).ok();
                }
            }
        }
        let mut cnt = 0;
        for i in 0..H {
            for j in 0..W {
                if g[i][j] > 0 && uf.find(i*W + j) == i*W + j {
                    cnt += 1;
                }
            }
        }
        println!("{}", cnt);
    }
}



Measured memory_bytes: 5044
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L = LIST()
print("Yes" if len(set(L))==2 else "No")

Measured memory_bytes: 5148
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct edge{int nx,t;}e[MN+5];
int h[MN+5],en,d[MN+5],k,ans;
inline void ins(int x,int y){e[++en]=(edge){h[x],y};h[x]=en;}
void dfs(int x,int fa)
{
	for(int i=h[x];i;i=e[i].nx)
		dfs(e[i].t,x),d[x]=max(d[x],d[e[i].t]); 
	if(fa>1&&++d[x]==k)++ans,d[x]=0;
}
int main()
{
	int n,i;
	n=read();k=read();ans=read()>1;
	for(i=2;i<=n;++i)ins(read(),i);
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> l(2*n);
  for(int i=0;i<2*n;i++) cin >> l[i];

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

  int cnt=0;
  for(int i=0;i<2*n;i+=2){
    cnt += min(l[i],l[i+1]);
    // cout << cnt << endl;
  }
  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a, h, m, s;

  scanf("%d", &a);

  h = a / 3600;
  m = a % 3600 / 60;
  s = a % 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int cnt=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
        {
            cnt++;
        }
    }
    cout<<cnt+1;
    return 0;
}


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

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



Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {

        int[] A = new int[MAX];
        int n = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++) {
            A[i] = int.Parse(inpt[i]);
        }
        long ans = this.MergeSort(A, n, 0, n);
        Console.WriteLine(ans);
    }

    private long Merge(int[] A, int n, int left, int mid, int right)
    {
        long cnt = 0;
        int n1 = mid - left;
        int n2 = right - mid;
        for (int i = 0; i < n1; i++)
        {
            this.L[i] = A[left + i]; 
        }
        for (int i = 0; i < n2; i++)
        {
            this.R[i] = A[mid + i];
        }
        this.L[n1] = SENTINEL;
        this.R[n2] = SENTINEL;
        int j = 0;
        int k = 0;
        for (int i = left; i < right; i++)
        {
            if (this.L[j] <= this.R[k])
            {
                A[i] = this.L[j++];
            }
            else
            {
                A[i] = this.R[k++];
                cnt += (n1 - j);
            }
        }
        return cnt;
    }

    private long MergeSort(int[] A, int n, int left, int right) {
        int mid;
        long v1, v2, v3;
        if (left + 1 < right)
        {
            mid = (left + right) / 2;
            v1 = this.MergeSort(A, n, left, mid);
            v2 = this.MergeSort(A, n, mid, right);
            v3 = this.Merge(A, n, left, mid, right);
            return v1 + v2 + v3;
        }
        else
        {
            return 0;
        }
    }

    private const int MAX = 200000;
    private const int SENTINEL = int.MaxValue;
    private int[] L = new int[MAX / 2 + 2];
    private int[] R = new int[MAX / 2 + 2];


    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 25924
#include <stdio.h>

int main(int argc, char *args[])
{
	int n,x;
	int count;

	int a,b,c;


	while(1) {

		count = 0;

		scanf("%d %d", &n, &x);

		if( n == 0 && x == 0 ) {
			break;
		}

		for( a=1; a<=n-2; a++ ) {
			for( b=a+1; b<=n-1; b++ ) {
				for( c=b+1; c<=n; c++ ) {
					if( a+b+c == x ) {
						count++;
					}
				}
			}
		}

		printf("%d\n", count);

	}
	

	return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int a[200005];
    vector<pii> vec;
    reps(i,n){
      cin >> a[i];
      vec.emplace_back(a[i],i);  
    }

    sort(all(vec),greater<pii>());
    reps(i,n){
      if(vec[0].se == i){
	cout << vec[1].fi << '\n';
      } else {
	cout << vec[0].fi << '\n';
      }
    }
    return 0;
}


Measured memory_bytes: 4080
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i32; n],
    }
    let mut mx: i32 = a[0];
    let mut sum: i64 = 0;
    for i in 1usize..n {
        if a[i] < mx {
            sum += (mx - a[i]) as i64;
        } else {
            mx = a[i];
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4696
a, b, c, d = map(int, raw_input().split())

s = 0
on_a = 0
on_b = 0
for i in range(101):
    if i == a:
        on_a = 1
    if i == b:
        on_a = 0
    if i == c:
        on_b = 1
    if i == d:
        on_b = 0
#    print(i, on_a, on_b)
    if on_a and on_b:
        s += 1

print(s)


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
string s;
int a,b,c,n;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    vector<int>q(n);
    int s = 0;
    map<int,int>maps;
    f(i,0,n){
        cin >> q[i];
        s += q[i];
        maps[q[i]]++;
    }
    cin >> a;
    f(i,0,a){
        cin >> b >> c;
        // cout << s << "\n";
        s = s - maps[b]*b + (maps[b]*c);
        // int r = maps[b];
        // maps[c] += maps[b];

        // cout << s << " g \n";
        maps[c] += maps[b];
        maps.erase(b);

        // s += (maps[c]-r)*c;
        cout << s << "\n";
    }
    return 0;
}
 

Measured memory_bytes: 7948
/* 2018-01-07-17.30.16 */

#include<bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;

int main()
{
    int n,i;
    scanf("%d",&n);
    bool marked[N];
    for(i=0;i<=N;i++) marked[i]=false;
    int cnt=0;
    for(i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(!marked[x]) marked[x]=true,cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int     main() {
        int N;
        cin >>N;
        vector<long> A(N);
        for (int i=0; i<N; i++)
                cin >> A.at(i);
        sort(A.begin(), A.end());
        int S=1;
        long ss=A.at(0);
        for (int i=1; i<N; i++) {
                if (ss*2>=A.at(i))
                        S++;
                else
                        S=1;
                ss += A.at(i);
        }
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 1024
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int mod = 1e9+7;

int h , w;
int x , y;


int main(){
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10) << (1.000 * w * h) / 2 << " ";
    if(w % 2 == 0 && h % 2 == 0 && x == w/2 && y == h/2){
        cout << 1;
    } else {
        cout << 0;
    }

}

Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
d=[0]*-~n
for i in range(1,n+1):
 for j,k in zip((1,2,3,4,5,6,7,8,9),(2,5,5,4,5,6,3,7,6)):
  if j in a and i-k>=0and(i-k<1or d[i-k]):d[i]=max(d[i],d[i-k]*10+j)
print(d[n])

Measured memory_bytes: 51036
n = int(input())
A = list(map(int, input().split()))


# MAX = 200000
SENTINEL = 10 ** 9 + 1
# L = [0] * (MAX // 2 + 2)
# R = [0] * (MAX // 2 + 2)

L = [0] * (n // 2 + 2)
R = [0] * (n // 2 + 2)

def merge(A, left, mid, right):
	global cnt
	n1 = mid - left
	n2 = right - mid
	for i in range(n1):	L[i] = A[left + i]
	for i in range(n2): R[i] = A[mid + i]
	L[n1], R[n2] = SENTINEL, SENTINEL
	i, j = 0, 0
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
			cnt += n1 - i # = mid + j - k - 1
	return cnt

def merge_sort(A, left, right):
	# n = len(A)
	if left + 1 < right:
		mid = (left + right) // 2
		v1 = merge_sort(A, left, mid)
		v2 = merge_sort(A, mid, right)
		v3 = merge(A, left, mid, right)
		return v1 + v2 + v3
	else:
		return 0
	return 

cnt = 0
# print(A)
merge_sort(A, 0, n)
# print(A)
print(cnt)


Measured memory_bytes: 27480
number = int(input())
word = list(input())
judge = 'Yes'
            
if number%2 == 1:
	judge = 'No'
    
else:
	for i in range(int(number/2)):
		if word[i] != word[int(number/2 + i)]:
			judge = 'No'

print(judge)    

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

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

言うまでもなく、先頭と末尾の間に挟まれる文字の数は文字列の長さ-2である
終わり B問題にしては簡単すぎるね
*/

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

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

    sort(a.begin(), a.end());
    double ans = a.at(0);

    for(int i=1; i<n; i++)
        ans = double((ans+a.at(i))/2.0);

    cout << fixed << setprecision(15) << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int x, y;
	cin >> x >> y;
	int ans = 0;
	if (x <= 3)ans += 400000 - 100000 * x;
	if (y <= 3)ans += 400000 - 100000 * y;
	if (x == 1 && y == 1)ans += 400000;
	cout << ans;*/


	int n;
	cin >> n;
	vector<ll>a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	ll rui = 0;
	ll ans = abs(sum - 2 * a[0]);
	rep(i, n) {
		rui += a[i];
	
		ans = min(ans, abs(sum - 2 * rui));
	}
	cout << ans;


	/*int h, w, K;
	cin >> h >> w >> K;
	vector<vector<char>>s(h, vector<char>(w));
	rep(i, h)rep(j, w)cin >> s[i][j];
	vector<vector<int>>a(h, vector<int>(w));
	int k = 0;
	int num;
	rep(i, h) {
		num = 0;
		rep(j, w) {
			if (j == 0) {
				if (s[i][0] == '#')num++;
				k++;
				a[i][j] = k;
				continue;
			}
			if (s[i][j] == '.')a[i][j] = a[i][j - 1];
			else {
				num++;
				if (num > 1)k++;
				a[i][j] = k;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}*/
	return 0;
}

Measured memory_bytes: 1920