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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;
  bool ok = true;

  ll l = 0, r = s.size()-1;
  while(l < r) {
    if(s[l]==s[r]) {
      l ++; r --;
    } else {
      if(s[l] == 'x') {
	l++;
	ans ++;
      } else if(s[r] == 'x') {
	r --;
	ans ++;
      } else {
	ok = false;
	break;
      }
    }
  }

  cout << (ok?ans:-1) << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

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

int main(){
  int n,m;
  cin >> n >> m;
  
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) cin >> a.at(i) >> b.at(i);

  vector<int> c(m);
  vector<int> d(m);
  rep(i,m) cin >> c.at(i) >> d.at(i);

  rep(i,n){
    ll dist=1000000000;
    int ans=-1;
    rep(j,m){
      ll check = abs(a.at(i)-c.at(j)) + abs(b.at(i)-d.at(j));
      if(check<dist) {ans = j; dist=check;}
    }
    cout<<ans+1<<endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool isgood = true;
  if (s[0] == s[1]) isgood = false;
  if (s[2] == s[1]) isgood = false; 
  if (s[2] == s[3]) isgood = false;
  if (isgood) cout << "Good";
  else cout <<"Bad";
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
 
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	if(a == b) System.out.println("a == b");
    	else System.out.println((a > b)?"a > b":"a < b");
	}
}


Measured memory_bytes: 26212
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0 ; i < n ; i++) {
            s[i] = sc.next();
        }
        Map<String, Integer> map = new HashMap<String, Integer>();
        for (String t : s) {
            if (map.containsKey(t)) {
                map.put(t, map.get(t) + 1);
            } else {
                map.put(t, 1);
            }
        }
        int min = 0;
        for (Entry<String, Integer> entry : map.entrySet()) {
            min = Math.max(min, entry.getValue());
        }
        Set<String> set = new TreeSet<>();
        for (Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue() == min) set.add(entry.getKey());
        }
        for (String t : set) {
            System.out.println(t);
        }
    }

}

Measured memory_bytes: 84748
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

N, M = map(int, input().split())
uf = Uf(N+1)
for _ in range(M):
    X, Y, Z = map(int, input().split())
    uf.unite(X, Y)
s = set()
for i in range(1, N+1):
    s.add(uf.root(i))
print(len(s))


Measured memory_bytes: 14700
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

#define MAX 100000

// p[i] : i 以下の素数の個数
bool p[MAX + 1];
int pp[MAX + 1];

int main() {

	//clock_t start, end;
	//start = clock();

	for (int i = 2; i <= MAX; i++) p[i] = true;
	for (int i = 2; i * i <= MAX; i++) {
		for (int j = i * i; j <= MAX; j += i) {
			p[j] = false;
		}
	}

	for (int i = 2; i <= MAX; i++) {
		int N = (i + 1) / 2;
		if (p[i] && p[N]) pp[i] = 1;
	}

	for (int i = 2; i < MAX; i++) pp[i + 1] += pp[i];
	
	int Q;
	cin >> Q;

	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		cout << pp[r] - pp[l - 1] << endl;
	}

	//end = clock();
	//printf("%f sec.\n", double(end - start) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    ll N;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        ll A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


Measured memory_bytes: 764
from math import *
a,b,c = map(int,raw_input().split())
sinc = sin(radians(c))
cosc = cos(radians(c))
S = 0.5 * a * b * sinc
L = a+b+sqrt(a**2+b**2-2*a*b*cosc)
h = b*sinc
print S
print L
print h

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "MON")
        cout << 6 << '\n';
    else if (s == "TUE")
        cout << 5 << '\n';
    else if (s == "WED")
        cout << 4 << '\n';
    else if (s == "THU")
        cout << 3 << '\n';
    else if (s == "FRI")
        cout << 2 << '\n';
    else if (s == "SAT")
        cout << 1 << '\n';
    else
        cout << 7 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int k, a, b; cin >> k >> a >> b;
    Rep(i, a, b+1) {
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;
	 long long h,w;
	
	cin >> h>>w;
	if (h == 1 || w == 1)cout << 1 << endl;
	else if (h % 2 == 0 || w % 2 == 0)cout << h * w / 2 << endl;
	else cout << h*w/2+1 << endl;
	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  ll s, a = INF;
  cin >> s;

  while (s >= 100) {
    a = min(a, abs(753 - s % 1000));
    s /= 10;
  }

  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define repd(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i >= _##i; --i)
#define debug(x...) printf("["#x"]="),print(x);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fcout cout<<setprecision(4)<<fixed
using namespace std;
typedef long long ll;
//======================================
namespace FastIO{
char print_f[105];void read() {}void print() {putchar('\n');}
template <typename T, typename... T2>
inline void read(T &x, T2 &... oth){x = 0;char ch = getchar();ll f = 1;while (!isdigit(ch)){if (ch == '-')f *= -1;ch = getchar();}while (isdigit(ch)){x = x * 10 + ch - 48;ch = getchar();}x *= f;read(oth...);}
template <typename T, typename... T2>
inline void print(T x, T2... oth){ll p3=-1;if(x<0) putchar('-'),x=-x;do{print_f[++p3] = x%10 + 48;}while(x/=10);while(p3>=0) putchar(print_f[p3--]);if(sizeof...(T2)) putchar(' ');print(oth...);}} // namespace FastIO

using FastIO::print;
using FastIO::read;
//======================================
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn = 1e6+5;
int a[maxn],b[maxn];
int main() {
#ifndef ONLINE_JUDGE
    freopen("H:\\code\\in.in", "r", stdin);
    freopen("H:\\code\\out.out", "w", stdout);
    clock_t c1 = clock();
#endif
//**************************************
    int n;
    read(n);
    rep(i,1,n) read(a[i],b[i]);
    int flag=0;
    rep(i,1,n-2){
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
            flag=1;
            break;
        }
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
//**************************************
    
#ifndef ONLINE_JUDGE
    cerr << "Time:" << clock() - c1 << "ms" << endl;
#endif
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
const int INF = 1001001001;
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll n, k, pos = 1, moves;
    cin >> n >> k;
    vector<ll> v(n+1), last(n+1);
    for(int i=1;i<=n;i++) cin >> v[i];
    while(k--) {
        pos = v[pos];
        if(last[pos]) k %= moves - last[pos];
        last[pos] = moves++;
    }
    cout << pos << endl;
    return 0;
}


Measured memory_bytes: 6372
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(-100,113):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)

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

int main(){
	using namespace std;

	vector<int> abc;
	int k;
	int tmp;
	for(int i=0;i<3;i++){
		cin >> tmp;
		abc.push_back(tmp);
	}
	cin >> k;
	sort(abc.begin(),abc.end());
	cout << abc[0] + abc[1] + abc[2] * pow(2,k) << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
typedef long long ll;
int N;
int l[26];
char S[100001];

ll add(ll a, ll b){return (a+b)%1000000007L;}
ll mul(ll a, ll b){return (a*b)%1000000007L;}

int main(void){
    cin >> N;
    cin >> S;
    memset(l, 0, 26);
    ll ans = 1;
    for (int i=0;i<N;i++){
        l[S[i]-'a']++;
    }
    for (int i=0;i<26;i++){
        if (l[i]==0) continue;
        ans = mul(ans, l[i]+1);
    }
    ans--;
    cout << ans << endl;
}

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

using namespace std;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;

ll mod = 1e9+7;

ll solve() {
    ll n, a, b; cin >> n >> a >> b;
    if ( a == 0 && b == 0) return 0;
    ll c = a + b;

    return a * (n / c) + min(n % c, a);
}

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

	cout << solve() << endl;
}


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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  if ((A+B) < (C+D)) {
  cout << "Right" << endl;
  }
  else if ((A+B) == (C+D)) {
  cout << "Balanced" << endl;
  }
  else if ((A+B) > (C+D)) {
  cout << "Left" << endl;
  }
}


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


long long dp[3005][3005][4];

int main(){
    int R, C, K; cin >> R >> C >> K;
    vector<vector<long long>> table(R, vector<long long>(C));

    for(int i=0; i<K; ++i){
            int r, c, v;
            cin >> r >> c >> v;
            r--; c--;
            table[r][c] = v;
    }

    //init
    for(int i=0; i<R; ++i){
        for(int j=0; j<C; ++j){
            for(int k=0; k<3; ++k){
                //右に行く場合
                //使う場合
                dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + table[i][j]);
                //使わない場合
                dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k+1]);

                //下に行く場合
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j+1][k+1]);
            }
        }
    }

    cout << dp[R][C-1][0] << endl;
}

Measured memory_bytes: 355600
n=int(input())
s = [input()for _ in range(n)]
t = input()
s += [t]
a = s.copy()
z = s.copy()
for i in range(n):
  a[i] = a[i].replace('?', 'a')
  z[i] = z[i].replace('?', 'z')
a.sort(reverse=True)
z.sort()
idx1 = z.index(t)
idx2 = n - a.index(t)
print(' '.join(map(str,range(idx1 + 1, idx2 + 2))))


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

int main()
{
	int n;


	while(true){
		int c = 0;
		
		cin >> n;

		if(n==0)
			break;


		for(int i=0 ;n!=1 ;i++){
		
			if(n%2 == 0){
				n = n/2;
				c++;
			}
			else if(n%2 != 0){
				n = 3*n + 1;
				c++;

			}
		}

		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
// scanf("%d %d %d %d", &w, &b, &d, &s); %lld
// printf("%d\n", points);
// const double PI = acos(-1);

int main() 
{
	fastIO;
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i<s.size(); i++){
		if(s[i]!=t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int H, W;
  scanf("%d", &H);
  scanf("%d", &W);
  int c[10][10];
  for (int i=0; i<10; i++){
    for (int j=0; j<10; j++){
      scanf("%d", &c[i][j]);
    }
  }
  std::vector<int > sum(10, 0);
  int A[205][205];
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      scanf("%d", &A[i][j]);
      if (A[i][j]!=-1){
        sum[A[i][j]]++;
      }
    }
  }
  int dist[10][10];
  for (int i=0; i<10; i++){
    for (int j=0; j<10; j++){
      dist[i][j] = c[i][j];
    }
  }
  for (int l=0; l<13; l++){
    for (int i=0; i<10; i++){
      for (int j=0; j<10; j++){
        for (int k=0; k<10; k++){
          dist[i][j] = std::min(dist[i][k]+dist[k][j], dist[i][j]);
        }
      }
    }
  }
  int ans = 0;
  for (int i=0; i<10; i++){
    ans += sum[i]*dist[i][1];
    //printf("ans += %d*%d\n", sum[i], dist[i][1]);
  }
  printf("%d\n", ans);
  return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> junnbann(1000);
    vector<int> mannzokudo (1000);
    vector<int> add(1000);

    rep(i,n)cin >>junnbann.at(i);
    rep(i,n)cin >> mannzokudo.at(i);
    rep(i,n-1)cin >> add.at(i);

    int all = 0;

    for(int i = 0;i<n;i++){
        int eat = junnbann.at(i);
        all += mannzokudo.at(eat-1);

        if(i != n-1){
            if(junnbann.at(i+1) == eat+1){
            all+=add.at(eat-1);
        }}
    }
    cout<<all<<endl;
   
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, Q; cin >> N >> Q;
	UnionFind uf(N);
	long long int sum = 0;
	for (int i = 0; i < Q; ++i) {
		string st; cin >> st;
		int x, y; cin >> x >> y;
		if (st == "0") {
			uf.unionSet(x, y);
		}
		else {
			cout << ((uf.root(x) == uf.root(y))?1:0 )<< endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3184
/*  ex3_2
    hangan2020 */

#include <stdio.h>
int main(void){
    int number, final_digit;
    scanf("%d", &number);
    /*Calculating final digit*/
    final_digit = number % 10;
    /*Dividing case according to the final digit*/
    switch (final_digit)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1656
import fractions

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

count = B - A + 1
lcd_of_CD = C * D // fractions.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)

Measured memory_bytes: 5560
#include <iostream>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <cstdio>
#include <math.h>
#include <map>
#include <algorithm>
#include <deque>
#include <stack>
#include<set>
//#include <bits/stdc++.h>
#define lson l,mid,rt<<1

#define rson mid+1,r,rt<<1|1

const int N=1e5+100;
using namespace std;

typedef long long ll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
map<string,int>mp;
int main()
{
    int n;cin>>n;
    string s;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(!mp[s]) ans++,mp[s]=1;
    }
    cout<<ans;
    return 0;
}


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

int main(){
  int R,S,P;
  cin>>R>>S>>P;
  vector<int> X(P),Y(P);
  for(int i=0;i<P;i++) cin>>X[i]>>Y[i];

  vector<int> v;
  for(int i=0;i<P;i++){
    int cost=R-X[i];
    if(Y[i]<=S) cost+=S-Y[i]+1;
    else cost+=Y[i]-(S+1)+1;
    v.push_back(cost);
  }

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

  int ans=0;
  for(int i=0;i<P;i++){
    ans=max(ans+1,v[i]);
  }
  cout<<ans+1<<endl;

  return 0;
}



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

int main() {
    int n;
    string s, t, result;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        result.push_back(s[i]);
    }
    for (int i = 0; i < n; i++) {
        if (result.rbegin()[i] != t.rbegin()[i]) {
            result.push_back(t.rbegin()[i]);
        }
    }
    cout << result.size();
    return 0;
}

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

int main(){
  string A, B;
  cin >> A >> B;
  if(A.size()<B.size()){
    cout << "LESS" << endl;
  }
  else if(A.size()>B.size()){
    cout << "GREATER" << endl;
  }
  else{
    int S=A.size();
    string Ans="EQUAL";
    for(int i=0; i<S; i++){
      if(A.at(i)>B.at(i)){
        Ans="GREATER";
        break;
      }
      else if(A.at(i)<B.at(i)){
        Ans="LESS";
        break;
      }
    }
    cout << Ans << endl;
  }
}


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

bool cmp(long long a, long long b){
  return a > b;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int K, N, get;
  vector<int> all;
  priority_queue<int> dis;
  cin >> K >> N;
  for(int i = 0; i < N; i++){
    cin >> get;
    all.push_back(get);
  }
  for(int i = 0; i < N - 1; i++){
    dis.push(all[i+1]-all[i]);
  }
  dis.push(K-all[N-1]+all[0]);
  cout << K-dis.top();
  return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int cnt = 0;
    int ans = 0;
    int h = 0;
    int last_h = 0;
    for (int i = 0; i < N; i++) {
        last_h = h;
        cin >> h;
        if (last_h < h) {
            ans = max(ans, cnt);
            cnt = 0;
        } else {
            cnt++;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i)

using namespace std;
long long n,W,ans;
long long w[N],v[N],f[N];
void in(long long &x){
    long long y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(long long x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(n);in(W);
    For(i,1,n){
    	in(w[i]);in(v[i]);
    }
    For(i,1,100000) f[i]=inf;
    For(i,1,n)
    	for(long long j=100000;j>=v[i];j--){
    		f[j]=min(f[j],f[j-v[i]]+w[i]);
    		if(f[j]<=W) ans=max(ans,j);
    	}
    o(ans);
    return 0;
}

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

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> s(M, 0);
    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        for(int j=0; j<K; j++){
            int a;
            cin >> a;
            s.at(a-1)++;
        }
    }
    int ans=0;
    for(int i=0; i<M; i++){
        if(s.at(i) == N){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define N 100009

int main()
{
    int a, b;
    cin >> a >> b;
    if(a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b << endl;
    else cout << "-1\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>
#include <cstdio>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef unsigned long long		ULLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	int			nNumber;
	int			nDivisorNumber;
	int			nRemainNumber;

	cin >> nNumber >> nDivisorNumber >> nRemainNumber;

	for (int i = 1; i <= 100; i++)
	{
		if ((nNumber * i) % nDivisorNumber == nRemainNumber)
		{
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, l, r, ans;
int main(void){
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d%d", &l, &r);
        ans+=r-l+1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
while True:
    n,m = [int(x) for x in input().split()]
    if n == 0 and m == 0:
        break
    L = [0] * m
    for _ in range(n):
        l = [int(x) for x in input().split()]
        for i in range(m):
            L[i] += l[i]

    M=[]
    for i, j in enumerate(L,1):
        M.append((i,j))

    M.sort(key=lambda x: (-x[1],x[0]) )
    print( *[ x for x, y in M] )


        


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 2000;
const int p = 1000000007;
int row, col;
char grid[maxn][maxn];
int dp[maxn];
int main(){	
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> row >> col;
	for(int i = 1;i <= row;++i)cin >> (grid[i]+1);
	for(int i = 1;i <= row;++i)for(int j = 1;j <= col;++j)dp[j] = (grid[i][j] == '#' ? 0 : (dp[j-1] + dp[j]) % p) + (i==1 and j==1);
	cout << dp[col];
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
using namespace std;

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

	if (s > w) {
		cout << "safe" << endl;
	}
	else {
		cout << "unsafe" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 1e5 + 100;
int a[MAXN];
int q[MAXN * 2];

int LC(int x) { return 2 * x + 1; }
int RC(int x) { return 2 * x + 2; }
int st[MAXN * 8];
void build(int l, int r, int id) {
	if (l == r) {
		st[id] = l;
		return;
	}
	int m = (l + r) / 2;
	build(l, m, LC(id));
	build(m + 1, r, RC(id));
	if (q[st[LC(id)]] < q[st[RC(id)]])
		st[id] = st[LC(id)];
	else
		st[id] = st[RC(id)];
	//st[id] = min(st[LC(id)], st[RC(id)]);
}
int query(int l, int r, int id, int ql, int qr) {
	if (ql <= l && qr >= r)
		return st[id];
	int m = (l + r) / 2;
	int res = ql;
	if (ql <= m) {
		int t = query(l, m, LC(id), ql, qr);
		if (q[t] < q[res])
			res = t;
	}
	if (qr > m) {
		int t = query(m + 1, r, RC(id), ql, qr);
		if (q[t] < q[res])
			res = t;
	}
	return res;
}

int N;
int go(int l, int r, int sub) {
	debug("go(%d, %d, %d)\n", l, r, sub);
	while (l <= r && q[l] == sub) l++;
	while (l <= r && q[r] == sub) r--;
	if (l > r) return 0;
	int id = query(0, 2 * N - 1, 0, l, r);
	debug("id: %d\n", id);
	int ansl = go(l, id - 1, q[id]);
	int ansr = go(id + 1, r, q[id]);
	return ansl + ansr + q[id] - sub;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) {
		int t = 0;
		bool need = false;
		while (a[i] > 1) {
			t++;
			if (a[i] % 2 != 0) need = true;
			a[i] /= 2;
		}
		if (need) q[2 * i] = t + 1, q[2 * i + 1] = t;
		else q[2 * i] = q[2 * i + 1] = t;
	}
	swap(q[0], q[1]);
	for (int i = 1; i < N - 1; i++) {
		if (q[2 * i - 1] < q[2 * i + 2])
			swap(q[2 * i], q[2 * i + 1]);
	}
	build(0, 2 * N - 1, 0);
//	for (int i = 0; i < 10; i++) debug("q[%d]: %d\n", i, q[i]);
//	for (int i = 0; i < 10; i++) debug("st[%d]: %d\n", i, st[i]);
//	debug("test - %d\n", query(0, 2 * N - 1, 0, 1, 2));
//	return 0;//
	int res = go(0, 2 * N - 1, 0);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4608
using System;
using System.Collections.Generic;

class AOJ
{
	public static void Main(string[] args)
	{
        var input = Console.ReadLine().Trim().Split(' ');
        int counter = input.Length;

        var st = new Stack<int>();
        for (int i = 0; i < counter; i++)
        {
            string s = input[i];
            int v1, v2;
            if (s == "+")
            {
                v2 = st.Pop();
                v1 = st.Pop();
                st.Push(v1 + v2);
            }
            else if (s == "-")
            {
                v2 = st.Pop();
                v1 = st.Pop();
                st.Push(v1 - v2);
            }
            else if (s == "*")
            {
                v2 = st.Pop();
                v1 = st.Pop();
                st.Push(v1 * v2);
            }
            else { st.Push(int.Parse(s)); }
        }

        Console.WriteLine(st.Pop());
	}
}

Measured memory_bytes: 5920
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int ctoi(char c){
	return c - '0';
}

int main(){
	string s;
	cin >> s;
	map<ll, ll> mapmod;

	int digit = 1, mem = 0;
	for (int i = s.length()-1; i >= 0; i--){
		mem = (mem + ctoi(s[i])*digit) % 2019;
		mapmod[mem]++;
		digit = (digit * 10) % 2019;
	}

	mapmod[0]++;
	ll ans = 0;
	for (auto x : mapmod){
		ans += x.second*(x.second-1)/2;
	}
	cout << ans << endl;
	return 0;
}



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

ll mn = 1e9;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    rep(i,n-k+1){
        if(h[i+k-1] - h[i] < mn) mn = h[i+k-1] - h[i];
    }
    cout << mn << endl;
}

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

using namespace std;

#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
    int depth;

    bool operator<(const Node &right) const {
        return parent < right.parent;
    }
};

const int MAX_N = 100000;
Node T[MAX_N];


int get_depth(int location) {
    int depth = 0;
    while (T[location].parent != -1) {
        depth++;
        location = T[location].parent;
    }
    return depth;
}

void printChildren(int location) {
    vector<int> children;
    if (T[location].left != -1) {
        location = T[location].left;
        children.push_back(location);
        while (T[location].right != -1) {
            location = T[location].right;
            children.push_back(location);
        }
    }

    for (int i = 0; i < children.size(); ++i) {
        if (i)
            cout << ", ";
        cout << children[i];
    }
}

void print(int location) {
    cout << "node " << location << ": ";
    cout << "parent = " << T[location].parent << ", ";
    cout << "depth = " << get_depth(location) << ", ";
    if (T[location].parent == -1) {
        cout << "root, ";
        cout << "[";
        printChildren(location);
        cout << "]" << endl;
    } else if (T[location].left != -1) {
        cout << "internal node, ";
        cout << "[";
        printChildren(location);
        cout << "]" << endl;
    } else {
        cout << "leaf, ";
        cout << "[]" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        T[i].parent = -1;
        T[i].left = -1;
        T[i].right = -1;
        T[i].depth = -1;
    }

    for (int i = 0; i < n; ++i) {
        int children;
        int position;
        cin >> position;
        cin >> children;
        for (int j = 0; j < children; ++j) {
            int child_node;
            int log;
            cin >> child_node;

            T[child_node].parent = position;
            if (!j) {
                T[position].left = child_node;
                log = child_node;
            } else {
                T[log].right = child_node;
                log = child_node;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        print(i);
    }
}

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

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a,b,c;
	cin >>a>>b>>c;
	if(a>=b){
	cout << "No" << endl;
	}
	else if(b>=c){
	cout << "No" << endl;
	}
	else {
	cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int f=0;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if((i+1)&1){
            if(s[i]=='R' ){
                ans++;
            }
            if(s[i]=='U'){
                ans++;
            }
            if(s[i]=='D'){
                ans++;
            }
        }else{
            if(s[i]=='L' ){
                 ans++;
            }
            if(s[i]=='U'){
                ans++;
            }
            if(s[i]=='D'){
                 ans++;
            }

        }
    }
    if(ans==s.size()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String str[] = s.split("");
        boolean boo = true;
        if(!str[0].equals("A")) boo = false;
        int count = 0;
        int index = 0;
        for(int i=2; i<str.length-1; i++){
            if(str[i].equals("C")){
                count++;
                index = i;
            }
        }
        if(count != 1) boo = false;
        for(int i=1; i<str.length; i++){
            if(i == index) continue;
            if(Character.isUpperCase(s.charAt(i))){
                boo = false;
            }
        }
        if(boo) System.out.println("AC");
        else System.out.println("WA");
    }
}

Measured memory_bytes: 23764
n,m=map(int,input().split())
A=[input() for _ in range(n)]
B=[input() for _ in range(m)]
 
ans='No'
 
for i in range(n-m+1):
    for j in range(n-m+1):
        C=[A[i+k][j:j+m] for k in range(m)]
        if B==C:
            ans='Yes'
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        v.emplace_back(b, a);
    }
    sort(all(v));
    reverse(all(v));
    set<int> s;
    for (int i = 1; i <= m; ++i)
        s.insert(i);
    
    ll sol = 0;
    for (auto k : v)
    {
        int b, a;
        tie(b, a) = k;
        auto q = s.lower_bound(a);
        if (q != s.end())
        {
            sol += b;
            s.erase(q);
        }
    }
    cout << sol;
}


Measured memory_bytes: 5748
#include<cstdio>
int main(){
  int n;
  char a[10];
  int ans = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s", a);
    if(a[0] == 'Y') ans = 1;
  }
  if(ans) puts("Four");
  else puts("Three");
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// 約数の全列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    cout << fixed << setprecision(15);
    
    ll N, M;
    cin >> N >> M;

    vector<ll> D = divisor(M);

    ll ans = 0;
    // 100の約数を小さい順に列挙
    for(auto i: D){
        if(i*N <= M) ans = i;
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n; i>0; i--)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, 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 (a > b) { a = b; return 1; } return 0; }
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int type = 26;

int main() {
	int D;
	cin >> D;
	// 不開催により低下する満足度
	int dec = 0;
	vector<int64_t> c(type);
	vector<vector<int64_t>> l(type, vector<int64_t>(1, -1));
	rep(i, type) {
		cin >> c.at(i);
		dec += c.at(i);
	}
	// 開催により増加する満足度
	vector<vector<int64_t>> s(D, vector<int64_t>(type));
	rep(i, D) {
		rep(j, type) {
			cin >> s.at(i).at(j);
		}
	}

	// 日程変更クエリ
	int M = 30000000;
	vector<pint> dq(M);
	// srand((unsigned int)time(NULL));
	rep(i, M) {
		dq.at(i).first = rand() % D;
		dq.at(i).second = rand() % type;
	}

	// 初期解の満足度計算
	int64_t a=0, b=0, x, y, z;
	vector<int64_t> t(D);
	rep(i, D) {
		// i日目に開催するtype
		x = 0;
		y = 0;
		rep(j, type) {
			if(chmax(y, s.at(i).at(j))) {
				x = j;
			}
		}
		t.at(i) = x;
		// 開催による増加
		a += s.at(i).at(x);
		// 不開催による減少
		b += (dec - c.at(x)*(i-l.at(x).at(l.at(x).size()-1)));
		l.at(x).push_back(i);
		a -= b;
		// 暫定満足度
		// cout << a << endl;
	}
	rep(i, type) {
		l.at(i).push_back(D);
	}

	// 変更処理
	rep(i, M) {
		int64_t p = a;
		x = dq.at(i).first;
		y = t.at(x);
		z = dq.at(i).second;
		if (y == z) continue;
		// 開催による増加差分
		a -= s.at(x).at(y);
		a += s.at(x).at(z);
		// 不開催による減少差分 増加
		int f = 0;
		// l.at(z).push_back(x);
		rrep(j, l.at(z).size()-1) {
			if (l.at(z).at(j-1) <= x) {
				f = j;
				break;
			}
		}
		a += (l.at(z).at(f) - x) * (x - l.at(z).at(f-1)) * c.at(z);
		// 不開催による減少差分 減少
		f = 0;
		rep1(j, l.at(y).size()) {
			if (l.at(y).at(j) == x) {
				f = j;
				break;
			}
		}
		// l.at(y).pop_back();
		a -= (l.at(y).at(f+1) - x) * (x - l.at(y).at(f-1)) * c.at(y);
		// 暫定満足度
		// cout << a << endl;
		if (p > a) {
			a = p;
		} else {
			t.at(x) = z;
			for(int j = f; j < l.at(y).size(); j++) {
			// rep1(j, l.at(y).size()) {
				if (l.at(y).at(j-1) == x) {
					l.at(y).at(j-1) = l.at(y).at(j);
					l.at(y).at(j) = x;
				}
			}
			l.at(y).pop_back();
			l.at(z).push_back(x);
			rrep(j, l.at(z).size()-1) {
				if (l.at(z).at(j-1) > x) {
					l.at(z).at(j) = l.at(z).at(j-1);
					l.at(z).at(j-1) = x;
				} else {
					break;
				}
			}
		}
	}

	// 解
	rep(i, D) {
		cout << t.at(i)+1 << '\n';
	}
}


Measured memory_bytes: 237704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main(){
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


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

typedef struct{
    int k;
    int p;
    int l;
    int r;
}Node;

Node node[500002];
int nil = -1;
int root = -1;
int z;

void insert(int k){
    int y = nil;
    int x = root;
    z++;
    node[z].k = k;
    node[z].l = nil;
    node[z].r = nil;

    while(x != nil){
        y = x;
        if(node[z].k < node[x].k){
            x = node[x].l;
        }
        else x = node[x].r;
    }
    node[z].p = y;
    if(y == nil){
        root = z;
    }
    else{
        if(node[z].k < node[y].k){
            node[y].l = z;
        }
        else node[y].r = z;
    }
}

void inorder(int ppp){
    if (ppp == nil) return;
    inorder(node[ppp].l);
    printf(" %d", node[ppp].k);
    inorder(node[ppp].r);
}

void preorder(int ppp){
    if (ppp == nil) return;
    printf(" %d", node[ppp].k);
    preorder(node[ppp].l);
    preorder(node[ppp].r);
}



int main()
{
    char cccc[20];
    int n;
    int a;

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%s", cccc);
        switch (strcmp(cccc,"insert")){
            case 0:
                scanf("%d", &a);
                insert(a);
                break;
            default:
                inorder(root);
                printf("\n");
                preorder(root);
                printf("\n");
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 9520
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
 
const ll mod = 1e9 + 7;
const ll mmod = 998244353;
 
vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};
 
vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

bool check(const vector<double>& v, ll& k, double len)
{
    ll cur = 0;
    for (int i = 0; i < v.size(); ++i)
    {
        cur += (ll)((v[i] - 0.1) / len);
        if (cur > k)
        {
            return 1;
        }
    }
    return 0;   
}
 
int main() {

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, k;
    cin >> n >> k;

    vector<double> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }

    double l = 0;
    double r = 1e10;

    while ((r - l) > 1e-5)
    {
        double m = (l + r) / 2.0;
        if (check(v, k, m))
        {
            l = m;
        }
        else
        {
            r = m;
        }
    }
    cout << (ll)ceil(r) << endl;
    
    return 0;
}

Measured memory_bytes: 4768