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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 10;
const int oo = 1e18;

int n, k;
vector<ii> vt, type;
set<ii> st, tmp;

bool cmp(const ii &x, const ii &y)    {
    return x.fi > y.fi;
}

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    cin >> n >> k;
    FOR(i, 1, n)    {
        int x, y; cin >> x >> y;
        vt.pb({x, y});
    }
    sort(vt.begin(), vt.end());
    for(int i = vt.size() - 1; i >= 0; --i) {
        if(i == vt.size() - 1 || vt[i].fi != vt[i + 1].fi)
            type.pb({vt[i].se, i});
        st.insert({vt[i].se, i});
    }

    int cnt = 0, ans = 0, sum = 0;
    while(k > tmp.size()) {
        auto it = st.end(); it --;
        tmp.insert(*it); sum += (*it).fi;
        st.erase(it);
    }

    sort(type.begin(), type.end(), cmp); ans = sum;

    FOR(i, 1, min(k, (int)type.size()))  {
        auto cur = type[i - 1];
        if(tmp.find(cur) != tmp.end())  {
            tmp.erase(tmp.find(cur));
        } else {
            sum += cur.fi;
            auto id = tmp.begin();
            sum -= (*id).fi;
            tmp.erase(id);
        }

        cnt ++;
        ans = max(ans, sum + cnt * cnt);
    }
    return cout << ans, 0;
}


Measured memory_bytes: 11120
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		String S = sc.next();
		String T = sc.next();
		char[] enc = new char['z' - 'a' + 1];
		char[] dec = new char['z' - 'a' + 1];
		char[] sa = S.toCharArray();
		char[] ta = T.toCharArray();
		for (int i = 0; i < sa.length; i++) {
			char s = sa[i];
			char t = ta[i];
			char es = enc[s - 'a'];
			char dt = dec[t - 'a'];
			if (es == 0 && dt == 0) {
				enc[s - 'a'] = t;
				dec[t - 'a'] = s;
			} else if (es != t || dt != s) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 28256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, K,ans=1;
    
    cin>>N>>K;
    
    for(int i=0;i<N;i++)
    {
        if(ans*2>=ans+K)
        {
            ans += K;
        }
        else ans *=2;
        
    }
    
    cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());
    rep(i, n) cout << vec[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588
# include<bits/stdc++.h>
# define LL long long
using namespace std;
const int M = 400005 ;
int n;
char s[M] ;
int main() {
	scanf("%s",s+1),n=strlen(s+1);
	LL ans=0;
	for(int i=1,L=1;i<=n;++i)
	  if(s[n-i+1]=='B') ans+=i-L,++L;
	printf("%lld",ans) ;
	return 0;
}


Measured memory_bytes: 384
from heapq import heappop, heappush
n,m = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
dist = [float("inf")]*n
seen = [False]*n
ans = [0]*n
def f(s):
    PQ = [(0,s)]
    dist[s] = 0
    while PQ:
        md,u = heappop(PQ)
        seen[u] = True
        if dist[u] < md: continue
        for v in G[u]:
            if seen[v]: continue
            if dist[v] > md+1:
                dist[v] = md+1
                heappush(PQ,(dist[v],v))
                ans[v] = u+1
f(0)
print("Yes")
for i in range(1,n): print(ans[i])

Measured memory_bytes: 40368
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;

import java.io.*;

public class Main {
    static int MAX = 4000000;
    
    static int[] A = new int[MAX+10];
    static int F;
    static void maxHeap(int i) {
        int l, r, huge;
        r = 2 * i + 1;
        l = 2 * i;
        
        if(l <= F && A[l] > A[i]) huge = l;
        else huge = i;
        if(r <= F && A[r] > A[huge]) huge = r;

        if(huge != i) {
            int temp = A[i];
            A[i] = A[huge];
            A[huge] = temp;
            maxHeap(huge);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        count(sc);
    }
 public static void count(Scanner s){
  F = s.nextInt();
        for(int i = 1; i <= F; ++i) A[i] = s.nextInt();

        for(int i = F / 2; i >= 1; i--) {
        maxHeap(i);
}
        for(int K = 1; K <= F; K++) {
            System.out.print(" " + A[K]);
        }
        System.out.println();
    }
 
 
 }


Measured memory_bytes: 194100
#include <iostream>
#include <queue>
#include <string>
#include <map>

using namespace std;

int d[] = {1, -1,  4, -4};

bool check(int space)
{
    return (space >= 0 && space < 8);
}


int main()
{
    map<string, int> m;
    queue<string> que;

    que.push("01234567");
    while (!que.empty()) {
        string now = que.front();
        que.pop();

        int space = now.find("0");
        for (int i = 0; i < 4; i++) {
            if (!check(space + d[i]))
                continue;
            if (space % 4 == 0 && i == 1)
                continue;
            if (space % 4 == 3 && i == 0)
                continue;
            string tmp = now;
            swap(tmp[space], tmp[space + d[i]]);
            if (m.count(tmp) == 0) {
                que.push(tmp);
                m[tmp] = m[now] + 1;
            }
        }
    }

    char c;
    while (cin >> c) {
        string panel;

        panel.push_back(c);
        for (int i = 1; i < 8; i++) {
            cin >> c;
            panel.push_back(c);
        }
        cout << m[panel] << endl;
    }

    return 0;
}

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

int main() {
	// 入力
	int a, b, c;
	cin >> a >> b >> c;

	set<int> abc;
	abc.insert(a);
	abc.insert(b);
	abc.insert(c);

	int ans = abc.size();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;
int main()
{
    ll L, R;
    cin >> L >> R;

    if (R - L > 3000) {
        cout  << 0 << endl;
    } else {
        ll res = 2018;
        for (ll i = L; i < R; ++i) {
            for (ll j = i+1; j <= R; ++j) {
                res = min(res, (i * j) % 2019);
            }
        }
        cout << res  << endl;
    }
}

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


int main(){
  long long A;
  string S;
  cin >> A >> S;
  int B = stoi(S.substr(0, S.size()-3) + S.substr(S.size()-2));

  cout << (A * B) / 100 << endl;
  return 0;
}


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

using namespace std;
typedef pair<char, char> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> Vec;
		for(int i = 0; i < n; ++i)
		{
			P p;
			cin >> p.first >> p.second;
			Vec.push_back(p);
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			char c;
			cin >> c;
			bool flag = false;
			for(int j = 0; j < Vec.size(); ++j)
			{
				if(Vec[j].first == c)
				{
					flag = true;
					cout << Vec[j].second;
				}
			}
			if(!flag)
			{
				cout << c;
			}
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1192
url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n+1, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            b[i] = 1
            balls[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k[0], end=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 99700
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner scan = new Scanner(System.in);
        String line  = scan.nextLine();
        
        for(int i = 0; i < line.length(); ++i){
            if(Character.isLowerCase(line.charAt(i))){
                System.out.print(Character.toUpperCase(line.charAt(i)));
            }
            
            else if(Character.isUpperCase(line.charAt(i))){
                System.out.print(Character.toLowerCase(line.charAt(i)));
            }
            
            else {
                System.out.print(line.charAt(i));
            }
        }
        
        System.out.println();
	}
}

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

int main() {
  int x; cin>>x;
  int a=x/500;
  int b=(x%500)/5;
  ll res=1000*a+5*b;
  cout<<res<<endl;
}


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

int main(){
	string s,s2="";
	cin >> s;
	
	for(int i=s.size()-1;i>=0;i--){
		if(i<0) break;
		if(s[i]=='r'){
			if(s[i-5]=='e'){
				s2 = "eraser" + s2;
				i-=4;
			}
			else if(s[i-6]=='d'){
				s2 = "dreamer" + s2;
				i-=5;
			}
		}
		else if(s[i]=='m'){
			if(s[i-4]=='d'){
				s2 = "dream" + s2;
				i-=3;
			}
		}
		else if(s[i]=='e'){
			if(s[i-4]=='e'){
				s2 = "erase" + s2;
				i-=3;
			}
		}
	}
	
	cout << (s==s2?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    ll s,c;cin>>s>>c;
    ll fst=min(s,c/2);
    ll rest=c-fst*2;
    if(rest>3){
        fst+=rest/4;
    }
    cout<<fst<<endl;

}

Measured memory_bytes: 3624
/*
  Fuad Ashraful Mehmet
  University of Asia Pacific,Bangladesh
  Date:28 th March 2020
  TODO:
  https://codeforces.com/problemset/problem/482/B
  uva: 11695 Flight Planning
  https://onlinejudge.org/external/116/11621.pdf
*/
#include<bits/stdc++.h>
#define all(o) (o).begin(),(o).end()
using namespace std;
void scan(int &x)
{
  scanf("%d",&x);
}
const int N=2e5+5;
typedef long long ll;
void Dbug();

ll A[N],cum[N];
void JoyBangla()
{
   
   ll ans=1e18;

   ll n,k;
   cin>>k>>n;

   for(int i=1;i<=n;++i)
   {
     cin>>A[i];
   }
    ll total=0;
   for(int i=2;i<=n;++i)
   {
     total+=abs(A[i]-A[i-1]);
   }

   total+=abs((k-A[n])+A[1]);

   for(int i=2;i<=n;++i)
   {
     ans=min({ans,total-abs(A[i]-A[i-1])});
   }

   ans=min({ans,total-abs((k-A[n])+A[1])});


   cout<<ans<<endl;


  
 
}

signed main()
{
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
 
 JoyBangla();
 /*
   ll x;
   cin>>x;

   ll ans=0;

   ll div=x/500;
   x=x%500;

   ans=div*1000;

   div=x/5;
   ans+=div*5;
   cout<<ans<<endl;


   */
 // Dbug();
  return 0;
}

void Dbug()
{
 
}

Measured memory_bytes: 1792
#include<cstdio>
#include<map>
#include<queue>
#include<iostream>

using namespace std;

long long k,a[55];

int main()
{
	cin >> k;
	for(int N = 50;N > 1;N--)
	{
		long long A=k/N,B=k%N;
		//if(A>=B)
		{
			for(int i = 1;i <= N;i++)
				a[i]=N-1+A;
			for(int i = 1;i <= B;i++)
			{
				a[i]+=N;
				for(int j = 1;j <= N;j++)
					if(i!=j)a[j]--;
			}
			cout << N << endl;
			for(int i = 1;i <= N;i++)
				cout << a[i] << " \n"[i==N];
			return 0;
		}
		//if(k<N)
		//{
		//	return 0;
		//}
	}
	return 0;
}

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

int main() {
    string s; cin >> s;
    deque<char> S(s.size());
    copy(s.begin(), s.end(), S.begin());
    int Q; cin >> Q;
    int r_cnt = 0;
    for (int i = 0; i < Q; i++)
    {
        int a; cin >> a;
        if(a==1) r_cnt++;
        else{
            int f; char c;
            cin >> f >> c;
            if((f==1 && r_cnt%2==0) || (f==2 && r_cnt%2==1)) S.push_front(c);
            else S.push_back(c); 
        }
    }
    s.resize(S.size());
    copy(S.begin(), S.end(), s.begin());
    if(r_cnt%2==1) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 1280
#include<stdio.h>



int water( int w ,int limit )
{
	return w - limit ;
}



int main()
{
	int kale  ;


	int w ;
	while( scanf( "%d" ,&w ) )
	{
		if( w < 0 )
		{
			return 0 ;
		}


		kale = 4280 - 1150 ;


		if( w > 30 )
		{
			kale -= 160 * water( w ,30 ) ;


			w = 30 ;
		}


		if( w > 20 )
		{
			kale -= 140 * water( w ,20 ) ;


			w = 20 ;
		}


		if( w > 10 )
		{
			kale -= 125 * water( w ,10 ) ;
		}


		printf( "%d\n" ,kale ) ;
	}
}

Measured memory_bytes: 600
#https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
# -*- coding: utf-8 -*-
import math
from decimal import *
a,b,c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() <  Decimal(c).sqrt():
  print("Yes")
else:
  print("No")

Measured memory_bytes: 60012
N = int(input())
A = input().split()
A = list(set(A))

for i in range(len(A)):
 A[i] = int(A[i])

while(1):
 if(len(A) == 1):
  ans = A[0]
  break 
 A = list(set(A))
 A.sort()
 if(A[0] == 0):
  A.pop(0)
 min_monster = A[0]
 for i in range(len(A)):
   if(i != 0):
      tmp = A[i]//min_monster
      A[i] -= min_monster*tmp

print(ans)

Measured memory_bytes: 18184
import * as fs from 'fs';

//in
// 3
// 1
//out
// 2
function main(inp: string) {

    const [a, b]: number[] = inp.split('\n').map(Number);
    // 1 2  3
    // 2 1  3
    // 1 3  2
    // 3 1  2
    // 2 3  1
    // 3 2  1
    console.log(6 - (a + b));
}

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#include<stdio.h>
typedef struct D{int f,e;char n[20];}D;
int N,Q,i,q;
D Y[1005];
int main()
{
	for(;scanf("%d%d",&N,&Q),N;)
	{
		for(i=0;i<N;Y[i].f=Y[i].e-Y[i].f+1,i++)
			scanf("%s%d%d",Y[i].n,&Y[i].f,&Y[i].e);
		for(;Q--;)
		{
			scanf("%d",&q);
			for(i=0;i<N;i++)
				if(Y[i].f<=q&&q<=Y[i].e)
				{
					printf("%s %d\n",Y[i].n,q-Y[i].f+1);
					break;
				}
			if(i==N)
				puts("Unknown");
		}
	}
	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
 
#define ll                 long long
#define ull                unsigned long long
#define pii                pair<int, int>
#define pll                pair<ll, ll>
#define mp                 make_pair
#define ff                 first
#define ss                 second
#define sz(x)              (int) x.size()
#define all(v)             v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
}
 
template <typename T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}
 
const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;

std::vector<pii> g[N];

int ans[N];

void dfs(int u, int p, int c) {
   ans[u] = c;
   for(auto xx : g[u]) {
   	 int v = xx.ff, w = xx.ss;
   	 if(p == v) continue;
   	 dfs(v, u, c ^ (w & 1));
   }
}

int solve() {
   int n; Int(n);
   for(int i = 1; i < n; i++) {
   	int u, v, w; Int(u, v, w);
   	g[u].push_back({v, w});
   	g[v].push_back({u, w});
   }
   dfs(1, 1, 0);
   for(int i = 1; i <= n; i++) {
   	printf("%d\n", ans[i]);
   }
	return 0;
}
 
int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int test = 1, tc = 0;
	//Int(test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}


Measured memory_bytes: 10752
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<climits>
#include<cassert>
#include<unordered_map>

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

using namespace std;

string max(string a,string b) {
  if( a.size() == b.size() ) {
    rep(i,(int)a.size()) {
      if( a[i] == b[i] ) continue;
      if( a[i] >  b[i] ) return a;
      else               return b;
    }
    return a;
  } else if( a.size() > b.size() ) {
    return a;
  } else {
    return b;
  }
}

unordered_map<string,string> memo;
string dfs(string s) {
  if( memo.count(s) ) {
    return memo[s];
  }
  bool fin = true;
  rep(i,(int)s.size()) {
    if( s[i] == 'L' || s[i] == 'R' || s[i] == '(' || s[i] == ')' || s[i] == ',' ) {
      fin = false;
      break;
    }
  }
  if( fin ) {
    rep(i,(int)s.size()) {
      if( s[i] == '?' ) s[i] = '9';
    }
    if( s != "0" && s[0] == '0' ) return "";
    return s;
  }
  if( (int)s.size() < 6 ) return "";
  if( !(s[1] == '('||s[1] =='?') || !(s[(int)s.size()-1]==')'||s[(int)s.size()-1]=='?') ) return "";
  string maxi = "";
  if( s[0] == 'L' || s[0] == 'R' || s[0] == '?' ) {
    REP(i,2,(int)s.size()-1) {
      if( s[i] == '?' || s[i] == ',' ) {
	string L = "", R = "";
	REP(j,2,i) L += s[j];
	REP(j,i+1,(int)s.size()-1) R+= s[j];
	string new_L = dfs(L);
	if( new_L.empty() ) continue;
	string new_R = dfs(R);
	if( new_R.empty() ) continue;
	if( s[0] == 'L' || s[0] == 'R' ) {
	  maxi = max(maxi,((s[0]=='L')?new_L:new_R));
	} else {
	  maxi = max(maxi,max(new_L,new_R));
	}
      }
    }
  }
  return memo[s] = maxi;
}

void compute(string s) {
  string answer = dfs(s);
  if( answer.empty() ) puts("invalid");
  else cout << answer << endl;
}

int main() {
  string s;
  cin >> s;
  compute(s);
  return 0;
}

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

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

    for(int i=0; i<s.length(); i++){
        int x = s[i] - 'A';
        x = (x + n) % 26;
        s[i] = 'A' + x;
    }

    cout << s << endl;  
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    ll n,m;
    cin>>n>>m;
    priority_queue<ll> q;
    for(ll i=0;i<n;++i)
    {
        ll x;
        cin>>x;
        q.push(x);
    }
    while(m--)
    {
        ll x=q.top();
        q.pop();
        q.push(x/2);
    }
    ll ans=0;
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 1400
using System;

namespace abc076_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string ret = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
            for (int i = 0; i <= s.Length - t.Length; i++)
            {
                bool flag = true;
                char[] now = s.ToCharArray();
                for (int j = 0; j < t.Length; j++)
                {
                    if (s[i + j] != '?' && s[i + j] != t[j])
                    {
                        flag = false;
                    }
                    else
                    {
                        now[i + j] = t[j];
                    }
                }
                string x = null;
                for (int j = 0; j < now.Length; j++)
                {
                    x += now[j];
                }
                if (flag)
                {
                    ret = ret.CompareTo(x) > 0 ? x : ret;
                }
            }
            Console.WriteLine(ret == "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" ? "UNRESTORABLE" : ret.Replace('?', 'a'));
        }
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
 long long int a , b , c , d;
  cin >> a >> b >> c >> d;
  cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

// #include "debug.cpp"

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

	int n, k;
	cin >> n >> k;
	int i, j, arr[n];
	for(i=0; i<n; i++){
		cin >> arr[i];
	}

	int rem = 0;
	
	for(int x=0; x<k; x++){

		int diff[n+1] = {0};
		for(i=0; i<n; i++){
			int l = max(0, i-arr[i]);
			int r = min(n-1, i+arr[i]);
			diff[l] += 1;
			diff[r+1] -= 1;
		}

		int count = 0;

		arr[0] = diff[0];
		if(arr[0] == n)
			count++;
		for(i=1; i<n; i++){
			arr[i] = arr[i-1] + diff[i];
			if(arr[i] >= n)
				count++;
		}

		if(count == n){
			break;
		}
	}

	for(i=0; i<n; i++)
		cout << arr[i] << " ";
	cout << "\n";



	

}

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

int main()
{
    int n;
    int A[50];
    cin >> n;
    for(int i=0;i<=n;i++)
    {
        if(i<2)
        {
            A[i]=1;
        }
        else
        {
            A[i]=A[i-1]+A[i-2];
        }
    }
    cout << A[n] <<endl;
}



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

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

  if(abs(a-b) <= d && abs(b-c) <= d){
    cout << "Yes" << endl;
  }
  else if(abs(a-c) <= d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main()
{
    int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a*b>=c*d)
            printf("%d\n",a*b);
        else
            printf("%d\n",c*d);
    }

}


Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let n = read_as_vec::<i32>()[0];

    if n/1000 == 1{
        println!("ABD");
    }else{
        println!("ABC");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] condstr = in.nextLine().split(" ");
        int num = Integer.parseInt(condstr[0]);
        int dim = Integer.parseInt(condstr[1]);
        int[][] point = new int[num][dim];
        for (int i = 0; i < num; i++) {
            for (int j = 0; j < dim; j++) {
                point[i][j] = Integer.parseInt(in.next());
            }
        }
        in.close();
        int count = 0;
        for (int i = 0; i < num - 1; i++) {
            for (int j = 1 + i; j < num; j++) {
                int distsq = 0;
                for (int k = 0; k < dim; k++) {
                    distsq += Math.pow((point[i][k] - point[j][k]), 2);
                }
                double dist = Math.sqrt(distsq);
                int distint = 0;
                distint += Math.pow((int) (dist), 2);
                if (distint == distsq) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


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

class Solution
{
    static void Main()
    {
        var size = new int[] { 1, 2, 4, 8 };
        var costs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        long n = long.Parse(Console.ReadLine()) * 4;

        for (int i = 0; i < 3; i++)
        {
            if (costs[i] * 2 < costs[i + 1])
            {
                costs[i + 1] = costs[i] * 2;
            }
        }

        long money = 0;
        for (int i = 3; i >= 0; i--)
        {
            if (n >= size[i])
            {
                var m = n / size[i];
                n -= m * size[i];
                money += m * costs[i];
            }
        }

        Console.WriteLine(money);
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
using namespace std;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
typedef vector<int> vi;
const int N=1e5+5;
int n,k;
vi a[7],ans;
vi mrg(const vi &a,const vi &b)
{
	static vi c; c.resize(n+1);
	fo(i,1,n) c[i]=a[b[i]];
	return c;
}
vi inv(const vi &a)
{
	static vi c; c.resize(n+1);
	fo(i,1,n) c[a[i]]=i;
	return c;
}
void writeln(const vi &a)
{
	fo(i,1,n) printf("%d ",a[i]);puts("");
}
int main()
{
	n=read(),k=read();
	a[1].resize(n+1),a[2].resize(n+1);
	fo(i,1,n) a[1][i]=read();
	fo(i,1,n) a[2][i]=read();
	fo(i,3,6) a[i]=mrg(a[i-1],inv(a[i-2]));
	ans.resize(n+1);
	fo(i,1,n) ans[i]=i;
	vi f,g; f.resize(n+1),g.resize(n+1);
	f = mrg(a[2],mrg(inv(a[1]),mrg(inv(a[2]),a[1])));
	fo(i,1,n) g[i]=i;
	//a[i]=f*a[i-6]*inv(f);
	for(int x=(k-1)/6;x;x>>=1)
	{
		if(x&1) g = mrg(g,f);
		f = mrg(f,f);
	}
	ans = mrg(g,a[(k-1)%6+1]);
	ans = mrg(ans,inv(g));
	writeln(ans);
	return 0;
}

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

using namespace std;
#define ll long long

const int N = 16;
ll dp[1 << N], sum[1 << N];
int a[N][N];

ll solve(int mask) {
    if (mask == 0) return 0;
    ll &ret = dp[mask];
    if (ret != -1) return ret;
    ret = -1e18;
    for (int submask = mask; submask; submask = (submask - 1) & mask) {
        ret = max(ret, solve(mask ^ submask) + sum[submask]);
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) cin >> a[i][j];

    for (int i = 1; i < (1 << n); i++) {
        vector<int> bits;
        ll cur = 0;
        for (int j = 0; j < n; j++) {
            if (i >> j & 1) {
                for (auto &x:bits) cur += a[x][j];
                bits.push_back(j);
            }
        }
        sum[i] = cur;
    }
    memset(dp, -1, sizeof dp);
    cout << solve((1 << n) - 1) << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <algorithm>
#define N (1<<19)
using namespace std;
void add(int,int);
int sum(int,int,int,int,int);
int tree[N],n,N1=N/2;

int main(){
  int q,com,x,y;

  cin >> n >> q;
  while(q--){
    cin >> com >> x >> y;
    if(com==0) add(x,y);
    else{
      int r=sum(x,y+1,0,0,N1);
      cout << r << endl;
    }
  }
  return 0;
}
void add(int x,int y){
  x+=N1-1;
  tree[x]+=y;
  while(x>0){
    x=(x-1)/2;
    tree[x]=tree[x*2+1]+tree[x*2+2];
  }
}
int sum(int a,int b,int k,int l,int r){
  if(r<=a||b<=l) return 0;
  if(a<=l&&r<=b) return tree[k];
  else{
    int vl=sum(a,b,k*2+1,l,(l+r)/2);
    int vr=sum(a,b,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
}

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

int main()
{
  int N;
  cin>>N;
  int W[N];
  int Wsum[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>W[i];
    sum+=W[i];
    Wsum[i]=sum;
  }
  
  int Wsub[N];
  for(int i=0;i<N;i++){
    Wsub[i]=sum-Wsum[i];
  }
  
  int tmp[N];
  for(int i=0;i<N;i++){
    tmp[i]=abs(Wsub[i]-Wsum[i]);
  }
  int ans=tmp[0];
  for(int i=0;i<N;i++){
	ans=min(ans,tmp[i]);
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

const int inf = 1e8;
struct Dinic {
    int n;
    vector<int> dist;
    vector<vector<int>> go;
    vector<int> it;
    void init(int N) {
        n = N;
        dist.resize(n);
        go.resize(n, vector<int>(n, 0));
        it.resize(n);
    }
    void add_edge(int x, int y, int f) {
        go[x][y] = go[y][x] = f;
    }
    bool bfs(int S, int E) {
        for (int i = 0; i < n; ++i) dist[i] = inf;
        queue<int> q;
        dist[S] = 0;
        q.push(S);
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            for (int i = 0; i < n; ++i) {
                if (dist[i] < inf) continue;
                if (go[x][i] <= 0) continue;
                dist[i] = dist[x] + 1;
                q.push(i);
            }
        }
        return dist[E] < inf;
    }
    int dfs(int x, int f, int E) {
        if (x == E) return f;
        for (int &i = it[x]; i < n; ++i) {
            if (go[x][i] <= 0) continue;
            if (dist[i] != dist[x] + 1) continue;
            int ret = dfs(i, min(f, go[x][i]), E);
            if (ret == 0) continue;
            go[x][i] -= ret;
            go[i][x] += ret;
            return ret;
        }
        return 0;
    }
    int maximum_flow(int S, int E) {
        int ret = 0;
        while (bfs(S, E)) {
            for (int i = 0; i < n; ++i) it[i] = 0;
            int f = 1;
            while (f > 0) {
                f = dfs(S, inf + inf, E);
                ret += f;
            }
        }
        return ret;
    }
} d;

int h, w;
char in[101];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    d.init(h + w + 2);
    int S = h + w;
    int E = h + w + 1;
    for (int i = 0; i < h; ++i) {
        cin >> in;
        for (int j = 0; j < w; ++j) {
            if (in[j] == 'o') d.add_edge(i, h + j, 1);
            if (in[j] == 'S') d.add_edge(S, i, inf), d.add_edge(S, h + j, inf);
            if (in[j] == 'T') d.add_edge(E, i, inf), d.add_edge(E, h + j, inf);
        }
    }
    int ans = d.maximum_flow(S, E);
    printf("%d\n", ans < inf ? ans : -1);
    return 0;
}

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

using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	int a[n];
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	int ans=0;
	
	while(1){
		bool ni=false;
		for(int i=0;i<n;i++){
			if(a[i]%2==0){
				a[i]/=2;
				ans++;
				ni=true;
				break;
			}
		}
		if(ni==false) break;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int dx[4] = {0,1,-1,0};
const int dy[4] = {-1,0,0,1};
int ac = 0;
int ans = 0;
void print(vector<vector<int> > field){
  cout << "-------------------------" <<endl;
  for(int i = 0;i < field.size();i++){
    for(int j = 0;j < field[0].size();j++){
      cout << field[i][j] ;
    }
    cout << endl;
  }
  cout << "-----------------------------------------------" << endl;
}
void  change(int c,int nc,int x,int y,vector<vector<int> > &field){
  field[y][x] = nc;
  int nx,ny;
  for(int i = 0;i < 4;i++){
    nx = x+dx[i];
    ny = y+dy[i];
    if(nx >= 0 && nx < field[0].size() && ny >= 0 && ny < field.size()){
      if(c == field[ny][nx]){
	change(c,nc,nx,ny,field);
      }
    }
  }

}
void bs(vector<vector<int> > field,int c){
  assert(c == ac);
  queue<pair<int,int> > que;
  que.push(pair<int,int>(0,0));
  field[0][0] = -1;
  int cnt = 1;
  while(!que.empty()){
    pair<int,int> tmp = que.front();que.pop();
    int x = tmp.first;
    int y = tmp.second;
    for(int i = 0;i < 4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(nx >= 0 && nx < field[0].size() && ny >= 0 && ny < field.size()){
	if(c == field[ny][nx]){
	  cnt++;
	  field[ny][nx] = -1;
	  que.push(pair<int,int>(nx,ny));
	}
      }  
    }
  }
  ans = max(ans,cnt);
}
void cal(int c,vector<vector<int> > field,int cnt){
  assert(c == field[0][0]);
  if(cnt == 4){
    if(c != ac){
      vector<vector<int> > tmp(field);
      change(c,ac,0,0,tmp);
      assert(tmp[0][0] == ac);
      bs(tmp,ac);
    }
    return ;
  }
  cnt++;
  for(int i = 0;i < 6;i++){
    if(i == c)continue;
    vector<vector<int> > tmp(field);
    change(c,i,0,0,tmp);
    assert(tmp[0][0] == i);
    cal(tmp[0][0],tmp,cnt);
  }
}

int main(){
  int h,w;
  while(cin >> h >> w >> ac && (h||w||ac)){
    ans = 0;
    ac--;
    vector<vector< int> > field(h,vector<int>(w,0));
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	cin >> field[i][j];
	field[i][j]--;
      }
    }
    cal(field[0][0],field,0);
    
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    int d1[7],d2[7];
    scanf("%d %d %d %d %d %d",&d1[0],&d1[1],&d1[2],&d1[3],&d1[4],&d1[5]);
    scanf("%d %d %d %d %d %d",&d2[0],&d2[1],&d2[2],&d2[3],&d2[4],&d2[5]);

    for(int i=0;i<4;i++){
        int tmp1=d1[0];
        d1[0]=d1[2]; d1[2]=d1[5]; d1[5]=d1[3]; d1[3]=tmp1;
        for(int j=0;j<4;j++){
            int tmp2=d1[0];
            d1[0]=d1[1]; d1[1]=d1[5]; d1[5]=d1[4]; d1[4]=tmp2;
            for(int k=0;k<4;k++){
                int tmp3=d1[1];
                d1[1]=d1[2]; d1[2]=d1[4]; d1[4]=d1[3]; d1[3]=tmp3;
                int chk=0;
                for(int p=0;p<6;p++){
                    if(d1[p]!=d2[p]){
                        break;
                    }else{
                        chk++;
                    }
                    if(chk==6){
                        printf("Yes\n");
                        return 0;
                    }
                }
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1152
import collections
h,p = map(int, raw_input().split())#10 37
mat = [list(raw_input()) for l in range(h)]
q = collections.deque([((0,0), 1)])

vis = set([(0,0)])
r  = float('inf')

while(q):
	u,d = q.popleft()

	if u == (h-1, p-1):
		r = d
		break
	for v in [(u[0]+1,u[1]), (u[0]-1,u[1]), (u[0],u[1]+1),(u[0],u[1]-1)]:
		if 0 <= v[0] < len(mat) and 0 <= v[1] < len(mat[0]):
			if v not in vis and mat[v[0]][v[1]] == '.':
				vis.add(v)
				q.append((v, d+1))

cc = collections.Counter()
for l in mat:
	for e in l:
		cc[e]+=1

if r < float('inf'):
	print cc['.'] - r
else:
	print -1


Measured memory_bytes: 85956
# O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline

def make_kth(A, B, k):
    n, m = len(A), len(B)
    q = [(-A[0] - B[0], 0, 0)]
    r=[]
    for _ in range(min(k, n * m)):
        v, s, t = heappop(q)
        r.append(-v)
        if t + 1 < m:
            heappush(q, (-A[s] - B[t + 1], s, t + 1))
        if t == 0 and s + 1 < n:
            heappush(q, (-A[s + 1] - B[0], s + 1, 0))
    return r

def main():
    _, _, _, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    a.sort(reverse=1)
    b.sort(reverse=1)
    c.sort(reverse=1)

    r = make_kth(a, b, k)
    r = make_kth(c, r, k)
    print(*r, sep="\n")

main()

Measured memory_bytes: 9440
N, K = list(map(int,input().split()))
d_list = []
A_list = []

result = list(range(1,N+1))

for i in range(K):
  d = int(input())
  A_list = list(map(int,input().split()))
  for j in range(len(A_list)):
    if(A_list[j] in result):
      result.remove(A_list[j])

print(len(result))




Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a=='a'){
		cout<<"vowel"<<endl;
	}
	else if(a=='i'){
		cout<<"vowel"<<endl;
	}
	else if(a=='u'){
		cout<<"vowel"<<endl;
	}
	else if(a=='e'){
		cout<<"vowel"<<endl;
	}
	else if(a=='o'){
		cout<<"vowel"<<endl;
	}
	else{
		cout<<"consonant"<<endl;
	}
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt
def shellSort(A, n):
    cnt = 0
    h = 4
    G = [1]
    while h < n:
        G += [h]
        h = 3 * h + 1
    m = len(G)
    for i in range(m - 1, -1, -1):
        cnt = insertionSort(A, n, G[i], cnt)
    print(m)
    print(*G[::-1])
    print(cnt)
    print(*A, sep="\n")
n = int(input())
# A = [int(readline()) for _ in range(n)]
A = list(map(int, sys.stdin))
shellSort(A, n)



Measured memory_bytes: 53384
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define ub             upper_bound
#define fi             first
#define mp             make_pair
#define vll            vector<ll>
#define se             second
#define sz             size()
#define mod            1000000007
#define endl           "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}

int main()
{
     fast;
     int q=1;
     //cin>>q;
     while(q--)
     {
       ll n,i,j,k,l,m,sum=0,ans=0,b=0,e;
      ll a,c=0,d=0;
       string s,s1;
       cin>>s>>s1;
       for(i=0;i<s.sz;i++)
       { if(s[i]!=s1[i])
           c++;
           else d++;

       }
cout<<c<<endl;

    }
   return 0;
}


Measured memory_bytes: 3800
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int ls[2002];
int rs[2002];
char in[2002][2003];
int main() {
	int H,W;
	scanf("%d%d",&H,&W);
	for(int i=0;i<H;i++){
		scanf("%s",in[i]);
	}
	int ret=max(H,W);
	for(int j=0;j<W;j++){
		ls[j]=rs[j]=1;
	}
	for(int i=1;i<H;i++){
		stack<P> st;
		st.push(P(i+1,0));
		for(int j=1;j<W;j++){
			if(st.size()){
				//cerr << i << ", " << j << "$ " << st.top().first << ", " << st.top().second << endl;
			}
			int c=0;
			for(int p=i-1;p<=i;p++){
				for(int q=j-1;q<=j;q++){
					if(in[p][q]=='.'){
						c++;
					}
				}
			}
			//cerr << i << ", " << j << ": " << c << endl;
			if(c%2==0){
				ls[j]++;
			}
			else{
				ls[j]=1;
			}
			//cerr << ls[j] << endl;
			while(st.size()&&st.top().first>ls[j]){
				ret=max(ret,(j-st.top().second)*st.top().first);
				st.pop();
			}
			c=0;
			for(int p=i-1;p<=i;p++){
				for(int q=j;q<=j+1;q++){
					if(in[p][q]=='.'){
						c++;
					}
				}
			}
			//cerr << i << ", " << j << ":: " << c << endl;
			if(j+1==W){
				rs[j]=0;
			}
			if(c%2==0){
				rs[j]++;
			}
			else{
				rs[j]=1;
			}
			//cerr << rs[j] << endl;
			int k=j;
			while(st.size()&&st.top().first>=rs[j]){
				ret=max(ret,(j-st.top().second+1)*st.top().first);
				k=st.top().second;
				st.pop();
			}
			st.push(P(rs[j],k));
		}
	}
	printf("%d\n",ret);


	return 0;
}



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

int main()
{
    string s;
    cin >> s;
    int p = 0;
    long long sum = 0;
    string ss = "";
    vector<string> partial;

    while (p < s.size())
    {
        if (p < s.size() - 1 && s[p] == 'B' && s[p + 1] == 'C')
        {
            ss += "D";
            p += 2;
        }
        else
        {
            ss += s[p];
            p += 1;
        }
    }

    p = 0;

    while (p < ss.size())
    {
        string tmp = "";
        if (ss[p] == 'A' || ss[p] == 'D')
        {
            while (ss[p] == 'A' || ss[p] == 'D')
            {
                tmp += ss[p];
                p += 1;
            }
            if (tmp.size() > 1)
            {
                partial.push_back(tmp);
            }
        }
        else
        {
            p += 1;
        }
    }

    for (auto i = 0; i < partial.size(); i++)
    {
        int size = partial[i].size();
        long long numD = 0;
        for (auto j = size - 1; j >= 0; j--)
        {
            if(partial[i][j] == 'D'){
                numD += 1;
            }else{
                sum += numD;
            }
        }
    }

    cout << sum << endl;
}

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

int main(){
  double a,b,c,d,e,f;
  cin >> a >> b >> c >> d;
  e=ceil(c/b);
  f=ceil(a/d);
  if(e<=f){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

int main() {
    string s;
    cin >> s;
    vector<int> cnt(2019, 0);
    int t = 0, ten = 1;
    for (int i=s.size()-1; i>=0; i--) {
        t = (t + ten * (s[i] - '0')) % 2019;
        ten *= 10;
        ten %= 2019;
        cnt[t]++;
    }
    int ans = 0;
    rep(i, 2019) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    ans += cnt[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
long calcmin(long N, long M)
{
    return M * (M - 1) / 2;
}
long calcmax(long N, long M)
{
    return M * (2 * N - M + 1) / 2;
}
int main(void)
{
    int N, K;
    long sums = 0;
    scanf("%i %i", &N, &K);
    for (long M = K; M <= N + 1; M++)
    {
        sums += calcmax(N, M) - calcmin(N, M) + 1;
    }
    printf("%ld\n", sums % 1000000007);

    return 0;
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;

int n;
vector<int> x, y;

void read(istream& cin) {
	cin >> n;
	x.resize(n);
	y.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		--x[i]; --y[i];
	}
}

struct ST {
	int n;
	vector<pair<int, int>> t;
	function<pair<int, int>(pair<int, int>, pair<int, int>)> op;

	ST(int n, function<pair<int, int>(pair<int, int>, pair<int, int>)> op) : n(n), t(2 * n), op(op) {}

	void upd(int v, pair<int, int> x) {
		t[v += n] = x;
		for (v >>= 1; v; v >>= 1) {
			t[v] = op(t[v << 1], t[v << 1 | 1]);
		}
	}

	int get(int l, int r, pair<int, int> ret) {
		for (l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
			if (l & 1) {
				ret = op(ret, t[l]);
			}
			if (!(r & 1)) {
				ret = op(ret, t[r]);
			}
		}
		return ret.second;
	}
};

vector<bool> was;
vector<int> cur;

const int inf = 1e9 + 228;

void dfs(int i, ST& t, ST& t1) {
	was[i] = true;
	cur.push_back(i);
	t.upd(x[i], { inf, -1 });
	t1.upd(x[i], { -inf, -1 });
	while (true) {
		int j = t.get(0, x[i], { inf, -1 });
		if (j == -1 || y[j] > y[i]) {
			break;
		}
		dfs(j, t, t1);
	}
	while (true) {
		int j = t1.get(x[i], n - 1, { -inf, -1 });
		if (j == -1 || y[j] < y[i]) {
			break;
		}
		dfs(j, t, t1);
	}
}

void solve(ostream& cout) {
	vector<int> ans(n);
	was.resize(n);
	auto f = [&](pair<int, int> x, pair<int, int> y) { return min(x, y); };
	auto f1 = [&](pair<int, int> x, pair<int, int> y) { return max(x, y); };
	ST t(n, f), t1(n, f1);
	for (int i = 0; i < n; i++) {
		t.upd(x[i], { y[i], i });
		t1.upd(x[i], { y[i], i });
	}
	for (int i = 0; i < n; i++) {
		if (!was[i]) {
			cur.clear();
			dfs(i, t, t1);
			for (int v : cur) {
				ans[v] = cur.size();
			}
		}
	}
	for (int x : ans) {
		cout << x << '\n';
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T = 1;
	// cin >> T;
	while (T--) {
		read(cin);
		solve(cout);
	}
}


Measured memory_bytes: 46892
N,M=map(int, input().split())
ansY = [0]*N
ansWA = [0]*N
for i in range(M):
  id,ans = input().split()
  idr = int(id)-1
  if ans=='AC':
    ansY[idr]=1
  elif ans=='WA' and ansY[idr]==0:
    ansWA[idr]+=1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY),WA)

Measured memory_bytes: 5528