akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b=[0 for _ in range(n)]
for i in range(n):
    y=a[n-i-1]
    b[n-i-1]=y
    divs = make_divisors(n-i)
    for x in divs:
        a[x-1] = a[x-1] ^ y
print(sum(b))
l=[]
for i in range(n):
    if b[i] == 1:
        l.append(i+1)
print(' '.join(map(str,l)))

Measured memory_bytes: 81520
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define N_MAX 100001
#define M_MAX 100001

int par[N_MAX],size[N_MAX];

int find(int a)
{
	if (par[a] == a){
		return a;
	}
	return par[a] = find(par[a]);
}

void unite(int a, int b)
{
	if (find(a) == find(b)){
		return;
	}
	int s = size[find(a)];
	par[find(a)] = find(b);
	size[find(b)] += s;

	return;
}

void solv()
{
	int N, M; scanf("%d%d", &N, &M);
	pair<int, int> edge[M_MAX];
	for (int i = 0; i < M; i++){
		int a, b; scanf("%d%d", &a, &b);
		edge[i] = make_pair(a, b);
	}

	long long int table[M_MAX];
	table[M] = (long long int)N*(long long int)(N - 1) / 2;

	for (int i = 0; i < N; i++){
		par[i] = i;
		size[i] = 1;
	}

	for (int i = M - 1; i >= 0; i--){
		table[i] = table[i+1];
		if (find(edge[i].first-1) != find(edge[i].second-1)){
			table[i] -= (long long int)size[find(edge[i].first-1)] * (long long int)size[find(edge[i].second-1)];
			unite(edge[i].first-1, edge[i].second-1);
		}
	}

	for (int i = 1; i <= M; i++){
		printf("%lld\n", table[i]);
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin>>n;
	string s,t,r="";
	cin>>s>>t;
	for(int i=0;i<n;i++)
	{
		char ss=s.at(i);
		char tt=t.at(i);
		r+=ss;
		r+=tt;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 256
s = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531, 1571, 1601, 1621, 1721, 1741, 1801, 1811, 1831, 1861, 1871, 1901, 1931, 1951, 2011, 2081, 2111, 2131, 2141, 2161, 2221, 2251, 2281, 2311, 2341, 2351, 2371, 2381, 2411, 2441, 2521, 2531, 2551, 2591, 2621, 2671, 2711, 2731, 2741, 2791, 2801, 2851, 2861, 2971, 3001, 3011, 3041, 3061, 3121, 3181, 3191, 3221, 3251, 3271, 3301, 3331, 3361, 3371, 3391, 3461, 3491, 3511, 3541, 3571, 3581, 3631, 3671, 3691, 3701, 3761, 3821, 3851, 3881, 3911, 3931]

n = int(input())
o = ""
for i in range(n):
    o+=str(s[i])+" "
print(o)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin >> n >> t;
    vpii a(n);
    ffor(i,n) cin >> a[i].ff >> a[i].ss;
    vvi dp1(n + 1,vi(t + 1)),dp2(n + 2,vi(t + 1));

    // dp1[i][j] -> max deliciousness with 1 to i dishes in j minutes


    for(int i = 1; i <= n; ++i)
    {
        for(int j = 0; j <= t; ++j)
        {
            dp1[i][j] += dp1[i - 1][j]; 
            if(j - a[i - 1].ff >= 0)
            {
                dp1[i][j] = max(dp1[i][j],dp1[i - 1][j - a[i - 1].ff] + a[i - 1].ss);
            }
        }
    }

    // dp2[i][j] -> max deliciousness with dishes i to nth available


    for(int i = n; i >= 1; --i)
    {
        for(int j = 0; j <= t; ++j)
        {
            dp2[i][j] += dp2[i + 1][j];
            if(j - a[i - 1].ff >= 0)
            {
                dp2[i][j] = max(dp2[i][j],dp2[i + 1][j - a[i - 1].ff] + a[i - 1].ss);
            }
        }
    }

   
    // Calculating the max 
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 0; j <= t; ++j)
        {
            if(t - 1 - j >= 0)
            ans = max(ans,dp1[i - 1][j] + dp2[i + 1][t - 1 - j] + a[i - 1].ss);
        }
    }

    cout << ans;
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 1, (int)A.size()) out << A[i] + 1 << " ";
    return out;
}

int CycleIndex(const vector<int> &A, int n){
    set<int> sy;    //set stores the indices of the elements
    sy.insert(1);
    int next = A[1];
    while (1) {
        if (sy.count(next)) {
            return next;
        } else {
            sy.insert(next);
            next = A[next];
        }
    }
    
}

int32_t main() {
    IOS int n, k;
    cin >> n >> k;
    vector<int> A(n+1);   fr(i,1,n+1)   cin>>A[i];
    int cycle = CycleIndex(A, n);

    cerr << cycle << endl;

    int curr = 1;
    while (curr != cycle and k>0){
        curr = A[curr];
        k--;
    }
    
    int start = cycle,len = 0;
    do{
        len++;
        start = A[start];
    }while(start != cycle);

    k %= len;

    while(k--){
        curr = A[curr];
    }

    cout << curr << endl;
    return 0;
}


Measured memory_bytes: 13976
N,K=map(int,input().split())
A=[]
ans=[]
for i,a in enumerate(input().split()):
  A.append((int(a),i))
unuse=N
for s in range(K+1):
  A.sort(reverse=True)
  for i in range(N):
    a,k=A[i]
    if k==unuse:
      continue
    if a==0:
      print(-1)
      exit()
    ans.append(str(k+1))
    A[i]=(a-1,k)
  unuse=int(ans[-1])-1
 # print(ans,A,unuse)
print(len(ans))
print(" ".join(ans))




Measured memory_bytes: 39152
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> vp(n);
  for (int i = 0; i < n; ++i) {
    cin >> vp[i];
  }

  sort(vp.begin(), vp.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += vp[i];
  }

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

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c-a) <= d or (abs(a-b) <= d && abs(b-c) <= d))cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> mp;
  rep(i,n) {
    cin >> a[i];
    mp[i + a[i]]++;
  }
  
  ll ans = 0;
  
  rep(i,n) {
    ans += mp[i - a[i]];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 27468
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x=1,z=0;
    cin>>a>>b;
    int c[b],d[b],y=0,vy=0;
    for(int i=0;i<b;i++){
        cin>>c[i]>>d[i];
        if(y<c[i]) y=c[i];
    }
    while(1){
        vy=y;
        y=0;
        for(int i=0;i<b;i++){
            if(vy>=d[i]){
                c[z]=c[i];
                d[z]=d[i];
                if(y<c[i]) y=c[i];
                z++;
            }
        }
        if(z) x++;
        else break;
        z=0;
    }
    cout<<x<<endl;
}


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

int main() {
  int A, B, a, b, c, d, e, n, cnt = 0;
  cin >> A >> B;
 
  for (int i = A; i <= B; i++) {
    n = i;
    
    a = n / 10000;
    n %= 10000;
    b = n / 1000;
    n %= 1000;
    c = n / 100;
    n %= 100;
    d = n / 10;
    n %= 10;
    e = n;
    
    if (a == e && b == d) cnt++;
  }
  cout << cnt << endl;
}


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

using namespace std;

int main(){
     int N,M;
     while(cin>>N>>M,N||M){
	  int temp;
	  list<int> times;
	  for(int i=0;i<N+M;i++){
	       cin>>temp;
	       times.push_back(temp);
	  }
	  times.sort();
	  list<int>::iterator itr=times.begin();
	  int maxtime=0;
	  int back=0;
	  while(times.end()!=itr){
	       //cout<<*itr<<endl;
	       int d=(*itr)-back;
	       maxtime=max(maxtime,d);
	       back=(*itr);
	       itr++;
	  }
	  //cout<<endl;
	  cout<<maxtime<<endl;
     }
     return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (n == m)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int root[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
    int x, y;
    cin >> x >> y;
    cout << (root[x] == root[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5+100;
const int mod = 1e9+7;
const int inf = 1e9;
const int sigma = 30;
int n, m, k, t = 1;

int dp[ms];
int ele[ms];

void solve(){
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>ele[i];
    dp[i] = inf;
  }
  dp[0] = 0;
  dp[1] = abs(ele[1] - ele[0]);
  for(int i= 2; i<n; i++){
    dp[i] = min(abs(ele[i] - ele[i-1]) + dp[i-1], abs(ele[i] - ele[i-2]) + dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
  
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

a=0
b=sum(A)

temp=10**12
for i in range(N-1):
    a+=A[i]
    b-=A[i]
    temp=min(abs(a-b),temp)

print(temp)


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

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	char s[3][11];
	int i;
	for(i=0;i<3;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<3;i++){
		printf("%c",'A'+s[i][0]-'a');
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.12 03:24:22
**/

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



struct BellmanFord {
private:
    struct edge {
        int to;
        long long cost;
        edge(int to, long long cost) : to(to), cost(cost) {}
    };
    int N;
    std::vector< std::vector< edge > > G;
public:
    std::vector<long long> d;
    long long inf = 1e18 + 1;
    BellmanFord(int n) {
        N = n;
        G.resize(N);
    }
    void add_edge(int from, int to, long long cost, bool directed = false) {
        G[from].push_back(edge(to, cost));
        if (!directed) G[to].push_back(edge(from, cost));
    }
    void build(int s) {
        d = std::vector< long long >(N, inf);
        d[s] = 0;
        bool update = true;
        int i = 0;
        while (update) {
            update = false;
            for (int j = 0; j < N; j++) {
                for (const edge& e : G[j]) {
                    if (d[j] != -inf && d[j] != inf && d[j] + e.cost < d[e.to]) {
                        d[e.to] = d[j] + e.cost;
                        if (i == N - 1) {
                            d[e.to] = -inf;
                        }
                        update = true;
                    } else if (d[j] == -inf && d[e.to] != -inf) {
                        d[e.to] = -inf;
                        update = true;
                    }
                }
            }
            if (i < N - 1) i++;
        }
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    BellmanFord bf(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bf.add_edge(a,b,-c,true);
    }
    bf.build(0);
    if (bf.d[n - 1] == -bf.inf) {
        puts("inf");
    } else {
        cout << -bf.d[n - 1] << endl;
    }
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

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

    string S; cin >> S;
    int M; cin >> M;

    int a = S[0] - '0';
    vector<int> bs = {S[0] - '0'};
    for(int i = 2; i < S.size(); i += 2) {
        int si = S[i] - '0';
        if(S[i - 1] == '+') {
            a = a + si;
            bs.push_back(si);
        } else if(S[i- 1] == '*') {
            a = a * si;
            bs.back() = bs.back() * si;
        } else assert(0);
    }
    int b = 0;
    for(int i : bs) b += i;
    if(a == M and b == M) cout << "U" << endl;
    else if(a == M) cout << "L" << endl;
    else if(b == M) cout << "M" << endl;
    else cout << "I" << endl;    
    
    return 0;
}

Measured memory_bytes: 3220
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();
        int r = 0;
        int b = 0;
        
        for(int i=0; i<N; i++){
            if(str.charAt(i)=='R'){
                r++;
            }else{
                b++;
            }
        }
        if(r>b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972
// 1_1_A
#include<stdio.h>

void OutPut(int numbers[], int length){
    int i;
    for(i = 0; i < length - 1; i++){
        printf("%d ", numbers[i]);
    }
    printf("%d\n", numbers[length - 1]);

    return;
}

void InsertionSort(int numbers[], int length){
    int i, j, v;
    for(i = 1; i < length; i++){
        v = numbers[i];
        j = i - 1;
        while(j >= 0 && numbers[j] > v){
            numbers[j + 1] = numbers[j];
            j--;
        }
        numbers[j + 1] = v;
        OutPut(numbers, length);
    }

    return;
}

int main()
{
    int i, length;
    int numbers[100];

    scanf("%d", &length);
    for(i = 0; i < length; i++){
        scanf("%d", &numbers[i]);
    }

    OutPut(numbers, length);
    InsertionSort(numbers, length);

    return 0;
}

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

#define rep(var, start, end)  for(int var = start; var <= end; ++var)
#define drep(var, start, end) for(int var = start; var >= end; --var)

typedef long long ll;

using namespace std;

int main() {

    string S;

    cin >> S;

    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0295
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(RArInt().Aggregate((x, y) => x * y));
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 20344
require 'set'
require 'pp'

N, M = gets.chomp!.split(" ").map(&:to_i)

values = SortedSet.new
counter = {
    # value => count
}

N.times do |i|
    a, b = gets.chomp!.split(" ").map(&:to_i)
    counter[a] = (counter[a] || 0) + b
    values << a
end

buy = 0
sum = 0
values.each do |val|
    if buy + counter[val] >= M
        sum += (M - buy) * val
        break
    end

    sum += val * counter[val]
    buy += counter[val] 
end

puts sum


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int k,a,b;
void solve(){
	cin >> k >> a >> b;
	
	for(int i = 0; i <= b; i+=k){
		if(i >= a){
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	int n = sc.nextInt();
            int sum = 0;
            if(n > 50) System.out.println(0);
            else{
                for(int i = 0; i <= 9; i++){
                    for(int j = 0; j <= 9; j++){
                        for(int k = 0; k <= 9; k++){
                            for(int l = 0; l <= 9; l++){
                                if(i+j+k+l == n) sum++;
                            }
                        }
                    }
                }
                System.out.println(sum);
            }
        }
    }
}

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

long long gcd(long long a, long long b){
    if(a < b) swap(a, b);
    long long r = a % b;
    return (r > 0 ? gcd(b, r) : b);
}

long long lcm(long long a, long long b){
    return a / gcd(a, b) * b;
}

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

    long long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    
    long long l = lcm(n, m);
    long long ll = lcm(l / n, l / m);

    string a = "", b = "";
    for(long long i = 0; i < l; i += l / n){
        if(i % ll == 0) a += s[i / (l / n)];
    }
    for(long long i = 0; i < l; i += l / m){
        if(i % ll == 0) b += t[i / (l / m)];
    }
    
    cout << (a == b ? l : -1) << endl;

    return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn next_pos(cs: &Vec<Vec<usize>>, c: usize, pos: usize) -> (usize, bool) {
  let p = match cs[c].binary_search(&pos) {
    Ok(p) => p,
    Err(p) => p,
  };
  if p == cs[c].len() {
    (cs[c][0], true)
  } else {
    (cs[c][p], false)
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    s: chars,
    t: chars,
  }
  let mut cs = vec![vec![]; 26];
  for (i, &c) in s.iter().enumerate() {
    let c = c as usize - 'a' as usize;
    cs[c].push(i);
  }
  for &c in &t {
    let c = c as usize - 'a' as usize;
    if cs[c].is_empty() {
      puts!("-1\n");
      return;
    }
  }
  let mut pos = 0usize;
  for i in 0 .. t.len() {
    let c = t[i] as usize - 'a' as usize;
    let (p, wrap) = next_pos(&cs, c, pos % s.len());
    if wrap {
      pos = (pos / s.len() + 1) * s.len() + p + 1;
    } else {
      pos = pos / s.len() * s.len() + p + 1;
    }
  }

  puts!("{}\n", pos);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    long long int num, ans = 0;
    cin >> num;
    for (long long int i = 1; i * i <= num; i++) {
        if (num % i != 0)
            continue;
        if (i > 1 && num % (i - 1) != 0) {
            long long int cntAns = i - 1;
            if (num / cntAns == num % cntAns)
                ans += cntAns;
        }
        if (i * i != num && num / i > 1 && num % (num / i - 1) != 0) {
            long long int cntAns = num / i - 1;
            if (num / cntAns == num % cntAns)
                ans += cntAns;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main(){
        long long n,sum1=0,sum2=0,ans1=0,ans2=0,a;
        cin >> n;
        for(int i=0;i<n;i++){
            cin >> a;
            sum1+=a;
            if(i%2==0 and sum1<=0){
                ans1+=abs(sum1)+1;
                sum1=1;
            }
            if(i%2==1 and sum1>=0){
                ans1+=abs(sum1)+1;
                sum1=-1;
            }
            sum2+=a;
            if(i%2==0 and sum2>=0){
                ans2+=abs(sum2)+1;            
                sum2=-1;
            }
            if(i%2==1 and sum2<=0){
                ans2+=abs(sum2)+1;
                sum2=1;
            }
        }
        cout << min(ans1,ans2) << endl;
        return 0;
    }

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x:x[0])
X = []
L = []
for l in A:
    X.append(l[0])
    L.append(l[1])

pl = X[0] + L[0]
k = 0
for i in range(1, N):
    pr = X[i] - L[i]
    if pl > pr:
        k += 1
        pl = min(pl, X[i] + L[i])
    else:
        pl = X[i] + L[i]


print(N - k)

Measured memory_bytes: 30148
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 2005

using namespace std;

vector<ll> g[max_n];
ll n, x, y;

void solve()
{
	cin >> n >> x >> y;
	for (int i = 1; i < n; ++i)
	{
		g[i].push_back(i + 1);
		g[i + 1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	vector<ll> ans(n + 1, 0);
	for (int i = 1; i <= n; ++i)
	{
		queue<ll> q;
		vector<ll> d(n + 1, 0LL);
		q.push(i);
		bool vis[n + 1];
		memset(vis, false, sizeof vis);
		vis[i] = true;
		while (!q.empty())
		{
			ll cur = q.front();
			q.pop();
			for (ll c : g[cur])
			{
				if (!vis[c])
				{
					d[c] = d[cur] + 1LL;
					q.push(c);
					vis[c] = true;
				}
			}
		}
		for (int i = 0; i < n + 1; ++i)
		{
			ans[d[i]]++;
		}
	}
	for (int i = 1; i <= n - 1; ++i)
	{
		cout << ans[i] / 2 << endl;
	}
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3672
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	string s;
	cin >> n >> s;
	map<char, int> m;
	int ans = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		m[s[i]] ++;
		map<char, int> tmp;
		for (int j = i + 1; j < s.size(); ++j)
		{
			tmp[s[j]] ++;
		}
		int t = 0;
		for (auto i : m)
		{
			if (m[i.first] && tmp[i.first])
			{
				t++;
			}
		}
		ans = max(ans, t);
	}
	cout << ans;
	sp;
}

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

int main(void) {
    int N;cin>>N;
    int sum = 0;
    int org_N = N;
    while (N > 0) {
        sum += N % 10;
        N /= 10;
    }
    if (org_N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define Di 3.1415926
#include<math.h>
#include<string>
#include<set>
#define INF 0x3f3f3f3f
using namespace std;
ll  gcd(ll a,ll b)
{
    return a%b? gcd(b,a%b):b;
}
int a[200];
int s[100];
 bool judge(int i)
 {
     while(i)
     {
         int t=i%10;
            if(s[t])
            {
                return false;
            }
            i/=10;
     }
     return true;
 }
int main()
{
     int m,i;
     int n;
     cin>>m>>n;
     for(i=0;i<n;i++)
     {
         cin>>a[i];
          s[a[i]]=1;

     }
     for(i=m;;i++)
     {
          if(judge(i))
          {
            cout<<i<<endl;
              break;
          }
     }


 return 0;
}


Measured memory_bytes: 504
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
	int target,s=100,year=0;
	cin >> target ;
	while (s < target ){
		s += s/100;
		year++;
	}
	cout << year << endl ; 
}

signed main() {
	solve();
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
int main()
{
	int debt = 100000;
	int n;
	std::cin >> n;
	for(int i = 0; i < n; i++)
	{
		debt *= 1.05;
		if(debt % 1000 > 0)
		{
			debt -= debt % 1000;
			debt += 1000;
		}
	}
	std::cout << debt << std::endl;
	return 0;
}


Measured memory_bytes: 3036
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int x,n;
cin>>x>>n;
set<int>s;
for(int i=0;i<n;i++)
  {
  	int a;
  	cin>>a;
  	s.insert(a);
  }
  int index;
  int mini=INT_MAX;
  for(int i=x;i>=-150;i--)
     {
     	if(s.count(i)==0)
     	  {
     	  	if(mini>abs(x-i))
     	  	  {
     	  	  	mini=abs(x-i);
     	  	  	index=i;
     	  	  	break;
				 }
		   }
	 }
	  for(int i=x;i<=150;i++)
     {
     	if(s.count(i)==0)
     	  {
     	  	if(mini>abs(x-i))
     	  	  {
     	  	  	mini=abs(x-i);
     	  	  	index=i;
     	  	  	break;
				 }
		   }
	 }

	 cout<<index<<endl;
	return 0;
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

int x1,x2,x3,x4,x5;
cin>>x1>>x2>>x3>>x4>>x5;

if(x1==0){
cout<<1<<endl;
}else if(x2==0){
cout<<2<<endl;
}else if(x3==0){
    cout<<3<<endl;
}else if(x4==0){
    cout<<4<<endl;
}else {
    cout<<5<<endl;
}


}


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

using namespace std;

int main(){
  string S, T;
  int A, B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(U==S) cout << A-1 << " " << B << endl;
  if(U==T) cout << A << " " << B-1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var DAY = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var line;
while (line = lines.shift()) {
	var arr = line.split(' ').map(function(n){return +n;});
	if (arr[0] == 0 && arr[1] == 0) {
		break;
	}

	var d = new Date(2004, arr[0] - 1, arr[1]);
	console.log(DAY[d.getDay()]);
}

Measured memory_bytes: 7592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int MOD = 1000000007;

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

  map<int,int> mp;
  for(int i=1;i<=N;i++){
    int itmp = i;
    int j = 2;
    while(itmp > 1){
      if(itmp%j==0){
        mp[j]++;
        itmp /= j;
      } else {
        j++;
      }
    }
  }

  /*for(auto it = mp.begin() ; it!=mp.end() ; it++){
    cout << it->first << " " << it->second << endl;
  }*/

  ll ans = 1;
  for(auto it=mp.begin() ; it!=mp.end() ; it++){
    ans *= (it->second + 1);
    ans %= MOD;
  }

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

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

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

	string c;
	cin >> c;

	int ans = count(c.begin(), c.end(), 'W');
	reverse(c.begin(), c.end());
	int tmp=ans;
	for(int i=0; i<tmp;i++){
		if(c.at(i) == 'W') ans--;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3756
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,m ,a[N] ;
long long add[N] ,extra[N] ,ad ,cur ,ans ;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
        if(!i) continue ;
        if(a[i]>=a[i-1]) ans += a[i] - a[i-1] ;
        else ans += a[i]+m - a[i-1] ;
        if(a[i]-a[i-1]>1){
            ++add[a[i-1]+2] ;
            extra[a[i]+1] -= a[i] - a[i-1] - 1;
            --add[a[i]+1] ;
        }
        else if(a[i]<a[i-1]){
            if(a[i-1]<=m-2){
                ++add[a[i-1]+2] ;
                ++add[1] ;
                extra[1] += m - a[i-1] - 1 ;
            }
            else if(a[i-1]==m-1) ++add[1] ;
            else ++add[2] ;
            extra[a[i]+1] -= a[i]+m - a[i-1] - 1 ;
            --add[a[i]+1] ;
        }
    }
    long long mx = 0 ;
    for(int i=1;i<=m;++i){
        ad += add[i] ;
        cur += ad + extra[i] ;
        mx = max(mx ,cur);
    }
    printf("%lld",ans-mx);
    return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

string s1,s2;
int main(void) {
    int i,ans=0;
    cin >> s1 >> s2;
    for (i = 0; i < 3; i++) {
        if (s1[i] == s2[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define Fors(n) for(int i=1;i<=n;i++)
#define For(n) for(i=0;i<n;i++)
#define ll long long
#define vint(s) vector<int> s
#define pb(x)  push_back(x)
#define mpair(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll x=0,y=0,s=0,n=0,i=0;

int main(){
    IOS;
    cin >> x >> y;
    
    n = x+y ;
    s = x-y;
    i = x*y;
    //cout << s <<" :: "<< i << ":: "<< n<< endl;
    cout << max(i, max(n,s));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

template <typename T>
struct Dinic{
	struct edge{
		int to;
		T weight;
		int ind;
	};
	vector<vector<edge>> E;
	T inf;
	
	Dinic(vector<vector<pair<int,T>>> &e,T iv = 1000000001){
		inf = iv;
		E.resize(e.size(),vector<edge>());
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				edge t = {e[i][j].first,e[i][j].second,0};
				E[i].push_back(t);
			}
		}
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				E[i][j].ind = E[E[i][j].to].size();
				edge t = {i,0,j};
				E[E[i][j].to].push_back(t);
			}
		}
	}
	
	T maximum_flow(int s,int t){
		
		T ret = 0;
		
		while(true){
			vector<int> dis(E.size(),-1);
			queue<int> Q;
			Q.push(s);
			dis[s] = 0;
			while(Q.size()!=0){
				int u = Q.front();
				Q.pop();
				for(int i=0;i<E[u].size();i++){
					if(E[u][i].weight<=0)continue;
					int v = E[u][i].to;
					if(dis[v]!=-1)continue;
					dis[v] = dis[u]+1;
					Q.push(v);
				}
			}
			if(dis[t]==-1)break;
			
			vector<int> it(E.size(),0);
			
			while(true){
				T F = dfs(s,t,inf,it,dis);
				if(F==0)break;
				ret+=F;
			}
		}
		return ret;
	}
	
	T dfs(int now,int t,T f,vector<int> &it,vector<int> &dis){
		if(now==t)return f;
		
		for(int &i=it[now];i<E[now].size();i++){
			int to = E[now][i].to;
			T weight = E[now][i].weight;
			if(weight<=0||dis[now]+1!=dis[to]){
				continue;
			}
			T F = dfs(to,t,min(f,weight),it,dis);
			if(F!=0){
				E[now][i].weight-=F;
				E[E[now][i].to][E[now][i].ind].weight+=F;
				return F;
			}
		}
		return 0;
	}
	
};

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> A(N,vector<int>(M));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin>>A[i][j];
			A[i][j]--;
		}
	}
	
	vector<vector<int>> B(N,vector<int>());
	
	for(int i=0;i<M;i++){
		vector<vector<pair<int,int>>> E(2*N+2,vector<pair<int,int>>());
		int S = 2*N;
		int T = S+1;
		
		for(int j=0;j<N;j++){
			E[S].emplace_back(j,1);
			E[N+j].emplace_back(T,1);
			for(int k=0;k<A[j].size();k++){
				int a = j;
				int b = A[j][k]/M;
				E[a].emplace_back(N+b,1);
			}
		}
		
		Dinic<int> D(E);
		D.maximum_flow(S,T);
		vector<int> era(N);
		for(int j=0;j<N;j++){
			for(int k=0;k<E[j].size();k++){
				if(D.E[j][k].weight==0){
					era[j] = D.E[j][k].to - N;
					break;
				}
			}
		}
		
		for(int j=0;j<N;j++){
			
			for(int k=0;k<A[j].size();k++){
				if(A[j][k]/M==era[j]){
					B[j].push_back(A[j][k]);
					A[j].erase(A[j].begin()+k);
					break;
				}
			}
		}
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(j!=0)cout<<' ';
			cout<<B[i][j]+1;
		}
		cout<<endl;
	}
	
	for(int i=0;i<M;i++){
		vector<int> t(N);
		for(int j=0;j<N;j++)t[j] = B[j][i];
		sort(t.begin(),t.end());
		for(int j=0;j<N;j++)B[j][i] = t[j];
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(j!=0)cout<<' ';
			cout<<B[i][j]+1;
		}
		cout<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
#define rep(i, n) for(i = 0; i < (n); i++)
#define rrep(i, n) for(i = (n - 1); i >= 0; i--)
using namespace std;

bool vis[200005]={0};
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
    return 0;
}
void solve1()
{
    string str,str2;
    cin>>str>>str2;int ans=0;
    for(int i=0;i<str.length();i++)
    {
        if(str[i]!=str2[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3924
# B - Problem Set
def is_create(dic_d, t):
	for ti in t:
		if not ti in dic_d.keys():
			return False
		elif dic[ti] == 0:
			return False
		else:
			dic[ti] -= 1	
	
	return True


n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

if is_create(dic, t):
	print('YES')
else:
	print('NO')

Measured memory_bytes: 41816
#include "bits/stdc++.h"
#define int long long

using namespace std;

const int MOD = 1000000007;
int modpow(int a, int p) {
    if(p == 0) {
        return 1;
    }
    int t = modpow(a, p / 2);
    if(p % 2 == 0) {
        return t * t % MOD;
    }
    return t * t % MOD * a % MOD;
}
int modinv(int a) { return modpow(a, MOD - 2); }

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)]; }
};

signed main() {
    string S, f, b;
    cin >> S;
    int Q;
    cin >> Q;
    int pf = 0; // 0: to f, 1: to b
    for(auto i = 0ll; i < Q; i++) {
        int t;
        cin >> t;
        if(t == 1) {
            pf = 1 - pf;
        } else {
            int F;
            string C;
            cin >> F >> C;
            if(pf == F - 1) {
                f.push_back(C[0]);
            } else {
                b.push_back(C[0]);
            }
        }
    }
    if(pf == 0) {
        reverse(f.begin(), f.end());
        cout << f << S << b << endl;
    } else {
        reverse(S.begin(), S.end());
        reverse(b.begin(), b.end());
        cout << b << S << f << endl;
    }

    return 0;
}

Measured memory_bytes: 1088
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int dh[4] = {1,0,-1,0}, dw[4] = {0,1,0,-1};

int main(){
	int w,h;
	while(scanf("%d%d",&w,&h),w||h){
		int yoko[110][110],tate[110][110], cnt[110][110];
		rep(i,110) rep(j,110) cnt[i][j] = INF;
		cnt[0][0] = 1;
		rep(i,2*h-1){
			if(i%2==0){
				rep(j,w-1) scanf("%d", &tate[i/2][j]);
			} else{
				rep(j,w) scanf("%d", &yoko[i/2][j]);
			}
		}
		queue<P> que;
		que.push(P(0,0));
		while(true){
			if(que.size() == 0){
				printf("0\n");
				break;
			}
			P p = que.front(); que.pop();
			if(p.fi == h-1 && p.sec == w-1){
				printf("%d\n", cnt[h-1][w-1]);
				break;
			}
			//cout << p.fi << " " << p.sec << endl;
			if(p.fi != 0){
				if(yoko[p.fi-1][p.sec] == 0 && cnt[p.fi-1][p.sec] > cnt[p.fi][p.sec]+1){
					que.push(P(p.fi-1,p.sec));
					cnt[p.fi-1][p.sec] = cnt[p.fi][p.sec]+1;
				}
			}
			if(p.fi != h-1){
				if(yoko[p.fi][p.sec] == 0 && cnt[p.fi+1][p.sec] > cnt[p.fi][p.sec]+1){
					que.push(P(p.fi+1,p.sec));
					cnt[p.fi+1][p.sec] = cnt[p.fi][p.sec]+1;
				}
			}
			if(p.sec != 0){
				if(tate[p.fi][p.sec-1] == 0 && cnt[p.fi][p.sec-1] > cnt[p.fi][p.sec]+1){
					que.push(P(p.fi,p.sec-1));
					cnt[p.fi][p.sec-1] = cnt[p.fi][p.sec]+1;
				}
			}
			if(p.sec != w-1){
				if(tate[p.fi][p.sec] == 0 && cnt[p.fi][p.sec+1] > cnt[p.fi][p.sec]+1){
					que.push(P(p.fi,p.sec+1));
					cnt[p.fi][p.sec+1] = cnt[p.fi][p.sec]+1;
				}
			}
		}
	}
}

Measured memory_bytes: 1292
"""

縦横の最大の組を抽出
組の数の積がMより大きかったら和を出せばいい
それ以外は全探索

"""

from sys import stdin
import sys
H,W,M = map(int,stdin.readline().split())

Hdic = {}
Wdic = {}
HW = {}

for i in range(M):

    h,w = map(int,stdin.readline().split())
    HW[(h,w)] = i

    if h not in Hdic:
        Hdic[h] = []
    Hdic[h].append(w)

    if w not in Wdic:
        Wdic[w] = []
    Wdic[w].append(h)

hmax = 0
hmlis = []

for i in Hdic:
    if len(Hdic[i]) > hmax:
        hmax = len(Hdic[i])
        hmlis = []

    if len(Hdic[i]) == hmax:
        hmlis.append(i)

wmax = 0
wmlis = []

for i in Wdic:
    if len(Wdic[i]) > wmax:
        wmax = len(Wdic[i])
        wmlis = []

    if len(Wdic[i]) == wmax:
        wmlis.append(i)

if len(hmlis) * len(wmlis) > M:
    print (hmax + wmax)
else:

    for h in hmlis:
        for w in wmlis:
            if (h,w) not in HW:
                print (hmax + wmax)
                sys.exit()

    print (hmax + wmax - 1)


Measured memory_bytes: 278016
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let mut vec: Vec<char> = Vec::new();
    vec.push(s[0]);
    for i in 1..s.len() {
        if vec[vec.len() - 1] != s[i] {
            vec.push(s[i]);
        }
    }
    println!("{}", vec.len());
}


Measured memory_bytes: 4352
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
D = [0]*N
for i in range(N):
    a,b = MI()
    if a == b:
        D[i] = 1

for i in range(N-2):
    if D[i] == D[i+1] == D[i+2] == 1:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 62064