akhauriyash/Code-Regression huggingface dataset:
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,ans;
  cin >> n >> m;
  if(abs(n-m)>1) {
    cout << 0 << "\n";
  }
  else {
    if(n==m) {
      ans=2;
      for(int i=n; i>=1; i--) {
        ans*=i;
        ans%=MOD;
      }
      for(int i=m; i>=1; i--) {
        ans*=i;
        ans%=MOD;
      }
      cout << ans << "\n";
    }
    else {
      ans=1;
      for(int i=n; i>=1; i--) {
        ans*=i;
        ans%=MOD;
      }
      for(int i=m; i>=1; i--) {
        ans*=i;
        ans%=MOD;
      }
      cout << ans << "\n";
    }
  }
}

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

int main(){
	int n,l,r,cnt=0;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>l>>r;
		cnt+=(r-l+1);
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long n, m, ans = 0;
    cin >> n >> m;
    vector<long long> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }
    vector<vector<long long>> r(m, vector<long long>(2));
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin >> r.at(i).at(j);
        }
    }

    vector<bool> flag(n, true);
    for (int i = 0; i < m; i++)
    {
        long long a, b;
        a = r.at(i).at(0);
        b = r.at(i).at(1);
        if (h.at(a - 1) >= h.at(b - 1))
        {
            flag.at(b - 1) = false;
        }
        if (h.at(b - 1) >= h.at(a - 1))
        {
            flag.at(a - 1) = false;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (flag.at(i))
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9604
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
point = [K - Q for i in range(N)]

for i in range(Q):
    point[A[i]-1] += 1

for i in range(N):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11792
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))

#define loop(i,n)  for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i++)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define makeuniq(v) v.resize(unique(all(v)) - v.begin()); //only uniq element in vector after this
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>

#define pii pair<lli,lli>

#define vi vector<lli>
#define vvi vector<vi>
#define vpi vector<pii>
#define vbool vector<bool>

#define seti set<lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename Head>
void print(Head&& head)
{
    cout<<head<<endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail)
{
    cout<<head<<" ";
    print(tail...);
}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

/*
1D vector -  vi dp(n,value);
2D vector -  vvi dp(n,vi(n,value));
*/

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
      lli a,b,c,d;
      cin>>a>>b>>c>>d;
      print(max({a*c , b*c , a*d , b*d}));
  }
return 0;
}



Measured memory_bytes: 3648
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

public class Main {

    public BigDecimal pow(BigDecimal value) {
        return value.multiply(value);
    }

    public static BigDecimal sqrt(BigDecimal a, int scale){
        BigDecimal x = new BigDecimal(
                Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17) return x;

        BigDecimal b2 = new BigDecimal(2);
        for(int tempScale = 16; tempScale < scale; tempScale *= 2){
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                    x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }

    public BigDecimal average(int[] values) {
        int sum = 0;
        for (int i=0; i<values.length; i++) {
            sum += values[i];
        }
        return new BigDecimal(sum).divide(new BigDecimal(values.length), 5, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal var(int[] values) {
        BigDecimal sum = BigDecimal.ZERO;
        for (int i=0; i<values.length; i++) {
            sum = sum.add(pow(new BigDecimal(values[i]).subtract(average(values))));
        }

        return sum.divide(new BigDecimal(values.length), 5, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal std(int values[]) {
        return sqrt(var(values), 2);
    }

    public static void main(String[] args) {

    	Scanner sc = new Scanner(System.in);

        int count = 0;
		
        Main m = new Main();
        while(true) {
        	count = sc.nextInt();
        	if(count == 0) break;
            int[] values = new int[count];
        	for(int i=0; i<count; i++) {
        		values[i] = sc.nextInt();
        	}
        	System.out.println(m.std(values));
        }

        sc.close();
    }
}


Measured memory_bytes: 32260
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int dp[100005];

  for(int i=0;i<100005;i++)dp[i] = 200000;

  int a,b,c;
  string s1,s2;
  cin>>a;

  int cn = 0;
  int num[60];

  int tmp = 9;
  while(1){
    if(tmp > a) break;
    num[cn] = tmp;
    cn++;
    tmp*=9;
  }

  tmp = 6;
  while(1){
    if(tmp > a) break;
    num[cn] = tmp;
    cn++;
    tmp*=6;
  }

  //for(int i=0;i<cn;i++)cout<<num[i]<<" ";cout<<endl;

  dp[0] = 0;
  for(int i=0;i<=a;i++){
      for(int j=0;j<cn;j++){
        if((i+num[j])<100005){
          dp[i+num[j]] = min(dp[i+num[j]],dp[i]+1);
        }
      }
  }

  //for(int i=0;i<=127;i++)cout<<i<<" "<<dp[i]<<endl;

  int mi = 100005;
  for(int i=0;i<=a;i++){
    if(dp[i] != 200000)mi = min(mi,dp[i]+(a-i));
  }

  cout<<mi<<endl;
  return 0;
}

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

int main() {
  string s,t;
  cin >>s >>t;
  int a;
  a =s.size();
  for(int i=0; i<a; i++){
    if(s.at(i)==t.at(i)){
      continue;
    }
    else{
      cout <<"No" <<endl;
      return 0;
    }
  }
  cout <<"Yes" <<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	while(cin>>n){
		if(n<1200)cout<<"ABC"<<'\n';
		else if(n>=1200&&n<2800)cout<<"ARC"<<'\n';
		else cout<<"AGC"<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

#define pai 3.1415926535
using namespace std;

int main()
{

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

    double full = a * a * b;

    double just = atan2(b, a);
    //cout << "just = " << just << endl;
    double lb = 0.0, ub = pai / 2;
    for (int i = 0; i < 100; ++i)
    {
        double mid = (lb + ub) / 2;

        //cout << lb << " " << ub << endl;
        //double rad = mid * (pai / 180);
        if (mid <= just)
        {

           // cout << "mid = " << mid << ", tan(mid) = " << tan(mid) << endl;
           // cout << "aatanaa = " << a * a * tan(mid) / 2 * a << endl;

            if (full - a * a * tan(mid) / 2 * a >= x)
            { //あふれない
                lb = mid;
            }
            else
            {
                ub = mid;
            }
        }
        else
        {
            //cout << "mid = " << mid << ", tan(mid) = " << tan(mid) << endl;
            //cout << "aatanaa = " << a * a * tan(mid) / 2 * a << endl;
            if (b * b / tan(mid) * 0.5 * a >= x)
            { //あふれない
                lb = mid;
            }
            else
            {
                ub = mid;
            }
        }
    }
    cout << fixed;
    cout<<setprecision(6) << lb * 180.0 / pai << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long N, M;
  long long ans = 0;
  string s;

  cin >> N;
  vector<long long > A(N+1);
  vector<long long > B(N);
  for(int i = 0; i < N+1; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }

  for(int i = 0; i < N; i++){
    if(A[i] < B[i]){
      B[i] -= A[i];
      ans += A[i];
      if(B[i] <= A[i+1]){
        A[i+1] -= B[i];
        ans += B[i];
      }else{
        ans += A[i+1];
        A[i+1] = 0;
      }
    }else{
      ans += B[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi v(5);
	REP(i, 5)cin >> v[i];
	int ans = INF;
	REP(i, 5) {
		int sum = 0;
		REP(j, 5) {
			if (i == j)continue;
			sum += (v[j] + 9) / 10 * 10;
		}
		chmin(ans, sum + v[i]);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
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;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
    //処理
    //出力
    cout << n*800-(n/15)*200 << ENT;
    return 0;
}

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


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
		string s;
		cin >> s;
		ll ans = 0;
		for (int i=(int)s.length()-1 ; i>=0 ; i--)
		{
			int x = s[i] - '0';
			ans+=x;
		//	cerr << imie(ans) imie(x) imie(s[i]);
		}
		//cout << ans << endl;
		(ans%9==0)? cout << "Yes" << endl : cout << "No" << endl;
		return 0;
}  


Measured memory_bytes: 3764
def dist(x, y, pp)
  result = 0
  if pp != 0
    for i in 0...x.length
      result += (x[i] - y[i]).abs ** pp
    end
    result **= (1.0 / pp)
  else
    for j in 0...x.length
      result = (x[j] - y[j]).abs if (x[j] - y[j]).abs > result
    end
  end
  return result
end
gets
x, y = gets.split(" ").map(&:to_i), gets.split(" ").map(&:to_i)
4.times do |i|
  puts dist(x, y, (i + 1) % 4)
end

Measured memory_bytes: 6184
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  
  int a,b;cin >> a >> b;
  cout << max(0,a-2*b);

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main() {
  long int a,b=1,c=0,count=0;
  cin>>a;

  for(int i=0;i<a;i++){
	cin>>c;
    if(c==b){
      b++;
      count++;
}
  }
  if(count==0){
    cout<<-1;
    return 0;
  }
 cout<<a-count;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, q; cin >> n >> q; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(begin(a), end(a)); a.erase(unique(begin(a), end(a)), end(a));
	
	std::vector<int> dp(sqrt(a.back()) + 1, -1);
	for(int i = 1; i < dp.size(); i++) {
		int ma = 0;
		for(int j = 0; j < n; j++) ma = std::max(ma, a[j] % i);
		dp[i] = ma;
	}
	
	for(int i = 0; i < q; i++) {
		int b; cin >> b;
		
		if(dp.size() <= b) {
			int k = -1, ma = 0;
			while(++k * b <= a.back()) {
				int p = lower_bound(begin(a), end(a), (k + 1) * b) - begin(a); p--;
				if(p >= 0) ma = std::max(ma, a[p] % b);
			}
			cout << ma << endl;
		} else {
			cout << dp[b] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
n,m,t = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] - m
for i,aa in enumerate(a):
	if i != 0 and (aa - a[i-1]) >= 2*m:
		ans += (aa - a[i-1] - 2*m )
	if i == len(a)-1 and (t - aa) >= m:
		ans +=  (t - aa - m)
		continue
print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int a[101];
	int Alice = 0, Bob = 0;

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + N + 1);

	bool AB = true;
	for (int i = N; i >= 1; i--) {
		if (AB == true) { Alice += a[i]; AB = false; }
		else { Bob += a[i]; AB = true; }
	}
	cout << Alice - Bob;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
 
int main() {
   int  n,w,gmax=0;
   cin>>n>>w;
   vector<int> weights(n,0),values(n,0);
 
   for(int i=0;i<n;i++)
    cin>>weights[i]>>values[i];
 
   vector<long long int> dp(100001);
 
   for(int i=0;i<=n;i++)
   {
       for(int j=100001;j>=0;j--)
       {
 
           if(j==0)
           {
               dp[j]=0;
               continue;
           }
 
           if(i==0)
           {
               dp[j]=w+1;
               continue;
           }
 
           if(values[i-1]<=j)
           {
               dp[j]=min(weights[i-1]+dp[j-values[i-1]],dp[j]);
           }
       }
   }
    
    for(int j=0;j<100001;j++)
       {
           if(dp[j]<=w)
            gmax=max(gmax,j);
       }
 
   cout<<gmax;
 
   return 0;
}

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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; }

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









int main(){
  string s;
  cin >> s;
  string f, b;
  ll Q;
  cin >> Q;
  int cnt = 0;
  int cnt2 = 0;
  REP(i, Q){
    int x;
    cin >> x;

    if(x == 1){
      cnt++;
      // cnt2++;
      }else if(x == 2){
        // cnt2 = 0;
        int y;
        cin >> y;
        char c;
        cin >> c;
        if(y == 1) {
          if(cnt % 2 == 0) f = c + f;
          else b = b + c;
        }
        else if(y == 2) {
          if(cnt % 2 == 0) b = b + c;
          else f = c + f;
      }
  }
  }

  

  string ans = f + s + b;
  if(cnt % 2 == 1) reverse(all(ans));
  print(ans);
  return 0;
}


Measured memory_bytes: 1512
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  // printf("Hello World\n") // Your code here!
    int a , b ;

    cin >> a;
    cin >> b;
    
    if (a<b){
   cout << "a < b";
} else if (a>b){
   cout << "a > b";
} else {
   cout<< "a == b";
}
   
    cout << endl;
}



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

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef pair <ll, ll> pi;

priority_queue<pi> qless;
priority_queue<pi, vector<pi>, greater<pi>> qgreat;
pi mid;
ll q, cnt, lsum, gsum, off;

int main() {
    fio;
    
    cin >> q;
    for(int i=0;i<q;i++) {
        int t;
        int a=0, b=0;
        cin >> t;
        if(t == 1) {
            cnt++;
            cin >> a >> b;
            off += b;
            if(i == 0) {
                mid = {a, 0};
                continue;
            }
            if(mid < (pi){a, i}) {
                qgreat.push({a,i});
                gsum += a-mid.first;
            }
            else {
                qless.push({a,i});
                lsum += mid.first-a;
            }
            while(qless.size() > (cnt-1)/2) {
                lsum -= (mid.first - qless.top().first) * qless.size();
                gsum += (mid.first - qless.top().first) * qgreat.size();
                qgreat.push(mid);
                mid = qless.top();
                qless.pop();
                gsum += (qgreat.top().first - mid.first);
            }
            while(qgreat.size() > (cnt)/2) {
                lsum -= (mid.first - qgreat.top().first) * qless.size();
                gsum += (mid.first - qgreat.top().first) * qgreat.size();
                qless.push(mid);
                mid = qgreat.top();
                qgreat.pop();
                lsum += (mid.first - qless.top().first);
            }
        }
        else
            cout << mid.first << ' ' /*<< lsum << ' ' << gsum << ' '  << off << ' ' */ << lsum + gsum + off <<  '\n';
    }
    return 0;
}

Measured memory_bytes: 4588
#include<cstdio>
using namespace std;
#define MAX 100000
#define NIL -1

struct Node{
  int parent,left,right;
};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root = 0;

  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;

  for(int i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(int i=0;i<n;i++) if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(int i=0;i<n;i++) print(i);
  return 0;
}



Measured memory_bytes: 2704
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1e5 + 10;
int a[maxn];
int main(){
    IOS;
    int n, c, k;
    cin >> n >> c >> k;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a + n);
    int cur = 0, cnt = 0;
    while(cur != n){
        int x = a[cur];
        int len = 0;
        for(int i=cur; len < c && i<n; i++){
            if(a[i] <= x + k)
                len++;
            else
                break;
        }
        cnt++, cur += len;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	LL fib[47];
	fib[0] = 1;
	fib[1] = 1;
	FOR(i, 2, 45)fib[i] = fib[i - 1] + fib[i - 2];

	int n; cin >> n;
	cout << fib[n] << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin >> n >> d;
  vector<long int> lx(n);
  vector<long int> ly(n);
  int count = 0;
  long double t = 0;
  for(int i=0; i<n; i++) {
    t = 0;
    cin >> lx[i] >> ly[i];
    t += lx[i]*lx[i];
    t += ly[i]*ly[i];
    t = sqrt(t);
    if(d >= t) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 6488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

int main() {
    long long a;
    string b;
    cin >> a >> b;

    long long b2 = 100 * (long long)(b[0] - '0') + 10 * (long long)(b[2] - '0') + 1 * (long long)(b[3] - '0');

    long long ans = a * b2 / 100;

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int a, b; cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
string s,k;
int main(){
    cin>>s>>k;
    if(s<k)
    {
        cout<<"<"<<endl;
    }
    if(s>k)
    {
        cout<<">"<<endl;
    }
    if(s==k)
    {
        cout<<"="<<endl;
    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

bool isPrime(ll n)
{
    bool res = true;
    for (ll i = 2; i + i <= n; ++i)
    {
        if (n % i == 0)
        {
            res = false;
            break;
        }
    }

    return res;
}
int main()
{
    ll X;
    cin >> X;
    ll ans;
    for(ll i = X; ; ++i)
    {
        if (isPrime(i))
        {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


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

string devide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  string S;
  cin >> S;

  // 反転
  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; i++)  reverse(devide[i].begin(), devide[i].end());

  //端から切っていく
  bool can = true;
  for(int i = 0; i != S.size();){
    bool can2 = false; // devideの文字のどれかに当てはまるか

    for(int j = 0; j < 4; j++){
      string d = devide[j];
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }

  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  long w , h;
  scanf("%ld %ld",&w,&h);
  long x , y;
  scanf("%ld %ld",&x,&y);
  
  long double ans = (w*h)/2.0;
  printf("%10llf",ans);
 
  if(w%2 == 0 && h%2 == 0&&x == w/2 && y == h/2){
    printf(" 1");
  }
  else{
    printf(" 0");
  }
  
  return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

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

int N, M;
set <P> AB;


string search(){
    for(auto ab:AB){
        if(ab.first==1 && AB.find(P(ab.second, N))!=AB.end()) return "POSSIBLE";
    }
    return "IMPOSSIBLE";
}

int main() {
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        AB.insert(P(a,b));
    }
    
    cout << search() << endl;
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "YES";
const string NO = "NO";



void solve(long long H, long long W, long long N, long long s_r, long long s_c, std::string S, std::string T){
    LL l = -1, r = W, u = -1, d = H;

    RREP(i, N-1) {
        if(i != N - 1) {
            if(T[i] == 'U') d = min(H, d+1);
            if(T[i] == 'D') u = max(-1LL, u-1);
            if(T[i] == 'L') r = min(W, r+1);
            if(T[i] == 'R') l = max(-1LL, l-1);
        }

        if(S[i] == 'U') u++;
        if(S[i] == 'D') d--;
        if(S[i] == 'L') l++;
        if(S[i] == 'R') r--;
        
        if(l == r || d == u || l == W-1 || r == 0 || u == H-1 || d == 0) {
            cout << NO << endl;
            return;
        }
    }

    s_r--;
    s_c--;
    if(s_r <= u || d <= s_r || s_c <= l || r <= s_c) {
        cout << NO <<endl;
    }else{
        cout << YES << endl;
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    long long s_r;
    scanf("%lld",&s_r);
    long long s_c;
    scanf("%lld",&s_c);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(H, W, N, s_r, s_c, S, T);
    return 0;
}


Measured memory_bytes: 1160
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int now = 0;
        String[] S = new String[H];
        for (int i = 0; i < H; i++) {
            S[i] = sc.next();           
        }
        int index = 1;
        for (String s : S) {
            index--;
            boolean order = true;
            for (int i = 0; i < s.length(); i++) {
                char nowmark = s.charAt(i);
                if (nowmark == '#') {
                    if (i != index) {
                        System.out.println("Impossible");
                        return;
                    }
                    if (!order) {
                        System.out.println("Impossible");
                        return;
                    }
                    index++;
                } else {
                    if (i >= index) {
                        order = false;
                    }
                }
            }
        }
        System.out.println("Possible");
    }
    
}

Measured memory_bytes: 35676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int n;
  scanf("%d",&n);

  int count = 0;
  int digit = 1;
  for(int i = 1; i <= n; ++i){
    if(i == 10 || i == 100 || i == 1000 || i == 10000 || i == 100000) digit ++;
    if(digit % 2 == 1) count ++;
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
int main() {
   // cout<<"Hello World!";
  int a;
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200)
  {
      cout<<s<<endl;
  }
  else
  {
      cout<<"red"<<endl;
  }


}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<ll>a,b,c,ab,abc;
ll x,y,z,k,A;
int main(void){
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++){
        cin>>A;
        a.push_back(A);
    }
    for(int i=0;i<y;i++){
        cin>>A;
        b.push_back(A);
    }
    for(int i=0;i<z;i++){
        cin>>A;
        c.push_back(A);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    for(int i=0;i<min(3000LL,x*y);i++){
        for(int j=0;j<z;j++){
            abc.push_back(ab[i]+c[j]);
        }
    }
    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());
    for(int i=0;i<k;i++)cout<<abc[i]<<endl;
}


Measured memory_bytes: 43384
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static char S[200001];

int main(void) {
    size_t N, A, B, C, D;

    scanf("%zu %zu %zu %zu %zu\n%s", &N, &A, &B, &C, &D, S);
    A--;
    B--;
    C--;
    D--;

    if (C < D) {
        for (size_t pos = A + 1; pos <= D; pos++) {
            if (S[pos] == '#' && S[pos - 1] == '#') {
                puts("No");
                return 0;
            }
        }

        puts("Yes");
    }
    else {
        bool containsSwapSpace = false;
        for (size_t pos = A + 1; pos <= C; pos++) {
            if (S[pos] == '#' && S[pos - 1] == '#') {
                puts("No");
                return 0;
            }
            if (B + 1 <= pos && pos < D + 2) {
                if (S[pos] == '.' && S[pos - 1] == '.' && S[pos - 2] == '.') {
                    containsSwapSpace = true;
                }
            }
        }
        if (!containsSwapSpace) {
            puts("No");
            return 0;
        }

        puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 384
N = gets.to_i
d = gets.split(" ").map(&:to_i)
d.sort!
cnt = 0
if d.size % 2 != 0
  c1 = c2 = d.size/2
else
  c1 = d.size/2 - 1
  c2 = d.size/2 
end
d[c1].upto(d[c2]-1) do |k|
  cnt += 1
end
puts cnt

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

int main(){
    string s; cin >> s;
    int ans = 0;
    rep(i, s.size()){
        if(s[i]=='2') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3508
def ans():
  N, M = map(int,input().split())
  A = [list(map(int,input().split())) for _ in range(N)]
  d = {}
  cnt = 0
  for a in A:
    for j in range(1,a[0]+1):
      if(a[j] in d):
        d[a[j]] += 1
      else:
        d[a[j]] = 1
      if(d[a[j]] == N):
        cnt += 1
  print(cnt)
ans()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
map<string,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc(n);
    char last;
    rep(i,1,n) {
        string S;
        cin >> S;
        if(M[S] == 1 or (i != 1 and S[0] != last)) {
            printf("No\n");
            return 0;
        }
        M[S] = 1;
        last = S[S.size() - 1];
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] A = new int[N-1];
    for(int i=0; i<N-1; i++) {
      A[i] = scan.nextInt();
    }
    scan.close();

    int[] count = new int[N];
    for(int i=0; i<N-1; i++) {
      count[A[i]-1]++;
    }
    for(int i=0; i<N; i++) {
      System.out.println(count[i]);
    }
  }
}

Measured memory_bytes: 59220
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int data[][] = new int[m][2];

		for (int i = 0; i < m; i++) {
			data[i][0] = sc.nextInt();
			data[i][1] = sc.nextInt();
		}

		int min = data[0][0];
		int max = data[0][1];

		for (int i = 1; i < m; i++) {
			if (min < data[i][0]) {
				min = data[i][0];
			}
			if (max > data[i][1]) {
				max = data[i][1];
			}
		}

		int result = max - min + 1;
		
		if (result < 0) {
			System.out.println(0);
		} else {
			System.out.println(result);
		}
	}
}

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



int main(void) {

    string s;

    cin >> s;

    if ( s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes";
    } else {
        cout << "No";

    }
}

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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll e, y;
	cin >> e >> y;
	switch(e){
	case 0:
		if (y <= 1911)
			cout << "M" << y - 1868+1 << endl;
		else if (y <= 1925)
			cout << "T" << y - 1912+1 << endl;
		else if (y <= 1988)
			cout << "S" << y - 1926+1 << endl;
		else
			cout << "H" << y - 1989+1 << endl;
		break;
	case 1:
		cout << y + 1868-1 << endl;
		break;
	case 2:
		cout << y + 1912 - 1 << endl;
		break;
	case 3:
		cout << y + 1926 - 1 << endl;
		break;
	default:
		cout << y + 1989 - 1 << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 3120
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
cnt = 0
last_a = 0
first_b = 0
double = 0
for i in range(N):
    s = input()
    for j in range(len(s) - 1):
        if s[j] == 'A' and s[j + 1] == 'B':
            cnt += 1
    if s[0] == 'B' and s[-1] == 'A':
        double += 1
    elif s[0] == 'B':
        first_b += 1
    elif s[-1] == 'A':
        last_a += 1
opt = 0
if first_b == 0 and last_a == 0 and double != 0:
    opt = double - 1
else:
    opt = min(first_b + double, last_a + double)
print(cnt + opt)

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

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    char c=s1.at(0);
    s1.at(0)=s1.at(2);
    s1.at(2)=c;
    if(s1==s2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
"""
Main??????????????????
"""
# Node??°?????????
N = int(input())

# Node??????????????????????????????
nodes = [[0 for i in range(N)] for j in range(N)]

# Node??????????¨????
for i in range(N):
    j = list(map(int, input().split())) # ??\??????????§£
    no = j[0] - 1                       # Node???????????????
    childNos = j[2:]                    # ??????????´??????????

    for j in range(len(childNos)):
        childNo = childNos[j] - 1
        nodes[no][childNo] = 1


# ??¨?????????
for i in range(N):
    for j in range(N):
        if j != N -1:
            print(nodes[i][j], end=" ")
        else:
            print(nodes[i][j])

Measured memory_bytes: 8352
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    private static int MAX = 10000;
    private static int MIN = 1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int i = 1;
            while (sc.hasNext()) {
                int x = Integer.parseInt(sc.nextLine());
                if (x == 0) {
                    break;
                }
                if (x > MAX || x < MIN || i > MAX) {
                    System.out.println("Condition is invalid.");
                    return;
                }
                System.out.printf("Case %d: %d\n", i++, x);
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}



Measured memory_bytes: 74780
#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a!=b&&a!=c&&b!=c)printf("3\n");
    else if(a!=b&&(a!=c || b!=c) || a!=c&&(a!=b || b!=c))printf("2\n");
    else printf("1\n");
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int n,c=0;
  	cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
      	cin >> a[i];
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
        if(a[i]==a[j])
          	continue;
        else
          for(int k=j+1;k<n;k++)
            if(a[i]!=a[k] && a[j]!=a[k])
              if((a[i]+a[j]>a[k])&&(a[i]+a[k]>a[j])&&(a[j]+a[k]>a[i]))
                c++;
      }
    cout << c; 
    return 0;
}

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

using namespace std;

int main() {
	set <int> s;
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	s.insert(a);
	s.insert(b);
	s.insert(c);
	printf("%d\n",s.size());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

void leapYear(int, int);
int main()
{
  int check1 = 0;
    while (true) {
        int a, b;
        std::cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if (check1 == 1) {
            std::cout << std::endl;
        }
        check1 = 1;
        leapYear(a, b);
    }
    return 0;
}
void leapYear(int a, int b)
{
    int check2 = 0;
    for (int year = a; year <= b; ++year) {
      if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            std::cout << year <<std::endl;
            check2 = 1;
      }
    }
    if (check2 == 0) {
        std::cout << "NA" <<std::endl;
    }
}

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

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  deque<ll> dq;

  if(n%2 == 0) {
    rep(i, n) {
      if(i%2 == 0) dq.push_back(a[i]);
      else dq.push_front(a[i]);
    }
  } else {
    rep(i, n) {
      if(i%2 != 0) dq.push_back(a[i]);
      else dq.push_front(a[i]);
    }
  }
  rep(i, n) {
    cout << dq[i] << (i == n-1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 5376