akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct edge {
    ll to, cost;
};
struct Gragh {
    vector<vector<edge>> G;
    ll N;
    vl visited;
    void init(ll n) {
        N = n;
        G.resize(N);
        visited = vl(N, 0);
    }

    void add(ll a, ll b, ll c = 1) { G[a].push_back((edge){b, c}); }

    void resetv(void) { visited = vl(N, 0); }

    vector<vl> d;
    vector<vl> warshall_floyd(void) {
        d.resize(N);
        rep(i, N) { d[i].resize(N); }
        rep(i, N) {
            rep(j, N) {
                if(i == j)
                    d[i][j] = 0;
                else
                    d[i][j] = INF;
            }
        }

        rep(i, N) {
            for(edge E : G[i]) {
                d[i][E.to] = E.cost;
            }
        }

        for(ll k = 0; k < N; k++) {         // 経由する頂点
            for(ll i = 0; i < N; i++) {     // 始点
                for(ll j = 0; j < N; j++) { // 終点
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        return d;
    }
};
vl B[MAX_N], C[MAX_N];
vl bfs1(ll x) {
    vl visited1(n + 1, 0);
    vl cost(n + 1, INF);
    vl Q1, Q2;
    visited1[x] = 1;
    k = 0;
    for(ll i : B[x]) {
        Q1.push_back(i);
    }
    while(!Q1.empty()) {
        Q2 = vl(0);
        for(ll i : Q1) {
            if(visited1[i] == 0) {
                cost[i] = k;
                visited1[i] = 1;
                for(ll j : B[i]) {
                    if(visited1[j] == 0) {
                        Q2.push_back(j);
                    }
                }
            }
        }
        Q1 = Q2;
        k++;
    }

    return cost;
}
int main() {
    cin >> n >> m >> l;
    Gragh G;
    G.init(n);
    rep(i, m) {
        cin >> a >> b >> c;
        a--;
        b--;
        G.add(a, b, c);
        G.add(b, a, c);
    }

    vector<vl> A;
    A = G.warshall_floyd();
    rep(i, n) {
        rep(j, n) {
            if(A[i][j] <= l)
                B[i].push_back(j);
        }
    }


    rep(i, n + 1) { C[i] = bfs1(i); }


    cin >> q;
    rep(i, q) {
        cin >> a >> b;
        a--;
        b--;
        cout << (C[a][b] == INF ? -1 : C[a][b]) << endl;
    }
}

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

using namespace std;

#define ll long long
#define md 1000000007
#define loop(i,a,b) for(int i=a; i<b; i++)
#define lloop(i,a,b) for (long long i=a; i<b; i++)
#define loopr(i,a,b) for(int i = a; i>=b; i--)
#define iterate(it, v) for (auto it = v.begin(); it!= v.end(); it++)
#define mk make_pair
#define pb push_back

template <typename T>
void printArray(T *arr, int n){
    loop(i,0,n){
        cout << arr[i] << " ";
    } cout << endl;
}

template <typename T>
void printMatrix(T **arr, int m, int n){
    loop(i,0,m){
        loop(j,0,n) cout << arr[i][j] << " ";
    } cout << endl;
}

ll int getMaxValue(int *w, int *v, int n, int W) {
    ll int dp[W+1];
    
    memset(dp, 0, sizeof(dp));
    
    loop(i,0,n) {
        loopr(j,W,w[i]) {
            dp[j] = max(dp[j], (ll)dp[j-w[i]] + (ll)v[i]);
        }
    }
    return dp[W];
}

int main(){
    int n, W;
    cin >> n >> W;
    int w[n], v[n];
    loop(i,0,n) cin >> w[i] >> v[i];

    cout << getMaxValue(w, v, n, W) << endl;
}

Measured memory_bytes: 1024
import numpy as np

n = int(input())
answer = [[i * j for j in range(1, 10)] for i in range(1, 10)]

flag = 0
for ans in answer:
  for a in ans:
    if a == n:
        flag=1
        break

if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21164
N = gets.to_i
P = gets.chomp.split(" ").map(&:to_i)

count = 0
min = P[0]

P.each_with_index do |x, i|
    if i ==  0
        count += 1
    elsif min >= x
        min = x
        count += 1
    end
end

puts "#{count}"


Measured memory_bytes: 18564
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
double n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << 2*n*3.1415926535 << "\n";
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int x;
    cin >> x;
    int kosu=x/100;
    x-=kosu*100;
    if(x<=kosu*5)cout << 1;
    else cout << 0;
    
    


}

/*



 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=100005;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int r,d,x;
      cin>>r>>d>>x;
      for(int i=0;i<10;i++)
      {
            x=r*x-d;
            cout<<x<<"\n";
      }
}


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

using namespace std;

#define MAX 500
#define MAX_M 10001

int main(){
  int N,M;
  while(cin >> N >> M,(N | M)){
    bool F[MAX] = {0},C[MAX] = {0};
    int A[MAX_M] = {0},B[MAX_M] = {0}, idx = 0;
    for(int i = 0 ; i < M ; i++){
      int a,b;
      cin >> a >> b; a--; b--;
      if(!a){
        F[b] = C[b] = true;
      }else{
        A[idx] = a; B[idx++] = b;
      }
    }
    for(int i = 0 ; i < idx ; i++){
      if(!F[A[i]] && F[B[i]]){
        C[A[i]] = true;
      }else if(F[A[i]] && !F[B[i]]){
        C[B[i]] = true;
      }
    }
    cout << count(C,C+N,1) << endl;
  }
  return 0;
}

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

using namespace std;

int main(void) {
  int N; cin >> N;
  N %= 10;

  if (N == 3) {
    cout << "bon" << endl;
  } else if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1ll << 60;
    rep(i, n) {
        vector<ll> vec, tmp;
        rep(j, n) {
            if (a[j] < a[i]) {
                if (tmp.size() >= k) {
                    sort(tmp.begin(), tmp.end());
                    rep(t, tmp.size() - (k - 1)) {
                        vec.push_back(tmp[t]);
                    }
                }
                tmp.clear();
            } else {
                tmp.push_back(a[j]);
            }
        }
        if (tmp.size() >= k) {
            sort(tmp.begin(), tmp.end());
            rep(t, tmp.size() - (k - 1)) {
                vec.push_back(tmp[t]);
            }
        }
        sort(vec.begin(), vec.end());
        if (vec.size() >= q) {
            ans = min(ans, vec[q - 1] - vec[0]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
const main = (txt: any): void => {
  const input = txt.split('\n')
  for (let i = 3; i <= parseInt(input[2]) + 2; i++) {
    let T: number[] = input[1].split(' ').map((i: string) => parseInt(i))
    const [p, x] = input[i].split(' ').map((i: string) => parseInt(i))
    T[p - 1] = x
    console.log(T.reduce((a, b) => a + b))
  }
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 8096
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

#define MODULO 1000000007

typedef long long ll;
using namespace std;

ll factorial(ll N) {
  if (N == 0) {
    return 1;
  } else {
    return (N * factorial(N - 1) % MODULO);
  }
}

int main(void) {
  ll N, M; cin >> N >> M;
  if (abs(N - M) > 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = N == M ? 2 : 1;
  ll fact1 = factorial(N);
  ll fact2 = factorial(M);
  ans = (ans * fact1) % MODULO;
  ans = (ans * fact2) % MODULO;
  cout << ans << endl;
}


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

int Breaking_bricks(vector<int> b,int n){
  int now = 1;
  int bb = 0;
  rep(i,n){
    if(now == b[i]) now++;
    else bb++; 
  }
  return (bb != n) ? bb : -1;
}

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n,0);
  rep(i,n){
    scanf("%d",&a[i]);
  }

  int ans = Breaking_bricks(a,n);
  cout << ans << endl;
 }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int w,a,b;
  cin >> w>>a>>b;
  if( w+a < b){
    cout << b-(w+a);
  }
  else if(b+w<a){
    cout << a-(b+w);
  }
  else{
    cout << 0;
  }
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w) { this->w = w; }
	void inline fix() { w %= mod; if (w < 0) w += mod; }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	modulo inline operator + (const modulo &b) { modulo r = *this; r += b; return r; }
	modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	
	modulo inline operator - (const modulo &b) { modulo r = *this; r -= b; return r; }
	modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	
	modulo inline operator * (const modulo &b) { modulo r = *this; r *= b; return r; }
	modulo& operator *= (const modulo &b) { w = (num) w * b.w % mod, fix(); return *this; }
	
	modulo inline operator / (const modulo &b) { modulo r = *this; r /= b; return r; }
	modulo& operator /= (const modulo &b) { *this *= b.inv(); return *this; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		// if (!w)  return 0;
		modulo a = *this, res = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1)  res *= a;
		return res;
	}
};

typedef modulo<998244353> rem;

const int nsz = int(2e5);
rem n, m, k, fac[nsz + 5], ifc[nsz + 5], ans;

void inline init() {
	fac[0] = ifc[0] = 1;
	cont (i, n) {
		fac[i] = fac[i - 1] * rem(i);
		ifc[i] = fac[i].inv();
	}
}

rem inline C(int n, int m) { return fac[n] * ifc[m] * ifc[n - m]; }

rem inline f(int n, int k) { return C(n - 1, k) * m * (m - rem(1)).pow(n - k - 1); }

int main() {
	scanf("%d%d%d", &n, &m, &k);
	init();
	circ (i, 0, int(k)) {
		ans += f(n, i);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 5376
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long x;

int main(){
    scanf("%ld", &x);
    if(x == 3 || x == 5 || x == 7){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}


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

ll choose(ll n){
    return n*(n-1)/2;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n)  a[i]--;
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    ll tot = 0;
    rep(i,n){
        tot += choose(cnt[i]);
    }
    rep(i,n){
        ll ans = tot;
        ans -= choose(cnt[a[i]]);
        ans += choose(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4344
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<pii>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"
 
int n;
 
bool read() {
    if (!(cin >> n)) {
        return 0;
    }
    return 1;
}

const int bound = 30000;
 
vi solve() {
    vvi by_rem(6);
    forn (i, bound + 1) if (i)
        by_rem[i % 6].pb(i);

    forn (i, 6)
        reverse(all(by_rem[i]));

    if (n == 3)
        return {2, 5, 63};
    
    vi ans;

    auto add = [&] (int rem)
    {
        assert(sz(by_rem[rem]) >= 1);
        ans.pb(by_rem[rem].back());
        by_rem[rem].pop_back();
    };

    add(3);
    add(3);
    add(2);
    add(4);
    n -= 4;

    while (n >= 2 && sz(by_rem[3]) >= 2)
    {
        add(3);
        add(3);
        n -= 2;
    }
    while (n >= 2 && sz(by_rem[2]) >= 1)
    {
        assert(sz(by_rem[2]) == sz(by_rem[4]));
        add(2);
        add(4);
        n -= 2;
    }
    while (n >= 1 && sz(by_rem[0]) >= 1)
    {
        add(0);
        n -= 1;
    }

    assert(n == 0);
    return ans;
}

int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    while (read()) {
        vi ans = solve();
        for (int x : ans)
            cout << x << ' ';
        cout << endl;
    }
 
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> dict(n, -1);
    vector<ll> a(n);
    rep(i,n) {
        int A;
        cin >> A;
        A--;
        a[i] = A;
    }
    ll now = 0;
    ll next = a[0];
    ll loop = -1;
    ll temae = -1;
    dict[0] = 0;
    rep(i,k){
        next = a[now];
        if(dict[next] != -1) {
            loop = next;
            temae = now;
            break;
        }
        dict[next] = dict[now] + 1;
        now = next;
    }
   

    if(loop == -1) {
        cout << now + 1 << endl;
        return 0;
    }
    
    ll loopback = dict[loop];
    ll looplength = dict[temae] - loopback + 1;
    ll cnt = (k - loopback) % looplength;
    ll ans = loop;

    rep(i,cnt){
        ans = a[ans];
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[110], b[110];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i < n - 1; ++i) {
		if (a[i - 1] == b[i - 1]) {
			if (a[i] == b[i]) {
				if (a[i + 1] == b[i + 1]) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()

	fmt.Println(N*800 - 200*(N/15))

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 640
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
P p[100010];
int c[100010], d[100010];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> c[i] >> d[i];
	}

	rep(i, n) {
		p[i].first = c[i] - d[i];
		p[i].second = c[i] + d[i];
	}
	sort(p, p + n);
	int now = p[0].second;
	int ans = 1;
	loop(i, 1, n) {
		if (p[i].first >= now) {
			now = p[i].second;
			ans++;
		}
		else {
			now = min(now, p[i].second);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) 
{
  int left = 0;
  int right = n;
  int mid;
  while(left < right) 
  {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) 
{
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) 
  {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) 
  {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


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

int main(){
  int n; cin >> n;
  int out = 0, ind = 1;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    if(a == ind){
      out++;
      ind++;
    }
  }
  if(out == 0){
    cout << -1;
  }else{
    cout << n - out;
  }
}

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

int main(){
  vector<int> vec(5);
  int count=0;
  int sum=0;
  int vec_a_sum=0;
  for(int i=0;i<5;i++){
    cin>>vec.at(i);
    sum+=vec.at(i);
    if(vec.at(i)%10==0){
      count++;
    }
    vec.at(i)%=10;
    vec_a_sum+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(count==5){
    cout<<sum<<endl;
  }
  else{
    cout<<sum+50-(count+1)*10
        -vec_a_sum+vec.at(count)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math


def calc_minkowski_distance(x1, x2, p):
    """calc L_p norm(finite dimension)

    Args:
        x1: vector1
        x2: vector2
        p: p in L_p

    Returns:
        L_p distance between x1 and x2 (float)
    """
    if p == "inf":
        return max([math.fabs(x[0] - x[1]) for x in zip(x1, x2)])
    else:
        return math.pow(sum([math.pow(math.fabs(x[0] - x[1]), p) for x in zip(x1, x2)]), 1.0 / p)


target = [1, 2, 3, "inf"]
dimension = int(raw_input())
x1 = [float(x) for x in raw_input().split()]
x2 = [float(x) for x in raw_input().split()]
for p in target:
    print(calc_minkowski_distance(x1, x2, p))

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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	set<int> s;
	while(n--) {
		int x;
		scanf("%d", &x);
		if(s.count(x)) return printf("NO\n"), 0;
		s.insert(x);
	}
	printf("YES\n");
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++){
		if(n % i == 0){
			int a = i, b = n / i;
			if(a <= 9 && b <= 9){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char words[10][5]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
char in[2100][2100];
int T[2100][2100];
int D[2100][2100];
int L[2100][2100];
int R[2100][2100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++){
		int cur=0;
		for(int j=0;j<b;j++){
			if(in[i][j]=='#')cur=0;
			else cur++;
			L[i][j]=cur;
		}
	}
	for(int i=0;i<a;i++){
		int cur=0;
		for(int j=b-1;j>=0;j--){
			if(in[i][j]=='#')cur=0;
			else cur++;
			R[i][j]=cur;
		}
	}
	for(int i=0;i<b;i++){
		int cur=0;
		for(int j=0;j<a;j++){
			if(in[j][i]=='#')cur=0;
			else cur++;
			T[j][i]=cur;
		}
	}
	for(int i=0;i<b;i++){
		int cur=0;
		for(int j=a-1;j>=0;j--){
			if(in[j][i]=='#')cur=0;
			else cur++;
			D[j][i]=cur;
		}
	}
	int ret=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(in[i][j]=='.'){
				ret=max(ret,L[i][j]+R[i][j]+T[i][j]+D[i][j]-3);
			}
		}
	}
	printf("%d\n",ret);
}

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

char str[5005],mid[5][10],temp[5];

int main()
{
	int s,ok,l;
	scanf("%s%d",&str,&s);
	l = strlen(str);
	for (int i = 0; i < 5; i++)
	{
		for (int j = 0; j < 5; j++)
		{
			mid[i][j] = 'z' + 1;
		}
		mid[i][5] = '\0';
	}
	for (int i = 0; i < l; i++)
	{			
		for (int j = 1; j <= 5; j++)
		{
			if (i + j > l)
			{
				continue;
			}
			for (int k = 1; k <= j; k++)
			{
				temp[k - 1] = str[i + k - 1];
			}
			for (int k = j + 1; k <= 5; k++)
			{
				temp[k - 1] = '\0';
			}
			for (int k = 0; k < 5; k++)
			{
				ok = 0;
				for (int m = 0; m < 5; m++)
				{
					if (temp[m] < mid[k][m])
					{
						ok = 1;
						for (int n = 4; n > k; n--)
						{
							for (int o = 0; o < 5; o++)
							{
								mid[n][o] = mid[n - 1][o];
							}
						}
						for (int n = 0; n < 5; n++)
						{
							mid[k][n] = temp[n];
						}
						break;
					}
					else if (temp[m] > mid[k][m])
					{
						ok = 2;
						break;
					}
				}
				if (ok < 2)
				{
					break;
				}
			}
		}
	}
	printf("%s\n",mid[s - 1]);
	return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
	let mut vs = vec![];
    for i in 0..5 {
    	vs.push(get!());
    }
    
    fn dfs(vs: &Vec<i64>, ans: &mut i64, cur: i64, p: usize) {
    	if p + 1 == 1 << 5 {
        	*ans = std::cmp::min(*ans, cur);
            return;
        }
        let cur = ((cur + 9) / 10) * 10;
        for i in 0..5 {
        	if p & (1 << i) == 0 {
            	let tmp = cur + vs[i];
                dfs(vs, ans, tmp, p | (1 << i));
            }
        }
    }
    
    let mut ans = 1000000;
    dfs(&vs, &mut ans, 0, 0);
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
    static void solve(){//Here is the main function
      int N = nextInt();
      int x = 800 * N;
      int y = 200 * (N / 15);
      myout(x - y);
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 33008
<?php
fscanf(STDIN, '%d', $num);
$ans = 0;
for ($i=1; $i <= $num ; $i++) { 
    for ($j=1; $j <= $num ; $j++) {
        $ij = gmp_gcd($i, $j); 
        for ($k=1; $k <= $num ; $k++) { 
            if ($k === 1) {
                $ans++;
                continue;
            }
            $ans+=gmp_gcd($ij, $k); 
        }
    }
}
echo $ans; 

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

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ----- end of debug ---------

const int N = 200010;
vector<long long> tree(4 * N), lazy(4 * N);

void push_down(int lb, int rb, int v) {
  tree[2 * v] += lazy[v];
  tree[2 * v + 1] += lazy[v];
  lazy[2 * v] += lazy[v];
  lazy[2 * v + 1] += lazy[v];
  lazy[v] = 0;
}

long long query(int ql, int qr, int lb ,int rb, int v) {
  if (rb <= ql || qr <= lb) return 1e18;
  if (ql <= lb && rb <= qr) return tree[v];
  push_down(lb, rb, v);  
  int m = (lb + rb) / 2;
  return min(query(ql, qr, lb, m, 2 * v), query(ql, qr, m, rb, 2 * v + 1));
}

void add(int ql, int qr, long long w, int lb, int rb, int v) {
  if (rb <= ql || qr <= lb) {
    return;
  }
  if (ql <= lb && rb <= qr) {
    tree[v] += w;
    lazy[v] += w;
    return;
  }
  push_down(lb, rb, v);
  int m = (lb + rb) / 2;
  add(ql, qr, w, lb, m, 2 * v);
  add(ql, qr, w, m, rb, 2 * v + 1);
  tree[v] = min(tree[2 * v], tree[2 * v + 1]);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n, m;
  cin >> n >> m;
  vector< vector< pair<int,int> > > intervals(n + 2);
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    int l, r, w;
    cin >> l >> r >> w;
    sum += w;
    intervals[r].emplace_back(l, w);
  }

  vector<long long> dp(n + 2);
  for (int i = 1; i <= n + 1; i++) {
    dp[i] = query(0, i, 0, n + 2, 1);
    add(i, i + 1, dp[i], 0, n + 2, 1);
    for (auto seg : intervals[i]) {
      int l, w;
      tie(l, w) = seg;
      add(0, l, w, 0, n + 2, 1);
    }
  }
  debug(dp);
  cout << sum - dp[n + 1] << '\n';
  return 0;
}

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

int main(){
  int x, y; cin >> x >> y;
  
  map<int, int> group;
  group.insert(make_pair(1, 0));
  group.insert(make_pair(3, 0));
  group.insert(make_pair(5, 0));
  group.insert(make_pair(7, 0));
  group.insert(make_pair(8, 0));
  group.insert(make_pair(10, 0));
  group.insert(make_pair(12, 0));
  group.insert(make_pair(4, 1));
  group.insert(make_pair(6, 1));
  group.insert(make_pair(9, 1));
  group.insert(make_pair(11, 1));
  group.insert(make_pair(2, 2));
  
  if (group.at(x) == group.at(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> W;
    W.push_back(0);
    for (int i=1;i<=N;i++) {
        int Wi;
        cin >> Wi;
        W.push_back(Wi);
    }

    int ans=INT32_MAX;

    for (int T=1;T<N;T++) {
        int S1=0;
        for (int i=1;i<=T;i++) {
            S1 += W[i];
        }
        int S2=0;
        for (int i=T+1;i<=N;i++) {
            S2 += W[i];
        }
        ans = min(ans, abs(S1-S2));
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll temp = max({a * c, a * d, b * c, b * d});

    if((a <= 0 && 0 <= b) || (c <= 0 && 0 <= d))
    {
        temp = max(temp, 0LL);
    }

    cout << temp;

    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,store="";
            boolean first=true;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("END_OF_TEXT"))break;
            	if(first){
            		store=line.toLowerCase();
            		first=false;
            	}else{
            		String[] str = line.split(" ");
            		for(int i=0;i<str.length;i++){
            			if(store.equals(str[i].toLowerCase())){
            				sum++;
            			}
            		}
            	}
            }
            System.out.println(sum);
        }
    }

}

Measured memory_bytes: 24196
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    FastScanner sc;

    void run() {
        sc = new FastScanner();
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();

        if ("+".equals(op)) {
            System.out.println(a + b);
        } else {
            System.out.println(a - b);
        }
    }
}

/** 標準入力読み込み用クラス */
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;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        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();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main(void){
    long long n, sum;
    cin >> n;
    sum = 0;

    for(long long i = 1; i <= n; ++i){
        if(i % 3 == 0 || i % 5 == 0)sum += i;
    }
    cout << ((1 + n) * n) / 2 - sum << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 998244353, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */
const int N = 3e5+1;

ll n, a, b, k, ans, fact[N];
ll modPow(ll b, ll e) {
	if(e == 0) return 1;
	if(e == 1) return b;
	return modPow(b*b % MOD, e >> 1) * modPow(b, e & 1) % MOD;
}
ll C(int n, int k) {
	return fact[n] * modPow(fact[k], MOD-2) % MOD * modPow(fact[n-k], MOD-2) % MOD;
}
int main() {
	cin >> n >> a >> b >> k;
	fact[0] = 1;
	fori(i, 1, n) fact[i] = fact[i-1] * i % MOD;
	fori(x, 0, n) {
		if((k - a*x) % b) continue;
		ll y = (k - a*x) / b;
		if(y >= 0 && y <= n) ans += C(n, x) * C(n, y) % MOD;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main (){
    int n,q;
    cin >> n >> q;
    int l,r;
    int j=0;
    string  s;
    cin >> s;
    int h[100005] = {};
    for(int i=1;i<=n;i++){
        h[i]=h[i-1];
        if(s[i-1]=='A'&&s[i]=='C'){
            h[i]=h[i-1]+1;
        }
    }
    while(j<q){
        cin >> l >> r;
        cout << h[r-1]-h[l-1] << endl;
        j++;
    }
    return 0;
} 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (T&& t) noexcept
      : T(std::forward<T>(t)) {}
    template<typename... Args>
    constexpr decltype(auto) operator()(Args&&... args) const
      {return T::operator()(*this, std::forward<Args>(args)...);}
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{std::forward<T>(t)};
}

template<typename T>
class diameter {
    struct edge {
      size_t to; T cost;
      edge(size_t to, T cost) : to(to), cost(cost){}
    };
    size_t n;
    std::vector<std::vector<edge>> graph;

  public:
    diameter(size_t n) : n(n), graph(n){}

    // Insert an edge.
    void insert(size_t i, size_t j, T cost = 1) {
      assert(0 <= i && i < n);
      assert(0 <= j && j < n);
      graph.at(i).emplace_back(j, cost);
      graph.at(j).emplace_back(i, cost);
    };

    // Calculate the diameter.
    auto operator()(size_t root = 0){
      std::vector<T> depth; 
      auto cal = [&] (size_t r) {
        depth.assign(n, 0);
        fix ([&](auto dfs, size_t crr, size_t p) -> void {
          for (auto const& e : graph.at(crr)) {
            if (e.to == p) continue;
            depth.at(e.to) = depth.at(crr) + e.cost;
            dfs(e.to, crr);
          }
        })(r, r);
      };
      cal(root);
      auto ex = std::max_element(depth.begin(), depth.end()) - depth.begin();
      cal(ex);
      return *std::max_element(depth.begin(), depth.end());
    }
};
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  auto diam = diameter<int>(n);
  for (size_t _ = 0; _ < n - 1; _++) {
    size_t a, b; std::cin >> a >> b;
    a--, b--;
    diam.insert(a, b);
  }
  std::cout << (diam() % 3 == 1 ? "Second" : "First") << std::endl;;
  return 0;
}

Measured memory_bytes: 24448
import heapq
import math

def main():
    N = input()
    A = list(map(int, input().split()))

    res = 0
    max_a = A[0]
    for a in A[1:]:
        if max_a > a:
            res += (max_a - a)
        else:
            max_a = a

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 93708
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long n;
  cin >> n;
  while(n / 10){
    if(n % 10 == 7){
      cout << "Yes";
      return 0;
    }
    n /= 10;
  }
  if(n % 10 == 7){
      cout << "Yes";
      return 0;
  }
  cout << "No";
}

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

//#define rep(i,n) for(int i=0;i<(n);i++)
//#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};
ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

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

  int i,j;
  int X; cin >> X;
  vector<int>isprime(110001,1);
  isprime[0]=0; isprime[1]=0;
  for(i=2;i*i<=110000;i++){
      if(isprime[i]==0){continue;}
      for(j=2;j*i<=110000;j++){
          isprime[j*i]=0;
      }
  }
  for(i=X;i<=110000;i++){
      if(isprime[i]==1){cout << i << endl; return 0;}
  }
  cout << "NG";

  return 0;
}


Measured memory_bytes: 3756
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







template<class T> class SegmentTreeSum{
    int n = 0;
    std::vector<T> dat;
    T fill = 0;
public:
    SegmentTreeSum(){}
    SegmentTreeSum(int m, T fil = 0){
        fill = fil;
        int i = 1;
        while(i < m) i *= 2;
        n = i;
        dat.resize(2*i - 1);
        for(int j(0), j_len(2*i-1); j < j_len; ++j)
            dat[j] = fill;
    }

    void update(int k, T a){
        k += n - 1;
        T moto = dat[k];
        dat[k] = a;
        while(k){
            k = (k - 1) / 2;
            dat[k] += a - moto;
        }
    }

    void updateIncrease(int k, T a){
        update(k, dat[k+n-1] + a);
    }
    void updateIncrease(int k){
        updateIncrease(k, 1);
    }

    void updateDecrease(int k, T a){
        update(k, dat[k+n-1] - a);
    }
    void updateDecrease(int k){
        updateDecrease(k, 1);
    }

    T getSum(int a, int b, int k=0, int l=0, int r=-1){
        //[a, b[であることに注意
        if(r < 0) r = n;
        if(r <= a || b <= l) return fill;
        if(a <= l && r <= b) return dat[k];

        T vl = getSum(a, b, 2*k+1, l, (l+r)/2);
        T vr = getSum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }

    T getvalue(int k){
        return dat[k+n-1];
    }

    bool getExist(int l, int r){//全て非負と仮定
        //[l, r]
        return (getSum(l, r+1) > fill);
    }
};

int main(){
    int N, Q; std::cin >> N >> Q;
    SegmentTreeSum<long long> st(N);
    {
        int a;
        for(int i(0); i < N; ++i){
            std::cin >> a;
            st.update(i, a);
        }
    }
    {
        int op, l, r;
        for(int i(0); i < Q; ++i){
            std::cin >> op >> l >> r;
            if(op) std::cout << st.getSum(l, r) << "\n";
            else st.updateIncrease(l, r);
        }
    }
    return 0;
}


Measured memory_bytes: 12524
let [|a;b|] = stdin.ReadLine().Split() |> Array.map int
let amin = (a * 100 + 7) / 8
let amax = ((a + 1) * 100 + 7) / 8
let bmin = (b * 100 + 9) / 10
let bmax = ((b + 1) * 100 + 9) / 10
if amin>=bmax || bmin>=amax then stdout.WriteLine -1
else [amin;bmin] |> List.max |> stdout.WriteLine

Measured memory_bytes: 13396