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

int main(){

    string str; cin >> str;
    int c[100] = {};
    for(int i = 0; i < str.size(); i++){
        c[(int)str[i] - 'a']++;
    }

    bool flag = true;
    for(int i = 0; i < 100; i++){
        if(c[i] % 2 == 1) flag = false;
    }


    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

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

  int ans = 0;
  for(int i=0;i+2<n;i++){
    ans += (s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C');
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef vector<int> vi;
#define mp make_pair
#define MAX 1e13
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pi> vii;
#define LSOne(S) (S & (-S))
int arr[25];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int cnt = 0;
	for (int i = 1; i < n - 1; i++)
	{
		if (arr[i]<arr[i + 1] && arr[i]>arr[i - 1] || arr[i] > arr[i + 1] && arr[i] < arr[i - 1])
			cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;
pair<int,int> p[10];

int main()
{
  int i,n;
  char name[10][25]={};
  int w,l,d;
  bool time=false;
  while(1){
    cin>>n;
    if(n==0)break;
    if(time)
      cout<<endl;
    rep(i,n){
      scanf("%s %d %d %d",name[i],&w,&l,&d);
      p[i].first=-1*(w*3+d);
      p[i].second=i;
    }
    sort(p,p+n);
    
    rep(i,n)
      printf("%s,%d\n",name[p[i].second],-1*(p[i].first));

    time=true;
  }

}

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

int main(){
	int r=100001;
	int n; cin>>n;
	vector<int> v(r);
	rep(i,n){
		int a; cin>>a; v[a]++;
	}
	int mx=0;
	for(int i=1; i<r-1; i++){
		int sum=v[i-1]+v[i]+v[i+1];
		mx=max(mx,sum);
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int H, W, h, w;

	cin >> H >> W;
	cin >> h >> w;

	int all = H * W;

	all = all - W * h - H * w +h*w;
	cout << all << endl;
	//return 0;
}

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

int main(){
	bool submit[31];
	for(int i=0;i<31;i++)submit[i]=true;
	submit[0]=false;
	int n;
	for(int i=0;i<28;i++){
		cin>>n;
		submit[n]=false;
	}
	/*for(int i=1;i<31;i++)cout<<i<<" ";
	cout<<endl;*/
	for(int i=1;i<31;i++){
		//if(i>9)cout<<submit[i]<<"  ";
		if(submit[i])cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll A, B;
    cin >> A >> B;
    --A;

//    ll fa = (A + 1) / 2 % 2, fb = (B + 1) / 2 % 2;
//    int M = 41;
//    REP(i, M-1) {
//        ll v = 1LL << (M - i - 1);
//
//        if (A & v) {
//            A -= v;
//            if (A % 2 == 0) fa += v;
//        }
//
//        if (B & v) {
//            B -= v;
//            if (B % 2 == 0) fb += v;
//        }
//    }

    ll fa = (A + 1) / 2 % 2;
    if (A % 2 == 0) fa ^= A;

    ll fb = (B + 1) / 2 % 2;
    if (B % 2 == 0) fb ^= B;

    cout << fixed << setprecision(20);
    cout << ll(fb ^ fa) << endl;

}


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

namespace ARC088_D___Wide_Flip
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static int solver()
        {
            var S = Console.ReadLine();
            if (S.Length == 1) return 1;
            var result = S.Length;
            for (int i = 1; i < S.Length; i++)
            {
                if (S[i] != S[i - 1]) result = Math.Min(result, Math.Max(i, S.Length - i));
            }
            return result;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main()
{
    int n, m;

    cin>>n>>m;

    multimap<int, int> mp;

    for(int i=0;i<n;i++){
        int ta, tb;
        cin>>ta>>tb;
        mp.insert({ta, tb});
    }

    int ans = 0;

    auto itr = mp.begin();

    multiset<int, greater<int >> ms;

    for(int i=1;i<=m;i++){
        while(itr->first <= i && itr!=mp.end()){
            ms.insert(itr->second);
            itr++;
        }
        if(!ms.empty()){
            ans += *ms.begin();
            ms.erase(ms.begin());
        }
    }
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 11136
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	S := readBytes()
	m := make(map[byte]int)
	for _, c := range S {
		m[c]++
	}
	if len(m) != 2 {
		println("No")
		return
	}
	for _, count := range m {
		if count != 2 {
			println("No")
			return
		}
	}
	println("Yes")

}

// -----------------------------------------------------------------------------


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

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
using mint = Fp<MOD>;

int main(){
    int N,M,K; cin >> N >> M >> K;
    mint n=N,m=M,k=K;
    mint res=0;
    COMinit();
    rep(i,K+1){
        mint a = (m*COM(N-1,i)*modpow(m-1,N-1-i) );
        res+=a;
    }
    cout << res << endl;
}

Measured memory_bytes: 15580
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;
#define INF 1e9

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

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

int64 modinv(int64 a, int64 m) {
    int64 b = m, u = 1, v = 0;
    while (b) {
        int64 t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R) {
        int p;
        cin >> p;
        r[i] = p - 1;
    }
    int L[N][N];
    rep(i, N) rep(j, N) L[i][j] = INF;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a -= 1;
        b -= 1;
        L[a][b] = c;
        L[b][a] = c;
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                L[i][j] = min(L[i][j], L[i][k] + L[k][j]);
                L[j][i] = L[i][j];
            }
        }
    }

    int ans = INF;
    sort(all(r));
    do {
        int a = 0;
        rep(i, R-1) {
            a += L[r[i]][r[i+1]];
        }
        ans = min(ans, a);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "YES" << endl;}
void no(){ cout << "NO" << endl;}

//-----------------------------------------
vector<long long> factor_array(long long n){
  vector<long long> res;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i*i!=n){
        res.push_back(n/i);
      }
    }
  }
  sort(res.begin(),res.end());
  return res;
}

bool is_prime(long long n){
  if(n==2){
    return true;
  }
  else if(n<2 || n%2==0){
    return false;
  }
  else{
    long long i = 3;
    while(i*i<=n){
      if(n%i==0){
        return false;
      }
      i += 2;
    }
    return true;
  }
}

vector<pair<long long, long long>> prime_factorization(long long n){
  vector<pair<long long, long long>> res ;
  vector<long long> tmp = factor_array(n) ;
  for(long long i = 0; i<(long long)tmp.size(); i++){
    if(is_prime(tmp[i])){
      long long m = n;
      long long cnt = 0;
      while(m%tmp[i]==0){
        m /= tmp[i];
        cnt++;
      }
      res.push_back(make_pair(tmp[i],cnt));
    }
  }
  return res;
}

vector<bool> prime_table(int n){
  vector<bool> res(n+1,true);

  res[0] = false;
  res[1] = false;

  for(int i=2;i*i<=n;i++){
    if(res[i]){
      int j = i+i;
      while(j<=n){
        res[j] = false;
        j += i;
      }
    }
  }
  return res;
}
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);


  ll n;
  cin >> n;

  vpll tmp = prime_factorization(n);

  ll ans = 0;

  for(ll i = 0; i < tmp.size(); i++){
    ll j = 1;
    while(1){
      if(tmp[i].second >= j){
        ans++;
        tmp[i].second -= j;
        j++;
      }
      else break;
    }
  }

  cout << ans << endl;




  return 0;
}



Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a<=8 && b <=8)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;


  return 0;
}

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

int main(){
   int N;
   cin>>N;
   vector<int> V(N);
   int ans = 0;

  for(int i=0;i<N;i++){
      cin>>V.at(i);
      ans += V.at(i);
  }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
   cout<<ans-V.at(0)/2<<endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int k,a,b; cin >> k >> a >> b;
    int v = 1;
    v = b/k;
    debug(v*k);
    if(v*k>=a) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
using ll = long long;
using namespace std;

ll N, M, a[100010][3], res = -(1LL << 60);

int main() {
	cin >> N >> M;
	REP(i,N) {
		REP(j,3) cin >> a[i][j];
	}
	REP(i,8) {
		vector<ll> vec;
		REP(j,N) {
			ll S = 0;
			REP(k,3) {
        if ((i / (1 << k)) % 2 == 0) S += a[j][k];
        else S -= a[j][k];
      }
			vec.push_back(S);
		}
		sort(ALL(vec)); reverse(ALL(vec));
		ll ans = 0;
		REP(j,M) ans += vec[j];
		chmax(res, ans);
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  rep(i, m) {
    cin >> l[i] >> r[i];
    --l[i];
    --r[i];
  }

  vector<int> imos(n + 1, 0);
  rep(i, m) {
    ++imos[l[i]];
    --imos[r[i] + 1];
  }
  rep(i, n) imos[i+1] += imos[i];
  int ans = 0;
  rep(i, n+1) if (imos[i] == m) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4552
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, l;
    cin >> n >> l;

    int sum = 0;
    rep(i, n){
        sum += l + i;
    }

    int ans = sum - l;
    rep(i, n){
        int tmp = sum - l - i;
        if(abs(sum - tmp) < abs(sum - ans)){
            ans = tmp;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main() {

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

    if (a > b) {
        int num = a;
        a = b;
        b = num;
    }

    if (b > c) {
        int num = b;
        b = c;
        c = num;
    }

    if (a > b) {
        int num = a;
        a = b;
        b = num;
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())

g = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))     

Measured memory_bytes: 232312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main(){
    ll x, y;
    cin >> x >> y;
    int cnt = 1;
    ll now = x;
    while (now * 2 <= y) {
        now *= 2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger

object Main {
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        val max = new BigInteger("1"+"0"*80)
        while(sc.hasNext){
	        val a = sc.nextBigInteger
	        val b = sc.nextBigInteger
	        val sum = a.add(b)
	        if(sum.compareTo(max) == -1) println(sum)
	        else println("overflow")
	        
    	}
    }
}

Measured memory_bytes: 44868
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
#include <iterator>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

ll n, k, a, b;
map<ll, ll> m;

int main() {

  cin >> n >> k;
  rep(i, n) {
    cin >> a >> b;
    m[a] += b;
  }

  ll sum = 0;
  for(auto it : m) {
    sum += it.second;
    if(sum>=k) {
      cout << it.first << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
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(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

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

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

const ll inf = (ll)1e18 + 5;


multiset<ll> lo, hi;
ll x = 0, y = 0;
void addhi() {
	multiset<ll>::iterator it = (--lo.end());
	x -= *it;
	y += *it;
	hi.insert(*it);
	lo.erase(it);
}
void addlo() {
	multiset<ll>::iterator it = hi.begin();
	x += *it;
	y -= *it;
	lo.insert(*it);
	hi.erase(it);
}
void add(ll v) {
	lo.insert(v);
	x += v;
	addhi();
	addlo();

	if (lo.size() > hi.size() + 1) {
		addhi();
	}
}

ll med() {
	return *(--lo.end());
}

void solve() {
	ll q;
	in(q);

	ll c = 0;
	REP(i,0,q) {
		ll v;
		in(v);
		
		if (v == 1) {
			ll a, b;
			in(a,b);
			
			c += b;
			
			add(a);
		} else {
			ll m = med();
			ll diff = (m * lo.size()) - x + y - (m * hi.size());
			cout << m << ' ' << diff + c << endl;
		}
	}
}

signed main() {
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long n, m, x,cnt , ans;
const ll N = 1e5 + 7;
    vector<ll>d(N);
    string s , s1;
int main(){
    cin >> n;
    for( int i = 1;i < n;i ++ ){
        for( int j = 1;j < n;j ++ ){
            if( i * j < n )
                cnt ++;
            else
                break;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 3808
#include <stdio.h>

int main(void){
    int i,j,k,n,a,b,dice[7],
        side[5] = {2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
    
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
    
    scanf("%d", &n);
    
  //上面を合わせる
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
    
        for(j=1;dice[j]!=a;j++);
        
       //回転  
    
        for(k=0;order[j][k]!='\0';k++){
        
            dice[0] = dice[1];
        
            switch(order[j][k]){
                
                case 'E':
                    dice[1] = dice[4];
                    dice[4] = dice[6];
                    dice[6] = dice[3];
                    dice[3] = dice[0]; 
                    break;
            
                case 'N':
                    dice[1] = dice[2];
                    dice[2] = dice[6];
                    dice[6] = dice[5];
                    dice[5] = dice[0]; 
                    break;
            
                case 'S':
                    dice[1] = dice[5];
                    dice[5] = dice[6];
                    dice[6] = dice[2];
                    dice[2] = dice[0]; 
                    break;
                
                case 'W':
                    dice[1] = dice[3];
                    dice[3] = dice[6];
                    dice[6] = dice[4];
                    dice[4] = dice[0]; 
                    break;

            }
        }
        
        for(j=0;b!=dice[side[j]];j++);
        
        printf("%d\n",dice[side[j+1]]);
        
    }
    
    return 0;
}


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

int main(void){
  int n, l, i;
  vector<string> s(100);

  cin >> n >> l;

  for(i = 0; i < n; i ++)
    cin >> s.at(i);

  for(i = 0; i < n; i ++)
    if(s.at(i) == "") break;

  s.erase(s.begin()+i, s.end());

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

  for(i = 0; i < n; i ++)
    cout << s.at(i);

  cout << endl;

  return 0;
}

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

#define MAX (ll(1e6)+7)
#define MOD (ll(1e9)+7)
#define INF (ll(1e18)+7)

#define elif else if
#define def inline auto

#define for_in(a,b,c) for(ll a=(b);a<(c);++a)
#define repeat(a,b) for(ll a=0;a<(b);++a)
#define repeat_down(a,b) for(ll a=(b);a>=0;--a)

#define array_size(a) ll(sizeof(a)/sizeof(a[0]))

#define def_input(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define if_print(a,b,c) output(a?#b:#c)
#define print(a) output(#a)
#define fout(a) cout<<fixed<<setprecision(10)<<a
#define fillout(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define ios_boost cin.tie(0);ios::sync_with_stdio(false)

#define digit(a) to_string(a).length()
#define lcm(a,b) a*b/gcd(a,b)

char N='\n',S=' ';
const ll primes[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll temp_index;

inline void input(){}
template<class T,class...A>inline void input(T&&t,A&&...a){cin>>t;input(move(a)...);}
template<class T>inline void output(T&t){cout<<t<<N;}
template<class T,class...A>inline void output(T&t,A&...a){cout<<t<<S;output(move(a)...);}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>const&v)
{bool d=0;for(T x:v){if(d)o<<S<<x;else{o<<x,d=1;}}o<<N;return o;}

def get_ll(){ll x;input(x);return x;}
def gcd(ll a,ll b){ll c;while(a){c=a;a=b%a;b=c;}return b;}

inline bool is_prime(ll a){
    if(a<48){for_in(i,0,15)if(primes[i]==a)return 1;}
    elif(a<2809)return gcd(614889782588491410,a)==1;
    else {print(Error:Argument>2808);exit(1);}return 0;
}

template<class T>def sum_array(T&a,T&b){
    b[0]=a[0];
    for_in(i,1,array_size(a))b[i]=a[i]+b[i-1];
}

map<string,ll>LIST;
map<ll,string>VLIST;

def val(string a){
    auto IT=LIST.find(a);
    if(IT!=LIST.end()){
        return LIST[a];
    }
    else{
        ll v=LIST.size();
        LIST[a]=v;
        VLIST[v]=a;
        return v;
    }
}

ll b,c,d,a[101];
int main(){
    ios_boost;
    def_input(n);

    for_in(i,0,26)for_in(j,0,15){
        if(i*4+j*7<=100){
            a[i*4+j*7]=1;
        }
    }
    a[0]=0;
    cout<<(a[n]?"Yes":"No")<<endl;
}

//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)



Measured memory_bytes: 256
#include  <iostream>

using namespace std;

long long gcd(long long c, long long d)
{
	return d ? gcd(d, c % d) : c;
}
long long lcm(long long c, long long d) {
	return c / gcd(c, d) * d;
}

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

	long long c1, c2, d1, d2, cd1, cd2;
	c2 = b / c;
	d2 = b / d;

	c1 = (a - 1) / c;
	d1 = (a - 1) / d;

	long long ans;

	long long sd = lcm(c, d);
	cd2 = b / sd;
	cd1 = (a - 1) / sd;
	ans = b - a + 1 - (c2 - c1) - (d2 - d1) + (cd2 - cd1);

	cout << ans << endl;
}

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

int main(void){
	int K,T,a;
	cin>>K>>T;
	priority_queue<pair<int,int>> qu;//cnt,i
	rep(i,T){
		cin>>a;
		qu.push({a,i});
	}
	pair<int,int> before = qu.top();
	qu.pop();
	before.first--;

	while(!qu.empty()){
		pair<int,int> now = qu.top();
		qu.pop();
		now.first--;
		if(before.first)qu.push(before);
		before=now;
	}
	cout<<before.first<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a[3];

int main(){
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
int a, b, c, z;
scanf("%d %d %d", &a, &b, &c);

if(a > b){
z = a;
a = b;
b = z;
}
if(b > c){
z = b;
b = c;
c = z;
}
if(a > b){
z = a;
a = b;
b = z;
}
printf("%d %d %d\n", a, b, c);

return 0;
}



Measured memory_bytes: 2104
# AOJ 1126: The Secret Number
# Python3 2018.7.16 bal4u

while True:
	W, H = map(int, input().split())
	if W == 0: break
	d = [list(input()) for r in range(H)]
	a = [[0 for c in range(W)] for r in range(H)]
	ans = 0
	for r in range(H):
		for c in range(W):
			if not d[r][c].isdigit(): continue
			a[r][c] = k = int(d[r][c])
			if c > 0 and d[r][c-1].isdigit():
				a[r][c] = a[r][c-1]*10 + k
			if r > 0 and d[r-1][c].isdigit():
				t = a[r-1][c]*10 + k
				a[r][c] = max(a[r][c], t)
			ans = max(ans, a[r][c])
	print(ans);



Measured memory_bytes: 5624
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  double n;
  cin >> n;
  cout << 2*n*3.1415926535<<endl;
}


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

int main(){
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    
    if(S[K-1] == 'A'){
        S[K-1] = 'a';
    }else if(S[K-1] == 'B'){
        S[K-1] = 'b';
    }else if(S[K-1] == 'C'){
        S[K-1] = 'c';
    }

    cout << S << endl;
    return 0;
}

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

public class Main {	

	private static void solve(){
		//Implement solution here.
		int X = ni();
		int N = ni();
		List<Integer> p = new ArrayList<Integer>();
		for(int i = 0; i < N; i++)p.add(ni());
		Map<Integer,Boolean> map = new HashMap<>();
		for(int i:p)map.put(i,true);
		int result = -1;
		for(int dist = 0; dist <= 100; dist++) {
			int bpos = X - dist;
			int fpos = X + dist;

			if(!map.containsKey(bpos)) {
				result = bpos;
				break;
			}
			if(!map.containsKey(fpos)) {
				result = fpos;
				break;
			}
		}
		System.out.println(result);
//		for(int i = 1 ; i < 101; i++) {
//			System.out.print(i + " ");
//		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
		boolean hasNext = true;
//		while(hasNext){
//			solve();	
//			try{
//				br.mark(1);
//				if(br.read() > 0){
//					br.reset();			
//					System.out.println("---");
//				} else {
//					hasNext = false;
//				}
//			}catch(Exception e){
//				throw new RuntimeException(e);
//			} 
//		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string s;
    cin >> s;

    vector<bool> alph(26, false);
    for (char c : s)alph[c - 'a'] = true;

    if (s.length() == 26) {
        alph[s.back() - 'a'] = false;
        s.erase(--s.end());
        rFOR(i, 0, 25) {
            FOR(j, s[i] - 'a', 26) {
                if (!alph[j]) {
                    s[i] = 'a' + j;
                    goto END;
                }
            }
            alph[s.back() - 'a'] = false;
            s.erase(--s.end());
        }
    }
    else {
        FOR(i, 0, 26) {
            if (!alph[i]) {
                s += 'a' + i;
                break;
            }
        }
    }
END:
    cout << (s == "" ? "-1" : s) << "\n";
}

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

int X[8], Y[8];


int main() {
  int N, result;
  int i, j;
  double D;
  scanf ("%d", &N);
  for (i=0;i<N;i++) {
      scanf("%d %d", &X[i], &Y[i]);
  }
  
  D=0;
  for(i=0;i<N;i++) {
    for (j=i+1;j<N;j++) {
      D+=sqrt((double)  ((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j])));
    }
  }
  
  
  
  
  printf("%lf", 2*D/N);
  return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int c[N];
    rep(i,N){
        cin>>c[i];
    }

    int dp[N+1];
    map<int,int> m;
    dp[0]=1;
    for(int i=0;i<N;i++){
        dp[i+1]=dp[i];
        dp[i+1]%=MOD;
        if(i!=0&&c[i]==c[i-1])continue;
        if(!m[c[i]]){
            m[c[i]]=dp[i+1];
        }else{
            dp[i+1]+=m[c[i]];
            dp[i+1]%=MOD;
            m[c[i]]=dp[i+1];
        }
    }
    cout << dp[N] << endl;





    



}


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

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

  int h,m;
  h = s/3600;
  s = s-h*3600;

  m = s/60;
  s = s-m*60;

  cout << h << ':' << m << ':' << s << endl;

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    int n;
    sc(n);
    if(n < 1200)puts("ABC");
    else if(n < 2800)puts("ARC");
    else puts("AGC");
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
map<ll,ll> res;
map<ll,ll> prime_fact(ll n){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;
prime_fact(N);
for (auto itr : res) {
        ll q=itr.second;
        ll nmax=0;
        rep1(i,1000){
            if(i*(i+1)/2>q){
                nmax=i-1;
                break;
            }
        }
        ans+=nmax;
}
cout<<ans<<endl;


}
    


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
	int k,a,b;
	cin>>k>>a>>b;
	int lower=(a%k==0)?a:(a+(k-(a%k)));
	int upper=(b%k==0)?b:(b-(b%k));
	if(lower<=b||upper>=a)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
}
int32_t main()
{
	op1;op2;op3;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	trozen();
	return 0;
}


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

//works for multiple testcases.....
//1-indexing converted to zero in the problem!!!



ll a1[300010];
ll b1[300010];
ll c1[300010];
ll mf[300010];
const ll MAX=300010;
ll timer=0;
ll L[MAX];
ll R[MAX];
ll a[MAX];








void dfs(ll v,ll p,vector<ll> G[MAX])
{
	L[v] = timer;
	timer ++;
	for(ll to: G[v])
	{
		if (to == p) continue;
		dfs(to,v,G);
	}
	R[v] = timer - 1;
}
 
 
 
int main() 
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
vector<ll> G[MAX];

timer=0;
ll i;
ll n,q;
cin>>n;
cin>>q;
//accepting the number of nodes and queries.............

	for(i=1;i<=n-1;i++)
	{
	    ll a,b;
	
	//accepting__edges!!
	
		cin>>a>>b;
		--a;--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
   for(i=0;i<n;i++)
	{
	    a[i]=0;
//accepting the values of each node... .. ...

	   
	}
	

 timer=0;
	dfs(0,-1,G);
	for(i = 0; i < n; i++)
	{
	    a1[L[i]]=i;
	    b1[L[i]]=a[i];
	    c1[i]=L[i];
	    
	    //indexofarray.......valueofnode.......indexofnode
	      // cout<<L[i]<<" "<<a[i]<<" "<<i;
	  //  cout<<"\n";
	
	    
	    
	    
	}
	
	

	while(q--)
	{
	    ll x,y;
	    cin>>x>>y;
	    x--;//index__of__my__node__!!!
	  //  cout<<x<<" "<<y<<"\n";
	    ll l,r;
	    l=L[x];
	    r=R[x];
	  //  cout<<l<<" "<<r;
	    //cout<<"\n";
	    b1[l]=b1[l]+y;
	    
	    if(r==n-1)
	    {
	        
	    }
	    else
	    {
	    b1[r+1]=b1[r+1]-y;
	    }
	    
	 
    }
    
    
    
    
    i=1;
    while(i<=n-1)
    {
        
        b1[i]=b1[i]+b1[i-1];
        
        i++;
    }
    i=0;
    while(i<n)
    {ll x=L[i];
    cout<<b1[x]<<" ";
        
        
        
        i++;
    }
 
 
 
	return 0;
}



Measured memory_bytes: 40960
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;

    return 0;    
}


Measured memory_bytes: 256
from bisect import bisect_left as bl
from bisect import bisect_right as br

n, v = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = list(map(int, input().split()))

AB = [a + b for a in A for b in B]
CD = [c + d for c in C for d in D]

AB.sort()
CD.sort()

ans = 0
for ab in AB:
  target = v - ab
  ans += br(CD, target) - bl(CD, target)
print(ans)


Measured memory_bytes: 101248
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
ans = 0
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int x, int y){
    int r;
    // ユーグリッドの互除法
    while((r = x % y) != 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}
int main(){
  int N;
  long long X,ans = 0;
  cin>>N>>X;
  long long x[N+1];
  for(int i = 0;i<N;i++){
    cin>>x[i];
  }
  x[N]=X;
  sort(x,x+(N+1));
  ans = x[1]-x[0];
  for(int i = 2;i<=N ;i++){
    ans = gcd(x[i]-x[i-1],ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

using MIte = multimap<ll, ll, greater<ll> >::iterator;



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

	// long long?
	int N;
	string S;
	cin >> N >> S;

	int ans = 1;
	for (int i = 0; i != N - 1; ++i) {
		if (S[i] != S[i + 1]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512