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

int main(){
  int N,A,B,allsum=0;
  cin >> N >> A >> B;
  for(int i=0;i<N;i++){
    int sum=0;
    int C=i+1;
    while(C>0){
      sum+=C%10;
      C/=10;
    }
    if(A<=sum && sum<=B){
      allsum+=i+1;
    }
  }
  cout << allsum << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string ans = "";
  int n;
  cin >> n;
  vector<string> vec(n);
  vector<vector<int> > a(n, vector<int> (26, 0));
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    for (int j = 0; j < vec[i].size(); j++) {
      ++(a[i][ vec[i][j] - 'a']);
    }
  }

  for (int i = 0; i < 26; i++) {
    int m = INT_MAX;
    for (int j = 0; j < n; j++) {
      m = min(m, a[j][i]);
    }
    
    for (int r = 0; r < m; r++) {
      ans += (char)('a' + i);
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 256
// 2011/09/25 Tazoe

#include <iostream>
using namespace std;

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

	int n[100];
	for(int i=0; i<N; i++)
		cin >> n[i];

	long long DP[21];
	for(int i=0; i<=20; i++)
		DP[i] = 0;
	DP[n[0]] = 1;

	for(int i=1; i<N-1; i++){
		long long T[21];
		for(int j=0; j<=20; j++)
			T[j] = DP[j];

		for(int j=0; j<=20; j++)
			DP[j] = 0;

		for(int j=0; j<=20; j++){
			if(j+n[i]>=0&&j+n[i]<=20)
				DP[j+n[i]] += T[j];
			if(j-n[i]>=0&&j-n[i]<=20)
				DP[j-n[i]] += T[j];
		}
	}

	cout << DP[n[N-1]] << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    while (cin >> N, N) {
        int a, maxi = 0, mini = 1000, sum = 0;
        for (int i = 0; i < N; i++) {
            cin >> a;
            maxi = max(maxi, a);
            mini = min(mini, a);
            sum += a;
        }
        cout << (sum - maxi - mini) / (N - 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())

for i in range(1,n+1):
  k = n//i
  ans += i * k * (k+1) //2
print(ans)

  

Measured memory_bytes: 66724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
vector <int > A;





int main()
{

	cin >> N;


	A.resize(N);

	REP(i,N){
		cin >> A[i];
	}
	if(N == 1){
		cout << 1;
		return 0;
	}

	int ans = 1;
	int flag = 1;
	long v,oldv;
	FOR(i,0,N-1){
		v = A[i+1] - A[i];
		if(v == 0)
			continue;
		if(flag){
			oldv = v;
			flag = 0;
			continue;
		}
		if((oldv > 0 && v > 0) || (oldv < 0 && v < 0)){
			continue;
		} else {
			ans++;
			flag=1;
		}
	}
	cout << ans << endl;
}



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

list = []

for i in range(n):
    temperature = t - list_original[i]*0.006
    list.append(abs(a - temperature))

point = list.index(min(list)) + 1

print(point)


Measured memory_bytes: 3060
#if 1
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "angle1"


LL S(LL x) {
	LL sum = 0;
	while (x) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}

void solve()
{
	/*
	vector <LL> tmp;
	for (int i = 1; i < 1000000; i++) {
		bool fl = 0;
		for (int j = i + 1; j < 1000000; j++) {
			if (i * S(j) > j * S(i)) {
				fl = 1;
				break;
			}
		}
		if (!fl)
			tmp.pb(i);
	}
	*/
	LL k;
	cin >> k;
	LL start = 1;
	LL add = 1;
	for (int i = 0; i < k; i++) {
		cout << start << endl;
		while (LD(start + add) / S(start + add) > LD(start + 2 * add) / S(start + 2  *add)) {
			add *= 10;
		}
		start += add;
	}
	
}

int main()
{

	//START
	//freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
	//freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout);
	solve();


	//END		 
	return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
	forn(i, v.size())
		is >> v[i];
	return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
	forn(i, v.size())
		os << v[i] << " ";
	return os;
}
#endif

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;

    vector<string> era;
    vector<int> span;
    vector<int> end;
    for (int i = 0; i < n; i++) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      era.push_back(s);
      span.push_back(a);
      end.push_back(b);
    }

    for (int i = 0; i < m; i++) {
      int year;
      bool hit = false;
      cin >> year;
      for (int j = 0; j < n; j++)
        if (end[j] - span[j] <= year && year <= end[j] &&
            year - end[j] + span[j] != 0) {
          cout << era[j] << ' ' << (year - end[j] + span[j]) << endl;
          hit = true;
        break;
        }
      if (!hit)
        cout << "Unknown" << endl;
    }
    era.clear();
    span.clear();
    end.clear();
  }
  return 0;
}

Measured memory_bytes: 1304
use std::io::{Read};
use std::str::FromStr;

struct Scanner<R: Read> {
    r: R
}

impl<R: Read> Scanner<R> {
    fn new(r: R) -> Scanner<R> {
        Scanner{
            r: r,
        }
    }

    fn next<T>(&mut self) -> T
    where
    T: FromStr,
      <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.r.by_ref()
            .bytes()
            .map(|r: ::std::io::Result<u8>| -> u8 { r.unwrap() })
            .map(|u: u8| -> char { u as char})
            .skip_while(|c: &char| -> bool { c.is_whitespace() })
            .take_while(|c: &char| -> bool { !c.is_whitespace()})
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::cmp::max;

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin);

    let n: i32 = sc.next();
    let v: Vec<i32> = (0..n).map(|_| sc.next()).collect();
    let mut mv: i32 = std::i32::MIN;
    let mut buy_min: i32 = std::i32::MAX;

    for i in 0..n-1 {
        if v[i as usize] < buy_min {
            buy_min = v[i as usize]
        } else {
            continue;
        }

        for j in i+1..n {
            mv = max(mv, v[j as usize] - v[i as usize])
        }
    }
    println!("{}", mv);
}


Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> vec(10000010);
  ll sum = 0;
  int m;
  rep(i,N+1)
  {
    sum += i;
    if(sum >= N)
    {
      m = i;
      break;
    }
  }
  for(int i=m;i>0;i--)
  {
    if(N>=i)
    {
      cout << i << endl;
      N -= i;
    }
    if(N==0)
    {
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 42332
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(auto &a : s) cin>>a;
    vector<vector<int>> l(h,vector<int>(w));
    auto r = l,u = l, d = l;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j)if(s[i][j] != '#'){
            l[i][j] = 1;
            if(j)l[i][j] += l[i][j-1];
        }
        for(int j=w-1;j>=0;--j)if(s[i][j] != '#'){
            r[i][j] = 1;
            if(j != w-1)r[i][j] += r[i][j+1];
        }
    }
    for(int j=0;j<w;++j){
        for(int i=0;i<h;++i)if(s[i][j] != '#'){
            u[i][j] = 1;
            if(i)u[i][j] += u[i-1][j];
        }
        for(int i=h-1;i>=0;i--)if(s[i][j] != '#'){
            d[i][j] = 1;
            if(i != h-1) d[i][j] += d[i+1][j];
        }
    }
    ll ret = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            ret = max(ret , (ll)l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3ll);
        }
    }
    cout << ret << endl;
    return 0;
}



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

struct lazysegtree {
    int size;
    //初期値0
    vector<int> node, lazy;
    
    lazysegtree(int n) {
        size = 1;
        while (size<n) size *= 2;
        node.resize(2*size-1);
        lazy.resize(2*size-1);
    }
    
    void eval(int k) {
        node[k] += lazy[k];
        
        if (k<size-1) {
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        
        lazy[k] = 0;
    }
    
    void update(int a, int b, int x, int k, int l, int r) {
        eval(k);
        
        if (b<=l || r<=a) return;
        
        if (a<=l && r<=b) {
            lazy[k] += x;
            eval(k);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            //ここ変える
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
    
    int query(int a, int b, int k, int l, int r) {
        eval(k);
        if (b<=l || r<=a) return -1000000000;
        if (a<=l && r<=b) return node[k];
        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        //ここ変える
        return max(vl, vr);
    }
    
    //[a, b)にxを足す
    void add(int a, int b, int x) {
        update(a, b, x, 0, 0, size);
    }
    
    //[a, b)に対するクエリ
    int get(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};


int H, W, M;
vector<int> h, w;
vector<int> sub[300010];
int pl[300010];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W >> M;
    if (H==1 || W==1) {
        cout << M << endl;
        exit(0);
    }
    lazysegtree lst(H);
    rep(i, M) {
        int hi, wi; cin >> hi >> wi;
        hi--;
        wi--;
        h.pb(hi);
        w.pb(wi);
        sub[wi].pb(hi);
        lst.add(hi, hi+1, 1);
        pl[wi]++;
    }
    int ans = 0;
    rep(i, W) {
        for (auto& x:sub[i]) lst.add(x, x+1, -1);
        int M = lst.get(0, H);
        ans = max(ans, M+pl[i]);
        for (auto& x:sub[i]) lst.add(x, x+1, 1);
    }
    cout << ans << endl;
}

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

int main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  
  sort(v.begin(), v.end());
  
  double avg = v[0];
  
  for(int i=1;i<n;i++){
    avg += v[i];
    avg /= 2.0;
  }
  
  printf("%.10lf\n",avg);
  return 0;
}

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


int main()
{


    int n,d;
    cin>>n>>d;


    int wk=n%(2*d+1);

    if(wk==0)
        cout<<n/(2*d+1)<<endl;
    else
        cout<<n/(2*d+1)+1<<endl;
    

    return 0;
}   

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
    }

    int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for (int i = 0; i < M; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        --x; --y;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()
	matrix := make([][]byte, H)
	dp := make([][]int, H)

	for i := 0; i < H; i++ {
		matrix[i] = []byte(sc.NextLine())
		dp[i] = make([]int, W)
		fill(dp[i], H*W)
	}
	if matrix[0][0] == '#' {
		dp[0][0] = 1
	} else {
		dp[0][0] = 0
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			p := 0
			//fmt.Println(string(matrix[i][j]))

			if matrix[i][j] == '#' {
				p++
			}
			if j > 0 {
				pp := p
				if matrix[i][j-1] == '#' {
					pp = 0
				}
				dp[i][j] = min(dp[i][j], dp[i][j-1]+pp)
			}
			//fmt.Println(i, j, dp[i][j], p)

			if i > 0 {
				pp := p
				if matrix[i-1][j] == '#' {
					pp = 0
				}
				dp[i][j] = min(dp[i][j], dp[i-1][j]+pp)
			}
			//fmt.Println(i, j, dp[i][j])
		}
	}
	fmt.Println(dp[H-1][W-1])
}

func fill(arr []int, v int) {
	for i := 0; i < len(arr); i++ {
		arr[i] = v
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	unordered_map<string, int> m;
	string a[n];
	int ans = 0;
	rep(i,0,n)
	{
		cin>>a[i];
		m[a[i]]+=1;
		ans = max(ans, m[a[i]]);
	}	
	
	vector<string> v;
	
	rep(i,0,n)
	{
		if(m[a[i]] == ans)
		{
			v.push_back(a[i]);
			m[a[i]] = 0;
		}
	}
	sort(v.begin(), v.end());
	rep(i,0,v.size()) cout<<v[i]<<endl;
}




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

int main(){
	string ss,ans;
	while(cin>>ss){
		int size=ss.size();
		if(size%2==1){
			cout<<"NA"<<endl;
			continue;
		}
		for(int i=0;i<size;i+=2){
			int num1=ss[i]-'0';
			int num2=ss[i+1]-'0';
			if(num1<1 || num1>6 || num2<1 || num2>5){
				ans="NA";
				break;
			}
			int num=((int)(ss[i]-'0')-1)*5+((int)(ss[i+1]-'0'))-1;
			if(num<26){
				ans+=(char)(num+'a');
			}else if(num==26){
				ans+='.';
			}else if(num==27){
				ans+='?';
			}else if(num==28){
				ans+='!';
			}else if(num==29){
				ans+=" ";
			}else{
				ans="NA";
				break;
			}
		}
		cout<<ans<<endl;
		ans="";
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define y1 cgbngfgn
#define pb push_back
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fir first
#define m_p make_pair
#define sec second
#define files(name) freopen(name".dat","r",stdin); freopen (name".sol","w",stdout);
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#define time pdojegoritg
typedef long long ll;
typedef long double ld;
const int arr=500000;

bool dp[9001][9001*4];

signed main()
{
    string st;
    cin>>st;
    int x,y;
    cin>>x>>y;
    vector<int> vec1,vec2;
    int now=1;
    int sum=0;

    for (auto i:st)
    {
        if (i=='T')
        {
            if (now)
                vec1.pb(sum); else
                vec2.pb(sum);
            now=!now;
            sum=0;
        } else
        {
            sum++;
        }
    }
    if (now)
        vec1.pb(sum); else
        vec2.pb(sum);


    int pl=st.size()+100;
    dp[1][vec1[0]+pl]=1;
    //cout<<dp[1][1+pl];
    for (int i=2;i<=vec1.size();i++)
        for (int j=-pl;j<=pl;j++)
        if (dp[i-1][j+pl])
        {
            dp[i][j+pl+vec1[i-1]]=1;
            dp[i][j+pl-vec1[i-1]]=1;
        }
    //cout<<dp[2][-2+pl]<<'\n';


    bool ch=dp[vec1.size()][x+pl];
    dp[0][pl]=1;
    for (int i=1;i<=vec1.size();i++)
        for (int j=-pl;j<=pl;j++)
            dp[i][j+pl]=0;

    for (int i=1;i<=vec2.size();i++)
        for (int j=-pl;j<=pl;j++)
        if (dp[i-1][j+pl])
        {
            dp[i][j+pl+vec2[i-1]]=1;
            dp[i][j+pl-vec2[i-1]]=1;
        }


    ch&=dp[vec2.size()][y+pl];

    if (ch)
        cout<<"Yes"<<'\n' ;else
        cout<<"No"<<'\n';
}


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

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

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

  int n; cin >> n;
  map<ll, ll> mp;
  ll a;
  rep(i, n) {
    cin >> a;
    mp[a]++;
  }

  ll ans = 0;
  for(auto elem : mp) {
    if(elem.first != elem.second) {
      if(elem.second < elem.first) {
        ans += elem.second;
      } else {
        ans += elem.second-elem.first;
      }
    }
  }

  cout << ans << '\n';
  return 0;
}


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

/*
  ll n , m ;
  cin >> n >> m ;
  ll a , b , c ;
  cin >> a >> b >> c ;
  vector<ll> A(n) ;
  cout << "Yes" << endl ;
  cout << "No"  << endl ;
*/

int main(){
  ll n , k ;
  cin >> n >> k ;
  vector<ll> A(n) ;
  rep(i,n) cin >> A[i] ;
  rep(i,n-k){
    if( A[i] < A[k+i] ){
      cout << "Yes" << endl ;  
    }
    else{
      cout << "No"  << endl ;
    }
  }
}


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

using namespace std;

#define N 55

int n, m, Q, i, A[N], a[N], b[N], c[N], d[N], ans;

void dfs(int x,int y)
{
	int i, sum;
	
	if (x==n+1) {
		sum=0;
		for (i=1; i<=Q; i++) if (A[b[i]]-A[a[i]]==c[i]) sum+=d[i];
		ans=max(ans,sum);
		return;
	}
	for (i=y; i<=m; i++) {
		A[x]=i;
		dfs(x+1,i);
	}
}

int main (void)
{
	scanf("%d%d%d",&n,&m,&Q);
	for (i=1; i<=Q; i++) scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3760
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    mint ans=0;
    long long int x=0,y=0,i,j,n,k;
    scanf("%lld %lld\n",&n,&k);
    j=n;
    for(i=0;i<k;i++){
        x=x+i;
        y=y+j;
        j--;
    }
    ans+=y-x+1;
    for(;i<=n;i++){
        x=x+i;
        y=y+j;
        j--;
        ans+=y-x+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		if(n==1&&m==1) System.out.println(1);
		else if(n==1||m==1) System.out.println(Math.max(n, m)-2);
		else System.out.println((n-2)*(m-2));
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;

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

  cin >> N;
  int num4 = 0;
  int num2 = 0;
  rep(i, N) {
    int a; cin >> a;
    if (a%4==0) {
      num4++;
    } else if (a%2==0) {
      num2++;
    }
  }
  cout << ((num4*2+1 + (num2/2*2) >= N) ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, r=0, g=0, b=0;
  long long count = 0;
  string S;
  cin >> N >> S;
  
  for(int i=0; i<N; i++){
    if(S.at(i) == 'R')
      r++;
    else if(S.at(i) == 'G')
      g++;
    else
      b++;
  }
  
  count = r * b * g;
  
  
  for (int i=0;i<N-1; i++){
    for(int j=1; j<N; j++){
      int k = i+2*j;
      if(k<N){
        if(S.at(i) != S.at(i+j) && S.at(i+j) != S.at(k) && S.at(k) != S.at(i))
          count--;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3636
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = [input() for i in range(n)]
m = readInt()
t = [input() for i in range(m)]

ans = 0
for i in s:
  ans = max(ans,s.count(i)-t.count(i))
print(ans)

Measured memory_bytes: 9416
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;

public class Main {
    static ArrayList<Integer> counter = new ArrayList<>();

    static {
        counter.add(1);
    }

    public static void main(String[] args) throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String line = bufferedReader.readLine();
        long N = Long.parseLong(line);
        int lim = (int) Math.sqrt(N) + 1;
        ArrayList<Integer> pSet = new ArrayList<>();
        int cnt = 0;
        {
            int i = 2;
            if (isP(i, pSet)) {
                Pair pair = div(N, i);
                if (pair.cnt != 0) {
                    cnt += count(pair.cnt);
                    N = pair.res;
                }
                pSet.add(i);
            }
        }
        for (int i = 3; i < lim; i += 2) {
            int tlim = (int) Math.sqrt(N) + 1;
            if (tlim < i) {
                break;
            }
            if (isP(i, pSet)) {
                Pair pair = div(N, i);
                if (pair.cnt != 0) {
                    cnt += count(pair.cnt);
                    N = pair.res;
                }
                pSet.add(i);
            }
        }
        if (N != 1) {
            cnt++;
        }
        System.out.println(cnt);
    }

    private static int count(int src) {
        int size = counter.size();
        for (int i = 0; i < size; i++) {
            int l = counter.get(i);
            if (src < l) {
                return i;
            }
        }
        int max = counter.get(size - 1);
        for (int i = size; ; i++) {
            max += i + 1;
            counter.add(max);
            if (src < max) {
                return i;
            }
        }
    }

    private static Pair div(long src, int p) {
        int cnt = 0;
        while (true) {
            if (src / p * p == src) {
                src = src / p;
                cnt++;
            } else {
                return new Pair(src, cnt);
            }
        }
    }

    private static boolean isP(int src, ArrayList<Integer> pSet) {
        for (Integer p : pSet) {
            if (src / p * p == src) {
                return false;
            }
            if (p * p > src) {
                break;
            }
        }
        return true;
    }

    static class Pair {
        long res;
        int cnt;

        public Pair(long res, int cnt) {
            this.res = res;
            this.cnt = cnt;
        }
    }
}


Measured memory_bytes: 37900
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M, A;
	long long count = 0, ans = 0;
	map<long long, long long> mp;
	mp[0]++;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A;
		count += A % M;
		count = count % M;
		mp[count]++;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans += (it->second - 1) * it->second / 2;
	}
	cout << ans;
}

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

using namespace std;



int main(){
  int n;
  string vals;
  int res = 1;
  cin >> n;
  cin >> vals;
  string prev = vals.substr(0, 1);

  // cout<<"prev: " << prev << endl;
  // cout<<"vals:" << vals.substr(2, 1) <<endl;

  for(int i=1; i<n; i++){
    if(vals.substr(i, 1).compare(prev) != 0){
      res += 1;
      prev = vals.substr(i, 1);
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 512
//package AtCoder.ABC155;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        int n = in.NI();
        boolean fl = true;
        for (int i=0;i<n;i++){
            int x = in.NI();
            if (x%2==1) continue;
            if (x%3==0 || x%5==0) continue;
            else fl = false;
        }
        if (fl) {
            out.println("APPROVED");
        } else {
            out.println("DENIED");
        }
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

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

using namespace std;

#define MAX 51
 
int main(){
    int n,m,dp[MAX][MAX];
    string str[MAX];
 
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++){
	cin >> str[i];
    }
    fill(dp[0],dp[MAX-1],0); 
 
    dp[0][0] = str[0][0]-'0';
    for(int i = 1 ; i < n ; i++){
	dp[i][0] = dp[i-1][0] + (str[i][0]-'0');
    }
 
    for(int j = 1 ; j < m ; j++){
	dp[0][j] = dp[0][j-1] + (str[0][j]-'0');
    }
 
    for(int i = 1 ; i < n ; i++){
	for(int j = 1 ; j < m ; j++){
	    dp[i][j] = min(dp[i-1][j],dp[i][j-1])+(str[i][j]-'0');
	}
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}

Measured memory_bytes: 3176
N = int(input())
ans = [0] * (10**4+1)

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            n = i*i + j*j + k*k + i*j + j*k + k*i
            if n <= 10**4:
                ans[n] += 1

for i in range(1,N+1):
    print(ans[i])


Measured memory_bytes: 9140
#include<fstream>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<stdlib.h>
#include<iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)
		cin >> vec.at(i);
	sort(vec.begin(), vec.end());//難易度を小さい順に並べた


	if (n == 2) {
		if (vec.at(n / 2 - 1) == vec.at(n / 2))
			cout << 0 << endl;
		else
			cout << vec.at(n / 2) - vec.at(n / 2 - 1) << endl;
	}

	else {
		if (vec.at(n / 2 - 1) == vec.at(n / 2))
			cout << 0 << endl;
		else if (vec.at(n / 2 - 1) == vec.at(n / 2 - 2) || vec.at(n / 2) == vec.at(n / 2 + 1))
			cout << vec.at(n / 2) - vec.at(n / 2 - 1) << endl;
		else
			cout << vec.at(n / 2) - vec.at(n / 2 - 1) << endl;

	}
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<map<int, long long>> mp(n + 1);
  auto rec = [&](auto&& self, int i, int c) -> long long {
    if (c < 0 or c > (n - i + 1) / 2) {
      return -inf<long long>;
    }
    if (i == n) {
      return 0;
    }
    if (i == n - 1) {
      return c ? a.back() : 0;
    }
    if (mp[i].count(c)) {
      return mp[i][c];
    }
    return mp[i][c] = max(a[i] + self(self, i + 2, c - 1), self(self, i + 1, c));
  };
  cout << rec(rec, 0, n / 2) << '\n';
}


Measured memory_bytes: 43824
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <map>
#define key 2333
#define maxn 100005
#define uLL unsigned long long
using namespace std;
uLL hsh[maxn],bas[maxn];
map<uLL,int>h;
char s[maxn];
int n;
priority_queue<int> hep;
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
uLL gethashcode(int i,int p){
    return hsh[i+p-1]-hsh[i-1]*bas[p];
}
inline bool check(int p){
	h.clear();
	for(int i=1;i+p-1<=n;i++){
        uLL num = gethashcode(i,p);
        if(h[num]){
            if(h[num]+p<=i){
                return 1;
            }
        }
        else
            h[num]=i;
	}
	return 0;
}
int main(){
	n=read();
	scanf("%s",s+1);
	bas[0]=1;
	for (int i=1;i<=n;i++) hsh[i]=hsh[i-1]*key+s[i]-'a',bas[i]=bas[i-1]*key;
	int L=0,R=n/2,ret=0;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid)) ret=mid,L=mid+1;
		else R=mid-1;
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, m, l;
    string s, t;
    cin >> n >> m >> s >> t;
    ll g = __gcd(n, m);
    l = (n * m) / g;
    bool ok = true;
    rep(i, g){
        if(s[i * (n / g)] != t[i * (m / g)])ok = false;
    }
    if(ok)cout << l << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    int sum = 0;
    sum += min(a, k);
    k -= a;
    if(k > 0){
        k -= b;
        if(k > 0)
            sum -= min(c, k);
    }
    cout <<sum<< endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+11;
const int M=7e5+11;
const int MAXN=1e7+11;
const int inf=2147483647;
int n,tot,cnt=1,t1,t2,mx,S,T,hd[M];
int ans,pri[M],L[N<<1],R[N<<1];
bitset<MAXN> is,a;
struct Edge{int nxt,to,val;}e[M];
void ins(int x,int y,int z){
    e[++cnt].nxt=hd[x];
    e[cnt].to=y;hd[x]=cnt;
    e[cnt].val=z;
}
void prepare(){
    is[0]=is[1]=1;
    for(int i=2;i<MAXN;i++){
        if(!is[i]) pri[++tot]=i;
        for(int j=1;j<=tot&&i*pri[j]<=MAXN;j++){
            is[pri[j]*i]=1;
            if(i%pri[j]==0) break;
        }
    }
}
namespace Network_Flow{
    queue<int> p;
    int dep[N<<1];
    int bfs(){
        memset(dep,0,sizeof(dep));
        p.push(S);dep[S]=1;
        while(!p.empty()){
            int x=p.front();p.pop();
            for(int i=hd[x];i;i=e[i].nxt){
                int y=e[i].to,v=e[i].val;
                if(!dep[y]&&v){
					dep[y]=dep[x]+1;
                    p.push(y);
                }
            }
        }
        if(dep[T]) return 1;
        return 0;
    }
    int dfs(int x,int flow){
        if(x==T||flow<=0) return flow;
        int rest=0;
        for(int i=hd[x];i;i=e[i].nxt){
            int j=e[i].to;int v=e[i].val;
            if(dep[j]==dep[x]+1&&v){
                int now=dfs(j,min(v,flow));
                e[i].val-=now;
                e[i^1].val+=now;
                flow-=now;rest+=now;
                if(flow<=0) break;
            }
        }if(!rest) dep[x]=-1;
        return rest;
    }
    int dinic(){
        int maxflow=0;
        while(bfs()) maxflow+=dfs(S,inf);
		return maxflow;
    }
}
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
signed main(){
    prepare();n=read();
    for(int i=1;i<=n;i++){
        int x=read();
        a[x]=1,mx=max(mx,x);
    }
    for(int i=1;i<=mx+1;i++)
        if(a[i]!=a[i-1]) i&1?L[++t1]=i:R[++t2]=i;
    S=0,T=t1+t2+1;
    for(int i=1;i<=t1;i++)
        ins(S,i,1),ins(i,S,0);
    for(int i=1;i<=t2;i++)
        ins(i+t1,T,1),ins(T,i+t1,0);
    for(int i=1;i<=t1;i++)
        for(int j=1;j<=t2;j++)
            if(!is[abs(L[i]-R[j])])
                ins(i,j+t1,1),ins(j+t1,i,0);
    int Val=Network_Flow::dinic();
    ans+=Val;ans+=(t1-Val)/2*2+(t2-Val)/2*2;
    ans+=((t1-Val)&1)*3;printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>

bool solve(int *arr,int n,int i,int x) {
	if (x == 0) {
		return true;
	}
	if (i > n) {
		return false;
	}
	
	bool r = solve(arr,n,i+1,x) || solve(arr,n,i+1,x-arr[i]);
	return r;
}

int main() {
	int n,q;
	int *arr;
	scanf("%d",&n);
	arr = new int[n];
	for (int i=0;i<n;i++) {
		scanf("%d",arr+i);
	}
	scanf("%d",&q);
	for (int i=0;i<q;i++) {
		int x;
		scanf("%d",&x);
		if (solve(arr,n,0,x)) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	return 0;
} 



Measured memory_bytes: 2696
#include <stdio.h>
#include <math.h>

int gcd(int a, int b) {
  int t;
  while(b) {
    t = a % b;
    a = b;
    b = t;
  }
  return a;
}

int main(void){
  int p, q, i, j, ans = 1, bef = 0;
  scanf("%d%d", &p, &q);
  q /= gcd(p, q);
  for(i = 2; i <= sqrt(q) + 1;) {
    if(!(q % i)) {
      if(bef != i) ans *= i, bef = i;
      q /= i;
    } else ++i;
  }
  if(bef != q) ans *= q;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean r = false;
		for(int i=1;i<=9;i++){
			if(n%i==0 && n/i<=9){
				r = true;
				break;
			}
		}
		System.out.println(r?"Yes":"No");
		sc.close();
	}
}


Measured memory_bytes: 22996
package main

import (
	"fmt"
)

func abs(n int64) int64 {
	if n >= 0 {
		return n
	} else {
		return -n
	}
}

func main() {
	var x, k, d int64
	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)
	x = abs(x)
	ans := x

	if x > abs(k*d) {
		ans = x - abs(k*d)
	} else {
		if (k-x/abs(d))%2 == 0 {
			ans = x % abs(d)
		} else {
			temp := x % abs(d)
			if abs(temp+d) < abs(temp-d) {
				ans = abs(temp + d)
			} else {
				ans = abs(temp - d)
			}
		}
	}

	fmt.Println(abs(ans))
}


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

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

  int ans;

  if (S == "SUN") ans = 7;
  if (S == "MON") ans = 6;
  if (S == "TUE") ans = 5;
  if (S == "WED") ans = 4;
  if (S == "THU") ans = 3;
  if (S == "FRI") ans = 2;
  if (S == "SAT") ans = 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	ll x,a;
	cin >> x;
	vector<ll> v;
	v.pb(2);
	v.pb(1);
	REP(i,1,x)
	{
		a = v[i] + v[i-1];
		v.pb(a);
		//cout << a<<endl;
	}
	cout << v[x];
	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "string.h"

char s[100012];
char d[] = "ream";
char e[] =  "rase";
int main()
{
    int i,j,n,flag,f;
    while (scanf ("%s",s) != EOF)
    {
        flag = 1;
        f = 0;
        n = strlen(s);
        for (i=0;i<n;i+=5)
        {
           if (f == 1)
           {
               break;
           }
           if (n - i < 4)
           {
               flag = 0;
               break;
           }
           if (s[i] == 'd')
           {
               for (j=1;j<5;j++)
               {
                  if (s[i+j] != d[j-1])
                  {
                      flag = 0;
                      break;
                  }
               }
               if (s[i+5] == 'e' && s[i+6] == 'r')
               {
                   if (n-i-j == 2)
                   {
                       f = 1;
                   }
                   if (s[i+7] == 'e' || s[i+7] == 'd')
                   {
                       i+=2;
                   }
               }
           }
           else if (s[i] == 'e')
           {
               for (j=1;j<5;j++)
               {
                  if (s[i+j] != e[j-1])
                  {
                      flag = 0;
                      break;
                  }

               }
               if (s[i+5] == 'r')
               {
                    i++;
               }
           }
           if (!flag)
           {
               break;
           }
        }
        printf ("%s\n",flag?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
c=0
l=[0,3,5,7]
for i1 in l:
 for i2 in l:
  for i3 in l:
   for i4 in l:
    for i5 in l:
     for i6 in l:
      for i7 in l:
       for i8 in l:
        for i9 in l:
         x=str(i1+10*i2+100*i3+1000*i4+10**4*i5+10**5*i6+10**6*i7+10**7*i8+10**8*i9)
         if '3' in x and '5' in x and '7' in x and '0' not in x and int(x)<=n:c+=1
print(c)

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


int A[1001];

int main(){
	long long sum=0;
	string s;
	cin >> s;
	
	for(int i=0;i<s.size();i++){
		sum+=i-A[s[i]];
		A[s[i]]++;
	}
	
	cout << sum+1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String n = scan.nextLine();
        while (!n.equals("0")){
            int sum = 0;
            for(int x = 0; x < n.length();x++) {
                sum = sum + Integer.parseInt(Character.toString(n.charAt(x)));
            }
            System.out.println(sum);
            n = scan.nextLine();
        }
    }
}


Measured memory_bytes: 26904
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}


int main()
{
    int a, b;
    while(~scanf("%d%d", &a, &b))
    {
        int a1 = max(a, b);
        int b1 = min(a, b);
        int ans1 = gcd(a1, b1);
        long long  ans2 = a / ans1 * b;
        cout<<ans1<<" "<<ans2<<endl;
    }

    return 0;

}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

int main(void) {
    ll a[5];
    ll i;
    ll min=10;
    
    ll ans=0;
    for(i=0; i<5; i++) {
        cin >> a[i];
        
        if(a[i]%10==0) {
            ans+=a[i];
            continue;
        }
        
        ans+=a[i]+10-a[i]%10;
        chmin(min, a[i]%10);
    }
    
    
    pt(ans-10+min);
    
    
    
}







Measured memory_bytes: 384
N,M = map(int,input().split())
L= 0
R = 10 ** 5
for i in range(M):
  Lm,Rm = map(int,input().split())
  L = max(L,Lm)
  R = min(R,Rm)
if R - L < 0:
  print(0)
else:
  print(R - L + 1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	bool ans = false;
	for (int i = 1; i <= b; i++) {
		if (a * i % b == c) {
			ans = true;
		}
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int check(){

}

int main(){
  vector<int> pp;
  int max = 55555;
  int prime[55556] = {};
  for(int i = 0; i <= max; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for(int i = 2; i * i <= max; i++){
    if(prime[i]){
      for(int j = i; i * j < max; j++){
        prime[i*j] = 0;
      }
    }
  }
  for(int i = 2; i <= 55555; i++){
    if(prime[i] && i % 5 == 1) pp.push_back(i);
  }
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cout << pp[i] << (i == n-1 ? "\n": " ");
  return 0;
}


Measured memory_bytes: 512
n = int(input())

p_lst = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
    if p_lst[i-1] < p_lst[i] < p_lst[i+1]:
        count += 1
    elif p_lst[i+1] < p_lst[i] < p_lst[i-1]:
        count += 1
    else:
        pass

print(count)

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

using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;for (int tt = 1;tt <= t;tt++)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;	
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

ll seen[N];
int h[N];
int n, k;

ll dfs(int node) {
	if (node == n) return 0;
	int jump = 1;
	if (seen[node] != -1) return seen[node];
	seen[node] = INF;
	for (int jump = 1;jump <= k && node + jump <= n;jump++) {
		seen[node] = min(seen[node], abs(h[node] - h[node + jump]) + dfs(node + jump));
	}
	return seen[node];
}

int main(int argc, char const *argv[])
{
	fast;

	cin >> n >> k;

	frep(i, 1, n) {
		seen[i] = -1;
		cin >> h[i];
	}

	cout << dfs(1) << '\n';

	return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vi= vector<int>;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvi= vector<vector<int>>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N,M;
    cin >> N >> M;
    dsu d(N);
    REP(i,M){
        ll r,l;
        cin >> r >> l;
        r--;
        l--;
        d.merge(r,l);
    }
    vector<vector<int>> group = d.groups();
    cout << group.size()-1 << "\n";
}

Measured memory_bytes: 9024
using System;
namespace Atcoder
{
    class ABC135
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if( (a + b)%2 == 0)
            {
                Console.Write((a + b) / 2);
            }
            else
            {
                Console.Write("IMPOSSIBLE");
            }
        }
    }
}

Measured memory_bytes: 13140