akhauriyash/Code-Regression huggingface dataset:
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n, m, k; 
ll arr[3001][3001];
ll dp[3001][3001][4];

ll solve(int idx, int jdx, int t) {

    if(idx == n && jdx == m) 
        return 0;

    if(dp[idx][jdx][t] != -1)
        return dp[idx][jdx][t];

    ll ans = 0;
    if(idx + 1 <= n) {
        ans = max(ans, solve(idx + 1, jdx, 0));
        if(t + 1 <=3 && arr[idx][jdx] > 0) 
            ans = max(ans, solve(idx + 1, jdx, 0) + arr[idx][jdx]);
    } 
    if(jdx + 1 <= m) {
        ans = max(ans, solve(idx, jdx + 1, t));
        if(t + 1 <=3 && arr[idx][jdx] > 0)
            ans = max(ans, solve(idx, jdx + 1, t + 1) + arr[idx][jdx]);
    }

    return dp[idx][jdx][t] = ans;
}

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    memset(dp, -1, sizeof dp);
    memset(arr, 0, sizeof arr);
    cin >> n >> m >> k;

    for(int i = 0 ; i < k; i++){
        int x, y, v;
        cin >> x >> y >> v;
        arr[x-1][y-1] = v;
    }

    
    cout << solve(0, 0, 0) << endl;
   
    return 0;
}

Measured memory_bytes: 355980
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <list>
#include <set>
using namespace std;
 
#define INF 99999999
bool prime[10000001];
bool like[10000001] = {};
int liken[10000002] = {};
int main() {
	fill(prime, prime + 10000001, true);
	prime[0] = prime[1] = false;
	vector<int> prime_n;
	for (int i = 2; i < 10000001; i++) {
		if (prime[i] == true) {
			prime_n.push_back(i);
			for (int j = 2; i * j < 10000001; j++) {
				prime[i * j] = false;
			}
		}
	}
	for (int i = 0; i < prime_n.size(); i++) {
		if (prime[(prime_n[i] + 1) / 2]) {
			like[prime_n[i]] = true;
			//cout << prime_n[i] << " " << (prime_n[i] + 1) / 2 << endl;
		}
	}
	for (int i = 1; i < 10000002; i++) {
		liken[i] += liken[i-1] + (int)like[i - 1];
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		cout << liken[b + 1] - liken[a - 1] << endl;
	}
 
}

Measured memory_bytes: 63212
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    char a[3];
    int i,s=700;
    for(i=0;i<3;i++)
        {
            scanf("%c",&a[i]);
            if(a[i]=='o')
             s=s+100;
        }
 
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

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

    int B[N];
    int A[N];

    rep(i, 0, N-1) {
        cin >> B[i];
        //A[i] = B[i];
    }
    
    A[0] = B[0];
    A[1] = B[0];

    rep(i, 1, N-1) {
        if(A[i] > B[i]) {
            A[i] = B[i];
            A[i + 1] = B[i];
        } else {
            A[i + 1] = B[i];
        }
    }

    rep(i, 0, N) {
        //cout << A[i] << endl;
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
        cout << 3;
    else if(s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R')
        cout << 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
        cout << 1;
    else
        cout << 0;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	x := -1
	for i := 0; i < n-1; i++ {
		if l <= as[i]+as[i+1] {
			x = i
			break
		}
	}
	if x == -1 {
		fmt.Println("Impossible")
		return
	}

	ans := make([]int, 0)
	left, right := 0, n-2
	for left != right {
		if left < x {
			ans = append(ans, left)
			left++
		} else if x < right {
			ans = append(ans, right)
			right--
		}
	}
	ans = append(ans, x)

	fmt.Println("Possible")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i] + 1)
	}
}


Measured memory_bytes: 8320
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N, K;
ll MOD;

ll DP[310][310]; // [Length][Min_value]
ll C[500][500];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    memset(DP, 0, sizeof(DP));
    memset(C, 0, sizeof(C));
    cin >> N >> K >> MOD;
    C[0][0] = 1;
    for (int i = 0;i < 499;i++) {
        for (int j = 0;j <= i;j++) {
            C[i + 1][j + 1] += C[i][j];
            C[i + 1][j + 1] %= MOD;
            C[i + 1][j] += C[i][j];
            C[i + 1][j] %= MOD;
        }
    }
    for (int i = 1;i <= K;i++) {
        DP[0][i] = 1;
        DP[1][i] = (K - i + 1) % MOD;
    }
    DP[0][K + 1] = 1;
    for (int l = 2;l <= N;l++) {
        for (int left = 0;left + 1 <= l;left++) {
            int right = l - left - 1;
            for (int mi = 1;mi <= K;mi++) {
                ll v = C[l][left];
                v *= DP[left][mi + 1];
                v %= MOD;
                v *= DP[right][mi];
                v %= MOD;
                DP[l][mi] += v;
                DP[l][mi] %= MOD;
            }
        }
        for (int k = K;k > 1;k--) {
            DP[l][k - 1] += DP[l][k];
            DP[l][k - 1] %= MOD;
        }
    }
    cout << DP[N][1] << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    string S;
    cin >> S;
    cout << S[0] << S[1] << S[2] << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(snip_i, n) cin >> p.at(snip_i);
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k){
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
#include <fstream>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REM(i,a,n) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
const double PI = 3.1415926535897932;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 0
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#ifdef _DEBUG
//#include "IntMod.h"
//#include "Union_Find.h"
//#include "Graph.h"
//#include "Suffix_Array.h"
//#include "Matrix.h"
//#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int N;
int main() {
	cin >> N;
	cout << (N % 1000 % 111 == 0 || N / 10 % 111 == 0 ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int r, c, k, res = 0;
    char b[10][10];
    cin >> r >> c >> k;
    for( int i = 0; i < r; i++ )
        for( int j = 0; j < c; j++ ){
            cin >> b[i][j];
        }
    for( int i = 0; i < (1 << r); i++) {
        for( int j = 0; j < (1 << c); j++ ){
            char tmp[10][10];
            int cnt = 0;
            for( int k = 0; k < r; k++ )
                for( int z = 0; z < c; z++ ){
                    if( (i & (1<< k)) || (j & (1 << z)) )
                        tmp[k][z] = 'o';
                    else
                        if(b[k][z] == '#')
                            cnt++;
                }
            //cout << i << ' ' << j << ' ' << cnt << endl;
            if(cnt == k)
                res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
    
/*
    Author: Koushik Sahu
    Created: 18 Sep 2020 09:49:07
*/

int x;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>x;
    cout<<1-x<<"\n";
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	ll a[26];
	ll b[26];
int main(){
	string o,e;
	cin>>o>>e;
	vector<char> v;
	rep(i,0,o.length()+e.length()){
		if(i%2==1)v.push_back(e[i/2]);
		else v.push_back(o[i/2]);
	}
	rep(i,0,v.size())cout<<v[i];
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private int n,q,top_id;
	private long top_value;
	private long[] list;

	private void mainrun() {
		scan = new Scanner(System.in);

		n = scan.nextInt();
		q = scan.nextInt();

		list = new long[n+1];
		Arrays.fill(list,0);

		list[0] = Integer.MIN_VALUE;

		top_id =  0;
		top_value = Integer.MIN_VALUE;

		for(int i = 0;i < q;i++) {
			int a = scan.nextInt();
			int v = scan.nextInt();

			list[a] += v;

			if(a == top_id && v > 0) {
				top_value = list[a];

			}else if(a != top_id && v > 0){
				if(list[top_id] < list[a] || (list[top_id] == list[a] && top_id > a)) {
					top_id = a;
					top_value = list[a];
				}

			}else if(a == top_id && v < 0){
				top_id = 0;
				top_value = list[0];
				int cnt = 0;

				for(long l : list) {
					if(top_value < l) {
						top_id = cnt;
						top_value = l;
					}
					cnt++;
				}

			}else if(a != top_id && v < 0){
				/* */

			}

			System.out.println(top_id + " " + top_value);
		}

		scan.close();
	}
}


Measured memory_bytes: 107660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>L(N);
    rep(i,N) cin>>L[i];
    ll ans = 0;
    rep(i,N){
        rep3(j,i+1,N){
            rep3(k,j+1,N){
                if(L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]){
                    if(L[i]+L[k]>L[j] && L[i]+L[j]>L[k] &&L[j]+L[k]>L[i]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<ll, ll> P;
int main()
{
    
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<P> order(N - 1);
    int p = 0, m = 0;
    ll ans = 0;

    rep(i, N) {
        cin >> A[i];
        if (A[i] >= 0) p++;
        else m++;
    }
    sort(all(A));

    if (m == 0) {
        ll right = A[0];
        for (int i = N - 1; i >= 2; i--) {
            order[N - i - 1] = P(right, A[i]);
            right -= A[i];
        }
        order[N - 2] = P(A[1], right);
        ans = A[1] - right;
    }
    else if (p == 0) {
        ll left = A[N - 1];
        for (int i = 1; i < N - 1; i++) {
            order[i - 1] = P(left, A[i]);
            left -= A[i];
        }
        order[N - 2] = P(left, A[0]);
        ans = left - A[0];
    }
    else {
        ll right = A[0];
        ll left_i = N - 1;
        int cnt = 0;
        for (int i = N - 1; i >= 0; i--) {
            left_i = i;
            if (p <= 1) break;
            order[cnt] = P(right, A[i]);
            right -= A[i];
            cnt++;
            p--;
        }
        order[cnt] = P(A[left_i], right);
        cnt++;
        ans = A[left_i] - right;
        for (int i = 1; i < left_i; i++) {
            order[cnt] = P(ans, A[i]);
            ans -= A[i];
            cnt++;
        }
    }

    cout << ans << endl;
    rep(i, N - 1) {
        cout << order[i].first << " " << order[i].second << endl;
    }

    return 0;
}

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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 2e5 + 1;

int mk = 0;
int id[N], sz[N];
bool w[N];
vector<int> adj[N];

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    fill(w, w + n, 0);
    fill(sz, sz + n, 0);
    for (int i = 0; i < n; i++) {
        if (w[i]) continue;
        
        int ptr = 0;
        vector<int> q;
        q.push_back(i);

        w[i] = 1;
        while (ptr < SZ(q)) {
            int node = q[ptr++];
            id[node] = mk;
            sz[mk]++;
            for (int j : adj[node])
                if (!w[j]) {
                    w[j] = 1;
                    q.push_back(j);
                }
        }
        mk++;
    }

    sort(sz, sz + mk);
    cout << sz[mk - 1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 16932
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    int n, k;
    cin >> n >> k;
    vector<bool> sunuke (n, false);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            sunuke[a - 1] = true;
        }
    }
    size_t num = std::count_if (sunuke.begin (), sunuke.end (),
                                [] (bool x) { return !x; });
    cout << num;
}


Measured memory_bytes: 3632
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let i = (0..N).max_by_key(|&i| A[i]).unwrap();
    let ans = A[i] + B[i];

    println!("{}", ans);
}


Measured memory_bytes: 8444
S = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
A = list(map(int, S.split(',')))
i = int(input())
print(A[i-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <math.h>
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++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

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

    int i_max = max(Y / 10000, N);
    int j_max = max(Y / 5000, N);
    for (int i = 0; i <= i_max; i++) {
        for (int j = 0; j <= j_max; j++) {
            int money_rem = Y - 10000 * i - 5000 * j;
            int bill_rem = N - i - j;

            if (money_rem >= 0 and money_rem == 1000 * bill_rem) {
                cout << i << " " << j << " " << bill_rem << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}


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

int main() {
	string S,T;
  
  cin >> S >> T;
  
  int count = 0;
  
  for(int i = 0 ; i < S.size() ; i++){
  	if(S.at(i)!=T.at(i)){
    	count++;
    }      
  }
  
  cout << count << endl;

}	


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve(){
    ll x; cin >> x;
    ll ans = (x/500)*1000 + ((x%500)/5)*5;
    cout << ans << endl;
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
D=list(map(int,input().split()))
E=collections.Counter(D)
M=int(input())
T=list(map(int,input().split()))
F=collections.Counter(T)
r='YES'
for u in F.keys():
     if E[u] < F[u]:
         r='NO'
print(r)


Measured memory_bytes: 153340
import java.util.Scanner;

class Main {

	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);

		int m = 0, f = 0, r = 0;
		while(true){
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			
			if(m == -1 && f == -1 && r == -1)break;
			
			if(m >= 0 && f >= 0){
				if(m + f >= 80){
					System.out.println("A");
				}else if(m + f < 80 && m + f >= 65){
					System.out.println("B");					
				}else if(m + f < 65 && m + f >= 50 || r >= 50){
					System.out.println("C");
				}else if(m + f < 50 && m + f >= 30){
					System.out.println("D");
				}else if(m + f < 30){
					System.out.println("F");
				}
			}else{
				System.out.println("F");
			}
		}
		
		
	}
}	

Measured memory_bytes: 26324
package main

import (
  "fmt"
  "sort"
)
func biL(a []int, x int) int {return sort.SearchInts(a, x)}
func biR(a []int, x int) int {return sort.Search(len(a), func(i int) bool {return a[i] > x})}

func main() {
  var n int
  fmt.Scan(&n)
  cand := []int{105, 165, 195, 135, 189}
  sort.Ints(cand)
  fmt.Println(biR(cand, n))
}

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

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

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

  unordered_set<int> pressed;
  int now = 0;
  int ans = -1;
  for (int i = 0; i < n; i++) {
    if (pressed.find(now) != pressed.end()) break;
    if (now == 1) {ans = i; break;}
    pressed.insert(now);
    now = a[now];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4772
n=int(input())
for i in range(500):
    if i*(i-1)//2==n:
        print("Yes")
        print(i)
        l=[[] for i in range(i)]
        a=1
        for j in range(i-1):
            for k in range(j+1,i):
                l[j].append(a)
                l[k].append(a)
                a+=1
        for j in range(i):
            print(i-1,end=" ")
            for k in range(i-1):
                print(l[j][k],end=" ")
            print("")
        n=0
        break
if n>0:
    print("No")


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for(int i = 0; i < N; i++) cin >> x[i];
  for(int i = 0; i < M; i++) cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (x.back() < y[0] && X < y[0] && y[0] <= Y) {
	cout << "No War" << endl;
  } else {
	cout << "War" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;
  cin >> A;
  cin >> B;
  K = ( A + B ) /2;
 
  if (A >=K && B < K && (A+B) % 2 ==0) {
    cout <<  ( A + B ) /2 << endl;
  }
  else if (A < K && B >= K && (A+B) % 2 ==0 ) {
    cout << ( A + B ) /2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
        int n, ar[101] = {};
        cin >> n;
        for (int i = 0; i < n; i++) cin >> ar[i];
        int sm = 0;
        sort(ar, ar + n);
        reverse(ar, ar + n);
        for (int i = 0; i < n - (n & 1); i += 2) sm += ar[i] - ar[i + 1];
        if (n & 1) sm += ar[n - 1];
        cout << sm;
        return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
di=[0]*k
Ap=[0]*n
for i in range(0,k):
    di[i] = int(input())
    A = list(map(int, input().split()))
    ai=0
    A.append(-100)
    for j in range(1,n+1):
        if A[ai]==j:
            ai=ai+1
            Ap[j-1]=1
num=0
for l in range(0,n):
    if Ap[l]==0:
        num=num+1
print(num)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Y,M,D;
  char A,B;
  cin>>Y>>A>>M>>B>>D;
  if(Y>2019){
    cout<<"TBD"<<endl;
  }
  else if(M>4){
    cout<<"TBD"<<endl;
  }
  else{
    cout<<"Heisei"<<endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
int main()
{
    int N;
    cin >> N;

    string S;
    cin>>S;

    REP(i, S.size()){
        int a = (S[i]-'A')+N;
        a%=('Z'-'A'+1);
        cout << char(a+'A');
        //cout << char(a);
    }
    cout  << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <tuple>

using namespace std;

u_int64_t a[1'000], b[1'000], c[1'000];

vector<u_int64_t> scores;

using Cake = tuple<u_int64_t, int, int, int>;

int main()
{
    int x, y, z, k;

    cin >> x >> y >> z >> k;
    for (int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }

    auto comp = [](const u_int64_t &l, const u_int64_t &r) {
        return l > r;
    };
    sort(a, a + x, comp);
    sort(b, b + y, comp);
    sort(c, c + z, comp);

    auto cake_cmp = [](const Cake &l, const Cake &r) {
        return l > r;
    };
    set<Cake, decltype(cake_cmp)> q(cake_cmp);
    set<Cake> hist;

    Cake initial(a[0] + b[0] + c[0], 0, 0, 0);
    q.insert(initial);
    hist.insert(initial);

    for (int i = 0; i < k; i++)
    {
        auto it = q.begin();
        Cake cake = *it;
        q.erase(it);

        scores.push_back(get<0>(cake));

        if (get<1>(cake) + 1 < x)
        {
            Cake ca(a[get<1>(cake) + 1] + b[get<2>(cake)] + c[get<3>(cake)], get<1>(cake) + 1, get<2>(cake), get<3>(cake));
            if (hist.find(ca) == hist.end())
            {
                q.insert(ca);
                hist.insert(ca);
            }
        }
        if (get<2>(cake) + 1 < y)
        {
            Cake ca(a[get<1>(cake)] + b[get<2>(cake) + 1] + c[get<3>(cake)], get<1>(cake), get<2>(cake) + 1, get<3>(cake));
            if (hist.find(ca) == hist.end())
            {
                q.insert(ca);
                hist.insert(ca);
            }
        }
        if (get<3>(cake) + 1 < z)
        {
            Cake ca(a[get<1>(cake)] + b[get<2>(cake)] + c[get<3>(cake) + 1], get<1>(cake), get<2>(cake), get<3>(cake) + 1);
            if (hist.find(ca) == hist.end())
            {
                q.insert(ca);
                hist.insert(ca);
            }
        }
    }

    for (int i = 0; i < k; i++)
    {
        cout << scores[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
s = input()
t = input()
import sys
revs = list(reversed(s))
revt = list(reversed(t))
if len(s) < len(t):
    print("UNRESTORABLE")
else:
    cur = 0
    for _ in range(len(s)-len(t)+1):
        char = revs[cur:cur+len(t)]
        charcopy = char.copy()
        for i,c in enumerate(char):
            if (i == len(char)-1) & ((c == "?") | (c == revt[i])):
                revs[cur:cur+len(t)] = revt
                for j in range(len(revs)):
                    if revs[j] == "?":
                        revs[j] = "a"
                print("".join(list(reversed(revs))))
                sys.exit()
            elif (c == "?") | (c == revt[i]):
                char[i] == revt[i]
            else:
                cur += 1
                break
        else:
            char = charcopy      
    else:
        print("UNRESTORABLE")

Measured memory_bytes: 9196
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    (n, k) = [int(e) for e in lines[0].split(" ")]
    a = [int(e) for e in lines[1].split(" ")]

    return (n, k, a)


def solve(n, k, a):

    # previous = 1
    # for i in range(k):
    #     previous = previous * a[i]

    
    result = []
    for i in range(k, n):

        if a[i-k] < a[i]:
            result.append('Yes')
        else:
            result.append('No')


    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


Measured memory_bytes: 103524
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
if N >= M:
    print(0)
else:
    X.sort()
    gap = []
    for i in range(1,M):
        gap.append(X[i]-X[i-1])
    s = X[M-1] - X[0]
    gap.sort(reverse=True)
    d = 0
    for i in range(N-1):
        d += gap[i]
    print(s-d)

Measured memory_bytes: 56872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    
    string s;
    cin >> s;
    
    int n = s.size();
    int mind = 114514;
    for (int i = 0; i < n-2; i++) {
        string p = {s[i], s[i+1], s[i+2]};
        int d = abs(753 - atoi(p.c_str()));
        mind = min(mind, d);
    }
    cout << mind << endl;
    
}

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

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

	if (a < 10 && b < 10)cout << a * b;
	else cout << "-1";
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] s = scn.nextLine().toCharArray();

		boolean can = true;
		for(int i = 0;i < s.length;i++) {
			if(i%2 == 0) {
				if(s[i] == 'L')can = false;
			}else {
				if(s[i] == 'R')can = false;
			}

			if(!can)break;
		}
		System.out.println(can?"Yes":"No");
	}

}

Measured memory_bytes: 23636
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int l = scan.nextInt();
        long[][] a = new long[n + 1][m + 1];
        long[][] b = new long[m + 1][l + 1];
        long[][] c = new long[n + 1][l + 1];
        int i,j,k;
        for(i = 1; i <= n; ++i){
            for(k = 1; k <= m; ++k){
                a[i][k] = scan.nextInt();
            }
        }
        for(k = 1; k <= m; ++k){
            for(j = 1; j <= l; ++j){
                b[k][j] = scan.nextInt();
            }
        }
        for(i = 1; i <= n; ++i){
            for(j = 1; j <= l; ++j){
                for(k = 1; k <= m; ++k){
                    c[i][j] += a[i][k] * b[k][j] ;
                }
            }
                 
            }
        for(i = 1; i <= n; ++i){
            for(j = 1; j <= l; ++j){
                if(j == l)
                    System.out.println(c[i][j]);
                else
                    System.out.print(c[i][j]+" ");
            }
        }
        }
}
         
     

Measured memory_bytes: 52904
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s,t;
    cin>>s>>t;
    int l1 = s.length();
    t.resize(l1);
    if(t == s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;cin >> c;
    if(c>='A' and c<='Z')cout << "A";
    else cout << "a";
    }


Measured memory_bytes: 3608
solve :: Int -> Int -> Int -> String
solve _ a b = if (a - b) `mod` 2 == 0 then "Alice" else "Borys"


main :: IO ()
main = do
  conts <- getContents
  let [valN, valA, valB] = map read (words conts)
      answer = solve valN valA valB
  putStrLn answer


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  string ans = "APPROVED";
  for(auto a : A){
    if(a%2) continue;
    if(a%3 and a%5){
      ans = "DENIED";
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const int maxn=2e5+10;

int k;
bool f;



int main()
{
	int a,b,c;
	cin>>a>>b>>c>>k;
	while( k && b<=a ) b*=2,k--;
		while ( k && c<=b ) c*=2,k--;
		
	if( c>b && b>a ) puts("Yes");
	else puts("No");
} 

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans,i;
char w[3];
  cin >> w;
  for(i=0;i<3;++i)
  {
  if(w[i]=='R') ans++;
  }
  if(w[0]=='R' && w[1]=='S' && w[2]=='R') cout << '1';
  else cout << ans;
return 0;}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a<=b){
                if(b<=c){
                        printf("%d %d %d\n",a,b,c);
                }
                else if(a<=c){
                        printf("%d %d %d\n",a,c,b);
                }
                else if(c<=a)
                        printf("%d %d %d\n",c,a,b);
                }
        else {
                if(c<=b){
                        printf("%d %d %d\n",c,b,a);
                }
                else if(a<=c){
                        printf("%d %d %d\n",b,a,c);
                }
                else if(c<=a){
                        printf("%d %d %d\n",b,c,a);
        }
        }
        
         return 0;
}

Measured memory_bytes: 2720
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    long long int A,B;
    cin >> A >> B;
    bool draw=false;
    bool Alice=false;
    bool Bob=false;
    if(A==1){
        A=14;
    }
    if(B==1){
        B=14;
    }
    if(A==B){
        draw = true;
    }
    else{
        if(A>B){
            Alice=true;
        }
        else{
            Bob = true;
        }
    }
    if(draw){
        cout << "Draw";
    }
    else{
        if(Alice){
            cout << "Alice";
        }
        else{
            cout << "Bob";
        }
    }
    }

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, r, tmp;
  
  scanf("%d%d", &a, &b);
  if(a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  
  while(a % b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  printf("%d\n", b);
  
  return 0;
}

Measured memory_bytes: 592
a,b = map(int,input().split())
# main
if (a <= 0 <= b) or a == 0 or b == 0:
    ans = "Zero"
elif b < 0:
    if (b - a) % 2 == 1:
        ans = "Positive"
    else:
        ans = "Negative"
else:
    ans = "Positive"
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

  private static void solve(int n) {
    System.out.println(n % 1_000 > 0 ? 1_000 - n % 1_000 : 0);
  }

  public static void main(String[] args) {
    int n = scanner.nextInt();
    solve(n);
  }

  private static final Scanner scanner = new Scanner(System.in);
}


Measured memory_bytes: 35656
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
#include "atcoder/fenwicktree.hpp"
using namespace std;
using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
  
    int n,q; cin>>n>>q;
    fenwick_tree<ll> bit{n};
    rep(i,n){
        int a; cin>>a;
        bit.add(i,a);
    }
    rep(_,q){
        int t,l,r; cin>>t>>l>>r;
        if(t==0){
            bit.add(l,r);
        }
        else{
            printf("%lld\n",bit.sum(l,r));
        }
    }
}


Measured memory_bytes: 8252
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll N,M;
    cin >> N >> M;
    // map<int,int> ac;
    // map<int,int> wa;
    ll ac[N+1];
    ll wa[N+1];
    for(ll i=0; i<N+1; ++i) ac[i]=wa[i]=0;
    for (ll i=0; i<M; ++i)
    {
        ll p; string s;
        cin >> p >> s;
        if(s=="AC") ac[p]=1;
        else
        {   if(ac[p]==1) continue;
            wa[p] += 1;
        }
    }

    ll acN=0; ll waN=0;
    for(ll i=0; i<N+1; ++i)
    {
        acN += ac[i];
        if(ac[i]==1) waN += wa[i];
    }

    cout << acN << " " <<waN << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

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

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
struct edge{int v,nxt,f;ll w;}e[N];
int f[N],fr[N],in[N],n,tot,t,flow,head[N];
ll d[N],ans;
void add(int x,int y,int f,ll w){
	e[++tot]={y,head[x],f,w};
	head[x]=tot;
	e[++tot]={x,head[y],0,-w};
	head[y]=tot;
}
bool spfa(){
	memset(d,192,sizeof(d));d[0]=0;
	memset(f,0,sizeof(f));f[0]=1e9;
	memset(fr,0,sizeof(fr));
	queue<int> q;q.push(0);
	while(!q.empty()){
		int u=q.front();q.pop();in[u]=0;
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].f&&d[e[i].v]<d[u]+e[i].w){
				d[e[i].v]=d[u]+e[i].w;
				f[e[i].v]=min(f[u],e[i].f);
				fr[e[i].v]=i;
				if(!in[e[i].v]) q.push(e[i].v),in[e[i].v]=1;
			}
	}
	return f[t];
}
void update(){
	flow+=f[t];ans+=f[t]*d[t];
	for(int x=t;fr[x];x=e[fr[x]^1].v)
		e[fr[x]].f-=f[t],e[fr[x]^1].f+=f[t];
}
ll EK(){
	ans=flow=0;
	while(spfa()) update();
	return ans;
}
int main(){
	read(n);tot=1;t=2*n+5;
	for(int i=1;i<=n;i++){
		int x,y,z;read(x);read(y);read(z);
		add(0,i,z,0);
		add(i,2*n+1,z,x+y);
		add(i,2*n+2,z,x-y);
		add(i,2*n+3,z,-x+y);
		add(i,2*n+4,z,-x-y);
	}
	for(int i=1;i<=n;i++){
		int x,y,z;read(x);read(y);read(z);
		add(i+n,t,z,0);
		add(2*n+4,i+n,z,x+y);
		add(2*n+3,i+n,z,x-y);
		add(2*n+1,i+n,z,-x-y);
		add(2*n+2,i+n,z,-x+y);
	}
	cout<<EK()<<'\n';
	return 0;
}


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

typedef __int128 LL;

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define fi first
#define se second
#define pb push_back

template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

long long s[112345];
#define lim 2155
int isprime[lim];
vector<int> p;
map<LL,LL> q;
struct cww{cww(){
    REP(i,lim)isprime[i]=1;
    FOR(i,2,lim)if(isprime[i]){
        p.pb(i);
        for(int j=i+i;j<lim;j+=i)
            isprime[j]=0;
    }
    for(LL i=lim;i<100001;i++){
        int f=1;
        for(auto &d:p)if(i%d==0){f=0;break;}
        if(f){
            q[i]=i*i;
            q[i*i]=i;
        }
    }
}}star;
typedef pair<LL,LL> P;
int main(){
    int N;scanf("%d",&N);
    REP(i,N)scanf("%lld",s+i);
    int res=0,ans=0;
    map<P,P> memo;
    REP(i,N){
        LL now=s[i];
        LL key=1;
        LL rev=1;
        for(auto &d:p){
            if(now%d==0){
                int cnt=0;
                while(now%d==0){
                    now/=d;
                    cnt++;
                }
                cnt%=3;
                REP(j,cnt)key*=d;
                cnt=(3-cnt)%3;
                REP(j,cnt)rev*=d;
            }
        }
        if(q.count(now)){
            key*=now;
            rev*=q[now];
        }else{
            key*=now;
            rev*=now*now;
        }
        if(key==1)
            ans=1;
        else{
            if(key<=rev)
                memo[P(key,rev)].fi++;
            else memo[P(rev,key)].se++;
        }
    }
    for(auto &it:memo){
        //printf("%lld %lld:%lld %lld\n",it.fi.fi,it.fi.se,it.se.fi,it.se.se);
        res+=max(it.se.fi,it.se.se);
    }
    printf("%d\n",res+ans);
    return 0;
}


Measured memory_bytes: 13568
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let b = read_vec::<usize>();

    let mut sum_a = vec![0; n];
    sum_a[0] = a[0];
    for i in 1..n {
        sum_a[i] = a[i] + sum_a[i - 1];
    }

    let mut sum_b = vec![0; n];
    sum_b[0] = b[0];
    for i in 1..n {
        sum_b[i] = b[i] + sum_b[i - 1];
    }

    let mut ans = a[0] + sum_b[n - 1];
    for i in 1..n {
        ans = max(ans, sum_a[i] + sum_b[n - 1] - sum_b[i - 1]);
    }
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        int ans = solve(n, d);
        System.out.println(ans);
    }

    static int solve(int n, int[] d) {
        Arrays.sort(d);

        int arc = d[n / 2];
        int abc = d[n / 2 - 1];
        return arc - abc;
    }
}


Measured memory_bytes: 51660