akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] arr = new int[m];
		for (int i = 0; i < m; i++) {
			arr[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			int total = c;
			for (int j = 0; j < m; j++) {
				total += sc.nextInt() * arr[j];
			}
			if (total > 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  string a,b;
  cin >> a >> b;
  if(a.length()>b.length())puts("GREATER");
  if(a.length()<b.length())puts("LESS");
  if(a==b){
    puts("EQUAL");
  } else {
    if(a.length()==b.length()){
      REP(i,a.length()){
        if(a[i]>b[i]){
          puts("GREATER");
          break;
        }
        if(a[i]<b[i]){
          puts("LESS");
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int n, q;
int l, r;
int sum[100005];
char str[100005];

int main()
{
	int len;

	scanf("%d %d", &n, &q);
	scanf("%s", str);

	len = strlen(str);
	for (int i = 1; i < len; i++) {
		if (str[i - 1] == 'A' && str[i] == 'C') {
			sum[i] = sum[i - 1] + 1;
		} else {
			sum[i] = sum[i - 1];
		}
	}


	for (int i = 0; i < q; i++) {
		scanf("%d %d", &l, &r);
		l--; r--;

		printf("%d\n", sum[r] - sum[l]);
	}

	return 0;
}


Measured memory_bytes: 1280
import sys
from io import StringIO
import unittest
import math
# 検索用タグ、繰り返し2乗法、膨大な組み合わせ、フェルマーの小定理
# https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
# ちなみに、pythonでは(pow())にて実装済みなので、自作不要。
# https://note.com/keyem/n/n526ee14fe3de
# 「繰り返し2乗法」はプログラム数学とでも呼ぶべき分野(高校、大学数学とは多分違う。「プログラムに対してのみ」効果があるので・・)
# --------------------------------------------------
# この問題のポイントは・・「組み合わせをXの(y)-2乗」という形に変換する事。
# https://img.atcoder.jp/abc156/editorial.pdf
# https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
# 10億種類の花から10万個を選ぶ・・というのは処理速度的に無理だが、
# 「Xの?乗」という形に変換できれば、繰り返し2乗法で高速に計算できる!(pythonならpow()を使うだけでOK)
# --------------------------------------------------

# 膨大な組み合わせ(10億C10万とか)の数を求める関数。
def cmb(n, r):
    mod = 10**9+7
    ans = 1
    for i in range(r):
        ans *= n-i
        ans %= mod
    for i in range(1, r+1):
        ans *= pow(i, mod-2, mod)
        ans %= mod
    return ans

def resolve():

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

    # 10の9乗+7を算出しておく。
    div = pow(10, 9) + 7

    # 合計 = a,bを無視した総パターン数 - patternAの数 - patternbの数
    total = pow(2, n, div) - 1 - cmb(n, a) - cmb(n, b)
    print(total % div)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 1 3"""
        output = """7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1000000000 141421 173205"""
        output = """34076506"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  int count=0;
  for(int i=0;i<n;i++){
    if(count==0&&s[i]=='T'){
      ans++;
    }
    else if(s[i]=='T'){
      count++;
    }
    else if(s[i]=='S'){
      count--;
    }
  }
  cout << 2*ans << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin >> n;
    vl a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i] >> b[i];
        c[i] = a[i] + b[i];
    }
    sort(all(c),greater<ll>()); //降順そーと
    ll res = 0,res1=0;
    rep(i,n){
        if(i%2==0)res+=c[i];
        else res1+=c[i];
    }
    cout << res - accumulate(all(b),0LL) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
 vector<int> data(11000);
  for (int i = 0; i < 11000; i++ ) {
       data.at(i) = 0;
    }
 for(int i=1;i<100;i++){
  for(int j=1;j<100;j++){
    for(int k=1;k<100;k++){
      int a = i*i + j*j + k*k + i*j + j*k + k*i;
      if(a<10005) data.at(a)++;
      else break;
    }
  }
 }
  int a;
  cin >> a;
  for(int i=1;i<=a;i++){
   cout << data.at(i) << endl;
  }
}


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

using namespace std;

int main(){

    int n, k;
    cin >> n >> k;

    int a;
    vector<int> tmp(n);

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

    sort(tmp.begin(), tmp.end(), greater<int>());

    int ans = n;

    for(int i = 0; i<k; i++)
        ans -= tmp[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  string s;
  cin >> s;
  ll ans = 0;
  string t = "CODEFESTIVAL2016";
  for(ll i = 0; i < s.size(); i++){
    if(t[i] != s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
@SuppressWarnings("Duplicates")
// author @mdazmat9
public class Main{
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        int test = 1;
        //test=sc.nextInt();
        for (int ind = 0; ind < test; ind++) {
            solve();
        }
        out.flush();
    }
    static void solve(){
        String s=sc.next();
        String t=sc.next();
        int count=0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)==t.charAt(i))count++;
        }
        out.println(count);

    }







    static int[] intarray(int n){ int [] a=new int[n];for(int i=0;i<n;i++)a[i]=sc.nextInt();return a; }
    static long[] longarray(int n){ long [] a=new long[n];for(int i=0;i<n;i++)a[i]=sc.nextLong();return a; }
    static ArrayList<Integer> intlist(int n){ArrayList<Integer> list=new ArrayList<>();for(int i=0;i<n;i++)list.add(sc.nextInt());return list; }
    static ArrayList<Long> longlist(int n){ArrayList<Long> list=new ArrayList<>();for(int i=0;i<n;i++)list.add(sc.nextLong());return list; }
    static int[][] int2darray(int n,int m){ int [][] a=new int[n][m];for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ a[i][j]=sc.nextInt(); } }return a; }
    static long[][] long2darray(int n,int m){ long [][] a=new long[n][m];for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ a[i][j]=sc.nextLong(); } }return a; }
    static char[][] char2darray(int n,int m){ char [][] a=new char[n][m];for(int i=0;i<n;i++){ String s=sc.next(); a[i]=s.toCharArray(); }return a; }

    static double pi=3.14159265358979323846264;
    public static double logb( double a, double b ) {return Math.log(a) / Math.log(b); }
    static long fast_pow(long a, long b,long abs) {
        if(b == 0) return 1L;
        long val = fast_pow(a, b / 2,abs);
        if(b % 2 == 0) return val * val % abs;
        else return val * val % abs * a % abs;
    }
    static long abs = (long)1e9 + 7;
    static   void shuffle(int[] a) { int n = a.length;for(int i = 0; i < n; i++) { int r = i + (int) (Math.random() * (n - i));int tmp = a[i];a[i] = a[r];a[r] = tmp; } }
    static long gcd(long a , long b) {
        if(b == 0) return a;
        return gcd(b , a % b);
    }
}

class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;
    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }
    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int64_t a, b, x,ans=0;
	cin >> a >> b >> x;
	if(x > 1 && a == 0)
		return cout << 1 + b / x - (a - 1) / x << endl, 0;
	cout << b / x - (a-1) / x << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int k;
    cin >> k;
    int r = 0;
    for (int i=1; i<=k; i++) {
        r = (r * 10 + 7) % k;
        if (r == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int sum = a + b;
  int error = a - b;
  int product = a * b;
  
  int max = sum;
  if(max < error)
  {
      max = error;
  }
  if(max < product)
  {
      max = product;
  }
  
  cout << max << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll a, b, x;
    cin >> a >> b >> x;
    double pi = 3.14159265358979323846; 

    double theta = 0;
    double uhen = 0;
    if(2*x<=a*a*b){
        uhen = 1.0*a*b*b/2.0/x;
    }else{
        uhen = 2.0*(a*a*b-x)/a/a/a;
    }
    theta = atan(uhen);

    double res = 180*theta/pi;
    printf("%.10f\n", res);

    return 0;
}

Measured memory_bytes: 4136
/*
author: orthodoxparadox
09-Jan-2019
10:55:53
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define fup(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fnu for(ll i = 0; i < n; i++)
#define rev(Y) reverse(all(Y))
#define oiint ostream_iterator<int>(cout, " ") 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define dbg(...)
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<v.size();++i) x<<v[i]<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;} 
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int mod = 1e9 + 7;

int takemod(int a){return ((a%mod)+mod)%mod;}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a){return takemod(fast_exp(takemod(a), mod-2));}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	clock_t t1, t2;
	t1 = clock();

	int n, k;
	cin >> n >> k;
	int h[n+1], dp[n+1];
	for(int i = 0; i < n; i++) cin >> h[i+1];
	dp[0] = 0;
	dp[1] = 0;
	h[0] = h[1];
	for(int i = 2; i <= n; i++)
	{
		dp[i] = 1e18;
		for(int j = 1; j <= min(k, i); j++)
		{
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}
	cout << dp[n];
	t2 = clock(); cerr << "time taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using ppii = pair<pii,pii>;

ll solve() {
    ll N, l, r;
    cin >> N;
    vector<pii> A(N);
    ll xmin = 0;
    int xi;
    for ( int i = 0; i < N; i++ ) {
        cin >> l >> r;
        A[i] = pii(l,r);
    }
    sort(A.begin(), A.end());
    for ( int i = 0; i < N; i++ ) {
        l = A[i].first;
        r = A[i].second;
        if ( xmin < r-l+1 ) {
            xmin = r-l+1;
            xi = i;
        }
    }
    l = 0, r = 10e9+1;
    for ( int i = 0; i < N; i++ ) {
        if ( A[i] == A[xi] ) continue;
        l = max(l, A[i].first);
        r = min(r, A[i].second);
        if ( r < l ) break;
    }
    xmin += l < r ? r-l+1 : 0;

    vector<ppii> c;
    c.push_back(ppii(A[xi], pii(-1,-1)));
    for ( int ii = 0; ii < N; ii++ ) {
        int i = ii % 2 == 0 ? ii/2 : N - 1 - ii/2;
        if ( i == xi ) continue;
        vector<ppii> cn;
        for ( ppii pp : c ) {
            ll l1 = max(pp.first.first, A[i].first);
            ll r1 = min(pp.first.second, A[i].second);
            ll w11 = l1 < r1 ? r1-l1+1 : 0;
            ll w12 = pp.second.first == -1 ? 0 : pp.second.second - pp.second.first + 1;
            if ( pp.second.first == -1 || w11 + w12 >= xmin ) {
                cn.push_back(ppii(pii(l1,r1), pp.second));
            }
            ll l2 = pp.second.first == -1 ? A[i].first : max(pp.second.first, A[i].first);
            ll r2 = pp.second.first == -1 ? A[i].second : min(pp.second.second, A[i].second);
            ll w21 = pp.first.second - pp.first.first + 1;
            ll w22 = l2 < r2 ? r2-l2+1 : 0;
            if ( w21 + w22 >= xmin ) {
                cn.push_back(ppii(pp.first, pii(l2,r2)));
            }
        }
        c.swap(cn);
        if ( c.empty() ) break;
    }


    ll ans = 0;
    for ( ppii pp : c ) {
        if ( pp.second.first == -1 ) continue;
        ll w31 = pp.first.second >= pp.first.first ? pp.first.second - pp.first.first + 1 : 0;
        ll w32 = pp.second.second >= pp.second.first ? pp.second.second - pp.second.first + 1 : 0;
        ans = max(ans, w31+w32);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mod = 1_000_000_007;
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = n - k + 1;
        int b = k - 1;
        Combination conR = new Combination(r, mod);
        Combination conB = new Combination(b, mod);
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= k; i++) {
            long tmp = 0L;
            if (i - 1 <= n - k) {
                tmp = ( conB.comb(b, i - 1) * conR.comb(r, i)) % mod;
            }
            sb.append(tmp).append("\n");
        }
        System.out.println(sb.toString());
        sc.close();

    }

}

class Combination {

    /** factorial:階乗 */
    private long fac[];
    /** inverse:逆元（ここでは、fac[i]をMOD-2乗したものをMODで割った余り） */
    private long inv[];
    /** 除数 */
    private int mod;

    /**
     * コンストラクタ
     * @param size 組み合わせの対象となる個数
     * @param mod 除数
     */
    public Combination(int size, int mod) {
        this.fac = new long[size + 1];
        this.inv = new long[size + 1];
        this.mod = mod;

        this.fac[0] = 1;
        this.inv[0] = 1;

        for (int i = 1; i <= size; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = modPow(fac[i], (int) mod - 2) % mod;
        }
    }

    /**
     * n個の中からr個選ぶ組み合わせの数（nCr）をmodで割った余りを算出する
     * @param n 元の集合の要素数
     * @param r 組み合わせる要素数
     * @return nCr % mod
     */
    public long comb(int n, int r) {
        return fac[n] * inv[r] % mod * inv[n - r] % mod;
    }

    /**
     * base^exp をmodで割った余りを算出する
     * @param base 基数
     * @param exp 指数
     * @return base^exp % mod
     */
    private long modPow(long base, int exp) {
        long ret = 1;
        while (exp > 0) {
            if ((exp & 1) == 1) {
                ret = ret * base % mod;
            }
            base = base * base % mod;
            exp >>= 1;
        }
        return ret;
    }

}


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

int rec(int a[],int n){

  if(n==1) return a[0];
  int b[10]={0};
  
  for(int i=0;i<n-1;i++){
    b[i]=(a[i]+a[i+1])%10;
  }
  
  return rec(b,n-1);
}

int main(){

  int a[10];
  char str[11];

  while(scanf("%s",str) != EOF){
    
    for(int i=0;i<10;i++){
      a[i]=str[i]-'0';
    }

    int ans = rec(a,10);

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

  }

  return 0;
}

Measured memory_bytes: 1136
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    map <string,int> hash;
    int n; cin>>n; 
    string  s;
    cin >> s;
    hash[s]++; n--;
    bool ok=true;
    char c=s[sz(s)-1];
    while (n--){
        cin>>s; hash[s]++; 
        if (s[0] != c) ok=false;
        if (hash[s]>1) ok=false;
        c = s[sz(s)-1];
    }
    cout << (ok?"Yes":"No") << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3636
require 'set'

roll = lambda do |dice, p|
  dice.each_with_index.sort_by {|_, i| p[i] }.map(&:first)
end
permutations = Set.new
permutations << [0, 1, 2, 3, 4, 5]
todo = [[0, 1, 2, 3, 4, 5]]
until todo.empty?
  dice = todo.pop
  [[2, 1, 5, 0, 4, 3], [4, 0, 2, 3, 5, 1]].each do |p|
    d = roll[dice, p]
    unless permutations.member? d
      permutations << d
      todo << d
    end
  end
end
dice = gets.split.map(&:to_i)
gets.to_i.times do
  a, b = gets.split.map {|s| dice.find_index s.to_i }
  p dice[permutations.find {|p, q| a == p && b == q }[2]]
end

Measured memory_bytes: 9000
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var s = new Queue<int>(Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x));

		var q = new int[n + 1].Select(_ => new List<int>()).ToList();
		q[n].Add(int.MaxValue);
		while (s.Any())
		{
			var hp = s.Dequeue();
			var match = false;
			for (var i = q.Count - 1; i >= 0; i--)
				if (hp < q[i][0])
				{
					for (var j = i - 1; j >= 0; j--) q[j].Add(hp);
					q[i].RemoveAt(0);
					if (!q[i].Any()) q.RemoveAt(i);
					match = true;
					break;
				}
			if (!match) { Console.WriteLine("No"); return; }
		}
		Console.WriteLine("Yes");
	}
}


Measured memory_bytes: 44392
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;

int main() {
    ll n, a, b, c, x;
    while(cin >> n >> a >> b >> c >> x, n) {
        vector<ll> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }
        int i = 0;
        int ret = 0;
        while(i < n && ret <= 10000) {
            for(int cnt=0; cnt<10000; ++cnt) {
                if(x == v[i]) {
                    ret += cnt;
                    if(i != n-1) {
                        ++ret;
                        x = (a*x + b) % c;
                    }
                    ++i;
                    break;
                } else if(cnt == 9999) {
                    ret += 10001;
                }
                x = (a*x + b) % c;
            }
        }
        if(ret > 10000) {
            cout << -1 << endl;
        } else {
            cout << ret << endl;
        }
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
      int n,q;
      cin >> n;
      vll a;
      unordered_map<ll,ll> m;
      inl(a,n);
      vll b,c;
      cin >> q;
      for(ll i=0;i<q;i++){
            ll x,y;cin >>x>>y;
            b.pb(x);c.pb(y);
      }
      for(ll i=0;i<n;i++){
            m[a[i]]++;
      }

      ll sum = accumulate(all(a),0ll);

      for(ll i=0;i<q;i++){
            ll cx =0;
            if(m[b[i]]){
                  cx = m[b[i]];
                  m[b[i]] = 0;
            } else {
                  cout << sum << endl;
                  continue;
            }
            m[c[i]]+=cx;
            sum = sum +(c[i] - b[i])*cx;
            cout << sum << endl;
      }


      
}


Measured memory_bytes: 9444
#include <iostream>

using namespace std;
int cnt[10];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int p=0;
    for(int i=0;i<n;i++){
        if(a[i]<3200){
            if(a[i]<400)cnt[1]=1;
            else if(a[i]<800)cnt[2]=1;
            else if(a[i]<1200)cnt[3]=1;
            else if(a[i]<1600)cnt[4]=1;
            else if(a[i]<2000)cnt[5]=1;
            else if(a[i]<2400)cnt[6]=1;
            else if(a[i]<2800)cnt[7]=1;
            else if(a[i]<3200)cnt[8]=1;



        }
        else p++;

    }
    int s=0;
    for(int i=1;i<9;i++)s+=cnt[i];
    if(s==0)cout<<1<<" "<<p;
    else
    cout<<s<<" "<<s+p;
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Dist(G *[][]int, s, t int) int {
  N := len((*G))
  D := make([]int, N)
  for i := range D {
    D[i] = -1
  }
  D[s] = 0
  Q := make([]int, 0)
  Q = append(Q, s)
  for 0 < len(Q) {
    q := Q[0]
    Q = Q[1:]
    for adj, e := range (*G)[q] {
      if 0 < D[adj] || e < 1 { continue }
      D[adj] = D[s] + 1
      Q = append(Q, adj)
    }
  }
  return D[t]
}

func Solve() {
  N := NextInt()
  A := NextIntVec()
  B := NextIntVec()
  for i, a := range A {
    if B[i] == a || B[i] * 2 < a { continue }
    Write(-1)
    return
  }
  G := make([][]int, 51)
  for i := range G {
    G[i] = make([]int, 51)
  }
  for d := 1; d < 50; d++ {
    for i := range G {
      G[i][i % d]++
    }
  }
  S := make([]int, 0)
  for s := 49; 0 < s; s-- {
    for i := range G {
      G[i][i % s]--
    }
    for i := 0; i < N; i++ {
      if Dist(&G, A[i], B[i]) < 0 {
        for j := range G {
          G[j][j % s]++
        }
        S = append(S, s)
        break
      }
    }
  }
  ans := 0
  for _, s := range S {
    ans += 1 << uint(s)
  }
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	string  A,B,C;
	cin >> A >> B >> C;
	cout << (char)(A[0]-0x20) << (char)(B[0]-0x20) << (char)(C[0]-0x20) <<endl;
	//(char)でint型をchar型にできる
	//小文字のコードは大文字のコードより0x20(16進数の“20”)大きい
	// str.size() strの文字数が取得できる
	return 0;
}


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

using namespace std;

#define MAX (10001)

bool is_prime[MAX+1];

void Sieve()
{
  fill(is_prime, is_prime+MAX, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i*i<=MAX; i++) {
    if(is_prime[i]) {
      for(int j=i*i; j<=MAX; j+=i) {
	is_prime[j] = false;
      }
    }
  }
}

int main() {
  
  Sieve();
  
  int N;
  while(cin >> N) {
    int ans = 0;
    for(int i=0; i<N; i++) {
      ans += is_prime[i+1] && is_prime[N-i];
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}


int main()
{
    ll n;
    cin >> n;
    ll ans = INF;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0){
            ll a, b;
            a = n / i;
            b = i;
            ans = min(ans, (b - 1) + (a - 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
flag = True
for i in range(1, n-1):
    if h[n-i] - h[n-i-1] == -1:
        h[n-i-1] -= 1
    elif h[n-i] - h[n-i-1] < -1:
        flag = False
if flag:print("Yes")
else:print("No")

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

int main() {


	

	int n;
	int flag = 0;


	int a[200000];
	

	cin >> n;
	for (int i = 0; i < n; i++) {

		cin >> a[i];
	}

	sort(a, a + n);

	for (int i = 0; i < n-1; i++) {
		if (a[i] == a[i + 1]) {
			flag = 1;
			break;
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] == a[j]) {
				flag = 1;
				break;
			}



		}

		if (flag == 1)break;
	}
	*/

	if (flag == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;

}

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

//a進法でのnの桁和
int digitsum(int n, int a){
  int res = 0;
  while(n > 0){
    res += n % a;
    n /= a;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = n;
  for (int i = 0; i <= n; i++){
    int tmp = digitsum(i, 6) + digitsum(n - i, 9);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin>>n;
  double ans;
  if (n % 2 == 0) {
    ans = 0.5;
  } else {
    ans = (1.0)*((n - 1) / 2 + 1) / n;
  }
  printf("%.7lf\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n,k;
		double win = 0;

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		for(int i=1;i<=n;i++) {
			int p = i;
			int j = 0;
			while(p<k) {
				j++;
				p = i*(int)Math.pow(2, j);
				
			}
			win += (1.0/(double)n)*Math.pow(0.5, j);

		}
//		String str = String.valueOf(String.format("%.13f", win));
		System.out.println(win);
	}
}


Measured memory_bytes: 21844
"use strict"

function Main(input) {
  let args = input.split("\n");

  let NM = args[0].split(" ");

  let N = parseInt(NM[0], 10);
  let M = parseInt(NM[1], 10);

  args.shift();
  args.pop();

  let citys = args.map((e, i) => {
    let cityInfo = e.split(" ").map(e => parseInt(e));
    return [i, cityInfo[0], cityInfo[1]]
  });

  citys.sort((a, b) => (a[2] - b[2]));

  let countryCount = Array(N + 1).fill(1);

  citys.forEach((e) => {
    e[3] = ('000000' + e[1]).slice(-6) + ('000000' + countryCount[e[1]]).slice(-6);
    countryCount[e[1]]++;
  });

  citys.sort((a, b) => (a[0] - b[0]));

  let result = '';
  citys.forEach(e => result += (e[3] + '\n'));
  console.log(result.trim());
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 94272
#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen=1<<18|1;
inline char gc(){
	static char buf[rlen],*ib,*ob;
	(ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin));
	return ib==ob?-1:*ib++;
}
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
const int mod=1e9+7;
typedef pair<int,int> pii;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:(a-=mod);}
inline void Dec(int&a,int b){(a-=b)<0?(a+=mod):a;} 
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
const int N=2005;
int a[N],n,k,ans=0;
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read(),k=read();
	for(ri i=1;i<=n;++i)a[i]=read();
	for(ri i=1;i<=n;++i)for(ri j=i+1;j<=n;++j){
		if(a[i]>a[j])Add(ans,k);
	}
	for(ri t=0,coe=(ll)k*(k-1)/2%mod,i=1;i<=n;++i,t=0){
		for(ri j=1;j<=n;++j)if(a[i]>a[j])++t;
		Add(ans,mul(coe,t));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val h, w = sc.nextInt()
    
    val map = Array.ofDim[Char](h, w)
    
    for (i <- map.indices) {
      val a = sc.next().toCharArray
      map(i) = a
    }
    
    var ans = "Yes"
    
    for (i <- 0 until h) {
      for (j <- 0 until w) {
        if (map(i)(j) == '#') {
          val arr = Array((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)).filter(a => 0 <= a._1 && a._1 < h && 0 <= a._2 && a._2 < w)
          val m = arr.map(a => map(a._1)(a._2))
          if (!m.contains('#')) {
            ans = "No"
          }
        }
      }
    }
    
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}


Measured memory_bytes: 27980
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll s=S.size();
    ll t=T.size();
    //sA[i]はS[i-1]までのAの個数
    vector<ll> sA(s+1,0);   
    vector<ll> sB(s+1,0);

    vector<ll> tA(t+1,0);
    vector<ll> tB(t+1,0);

    for(ll i=1;i<=s;++i){
        sA[i]=sA[i-1];
        sB[i]=sB[i-1];
        if(S[i-1]=='A')sA[i]++;
        else sB[i]++;
    }
    for(ll i=1;i<=t;++i){
        tA[i]=tA[i-1];
        tB[i]=tB[i-1];
        if(T[i-1]=='A')tA[i]++;
        else tB[i]++;
    }
    ll q;
    cin >> q;
    for(ll i=0;i<q;++i){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;c--;d--;
        ll K=sA[b+1]-sA[a]-tA[d+1]+tA[c];
        ll L=sB[b+1]-sB[a]-tB[d+1]+tB[c];
        if((L-K+3000000000)%3==0)prt("YES")
        else prt("NO")
    }

    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
double dp[100000]; // dp[i]: 現在の得点がiのときの勝率
int main()
{
    int N, K; cin >> N >> K;
    for (int i = K-1; i >= 1; i--) {
        dp[i] = 0.5 * (i * 2 >= K ? 1.0 : dp[i*2]) + 0.5 * 0;
    }
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += (i >= K ? 1.0 : dp[i]) / N;
    }
    cout << fixed << setprecision(12) << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    for (int i = 0; i < 4; i++) {
        s[i] -= '0';
    }

    int a0 = s[0] * 10 + s[1];
    int a1 = s[2] * 10 + s[3];

    int b = 0;
    if (1 <= a0 && a0 <= 12) b ^= 1;
    if (1 <= a1 && a1 <= 12) b ^= 2;

    string r[4] = { "NA", "MMYY", "YYMM", "AMBIGUOUS", };
    cout << r[b] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  int arr[N+1];
  for(int i=1; i<=N; i++){
    if(i%3  == 0 || i%5 ==0)
      arr[i] = 0;
    else
      arr[i] = i;
  }

  long long sum = 0;
  for(int i=1; i<=N; i++)
    sum += arr[i];

  cout << sum << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    x.at(i) = lower_bound(a.begin(), a.end(), b.at(i)) - a.begin();
  }
  vector<long> xsum(n + 1);
  for (int i = 0; i < n; i++) {
    xsum.at(i + 1) = xsum.at(i) + x.at(i);
  }
  long s = 0;
  for (int i = 0; i < n; i++) {
    s += xsum.at(lower_bound(b.begin(), b.end(), c.at(i)) - b.begin());
  }
  cout << s << endl;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	a, _ := strconv.Atoi(s)
	fmt.Println(a + int(math.Pow(float64(a), 2)+math.Pow(float64(a), 3)))
}


Measured memory_bytes: 1772
s = input()
n = len(s)
t = int(s, 2)

l = [i % 2 for i in range(1, n + 1)]
b = ''.join(map(str, l))

p = int(b, 2)
q = p >> 1

a = bin(t ^ p).count('1')
b = bin(t ^ q).count('1')

print(min(a, b))

Measured memory_bytes: 55696
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  rep2(i, A, B + 1) {
    string s = to_string(i);
    string ss = s;
    REVERSE(s);
    if (ss == s) {
      ans++;
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  long long int l,r;
  
  long long int sum=0;
  for(int i=0;i<N;i++){
    cin >> l >> r; 
    sum+=r-l+1;
      }
  cout << sum << endl;}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    println!("ABC{}", s);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}


let _ = {
    let n = Int(readLine()!)!
    let A = readWords { Int($0)! }

    let total = A.reduce(0, ^)
    print(A.map { (total^$0).description }.joined(separator: " "))
}()

Measured memory_bytes: 26468
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
 
using namespace std;

class Point {
  public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() {return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
 
typedef Point Vector;

typedef struct Segment{
  Point p1, p2;
};

typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef vector<Point> Polygon;

double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
  return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Segment s1, Segment s2){
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b){
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
  return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2){
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p){
  Vector base = s.p2 - s.p1;
  double r = dot(p-s.p1, base) / base.norm();
  return s.p1 + base * r;
}

Point reflect(Segment s, Point p){
  return p + (project(s, p) - p) * 2.0;
}
 
int main(){
  Segment s;
  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;

  int q;
  scanf(" %d", &q);
  for(int i = 0; i < q; ++i){
    Point p;
    cin >> p.x >> p.y;
    Point ans = reflect(s, p);
    printf("%.10lf %.10lf\n", ans.x, ans.y);
  }
}


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

int main() {
  int n;
  cin >> n;
  if (n%10==2 ||n%10==4 ||n%10==5 || n%10==7 ||n%10==9) {
    cout << "hon" << endl;
  }
  else if (n%10==0 ||n%10==1||n%10==6 || n%10==8 ) {
    cout << "pon" << endl;
  }
  else cout << "bon" << endl;
    
}




Measured memory_bytes: 3624
N, M = map(int, input().split(" "))
stores = []

for i in range(N):
    Ai, Bi = map(int, input().split(" "))
    stores.append((Ai, Bi))    

price = 0
for a, b in sorted(stores, key=lambda x: x[0]):
    if M <= b:
        price += a * M
        break
    else:
        price += a * b
        M -= b
print(price)


Measured memory_bytes: 18948
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int a,b;
	double check=0;
	string s;
	cin >> a >> b;
	s = to_string(b);
	check = pow((double)(a * pow(10, s.length()) + b), 1.0/2.0);
	cout << (ceil(check) == floor(check) ? "Yes" : "No")  << endl;
} 


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int K;
    cin >> K;

    while (K % 2 == 0) K /= 2;
    while (K % 5 == 0) K /= 5;

    vi dist(K, INT_MAX);
    dist[1] = 0;

    for (deque<int> dij({1}); !dij.empty(); ) {
        int loc = dij.front(); dij.pop_front();
        if (dist[loc] < dist[10 * loc % K]) {
            dist[10 * loc % K] = dist[loc];
            dij.push_front(10 * loc % K);
        }
        if (dist[loc] + 1 < dist[(loc + 1) % K]) {
            dist[(loc + 1) % K] = dist[loc] + 1;
            dij.push_back((loc + 1) % K);
        }
    }

    cout << dist[0] + 1 << endl;

    return 0;
}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;

int main(){
	cin >> n >> m;
	cout << n+m/2 << endl;
	return 0;
}

Measured memory_bytes: 256