akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

string s;

int n,p[67108870],t,ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    n=s.lg; t=0;
    for(int i=0;i<(1<<26);i++){
        p[i]=1e9;
    }
    p[0]=0;
    for(int i=1;i<=n;i++){
        int b=1<<(s[i-1]-'a');
        t^=b;
        ans=p[t]+1;
        for(int i=0;i<26;i++){
            b=t^(1<<i);
            ans=min(ans,p[b]+1);
        }
        p[t]=min(p[t],ans);
        //cout << ans << ' ';
    }
    cout << ans;
}


Measured memory_bytes: 262804
#include<bits/stdc++.h>
#define int long long
using namespace std;
int fl[10000011],prm[10000011],sz=0,spf[10000011],ar[10000011],a2[10000001] ;
void sieve()
{
    int mx=sqrt(10000001) ;
    for(int i = 1 ; i <= 10000001 ; i++) spf[i]=i ;
    fl[1]=1 ; fl[0]=1 ; spf[2]=2 ;
    for(int i = 4 ; i <= 10000001 ; i+=2) {fl[i]=1 ; spf[i]=2 ;}
    for(int i = 3 ; i <= 10000001 ; i+=2)
    {
        if(!fl[i])
        {
            if(i>mx) continue ;
            for(int j=i*i ; j <= 10000001 ; j+=(i*2)) {fl[j]=1 ; if(spf[j]==j) spf[j]=i ;}
        }
    }
    /*for(int i = 1 ; i <= 10000000 ; i++)
    {
        for(int j = i ; j <= 10000000 ; j+=i)
        {
            v[j]
        }
    }*/
}
int32_t main()
{
    sieve() ;
    int n; int ans=0 ; scanf("%lld",&n) ;
    for(int k = 1 ; k <= n ; k++)
    {
       // cout<<k<<endl ;
        int s=1 ;
        int p=k ;
        set<int>st ;
        while(p!=1)
        {
            int x=spf[p] ;
            st.insert(x) ; ar[x]++ ;
            p/=x ;
        }
        for(auto x: st)
        {
            int p=ar[x] ; ar[x]=0 ;
            s*=(p+1) ;
        }
        ans+=(k*s) ;
    }
    printf("%lld\n",ans) ;
}
// 10000000


Measured memory_bytes: 238108
let () =
  let rec charlist_of_string str i n =
    if i = n then [] else str.[i] :: charlist_of_string str (i+1) n in
  Scanf.scanf "%s\n" @@ fun s ->
  let slist = List.fast_sort compare 
      (charlist_of_string s 0 (String.length s)) in
  let str = List.fold_left (fun str c -> str ^ Char.escaped c) "" slist in
  Printf.printf "%s\n"
    (if str.[0] = str.[1] && str.[1] <> str.[2] && str.[2] = str.[3]
     then "Yes" else "No")

Measured memory_bytes: 3744
#include <stdio.h>

int main() {
	int N, M, C, B[20], A, i, j, sum, cnt = 0;

	scanf("%d %d %d", &N, &M, &C);
	for (i = 0; i < M; i++) {
		scanf("%d", &B[i]);
	}
	for (i = 0; i < N; i++) {
		sum = 0;
		for (j = 0; j < M; j++) {
			scanf("%d", &A);
			sum = sum + A * B[j];
		}
		sum = sum + C;
		if (sum > 0) cnt++;
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int N,M;cin>>N>>M;
    UnionFind<int> UF(N,0);
    int L,R,D;
    bool f=true;
    FOR(i,0,M){
        cin>>L>>R>>D;
        L--;R--;
        if(!UF.issame(L,R)){
            UF.merge(L,R,D);
        }else{
            if(D!=UF.diff(L,R)){
                f=false;
                break;
            }else{
                continue;
            }
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, M, K;
vector<ll> Parent;

ll root(ll p){

  ll Pp = Parent[p];

  if(p == Pp)return Pp;

  return Parent[p] = root(Pp);

}

void Unify(ll a, ll b){

  ll Ra = root(a), Rb = root(b);

  if(Ra == Rb)return;

  Parent[Rb] = Ra;

}

int main(){
cin >> N >> M >> K;
Parent.resize(N + 1);
map<ll, ll> S;
vector<ll> Friend(N + 1);
vector<ll> Block(N + 1);

rep(i, 1, N + 1)Parent[i] = i;

rep(i, 0, M){

  ll a , b;cin >> a >> b;

  Unify(a, b);

  Friend[a]++;Friend[b]++;

}

rep(i, 1, N + 1){

  Parent[i] = root(i);

  S[Parent[i]]++;
  
}

rep(i, 0, K){

  ll a , b;cin >> a >> b;

  if(Parent[a] == Parent[b]){Block[a]++;Block[b]++;}

}

rep(i, 1, N + 1){

  cout << S[root(i)] - Friend[i] - Block[i] - 1 << " ";
  
}
}

Measured memory_bytes: 11544
N = int(input())
A = list(map(int, input().split()))

num = [0 for i in range(N)]
for i in range(N, 0, -1):
        q = N // i
        s = A[i - 1]
        for j in range(2, q + 1):
                s += num[i * j - 1]
                s = s % 2
        num[i - 1] = s

M = sum(num)
print(M)

lst = []
for i in range(N):
        if num[i] == 1:
                lst.append(i+1)
print(' '.join(map(str, lst)))

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

int main() {
    int t;
    int ans = 0;
    int maximum = 0;
    for(int i = 0; i < 5; i++)
    {
        cin >> t;
        
        if (t % 10 != 0) {
            maximum = max(maximum, (10 - t % 10));
            ans += t + (10 - t % 10);
        }
        else ans += t;
    }
    cout << (ans - maximum) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n % 1000 == 0)
        cout << 0;
    else
    cout << 1000 - (n % 1000);
}









Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 1e5 + 5;
int n, m, h[M], vis[M];
vector <int> g[M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	for(int i = 0; i < m; i++)
	{
		int u, v;	cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		if(vis[i])	continue;
		int ok = 1;
		for(auto &j : g[i])
		{
			if(h[j] >= h[i])
			{
				ok = 0;
				break;
			}
			else	vis[j] = 1;
		}
		ans += ok;
	}
	cout << ans;
    	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N+1), B(N);
    for(int i = 0; i < N + 1; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    long long cnt = 0;
    for(int i = 0; i < N; i++){
        if(B[i] > A[i]){
            cnt += A[i];
            if(i != N){
                cnt += min(A[i+1], B[i] - A[i]);
                A[i+1] -= min(A[i+1], B[i] - A[i]);
            }
        }else{
            cnt += B[i];
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// #include <bits/stdtr1c++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
 
 
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
 
/// Typedef
typedef long long           ll;
typedef unsigned long       ul;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef vector<ll>          vll;
typedef pair<int,int>       pii;
typedef pair<ll,ll>         pll;
 
#define mt                  make_tuple
#define fbo                 find_by_order
#define ook                 order_of_key
#define UB                  upper_bound
#define LB                  lower_bound
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define SQR(x)              ((x)*(x))
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)

/// Constants
#define MAX                 200005 
#define MOD                 1000000007
#define base                1000000007
#define eps                 1e-9
#define INF                 1<<20    // 2,305,843,009,213,693,952
#define inf                 2000000000       // 536,870,912
#define PI                  acos(-1.0)  // 3.1415926535897932
// #define INF              0x3f3f3f3f3f3f3f3f
// #define inf              0x3f3f3f3f
///string reverse example

int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("C:\\Users\\raiha.DESKTOP-5M3GJRN\\Videos\\Raihan\\input.txt", "r", stdin);
        freopen("C:\\Users\\raiha.DESKTOP-5M3GJRN\\Videos\\Raihan\\output.txt", "w", stdout);
    #endif
    int a,b,c;
    cin>>a>>b>>c;
    if( (a==b && b!=c) || (b==c&&a!=c) || (a==c&&b!=a) )puts("Yes");
    else puts("No");
    #ifdef VAMP
       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 256
//
//  main.cpp
//  B_PictureFrame
//
//  Created by user1 on 2017/05/20.
//  Copyright © 2017年 user1. All rights reserved.
//

#include <iostream>
#include <cstring>
int H, W;
char a[100+ 2][100 + 2];



using namespace std;

void init(){
    for(int h = 0; h<100+2; h++){
        for(int w=0; w<100+2; w++){
            a[h][w] = '0';        }
    }
}

void input(){
    std::cin >> H;
    std::cin >> W;
    
    //入力
    std::string buff;
    int ind = 0;
    //読み捨て
    std::getline(std::cin, buff);
    
   // cout << buff;
    while(std::cin){
        getline(std::cin, buff);
        //Char array's index is offset +1 for head "#".
        strcpy(&(a[ind+1][1]), buff.c_str());
        if(ind >= H) break;
        ind ++;
        
    }
}

void solve(){
    //add "#" head and tail.
    for(int i=0; i<W+2; i++){
        a[0][i] = '#';
        a[H+1][i] = '#';
    }
    
    for(int i=0; i<H+2; i++){
        a[i][0] = '#';
        a[i][W+1] = '#';
    }
}

void show(){
    for(int h = 0; h<H+2; h++){
        for(int w=0; w<W+2; w++){
            printf("%c", a[h][w]);
        }printf("\n");
    }
}

int main(int argc, const char * argv[]) {
    // insert code here...
    init();
    input();
    //show();
    solve();
    show();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n;
  int A[4];
  char S[3];
  for (int i = 0; i < 4; i++)
  {
    A[i] = 0;
  }

  scanf("%d", &n);

  for (int i = 0; i < n; i++)
  {
    scanf("%s", S);
    switch (S[0])
    {
    case 'A':
      A[0]++;
      break;
    case 'W':
      A[1]++;
      break;
    case 'T':
      A[2]++;
      break;
    case 'R':
      A[3]++;
      break;
    default:
      break;
    }
  }

  printf("AC x %d\n", A[0]);
  printf("WA x %d\n", A[1]);
  printf("TLE x %d\n", A[2]);
  printf("RE x %d\n", A[3]);
  return 0;
}

Measured memory_bytes: 1736
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace MaximumProfit
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var value = new List<int>();
            for (var i = 0; i < n; i++) value.Add(int.Parse(ReadLine()));
            var min = value[0];
            var max = value[1] - value[0];
            for (var i = 1; i < n; i++)
            {
                if (value[i] - min > max) max = value[i] - min;
                if (min > value[i]) min = value[i];
            }
            WriteLine(max);
        }
    }
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind treek(N);
    UnionFind treel(N);

    rep(i, K) {
        int  x, y;
        cin >> x >> y;
        treek.unite(x-1, y-1); // xの木とyの木を併合する
    };
    rep(i, L) {
        int  x, y;
        cin >> x >> y;
        treel.unite(x-1, y-1); // xの木とyの木を併合する
    };

    
    vector<P>vec(N);
    rep(i,N){
    vec[i].first=treek.root(i);
    vec[i].second=treel.root(i);
    }
    map<P,ll>M;
    rep(i,N)M[vec[i]]++;
    rep(i,N)cout<<M[vec[i]]<<endl;
    
    return 0;
};


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

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

int main(){
  int n,m;
  cin >> n >> m;

  multiset<ll> a;
  rep(i,n){
    ll g;
    cin >> g;
    a.insert(g);
  }

  rep(i,m){
    ll d;
    d =  *a.rbegin();
    a.erase(a.find(d));
    d = d/2;
    a.insert(d);
  }

  ll ans=0;
  rep(i,n){
    ll d = *a.rbegin();
    a.erase(a.find(d));
    ans+=d;
  }

  cout << ans;
  
}

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

using namespace std;

int main() {
    while(1) {
        int n, a, b, c, x;
        cin >> n >> a >> b >> c >> x;
        if (n == 0) break;
        vector<int> y;
        for (int i = 0; i < n; ++i) {
            int yi;
            cin >> yi;
            y.push_back(yi);
        }

        int i;
        int tmp = 0;
        for (i = 0; i < 10001; ++i) {
            if (x == y[tmp]){
                tmp++;
                if(tmp == n) break;
            }
            x = (a * x + b) % c;
        }

        cout << (i == 10001 ? -1 : i) << endl;
    }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    if(n%2!=0) cout<<0;
    else{
        ll num=n/2,cont=0;
        while(num){
            cont+=num/5; num/=5;
        }
        cout<<min(n/2,cont);
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a==b) cout<<"Draw"<<endl;
	else if(a==1) cout<<"Alice"<<endl;
	else if(b==1) cout<<"Bob"<<endl;
	else if(a>b) cout<<"Alice"<<endl;
	else if(a<b) cout<<"Bob"<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    ll h,w;cin >> h >>w;
    vector<string> g(h);rep(i,h)cin >> g[i];
    vvl seen(h,vl(w));seen[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(g[i][j]=='#')continue;
            if(i+1<h)seen[i+1][j]+=seen[i][j],seen[i+1][j]%=MOD;
            if(j+1<w)seen[i][j+1]+=seen[i][j],seen[i][j+1]%=MOD;
        }
    }
    cout << seen[h-1][w-1] <<endl;
}

Measured memory_bytes: 13028
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void dfs(int cur, vector<vector<int>> edges, vector<bool>& visited, P cut) {
    if (visited[cur]) return;
    visited[cur] = true;
    for (auto e : edges[cur]) {
        if (P(cur, e) == cut || P(e, cur) == cut) continue;

        dfs(e, edges, visited, cut);
    }
}

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

    int N, M;
    cin>>N>>M;
    int e1, e2;
    vector<P> es(M);
    rep(i, M) {
        cin>>e1>>e2; e1--; e2--;
        es[i] = P(e1, e2);
    }
    vector<vector<int>> edges(N);
    rep(i, M) {
        edges[es[i].first].push_back(es[i].second);
        edges[es[i].second].push_back(es[i].first);
    }
    int cnt = 0;
    rep(i, M) {
        vector<bool> visited(N);
        dfs(0, edges, visited, es[i]);
        rep(i, N) {
            if (!visited[i]) {
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>
#include <map>

using namespace std;

int main(){
	int h,n,sum=0;
	
	cin >> h >> n;
	
	vector<int> v(n);
	
	for(int i=0;i<n;i++){
		cin >> v[i];
		sum += v[i];
	}
	
	if(sum >= h)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 640
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
  	n = len(raw_input())
  	temp = ['x' for _ in range(n)]
  	#print(temp)
  	print(''.join(temp))
    #ans = ''.join(temp)
	#print(ans)
    

main()

Measured memory_bytes: 85032
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;
ll n, m, k;

vector<int> mul(vector<int> a, vector<int> b)
{
    vector<int> c(a.size());
    for (int i = 0; i < a.size(); i++)
    {
        c[i] = a[b[i]];
    }
    return c;
}

vector<double> mul(vector<double> a, vector<int> b)
{
    vector<double> c(a.size());
    for (int i = 0; i < a.size(); i++)
    {
        c[i] = a[b[i]];
    }
    return c;
}

vector<int> inq(vector<int> perm, ll k)
{
    if (k == 0)
    {
        vector<int> c;
        for (int i = 0; i < perm.size(); i++) c.push_back(i);
        return c;
    }
    vector<int> l = inq(perm, k / 2);
    if (k % 2) return mul(mul(l, l), perm);
    return mul(l, l);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector<double> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    cin >> m >> k;
    vector<int> perm(n - 1);
    iota(all(perm), 0);
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        x--;
        swap(perm[x - 1], perm[x]);
    }
    vector<int> c = inq(perm, k);
    vector<int> y(n - 1);
    for (int i = 0; i + 1 < n; i++)
    {
        y[i] = x[i + 1] - x[i];
    }
    y = mul(y, c);
    double s = x[0];
    for (int i = 0; i < n; i++)
    {
        printf("%.9f\n", s);
        if (i != n - 1)
            s += y[i];
    }
}


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

using namespace std;

int main(){
  int a, b, c;

  cin >> a >> b >> c;

  cin.ignore();

  int ans;

  if(b + c > a){
    ans = b + c - a;
  } else {
    ans = 0;
  }
  cout << ans << endl;
                 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#include <queue>
#include <unordered_map>
#include <utility>

using namespace std;

int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};

int arrayToState(int s[8]) {
  int state = 0;
  for (int i = 0; i < 8; ++i) {
    state = (state << 3) | s[i];
  }
  return state;
}

void stateToArray(int state, int s[8]) {
  for (int i = 7; i >= 0; --i) {
    s[i] = state & 7;
    state >>= 3;
  }
}

unordered_map<int, int> visited;

void buildMinSwap() {
  int s[8];
  for (int i = 0; i < 8; ++i) {
    s[i] = i;
  }
  int startState = arrayToState(s);
  queue<int> q;
  q.push(startState);
  visited.insert(make_pair(startState, 0));
  int swapCount = 0;
  while (!q.empty()) {
    swapCount++;
    int count = q.size();
    while (count-- > 0) {
      int state = q.front();
      q.pop();
      stateToArray(state, s);
      int i;
      for (i = 0; i < 8; ++i) {
        if (s[i] == 0) {
          break;
        }
      }
      int r = i / 4;
      int c = i % 4;
      for (int d = 0; d < 4; ++d) {
        int nr = r + dr[d];
        int nc = c + dc[d];
        if (nr < 0 || nr > 1 || nc < 0 || nc > 3) {
          continue;
        }
        int j = nr * 4 + nc;
        swap(s[i], s[j]);
        int nextState = arrayToState(s);
        if (visited.find(nextState) == visited.end()) {
          q.push(nextState);
          visited.insert(make_pair(nextState, swapCount));
        }
        swap(s[i], s[j]);
      }
    }
  }
}

int main() {
  //freopen("SevenPuzzle.in", "r", stdin);
  int s[8];
  buildMinSwap();
  while (true) {
    int i;
    for (i = 0; i < 8; ++i) {
      if (scanf("%d", &s[i]) != 1) {
        break;
      }
    }
    if (i < 8) {
      break;
    }
    int state = arrayToState(s);
    int result = visited[state];
    printf("%d\n", result);
  }
  return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  int main()
  {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

      ll n,xorr=0;
      cin>>n;
      vector<ll>a(n);
      for(int i=0;i<n;i++)
        {cin>>a[i];
         xorr=xorr^a[i];
        }
        for(int i=0;i<n;i++)
            cout<<(a[i]^xorr)<<" ";
        cout<<endl;


    return 0;
  }


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

int main() {
  string s;
  cin >> s;
  if (s=="SUN"){
    cout << 7 << endl;
  }
  else if (s=="MON"){
    cout << 6 << endl;
  }
  else if (s=="TUE"){
    cout << 5 << endl;
  }
  else if (s=="WED"){
    cout << 4 << endl;
  }
    else if (s=="THU"){
    cout << 3 << endl;
  }
  else if (s=="FRI"){
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
}

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

int main(){
	int n; cin >> n;
	
	int mi = 1e9;
	for(int i = 1; i < n; i++) {
		std::string A = std::to_string(i);
		std::string B = std::to_string(n - i);
		
		int a = 0, b = 0;
		for(int i = 0; i < A.size(); i++) a += A[i] - '0';
		for(int i = 0; i < B.size(); i++) b += B[i] - '0';
		mi = std::min(mi, a + b);
	}
		
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	vvl dp(n+1,vl(13));
	dp[0][0]=1;
	rep(i,n){
		rep(j,13){
			if(s[i]=='?'){
				rep(k,10){
					dp[i+1][((j*10)+(k))%13]+=dp[i][j];
					dp[i+1][((j*10)+(k))%13]%=MOD;
				}
			}
			else{
				dp[i+1][((j*10)+(s[i]-'0'))%13]+=dp[i][j];
				dp[i+1][((j*10)+(s[i]-'0'))%13]%=MOD;
			}
		}
	}
	cout<<dp[n][5]<<endl;;
}


Measured memory_bytes: 13648
// preparation for N log^2 N

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int[] A = new int[3];
		int sum = 0;
		for (int i = 0; i < A.length; ++i) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		if (sum >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

bool comp_by_first(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
  int N;
  cin >> N;
  auto red = vector<pair<int, int>>(N);
  auto blue = vector<pair<int, int>>(N);
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    red[i] = {a, b};
  }
  REP(i, N) {
    int c, d;
    cin >> c >> d;
    blue[i] = {c, d};
  }
  sort(ALL(red), comp_by_first);
  sort(ALL(blue), comp_by_first);

  int ans = 0;
  auto used_red = vector<bool>(N, false);
  REP(i, N) {
    auto b = blue[i];
    int y_max = -1;
    int y_max_i = -1;
    REP(j, N) {
      auto r = red[j];
      if(b.first > r.first && b.second > r.second) {
        if(y_max < r.second && !used_red[j]) {
          y_max = r.second;
          y_max_i = j;
        }
      }
    }
    if(y_max_i != -1) {
      used_red[y_max_i] = true;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        
        String[] ary = line.split(" ");
        int a = Integer.parseInt(ary[0]);
        int b = Integer.parseInt(ary[1]);
        
        int ansA = a / b;
        int ansB = a % b;
        double ansC = (double)a / (double)b;
        
        
        System.out.print(ansA + " " + ansB + " ");
        System.out.printf("%.5f", ansC);
        System.out.println("");
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main() {
    string s; cin>>s;
    string t = "";
    rep(i,s.size()) t += (i%2==0 ? 'g' : 'p');

    int l=0, w=0;
    rep(i,s.size()) {
        if(s[i] == 'g' and t[i] == 'p') w++;
        else if(s[i] == 'p' and t[i] == 'g') l++;
    }

    cout << w-l << endl;

    return 0;
}

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

int main() {
    int A[3];
  cin >> A[0] >> A[1] >> A[2];
    
    if (22 <= A[0] + A[1] + A[2]) cout << "bust" << endl;
    if (22 > A[0] + A[1] + A[2]) cout << "win" << endl;
    
    
}

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

typedef long long ll;
const int maxn=200010;

ll a[maxn],b[maxn],c[maxn];
ll n;

ll Midfind(ll k)
{
    ll l=0,r=n+1;
    while(l<r-1)
    {
        ll mid=(l+r)/2;
        if(c[mid]>=k)
            r=mid;
        else
            l=mid;
    }
    return r;
}

int main()
{
    //    int n;
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
        cin >> b[i];
    ll sum=0;
    for(int k=1; k<=29; k++)
    {
        ll res=(1<<k)-1;
        for(int i=1; i<=n; i++)
            c[i]=b[i]&res;
        sort(c+1,c+n+1);
        ll cnt=0;
        for(int i=1; i<=n; i++)
            cnt+=n-Midfind((1<<(k-1))-(a[i]&res))+1;
        for(int i=1; i<=n; i++)
            cnt-=Midfind(((1<<k)+(1<<(k-1)))-(a[i]&res))-Midfind((1<<k)-(a[i]&res));
        if(cnt%2)
            sum+=(1<<(k-1));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll k;
   while(cin>>k)
   {
       ll ans =0;
       ll n =7;
       bool flag = false;
       for(ll i=1;i<=k;i++)
       {
           n=n%k;
           if(n==0)
           {
               flag=true;
               ans = i;
               break;
           }
           n=n*10+7;
       }
       if(flag)cout<<ans<<endl;
       else
        cout<<-1<<endl;
   }
}


Measured memory_bytes: 3588
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
L = [[int(i) for i in input().split()][::-1] for _ in range(M)]

A.sort()
L.sort(reverse=True)

cur = 0
ans = 0
for c, b in L:
    while b > 0 and cur < N and A[cur] < c:
        A[cur] = c
        ans += c
        cur += 1
        b -= 1
print(ans + sum(A[cur:]))


Measured memory_bytes: 24004
#include<iostream>

using namespace std;

int main() {
	int num[5];
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (num[i] >= num[j]) {
				int tmp;
				tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}
	for (int i = 0;i<5; i++) {

		if (i != 4) {
			cout << num[i]<<" ";
		}
		else {
			cout << num[i] << endl;
		}
	}
	
}


Measured memory_bytes: 3020
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const double g = 9.8;
const double eps = 1e-10;
const int N = 60;
int n, v, x, y, L[N], B[N], R[N], T[N];
double calc(double vy, double t) {
    return vy * t - g * t * t / 2;
}
int cmp(double lb, double ub, double a) {
    return a < lb + eps ? -1 : a > ub - eps ? 1 : 0;
}
bool check(double qx, double qy) {
    double a = g * g / 4, b = g * qy - v * v, c = qx * qx + qy * qy;
    double d = b * b - 4 * a * c;
    if (d < 0 && d > -eps) d = 0;
    if (d < 0) return false;
    for (int co = -1; co <= 1; co += 2) {
        double t2 = (-b + co * sqrt(d)) / (2 * a);
        if (t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;
        double yt = calc(vy, x / vx);
        if (yt < y - eps) continue;
        bool ok = true;
        for (int i = 0; i < n; i++) {
            if (L[i] >= x) continue;
            if (R[i] == x && y <= T[i] && B[i] <= yt) ok = false;
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));
            int xH = cmp(L[i], R[i], vx * (vy / g));
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0) ok = false;
            if (yL * yR <= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}

void solve() {
    for (int i = 0; i < n; i++) {
        R[i] = min(R[i], x);
    }
    bool ok = check(x,y);
    for (int i = 0; i < n; i++) {
        ok |= check(L[i], T[i]);
        ok |= check(R[i], T[i]);
    }
    puts(ok ? "Yes" : "No");
}

int main() {
    scanf("%d%d%d%d", &n, &v, &x, &y);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d%d", L + i, B + i, R + i, T + i);
    }
    solve();
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

int main()
{
	debugORfast(0,1);
	int n; cin>>n;
	if(n%1000)
		cout<<1000-(n%1000)<<endl;
	else 
		cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int a,b;cin>>a>>b;
	if(a<b){cout<<"a < b"<<endl;}
	if(a>b){cout<<"a > b"<<endl;}
	if(a==b){cout<<"a == b"<<endl;}
	RE;
}


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

template <typename T>
vector<T> make_vector(size_t sz)
{
	return vector<T>(sz);
}

template <typename T, typename... U>
auto make_vector(size_t sz, U... tails)
{
	return vector<decltype(make_vector<T>(tails...))>(sz, make_vector<T>(tails...));
}

template <typename T>
void fill_vector(vector<T> &v, T init)
{
	fill(v.begin(), v.end(), init);
}

template <typename T, typename U>
void fill_vector(vector<U> &vec, T init)
{
	for (auto &&v : vec)
	{
		fill_vector<T>(v, init);
	}
}

int main()
{
	string s;
	int64_t k;
	cin >> s >> k;

	int64_t n = s.size();

	auto dp = make_vector<int64_t>(n + 1, 2, 4);
	fill_vector<int64_t>(dp, 0);

	dp[0][1][0] = 1;

	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = 0; j < 2; j++)
		{
			for (int64_t l = 0; l <= 3; l++)
			{
				int64_t lim = j ? (s[i] - '0') : 9;
				for (int64_t d = 0; d <= lim; d++)
				{
					if (l + (d != 0) <= 3)
					{
						dp[i + 1][j && (d == lim)][l + (d != 0)] += dp[i][j][l];
					}
				}
			}
		}
	}

	cout << (dp[n][0][k] + dp[n][1][k]) << endl;

	return 0;
}

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

vector<bool> reachable(int from, int to, string& s) {
  int n = s.size();
  vector<bool> can(n);
  can[from]=true;
  repeat(i,from+1,to+1) {
    if(i-1>=0&&i-1<n) {
      if(can[i-1]&&s[i]=='.')
	can[i]=can[i-1];
    }
    if(i-2>=0&&i-2<n) {
      if(can[i-2]&&s[i]=='.')
	can[i]=can[i-2];
    }
  }
  return can;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d>>s;
  a--;
  b--;
  c--;
  d--;
  vector<bool> ra = reachable(a,c,s);
  vector<bool> rb = reachable(b,d,s);
  if(c<d) {
    if(ra[c]&&rb[d]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if(ra[c]&&rb[d]) {
      rep(i,n-2) {
	if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'&&ra[i]&&rb[i+1]&&ra[i+2]) {
	  cout << "Yes" << endl;
	  return 0;
	}
      }
      cout << "No" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	REP(i,9)REP(j,9)cout << i+1 << "x" << j+1<< "=" << (i+1)*(j+1) << endl;
	return 0;
}

Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {
	
	int[][] array;

	public static void main(String[] args) {
		Main main = new Main();
		Scanner in = new Scanner(System.in);
		String first;
		String second;
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			first = in.next();
			second = in.next();
			//System.out.printf("First: %s, Second: %s\n", first, second);
			main.fillArray(first, second);
			//main.printArray();
		}

	}
	
	public void startArray(String first, String second) {
		array = new int[first.length() + 1][second.length() + 1];
		array[0][0] = 0;
		for (int i = 1; i <= first.length(); i++)
			array[i][0] = 0;
		for (int i = 1; i <= second.length(); i++)
			array[0][i] = 0;
	}
	
	public void fillArray(String first, String second) {
		startArray(first, second);
		for (int i = 1; i <= first.length(); i++) {
			for (int j = 1; j <= second.length(); j++)
				fillSpot(first, second, i, j);
		}
		System.out.println(array[first.length()][second.length()]);
	}
	
	public void fillSpot(String first, String second, int i, int j) {
		int hightest = (array[i-1][j] > array[i][j-1])? array[i-1][j] : array[i][j-1];
		String firstLetter = first.substring(i-1, i);
		String secondLetter = second.substring(j-1, j);
		//System.out.printf("Pair: (%s, %s) \n", firstLetter, secondLetter);
		if (firstLetter.equals(secondLetter)) {
			array[i][j] = array[i-1][j-1] + 1;
		} else {
			array[i][j] = hightest;
		}
		
	}
	
	public void printArray() {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[0].length; j++) {
				System.out.print(array[i][j] + " ");
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 545032
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
for i in range(n):
    dic[input()] += 1
n = int(input())
for i in range(n):
    dic[input()] -= 1
m = sorted([i for i in dic.values()])[-1]
if m >= 0:
    print(m)
else:
    print(0)

Measured memory_bytes: 3444
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var p int
	var s string
	ac := make(map[int]struct{})
	wa := make(map[int]int)
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &s)
		if s == "AC" {
			ac[p] = struct{}{}
		} else if _, o := ac[p]; !o {
			wa[p]++
		}
	}

	pen := 0
	for i, v := range wa {
		if _, o := ac[i]; o {
			pen += v
		}
	}
	fmt.Println(len(ac), pen)
}

Measured memory_bytes: 8064