akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N, M;
    scanf("%d", &N);
    int D[N];
    for(int i = 0; i < N; ++i) scanf("%d", &D[i]);
    scanf("%d", &M);
    int T[M];
    for(int i = 0; i < M; ++i) scanf("%d", &T[i]);

    if(N < M) { printf("NO\n"); return 0;}

    sort(D, D + N);
    sort(T, T + M);
    int d = 0, t = 0;
    for(t = 0; t < M; ++t) {
        while(d < N && D[d] != T[t]) ++d;
        if(d >= N) break;
        ++d;
    }
    if(t >= M) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;


int main(){
	int n;
	cin>>n;
	vi a(n+1), b(n);
	for (int i = 0; i < n+1; i++){
		cin>>a[i];
	}
	for (int i = 0; i < n; i++){
		cin>>b[i];
	}

	ll sum=0;
	for (int i = 0; i < n; i++){
		int t=min(a[i],b[i]);
		sum+=t;
		b[i]-=t;
		int next=min(a[i+1],b[i]);
		sum+=next;
		a[i+1]-=next;
	}

	cout<<sum<<endl;

	return 0;
}
	

Measured memory_bytes: 1024
n=int(input())
a=[1,2,3,4,5,6,7,8,9,2,4,6,8,10,12,14,16,18,3,6,9,12,15,18,21,24,27,4,8,12,16,20,24,28,32,36,5,10,15,20,25,30,35,40,45,6,12,18,24,30,36,42,48,54,7,14,21,28,35,42,49,56,63,8,16,24,32,40,48,56,64,72,9,18,27,36,45,54,63,72,81]
if n in a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N-1;i+=1)
using namespace std;
int main() {
  int N;
  string S;
  cin>>N;
  cin>>S;
  int count=1;
  rep(i,N) if(S[i]!=S[i+1]) {
    count+=1;
  }
  cout<<count<<endl;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,k;
    cin >> n >> k;
    vector<pair<int,int>> A(n);

    FOR(i,0,n){
        int a,b;
        cin >> a >> b;
        A.pb(mp(b,a));
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    ll cur=0,cc=0;
    bool vis[100005];
    memset(vis,false,sizeof(vis));
    vector<ll> B,C;

    FOR(i,0,n){
        if(i<k){
            cur+=A[i].ff;
            if(!vis[A[i].ss]){
                cc++;
                vis[A[i].ss]=true;
            }else{
                B.pb(A[i].ff);
            }
        }else{
            if(!vis[A[i].ss]){
                C.pb(A[i].ff);
                vis[A[i].ss]=true;
            }
        }
    }
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    reverse(C.begin(),C.end());
    int x=min(B.sz(),C.sz());
    B.resize(x);
    C.resize(x);
    ll res=cur+1LL*cc*cc;

    FOR(i,0,x){
        if(i){
            B[i]+=B[i-1];
            C[i]+=C[i-1];
        }
        res=max(res,cur-B[i]+C[i]+1LL*(cc+i+1)*(cc+i+1));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  // int a = min(x * h, min(y * w, min((w - x) * h, (h - y) * w)));
  double a = w * h / 2;
  cout << fixed << a << endl;
  int b = 0;
  if(y == h / 2 && x == w / 2) b = 1;
  cout << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
max_p = -1

for i in range(n):
    point = sum(A1[:i+1]) + sum(A2[i:])
    max_p = max(max_p, point)
print(max_p)

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string A,B,C; cin >> A >> B >> C;
    char a = A[0] - 32; 
    char b = B[0] - 32; 
    char c = C[0] - 32; 
    cout << a << b << c << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define f(i,n)          for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef tree<pii, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

int32_t main()
{
	g_b();
	int n; cin >> n;
	int ans = 0;
	string s; cin >> s;
	int w = 0, r = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'W')w++;
		else r++;
	}
	for (int i = 0; i < r; i++) if (s[i] == 'W') ans++;
	cout << ans;
	return 0;

}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	cout<<fixed<<setprecision(15);
	double r; cin>>r;
	double ans = 2*3.14159265358979323846*r;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <map>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double h_rad, m_rad;
	h_rad = 2.0 * M_PI* (h + m / 60.0) / 12.0;
	m_rad = 2.0 * M_PI*m / 60.0;
	pair<double, double> hh, mm;
	hh.first = a*sin(h_rad);
	hh.second = a*cos(h_rad);
	mm.first = b*sin(m_rad);
	mm.second = b*cos(m_rad);
	double ans = (hh.first - mm.first)*(hh.first - mm.first) + (hh.second - mm.second)*(hh.second - mm.second);
	ans = sqrt(ans);
	cout << setprecision(15) << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void){
	int S, h = 0, m = 0, s = 0;

	scanf("%d",&S);
	h = S / (3600);
	m =	(S - (h*3600))/60;
	s = S %60;
 	printf("%d:%d:%d\n",h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i]; a[i]--;
	}
	vector<int> b(N); rep(i, 0, N) {
		cin >> b[i]; b[i]--;
	}
	vector<bool> use(N); rep(i, 0, N) {
		use[b[i]] = true;
	}

	bool ok = true;
	rep(i, 0, N) {
		if (use[i] == false) {
			ok = false;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
		vector<int> c(N);
		vector<int> d(N);
		iota(all(c), 1);
		iota(all(d), 1);
		rep(i, 0, N) {
			if (use[i] == false) {
				d[i]++;
				if (d[i] > N)d[i] = 1;
				break;
			}
		}
		cout << c[a[0]]; rep(i, 1, c.size()) { cout << " " << c[a[i]]; } cout << endl;
		cout << d[a[0]]; rep(i, 1, d.size()) { cout << " " << d[a[i]]; } cout << endl;
	}

	return 0;
}


Measured memory_bytes: 4524
s = list(map(int, input().split()))
s.sort()
t1 = s[2]-s[0]
t2 = s[2]-s[1]
if t1 % 2 == 0:
    if t2 % 2 == 0:
        print((t1+t2)//2)
    else:
        print(t1//2 + t2//2 + 2)
else:
    if t2 % 2 == 0:
        print(t1//2 + t2//2 + 2)
    else:
        print((t1+t2)//2)


Measured memory_bytes: 38384
class Array
  def minus(other)
    a = self.dup
    other.each do |i|
      f = false
      a = a.reject{|j| j == i && !f ? f = true : false}
    end
    return a
  end
end

@pattern = (1..7).map{|i| [i,i+1,i+2]} + (1..9).map{|i| [i,i,i]}
def c(arr)
  return true if arr.size == 0
  @pattern.each do |pat|
    if (arr.size - arr.minus(pat).size) == 3
      return true if c(arr.minus(pat))
    end
  end
  return false
end

def get_pairs(arr)
  (1..9).to_a.select { |i| arr.count(i) >= 2 }
end

def keep_rule?(arr)
  return false if (1..9).any?{ |i| arr.count(i) > 4 }
  pair_nums = get_pairs(arr)
  pair_nums.each do |pn|
    rem_arr = arr.minus([pn,pn])
    return true if c(rem_arr)
  end
  return false
end

while gets do
  arr = $_.chomp.chars.map(&:to_i)
  sel = (1..9).to_a.select { |i| keep_rule?(arr+[i]) }
  puts sel.empty? ? '0' : sel * " "
end

Measured memory_bytes: 6700
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
    ld r; cin >> r;
    outl(2 * r * M_PI);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

static int counter(int i) {
    int count = 0;
    while (i > 0) {
        if (i & 1) {
            count++;
        }
        i = i >> 1;
    }
    return count; }

int solve(const int N, const vector<vector<pair<int, int> > > &A) {
    int max = 0;

    for (int bits = 0; bits < 1 << N; bits++) {
        bool b = true;
        for (int i = 0; i < N; i++) {
            if ((bits >> i) & 1) {
                for (int j = 0; j < (int) A[i].size(); j++) {
                    if ((((bits >> A[i][j].first) & 1) && !A[i][j].second)
                            || (!((bits >> A[i][j].first) & 1) && A[i][j].second)) {
                        b = false;
                        goto end;
                    }
                }
            }
        }
end:
        if (b) {
            chmax(max, counter(bits));
        }
    }

    return max;
}

int main(void) {
    int N;
    cin >> N;

    vector<vector<pair<int, int> > > A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            A[i].push_back({x - 1, y});
        }
    }

    cout << solve(N, A) << endl;

    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split('/');
            int year = int.Parse(S[0]);
            int month = int.Parse(S[1]);
            int day = int.Parse(S[2]);
            if (year < 2019)
            {
                Console.WriteLine("Heisei");
            }
            else if (year == 2019 && month < 4)
            {
                Console.WriteLine("Heisei");
            }
            else if (year == 2019 && month == 4 && day < 31)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  vector<P> list(N);
  map<int, unordered_set<int>> exists;
  FOR(i, N) {
    GI2(x, y);
    list[i] = P(x, y);
    exists[x].insert(y);
  }
  ll ans = 1LL << 50;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int p = list[j].first - list[i].first,
          q = list[j].second - list[i].second;
      ll cnt = 0;
      for (P pr : list) {
        if (!exists[pr.first - p].count(pr.second - q)) {
          cnt++;
        }
      }
      ans = min(ans, cnt);
    }
  }
  if (N == 1)
    ans = 1;
  print(ans);
  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    double l;
  cin>>l;
  double ans=(l*l*l)/27;
  cout<<fixed<<setprecision(10)<<ans;
}


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

int main() {
	long x, a, b;
	cin >> x >> a >> b;
	
	int ax = abs(x-a);
	int xb = abs(x-b);
	
	if(ax >= xb) cout << "B";
	else cout << "A";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

char t[200010];

int main(){
  scanf("%s",t);
  int l=strlen(t);
  for(int i=0;i<l;i++){
    if(t[i]=='?'){
      t[i]='D';}}
  //printf("%lu\n",strlen(t));
  printf("%s\n",t);
  
  return 0;
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
int main()
{
  int N, T;
  std::cin >> N >> T;
  int ans = 1001;
  for(int i = 0; i < N; i++){
  	int t, c;
    std::cin >>c>>t;
    if(t <=T){ans=std::min(ans, c);}
  }
  std::cout << (ans==1001?"TLE":std::to_string(ans))<<std::endl;  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    int prev=0, move=0, ans=0;
    rep(i,n) {
        int cur;
        scanf("%d", &cur);
        if (prev >= cur) move++;
        else move=0;
        prev = cur;
        ans = max(ans, move);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[4],b[4],h=0,v=0,i,j;
	while(scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])!=EOF)
	{
		h=v=0;
		scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
		for(i=0;i<4;i++)
			for(j=0;j<4;j++)
			{
				if(i==j && a[i]==b[j])
					h++;
				else if(a[i]==b[j])
					v++;
			}
			printf("%d %d\n",h,v);
	}
	return 0;
}

Measured memory_bytes: 596
N = int(input())
b = list(map(int,input().split()))
l = []
while b:
    for i in range(len(b)-1,-1,-1):
        if b[i] == i + 1:
            del b[i]
            l += i + 1,
            break
    else:
        print(-1)
        exit()
for i in l[::-1]:
    print(i)

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

typedef long long int ll;
ll n, a[200007];

int main() {
    cin >> n;
    for(ll i = 0; i < n; ++i) cin >> a[i];

    ll sum = 0;
    for(ll i = 1; i < n; ++i) {
        if(a[i] < a[i - 1]) {
            sum += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll c[30],s[400][30];
 
int main()
{
	int D;
	cin >> D;
	rep(i,26)
	{
		cin >> c[i];
	}
	rep(i,365)
	{
		rep(j,26)
		{
			cin >>s[i][j];
		}
	}
	rep(i,365)
	{
		cout << 26 - (i%26) << endl;
	}
	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int MAXN=1e5+10;
ll a[MAXN];
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	ll l=2,r=2;
	for (int i=n;i>=1;i--)
	 {
	 	if (r<a[i]) {
	 		printf("%d\n",-1); exit(0);
		 }
		ll t2=r/a[i],t1=(l-1)/a[i];
		if (t2==t1) {
			printf("%d\n",-1); exit(0);
		}   
		l=(t1+1)*a[i]; r=(t2+1)*a[i]-1;
	 }
	printf("%lld %lld\n",l,r); 
}

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

int main() {
  int N;
  cin >> N;
  LL sum = 0;
  for(int i=1; i<=N; ++i) {
    if(i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
} 

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,a,n)	for(int i=a;i<n;i++)
int main(){
	int a,b;
	cin>>a>>b;
	bool can;
	if((a+b)%3==0||a%3==0||b%3==0){
		can=true;
	}
	else{
		can=false;
	}
	if(can==true){
		cout<<"Possible"<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
}

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

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

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        if (n == 3 || n == 5 || n == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32776
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 924844033
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
ll par[214514];
ll rankk[214514];
ll siz[214514];
ll hen[214514];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rankk[i]=0;
		siz[i] = 1;
		hen[i] = 0;
	}
}
ll find(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x==y){
		hen[x]++;
		return;
	}
	if(rankk[x]<rankk[y]){
		par[x]=y;
		siz[y]=siz[x]+siz[y];
		hen[y]=hen[x]+hen[y]+1;
	}else{
		par[y]=x;
		siz[x]=siz[x]+siz[y];
		hen[x]=hen[x]+hen[y]+1;
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
signed main(){
	int n,h,w;
	cin>>n>>h>>w;
	init(h+w+1);
	vector< pair<int, pair<int,int> > > cards;
	for(int i=0;i<n;i++){
		int rpos,cpos,value;
		cin>>rpos>>cpos>>value;
		cards.pb( mp( value, mp( rpos, cpos ) ) );
	}
	sort( cards.begin(), cards.end() );
	reverse( cards.begin(), cards.end() );
	int ans = 0;
	for(int i=0;i<cards.size();i++){
		int r = cards[i].second.first;
		int c = cards[i].second.second + h;
		int v = cards[i].first;
		int pr = find(r);
		int pc = find(c);
		if( pr == pc ){
			int ed = hen[pr];
			int ve = siz[pr];
			if( ve > ed ){
				ans += v;
				unite(r,c);
			}
		}
		else{
			int ed = hen[pr] + hen[pc];
			int ve = siz[pr] + siz[pc];
			if( ve > ed ){
				ans += v;
				unite(r,c);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11380
N = gets.to_i
A = gets.split.map(&:to_i).sort

M = [nil] * A.last
ans = 0
A.each_with_index do |a,i|
    next if M[a]
    ans += 1 if a!=A[i+1]
    a.step(M.size,a){|m| M[m]=true}
end

puts ans

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

int main(){
  int t=4280;
  while(1){
    int n;
    cin>>n;
    if(n==-1){
      break;
    }
    if(n<=10){
      cout<<t-1150<<endl;
    }
    else if(n<=20){
      cout<<t-1150-(n-10)*125<<endl;
    }
    else if(n<=30){
      cout<<t-1150-1250-(n-20)*140<<endl;
    }
    else{
      cout<<t-1150-1250-1400-(n-30)*160<<endl;
    }
  }
}


Measured memory_bytes: 3080
import itertools
n, a, b, c = map(int ,input().split())
ln = [int(input()) for _ in range(n)]

ans = 10**10
for l in itertools.product([0, 1, 2, 3], repeat = n):
    if 1 in l and 2 in l and 3 in l:
        count = [0] * 3
        total = [0] * 3
        for i, li in enumerate(l):
            if li != 0:
                count[li-1] += 1
                total[li-1] += ln[i]
        cost = 0
        cost += abs(a - total[0]) + 10 * (count[0] - 1)
        cost += abs(b - total[1]) + 10 * (count[1] - 1)
        cost += abs(c - total[2]) + 10 * (count[2] - 1)
        if ans > cost:
            ans = cost
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
#define mul(x,y) ((long long)(x)*(y)%mod)
const int N=5010;
int f[N],inv[N],invf[N],d[N],pp[N];char buf[N];
int bin(int n,int r){
	return mul(f[n],mul(invf[r],invf[n-r]));
}
int main(){
	inv[1]=1;
	for(int i=2;i<N;i++)inv[i]=mul(mod-mod/i,inv[mod%i]);
	f[0]=invf[0]=1;
	for(int i=1;i<N;i++){
		f[i]=mul(i,f[i-1]);
		invf[i]=mul(invf[i-1],inv[i]);
	}
	pp[0]=1;
	for(int i=1;i<N;i++)pp[i]=mul(pp[i-1],2);
	d[0]=1;
	for(int i=1;i<N;i++){
		d[i]=d[i-1];
		for(int k=2;k<=i;k+=2){
			d[i]+=mul(d[i-k],mul(pp[k/2],mul(inv[k/2],bin(k-2,k/2-1))));
			if(d[i]>=mod)d[i]-=mod;
		}
	}
	int n;scanf("%d",&n);scanf("%s",buf);int m=strlen(buf);
	int ans=0;
	for(int k=0;k<=(n-m)/2;k++){
		int x=1;
		x=mul(x,m);
		x=mul(x,inv[m+k]);
		x=mul(x,bin(m+2*k-1,k));
		x=mul(x,pp[k]);
		x=mul(x,d[n-m-k-k]);
		ans+=x;
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
}

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

int main()
{
	vector<long long> cost( 4 );
	for( int i = 0; i < 4; i++ ) {
		cin >> cost[i];
	}
	long long N;
	cin >> N;

	double l[4] = { 0.25, 0.5, 1, 2 };
	long long ans = INT64_MAX / 2;
	for( int mask = 0; mask < 1 << 4; mask++ ) {
		long long s = 0;
		long long n = N;
		int bit = 0;
		for( int i = 3; i >= 0; i-- ) {
			if( mask >> i & 1 ) {
				long long d = floor( n / l[i] );
				if( bit + 1 == __builtin_popcount( mask ) ) d = ceil( n / l[i] );
				s += d * cost[i];
				n -= d * l[i];
				bit++;
			}
		}
		if( s == 0 || n != 0 ) continue;
		ans = min( ans, s );
	}

	cout << ans << endl;
}


Measured memory_bytes: 3676
#include<iostream>
using namespace std ;
int main() {
	int count1[26]={0} ;
	string a ; cin >> a ;
	for(int i = 0 ; i < a.length() ; i++ ) {
		count1[a[i]-'a']++;
	}
	bool flag = false ;
	for(int i = 0 ; i < 26 ; i++ ) {
		if(count1[i] % 2 != 0) {
			flag = true ;
			break ;
		}
	}
	if(flag ) cout <<"No" << endl;
	else cout <<"Yes" << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll k;
    cin >> k;
    ll rem = 7;
    if(k==7) {cout << "1"; return 0;}
    ll res = 1;
    unordered_set<ll> seen;
    rem%=k;
    while(rem!=0) {
        if(seen.count(rem)) {
            cout << "-1"; return 0;
        }
        seen.insert(rem);
        rem = rem*10+7;
        rem %= k;
        res++;
    }
    cout << res;
}


Measured memory_bytes: 42652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  long long H,W;
  cin >> H >> W;

  long long ans=1000000000;
  for(long long h=0;h<=H;h++){
    long long x=h*W;
    long long y=(H-h)*(W/2);
    long long z=(H-h)*((W+1)/2);
    ans=min(ans,max({x,y,z})-min({x,y,z}));
    x=h*W;
    y=((H-h)/2)*W;
    z=((H-h+1)/2)*W;
    ans=min(ans,max({x,y,z})-min({x,y,z}));
  }
  for(long long w=0;w<=W;w++){
    long long x=w*H;
    long long y=(W-w)*(H/2);
    long long z=(W-w)*((H+1)/2);
    ans=min(ans,max({x,y,z})-min({x,y,z}));
    x=w*H;
    y=((W-w)/2)*H;
    z=((W-w+1)/2)*H;
    ans=min(ans,max({x,y,z})-min({x,y,z}));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, W = map(int, input().split())
WV = []
for i in range(n):
    w, v = map(int, input().split())
    WV.append((w, v))

INF = 10**18
dp = [[-INF]*(W+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    w, v = WV[i]
    for j in range(W+1):
        dp[i+1][j] = dp[i][j]
    for j in range(W+1):
        if j+w <= W:
            dp[i+1][j+w] = max(dp[i+1][j+w], dp[i][j]+v)
print(max(dp[-1]))


Measured memory_bytes: 148312
/*
 *  *s.rbegin()=*(--s.end())
 *   sort(v.rbegin(),v.rend()) = negative of v[i] , sort(v.begin(),v.end())
 *   sort(v.begin()+l_index,v.begin()+r_index+1);
 * 
 *   for(auto &it:v)cin>>it; 
 *   n + n/2 + n/3 + n/4 + n/5 + ........n/n =>n*log(n)
 *   n + n/3 + n/5 + n/7 + n/11+.............=>n*log(log(n))
 *   1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 .......=>gcd( a[i] , a[i+1] , a[i+2] )=1;
 *   2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 ......=>upto 1e6 max diff a[i], a[i+1] ~ 150
 *   Every even integer greater than 2 can be expressed as the sum of two primes.[1]  : https://en.wikipedia.org/wiki/Goldbach%27s_conjecture
 *   printf("%03d\n",k);
 *   scanf("%d/%d/%d",&d,&m,&y);   
 */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
vector<int>dx={0,1,0,-1},dy={1,0,-1,0};
long long  gcd(long long  a,long long b)
{
     while (a&&b)a>b?a%=b:b%=a;
     return a+b;
}
const int N=1e6;
int n,m,ans=1e18+100,k;
int d_sum(int num)
{
	int s=0;
	while(num)
	{
		s+=num%10;num/=10;
	}
	return s;
}
int is_possible(int mid)
{ 
	int d=d_sum(mid);
	if( mid*mid + d*mid == n )return 0;
	else if( mid*mid + d*mid > n)return 1;
	else return -1;
}

int32_t main()
{
	IOS
	float n,k;cin>>n>>k;
	float f=0;
	for(int i=1;i<=n;i++)
	{
		int score=i;
		float p=1/n;
		while(score < k)
		{
			score*=2;
			p/=2;
		}
		f+=p;
	}
	 cout << fixed << setprecision(10) << f <<endl;
}
		


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int main()
{
    char a;
    cin>>a;
    if(a>='A'&&a<='Z')
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<'a'<<endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int fa[200005];
int son[200005];
int ans = 0;
int N, M, A, B;
int Find(int x)
{
    if (fa[x] == x)
        return x;
    else
    {
       return fa[x] = Find(fa[x]);
    }
}
void cal(int x, int y)
{
    int xx = Find(x);
    int yy = Find(y);
    //cout << xx << " --" << yy << endl;
    if (xx == yy)
        return;
    else
    {
        fa[xx] = yy;
        son[yy] += son[xx];
    }
}
void init()
{
    for (int i = 0; i <= N; i++)
    {
        son[i] = 1;
        fa[i] = i;
    }
}
int main()
{

    cin >> N >> M;
    init();
    for (int i = 1; i <= M; i++)
    {
        cin >> A >> B;
        cal(A, B);
    }
     for (int i = 1; i <= N; i++)
     {
        ans = max(ans,son[i]);
     }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		long l = sc.nextLong();
		//long count=0;

		/*for(int i=1;i<=n;i++) {

		}*/
		if(Math.abs(n-k)<=l || (Math.abs(n-m)<=l&&Math.abs(m-k)<=l)) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(s.substring(0,1)+t.substring(1,2)+g.substring(2,3));
	}
}




Measured memory_bytes: 21204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    while(q--) {
        int b, m, e;
        cin >> b >> m >> e;
        rotate(a.begin()+b, a.begin()+m, a.begin()+e);
        
    }
    rep(i, n) {
        cout << a[i] << (i == n-1?'\n':' ');
    }
}


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

int main() {
  int n,answer;
  cin>>n;
  vector<int> nums(n);
  for(int i=0; i<n; i++){
    cin>>nums.at(i);
  }
  sort(nums.begin(), nums.end());
  reverse(nums.begin(), nums.end());
  answer=nums.at(0);
  for(int i=1; i<n; i++){
    if(i%2==1){
      answer=answer-nums.at(i);
    }else{
      answer=answer+nums.at(i);
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);
        long C = long.Parse(input[2]);
        long K = long.Parse(input[3]);
        if (K<=A) { Console.WriteLine(K); }
        else if (K <= A + B) { Console.WriteLine(A); }
        else { Console.WriteLine(A-(K-(A+B))); }
    }
}

Measured memory_bytes: 27548
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int a = int.Parse(cin[0]);
        int b = int.Parse(cin[1]);
        string s = Console.ReadLine();

        bool flag = false;
        for (int i = 0; i < s.Length; i++)
        {
            if (i == a && s[i] != '-')
            {
                flag = true;
                break;
            }
            else if (i != a)
            {
                if (s[i] < '0' || '9' < s[i]) flag = true;
            }
        }
        if (flag) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}
int main()
{
    Imposter

    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        f(n) cin>>a[i];
        ll h=a[0];
        ll ans=0;
        for(int i=1;i<n;i++)
        {
            if(a[i]>=a[i-1])
                continue;
            else
            {
                ans+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 4372
class UnionFind
  def initialize(n)
    @parents = Array.new(n) { |i| i }
  end

  def find(x)
    return x if @parents[x] == x
    @parents[x] = find(@parents[x])
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def unite(x, y)
    x_root = find(x)
    y_root = find(y)

    return if x_root == y_root

    @parents[y_root] = x_root
  end

  def size
    n = 0
    @parents.each_with_index { |x, i| n += 1 if x == i }
    n
  end
end

def one_or_two(n, params)
  u = UnionFind.new(n)
  params.each do |x, y, z|
    u.unite(x - 1, y - 1)
  end
  u.size
end

n, m = gets.split.map(&:to_i)
params = []
m.times do
  params << gets.split.map(&:to_i)
end

puts one_or_two(n, params)

Measured memory_bytes: 10364
#include<bits/stdc++.h>
using namespace std;
int i,l;
string s;
int main()
{
	cin>>s;
	l=s.length();
	i=0;
	while((s[i]!='C')&&(i<l)) i++;
	while((s[i]!='F')&&(i<l)) i++;
	if (i==l) printf("No");
	else printf("Yes");
	return 0;
}

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

int main(){
	int n,m,sum=0,t,p;
	cin >> n;
	vector<int> v(n);
	for (int i=0;i<n;i++){
		cin >> t;
		v[i] = t;
		sum+=t;
	}
	cin >> m;
	for (int i=0;i<m;i++){
		cin >> p >> t;
		n = sum -(v[p-1]-t);
		cout << n << endl;
	}
 }


Measured memory_bytes: 256
n, m, q = list(map(int, input().split()))
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

country = [[0]*(n+1) for _ in range(n+1)]
for l, r in lr:
    country[r][l] += 1

cumsum = [[0]*(n+1) for _ in range(n+1)]
for y in range(1, n+1):
    for x in range(1, n+1):
        cumsum[y][x] = country[y][x]+cumsum[y][x-1]
for y in range(1, n+1):
    for x in range(1, n+1):
        cumsum[y][x] += cumsum[y-1][x]
# for cy in cumsum: print(cy)

for p, q in pq:
    ans = cumsum[q][q] - cumsum[q][p-1] - cumsum[p-1][q] + cumsum[p-1][p-1]
    print(ans)


Measured memory_bytes: 79228
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e12;

bool lessY(const mp &a, const mp &b){
 return a.second != b.second ? a.second < b.second : a.first < b.first;
}

int main(){
 ll n,m;
 cin>>n>>m;
 vector<ll> x(n),y(n);
 vector<mp> z(n);
 for(ll i=0;i<n;i++) cin>>x[i]>>y[i];
 for(ll i=0;i<n;i++) z[i] = mp(x[i],y[i]);
 set<ll> ux,uy;// unique x,y;
 for(auto i:x) ux.insert(i);
 for(auto i:y) uy.insert(i);
 ll h = ux.size(),w = uy.size();
 vector<ll> rx,ry;
 for(auto i:ux) rx.push_back(i);
 for(auto i:uy) ry.push_back(i);
 vector<vector<ll> > dp(h+1,vector<ll>(w+1,0) );
 for(int i=0;i<n;i++){
  auto ix = lower_bound(rx.begin(),rx.end() , x[i] );
  auto iy = lower_bound(ry.begin(),ry.end() , y[i] );
  int xi = ix-rx.begin();
  int yi = iy-ry.begin();
 // cout<<xi<<' '<<yi<<endl;
  dp[xi+1][yi+1]++;
 }
 for(int i=0;i<h;i++)
  for(int j=0;j<w;j++) dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1]-dp[i][j];

 for(ll i=0;i<m;i++){
  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  auto xs = lower_bound(rx.begin(),rx.end(), sx );
  auto ys = lower_bound(ry.begin(),ry.end(), sy );
  auto xt = upper_bound(rx.begin(),rx.end(), tx );
  auto yt = upper_bound(ry.begin(),ry.end(), ty );
  //xt--,yt--;
  int ssx = xs-rx.begin();
  int ssy = ys-ry.begin();
  int ttx = xt-rx.begin();
  int tty = yt-ry.begin();
  //cout<<ssx<<' '<<ssy<<' '<<ttx<<' '<<tty<<endl;
  cout<<dp[ttx][tty]-dp[ttx][ssy]-dp[ssx][tty]+dp[ssx][ssy]<<endl;
 }


}



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

const long long INF = 1e18L+5;

int main(){

    int n, k;
    std::cin >> n >> k;

    std::vector<long long> w;
    std::vector<long long> v;

    for(int i = 0; i < n; i++)
    {
        long long weight, value;
        std::cin >> weight >> value;
        w.push_back(weight);
        v.push_back(value);
    }

    long long sum = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
    }

    std::vector<long long> dp(sum + 5, INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++)
    {
        int x = sum - v[i];
        for(int j = x; j >= 0; j--)
        {
            dp[j+v[i]] = std::min(dp[j]+w[i],dp[j + v[i]]);
        }
    }

    int sol = 0;
    for(int i = 0; i <= sum; i++)
    {
        if(k >= dp[i])
        {
            sol = std::max(i,sol);
        }
    }
    std:: cout << sol;
    return 0;
}

Measured memory_bytes: 1024
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    string s;
    while(cin >> s) {
        if(s == "#") break;
        string pat = "147208369";

        int ans = INF;
        rep(p,0,2) {
            int cnt = 0, prev = -1;
            rep(j,0,s.length()) {
                int i = cnt + j;
                int x = pat.find(s[j]);
                x /= 3;
                if(prev >= 0) {
                    if(p == 0) {
                        if(i%2==1 && prev > x) cnt++;
                        if(i%2==0 && prev < x) cnt++;
                    }
                    else {
                        if(i%2==1 && prev < x) cnt++;
                        if(i%2==0 && prev > x) cnt++;
                    }
                }
                prev = x;
            }
            // printf("cnt = %lld\n", cnt);
            chmin(ans, cnt);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
import numpy as np

N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

amtx = np.array(A)
bvec = np.array(B)
score = np.count_nonzero(np.dot(amtx, bvec.T) > -C)
print(score)

Measured memory_bytes: 12508
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

int cmp_int (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 len = 1;
  i32 *f = ALLOC (100000, i32);
  i32 i = 1;
  for (; i * i < n; ++i) {
    f[len++] = i;
    f[len++] = n / i;
  }
  if (i * i == n) {
    f[len++] = i;
  }
  SORT (f, len, cmp_int);
  for (i32 i = len - 1; i >= 1; --i) {
    f[i] -= f[i - 1];
  }
  const i32 mod = 1000000007;
  i32 *dp = ALLOC (len, i32);
  i32 *imos = ALLOC (len + 1, i32);
  dp[1] = 1;
  for (i32 i = 1; i <= k; ++i) {
    for (i32 j = 1; j < len; ++j) {
      imos[len - j] = dp[j];
    }
    for (i32 j = len - 1; j >= 1; --j) {
      imos[j] = (imos[j] + imos[j + 1]) % mod;
      dp[j] = (i64) imos[j] * f[j] % mod;
    }
  }
  i64 ans = 0;
  for (i32 i = 1; i < len; ++i) {
    ans += dp[i];
  }
  ans %= mod;
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1056
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

ans = float("inf")

if N < 3:
  ans = 1
else:   
  for i in range(N):
    x, y = xy[i][0], xy[i][1]
    for j in range(N):
      if i == j:
        continue
      p, q = xy[j][0] - x, xy[j][1] - y
      cnt = 0
      for k in range(N):
        xk, yk = xy[k][0], xy[k][1]
        for l in range(N):
          if k == l:
            continue
          if xy[l][0] - xk == p and xy[l][1] - yk == q:
            cnt += 1
      ans = min(ans, N - cnt)
print(ans)

Measured memory_bytes: 3064