akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);
using cMatrixRepEdges=std::vector<std::vector<int>>;
pair<vector<int>,int> solve_by_EdmondsKarp_helper(const cMatrixRepEdges& ResidualNetwork,int source,int sink){
	if(ResidualNetwork.empty())return make_pair(vector<int>(),0);

	vector<bool> IsVisit(ResidualNetwork.size(),false);
	vector<int> Parents(ResidualNetwork.size(),-1);
	queue<pair<int,int>> Q;
	Q.push(make_pair(source,INT_MAX));
	IsVisit[source]=true;

	int ans=0;
	while(!Q.empty()){
		auto now=Q.front();
		Q.pop();
		if(now.first==sink){
			ans=now.second;
			break;
		}

		for(int i=0;i<ResidualNetwork.size();++i){
			if(ResidualNetwork[now.first][i]>0 && !IsVisit[i]){
				IsVisit[i]=true;
				Parents[i]=now.first;
				Q.push(make_pair(i,min(now.second,ResidualNetwork[now.first][i])));
			}
		}
	}

	return make_pair(Parents,ans);
}
cMatrixRepEdges solve_by_EdmondsKarp(const cMatrixRepEdges& FlowNetwork,int source,int sink){
	if(FlowNetwork.empty() || source<0 || FlowNetwork.size()<=source || sink<0 || FlowNetwork.size()<=sink)return cMatrixRepEdges();

	cMatrixRepEdges ResidualNetwork=FlowNetwork;
	cMatrixRepEdges AnsFlow(FlowNetwork.size(),vector<int>(FlowNetwork.size(),0));

	while(1){
		auto ans=solve_by_EdmondsKarp_helper(ResidualNetwork,source,sink);
		//source??????sink???????????????????????????????????£???
		if(ans.first[sink]<0)break;

		int to=sink;
		int from=ans.first[sink];
		while(to!=source){
			if(FlowNetwork[from][to]>0){
				AnsFlow[from][to]+=ans.second;
				ResidualNetwork[from][to]=FlowNetwork[from][to]-AnsFlow[from][to];
				ResidualNetwork[to][from]=AnsFlow[from][to];
			}
			else{
				AnsFlow[to][from]-=ans.second;
				ResidualNetwork[to][from]=FlowNetwork[to][from]-AnsFlow[to][from];
				ResidualNetwork[from][to]=AnsFlow[to][from];
			}

			to=from;
			from=ans.first[from];
		}
	}

	return AnsFlow;
}


int main() {
	int N,M;
	cin>>N>>M;
	cMatrixRepEdges Edges(N,vector<int>(N,0));
	for(int i=0;i<M;++i){
		int u,v,w;
		cin>>u>>v>>w;

		Edges[u][v]=w;
		//Edges[u].push_back(v);
	}

	auto ans=solve_by_EdmondsKarp(Edges,0,N-1);
	
	int flow=0;
	for(const auto& val:ans[0]){
		flow+=val;
	}

	for(int i=0;i<N;++i){
		flow-=ans[i][0];
	}

	cout<<flow<<endl;

	//system("pause");
	return 0;
}

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

int main(){
	int w,n;
	cin >> w>> n;
	vector<int> num(w);
	for(int i=0; i<w; i++) num[i]=i+1;
	
	for(int i=0; i<n; i++){
		int a,b;
		scanf("%d,%d", &a, &b);
		swap(num[a-1], num[b-1]);
	}
	for(int i=0; i<w; i++){
		cout << num[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string[] strInputArray = Console.ReadLine().Split(' ');
            double[] inputArray = Array.ConvertAll<string, double>(strInputArray, delegate(string value) { return double.Parse(value); });
            double d = Math.Floor(inputArray[0] / inputArray[1]);
            double r = inputArray[0] % inputArray[1];
            double f = inputArray[0] / inputArray[1];
            Console.WriteLine(d + " " + r + " " + f.ToString("0.00000"));
            Console.ReadLine();
        }
    }


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

using namespace std;
#define ll long long
int main()

{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
   
    int i;
    string s;
    cin>>s;
    int flag=0;
    for(i=1;i<s.length();i++){
    	if(s[i]==s[i-1]){
    		flag=1;
    		break;
    	}
    }
    if(flag)cout<<"Bad";
    else cout<<"Good";

   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A[10];

signed main(){
	REP(i,5){
		cin>>A[i];
		if(A[i]==0){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}


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

int main() {
  long long int a,b,c,d,e,f,answer=0;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    if(a%2==0){
      cout<<"-1"<<endl;
      return 0;
    }
    cout<<"0"<<endl;
    return 0;
  }
  while(a%2==0&&b%2==0&&c%2==0){
    d=(a+b)/2;
    e=(b+c)/2;
    f=(c+a)/2;
    a=d;
    b=e;
    c=f;
    answer++;
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;

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

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

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xと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]++;
    }
  }

  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, m;
  cin >> n >> m;
  UnionFind u(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    u.unite(a, b);
  }

  int size = 0;
  vector<int> tree(n, 0);
  for (int i = 0; i < n; i++) {
    tree[u.root(i)]++;
  }

  size = n - count(tree.begin(), tree.end(), 0);

  cout << size - 1 << endl;
}

Measured memory_bytes: 4520
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n, k = map(int, input().split())
    a = sorted(map(int, input().split()))
    print(sum(a[:k]))

main()


Measured memory_bytes: 65332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  bool p=false, w=false, g=false, y=false;
  for(int i=0; i<N; i++){
    string x;
    cin >> x;
    if(x == "P")
      p = true;
    if(x == "W")
      w = true;
    if(x == "G")
      g = true;
    if(x == "Y")
      y = true;
  }
  
  int num = 0;
  if(p)
    num++;
  if(w)
    num++;
  if(g)
    num++;
  if(y)
    num++;
  
  if(num == 3){
    cout << "Three" << endl;
  }
  if(num == 4){
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
ll A[100000];
ll C[100000];
ll QL[100000];
ll QR[100000];
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll t = mod_pow(a, n / 2);
		return (t*t) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
int main() {
	string S;
	cin >> S;
	int N = S.size();
	A[0] = (S[0] == 'A');
	QL[0] = (S[0] == '?');
	for (int i = 1; i < S.size(); i++) {
		A[i] = A[i - 1] + (S[i] == 'A');
		QL[i] = QL[i - 1] + (S[i] == '?');
	}
	C[N - 1] = (S[N - 1] == 'C');
	QR[N - 1] = (S[N - 1] == '?');
	for (int i = S.size() - 2; i >= 0; i--) {
		C[i] = C[i + 1] + (S[i] == 'C');
		QR[i] = QR[i + 1] + (S[i] == '?');
	}
	ll ans = 0;
	for (int i = 1; i + 1 < S.size(); i++) {
		if (S[i] != 'B' && S[i] != '?') continue;
		ll t = A[i - 1] * C[i + 1];
		(t *= mod_pow(3, QL[i - 1] + QR[i + 1])) %= MOD;
		(ans += t) %= MOD;
		if (QR[i + 1]) {
			t = A[i - 1] * QR[i + 1];
			(t *= mod_pow(3, QL[i - 1] + QR[i + 1] - 1)) %= MOD;
			(ans += t) %= MOD;
		}
		if (QL[i - 1]) {
			t = QL[i - 1] * C[i + 1];
			(t *= mod_pow(3, QL[i - 1] + QR[i + 1] - 1)) %= MOD;
			(ans += t) %= MOD;
		}
		if (QL[i-1] && QR[i + 1]) {
			t = QL[i - 1] * QR[i + 1];
			(t *= mod_pow(3, QL[i - 1] + QR[i + 1] - 2)) %= MOD;
			(ans += t) %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ll;
typedef std::pair<int, int> P;
 
#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back
 
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 200010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n, k; cin >> n >> k;
	int a[MAX] = {};
	rep(i, n){
		int tmp; cin >> tmp;
		a[tmp] += 1;
	}
	ll sum = 0;
	rep(i, MAX) sum += a[i];
	sort(a, a + MAX, greater<int>());
	rep(i, k) sum -= a[i];
	cout << sum << END;
}
 
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

int main()
{
  int n,k,ans;
  k=1;
  cin>>n;
  ans=n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
  }
  for(int i=0;i<n;i++)
  {
    if(a.at(i)==k)
    {
      ans--;
      k++;
    }
  }
  if(k!=1)
    cout<<ans<<endl;
  else
    cout<<"-1"<<endl;
}

Measured memory_bytes: 3972
#include<stdio.h>
#define MAX 100001
#define NIL -1
typedef struct{
  int parent;
  int left;
  int right;
}node;
void setdepth(int,int);
int getdepth(int);
void printchildren(int);
void print(int);

int n,D[MAX];
node T[MAX];

int main(){
  int k,i,j,c,p,l,num;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d",&num);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&p);
      if(j==0)T[num].left=p;
      else T[l].right=p;
      l=p;
      T[p].parent=num;
    }
  }
  for(i=0;i<n;i++){
  D[i]=getdepth(i);
}
    for(i=0;i<n;i++){
     print(i);
    }
  return 0;
}

/*void setdepth(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)setdepth(T[u].right,p);
  if(T[u].left!=NIL)setdepth(T[u].left,p+1);

}*/
int getdepth(int u){
  int d=0;
  while(T[u].parent!=NIL){
    u=T[u].parent;
    d++;
  }
  return d;
}

void printchildren(int u){
  int c,x=0;
  c=T[u].left;
  printf(" [");
  while(c!=NIL){
    if(x!=0)printf(", ");
    printf("%d",c);
    c = T[c].right;
    x=1;
  }
  printf("]\n");
}
void print(int u){
  printf("node %d: parent = %d, depth = %d,",u,T[u].parent,D[u]);

  if(T[u].parent==NIL)printf(" root,");
  else if(T[u].left==NIL)printf(" leaf,");
  else printf(" internal node,");

  printchildren(u);
}



Measured memory_bytes: 3260
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        if (a[s] != -1 && a[s] != c) {
            cout << -1;
            return;
        }
        a[s] = c;
    }
    
    if ((n == 1 && a[0] == -1)) {
        cout << 0;
        return;
    }
    if ((n > 1 && !a[0])) {
        cout << -1;
        return;
    }
    if (a[0] == -1) a[0] = 1;
    for (int i : a) cout << (i == -1 ? 0 : i);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#define SF scanf
#define PF printf
#define MAXN 300010
using namespace std;
typedef long long ll;
int n;
ll L,ans,x[MAXN],t[MAXN];
pair<int,int> s[MAXN];
stack<int> q[2];
bool del[MAXN];
int main(){
    SF("%d%lld",&n,&L);
    for(int i=0;i<n;i++)
        SF("%lld",&x[i]);
    for(int i=0;i<n;i++){
        SF("%lld",&t[i]);
        ans+=(t[i]/(2ll*L))*2ll*L;
        t[i]%=(2ll*L);
    }
    //PF("[%lld]",ans);
    bool flag=0;
    for(int i=0;i<n;i++){
        if(t[i]!=0){
            flag=1;
            if(t[i]<=2ll*(L-x[i]))
                s[i].first=0;
            else
                s[i].first=1;
            if(t[i]<=2ll*x[i])
                s[i].second=0;
            else
                s[i].second=1;
        }
        else{
            s[i].first=s[i].second=1;
        }
    }
    for(int i=0;i<n;i++)
        if(s[i].first==1&&s[i].second==1){
            del[i]=1;
            if(t[i]!=0)
                ans+=2ll*L; 
            //PF("********(%lld %lld)******",t[i],x[i]);
        }
    for(int i=0;i<n-1;i++){
        if(del[i]==1)
            continue;
        if(s[i].first==0&&s[i].second==1){
            if(!q[1].empty()){
                del[q[1].top()]=1;
                del[i]=1;
                q[1].pop();
                ans+=2ll*L;
            }
            else if(!q[0].empty()){
                del[q[0].top()]=1;
                del[i]=1;
                q[0].pop();
                ans+=2ll*L;
            }
        }
        else if(s[i].second==0){
            q[s[i].first].push(i);
        }
    }
    while(!q[1].empty())
        q[1].pop();
    while(!q[0].empty())
        q[0].pop();
    //PF("{%lld}",ans);
    for(int i=0;i<n-1;i++){
        if(del[i]==1||(s[i].first==0&&s[i].second==1))
            continue;
        if(s[i].first==0){
            if(!q[1].empty()){
                del[i]=1;
                del[q[1].top()]=1;
                q[1].pop();
                ans+=2ll*L;
            }
            else if(!q[0].empty()){
                del[i]=1;
                del[q[0].top()]=1;
                q[0].pop();
                ans+=2ll*L;
            }
            else
                q[0].push(i);
        }
        else
            q[1].push(i);
    }
    if(s[n-1].first==0&&del[n-1]==0){
        for(int i=0;i<n-1;i++)
            if(del[i]==0&&s[i].second==0){
                del[i]=1;
                del[n-1]=1;
                ans+=2ll*L;
                break;
            }
    }
    /*for(int i=0;i<n;i++)
        PF("[%d %d %d]\n",s[i].first,s[i].second,del[i]);
    PF("{%lld}",ans);*/
    ll res=0,sum=0;
    for(int i=0;i<n;i++)
        if(del[i]==0)
            sum++;
    if(del[n-1]==0){
        if(s[n-1].first==1&&s[n-1].second==0)
            res=sum+1;
        else
            res=sum;
    }
    if(del[n-1]==1)
        res=sum+1;
    ans+=res*2ll*L;
    PF("%lld",ans);
} 


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

int main(){
  string str;
  int q;
  cin >> str;
  cin >> q;
  while(q--){
    string s;
    cin >> s;
    if(s == "print"){
      int a, b;
      cin >> a >> b;
      cout << str.substr( a, b - a + 1) << endl;
    } else if(s == "reverse"){
      int a, b;
      cin >> a >> b;
      reverse( str.begin() + a, str.begin() + b + 1);
    } else {
      int a, b;
      string p;
      cin >> a >> b >> p;
      str.replace( a, b - a + 1, p);
    }
  }
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
using Graph = vector<vector<int>>;

int main() {

    int n; cin >> n;
    int u, k;

    Graph G(n+1);
    for ( int i = 1; i <= n; ++i ) {
        cin >> u >> k;
        for ( int j = 1; j <= k; ++j ) {
            int a;
            cin >> a;
            G[i].push_back(a);
            //G[b].push_back(a);
        }
    }

    /*for ( int i = 1; i <= n; ++i ) {
        for ( int ax : G[i] ) {
            cout << ax ;
        }
        cout << endl;
    }*/

    vector<int> dist(n+1,-1);
    queue<int> que;

    dist[1] = 0;
    que.push(1);

    while ( !que.empty() ) {
        int v = que.front();
        que.pop();

        for ( int nv : G[v] ) {
            if ( dist[nv] != -1 ) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    for ( int i = 1; i <= n; ++i ) {
        cout << i << " " << dist[i] << endl; 
    }
}


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

using namespace std;

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

typedef pair<int, int> ii;

int n;

string s;

void bye() {
    cout << "-1\n";
    exit(0);
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> s;
    n = s.length();
    s = "+" + s;
    if(s[1] == '0')
        bye();
    if(s[n] == '1')
        bye();
    for(int i = 1; i <= n - 1; i++) {
        if(s[i] != s[n - i])
            bye();
    }
    cout << "1 2\n";
    int pter = 3, lmao = 2;
    for(int i = 2; i <= n - 1; i++) {
        if(s[i] == '1') {
            cout << lmao << " " << pter << "\n";
            lmao = pter;
            pter++;
        }
        else {
            cout << lmao << " " << pter << "\n";
            pter++;
        }
    }
}


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

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

    //I don't care about anybody, and fuck ratings! I'll go to google!
    ll a, b, count = 0; cin>>a>>b;
    a = __gcd(a, b);
    for(ll i = 2; i*i<=a; i++){
        if(a%i==0){
            count++;
            while(a%i==0) a /= i;
        }
    }
    if(a>1) count++;

    cout<<count+1<<"\n";
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
K = {i: 0 for i in range(1, M+1)}

for i in range(N):
    row = list(map(int, input().split()))
    for j in range(1, row[0]+1):
        K[row[j]] += 1

result = [1 for i in range(1, M+1) if K[i] == N]
print(sum(result))

Measured memory_bytes: 3064
import java.util.*

fun main(vararg args: String) {
    val scanner = Scanner(System.`in`)
    val input = scanner.nextInt()

    calc(input, mutableListOf(), 1)
}

fun calc(input: Int, list: MutableList<Int>, count: Int) {
    if (list.contains(input)) {
        println(count)
        return
    }

    list.add(input)
    calc(newValue(input), list, count + 1)
}

fun newValue(input: Int): Int {
    return if (input % 2 == 0) { input / 2 } else { input * 3 + 1}
}

Measured memory_bytes: 31264
<?php
fscanf(STDIN, '%d', $row);
fscanf(STDIN, '%d', $col);
fscanf(STDIN, '%d', $goal);
$now = 0;
$ans = 0;
while($now < $goal) {
    $now += max($row, $col);
    $ans++;
}
echo $ans;

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

#include <atcoder/all>
using namespace std;
using ll = long long;
using ld = long double;

namespace my {
/*汎用*/
template <typename T>
void input_vec(vector<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

/*整数*/
ll gcd(ll a, ll b) {  // O( log(max(a,b)) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(max(a,b)) )
ll modinv(ll n, ll mod) {                               // O( log(max(n,mod)) )
  assert(mod > 0 && my::gcd(n, mod) == 1);
  n %= mod;
  if (n < 0) n += mod;
  ll a = mod, b = n, x = 1, y = 0;
  while (b != 0) {
    ll q = a / b, r = a % b;
    a = b;
    b = r;
    y -= q * x;
    swap(x, y);
  }
  y %= mod;
  if (y < 0) y += mod;
  return y;
}

bool is_prime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> prime_factorize(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}

/*union find*/
class unionfind {
 private:
  /*根のparの値は「-(その木の要素数)」とする*/
  ll n_;
  vector<ll> par;

  ll root(ll a) {  // O( log(n) )
    if (par.at(a) < 0)
      return a;
    else {
      par.at(a) = root(par.at(a));  //経路圧縮
      return par.at(a);
    }
  }

 public:
  unionfind(ll n) : n_(n), par(n, -1) {}  // O(n)

  void unite(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    if (root(a) == root(b))
      return;
    else {
      ll ra = root(a), rb = root(b);
      if (-par.at(ra) < -par.at(rb)) swap(ra, rb);  //サイズによる併合
      par.at(ra) += par.at(rb);
      par.at(rb) = ra;
    }
  }

  bool is_same(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    return root(a) == root(b);
  }

  ll size(ll a) {  // O( log(n) )
    assert(0 <= a && a < n_);
    return -par.at(root(a));
  }
};
}  // namespace my
////////////////////////////////////////////////

int main() {
  int n, m;
  cin >> n >> m;
  atcoder::dsu uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    uf.merge(--a, --b);
  }
  set<int> hoge;
  for (int i = 0; i < n; i++) {
    hoge.insert(uf.leader(i));
  }
  cout << hoge.size() - 1 << endl;
}

Measured memory_bytes: 7588
#include<bits/stdc++.h>
#define forr(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 = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n - i; j++) {
            if(i * 10000 + j * 5000 + 1000* (n - i - j) == y) {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
             }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
total = 0
saidai = -9999
#累積和の最大値を定義します
ans = 0
B = [0]*(len(A)+1)
#Bは累積和のリスト
for i in range(len(A)):
    total += A[i]
    B[i+1] = total
    #A[i]までの合計をB[i+1]へ
for j in range(N-K+1):
     if B[j+K]-B[j]>saidai:
      #最大値比較
            saidai = B[j+K]-B[j]
            P = A[j:j+K]
          #最大値比較をしたとき、スライスをとる
for i in range(len(P)):
    ans += (0.5*P[i]*(P[i]+1))/P[i]
    #スライスをとったところの期待値を計算
print(ans)

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

int main() {
int n, c;
cin >> n >> c;
vector<vector<int>> d(c, vector<int> (c));
for (int i = 0; i < c; i++) {
for (int j = 0; j < c; j++) {
cin >> d[i][j];
}
}

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

vector<vector<int>> cost(3, vector<int> (c));

for (int cc = 0; cc < c; cc++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int s = (i + j) % 3;
cost[s][cc] += d[a[i][j] - 1][cc];
}
}
}

int best = 1000000000;
for (int c1 = 0; c1 < c; c1++) {
for (int c2 = 0; c2 < c; c2++) {
for (int c3 = 0; c3 < c; c3++) {
if (c1 != c2 && c2 != c3 && c1 != c3) {
best = min(best, cost[0][c1] + cost[1][c2] + cost[2][c3]);
}
}
}
}

cout << best << endl;

return 0;
}

Measured memory_bytes: 1280
using System;

class MainClass
{
    public static void Main()
    {
        int width = 10;
        int height = 15;
        int n = int.Parse(Console.ReadLine());
        string[] infoArray = new string[n];
        string[,] allArray = new string[height, width];

        //Init allArray, infoArray
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                if ((i + 1) % 4 == 0)
                {
                    allArray[i, j] = "##";
                }
                else
                {
                    allArray[i, j] = " 0";
                }
            }
        }

        //Decide infoArray
        for (; n > 0; n--)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int[] nums = Array.ConvertAll(inputs, int.Parse);
            int b = nums[0], f = nums[1], r = nums[2], v = nums[3];
            int i = (b * 4 - 4) + f - 1;
            int j = r - 1;
            infoArray[n - 1] = i + " " + j + " " + v;
        }

        //Caluc v
        for (int i = 0; i < infoArray.Length; i++)
        {
            int[] xyArray = Array.ConvertAll(infoArray[i].Split(' '), int.Parse);
            int allArrayV = int.Parse(allArray[xyArray[0], xyArray[1]]);
            allArrayV += xyArray[2];
            allArray[xyArray[0], xyArray[1]] = " " + allArrayV.ToString();
        }

        //Display allArray
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                Console.Write(allArray[i, j]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld,ll> P;
bool node[605][605]={0};
ll edge_num[605]={0};
ld dp[605]={0};
priority_queue<P> pque[605];
ld solve(ll n){
  ld kdp[605]={0};
  bool used[605];
  for(int i=n;i>=1;i--) used[i]=false;
  used[n]=true;
  for(int i=n;i>1;i--){
    for(int j=1;j<=n;j++){
      if(node[j][i]){
        if(!used[i]) return 17441744;
        ld cos=(kdp[i]+(ld)(1))/(ld)edge_num[j];
        kdp[j]+=cos;
        used[j]=true;
      }
    }
  }
  return (used[1]?kdp[1]:17441744);
}
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<605;i++){
    for(int j=0;j<605;j++) node[i][j]=false;
  }
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    node[a][b]=true;
    edge_num[a]++;
  }
  bool used[605];
  for(int i=1;i<=n;i++) used[i]=false;
  used[n]=true;
  for(int i=n;i>1;i--){
    for(int j=1;j<=n;j++){
      if(node[j][i]&&used[i]){
        ld cos=(dp[i]+(ld)(1))/(ld)edge_num[j];
        pque[j].push(P(cos,i));
        dp[j]+=cos;
        used[j]=true;
      }
    }
  }
  ld ans=dp[1];
  for(int i=1;i<=n;i++){
    if(pque[i].empty()) continue;
    P p=pque[i].top();
    ll break_edge=p.second;
    edge_num[i]--;

    node[i][break_edge]=false;
    ld kans=solve(n);
    ans=min(ans,kans);
    node[i][break_edge]=true;
    edge_num[i]++;
  }
  cout<<fixed;
  cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 8576
#include<stdio.h>
int main(void)
{
	int a;
	scanf("%d",&a);
	if(a==25){
		printf("Christmas\n");
	}
	else if(a==24){
		printf("Christmas Eve\n");
	}
	else if(a==23){
		printf("Christmas Eve Eve\n");
	}
	else{
		printf("Christmas Eve Eve Eve\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;

class Main {

	public static final int MAX = 200000;

	public static void main(String[] args) throws IOException {


		for(int i =1; i<10; i++){
			for(int j =1; j<10; j++){

				System.out.println(i+"x"+j+"="+i*j);

			}
		}


	}

}

Measured memory_bytes: 23988
#include <stack>
#include <string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>


using namespace std;

const int MAXN = 100 + 10;
int A[MAXN];

int main() {
	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> A[i];

	sort(A, A + n);
	int cnt = 0;
	int j = 0;
	while (x > 0) {
		if (j == n) break;
		if (x >= A[j]) {
			x -= A[j];
			j++;
			cnt++;
		}
		else {
			break;
		}
	}
	if (x > 0 && j == n) cnt--;
	cout << cnt << endl;
	return 0;
}

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

#define print(n) cout  << n << "\n"

int main() {
	int i, j , k;
	cin >> i >> j >> k;
	if ((i *100 + j*10 + k) % 4 == 0) {
		print("YES");
	}else {
		print("NO");
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int k;
	cin >> k;
	if (k % 2 == 0) {
		cout << (k / 2)*(k / 2) << endl;
	}
	else {
		cout << (k / 2)*(k / 2 + 1) << endl;
	}

	return 0;
}



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

int main()
{
    int a;
    cin >> a;
    int ans=0;
    ans = a;
    ans+=a*a;
    ans+=a*a*a;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main() {
    int k, s;
    cin >> k >> s;

    int res = 0;
    rep(x, 0, k + 1) rep(y, 0, k + 1) {
        int z = s - x - y;
        if (0 <= z && z <= k) res++;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class team{
public:
	char name;
	int w;
	int l;
	
	bool operator <(const team arg) const{
		if(w == arg.w){
			return l < arg.l;
		}
		return w > arg.w;
	}
};

int main(void){
	int n;
	while(cin >> n && n){
		team t;
		vector<team> v;
		char c;
		int tmp;
		
		for(int j=0;j<n;j++){
			cin >> c;
			t.name = c;
			t.w = 0;
			t.l = 0;
			
			for(int i=0;i<n-1;i++){
				cin >> tmp;
				if(tmp == 0) t.w++;
				if(tmp == 1) t.l++;
			}
			v.push_back(t);
		}
		sort(v.begin(),v.end());
		
		for(int i=0;i<n;i++) cout << v[i].name << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
string a,b[1000],d;
int c[1000];
int main(){
	int top=0;
	d=" ";
	while(cin>>a){
		for(int i=0;i<a.size();i++)
			a[i]=tolower(a[i]);
		if(a.size()>=d.size())
			d=a;
		bool t=true;
		for(int i=0;i<top;i++){
			if(b[i]==a){
				t=false;
				c[i]++;
			}
		}
		if(t==true){
			b[top]=a;
			c[top]=1;
			top++;
		}
	}
	int best=0,set;
	for(int i=0;i<top;i++){
		if(c[i]>best){
			set=i;
			best=c[i];
		}
	}
	cout<<b[set]<<" "<<d<<endl;
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdint-intn.h>
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    Int x; cin >> x;
    Int rest = 100;
    Int ans = 0;
    while(rest < x) {
        ans++;
        rest *= 1.01;
    }
    println(ans);

    return 0;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 2e9 + 1;
const LL LINF = 1e12;
const LL MAXN = 5e3 + 1;
const LD EPS = 1e-6;

int h;
int w;
int d;
VCH A = { 'R', 'Y', 'G', 'B' };

inline void get(int i, int j)
{
	int kvadrat_x = i % (2 * d);
	int kvadrat_y = (j + 2*d*w) % (2 * d);
	kvadrat_x /= d;
	kvadrat_y /= d;

	cout << A[kvadrat_x * 2 + kvadrat_y];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> h >> w >> d;
	
	FOR(i, 0, h)
	{
		FOR(j, 0, w)
			get(i + j, i - j);

		cout << endl;
	}

	cin >> w;
	return 0;
}

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

lint n, m, v, p;
vector<lint> a;

// a[i]をp位以内にできるか
bool check(lint cand) {
    lint modi = a[cand] + m;
    if (modi < a[n - p]) {
        return false;
    }
    lint l = cand + 1, r = n - p + 1;
    lint limit = 0;
    for (int i = l; i < r; i++) {
        limit += min(m, modi - a[i]);
    }
    return limit >= (v - l - n + r) * m;
}

int main() {
    cin >> n >> m >> v >> p;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    lint ok = n - 1, no = -1;
    while (abs(ok - no) > 1) {
        lint mid = (ok + no) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            no = mid;
        }
    }
    cout << n - ok << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define F first
#define S second
#define inf (long long) 1e18
#define f(i,n)  for(int i=0;i<n;i++)
#define f(i,n) for(int i=n-1;i>=0;i--)
#define f(i,n) for(int i=1;i<=n;i++)

const int MOD = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int arr[n];
    int s=0,c=0;
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
        s+=arr[i];
    }
    int avg=s/n;
    for(int i=0;i<n;i++)
    {
        int k=avg-arr[i];
        c+=k*k;
    }
    int c1=0;
    for(int i=0;i<n;i++)
    {
        int k=avg+1-arr[i];
        c1+=k*k;
    }
    cout << min(c,c1);
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n;
  cin >> n;
  unordered_map<string, int> m;
  rep(i,n) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}


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

// traduções

// even -> par
// odd -> impar
// west -> oeste

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-12
const double PI = acos(-1.0);

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define FILL(a,v) memset(a, v, sizeof a)

// bitmask operations
#define SETBIT(S, j) S |= (1 << j)
#define CLEARBIT(S, j) S &= ~(1 << j)
#define ISSET(S, j) S & (1 << j)
#define FLIPBIT(S, j) S ^= (1 << j)
#define LSBIT(S) (S & (-S))

// debug
#define DEBUGSTR(S) cout << "(" << S << ")\n";

int tranform(int i, int j, int M) {
    return j + M*i;
}

class UFDS {
private:
    vi size, ps;
    int numSets;

public:
    UFDS(int N) : size(N + 1, 1), ps(N + 1), numSets(N) {
        iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x) {
        return x == ps[x] ? x : (ps[x] = find_set(ps[x]));
    }

    bool same_set(int x, int y) {
        return find_set(x) == find_set(y);
    }

    int getMax() {
        int maior = -1;
        int sz = size.size();
        for(int i = 0; i < sz; ++i)
            maior = max(maior, sizeOfSet(i));
        
        return maior;
    }

    int sizeOfSet(int i) { return size[find_set(i)]; }

    int numDisjointSets() const { return numSets; }

    void union_set(int x, int y) {
        int p = find_set(x), q = find_set(y);

        if(p == q)
            return;
        
        numSets--;

        if (size[p] < size[q])
            swap(p, q);

        ps[q] = p;

        size[p] += size[q];
    }
};

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N, M;
    scanf(" %d %d", &N, &M);

    UFDS UF(N);

    REP(i, 0, M) {
        int a, b;
        scanf(" %d %d", &a, &b);

        UF.union_set(a, b);
    }

    printf("%d\n", UF.getMax());

    return 0;
}


Measured memory_bytes: 4824
package main
import (
  "fmt"
  "strings"
)
func main() {
  var s string
  fmt.Scan(&s)
  s = strings.Replace(s,"BC","D",-1)
  n := len(s)
  x := make([]int,n)
  for i:=0;i<n;i++ {
    switch s[i:i+1] {
      case "B","C": x[i] = -1
      case "A": x[i] = 1
    }
  }
  var m,a int
  for i:=0;i<n;i++ {
    switch x[i] {
      case -1: a = 0
      case 0: m += a
      case 1: a++
    }
  }
  fmt.Println(m)
}

Measured memory_bytes: 3840
import java.util.*;

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

     public void execute() {
         Scanner sc = new Scanner(System.in);
         int s = sc.nextInt();
         List<Integer> a = new ArrayList<>();
         for (int i = 2; i <= 1000000; i++) {
             a.add(s);
             s = f(s);
             if (a.contains(s)) {
                 System.out.println(i);
                 return;
             }
         }
     }

     private int f(int n) {
         if (n % 2 == 0) {
             return n / 2;
         } else {
             return 3 * n + 1;
         }
     }
 }

Measured memory_bytes: 23252
#B
a, b, k = list(map(int,input().split()))
s = a
t = b
if k >= 0:
    if  a > 0:
        if k > a:
            a = 0
            k = k -s
        else:
            a = a-k
            k = 0
    if b > 0:
        if k >= 0:
            if k > b:
                b = 0
            else:
                b = b-k
print(a,b)

Measured memory_bytes: 3064
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll l , r;
	re(l,r);
	if(r - l >= 2019)
	{
		cout << 0 << "\n";
		return 0;
	}
	ll x1 = LONG_MAX, x2 = 0;
	vector < pair<ll,ll> > v, v1; 
	for(ll i = l; i+1<=r; i++)
	{
		for(int j= i+1 ; j<=r; j++)
		{
			x1 = min(x1,i*j % 2019); 
		}
	}
	cout <<x1 <<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<int> t(q), f(q);
  vector<char> c(q);

  int rev = 1;

  string front, back;
  for(int i = 0; i < q; i++){
    cin >> t[i];
    if(t[i] == 1){
      rev *= -1;
    }else{
      cin >> f[i] >> c[i];
      if(rev == 1){
        if(f[i] == 1){
          front += c[i];
        }else{
          back += c[i];
        }
      }else{
        if(f[i] == 2){
          front += c[i];
        }else{
          back += c[i];
        }
      }
    }
  }
  reverse(front.begin(), front.end());

  //cout << front << "\n";

  string ans = front + s + back;

  //cout << ans << "\n";

  if(rev == -1){
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3140
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N, M, C;
	cin >> N >> M >> C;
	vector<i64> B(M);
	for (auto& v : B)
	{
		cin >> v;
	}

	i64 ans = 0;
	REP(i, N)
	{
		i64 calc = C;
		REP(j, M)
		{
			i64 a;
			cin >> a;
			calc += a * B[j];
		}
		if (calc > 0)
			++ans;
	}

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

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

ans = 0

for i in range(n):
    x, y = map(int, list(input().split()))
    z = math.sqrt(x ** 2 + y ** 2)
    if z <= d:
        ans += 1
print(ans)


Measured memory_bytes: 9176