akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    if((b*10+c)%4==0) YES;
    else NO;

    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 200005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    ll n, a[N], b[N] = {0}, ans = 0;
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        b[a[i]] ++;
    }
    for (int i=1; i<=n; i++) {
        ans += b[i]*(b[i]-1)>>1;
    }
    for (int i=1; i<=n; i++) {
        ll res = ans;
        if (b[a[i]] == 1) {
            cout << ans << E;
            continue;
        }
        res -= b[a[i]]-1;
        cout << res << E;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, k;
vector<ll> a, f;
bool check(ll m){
    vector<ll> v; 
    for(int i=0;i<n;i++){
        v.push_back(f[i]*a[n-1-i]);
    }
    ll count=0;
    for(int i=0;i<n;i++){
        if(v[i]>m){
            count+=(v[i]-m+(f[i]-1))/f[i];
        }
    }
    //cout<<count<<"\n";
    return count<=k;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    for (int i = 0; i < n; i++)
    {
        ll tempa;
        cin >>tempa;
        a.push_back(tempa);
    }
    for (int i = 0; i < n; i++)
    {
        ll tempf;
        cin >>tempf;
        f.push_back(tempf);
    }
    sort(ALL(a));
    sort(ALL(f));
    ll l=-1;
    ll r=1000000000000000000;
    while(r-l>1){
        //cout<<l<<" "<<r<<"\n";
        ll mid=(r+l)/2;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout << r << "\n";
}


Measured memory_bytes: 7576
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

int n, m, a[100005], x, y, p[100005], com[100005], cn = 0;
vvi adj;
bitset<100005> usa, vis;
ll res = 0;

void dfs (int u, int c) {
    vis[u] = 1;
    com[u] = c;

    for (int v : adj[u])
        if (!vis[v])
            dfs(v, c);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    iota (p, p+n, 0);
    sort (p, p+n, [&] (int x, int y) {
        return a[x] < a[y];
    });

    adj = vvi(n);
    while (m--) {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for (int i = 0; i < n; i++) {
        if (!vis[i]) {
            dfs(i, i);
            cn++;
        }
    }

    if (cn == 1) {
        cout << 0 << endl;
        return 0;
    }

    cn -= 2;
    for (int i = 0; i < n; i++) {
        int u = p[i];

        if (usa[com[u]]) {
            if (cn > 0) {
                res += a[u];
                cn--;
            }
        } else {
            usa[com[u]] = 1;
            res += a[u];
        }
    }

    if (cn == 0)
        cout << res << endl;
    else
        cout << "Impossible" << endl;

	return 0;
}

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

namespace ALDS1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = new int[N];
            var input = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(input[i]);
            }
            A = SelectionSort(A, N);
        }

        public static int[] SelectionSort(int[] A, int N)
        {
            var change = 0;
            for (int i = 0; i <= N - 1; i++)
            {
                var minj = i;
                for (int j = i; j <= N - 1; j++)
                {
                    if (A[j] < A[minj])
                    {
                        minj = j;
                    }
                }
                if (A[i] != A[minj])
                {
                    var c = A[i];
                    A[i] = A[minj];
                    A[minj] = c;
                    change++;
                }
            }
            Print(A, N);
            Console.WriteLine(change);
            return A;
        }

        public static void Print(int[] A, int N)
        {
            var prt = "";
            for (int i = 0; i < N; i++)
            {
                if (i == N - 1)
                {
                    prt += A[i];
                }
                else
                {
                    prt += A[i] + " ";
                }
            }
            Console.WriteLine(prt);
        }
    }
}



Measured memory_bytes: 17900
#include <iostream>

int n, l[100], ans = 0;

int main()
{
    std::cin >> n;
    if (n < 3) {
        std::cout << 0 << std::endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }
    for (int i = 0; i < n-2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]) {
                    ans++;
                }
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a == 1 && b == 2){
        cout << 3 << endl;
    }
    if(a == 1 && b == 3){
        cout << 2 << endl;
    }
    if(a == 2 && b == 1){
        cout << 3 << endl;
    }
    if(a == 2 && b == 3){
        cout << 1 << endl;
    }
    if(a == 3 && b == 1){
        cout << 2 << endl;
    }
    if(a == 3 && b == 2){
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,m,l;
    scanf("%d %d",&a,&b);
    m = a * b;
    l = 2 * (a + b);
    printf("%d %d\n",m,l);
    return 0;
}



Measured memory_bytes: 2064
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b<c){
		printf("NA\n");
	}
	else{
		d=c-a;
		if(d<0){
			d=0;
		}
		printf("%d\n",d);
	}
	return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    puta(max(a-b*2,0ll));
    return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  int range;
  range = 2 * D + 1;
  int x;
  if (N % range == 0) {
    x = N / range;
  }
  else {
    x = N / range + 1;
  }
  cout << x <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll ksm(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e5+10;
char str[N];
int a[N];
int cnt[2020]; 
int main(){
	scanf("%s",str+1);
	int n=strlen(str+1);
	int ans=0,now=0,p=1;
	cnt[0]=1;
	per(i,1,n){
		a[i]=str[i]-'0';
		now=(now+a[i]*p)%2019;
		ans+=cnt[now];
		cnt[now]++;
		p=p*10%2019;
	}
	printf("%d",ans); 
    return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n, m;
	int sum = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		sum += t;
	}
	n -= sum;
	if (n < 0) {
		cout << -1;
	} else {
		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 3640
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,k;
    cin>>n>>k;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    vl sl,sr;
    for(int i=1;i<=n;i++)
    {
        ll l=max((ll)1,i-v[i]);
        ll r=min(n,i+v[i]);
        sl.pb(l);
        sr.pb(r);
    }
    sort(all(sl));
    sort(all(sr));
    for(int oper=1;oper<=k;oper++)
    {
        int flag=1;
        for(int i=1;i<=n;i++)
        {
            if(v[i]!=n)
            {
                flag=0;
                break;
            }
        }
        if(flag)
            break;
        for(int i=1;i<=n;i++)
        {
            ll x=lower_bound(all(sl),i+1)-sl.begin();
            ll y=lower_bound(all(sr),i)-sr.begin();
            ll now=x-y;
            v[i]=now;
        }
        sl.clear();
        sr.clear();
        for(int i=1;i<=n;i++)
        {
            ll l=max((ll)1,i-v[i]);
            ll r=min(n,i+v[i]);
            sl.pb(l);
            sr.pb(r);
        }
        sort(all(sl));
        sort(all(sr));
    }
    for(int i=1;i<=n;i++)
        cout<<v[i]<<' ';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 21528
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#define MAX 2000
#define VMAX 20000
using namespace std;
#define WHITE 0
#define BLACK 1

typedef long long ll;

int A[MAX],B[MAX],n,mini=2000000000,C[VMAX];

int color[MAX],myans;

void start(int x){
  color[x]=BLACK;
  int xvalue=A[x];
  int xsort=C[xvalue];
  int sum=xvalue,num=1,s=xvalue;
  while(true){
    xvalue=A[xsort];
    if(xsort==x) break;
    num++;
    s=min(s,xvalue);
    sum+=xvalue;
    color[xsort]=BLACK;
    xsort=C[xvalue];
  }
  if(num==1) return;
  else myans+=min(sum+s*(num-2),sum+mini*(num+1)+s);
  
}


void go(){
  for(int i=0;i<n;i++){
    if(color[i]==0) start(i);
  }
  cout<<myans<<endl;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
    mini=min(A[i],mini);
    B[i]=A[i];
  }
  sort(B,B+n);
  for(int i=0;i<n;i++){
    C[B[i]]=i;
  }

  go();






}



Measured memory_bytes: 3184
N = gets.to_i
A = gets.split.map(&:to_i)
ans = 0

1.upto(N-1) do |i| 
	(N-1).downto(i) do |j|
		if A[j-1] > A[j]
			A[j-1], A[j] = A[j], A[j-1]
			ans += 1
		end
	end
end

puts A.join(" ")
puts ans



Measured memory_bytes: 6868
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < n; i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

int main(){
    int n;
    cin >> n;
    string s[n];
    int cnt[4];
    rep(i, n) cin >> s[i];
    rep(i, 4) cnt[i]=0;

    rep(i, n){
        if(s[i]=="AC"){
            cnt[0]++;
        }
        else if(s[i]=="WA"){
            cnt[1]++;
        }
        else if(s[i]=="TLE"){
            cnt[2]++;
        }
        else if(s[i]=="RE"){
            cnt[3]++;
        }
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 6696
#include<bits/stdc++.h>
#define INF (1e15)
#define int long long
using namespace std;
typedef pair<int,int> P;

int n, x, a[2005];
int dp[2005][2005];

signed main(){
  
  cin>>n>>x;

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

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) dp[i][j]=INF;
  
  for(int i=0;i<n;i++) dp[i][0]=a[i];
  
  for(int i=0;i<n;i++)
    for(int j=1;j<n;j++)
      dp[i][j]=min(dp[i][j-1],a[(i-j+n)%n]);

  int ans=INF;
  
  for(int i=0;i<n;i++){
    int sum=i*x;
    for(int j=0;j<n;j++) sum+=dp[j][i];
    ans=min(ans,sum);
  }

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


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	const ll mod = 998244353;
    int n; cin >> n;
	int mx = 0;
	vector<int> v(n);
	map<int, int> m;
	rep(i, n) {
		cin >> v[i];
		m[v[i]]++;
		mx = max(mx, v[i]);
	}
	if(v[0] != 0){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	sort(All(v), greater<int>());
	for(int i = 0; i < n-1; i++){
		ans *= m[v[i]-1];
		ans %= mod;
	}
	cout << ans << endl;

    system("pause");
}


Measured memory_bytes: 5504
#include <cstring>
#include <string>
#include <vector>

#include <cassert>
#include <iostream>

using namespace std;

#define MAXN 200005

vector<int> L[MAXN];
int parent[MAXN], sz[MAXN], pos[MAXN], v[MAXN];
int s[MAXN], dx[MAXN], ans[MAXN];

int main(){
  int N,Q;
  scanf("%d %d", &N,&Q);

  for(int i = 0,a,b;i < N - 1;++i){
    scanf("%d %d", &a, &b);
    --a; --b;
    parent[b] = a;
    L[a].push_back(b);
  }

  for(int i = N - 1;i >= 0;--i){
    sz[i]++;
    if(i != 0)
      sz[ parent[i] ] += sz[i];
  }

  pos[0] = 0;

  for(int i = 0;i < N;++i){
    int p = pos[i];
    v[p] = i;
    s[i] = p;
    ++p;

    for(int j = L[i].size() - 1;j >= 0;--j){
      int x = L[i][j];
      pos[x] = p;
      p += sz[x];
    }

    //e[i] = p;
  }

  /*for(int i = 0;i < N;++i){
    cout << v[i] << " ";
  }
  cout << endl;

  for(int i = 0;i < N;++i){
    cout << pos[i] << " ";
  }
  cout << endl;

  for(int i = 0;i < N;++i){
    cout << sz[i] << " ";
  }
  cout << endl;*/

  memset(dx, 0, sizeof dx);

  int p, x;

  while(Q--){
    scanf("%d %d", &p, &x);
    --p;
    dx[ s[p] ] += x;
    dx[ s[p] + sz[p] ] -= x;
  }

  int cur = 0;

  for(int i = 0;i < N;++i){
    cur += dx[i];
    ans[ v[i] ] = cur;
  }

  for(int i = 0;i < N;++i){
    printf("%d ", ans[i]);
  }
  printf("\n");

  return 0;
}


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

int main () {
    int N, H, W;  cin >> N >> H >> W;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= H && B[i] >= W) ++res;
        //cout << A[i] << B[i] << endl;
    }

    cout << res << endl;
}

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

int main() {
    int64_t n, ans = 0, prev = 0, cnt = 0;
    cin >> n;
    vector<int64_t> a(n), s(n + 1, 0);
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        s[i + 1] = a[i] + s[i];
    }
    sort(s.begin(), s.end());
    for (auto i = 0; i < (int)s.size(); i++) {
        if (s[i] != prev) {
            ans += cnt * (cnt - 1) / 2;
            prev = s[i], cnt = 1;
            continue;
        }
        cnt++;
        if (i == (int)s.size() - 1)
            ans += cnt * (cnt - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6440
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){


    int a,b;
    cin >> a >> b;



    if(a > b){
        if(b == 1){
            cout << "Bob" << endl;
        }else{
            cout << "Alice" << endl;
        }
    }else if(a < b){

        if(a == 1){
            cout << "Alice" << endl;
        }else{
            cout << "Bob" << endl;
        }
    }else{
        cout << "Draw" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

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

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[2*i+1] + node[2*i+2];
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }

    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};


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

    SegmentTree seg(vector<int>(100100, 0));
    
    rep(i, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) seg.update(x-1, y);
        else cout << seg.getsum(x-1, y) << endl;
    }


    return 0;

}



Measured memory_bytes: 4132
from itertools import permutations as perm
from math import sqrt

n = int(input())
xy = [(x, y) for x, y in (map(int, input().split()) for _ in range(n))]
ans = 0
for order in perm(range(n)):
    for i, j in zip(order, order[1:]):
        xi, yi = xy[i]
        xj, yj = xy[j]
        ans += sqrt((xi-xj)**2+(yi-yj)**2)

nfact = 1
for i in range(1, n + 1):
    nfact *= i

print(ans/nfact)


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
int N,sw,count=0;
cin>>N;
int A[N];
REP(i,N)cin>>A[i];
bool flag=1;
while(flag){
    flag=0;
    FOR(i,1,N){
        if(A[i]<A[i-1]){
        count++;
        sw=A[i];
        A[i]=A[i-1];
        A[i-1]=sw;
        flag=1;
        }
    }
}
REP(i,N-1)cout<<A[i]<<" ";
cout<<A[N-1]<<endl<<count<<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX_A = 1e5+1;
int N, M;

void solve() {
    cin >> N >> M;
    vector<P> jobs(N);
    for (int i = 0; i < N; ++i) {
        int a,  b;
        cin >> a >> b;
        jobs[i]  = P(a, b);
    }
    sort(jobs.begin(), jobs.end());
    ll ans = 0;
    priority_queue<int> q;
    int start = 0;
    for (int d = 1; d <= M; ++d) {
        for (int i = start; i < N; ++i) {
            P j = jobs[i];
            if (j.first <= d) {
                q.push(j.second);
                start++;
            } else {
                start = i;
                break;
            }
        }
        if (!q.empty()) {
            ans += q.top(); q.pop();
        }
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 1660
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
int x, y, a, b, c;
vector<int> p, q, r;
signed main() {
	cin >> x >> y >> a >> b >> c;
	rep(i, a) {
		int z;
		cin >> z;
		p.push_back(z);
	}
	rep(i, b) {
		int z;
		cin >> z;
		q.push_back(z);
	}
	rep(i, c) {
		int z;
		cin >> z;
		r.push_back(z);
	}
	sort(all(p), greater<int>());
	sort(all(q), greater<int>());
	sort(all(r));
	prique(int) que;
	rep(i, x)que.push(p[i]);
	rep(i, y)que.push(q[i]);
	while (!r.empty()) {
		if (que.top() < r.back()) {
			que.pop();
			que.push(r.back());
			r.pop_back();
		}
		else break;
	}
	int ans = 0;
	while (!que.empty()) {
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <algorithm>

int main() {
	std::string s;
	int q;
	std::cin >> s >> q;

	std::string added[2];
	added[0].reserve(q);
	added[1].reserve(q);

	int flipped = 0;
	for (int i = 0; i < q; ++i) {
		int t;
		std::cin >> t;

		if (t == 1) {
			flipped = 1 - flipped;
			continue;
		}

		int f;
		char c;
		std::cin >> f >> c;

		added[(flipped + f - 1) % 2] += c;
	}

	std::reverse(added[0].begin(), added[0].end());
	s = added[0] + s + added[1];

	if (flipped == 1)
		std::reverse(s.begin(), s.end());

	std::cout << s << std::endl;
}

Measured memory_bytes: 1144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
        out.println(s.contains("A") && s.contains("B") ? "Yes" : "No");
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}


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

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

    int cards[4][13] = {0};

    for(size_t i = 0; i < n; i++)
    {
        char s;
        int mark, num;
        cin >> s >> num;

        switch (s)
        {
            case 'S':
                mark = 0;
                break;
        
            case 'H':
                mark = 1;
                break;
            
            case 'C':
                mark = 2;
                break;
            
            case 'D':
                mark = 3;
                break;

            default:
                break;
        }

        cards[mark][num-1] = 1;
    }

    for(size_t i = 0; i < 4; i++)
    {
        for(size_t j = 0; j < 13; j++)
        {
            //cout << i << " " << j << ": ";
            if (cards[i][j] == 0)
            {
                switch (i)
                {
                    case 0:
                        cout << "S ";
                        break;
                
                    case 1:
                        cout << "H ";
                        break;
                    
                    case 2:
                        cout << "C ";
                        break;
                    
                    case 3:
                        cout << "D ";
                        break;

                    default:
                        break;
                }

                cout << j+1 << endl;
            }
        }
    }
}


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

public class Hello
{
    public static void Main()
    {
        var aL = "abcdefghijklmnopqrstuvwxyz";
        var d = new Dictionary<char, int>();
        for (int i = 0; i < 26; i++) d[aL[i]] = i;
        var a = new int[26];
        var b = new int[26];
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        for (int i = 0; i < n; i++) { a[d[s[i]]]++; b[d[t[i]]]++; }
        var a2 = a.Where(x => x >= 1).OrderByDescending(x => x).ToArray();
        var b2 = b.Where(x => x >= 1).OrderByDescending(x => x).ToArray();
        var imin = Math.Min(a2.Length, b2.Length);
        for (int i = 0; i < imin; i++)
            a2[i] = Math.Max(a2[i] - b2[i], 0);
        Console.WriteLine(a2.Sum());
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }


//方針:最長増加部分列(LIS) の長さを各点への最小パスについて求める
//LISを1からつくるにはO(NlogN)、 長さの調査にはO(logN) 必要
// <- 毎回LISを生成するとO( (NlogN)^2 ) かかる
// -> 深さ優先探索(DFS) & 探索ごとにLISを更新 
//    (1探索当たりO(logN)*N回 -> O(NlogN) )
// <- 素朴に更新を繰り返すとDFSの復路通過で壊れる
// -> 更新前の状態を復元できるよう、stackで情報保持
//全点通過で探索終了

#define INF 1e15
#define MAX 300000
ll N;
ll a[MAX];
ll dp[MAX];
ll check_visit[MAX];
ll ans[MAX];
vector<ll> cnct[MAX];
stack< pair<ll,ll> > stk;

void dfs(int k){
    check_visit[k] = true;
    ll idx = distance(dp,lower_bound(dp,dp+N+1,a[k]));
    stk.push( make_pair(idx, dp[idx] ) );
    dp[idx] = a[k];
    ans[k] = distance(dp,lower_bound(dp,dp+N+1,INF));
    for(ll nxt: cnct[k]){
        if(check_visit[nxt]==0LL){
            dfs(nxt);
        }
    }
    idx = stk.top().first;
    dp[idx] = stk.top().second;
    stk.pop();
}

int main(){
  cin>>N;
  a[0] = 0;
  for(ll i=1;i<=N;++i){ cin >> a[i]; }
  FILL(dp,N+1,INF);
  FILL(check_visit,N+1,0LL);
  REP(i,N){
    ll u,v; cin>>u>>v;
    cnct[u].push_back(v);
    cnct[v].push_back(u);
  }
  dfs(1);
  for(int i=1;i<=N;++i){
    cout << ans[i] << "\n";
  }
}

Measured memory_bytes: 43104
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val d = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val x = n / 2 - 1
    var ans = 0
    for (i in d[x] until d[x+1]){
        ans++
    }
    println(ans)
}

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

using namespace std;

const int N = 1234567;

int p[N], any[N];

int find_set(int x) {
  if (x != p[x]) {
    p[x] = find_set(p[x]);
  }
  return p[x];
}

int main() {
  int cnt, n;
  scanf("%d %d", &cnt, &n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }
  for (int i = 0; i < cnt; i++) {
    int foo;
    scanf("%d", &foo);
    int root = -1;
    for (int j = 0; j < foo; j++) {
      int bar;
      scanf("%d", &bar);
      bar--;
      any[bar] = 1;
      if (j == 0) {
        root = find_set(bar);
      } else {
        int other = find_set(bar);
        p[other] = root;
      }
    }
  }
  int res = -1;
  for (int i = 0; i < n; i++) {
    if (!any[i]) {
      continue;
    }
    int x = find_set(i);
    if (res == -1) {
      res = x;
    } else {
      if (res != x) {
        res = -2;
        break;
      }
    }
  }
  puts((res != -2) ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 1024
#include "iostream"
using namespace std;

int main()
{
	int lis[100];
	int n;

	cin >> n;

	for (int i = 0; i < n;i++){
		cin >> lis[i];
	}
	
	for (int i = n-1; i >= 0; i--){
		if(i==0){
			cout << lis[i] <<endl;
		}
		else{
			cout << lis[i] <<" ";
		}
		
	}

	return 0;
}



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

void solve(long long X)
{
    if (X >= 1800)
        cout << '1' << endl;
    else if (X >= 1600)
        cout << '2' << endl;
    else if (X >= 1400)
        cout << '3' << endl;
    else if (X >= 1200)
        cout << '4' << endl;
    else if (X >= 1000)
        cout << '5' << endl;
    else if (X >= 800)
        cout << '6' << endl;
    else if (X >= 600)
        cout << '7' << endl;
    else if (X >= 400)
        cout << '8' << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3756
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; string s; cin >> n >> s;
    int ans = 0;
    int cntr = 0, cntg = 0, cntb = 0;
    rep(i, n) {
        if(s[i] == 'R') ++cntr;
        if(s[i] == 'G') ++cntg;
        if(s[i] == 'B') ++cntb;
    }
    ans = cntr * cntg * cntb;
    rep(i, n) {
        for(int j = i + 1; j < n; ++ j) {
            int l = j - i;
            int k = j + l;
            if(k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                -- ans;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main()
{
    char gate[3][4];
    int i,j;
    char a;
    for(i=0;i<2;i++)
    {
      gets(gate[i]);
    }
    if(gate[0][0]==gate[1][2]&&gate[0][1]==gate[1][1]&&gate[0][2]==gate[1][0])
        printf("YES");
    else
        printf("NO");
}


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

template <typename T>
struct WeightedUnionFind {
    vector<int> par, rank;
    vector<T> weight;

    WeightedUnionFind(int n) {
        par.resize(n);
        for (int i = 0; i < n; i++) par[i] = i;
        rank.resize(n);
        weight.resize(n);
    }

    int find(int x) {
        if (par[x] == x) return x;
        int r = find(par[x]);
        weight[x] += weight[par[x]];
        return par[x] = r;
    }

    bool unite(int x, int y, T w) {
        int rx = find(x), ry = find(y);
        w += weight[x] - weight[y];
        x = rx, y = ry;
        if (x == y) return false;

        if (rank[x] < rank[y]) swap(x, y), w = -w;

        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        weight[y] = w;
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    T diff(int x, int y) {
        find(x), find(y);
        return weight[y] - weight[x];
    }
};

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

    int n, q;
    cin >> n >> q;
    WeightedUnionFind<int> wuf(n);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 0) {
            int x, y, z;
            cin >> x >> y >> z;
            wuf.unite(x, y, z);
        } else {
            int x, y;
            cin >> x >> y;
            if (wuf.same(x, y)) cout << wuf.diff(x, y) << '\n';
            else cout << "?\n";
        }
    }
}


Measured memory_bytes: 4140
MOD = 1e+9.to_i + 7

def total(n)
  (n * (n + 1)) / 2
end

def main(argv)
  (n, k) = gets.chomp.split(' ').map(&:to_i)
  a = gets.chomp.split(' ').map(&:to_i)
  
  cnt = 0
  
  n.times do |i|
    l = 0
    (0...i).each do |j|
      if a[j] < a[i] then
        l += 1
      end
    end
    
    r = 0
    ((i + 1)...n).each do |j|
      if a[j] < a[i] then
        r += 1
      end
    end
    
    xl = (total(k - 1) * l) % MOD
    cnt = (cnt + xl) % MOD
    
    xr  = (total(k) * r) % MOD
    cnt = (cnt + xr) % MOD
  end
  
  puts cnt.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, a;
  cin >> n;
  map<int, int> odd, even;
  rep(i, n/2)
  {
    cin >> a;
    odd[a]++;
    cin >> a;
    even[a]++;
  }
  vector<pair<int, int>> vo, ve;
  for (auto i = odd.begin(); i != odd.end(); ++i) {
    vo.push_back(make_pair(i->second, i->first));
  }
  for (auto i = even.begin(); i != even.end(); ++i) {
    ve.push_back(make_pair(i->second, i->first));
  }
  sort(vo.begin(), vo.end(), greater<pair<int, int>>());
  sort(ve.begin(), ve.end(), greater<pair<int, int>>());
  if (vo[0].second != ve[0].second) {
    cout << n - vo[0].first - ve[0].first;
  } else {
    if (vo[0].first - (vo.size() > 1 ? vo[1].first : 0)
        < ve[0].first - (ve.size() > 1 ? ve[1].first : 0)) {
      cout << n - (vo.size() > 1 ? vo[1].first : 0) - ve[0].first;
    } else {
      cout << n - vo[0].first - (ve.size() > 1 ? ve[1].first : 0);
    }
  }
  return 0;
}


Measured memory_bytes: 6136
input = STDIN.gets
a_b_c = input.split(" ")
a = a_b_c[0].to_i
b = a_b_c[1].to_i
c = a_b_c[2].to_i
count = 0
for num in a .. b do
  if c % num == 0 then
    count += 1
  end
end

print count.to_s + "\n"

Measured memory_bytes: 8668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, K, S;
    cin >> N >> K >> S;

    if (S < 1e9) {
        rep(i, K) cout << S << " ";
        reps(i, K, N) cout << S + 1 << " ";
        cout << endl;
    } else {
        rep(i, K) cout << S << " ";
        reps(i, K, N) cout << 1 << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double[][] xy = new double[2][2];
		for (int i = 0; i < xy.length; i++) {
			for (int j = 0; j < xy[0].length; j++) {
				xy[i][j] = sc.nextDouble();
			}
		}
		double[] z = {Math.abs(xy[1][0] - xy[0][0]), Math.abs(xy[0][1] - xy[1][1])};
		double result = Math.sqrt(Math.pow(z[0], 2) + Math.pow(z[1], 2));
		System.out.printf("%.16f", result);
	}
}



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

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

    char ae, bs, ce; 
    bs = b.front();

    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }    
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

a,b = [int(i) for i in input().split()]

def f(x):
    if x == 0 or x==3:
        return 0
    elif x== 1:
        return 1
    elif x == 2:
        return 3
    y=x
    c=0
    while(y > 0):
        c+=1
        y=y//2
    
    return ((x+1)%2)*(2**(c-1)) + f(x-2**(c-1))

if a == 0:
    print(f(b))
else:
    print(f(b)^f(a-1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n;
    cin>>n;
    ll a[200005];
    for(int i=1;i<=n;i++){
        scanf("%lld",a+i);
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    ll ans=0,b=a[n/2];
    for(int i=1;i<=n;i++){
        ans+=abs(a[i]-b);
    }
    b=a[n/2+1];
    ll tmp=0;
    for(int i=1;i<=n;i++){
        tmp+=abs(a[i]-b);
    }
    cout<<min(ans,tmp);
    return 0;
}

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

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() 
{
	cin >> N >> M;
	for (int i = 1; i <= N; i++) 
    {
		for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
	}

	for (int i = 0; i < 8; i++) 
    {
		vector<long long>vec;
		for (int j = 1; j <= N; j++)
         {
			long long S = 0;
			for (int k = 0; k < 3; k++)
                { 
                    if ((i / (1 << k)) % 2 == 0) S += a[j][k]; 
                    else S -= a[j][k];
                }
			vec.push_back(S);
		}
		
        sort(vec.begin(), vec.end());
        reverse(vec.begin(), vec.end());
		long long ans = 0; 
		for (int j = 0; j < M; j++)
        {
            ans += vec[j];
        }
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 256