akhauriyash/Code-Regression huggingface dataset:
# abc131_c.py
# https://atcoder.jp/contests/abc131/tasks/abc131_c

# C - Anti-Division /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 整数 A,B,C,Dが与えられます。A 以上 B 以下の整数のうち、C でも Dでも割り切れないものの個数を求めてください。

# 制約
#     1≤A≤B≤1018
#     1≤C,D≤109
#     入力はすべて整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B C D

# 出力
# A以上 B 以下の整数のうち、C でも Dでも割り切れないものの個数を出力せよ。

# 入力例 1
# 4 9 2 3

# 出力例 1
# 2

# 5,7が条件を満たします。

# 入力例 2
# 10 40 6 8

# 出力例 2
# 23

# 入力例 3
# 314159265358979323 846264338327950288 419716939 937510582

# 出力例 3
# 532105071133627368


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B, C, D = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    import math

    cd = (C*D) // math.gcd(C, D)
    ac = (A-1) // C
    ad = (A-1) // D
    acd = (A-1) // cd
    a = (A-1) - ac - ad + acd
    log(f'a=[{a}]')
    bc = B // C
    bd = B // D
    bcd = B // cd
    b = B - bc - bd + bcd
    log(f'b=[{b}]')

    result = b-a

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 9 2 3']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['10 40 6 8']
        lines_export = [23]
    if pattern == 3:
        lines_input = ['314159265358979323 846264338327950288 419716939 937510582']
        lines_export = [532105071133627368]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 1e6 + 5;

int fac[N];

void solve() {
  int n; cin >> n;
  
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = i; j <= n; j += i) {
      fac[j]++;
    }
    ans += fac[i];
  }
  
  ans -= fac[n];
  cout << ans << '\n';
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1; // cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 11452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        long[] a1 = Read.longs();
        long[] a = new long[n];
        double ans1 = 0;
        for (int i = 0; i < a.Length; i++)
        {

            if (a1[i] % 2 == 0)
            {
                if ((a1[i] % 4 == 0))
                {
                    a[i] = 4;
                    ans1++;
                }
                else
                {
                    a[i] = 2;
                    ans1 += 0.5;
                }
            }
            else
            {
                a[i] = 1;
            }
        }
        int ans = (int)ans1;
        Console.WriteLine((n/2)<=ans?"Yes":"No");
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 21600
a,b,k=map(int, input().split())
resa = 0
resb = 0
 
if a <= k:
  resa = 0
else:
  resa = a - k

if b <= (k - a):
  resb = 0
else:
  resb = b - ((k-a) if (k-a) > 0 else 0)

print(str(resa) + " " + str(resb))

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

struct Drug {
  int64_t a;
  int64_t b;
  int64_t c;
  Drug(int pa, int pb, int pc) {
    a = pa;
    b = pb;
    c = pc;
  }
};

signed main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, ma, mb;
  cin >> n >> ma >> mb;
  const int64_t MAX_C = n * 100;
  const int64_t MAX_A = n * 10, MAX_B = n * 10;
  std::vector<Drug> drug;
  for (int i = 0; i < n; i++) {
    int m1, m2, m3;
    cin >> m1 >> m2 >> m3;
    drug.push_back(Drug(m1, m2, m3));
  }
  int64_t dp[MAX_A + 1][MAX_B + 1][n];
  for (int i = 0; i < MAX_A + 1; i++) {
    for (int j = 0; j < MAX_B + 1; j++) {
      for (int k = 0; k < n; k++) {
        dp[i][j][k] = INT64_MAX / 3;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    dp[0][0][i] = 0;
  }

  dp[drug[0].a][drug[0].b][0] = drug[0].c;
  // cout << dp[2][2][0] << endl;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < MAX_A + 1; j++) {
      for (int k = 0; k < MAX_B + 1; k++) {
        if (j - drug[i].a >= 0 && k - drug[i].b >= 0) {
          dp[j][k][i] =
              std::min(dp[j][k][i - 1],
                       dp[j - drug[i].a][k - drug[i].b][i - 1] + drug[i].c);
        } else {
          dp[j][k][i] = dp[j][k][i - 1];
        }
      }
    }
    // cout << dp[2][2][i] << endl;
  }
  // for (int j = 0; j < MAX_A + 1; j++) {
  //   for (int k = 0; k < MAX_B + 1; k++) {
  //     if (dp[j][k][n - 1] != INT64_MAX / 3)
  //       cerr << j << "\t" << k << "\t" << n - 1 << "\t" << dp[j][k][n - 1]
  //            << endl;
  //     if (dp[j][k][n - 1] == 117) {
  //       cerr << "gweagawe" << endl;
  //     };
  //   }
  // }

  int search_a = ma, search_b = mb;
  int64_t result = INT64_MAX / 3;
  bool found     = false;
  while (search_a <= MAX_A && search_b <= MAX_B) {
    if (result > dp[search_a][search_b][n - 1]) {
      result = dp[search_a][search_b][n - 1];
      found  = true;
    }
    search_a += ma;
    search_b += mb;
  }
  if (found) {
    cout << result << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 50560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll h,w;
namespace solve{
  #define H 20
  ll mas[H][H];
  ll px[H],py[H];
  ll d[H][H];
  
  struct qry{
      ll x,y,cost;
  };queue<qry> Q;
  void push(ll x,ll y,ll cost){
    qry gen;gen.x=x,gen.y=y,gen.cost=cost;
    Q.push(gen);
  }
  void dist(ll s){
    for(int i=0;i<H;i++)d[s][i]=1e9;
    ll dis[H][H];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)dis[i][j]=1e9;
    push(px[s],py[s],0);
    while(!Q.empty()){
      qry gen=Q.front(); Q.pop();
      ll x=gen.x,y=gen.y,cost=gen.cost;
      if(mas[x][y]==-2)continue;
      if(dis[x][y]<=cost)continue;
      dis[x][y]=cost;
      if(mas[x][y]>0)d[s][mas[x][y]]=cost;
      ll dx[]={0,1,0,-1},dy[]={1,0,-1,0};
      for(int r=0;r<4;r++){
	ll xx=x+dx[r],yy=y+dy[r];
	if(0<=xx&&xx<h&&0<=yy&&yy<w){
	  push(xx,yy,cost+1);
	}
      }
    }
  }
  void main(){
    ll cnt=1;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
      char c;cin>>c;
      if(c=='o')mas[i][j]=0,px[0]=i,py[0]=j;
      if(c=='*')mas[i][j]=cnt,px[cnt]=i,py[cnt]=j,cnt++;
      if(c=='x')mas[i][j]=-2;
      if(c=='.')mas[i][j]=-1;
    }
    for(int i=0;i<cnt;i++)dist(i);
    /*
    for(int i=0;i<cnt;i++){
      cout<<i<<":";
      for(int j=1;j<cnt;j++)cout<<d[i][j]<<" ";cout<<endl;
    }
    for(int i=0;i<cnt;i++)cout<<i<<"@"<<px[i]<<" "<<py[i]<<endl;*/
    vector<ll> v; for(int i=1;i<cnt;i++)v.push_back(i);
    ll ans=1e9;
    do{
      ll cur=d[0][v[0]];
      for(int i=1;i<cnt-1;i++)cur+=d[v[i-1]][v[i]];
      ans=min(ans,cur);
    }while(next_permutation(v.begin(),v.end()));
    if(ans>1e5)ans=-1;
    cout<<ans<<endl;
  }
};
int main(){
  while(cin>>w>>h&&h>0&&w>0){
    solve::main();
  }
    return 0;
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int N;
  cin>>N;
  vector<int> count(100000,0);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    count.at(a)++;
  }

  int ans=0;
  for(int i=1;i<99999;i++){
    ans=max(ans,count.at(i-1)+count.at(i)+count.at(i+1));
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	
	int index = -1;

	for (int i = 0; i < N ; i++) {
		int a;
		cin >> a;
		if (a == 1) {
			index = i;
		} 
	}
	int left  = index;
	int right = N - 1 - index; 
	int fill_once = K - 1;

	int count = (left + fill_once - 1)  / fill_once;
	int remain = count * fill_once - left;

	right -= remain;

	if (right > 0) {
		int right_count = (right + fill_once - 1)  / fill_once;
		count += right_count;
	}
	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <assert.h>
#include <iostream>

using namespace std;

int main() {
	long long n, m;
	cin >> n >> m;
	n = min(n, m / 2);
	cout << n + (m - n * 2) / 4 << "\n";
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const ll max_n = 200010;



int main(){
    // int u, v;
    // bool updated = false;
    ll N, K, cost, total_num;
    scanf("%lld %lld", &K, &N);
    vector<ll> house(N, 0);
    for(ll i=0;i<N;i++){
        scanf("%lld", &house[i]);
    }
    sort(house.begin(), house.end());
    ll max_diff = 0;
    for(ll i=0;i<N-1;i++){
        max_diff = max(house[i+1]-house[i], max_diff);
    }
    max_diff = max(house[0] + K - house[N-1], max_diff);

    printf("%lld\n", K - max_diff);


    return 0;

}

Measured memory_bytes: 1792
using System;

namespace Vanila
{
    public class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());
            if (N > K)
            {
                Console.WriteLine((N - K) * Y + K * X);
            }
            else {
                Console.WriteLine(N * X);
            }
         }
        public static long Max(long a, long b)
        {
            if (a <= b) return b;
            else return a;
        }
        public static long Min(long a, long b)
        {
            if (a == Max(a, b)) return b;
            else return a;
        }
        public static long GCD(long a, long b)
        {
            while (Max(a, b) % Min(a, b) != 0)
            {
                if (a < b) b %= a;
                else a %= b;
            }
            return Min(a, b);
        }
        public static long LCM(long a, long b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define  ll long long
using namespace std;

const int maxn=1e6+7;
ll sum[maxn];

int main (){
	map<ll,ll>mp;
	int n;cin>>n;ll val,ans=0;sum[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&val);
		sum[i]=sum[i-1]+val;
		if(sum[i]==0) ans+=(mp[0]++)+1;
		else ans+=mp[sum[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}





Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool solve(vector<string> w) {
  map<string, int> words;
  REP(i,w.size()) {
    //    cout << i << w[i] << endl;                                         
    words[w[i]]++;
    if(words[w[i]]>1) return false;
    if(i > 0) {
      if(w[i-1][w[i-1].length()-1] != w[i][0]) return false;
    }
  }
  return true;
}

int main() {
  int N; cin>>N;
  vector<string> w(N);
  REP(i,N) cin>>w[i];
  bool ans = solve(w);
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  cout << setprecision(10);
  int A,B,Q;
  cin >> A >> B >> Q;

  vector<ll> S(A);
  vector<ll> T(B);
  for(int i = 0; i < A; i++){
    cin >> S[i];
  }
  for(int i = 0; i < B; i++){
    cin >> T[i];
  }

  // (S,T)から一番近い(T,S)までの距離
  vector<ll> StoT(A,MAX);
  vector<ll> TtoS(B,MAX);

  for(int i = 0; i < A; i++){
    int index = lower_bound(T.begin(), T.end(), S[i]) - T.begin();

    if(index < B)   StoT[i] = min(StoT[i], abs(S[i] - T[index]));
    if(index+1 < B) StoT[i] = min(StoT[i], abs(S[i] - T[index+1]));
    if(index-1>= 0) StoT[i] = min(StoT[i], abs(S[i] - T[index-1]));

  }
  for(int i = 0; i < B; i++){
    int index = lower_bound(S.begin(), S.end(), T[i]) - S.begin();

    if(index < A)   TtoS[i] = min(TtoS[i], abs(T[i] - S[index]));
    if(index+1 < A) TtoS[i] = min(TtoS[i], abs(T[i] - S[index+1]));
    if(index-1>= 0) TtoS[i] = min(TtoS[i], abs(T[i] - S[index-1]));

  }


  while(Q--){
    ll x;
    cin >> x;

    ll ans = MAX;
    // Sから

    // Tから
    int index;
    index = lower_bound(T.begin(), T.end(), x) - T.begin();

    if(index < B)      ans = min(ans, abs(x - T[index]) + TtoS[index]);
    if(index + 1 < B)  ans = min(ans, abs(x - T[index+1]) + TtoS[index+1]);
    if(index - 1 >= 0) ans = min(ans, abs(x - T[index-1]) + TtoS[index-1]);

    index = lower_bound(S.begin(), S.end(), x) - S.begin();
    if(index < A)      ans = min(ans, abs(x - S[index]) + StoT[index]);
    if(index+1 < A)    ans = min(ans, abs(x - S[index+1]) + StoT[index+1]);
    if(index-1 >= 0)   ans = min(ans, abs(x - S[index-1]) + StoT[index-1]);


    cout << ans << endl;

  }


}


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

int main() {
  string s;

  cin >> s;

  while (1) {
    s.pop_back();
    s.pop_back();
    for (int i = 0; i < (int)s.size() / 2; i++) {
      if (s[i] != s[i + (int)s.size() / 2]) break;
      if (i == (int)s.size() / 2 - 1) {
        cout << (int)s.size();
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M, i, j, P[100001], Y[100001];
    vector<ll> yd[100010];
    int x;

    cin >> N >> M;

    for(i=1; i<=M; i++){
        cin >> P[i] >> Y[i];

        yd[P[i]].push_back(Y[i]);
    }

    for(i=1; i<=N; i++){
        sort(yd[i].begin(), yd[i].end());
    }

    for(i=1; i<=M; i++){
        printf("%06d", P[i]);

        auto x = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin();
        j = x;
        printf("%06d", j+1);

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

const int MAX_N = 300005;

ll fmemo[MAX_N + 3];
ll imemo[MAX_N + 3];
ll ifmemo[MAX_N + 3];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll fact(ll n){
    if(n == 0) return 1;
    if(fmemo[n]) return fmemo[n];
    return fmemo[n] = n * fact(n - 1) % MOD;
}

ll ifact(ll n){
    if(n == 0) return 1;
    if(ifmemo[n]) return ifmemo[n];
    return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
}

ll com(ll n, ll k){
    if(k > n) return 0;
    if(k < 0) return 0;
    if(k == n || k == 0) return 1;
    return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
}

int main()
{
    for(ll i = 1; i <= MAX_N; i++){
        imemo[i] = modpow(i, MOD - 2);
    }
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        if((k - a * i) % b == 0){
            int j = (k - a * i) / b;
            ans += com(n, i) * com(n, j) % MOD;
        }
    }
    cout << ans % MOD << endl;
}

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

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

  vector<int> NUM(M);
  vector<vector<int>> SUM(M, vector<int>(N+1));
  for(auto i = 0; i < N; ++i) {
    int m;
    cin >> m;
    --m;
    ++NUM[m];
    ++SUM[m][i+1];
    for(auto j = 0; j < M; ++j) SUM[j][i+1] += SUM[j][i];
  }

  auto test = [](int bit, int i) {return bit & (1 << i);};
  auto set = [](int bit, int i) {return bit | (1 << i);};
  auto cost = [&](int bit, int i) {
    auto n = 0;
    for(auto j = 0; j < M; ++j) if(test(bit, j)) n += NUM[j];
    return SUM[i][n + NUM[i]] - SUM[i][n];
  };

  vector<int> dp(1 << M);
  for(auto bit = 0; bit < (1<<M); ++bit)
    for(auto i = 0; i < M; ++i)
      if(!test(bit, i))
        dp[set(bit, i)] = max(dp[set(bit, i)], dp[bit] + cost(bit, i));

  cout << N - dp.back() << endl;
}

Measured memory_bytes: 14692
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <string>
#include <vector>

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

using usize = std::size_t;

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

  usize ans = std::numeric_limits<usize>::max();

  std::vector<bool> parity(26, false);
  for (const auto e : s) {
    parity[e - 'a'].flip();
  }

  std::cout << std::count(parity.begin(), parity.end(), true) / 2 << std::endl;

  return 0;
}



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

#define int long long
#define ll long long
#define pb push_back

int n, m;
vector<vector<int>> g;

main(){
    cin >> n >> m;
    g.resize(n);
    for(int i = 0; i < m; i++){
        int q, w;
        cin >> q >> w;
        q--;
        w--;
        g[w].pb(q);
        g[q].pb(w);
    }
    vector<int> h(n);
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        h[i] = -1;
    }
    queue<int> bfs;
    bfs.push(0);
    h[0] = 0;
    while (!bfs.empty()){
        int fi = bfs.front();
        bfs.pop();
        for(int i = 0; i < g[fi].size(); i++){
            int to = g[fi][i];
            if (h[to] == -1){
                h[to] = h[fi] + 1;
                ans[to] = fi;
                bfs.push(to);
            }
        }
    }
    cout << "Yes" << '\n';
    for(int i = 1; i < n; i++){
        cout << ans[i] + 1<< '\n';
    }
}


Measured memory_bytes: 13768
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const long long int MOD=1e9+7;

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

    if(M==1) {
        cout << 1 << endl;
        return 0;
    }
    
    long long int m=M;
    vector<int> vec;
    vec.push_back(0);
    long long int c=2;
    int counter=0;
    bool flag=false;
    while(m>=c*c) {
        if(m%c==0) {
            counter++;
            flag=true;
            m /= c;
        } else {
            if(flag) {
                vec.push_back(counter);
                counter=0;
            }
            flag=false;
            c++;
        }
    }

    vec.push_back(counter);

    if(c==m) {
        vec[vec.size()-1]++;
    } else {
        vec.push_back(1);
    }
    
    // for(int vi=0; vi<vec.size(); vi++) {
    //     cout << vec[vi] <<  " ";
    // }
    // cout << endl;

    int max_vec=0;
    for(int vi=1; vi<vec.size(); vi++) {
        max_vec = max(max_vec, vec[vi]);
    }
    
    vector<vector<long long int> > dp(N+1, vector<long long int>(max_vec+1, 0));
    dp[0][0]=1;
    for(int n=1; n<N+1; n++) {
        for(int vi=0; vi<max_vec+1; vi++) {
            if(vi==0) {
                dp[n][vi] = dp[n-1][vi];
            } else {
                dp[n][vi] = (dp[n-1][vi]+dp[n][vi-1])%MOD;
            }
        }
    }
    
    long long int ans=1;
    for(int vi=1; vi<vec.size(); vi++) {
        ans *= dp[N][vec[vi]];
        ans %= MOD;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 27648
package main

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

func main() {
  var n int = NextInt()
  var a []int = make([]int,n+1)
  for i:=0;i<n;i++ { a[NextInt()-1] = i }
  a[n] = -1
  var m int
  for i,j:=0,1;j<n+1;j++ {
    if a[j] > a[j-1] { continue }
    if m < j-i { m = j-i }
    i = j
  }
  fmt.Println(n-m)
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}

Measured memory_bytes: 5504
package main

import "fmt"

func main() {
  var str1, str2 string
  fmt.Scanf("%s", &str1)
  fmt.Scanf("%s", &str2)
  count := 0
  for i := 0; i < 3; i++ {
    if str1[i] == str2[i] {
      count++
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll x;
	cin >> x;
	cout << ceil((-1 + sqrt(1 + 8 * x)) / 2.0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >>  a.at(i);
  int sum = 0;
  for(int i = 0; i < N; i += 2){
    if(a.at(i) % 2 == 1) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i,N;
    cin >> N;
    int field[N];
    int dp[N];
    for(i=0;i<N;i+=1){
        cin >> field[i];
    }
dp[0]=0;
dp[1]=abs(field[0]-field[1]);
for(i=2;i<N;i+=1){
    dp[i]=min(dp[i-1]+abs(field[i-1]-field[i]),dp[i-2]+abs(field[i-2]-field[i]));
}
    cout << dp[N-1] << endl;
    return 0;
}



Measured memory_bytes: 4404
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let a = vec![1, 4, 7, 9];
    let mut b = input_vector::<usize>();
    b.sort();
    println!("{}",if a == b { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int N = 200010, MP = 20;
void getans(bool tmp) {
  if (tmp) puts("POSSIBLE");
  else puts("IMPOSSIBLE");
  exit(0);
}
struct edge {
  int la,b;
} con[N];
int tot,fir[N],vis[N],inp[N],sta[N],top,cir[N],cnt,avail[N][MP],val[N],n;
void add(int from,int to) {
  con[++tot] = (edge) {fir[from],to};
  fir[from] = tot;
}
int getmex(int pos) {
  for (int i = 0 ; i < MP ; ++ i) if (!avail[pos][i])
    return i;
  assert(0);
}
int fsd(int pos) {
  for (int i = fir[pos] ; i ; i = con[i].la)
    avail[pos][fsd(con[i].b)] = 1;
  return getmex(pos);
}
bool dfs(int pos) {
  vis[pos] = 1;
  inp[pos] = 1;
  sta[++top] = pos;
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (inp[con[i].b]) {
      while (sta[top] != con[i].b)
        cir[++cnt] = sta[top--];
      cir[++cnt] = sta[top--];
      return 1;
    } else if (vis[con[i].b]) continue;
    else if (dfs(con[i].b)) return 1;
  }
  inp[pos] = 0;
  top --;
  return 0;
}
int main() {
  int x;
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&x);
    add(x,i);
  }
  for (int i = 1 ; i <= n ; ++ i)
    if (!vis[i]) dfs(i);
  if (!cnt) getans(1);
  for (int k = 1 ; k <= cnt ; ++ k) {
    int pos = cir[k];
    for (int i = fir[pos] ; i ; i = con[i].la)
      if (con[i].b != cir[(k + cnt - 2) % cnt + 1])
      avail[pos][fsd(con[i].b)] = 1;
  }
  for (int i = 0 ; i < MP ; ++ i)
    avail[cir[cnt+1]][i] = avail[cir[1]][i];
  val[1] = getmex(cir[1]);
  for (int i = 2 ; i <= cnt+1 ; ++ i) {
    int tmp = avail[cir[i]][val[i-1]];
    avail[cir[i]][val[i-1]] = 1;
    val[i] = getmex(cir[i]);
    avail[cir[i]][val[i-1]] = tmp;
  }
  if (val[1] == val[cnt+1]) getans(1);
  int rec = val[1];
  avail[cir[1]][val[1]] = 1;
  val[1] = getmex(cir[1]);
  for (int i = 2 ; i <= cnt ; ++ i) {
    int tmp = avail[cir[i]][val[i-1]];
    avail[cir[i]][val[i-1]] = 1;
    val[i] = getmex(cir[i]);
    avail[cir[i]][val[i-1]] = tmp;
  }
  if (rec == val[cnt]) getans(1);
  getans(0);
  return 0;
}

Measured memory_bytes: 27136
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    long long N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= i + 1;
    }

    sort(A, A + N);
    long long b;
    if (N % 2) {
        b = A[N / 2];
    }
    else {
        b = (A[N / 2 - 1] + A[N / 2]) / 2;
    }

    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += abs(A[i] - b);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		int n =sc.nextInt();
		
int x = n*800;
int y = (n/15)*200;
System.out.println(x-y);


	}
	
	
	
}

class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll  long long
using namespace std;
const int manx=3e5+5;
ll n,k=1;
string s="          ";
void dfs(ll x){
    if(x==n+1){
        for(int i=1;i<=n;i++) cout<<s[i];
        cout<<endl;
        return;
    }
    for(int i=0;i<=k;i++) {
        s[x]='a'+i;
        ll tmp=k;
        if(i==k)k++;
        dfs(x+1);
        k=tmp;
    }
}
int main(){
    cin>>n;
    s[1]='a';
    dfs(2);
    return 0;
}


Measured memory_bytes: 1536
//rohitaas_15
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define int ll
#define um(a,b) unordered_map<a,b>
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
//#define endl "\n"
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
/*ll constructSTUtil(vr v,ll start,ll end,int *st,ll index)
{
	if(start==end)
	{
		st[index]=v[start];
		return st[index];
	}
	ll mid=(start+end)/2;
	st[index]=constructSTUtil(v,start,mid,st,2*index)+constructSTUtil(v,mid+1,end,st,2*index+1);
	return st[index];
}
ll *constructST(vr v,ll n)
{
	ll po=(ll)(ceil(log2(n)));
	ll msize=2*power(2,po)+1;
	vr st[msize];
	constructSTUtil(v,0,n-1,st,1);
	return st;
}*/
ll ask(ll x)
{
	cout<<x<<endl;
	ll y;
	cin>>y;
	return y;
}
bool compare(pair<ll,ll> &a,pair<ll,ll> &b)
{
	return a.second<b.second;
}
signed main()
{
	/*#ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	 #endif
	 */
	fastio();
	/*ll t,w;cin>>t;
	ll c=t;
	while(t--)
	{
	*/
		ll r;
		cin>>r;
		double pi=6.28318/(double)2;
		double ans=(double)2*pi*r;
		show(ans);


	//}
	/*cout<<"Case #"<<c-t<<": ";
		cout<<*/

}


Measured memory_bytes: 3776
#include<stdio.h>
int main()
{
    int D, N, i;
    int dh=1;
    scanf("%d %d", &D, &N);
    for(i=0; i<D; i++)
        dh=dh*100;
    if(N==100)
        printf("%d\n", N*dh + dh);
    else
        printf("%d\n", N*dh);
    return 0;
}

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

int main(){

    vector<int> S(9);
    for(int i=0;i<9;i++){
        cin>>S.at(i);
    }
    bool ans=true;
    if(S[1]-S[0]!=S[4]-S[3]||S[4]-S[3]!=S[7]-S[6]) ans=false;
    if(S[2]-S[1]!=S[5]-S[4]||S[5]-S[4]!=S[5]-S[4]) ans=false;
    if(S[3]-S[0]!=S[4]-S[1]||S[4]-S[1]!=S[5]-S[2]) ans=false;
    if(S[6]-S[3]!=S[7]-S[4]||S[7]-S[4]!=S[8]-S[5]) ans=false;
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
   


Measured memory_bytes: 256
package main

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

var mod = 1000000007

func main() {
	r := bufio.NewReader(os.Stdin)
	var x, a int
	fmt.Fscan(r, &x)
	fmt.Fscan(r, &a)

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

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

int main() {
	int cnt = 0;
	int use, want, nes;

	cin >> use >> want;

	if (want > 1) {
		nes = want - use;
		cnt++;

		while (nes > 0) {
			nes -= use - 1;
			cnt++;
		}
	}

	cout << cnt << "\n";

	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        // 入力
         long n = long.Parse(Console.ReadLine());
         long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //配列を昇順でソート
        Array.Sort(a);
        string ans = "YES";
        for (long i = 0; i < a.Length-1; i++)
        {
            if (a[i] == a[i+1])
            {
                ans = "NO";
            }
        }

        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 37020
n,m=map(int,input().split())
ab={}
for i in range(m):
    a,b=map(int,input().split())
    if a in ab:
        ab[a]=min(ab[a],b)
    else:
        ab[a]=b
ab = sorted(ab.items(), key=lambda x:x[0])

ans=1
min_end=10**10
for i in range(len(ab)):
    if ab[i][0]>=min_end:
        ans+=1
        min_end=ab[i][1]
    else:
        min_end=min(ab[i][1], min_end)
print(ans)

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

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	string s, t;
	int a, b;
	string r;
	cin >> s >> t;
	cin >> a >> b;
	cin >> r;
	if (s == r) {
		cout << a - 1 <<' '<< b << endl;
	}
	else cout << a <<' '<< b - 1 << endl;
}


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

using namespace std;

long long N , M , A[100001] , B[100001] , C[100001] , P[100001] , Q[100001];

int main(){
long long tong=0  ;
	ios_base::sync_with_stdio(0) ;
	cin >> N >> M ;
	cin>>P[1];
	for(long i=2 ; i<=M ; i++){
		cin >> P[i];
		if(P[i] <= P[i-1]) for(int j=P[i] ; j<P[i-1] ; j++) Q[j]++;
		else for(int k=P[i-1] ; k<P[i] ; k++) Q[k]++;
	}
	for(long i=1 ; i< N ; i++){
	    cin >> A[i] >> B[i] >> C[i] ;
	}
	for(long i=1 ; i<=N-1; i++){
		tong+=min(A[i]*Q[i] , C[i]+B[i]*Q[i]);	
	}
	cout<<tong<<endl;
return 0;
}

Measured memory_bytes: 7096
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int sum, max, min;
	
	while( 1 ){
		sum = 0; max = 0; min = 1000;
		cin >> n;
		vector<int> score(n);
		if( n == 0 ) break;
		for( int i = 0; i < n; i++ ){
			cin >> score[i];
			sum += score[i];
			if( max < score[i] ) max = score[i];
			if( min > score[i] ) min = score[i];
		}
		sum -= max + min;
		cout << sum/(n-2) << endl;
		score.clear();
	}
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#include<queue>
#define ll long long
int main()
{
	int n;
	cin>>n;
	ll sy=1000,temp=0;
	int num[n+1];
	int cha[n+1]={};
	for(int i=0;i<n;i++)   //进行初始化 
	{
		cin>>num[i];  //初始化 
		if(i>=1&&i<=n-1)     //如果是第二个到倒数第1个之间 
		{
			cha[i]=num[i]-num[i-1];     //进行差值数组的初始化 
			if(cha[i]>0)           //如果能赚钱 
			{
				temp=sy/num[i-1];     //求能买的股票个数 
				sy=sy+temp*cha[i];
			//	cout<<sy<<endl;       // 剩余的钱数 
			}
		}
	}
	cout<<sy<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e1+5;
const double EPS = 1e-6;
using namespace std;
char s[maxn];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	if(len<4) return printf("No\n"),0;
	int i=0;
	if(s[i]=='Y'&&s[i+1]=='A'&&s[i+2]=='K'&&s[i+3]=='I'){
		return printf("Yes\n"),0;
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define aint(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define mod 1000000007
#define intmx INT_MAX 
#define intmi INT_MIN
void solve(){
    string s,t;
    cin>>s>>t;
    int ans=intmx;
    ff(i,0,(int)s.size()-(int)t.size()+1){
        int cnt=0;
        ff(j,0,t.size()){
            if(s[i+j]!=t[j])
            cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3628
//https://atcoder.jp/contests/abc122/tasks/abc122_c
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;

    vector<int> a(N + 1, 0);

    for (int i = 1; i < N; i++) {
        a[i + 1] = a[i];
        if (S[i - 1] == 'A' && S[i] == 'C') {
            a[i + 1]++;
        }
    }
    
    int x, y;
    for (int i = 0; i < Q; i++) {
        cin >> x >> y;
        int ans = a[y] - a[x];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
#pragma GCC optimize("O3")
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<algorithm>
typedef signed long long int int64;
inline unsigned getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register unsigned x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
inline int64 min(const int64 &a,const int64 &b) {
	return a<b?a:b;
}
const int64 inf=0x7ffffffffffffff;
const int N=200001;
int n;
class FenwickTree {
	private:
		int64 val[N];
		int lowbit(const int &x) const {
			return x&-x;
		}
	public:
		FenwickTree() {
			std::fill(&val[0],&val[N],inf);
		}
		void modify(int p,const int64 &x) {
			while(p<=n) {
				val[p]=std::min(val[p],x);
				p+=lowbit(p);
			}
		}
		int64 query(int p) const {
			int64 ret=inf;
			while(p) {
				ret=std::min(ret,val[p]);
				p-=lowbit(p);
			}
			return ret;
		}
};
FenwickTree ta;
class RevFenwickTree {
	private:
		int64 val[N];
		int lowbit(const int &x) const {
			return x&-x;
		}
	public:
		RevFenwickTree() {
			std::fill(&val[0],&val[N],inf);
		}
		void modify(int p,const int64 &x) {
			while(p) {
				val[p]=std::min(val[p],x);
				p-=lowbit(p);
			}
		}
		int64 query(int p) const {
			int64 ret=inf;
			while(p<=n) {
				ret=std::min(ret,val[p]);
				p+=lowbit(p);
			}
			return ret;
		}
};
RevFenwickTree tb;
int64 f[N];
inline void modify(const int &p,const int64 x) {
	if(x<f[p]) {
		f[p]=x;
		ta.modify(p,x-p);
		tb.modify(p,x+p);
	}
}
int main() {
	n=getint();
	int q=getint(),a=getint(),b=getint();
	std::fill(&f[0],&f[N],inf);
	modify(a,0);
	int64 sum=0;
	while(q--) {
		a=b;
		b=getint();
		sum+=abs(a-b);
		int64 t1=ta.query(b)+b,t2=tb.query(b)-b;
		modify(a,min(t1,t2)-abs(a-b));
	}
	int64 tmp=inf;
	for(register int i=1;i<=n;i++) {
		tmp=min(tmp,f[i]);
	}
	printf("%lld\n",tmp+sum);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, c[N][3], dp[N][3];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++)
 		for(int j=0; j<=2; j++) 
		 	cin >> c[i][j];
 	for(int i=0; i<=2; i++) dp[1][i] = c[1][i];
 	for(int i=2; i<=n; i++)
 		for(int j=0; j<=2; j++)
 			for(int k=0; k<=2; k++)
 				if(k!=j) dp[i][j] = max(dp[i][j], dp[i-1][k] + c[i][j]);
 	int ans = 0;
 	for(int i=0; i<=2; i++) ans = max(ans, dp[n][i]);
 	cout << ans;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	set<int> s;
	int A, B, C;
	cin>>A>>B>>C;
	int hoge = A % B;
	bool d = false;
	while(!s.count(hoge)) {
		s.insert(hoge);
		if(hoge == C) {
			d = true;
			break;
		}
		hoge += (A % B);
		hoge = hoge % B;
	}
	if(d) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
s = input()
t_list = ['dream','dreamer','erase','eraser']
while s != '':
    for i in range(len(t_list)):
        if s[-len(t_list[i]):] == t_list[i]:
            s = s[:len(s)-len(t_list[i])]
            break
    else:
        print('NO')
        break
if s == '':
    print('YES')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define S(x) scanf("%d",&x);
#define SS(x,y) scanf("%d%d",&x,&y);
int num[106];
int main()
{
    int n;
    S(n);
    LL sum=0;
    for(int i=1;i<=n;i++)
        {
            S(num[i]);
            sum+=num[i];
        }
        //cout<<sum<<endl;
    LL avg=0;
    LL minn;
    LL ans=0;
    avg=(LL)ceil(sum*1.0/n);
    //cout<<avg<<endl;
    for(int i=1;i<=n;i++)
    {
        ans+=(num[i]-avg)*(num[i]-avg);
    }
    minn=ans;
    avg=(LL)floor(sum*1.0/n);
    ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=(num[i]-avg)*(num[i]-avg);
    }
    minn=min(minn,ans);
    printf("%d\n",minn);
}


Measured memory_bytes: 256