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

typedef pair<ll, ll> pair_t;

bool comp (const pair_t &a, const pair_t &b) {
  return a.first > b.first;
}

int main() {
  ll n, t;
  cin >> n >> t;

  ll a, b;
  vector<pair_t> p(n);
  for (ll i = 0; i < n; i++) {
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  
  sort(p.begin(), p.end(), comp);

  vector<vector<ll>> dp(n + 1, vector<ll>(t + 1, 0));
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= t; j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i - 1][max(j - p[i - 1].first, (ll)0)] + p[i - 1].second);
    }
  }

  // for (ll j = 0; j <= t; j++) {
  //   for (ll i = 0; i <= n; i++) {
  //     printf("%5d", (int)dp[i][j]);
  //   }
  //   printf("\n");
  // }

  cout << dp[n][t] << endl;
}


Measured memory_bytes: 70784
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    cs <- U.unfoldrN n B.uncons <$> B.getLine
    q <- readLn :: IO Int
    ks <- map read.words <$> getLine
    mapM_ (print.solve cs) ks

solve :: U.Vector Char -> Int -> Int
solve cs k = fst $ U.foldl' step (U.foldl' step0 (0, emptyQ) pre) $ U.zip cs post
  where
    (pre, post) = U.splitAt k cs
    step0 (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c q

    step (!res, !q) (ck, c)
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c $ pop ck q

data Q = Q !Int !Int !Int !Int

emptyQ :: Q
emptyQ = Q 0 0 0 0

push :: Char -> Q -> Q
push 'D' (Q d m dm f) = Q (d + 1) m dm f
push 'M' (Q d m dm f) = Q d (m + 1) (dm + d) f
push c q              = q

pop :: Char -> Q -> Q
pop c (Q d m dm f) = case c of
    'D' -> Q (d - 1) m (dm - m) (f + 1)
    'M' -> Q d (m - 1) dm (f + 1)
    _   -> Q d m dm (f + 1)

score :: Q -> Int
score (Q _ _ dm _) = dm


Measured memory_bytes: 7292
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string str;
  cin >> str;
  int i,j,a;
  while(str!="-"){
    cin >> j;
    for(i=0;i<j;i++){
      cin >> a;
      str=str.substr(a,str.size()-a)+str.substr(0,a);
    }
    cout << str << endl;
    cin >> str;
  }
}


Measured memory_bytes: 3212
x, N = gets.split.map(&:to_i)
p = []
p = gets.split.map(&:to_i)

if N == 0
  puts x
  exit
end

200.times do |i|
  upper, lower = x+i, x-i
  if not p.include?(lower)
    puts lower
    break
  elsif not p.include?(upper)
    puts upper
    break
  end
end

Measured memory_bytes: 14364
#include <iostream>
#include <iostream>
#include <string>
#include <vector>

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

int main(){
    std::string a;
    int flag = 0;

    // 入力
    std::cin >> a;


    rep(i, a.size()-1){
        if(a[i] != a[i+1]){
            flag = 1;
        }
    }

    if(flag == 0) std::cout << "No" << std::endl;
    else if(flag == 1) std::cout << "Yes" << std::endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ___                      \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define pii pair<int, int>
#define MAX INT_MAX
#pragma GCC optimize("Ofast")
#define int long long
const int MOD = (1e9 + 7);
using namespace std;
#define vvi vector<vector<int>>
const int mod = 998244353;

signed main()
{
	___ 
	float n,d; cin>>n>>d;
	int x = ceil(1.0*n/(2*d+1));
	cout<<ceil(n/(2*d+1))<<endl;
}



Measured memory_bytes: 256
N, M, *L = map(int, open(0).read().split())
sheet = [[[],[]] for i in range(N+1)]
for i,m in enumerate(zip(*[iter(L)]*2)):
  sheet[m[0]][0].append(i)
  sheet[m[1]][1].append(i)
ans = 0
log = set()
cnt = set()
for i in range(1,N+1):
  for x in sheet[i][1]:
    if x not in log:
      ans += 1
      log = log.union(cnt)
      cnt = set()
  for x in sheet[i][0]:
    cnt.add(x)
print(ans)

Measured memory_bytes: 56200
#include <stdio.h>

int main() {
  int i,j,max,min,n,x[200000];

  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&x[i]);
  }

  max = x[1] - x[0];
  min = x[0];
  for(i = 1; i < n; i++) {
    if(max < x[i] - min) max = x[i] - min; /*?????§????????§??????????????°??´??°?????????*/
    if(min > x[i]) min = x[i]; /*????????§?????????????°???????????°?????????¨????????´??°?????????*/
       }
    printf("%d\n",max);

    return 0;
  }

Measured memory_bytes: 1376
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>


string s,t,u;


int main(){
    cin>>s;
    rep(i,s.size())cout<<"x";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
map<ll,ll> help; 
int main(){
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i<=n;i++)cin>>a[i];
	for(ll i=n;i>=1;i--){
		 ll u=a[i]+i;
		 ans+=help[u];
		 help[i-a[i]]++;
	}
	cout<<ans<<endl;
	
	
	
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;

    cout << a*(n/(a+b)) + min(n%(a+b), a);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b, c, d;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c >> d;

  ll ac = a * c;
  ll ad = a * d;
  ll bc = b * c;
  ll bd = b * d;


  ll ans = max({ac, ad, bc, bd});
  cout << ans << endl;
}


Measured memory_bytes: 3636
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    # 0:gray 1:brown 2:green ...... 7:red
    colors_count = [0 for i in range(8)]
    super_count = 0
    for score in a:
        if int(score / 400) == 0:
            colors_count[0] += 1
        elif int(score / 400) == 1:
            colors_count[1] += 1
        elif int(score / 400) == 2:
            colors_count[2] += 1
        elif int(score / 400) == 3:
            colors_count[3] += 1
        elif int(score / 400) == 4:
            colors_count[4] += 1
        elif int(score / 400) == 5:
            colors_count[5] += 1
        elif int(score / 400) == 6:
            colors_count[6] += 1
        elif int(score / 400) == 7:
            colors_count[7] += 1
        else:
            super_count += 1

    # print(colors_count)

    # colors_count で0ではないとこの数
    not_zero_count = 0
    for num in colors_count:
        if num != 0:
            not_zero_count += 1

    if not_zero_count == 0:
        ans_min = 1
        # ans_max = super_count if super_count <= 8 else 8
        ans_max = super_count
    else:
        ans_min = not_zero_count
        # ans_max = not_zero_count + super_count if (not_zero_count + super_count) <= 8 else 8
        ans_max = not_zero_count + super_count

    print(str(ans_min) + ' ' + str(ans_max))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,x;
  cin>>a>>b>>x;
  c=a%x;
  a/=x;
  b/=x;
  if(c==0){
    cout<<b-a+1<<endl;
  }
  else {
    cout<<b-a<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int amari(int n);
int main(void){
    int N; cin >> N;
    int *pp; int M[10000];
    pp = M; int i = 0;

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    while(N != 1){
        *pp = amari(N);
        N = (N - amari(N))/-2;
        pp = pp + 1;
        i++;
    }

    *pp = 1; i++;
    while(i != 0){
        cout << *pp;
        pp = pp - 1;
        i--;
    }
    cout << endl;
    return 0;
}
int amari(int n){

    if(n %2 == 0){
        return 0;
    }else{
        return 1;
    }

}

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

#define ll long long

struct job{
  ll start;
  ll finish;
  ll dist;
  ll idx;
  job(){}
  job(ll s, ll f, ll d, ll i):start(s),finish(f),dist(d),idx(i){}

  friend bool operator<(const job&a, const job&b){
    if(a.finish == b.finish)return a.dist < b.dist;
    return a.finish < b.finish;
  }
};

int main(){
  ll n;cin >> n;
  vector<job> vec(n);
  for(int i = 0; i < n; ++i){
    ll a,b;cin >> a >> b;
    vec[i] = job(b - a, b, a, i);
  }

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

  ll t = 0;
  for(int i = 0; i < n; ++i){
    if(t > vec[i].start){
      cout << "No\n";
      return 0;
    }
    t += vec[i].dist;
    
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string a,b; cin>>a>>b;
    int l=b.length();
    string c=b.substr(0,l-1);
    if(a==c)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3656
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > G;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) cout << "Zero\n", exit(0);
    if (b < 0 && (b - a + 1) % 2 == 0) cout << "Positive\n", exit(0);
    if (b < 0 && (b - a + 1) % 2 != 0) cout << "Negative\n", exit(0);
    if (a > 0 || a % 2 == 0) cout << "Positive\n", exit(0);
    else cout << "Negative\n", exit(0);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.toInt()
    val cells = readLine()!!.trim().split(' ').map(String::toInt)
    val memo = Array(n){null as Boolean?}
    for (i in cells.indices){
        var single = i
        var double = (i + cells[i]) % n
        while(single != double && memo[double] == null){
            single = (single + cells[single]) % n
            double = (double + cells[double]) % n
            double = (double + cells[double]) % n
        }
        if (memo[double] == null){
            memo[single] = true
            single = (single + cells[single]) % n
            while(single != double){
                memo[single] = true
                single = (single + cells[single]) % n
            }
        }
        single = i
        while (memo[single] == null){
            memo[single] = false
            single = (single + cells[single]) % n
        }
    }
    println(
            memo.count{it!!}
    )
}


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

int main(){
    int n;
    cin >> n;
    int max = -1000000;
    int min = 1000000;
    long sum = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a>max){
            max = a;
        }
        if(a<min){
            min = a;
        }
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < 26; i++) {
			char ch = (char) ('a' + i);
			StringBuilder sb = new StringBuilder(s);
			int cnt = 0;
			while (true) {
				boolean flg = true;
				for (int j = 0; j < sb.length(); j++) {
					if (sb.charAt(j) != ch) {
						flg = false;
						break;
					}
				}
				if (flg) {
					break;
				}

				for (int j = 0; j < sb.length() - 1; j++) {
					if (sb.charAt(j) == ch || sb.charAt(j + 1) == ch) {
						sb.setCharAt(j, ch);
					}
				}
				sb.deleteCharAt(sb.length() - 1);
				cnt++;
			}
			ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
	}
}


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

int main(){
	int money = 100000;
	int n;

	cin >> n;
	for(int i = 0; i< n; i++){
		money *= 1.05;
		if(money % 1000 != 0){
			money += 1000 - (money % 1000);
		}
	}
	cout << money << endl;
} 

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

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

	int ans=0;
	int q;	cin>>q;
	for(int i=0;i<q;i++){
		int t;	cin>>t;

		int L=0,R=n;
		while(R-L>1){
			int mid=(R+L)/2;
			if(t<s[mid])R=mid;
			else L=mid;
		}
		if(s[L]==t)++ans;
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3108
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Wed Feb  6 11:57:01 2019
//
package main

import "fmt"

var primes []bool

func main() {
	primes := make([]bool, 1e5+1)
	for i := range primes {
		primes[i] = true
	}
	primes[0], primes[1] = false, false

	for i := 2; i <= 1e5; i++ {
		if primes[i] {
			for j := i + i; j <= 1e5; j += i {
				primes[j] = false
			}
		}
	}

	arr := make([]int, 1e5+1)
	for i := range arr {
		if primes[i] && primes[(i+1)/2] {
			arr[i]++
		}
	}

	for i := range arr {
		if i > 0 {
			arr[i] += arr[i-1]
		}
	}

	var Q int
	fmt.Scan(&Q)
	for i := 0; i < Q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(arr[r] - arr[l-1])
	}
}


Measured memory_bytes: 5888
def main():
  n, w = [int(e) for e in input().split()]
  maxv = 10 ** 3 * n + 1
  t = [-1 for i in range(maxv)]
  t[0] = w
  cmaxv = 0
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(cmaxv, -1, -1):
      if t[i] == -1:
        continue
      if t[i + nv] < t[i] - nw:
        t[i + nv] = t[i] - nw
        if cmaxv < i + nv:
          cmaxv = i + nv
  print(cmaxv)
main()

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String T = br.readLine();
        
        int count = 0;
        for(int i = 0; i < 3; i++){
            if ( S.charAt(i) == T.charAt(i) ) count++;
        }
        
        System.out.println(count);
        
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  clr(d,0);
  rep(i,0,3){
    cin >> n;
    d[n]++;
  }
  if(d[5] == 2 && d[7] == 1)puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	
	if(n == 1){
		printf("Hello World\n");
	}else{
		int a,b;
		scanf("%d %d",&a,&b);
		printf("%d\n",a+b);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n){
    if(n==0){
        break;
    }
    vint k(n);
    int count=0;
    bool fg=false;
    rep(i,n){
        cin>>k[i];
        if(k[i]!=0){
            count++;
        }
        if(k[i]>=2){
            fg=true;
        }
    }    
   if(!fg){
        cout<<"NA"<<'\n';
    }
    else{
        cout<<count+1<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int t[112345],x[112345],y[112345];
int main(){
  int N;
  bool flag=true;
  cin>>N;
  t[0]=0;
  x[0]=0;
  y[0]=0;
  FOR(i,1,N+1){
    cin>>t[i]>>x[i]>>y[i];
    int daiji=(t[i]-t[i-1])-((x[i]-x[i-1])+(y[i]-y[i-1]));

    if(daiji%2!=0 || daiji<0){
      flag=false;
    }
  }
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;

}


Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main() {
	int x;
	cin >> x;
	if ((x  < 700) || (x  >= 800 )) {
		x %= 100;
		if ((x < 70) || (x >= 80 )) {
			x %= 10;
			if ((x < 7) || (x >= 8)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3672
using System.Linq;
using System;
using System.IO;

class Program
{
  static void Main(string[] args)
  {
    var line = Console.ReadLine().Split(' ').Select(int.Parse);
    var k = line.First();
    var s = line.Last();

    var count = 0;
    for (int x = 0; x <= k; x++)
    {
      for (int y = 0; y <= k; y++)
      {
        var z = s - x - y;
        if(z < 0) break;
        if(z > k) continue;

        count++;
      }
    }

    Console.WriteLine(count);
  }
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  ll ans = 1LL << 60;
  rep(i, n - k + 1) {
    ll left = a[i];
    ll right = a[i + k - 1];
    ans = min(ans, min(abs(left), abs(right)) + right - left);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1152
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

fn main() {
    input!{
        N: usize,
        mut L: [usize; N],
    }
    L.sort();
    let mut ans = 0;
    for i in 0..(N-2) {
        let a = L[i];
        let mut right = i+1;
        for left in (i+1)..(N-1) {
            let b = L[left];
            while right < N && L[right] < a + b {
                right += 1;
            }
            ans += right - left - 1;

            if right == left {
                right += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
	int midterm, finalterm, makeup;
	while (true)
	{
		cin >> midterm >> finalterm >> makeup;
		if ((midterm == -1) && (finalterm == -1) && (makeup == -1))
			break;
		if ((midterm == -1) || (finalterm == -1))
			cout << "F\n";
		else
		{
			int sum = midterm + finalterm;
			if (sum >= 80)
				cout << "A\n";
			else if (sum >= 65 && sum < 80)
				cout << "B\n";
			else if (sum >= 50 && sum < 65)
				cout << "C\n";
			else if (sum >= 30 && sum < 50)
				if (makeup >= 50)
					cout << "C\n";
				else
					cout << "D\n";
			else
				cout << "F\n";
		}
	}
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

int n, m;
vll a, b;
ll k;

bool ok(int books) {
    int i = min(books, n); // where the first pointer starts
    int j = max(0, books - i); // where the second pointer starts

    if(j > m) return false;
    ll time = 1LL << 60;
    ll sumFirst = 0;
    ll sumSecond = 0;
    for(int x = 0; x <= i; x++) {
        sumFirst += a[x];
    }
    for(int x = 0; x <= j; x++) {
        sumSecond += b[x];
    }
    if(i + j == books)
        time = min(time, sumFirst + sumSecond);
    //cout << i + j << " " << time << endl;
    while(i > 0 || j <= m - 1) {
        //cout << " i is " << i << " j is " << j << " " <<  sumFirst << " " << sumSecond << endl;
        if(i > 0) {
            sumFirst -= a[i];
            i--;
        }
        if(j <= m - 1) {
            j++;
            sumSecond += b[j];
        }
        if(i + j == books)
            time = min(sumFirst + sumSecond, time);
    }
    //cout << time << endl;
    return time <= k;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> k;
    a.pb(0);
    b.pb(0);
    for(int i = 0; i < n; i++) {
        ll u;
        cin >> u;
        a.pb(u);
    }
    rep(i,0,m) {
        ll u;
        cin >> u;
        b.pb(u);
    }

    int low = 0;
    for(int x = 500000; x >= 1; x /= 2) {
        while(ok(low + x)) low += x;
    }
    cout << low << endl;

    //ok(1);





    return 0;
}


Measured memory_bytes: 7996
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7

def main():
  n,k = map(int,input().split())
  print(k * (k-1) ** (n-1))
    
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;
static const int MAX_N = 1010;

int main(void){
  long long int N, H, W;
  cin >> N >> H >> W;
  long long int A[MAX_N], B[MAX_N];
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(A[i] >= H && B[i] >= W) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
const stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
const lines = stdin.split(/\r?\n/g).filter(x => !!x);
for (const line of lines) {
    if (line == "0") break;
    const c = line.split(" ").map(x => Math.min(10, +x));
    const ones = c.filter(x => x === 1).length;
    const s0 = c.reduce((a, b) => a + b, 0);
    let snum = 0;
    for (let i = 0; i <= ones; i++) {
        const siraw = s0 + 10 * i;
        const si = siraw > 21 ? 0 : siraw;
        snum = Math.max(snum, si);
    }
    console.log(snum);
}


Measured memory_bytes: 17284
fun main(args: Array<String>) {
    abc090b()
}

fun abc090b() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    val answer = (a..b).count { num -> num.toString().let { it[0] == it[4] && it[1] == it[3] } }

    println(answer)
}


Measured memory_bytes: 38904
// AOJ 2021: Princess in Danger
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 10000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x07070707
#define NMAX 13000
#define N  7

typedef struct { int to[70], t[70]; } TBL;
TBL tbl[NMAX];
int len[NMAX];
int f[101];
int dist[NMAX];

int dijkstra(int start, int goal)
{
	int i, s, t, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node, t = que[0].t; deq();
		if (s >> N == goal) return t;
		if (dist[s] < t) continue;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i], d = dist[s] + tbl[s].t[i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return INF;
}

char buf[400], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}


int main()
{
	int n, m, l, k, a, h, i, j, ans;
	int x, y, t, u, v, u2, v2;

	while (fgets(p=buf, 60, stdin) && *p != '0') {
		n = getint(), m = getint(), l = getint();
		k = getint(), a = getint(), h = getint();

		if (l > 0) {
			fgets(p=buf, sizeof(buf), stdin);
			for (i = 0; i < l; i++) f[i] = getint();
		}
		f[l++] = a, f[l++] = h;

		memset(len, 0, sizeof(len));
		while (k--) {
			fgets(p=buf, 20, stdin);
			x = getint() << N, y = getint() << N, t = getint();
			for (j = t; j <= m; j++) {
				u  = x + j, v  = y + j;
				u2 = u - t, v2 = v - t;
				i = len[u]++, tbl[u].to[i] = v2, tbl[u].t[i] = t;
				i = len[v]++, tbl[v].to[i] = u2, tbl[v].t[i] = t;
			}
		}

		for (i = 0; i < l; i++) {
			u = f[i] << N;
			for (j = 0; j < m; j++) {
				v = u+j, v2 = v+1;
				t = len[v]++, tbl[v].to[t] = v2, tbl[v].t[t] = 1;
			}
		}

		ans = dijkstra((a << N) + m, h);
		if (ans == INF) puts("Help!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 7792
#include <iostream>
#include <algorithm>

using namespace std;

int dp[101][10001];
int v[101];
int w[10001];
int n, W;

void solve(){
  for(int i = n - 1; i >= 0; i--){
    for(int j = 0; j <= W; j++){
      if(j < w[i]){
        dp[i][j] = dp[i+1][j];
      }else{
        dp[i][j] = max(dp[i+1][j], dp[i+1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[0][W] << endl;
}

int main(){
  cin >> n >> W;
  for(int input = 0; input < n ; input ++){
    cin >> v[input];
    cin >> w[input];
  }
  solve();
  return 0;
}



Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define vi vector<int>
#define ppi pair<int,pi>
#define ld long double
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << end
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end) ; i += 1 - 2 * ((begin) > (end)))
#define nl cout<<"\n";
#define endl "\n"
#define par(a,n) f(i,0,n) cout<<a[i]<<" "; nl
//void prt(int x) {cerr << x;}
#define vv(n,m) vector <vector <int> > v(n, vector <int> (m));

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... brgs>
void err(istream_iterator<string> it, T a, brgs... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);	
}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef pair<int,int> pii;
typedef vector<pii> vpii;
const int mod = 1000000007;
const int N = 3e5;

int kadane(int*a, int n);
bool isPrime(int n);
int mpow(int a, int b);

void solve(){
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  f(i,0,n){
      cin>>a[i]>>b[i]>>c[i];
  }
  int adp[n]={0},bdp[n]={0},cdp[n]={0};
  adp[0]=a[0];
  bdp[0]=b[0];
  cdp[0]=c[0];
  f(i,1,n){
      adp[i]=a[i]+max(bdp[i-1],cdp[i-1]);
      bdp[i]=b[i]+max(adp[i-1],cdp[i-1]);
      cdp[i]=c[i]+max(adp[i-1],bdp[i-1]);
  }
  cout<<max(max(adp[n-1],bdp[n-1]),cdp[n-1])<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
        
}

int mpow(int a, int b){ /* pow(a, b) % m */
  int m=mod;
  int x=1;
  while (b>0){
    if (b&1){
      x=(x * a) % m;
    }
    a=(a*a) % m; /* compute the next power of 2 */
    b>>=1; /* this is equivalent to b = floor(b / 2) */
  }
  return x;
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 

int kadane(int*a, int n){
    int max_so_far = INT_MIN, max_ending_here = 0;
    f(i,0,n){
        max_ending_here+=a[i];
        max_so_far = max(max_so_far, max_ending_here);
        if(max_ending_here<0) max_ending_here=0;
    }
    return max_so_far;
}

Measured memory_bytes: 8284
n = int(input())
items = []
for _ in range(n):
    a, b = map(int, input().split())
    items.append((a, b))
items.sort(key=lambda x:-x[0] + -x[1])
t = sum([items[i][0] for i in range(0, n, 2)])
a = sum([items[i][1] for i in range(1, n, 2)])
print(t - a)


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

int cnt;
vector<int> v;
int c[50001];
int ans[50001];


int judge(int n){
  int c = 0;
  for(int i = 1; i <= sqrt(n); i++){
    if(n%i == 0) c++;
  }
  if(c == 1) return 0;
  return 1;
}

void solve(){
  int c = 0;
  for(int i = 2; i <= 50000; i++){
    if(judge(i) == 0){
      // cout << i << endl;
      v.push_back(i);
    }

  }


}

int main(){

  solve();
  memset(c,-1,sizeof(c));

  int a, b;


  memset(ans,0,sizeof(ans));
      for(int i = 0; i < v.size(); i++){
	for(int j = i; j < v.size(), v[i]+v[j] <= 50000; j++){
	  //	  if(v[i] + v[j] == a) cnt++;

	  ans[v[i]+v[j]]++;
	}
      }

  while(1){
    scanf("%d",&a);
    if(a == 0) break;
    cnt = 0;
    // if(c[a] != -1) printf("%d\n",c[a]);
    //else{

      printf("%d\n",ans[a]);
      //  c[a] = cnt;
      // }
  }


}

Measured memory_bytes: 1656
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();

        long left[] = new long[S.length()+1];
        long right[] = new long[S.length()+1];

        int c = 0;
        for (int i=0; i<S.length(); i++) {
            if ("<".equals(S.substring(i, i+1))) {
                left[i] = c;
                left[i+1] = c+1;
                c++;
            } else {
                c = 0;
            }
        }
        c = 0;
        for (int i=S.length()-1; i>=0; i--) {
            if (">".equals(S.substring(i, i+1))) {
                right[i] = c+1;
                right[i+1] = c;
                c++;
            } else {
                c = 0;
            }
        }
        for (int i=0; i<S.length(); i++) {
            if (left[i]<right[i])
                left[i] = right[i];
        }
        

        long sum = Arrays.stream(left).sum();
        PrintWriter out = new PrintWriter(System.out);
        out.println(sum);
        out.flush();
    }
}

Measured memory_bytes: 67916
#include<stdio.h>
 main(){
  int a=0;
  int W,H,x,y,r=0;  
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W){
    if(y-r>=0&&y+r<=H){
      a=1;
    }  
}  
else{
    a=0;
  }  
if(a==1){
    printf("Yes\n");
  }
  else if(a==0){
    printf("No\n");
  }
  return 0;
}

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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = n - 1; i >= 0; i--) {
		if (i != n - 1) cout << " ";
		cout << a[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3092
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	std::vector<PP> edges(m);
	REP(i, 0, m){
		scanf("%ld %ld %ld", &edges[i].se.fi, &edges[i].se.se, &edges[i].fi);
		edges[i].se.fi--;
		edges[i].se.se--;
	}
	
	std::vector<V> dist(n, V(n, 1e18));
	for(PP d: edges){
		dist[d.se.fi][d.se.se] = std::min(dist[d.se.fi][d.se.se], d.fi);
		dist[d.se.se][d.se.fi] = std::min(dist[d.se.se][d.se.fi], d.fi);
	}
	REP(k, 0, n) REP(i, 0, n) REP(j, 0, n) {
		dist[i][j] = std::min(dist[i][j], dist[i][k]+dist[k][j]);
	}

	int ans = 0;
	for(PP d: edges){
		if(dist[d.se.fi][d.se.se]<d.fi) ans++;
	}
	printf("%d\n", ans);
	return 0;

}



Measured memory_bytes: 384
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			int[] list = new int[10];
			String tmp = sc.next();
			for(int i = 0; i < 10; i++) {
				list[i] = Integer.parseInt(String.valueOf(tmp.charAt(i)));
			}
			
			for(int i = 0; i < 9; i++) {
				for(int j = 0; j < 10 - i - 1; j++) {
					int tmpX = list[j] + list[j+1];
					String TMPX = String.valueOf(tmpX);
					list[j] = Integer.parseInt(String.valueOf(TMPX.charAt(TMPX.length()-1)));
				}
			}
			out.println(list[0]);
		}
		out.flush();
	}
}

//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

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

int main(void){
 string str;
 cin >> str;
 int n=0,w=0,s=0,e=0;
 for(auto x:str){
  switch(x){
  case 'N': n=1; break;
  case 'W': w=1; break;
  case 'S': s=1; break;
  case 'E': e=1; break;
  }
 }
 cout << (!(n^s || w^e) ? "Yes" : "No") << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int haha=15000;
long long int n, W, best, w[100000], v[100000], dp[110][100005];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> W;
    for(long long int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=W;j++){
            if(i==0 or j==0){
                dp[i][j]=0;
            }
            else{
                best=dp[i-1][j];
                if(j>=w[i]){
                    best=max(best, dp[i-1][j-w[i]]+v[i]);
                }
                dp[i][j]=best;
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 82304
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    int MAX = 100002;

    int N; scanf("%d", &N);
    VI arr(N);
    VI cri(MAX, 0);
    REP(i, N){
        int d; scanf("%d", &d);
        arr[i] = d;
        cri[d]++;
    }

    int maxT = -(1 < 20);

    REP(i, MAX){
        if(i == 0){
            continue;
        }else{
            int sum = cri[i-1] + cri[i] + cri[i+1];
            maxT = max(maxT, sum);
        }
    }

    cout << maxT;

    return 0;
}











































Measured memory_bytes: 1152
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int h = sc.nextInt();
        int s = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        int q_2 = q*8;
        int h_2 = h*4;
        int s_2 = s*2;
        int d_2 = d*1;
        int res_2 = Math.min(q_2,Math.min(h_2,Math.min(s_2,d_2)));
        int res_1 = Math.min(q_2/2, Math.min(h_2/2,s_2/2));
        long res = (long)res_2*(n/2) + (long)res_1*(n%2);
        System.out.println(res);

        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void yesno(boolean f) {
        System.out.println(f ? "yes" : "no");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static int nibutan(int target, int[] ar) {
        // ar[i] >= target なる最小のiを探す
        int res;
        int high = ar.length;
        int low = 0;
        while (high > low) {
            res = (high + low) / 2;
            if (ar[res] < target) {
                // ↑↓ここを変える
                low = res + 1;
            } else {
                // ↓ここを変える
                high = res;
            }
        }
        return low;
    }

    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto cs = new int[](101);
    foreach (n; 2..N+1) {
        foreach (d; 2..N+1) {
            while (n%d == 0) {
                cs[d] += 1;
                n /= d;
            }
        }
    }
    int a, b, c, d, e;
    foreach (x; cs) {
        if (x >= 74) ++a;
        if (x >= 24) ++b;
        if (x >= 14) ++c;
        if (x >= 4) ++d;
        if (x >= 2) ++e;
    }
    writeln(a + b*(e-1) + c*(d-1) + d*(d-1)/2*(e-2));
}

Measured memory_bytes: 256