akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        const long mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            int[] st = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = st[0];
            int m = st[1];
            var ls = new List<MyClass>();
            for (int i = 0; i < m; i++)
            {
                var input = ReadLine().Split();
                ls.Add(new MyClass(int.Parse(input[0]), input[1]));
            }
            var sortedLS = ls.OrderBy(x => x.p).ToList();
            int WAans = 0;
            int ACans = 0;
            int WA = 0;
            int targetP = -1;
            bool seen = false;
            foreach (var item in sortedLS)
            {
                if (targetP != item.p)
                {
                    WA = 0;
                    seen = false;
                }
                if (item.s == "AC" && seen == false)
                {
                    WAans += WA;
                    ACans++;
                    seen = true;
                }

                targetP = item.p;
                WA++;
            }
            WriteLine(
                ACans + " " + WAans
                );
        }
        class MyClass
        {
            public MyClass(int p, string s)
            {
                this.p = p;
                this.s = s;
            }

            public int p { get; set; }
            public string s { get; set; }
        }
    }
}

Measured memory_bytes: 30384
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;


struct Dscc {
public:

	//belongs,newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;

	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id]) {
				dfs2(i, num, edges);
			}
		}
		unis[id] = num;
		return;
	}


}dscc;

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<string>sts;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			sts.push_back(st);
		}
		bool ok = true;
		vector<vector<int>>edges(26);
		for (int i = 0; i < N - 1; ++i) {
			string from = sts[i];
			string to = sts[i + 1];
			
			if (to.find(from) == 0) {
				continue;
			}
			else if(from.find(to)==0){
				ok = false;
				break;
			}
			else {
				int num = 0;
				while (1) {
					if (from[num] == to[num]) {

					}
					else {
						edges[from[num] - 'a'].push_back(to[num] - 'a');
						break;
					}
					num++;
				}
			}
		}
		if (ok) {
			auto pa=dscc.get(edges);
			if (pa.first.size() == 26) {

			}
			else {
				ok = false;
			}
		}
		if (ok) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>

#define NMAX 100001
using namespace std;

int DP[NMAX][4], initial[NMAX][4], n, p;

void read(){
    cin >> n;
    for(int i = 1; i <= n ; i++){
        for(int j = 0; j <= 2; j++){
            cin >> initial[i][j];
        }
    }
}

void solve(){
    for(int i = 0; i <= 2; i++)
        DP[1][i] = initial[1][i];

    for(int i = 1; i <= n - 1; i++){
        for(int j = 0; j <= 2; j++){
            DP[i+1][(j+1) % 3] = max(DP[i][j] + initial[i+1][(j+1)%3], DP[i+1][(j+1)%3]);
            DP[i+1][(j+2) % 3] = max(DP[i][j] + initial[i+1][(j+2)%3], DP[i+1][(j+2)%3]);
            //DP[i+1][(j+3) % 3] = max(DP[i][j] + initial[i+1][(j+3)%3], DP[i+1][(j+3)%3]);

        }
    }

    int maxx = 0;
    for(int i = 0; i <= 2; i++){
        if(maxx < DP[n][i])
            maxx = DP[n][i];
    }
    cout << maxx;
}

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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int> > s(m);
    vector<int> p(m);

    rep(i, 0, m) {
        cin >> k[i];
        rep(j, 0, k[i]) {
            int input_s;
            cin >> input_s;
            s[i].push_back(input_s);
        }
    }
    rep(i, 0, m) cin >> p[i];

    int ans = 0;
    
    rep(i, 0, (1<<n)) {
        vector<bool> switches(n);
        //cout << "switches: ";
        rep(j, 0, n) {
            switches[j] = (i >> j) & 1;
            //cout << switches[j] << " ";
            //switches.push_back((i >> j) & 1);
            //cout << ((j << i) & 1) << " ";
            //cout << ((i >> j) & 1) << " ";
        }
        //cout << endl;

        rep(j, 0, m) {
            int cnt = 0;
            rep(l, 0, k[j]) {
                cnt += switches[s[j][l]-1];
            }
            if(p[j] != cnt%2) {
                j = m;
            }
            if(j == m-1) {
                ans++;
            }
        }
        //cout << "ans: " << ans << endl;
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	string str1,str2;
	cin>>str1>>str2;
	for (register int i=0;i<3;++i) {
		if (str1[i]!=str2[2-i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int p,q,r,s,t,u,i,j,n;
	scanf("%d",&n);
	int a[n],b[n],c[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
		scanf("%d",&c[i]);
	}
	int dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0];
	dp2[0]=b[0];
	dp3[0]=c[0];
	for(i=1;i<n;i++)
	{
		p=a[i]+dp2[i-1];
		q=a[i]+dp3[i-1];
		r=b[i]+dp1[i-1];
		s=b[i]+dp3[i-1];
		t=c[i]+dp1[i-1];
		u=c[i]+dp2[i-1];
		if(p>q)
			dp1[i]=p;
		else
			dp1[i]=q;
		if(r>s)
			dp2[i]=r;
		else
			dp2[i]=s;
		if(t>u)
			dp3[i]=t;
		else
			dp3[i]=u;
	}
	int max;
	if(dp1[n-1]>=dp2[n-1] && dp1[n-1]>dp3[n-1])
		max=dp1[n-1];
	else if(dp2[n-1]>dp1[n-1] && dp2[n-1]>dp3[n-1])
		max=dp2[n-1];
	else
		max=dp3[n-1];
	printf("%d",max);
	return 0;
}
	
	

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

#define REP(i,n) for(int i=0;i<n;i++)
#define INF 999999999

using namespace std;

int main()
{
    string n;
    cin >> n;
    long ans = 0;
    int l = n.size();
    REP(i, 1 << (l-1)) {
        int now = i;
        long t = 0;
        int wait = 0;
        REP(j, l) {
            if(now == 0 ){
                t += stol(n.substr(j));
                break;
            }
            if(now % 2 == 0){
                now = now / 2;
            }else {
                t += stol(n.substr(wait,j-wait+1));
                wait = j+1;
                now = now / 2;
            }
        }
        ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split('\n')[0].split(' ').map(v => ~~v)
  let d = input.pop()

  if (Math.abs(input[0] - input[1]) <= d && Math.abs(input[1] - input[2]) <= d) console.log('Yes')
  else if (Math.abs(input[0] - input[2]) <= d) console.log('Yes')
  else console.log('No')
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        if ("ABC".equals(S)) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
int a,b;
void solve()
{
    if (a+b==15) cout<<"+";
    else if (a*b==15) cout<<"*";
    else cout<<"x";
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 1e6;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

int n;
int q;

string s;

ll pref[3][MAX_N];

ll ask(int t, int l, int r)
{
    if (l >= n)
    {
        return 0;
    }
    l = max(l, 0);
    r = min(r, n - 1);
    if (l == 0)
    {
        return pref[t][r];
    }
    else
    {
        return pref[t][r] - pref[t][l - 1];
    }
}

ll query(ll k)
{
    ll res = 0;
    ll cnt = 0;
    ll curAns = 0;
    for (int i = 0; i < n; ++i)
    {
        int last = i - k;
        if (last >= 0)
        {
            if (s[last] == 'D')
            {
                curAns -= ask(1, last + 1, i - 1);
                cnt--;
            }
        }
        if (s[i] == 'D')
        {
            cnt++;
        }
        if (s[i] == 'M')
        {
            curAns += cnt;
        }
        if (s[i] == 'C')
        {
            res += curAns;
        }
    }
    return res;
}

int solve()
{
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; ++i)
    {
        pref[0][i] = (i == 0 ? 0 : pref[0][i - 1]);
        pref[1][i] = (i == 0 ? 0 : pref[1][i - 1]);
        pref[2][i] = (i == 0 ? 0 : pref[2][i - 1]);
        if (s[i] == 'D')
        {
            pref[0][i]++;
        }
        else if (s[i] == 'M')
        {
            pref[1][i]++;
        }
        else if (s[i] == 'C')
        {
            pref[2][i]++;
        }
    }
    cin >> q;
    for (int i = 1; i <= q; ++i)
    {
        ll k;
        cin >> k;
        cout << query(k) << endl;
    }
    return 0;
}




Measured memory_bytes: 24860
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	string a, b;
	cin >> a >> b;

	for(unsigned i = 0;i < a.size();i++){
		cout << a[i];
		if(i < b.size()) cout << b[i];
	}
	cout << endl;

	rtn 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e2) + 9;
const int M = (1e4) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;



void solve()
{
	ll a, b, c, d, g, x, y;
	cin >> a >> b >> c >> d;
	if(a < b || d < b)
	{
		cout << "No\n";
		return;
	}
	a %= b;
	if(a > c)
	{
		cout << "No\n";
		return;
	}
	if(c > b)
	{
		if(d >= b)
			cout << "Yes\n";
		else
			cout << "No\n";
		return;
	}
	g = gcd(b,d);
	
	x = (c-a) / g;
	y = a + (x+1LL)*g;
	if(y < b)
	{
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL

using namespace std;
using llong = long long;


int main()
{
	IOS;

	string s;
	cin >> s;
	if (s[1] == 'R') cout << "ABC";
	else cout << "ARC";

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

char s[20];

int main()
{
    scanf("%s", s);
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define LL long long
#define CLR(a, b) memset(a, b, sizeof(a))

using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 30;
char ch[maxn][maxn];
int cnt[maxn][maxn], len[maxn];
int dp[1 << 14][15][15];
bool vis[maxn];

bool ok(int a, int b, int k)
{
    for(int i = 0; i < k; i ++)
    {
        if(ch[a][len[a] - k + i] != ch[b][i]) return false;
    }
    return true;
}

void init(int n)
{
    CLR(cnt, 0);CLR(vis, false);
    for(int i = 0; i < n; i ++)
    {
        for(int j = 0; j < n; j ++)
        {
            if(i != j)for(int k = min(len[i], len[j]); k; k --)
            {
                if(ok(i, j, k))
                {
                    cnt[i][j] = k;
                    break;
                }
            }
//            printf("%d %d %d\n", i, j, cnt[i][j]);
        }
    }
    for(int i = 0; i < n; i ++)
    {
        for(int j = 0; j < n; j ++) if(i != j)
        {
            if(strstr(ch[i], ch[j]))
            {
                vis[j] = true;
            }
        }
    }
    for(int i = 0; i < n; i ++)
    {
        dp[1 << i][i][i] = len[i];
    }
}

int main()
{
    int n;
    while(scanf("%d", &n), n)
    {
        for(int i = 0; i < n; i ++)
            scanf("%s", ch[i]), len[i] = strlen(ch[i]);//, printf("%d  %d\n", i, len[i]);
        CLR(dp, INF);init(n);
        for(int i = 0; i < (1 << n); i ++)
        {
            for(int s = 0; s < n; s ++) if(1 & (i >> s))
            {
                if(vis[s]) continue;
                for(int k = 0; k < n; k ++) if(1 & (i >> k))
                {
//                    printf("%d %d %d %d\n", i, k, s, dp[i][k][s]);
                    if(vis[k]) continue;
                    for(int j = 0; j < n; j ++) if(!((1 << j) & i))
                    {
                        if(vis[j]) continue;
                        dp[i|(1<<j)][j][s] = min(dp[i|(1<<j)][j][s], dp[i][k][s] + len[j] - cnt[j][k]);
                        dp[i|(1<<j)][k][j] = min(dp[i|(1<<j)][k][j], dp[i][k][s] + len[j] - cnt[s][j]);
//                        if(i == 3 && k == 0 && s == 1 && j == 2)
//                        {
//                            printf("%d %d %d\n", dp[3][0][1], cnt[1][2], len[2]);
//                            printf("%d  %d  ~~%d\n", dp[i][k][s] + len[j] - cnt[s][j], dp[i|(1<<j)][k][j], i|(1<<j));
//                        }
                    }
                }
            }
        }
        int ans = INF;
//        cout << (1 << n) - 1 << endl;
        int nn = (1 << n) - 1;
        for(int i = 0; i < n; i ++) if(vis[i]) nn ^= (1 << i);
        for(int i = 0; i < n; i ++)
            for(int j = 0; j < n; j ++)
                ans = min(dp[nn][i][j], ans);//, printf("%d %d !!! %d\n", i, j, dp[(1 << n) - 1][i][j]);
        printf("%d\n", ans);
    }
}

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

int main(){
  int r,D;
  vector<int> x(2010);
  cin >> r >> D >> x[1999];
  for(int i=1999;i<2009;i++){
  	x[i+1]=r*x[i]-D;
  }
  for(int i=2000;i<=2009;i++){
  	cout << x[i] << endl;
  }
}

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

static class NagataKanaIsAGenius {
    public static void Main() {
        int[]ks=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int k=ks[0];
        int s=ks[1];
        int ans=0;
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(0<=s-i-j&&s-i-j<=k)ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
import sys
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
h = IL()

for i in range(1,N):
  if h[i]-h[i-1] >= 1:
    h[i] -= 1
  elif h[i] == h[i-1]:
    continue
  else:
    print("No")
    exit()
else:
  print("Yes")

Measured memory_bytes: 63984
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif






int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int n, m; std::cin >> n >> m;
    atcoder::dsu UF(n);
    while(m--){
        int u, v; std::cin >> u >> v; --u; --v;
        UF.merge(u, v);
    }
    std::cout << UF.groups().size() - 1 << '\n';
    
    return 0;
}

Measured memory_bytes: 9004
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();
		int b=n.nextInt();
		if (a>b) System.out.println("a > b");
		if (a<b) System.out.println("a < b");
		if (a==b) System.out.println("a == b");
	}

}

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

int main(void) {
  ll N;
  cin >> N;
  char S[N][N];
  REP(i, 0, N) REP(j, 0, N) cin >> S[i][j];

  ll ans = 0;
  REP(k, 0, N) {
    bool ok = true;
    REP(i, 0, N) REP(j, 0, N) {
      ll nj = (i - k + N) % N, ni = (j + k) % N;
      ok = ok && S[i][j] == S[ni][nj];
    }
    if(ok) ans += N;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1 << 17;
struct Segt {
	ll sum[N << 1], add[N << 1];
	Segt() {
		memset(sum, 0, sizeof sum);
		memset(add, 0, sizeof add);
	}
	void pd(int i, int l) {
		if (add[i]) {
			sum[i] += add[i] * l;
			if (i < N) {
				add[i + i] += add[i];
				add[i + i + 1] += add[i];
			}
			add[i] = 0;
		}
	}
	void upd(int i, int a, int b, int l, int r, int v) {
		if (l <= a && b <= r) {
			add[i] += v;
			pd(i, b - a); return;
		}
		pd(i, b - a);
		if (r <= a || b <= l) return;
		int md = (a + b) >> 1;
		upd(i + i, a, md, l, r, v);
		upd(i + i + 1, md, b, l, r, v);
		sum[i] = sum[i + i] + sum[i + i + 1];
	}
	ll qry(int i, int a, int b, int l, int r) {
		pd(i, b - a);
		if (l <= a && b <= r) return sum[i];
		if (r <= a || b <= l) return 0;
		int md = (a + b) >> 1;
		ll L = qry(i + i, a, md, l, r);
		ll R = qry(i + i + 1, md, b, l, r);
		return L + R;
	}
} segt;
int n, m;
int a[N];
int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0; i < n; ++ i) cin >> a[i], -- a[i];
	ll tot = 0;
	for (int i = 0; i + 1 < n; ++ i) {
		if (a[i] < a[i + 1]) {
			tot += a[i + 1] - a[i];
			segt.upd(1, 0, N, a[i] + 2, a[i + 1] + 1, 1);
			segt.upd(1, 0, N, a[i + 1] + 1, a[i + 1] + 2, -(a[i + 1] - a[i] - 1));
		} else {
			tot += m - a[i] + a[i + 1];
			segt.upd(1, 0, N, a[i] + 2, m, 1);
			segt.upd(1, 0, N, 0, 1, m - a[i] - 1);
			segt.upd(1, 0, N, 1, a[i + 1] + 1, 1);
			segt.upd(1, 0, N, a[i + 1] + 1, a[i + 1] + 2, -(m - a[i] + a[i + 1] - 1));
		}
//		for (int j = 0; j < m; ++ j) cerr << segt.qry(1, 0, N, 0, j + 1) << " "; cerr << endl;
	}
	cerr << tot << endl;
	ll mx = 0;
	for (int i = 0; i < m; ++ i) {
		ll cur = segt.qry(1, 0, N, 0, i + 1);
//		cerr << i << ": " << cur << endl;
		mx = max(mx, cur);
	}
	cout << tot - mx << endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
 #define LIMIT 30

struct Puzzle{
  int cont[9];
  int space;
  string path;
  bool operator < ( const Puzzle &p ) const{
    for ( int i = 0; i < 8; i++ ){
      if ( cont[i] == p.cont[i] ) continue;
      return cont[i] > p.cont[i];
    }
    return false;
  }
};

int limit;
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char direction[4] = {'d', 'r', 'u', 'l'};

bool isTarget(Puzzle puzzle){
  for ( int i = 0; i < 9; i++ ){
    if ( puzzle.cont[i] != 1 + i ) return false;
  }
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while( !Q.empty() ){
    u = Q.front(); Q.pop();
    if ( isTarget(u) ){
      return u.path;
    }

    int sx, sy, tx, ty;
    sx = u.space/3;
    sy = u.space%3;

    for ( int r = 0; r < 4; r++ ){
      tx = sx + dx[r];
      ty = sy + dy[r];
      if ( tx < 0 || ty < 0 || tx >= 3 || ty >= 3 ) continue;
      v = u;
      swap(v.cont[u.space],v.cont[tx*3+ty]);
      v.space = tx*3+ty;
      if ( !V[v] ){
	V[v] = true;
	v.path += direction[r];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

main(){
  Puzzle in;
  for ( int i = 0; i < 9; i++ ){
    cin >> in.cont[i];
    if ( in.cont[i] == 0 ) {
      in.cont[i]=9;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  
}



Measured memory_bytes: 30460
def main():
    H, W, K = map(int, input().split())
    S = [list(map(int,list(input()))) for _ in range(H)]
    
    ans = float('inf')
    for i in range(1<<H-1):
        cut = []
        for j in range(H):
            if (i >> j) & 1:
                cut.append(j+1)

        tmp_S = [[0] * W for _ in range(len(cut) + 1)]
        tmp_id = 0
        for i in range(H):
            if i in cut:
                tmp_id += 1
            for j in range(W):
                tmp_S[tmp_id][j] += S[i][j]
        
        isOK = True
        for i in range(len(cut) + 1):
            for w in range(W):
                if tmp_S[i][w] > K:
                    isOK = False

        if not isOK:
            continue

        cnt = len(cut)
        white = [0] * (len(cut)+1)

        flag = False
        for w in range(W):
            for i in range(len(cut) + 1):
                white[i] += tmp_S[i][w]
                if white[i] > K:
                    cnt += 1
                    flag = True
                    break
            if flag:
                for i in range(len(cut) + 1):
                    white[i] = tmp_S[i][w]
                flag = False
        ans = min(ans, cnt)

    print(ans)

                


if __name__ == "__main__":
    main()

Measured memory_bytes: 46044
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=0; i<n; i++) cin>>b[i];
    for (int i=0; i<n; i++) cin>>c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    int64 ans = 0;
    for (int i=0; i<n; i++) {
        auto it1 = lower_bound(a.begin(), a.end(), b[i]);
        auto it2 = upper_bound(c.begin(), c.end(), b[i]);

        ans += (int64)(it1 - a.begin()) * (c.end() - it2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{   speed_up;
    int m, n, i, j, k, l;
    cin>>n>>m;
    vector<string> a(n), b(m);
    for(i = 0; i<n; i++)
    {
        cin>>a[i];
    }
    for(j = 0; j<m; j++)
    {
        cin>>b[j];
    }
    for(i = 0; i<n; i++)
    {
        for(j = 0; j<n; j++)
        {
            if(a[i][j]!= b[0][0]) continue;
            bool x = 1;
            for(k = 0; k<m; k++)
            {
                for(l = 0; l<m; l++)
                {
                    if(i+k>=n || j+l>=n || a[i+k][j+l]!=b[k][l])
                    {
                        x = 0;
                        break;
                    }
                }

            }
             if(x)
                {
                    puts("Yes");
                    return 0;
                }

        }
    }
    puts("No");
    return 0;
}







Measured memory_bytes: 3624
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

su = 0
N = int(input())
for i in range(1,N+1):
    for j in range(i+1,N+1):
        for k in range(j+1,N+1):
            su += gcd(i,j,k)
su *= 6
for x in range(1,N+1):
    for y in range(1,N+1):
        if x != y:
            su += 3*(gcd(x,y))
        else:
            su += x
print(su)


Measured memory_bytes: 9632
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;





signed main() {
	speed;
	int k, n;
	cin >> k >> n;
	vector<int> a, b;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (x > k / 2) {
			b.pb(k-x);
		}
		else {
			a.pb(x);
		}
	}
	sort(all(a));
	sort(rall(b));
	int mx = 0, p = 0;
	for (int i = 1; i < b.size(); ++i) {
		mx = max(b[i - 1] - b[i], mx);
	}
	if (!b.empty()) {
		p = -b.back();
	}
	for (int i = 0; i < a.size(); ++i) {
		mx = max(a[i] - p, mx);
		p = a[i];
	}
	if (!b.empty() && !a.empty()) {
		mx = max(mx,k - b[0] - a.back());
	}
	cout << k - mx;
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

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

vector<LDP> v;
vector<int> dir;
ld calc(ld t) {
	ld xmi = INF, xma = -INF;
	ld ymi = INF, yma = -INF;
	rep(i, v.size()) {
		ld nx = t * dx[dir[i]] + v[i].first;
		ld ny = t * dy[dir[i]] + v[i].second;
		xmi = min(xmi, nx);
		xma = max(xma, nx);
		ymi = min(ymi, ny);
		yma = max(yma, ny);
	}
	return (xma - xmi)*(yma - ymi);
}
void solve() {
	int n; cin >> n; v.resize(n); dir.resize(n);
	vector<ld> u, d, l, r;
	ld xmi = INF, xma = -INF;
	ld ymi = INF, yma = -INF;
	rep(i, n) {
		ld x, y; cin >> x >> y;
		v[i] = { x,y };
		char t; cin >> t;
		if (t == 'L') {
			dir[i] = 1;
			l.push_back(x);
			ymi = min(ymi, y);
			yma = max(yma, y);
		}
		else if (t == 'R') {
			dir[i] = 0;
			r.push_back(x);
			ymi = min(ymi, y);
			yma = max(yma, y);
		}
		else if (t == 'U') {
			dir[i] = 2;
			u.push_back(y);
			xmi = min(xmi, x);
			xma = max(xma, x);
		}
		else {
			dir[i] = 3;
			d.push_back(y);
			xmi = min(xmi, x);
			xma = max(xma, x);
		}
	}
	ld le = 0, ri = mod;
	rep(aa, 200) {
		ld ml = (le * 2 + ri) / 3.0;
		ld mr = (le + ri * 2) / 3.0;
		ld cl = calc(ml);
		ld cr = calc(mr);
		if (cl < cr)ri = mr;
		else le = ml;
	}
	cout << calc(le) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 5776
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int x , y;
  cin >> x >> y;
  string ans = "No";
  for (int i = 0 ; i <= x ; i ++) {
    if ((i * 2 + (x - i) * 4) == y) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

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

int N, M;  
cin >> N >> M;
vector<double> a(N);
rep(i,N){cin >> a.at(i);}

double temp, max;
max = 0.0;

rep (i,M){max += a.at(i);}
temp = max;

rep(i,N-M){
	temp = temp - a.at(i) + a.at(i+M);
  if (temp > max){max = temp;}
  }
double ans = 0.0;
ans +=max + M;
ans /= 2;
  
	cout<<fixed<<setprecision(10)<<ans<<endl;
  

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(std::string S){
    ll ans = 0;
    if(S == "RRR") ans = 3;
    if(S == "RRS" || S == "SRR") ans = 2;
    if(S == "RSS" || S == "SSR" || S == "RSR" ||  S == "SRS") ans = 1;
    if(S == "SSS") ans = 0;
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3624
n = int(raw_input())
a = []
for i in ["S","H","C","D"]:
    for j in xrange(1,14):
        a.append("{0} {1}".format(i,j))
for i in xrange(0,n):
    b = raw_input()
    a.remove(b)
for i in a:
    print i

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


  int main()
  {


       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
    /*  #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
      #endif
	*/

    int row,col,target;
    cin>>row>>col>>target;
    vector<string>nish;
    for(int i=0;i<row;i++)
    {
      string temp;
      cin>>temp;
      nish.push_back(temp);
    }

    long long int ans=0;
    for(int i=0;i<(1<<row);i++)
    {
      for(int j=0;j<(1<<col);j++)
      {
        int count=0;
        for(int i1=0;i1<row;i1++)
        {
          for(int j1=0;j1<col;j1++)
          {
            if((1<<i1 & i) && (1<<j1 & j) && nish[i1][j1]=='#')
              count++;
          }
        }

        if(count==target)
          ans++;

      }
    }


    cout<<ans<<endl;

    return 0;

  }

Measured memory_bytes: 3668
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[500005],g[500005],f(500005,0),b(500005,0),a(500005,0),ans(500005,0);
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli n,q;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    lli c=0,ans=0;
    for(lli i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            c=0;
            while(i<s.size() && s[i]=='R')
            {
                c++;i++;
            }
            ans=max(c,ans);
            i--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 42164
from operator import mul
from functools import reduce
import numpy as np

str_list = input().split(' ')
int_list = [int(x) for x in str_list]

X, Y = int_list[0], int_list[1]
if not (X+Y)%3==0:
    print(0)
    exit()


if X==Y:
    large_count = X//3
    small_count = X//3
else:
    large_count = np.abs(X-Y)
    small_count = int( (X+Y-3*large_count)/3/2 )
    large_count += small_count
#print(large_count, small_count)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(large_count+small_count, small_count, mod)
print(a)


Measured memory_bytes: 130860
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
int s[200010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    cin >> n;
    mem(s);
    for(int i = 1; i < n; i++){
        int x;
        cin >> x;
        s[x]++;
    }
    for(int i = 1; i <= n; i++) cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 4396
args = []
 while l = $stdin.gets
   args.push(l.strip)
 end
 
n = args[0].to_i
a = args[1].split(nil).map(&:to_i)
puts a.join(' ')
1.upto(n - 1) do |i|
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v do
    a[j+1] = a[j]
     j -= 1
  end
  a[j+1] = v
  puts a.join(' ')
end

Measured memory_bytes: 6108
#include <iostream>

using namespace std;

int main()
{
	int x[5];
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0)
			cout << ++i << endl;
	}
	
	return 0;
}

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

int main() {
	ll ans=0,n;
	cin>>n;
	while(cin>>n){
		while(n%2==0){
			ans++;
			n/=2;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/abc051/tasks/abc051_b
K, S = map(int, input().split(' '))
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - (x + y)
        if 0 <= z <= K:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
N=input()
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])
if A+B+C+D==7 :
  print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D==7 :
  print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C+D==7 :
  print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A+B-C-D==7 :
  print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B+C+D==7 :
  print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A-B+C-D==7 :
  print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D==7 :
  print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B-C-D==7 :
  print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")

Measured memory_bytes: 9192
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;
const int MAX_N = 200010;

struct UnionFind {
  vector<int> par;
  int rank[MAX_N] = {0};
  
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++){
      par[i] = i;
    }
  }
  
  int root(int x) {
    if (par[x] == x){
      return x;
    }
    return par[x] = root(par[x]);
  }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
  
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
    }
    if (rank[x] == rank[y]) {
      rank[x]++;
    }
  }
};

int main(int argc, const char * argv[]) {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind road(n);
  UnionFind rail(n);

  map<pair<int, int>, int> a;
  pair<int, int> b[200010];

  for (int i = 0; i < k; i++) {
      int p, q;
    cin >> p >> q;
    road.unite(p -1, q - 1);
  }
  for (int i = 0; i < l; i++) {
    int p, q;
    cin >> p >> q;
    rail.unite(p -1, q - 1);
  }

  for (int i = 0; i < n; i++) {
    b[i].first = road.root(i);
    b[i].second = rail.root(i);
    a[b[i]]++;
  }

  for (int i = 0; i < n; i++) {
    cout << a[b[i]] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 16768
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    c = collections.Counter(a)

    result = sorted(c.values())

    print(sum(result[:len(result)-k]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 34732
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
  quit()
for i in range(a+b+1):
  if i < a:
    if s[i] == "-":
      print("No")
      quit()
  if a < i:
    if s[i] == "-":
      print("No")
      quit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),m=nxtl();
    ll test=min(n,m/2);
    n-=test;
    m-=test*2;
    if(m>0)
    {
        test+=(m/4);
    }
    cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        cout << 'x';
    }
    cout << endl;

    return 0;    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define DUMPV(a) REP(_i, a.size()) printf("%d%c", a[_i], _i + 1 == a.size() ? '\n' : ' ')

const int N_MAX = 1e5;
const int K_MAX = 1e5;

int N, K;
char S[N_MAX + 1];

int M;
vector<int> vs;
vector<int> acc;

void solve() {
  if(S[0] == '0') vs.push_back(0);

  int i = 0;
  while (i < N) {
    char c = S[i];
    int v = 0;
    while(i < N && S[i] == c) {
      v++;
      i++;
    }
    vs.push_back(v);
  }

  if (S[N - 1] == '0') vs.push_back(0);

  int L = 2 * K + 1;
  int M = vs.size();
  if (M <= L) {
    printf("%d\n", N);
    return;
  }

  acc.resize(M + 1, 0);
  REP(i, M) acc[i + 1] = acc[i] + vs[i];

  int ans = 0;
  for (int i = 0; i <= M - L; i += 2) ans = max(ans, acc[i + L] - acc[i]);
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  scanf("%s", S);
}

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


Measured memory_bytes: 1272