akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vP p(N),q(N);
    rep(i,N){
        cin >> p[i].first >> p[i].second;
    }
    rep(i,N){
        cin >> q[i].first >> q[i].second;
    }
    sort(p.begin(),p.end(),greater<P>());
    sort(q.begin(),q.end(),greater<P>());
    set<int> st;
    st.insert(1e9);
    ll ans=0;
    ll np=0,nq=0;
    per(i,2*N-1){
        if(nq!=N&&q[nq].first==i){
            st.insert(q[nq].second);
            nq++;
        }
        if(np!=N&&p[np].first==i){
            int z=*st.lower_bound(p[np].second+1);
            if(z!=1e9){
                ans++;
                st.erase(z);
            }
            np++;
        }
    }
    cout << ans << endl;cerr<< 1 << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int n;
    	cin>>n;
    	int arr[n+1]={0};

    	for(int i=0;i<n-1;i++)
    	{
    		int x;
    		cin>>x;
    		arr[x]++;
    	}
    	for(int i=1;i<=n;i++)
    		cout<<arr[i]<<endl;
    	
    	
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> Bs(M);
    for (int i = 0; i < M; ++i)
    {
        cin >> Bs[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int sum = C;
        for (int j = 0; j < M; ++j)
        {
            int Aij;
            cin >> Aij;
            sum += Bs[j] * Aij;
        }
        if (sum > 0)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

int main() {
    int p[5][4][11], b, f, r, v, num, i, j, k;

    for(i=0;i<5;i++){
        for(j=0;j<4;j++){
            for(k=0;k<11;k++){
                p[i][j][k]=0;
            }
        }
    }

    cin >> num;
    for(i=0;i<num;i++){
        cin >> b >> f >> r >> v;
        p[b][f][r] = p[b][f][r] + v;
    }

    for(i=1;i<4;i++){
        for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                cout << " " << p[i][j][k];
            }
            cout << endl;
        }
        for(k=0;k<20;k++){
                cout << "#";
        }
        cout << endl;
    }

        for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                cout << " " << p[4][j][k];
            }
            cout << endl;
        }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M,C,sum=0;
  cin>>N>>M>>C;
  int linear=C;
  vector<int>vecB(M);
  for(int i=0;i<M;i++) cin>>vecB[i];
  vector<vector<int>>vecA(N,vector<int>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>vecA.at(i).at(j);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      linear+=vecB.at(j)*vecA.at(i).at(j);
    }
    if(linear>0){
      sum++;
      linear=C;
    }
    else linear=C;
    
  }
    
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int parent(int i)
{
	return i / 2;
}
int left(int i)
{
	return i * 2;
}
int right(int i)
{
	return i * 2 + 1;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	long A[n + 1];
	for(int i = 1; i <= n; i++)
		cin >> A[i];
	for(int i = 1; i <=n; i++)
	{
		cout << "node " << i << ": key = " << A[i] << ", ";
		if(parent(i) >= 1)
			cout << "parent key = " << A[parent(i)] << ", ";
		if(left(i) <= n)
			cout << "left key = " << A[left(i)] << ", ";
		if(right(i) <= n)
			cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}




Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
#define coutd if(DEBUG) cout 
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vii = vector<ii>;
const double PI = acos(-1);
const double EPS = 1e-9;

const long long MAX = 2000009;
ll sievesize;
bitset<MAX> bs;
vector<ll> primes;

void sieve(ll n){
    sievesize = n+1;
    bs.set();
    bs[0]=bs[1]=0;
    for(ll i=2; i<=sievesize; ++i){
        if(bs[i]){
            for(ll j=i*i; j<=sievesize; j+=i)
                bs[j]=0;
            primes.push_back(i);
        }
    }
}
bool is_prime(ll n){
    if(n<=(ll)sievesize) return bs[n];
    for(size_t i=0; i<primes.size() and primes[i]*primes[i]<=n; ++i)
        if(n%primes[i]==0) return false;
    return true;
}
int main(){
	ios::sync_with_stdio(0);
	ll a, b;
	cin >> a >> b;
	sieve(MAX);
	unordered_set<ll> div;
	for(ll i=1; i*i<=a; ++i){
		if(a%i==0){
			div.insert(i);
			div.insert(a/i);
		}
	}
	unordered_set<ll> st;
	for(ll i=1; i*i<=b; ++i){
		if(b%i==0){
			if(div.find(i)!=div.end())
				st.insert(i);
			if(div.find(b/i)!=div.end())
				st.insert(b/i);
		}
	}
	unordered_set<ll> pr;
	for(auto x:st)
		if(is_prime(x)) pr.insert(x);
	for(auto x:st){
		bool can=true;
		for(auto y:pr){
			if(x%y) continue;
			can=false;
			break;
		}
		if(can) pr.insert(x);
	}

	cout << len(pr) << endl;
}


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

// vector<int> dp(100000, 1e9);



ll sum(ll num)
{
    ll ans = num * (num + 1) / 2;
    return ans;
}

int main()
{
    ll N;
    ll ans = 0;
    scanf("%lld", &N);
    ll n3 = floor(N / 3);
    ll n5 = floor(N / 5);
    ll n15 = floor(N / 15);
    ll ansN = sum(N);
    ll ansN3 = sum(n3);
    ll ansN5 = sum(n5);
    ll ansN15 = sum(n15);
    ans = ansN - (3*ansN3 +5* ansN5 -15* ansN15);
    // cout << ansN << endl
    //  << ansN3 << endl
    //  << ansN5 << endl
    //  << ansN15 << endl;
    printf("%lld",ans);


    return 0;
}

Measured memory_bytes: 3824
S =[]
line = gets.split(" ").map {|n| n}
top = 0
i = 0

def push(x)
    top +=1
    S[top] = x
end

def pop1
    top -=1
    return S[top+1]
end

while i < line.count
    if line[i] == "+"
        a = S.pop
        b = S.pop
        S.push (a + b)
    elsif line[i] == "-"
        a = S.pop
        b = S.pop
        S.push (b - a)
    elsif line[i] == "*"
        a = S.pop
        b = S.pop
        S.push (a * b)
    else
        S.push(line[i].to_i)
    end
    i =i+1
end

puts S.pop


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

typedef struct
{
  /* This element must be the top of this structure. */
  char  s[ 31 ];
  int   pg;
} entry;

int cmpr (
  entry * a,
  entry * b
  )
{
  return ( a->pg - b->pg );
}

int main (
  void
  )
{
  entry e[ 100 ];
  int   l = 0;
  int   i;

  while ( scanf ( " %s %d", e[ l ].s, &e[ l ].pg ) == 2 )
  {
    ++l;
  }

  qsort ( e, l, sizeof ( entry ),
    (int (*)( const void *, const void * ))cmpr );
  qsort ( e, l, sizeof ( entry ),
    (int (*)( const void *, const void * ))strcmp );

  puts ( e[ 0 ].s );
  printf ( "%d", e[ 0 ].pg );
  for ( i = 1; i < l; ++i )
  {
    if ( strcmp ( e[ i - 1 ].s, e[ i ].s ) )
    {
      printf ( "\n%s\n%d", e[ i ].s, e[ i ].pg );
    }
    else
    {
      printf ( " %d", e[ i ].pg );
    }
  }
  puts ( "" );

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
using namespace std;


int main(void){
  int datanum;
  int notprimenum;
  int data;
  int divnum;

  notprimenum = 0;

  cin >> datanum;

  for (int i = 0 ; i < datanum ; i++){
    cin >> data;
    if(data == 1){
      notprimenum++;
      continue;
    }else if(data == 2){
      continue;
    }else if(data == 3){
      continue;
    }else{

      if(data % 2 == 0){
        notprimenum++;
        continue;
      }

      for (divnum = 3 ; divnum <= (int)sqrt(data) ; divnum += 2){
        if(data % divnum == 0){
          notprimenum++;
          break;
        }
      }
    }
  }

  cout << datanum - notprimenum << endl;

  return 0;
}

Measured memory_bytes: 3068
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, a, b, ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> a >> b;
    ans += (n / (a + b)) * a;
    ans += min((n % (a + b)), a);
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	vector< int > A(26,-1);
	for(int i=0;i<size;++i){
		int now = (str[i]-'a');
		if( A[now] == -1 ){
			A[now] = i;
		}else{
			int Len = i-A[now];
			if( Len <= 2 ){
				cout << A[now]+1 << " " << i+1 << endl;
				return;
			}
			A[now] = i;
		}
	}
	cout << "-1 -1" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

#define ll long long
#define MOD 1000000007


int main(){
    int h,w;
    cin>>h>>w;

    vector<vector<char>> t(h+2,vector<char>(w+2,'#'));

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>t.at(i).at(j);
        }
    }

    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            cout<<t.at(i).at(j);
        }
        cout<<endl;
    }


}



Measured memory_bytes: 256
def kaibun(S):
    n = len(S)
    if(n%2 != 0):
        for i in range(int((n-1)/2)):
            if(S[i] != S[n-i-1]):
                return 0
    else:
        for i in range(int(n/2)):
            if(S[i] != S[n-i-1]):
                return 0
    return 1
def kaikai(S):
    if(kaibun(S) == 0):
        print('No')
        return 0
    else:
        N = len(S)
        n = int((N-1)/2)
        S1 = S[:n]
        S2 = S[n + 1:]
        if(kaibun(S1) == 1 and kaibun(S2) == 1):
            print('Yes')
        else:
            print('No')
S = input()
kaikai(S)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
ll a,b,v,w,t;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>a>>v>>b>>w>>t;
    int flag;
    if(a<=b){
    	flag=((a+v*t)>=(b+w*t));
	}
	else{
		flag=((a-v*t)<=(b-w*t));
	}
	if(flag) cout<<"YES";
	else cout<<"NO";
    return 0;
}



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

using namespace std;

int main() {

    int N, X, T;
    cin >> N >> X >> T;

    int number;

    if(N % X == 0) {
        number = N / X;
    } else {
        number = (N / X) + 1;
    }

    int ans = T * number;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();
        char[] S = str.toCharArray();
        HashSet<Character> hs1 = new HashSet<Character>();
        HashSet<Character> hs2 = new HashSet<Character>();
        HashSet<Character> hs3 = new HashSet<Character>();
        
        int ans=0;
        for (int i = 0; i < N; i++) {
            if(hs1.add(S[i])){
                hs2.clear();
                for (int j = i+1; j < N; j++) {
                    if(hs2.add(S[j])){
                        hs3.clear();
                        for (int k = j+1; k < N; k++) {
                            hs3.add(S[k]);
                        }
                        ans+=hs3.size();
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24916
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e2 + 5;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n , a[N];
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> a[i];
    sort(a , a + n);
    int ans = 0;
    for(int i = 0;i < n;i++)
        for(int j = i + 1;j < n;j++)
            for(int k = j + 1;k < n;k++)
                if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k])
                    ans++;
    cout << ans;
    return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

int32_t main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a,b,c;
	cin>>a>>b>>c;
	cout<<max((int)0,c-(a-b));

    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int H, W, N, sh, sw;
	cin >> H >> W >> N >> sh >> sw;
	string a, b;
	cin >> a >> b;
	vector<string> opp({ "RL", "LR", "UD", "DU" });
	bool res = false;
	{
		int st = sw, mx = W;
		forn(i, N)
		{
			if (a[i] == 'R')
				++st;
			if (st > mx)
				res = true;
			if (b[i] == 'L')
				--st;
			st = max<int>(st, 1);
		}
		int alma = 42;
	}

	{
		int st = sw, mi = 0;
		forn(i, N)
		{
			if (a[i] == 'L')
				--st;
			if (st == mi)
				res = true;
			if (b[i] == 'R')
				++st;
			st = min<int>(st, W);
		}
		int alma = 42;
	}

	{
		int st = sh, mx = H;
		forn(i, N)
		{
			if (a[i] == 'D')
				++st;
			if (st > mx)
				res = true;
			if (b[i] == 'U')
				--st;
			st = max<int>(st, 1);
		}
		int alma = 42;
	}

	{
		int st = sh, mi = 0;
		forn(i, N)
		{
			if (a[i] == 'U')
				--st;
			if (st == mi)
				res = true;
			if (b[i] == 'D')
				++st;
			st = min<int>(st, H);
		}
		int alma = 42;
	}
	
	if (!res)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


Measured memory_bytes: 920
x,n = map(int,input().split()) # take input from the user
P = list(map(int,input().split()))
 
for i in range(101): # loop through the range
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  elif xr not in P:
    print(xr)
    break

# time complixity O(N)

Measured memory_bytes: 9084
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]"):
    answer = 0

    for i in range(N):
        if A[i]>=B[i]:
            A[i] -= B[i]
            answer += B[i]
            B[i] = 0
        else:
            B[i] -= A[i]
            answer += A[i]
            A[i] = 0

            if A[i+1]>=B[i]:
                answer += B[i]
                A[i+1]-=B[i]
            else:
                answer += A[i+1]
                A[i+1]=0
    print(answer)
        
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N + 1)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19452
n,T = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
if len(t)==1:
    print(T)
else:
    for i in range(1,len(t)):
        diff = t[i]-t[i-1]
        if diff < T:
            ans += diff
        else:
            ans += T
    print(ans+T)


Measured memory_bytes: 85456
import Data.List

ans (a':b':c':_) =
  let a = drop 1 a'
      b = drop 1 b'
      c = drop 1 c'
      r = (c \\ a) `union` (b `intersect` c)
  in
    length r

main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  print o
  

Measured memory_bytes: 4136
import java.util.*

fun main(args: Array<String>){
    val input = readLine()!!.toInt()
    var res = 0

    for (i in 1 until input+1) {
        for (j in i until input+1) {
            for (h in j until input+1) {
                res += gcd(listOf(i, j, h)) * calc(i, j, h)
            }
        }
    }
    println(res)
}

fun calc(i: Int, j: Int, h: Int): Int {
    if (i == j && j == h) return 1
    if (i == j || j == h) return 3
    return 6
}

fun gcd(list: List<Int>): Int {
    // 最大公約数を求める対象となる数が格納されたスタック
    val stack = listToStack(list)

    // ユークリッドの互除法を用いて、最大公約数を導出する
    // (最終的にスタック内に1つだけ数が残り、それが最大公約数となる)
    while (1 < stack.size) {
        // スタックから2つの数をpop
        val pops = (0 until 2).map {
            stack.pop()
        }

        // スタックからpopした2つの数のうち、小さい方の数のインデックス
        val minIndex = if (pops[1] < pops[0]) {
            1
        } else {
            0
        }

        // スタックからpopした2つの数のうち、小さい方の数をpush
        stack.push(pops[minIndex])

        // スタックからpopした2つの数の剰余
        val r = pops[(minIndex + 1) % 2] % pops[minIndex]

        // スタックからpopした2つの数に剰余があるならば、それをpush
        if (0 < r) {
            stack.push(r)
        }
    }

    // 最大公約数を返す
    return stack.pop()
}

fun listToStack(list: List<Int>): Stack<Int> {
    // スタック
    val stack = Stack<Int>()

    for (e in list) {
        stack.push(e)
    }

    return stack
}



Measured memory_bytes: 57580
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200) {
        cout<<s<<endl;
        return 0;
    }
    cout<<"red"<<endl;

    return 0;
}


Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	int mn[] = {105,135,165,189,195};
	int res = 0;
	for (int i = 0; i < 5; ++i) {
		if (N < mn[i]) {
			break;
		}
		else {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  ll v2 = 0, v4 = 0;
  REP(i, 0, N) {
    cin >> A[i];
    if (A[i] % 4 == 0) {
      v4++;
    } else if (A[i] % 2 == 0) {
      v2++;
    }
  }

  ll n;
  if (N % 2 == 0) {
    n = N;
  } else {
    n = N - 1;
  }
  if (n / 2 <= v4 + (v2 / 2)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

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

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int a, b, c;
	cin >> a >> b >> c;
	int h[101] = { 0 };

	h[a]++;
	h[b]++;
	h[c]++;

	int ans = 0;
	FOR(i, 1, 101) {
		if (h[i] > 0) ans++;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=50000;
ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

bool prime[10000001];
void fin()
{
    for(int i=2;i*i<=1000000;i++)
    {
        if(!prime[i])
        for(int j=i*i;j<=1000000;j+=i)
            prime[j]=true;
    }
}


void solve()
{
    string s;
    cin>>s;
    ll a=0,b=0,n=s.length();
    //debug(n);
    for(int i=0;i<n;i++)if(s[i]=='A')a++;else b++;
   // debug2(a,b);
    if(a!=0 && b!=0)
        cout<<"Yes";
    else
        cout<<"No";
}

int main(){
    boost;
  solve();
}


Measured memory_bytes: 384
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}
fn mm(a : i64, b : i64) -> i64 {
    if a > b {
        uq(a, b);
    }
    uq (b, a)
}

fn uq(l : i64, s : i64) -> i64 {
    if l % s == 0 {
        return s;
    }
    uq(s, l % s)
}

fn main() {
    let input : usize = rd_one();
    let a : Vec<i64> = rd_vec();
    let mut answer = a[0];
    for i in 1..input {
        answer = mm(answer, a[i]);
    }
    println!("{}", answer);
}

Measured memory_bytes: 8444
def sarch(B, C, D):
    return a + B * b + C * c + D * d == 7

def ansprint(B, C, D):
    print(str(a) + B + str(b) + C + str(c) + D + str(d) + "=7")

def figstr(B, C, D):
    BB = "-"
    CC = "-"
    DD = "-"
    if B == 1:
        BB = "+"
    if C == 1:
        CC = "+"
    if D == 1:
        DD = "+"
    ansprint(BB, CC, DD)

S = input()
a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])

if sarch(1, 1, 1):
    figstr(1, 1, 1)
elif sarch(1, -1, 1):
    figstr(1, -1, 1)
elif sarch(1, 1, -1):
    figstr(1, 1, -1)
elif sarch(-1, 1, 1):
    figstr(-1, 1, 1)
elif sarch(-1, -1, 1):
    figstr(-1, -1, 1)
elif sarch(1, -1, -1):
    figstr(1, -1, -1)
elif sarch(-1, 1, -1):
    figstr(-1, 1, -1)
elif sarch(-1, -1, -1):
    figstr(-1, -1, -1)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

int slv(string &a, string &b)
{
  sort(ALL(a));
  sort(ALL(b));
  unordered_set<char> U;
  set_intersection(ALL(a), ALL(b), inserter(U, U.end()));
  return LEN(U);
}

signed main()
{
  int N; string s; cin >> N >> s;

  int ans = 0;
  for (int i = 1; i < LEN(s)-1; ++i) {
    string a = s.substr(0, i);
    string b = s.substr(i, LEN(s)-i);
    chmax(ans, slv(a,b));
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
const ll af=1000000007;
int main() {
	string s,t;
	int n;
	ll ans=0;
	ll wa=0;
	cin >>n;
	vector<ll>a(n);
	rep(i,n){
		cin >>a[i];
		if (i>0)wa+=a[i-1];
		ans+=(a[i]%af)*(wa%af);
		ans %=1000000007;
	}
	cout <<ans<<endl;
	return 0;
}


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

ll gcd(ll a, ll b){
	
	ll x = a * b;
	  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
	  /* ユークリッドの互除法 */
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return x/b;

}


int main(){
	
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	
	ll total = b-a+1; // 総数
	ll cdiv = 0; // cで割れる数の総数
	ll ddiv = 0; // dで割れる数の総数
	ll div = 0; // c or dで割れる数の総数
	
	cdiv = b/c - (a-1)/c;
	ddiv = b/d - (a-1)/d;
	div = cdiv + ddiv - ( b/gcd(c,d) - (a-1)/gcd(c,d) );
	
	cout << total-div << endl;
	return 0;
}

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


void solve(long long a, long long b){
    cout << round(((float)a + (float)b) / 2) << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
N = len(A)
amax = A[-1]
P = [0 for _ in range(amax+1)]
for i in range(N):
    P[A[i]] = 1
for i in range(N):
    a = A[i]
    for j in range(a*2,amax+1,a):
        P[j] = 0
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
for i in range(N):
    a = A[i]
    if P[a]==1 and C[a]>1:
        P[a] = 0
print(sum(P))

Measured memory_bytes: 196276
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c[ohara], d, tmp, m, h, w, x, y, sum, k, q;
ll flo[3000][3000];

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

  cin >> n >> m;
  rep(i, n) {
    rep(j, n) {
      if (i == j)
        flo[i][j] = 0;
      else
        flo[i][j] = LINF;
    }
  }
  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    flo[a[i]][b[i]] = c[i];
    flo[b[i]][a[i]] = c[i];
  }
  rep(i, n) {
    rep(j, n) {
      rep(k, n) { flo[j][k] = min(flo[j][i] + flo[i][k], flo[j][k]); }
    }
  }

  rep(i, m) {
    if (flo[a[i]][b[i]] == c[i]) continue;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 8960
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import numpy as np

MOD = 10 ** 9 + 7
N = int(input())

graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)

"""
包除の原理。各頂点を根として
・偶数個を選ぶ、そこが反例となっている、他は何でもよい、
・奇数個を選ぶ、そこが反例となっている、他は何でもよい
・根を含む成分は保留してある。保留している頂点の数を持っておく。
・偶数個の場合と奇数の場合の差分だけ持っておく
"""

def dp_merge(data1,data2):
    N1 = len(data1) - 1
    N2 = len(data2) - 1
    if N1 > N2:
        N1,N2 = N2,N1
        data1,data2 = data2,data1
    data = np.zeros(N1+N2, dtype = np.int64)
    for n in range(1,N1+1):
        data[n:n+N2] += data1[n] * data2[1:] % MOD
    data %= MOD
    return data

fact_2 = [1,0,1]
for n in range(3,N+10):
    fact_2.append(fact_2[n-2] * (n-1) % MOD)
fact_2 = np.array(fact_2, dtype = np.int64)

def dp_add_edge(data):
    N = len(data) - 1
    data1 = np.zeros(N+2, dtype=np.int64)
    # 辺を反例に加えない
    data1[1:] = data
    # 辺を反例に加える
    data1[1] = - (data * fact_2[:N+1] % MOD).sum() % MOD
    return data1

def dfs(v, parent = None):
    data = None
    for y in graph[v]:
        if y == parent:
            continue
        data1 = dfs(y, v)
        # mergeする前に、最後の辺をひとつ加える
        data1 = dp_add_edge(data1)
        if data is None:
            data = data1
        else:
            data = dp_merge(data, data1)
    if data is None:
        return np.array([0,1],dtype=np.int64)
    return data

data = dfs(1)

answer = (data * fact_2[:N+1] % MOD).sum() % MOD

print(answer)



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

struct NODE{
  int k;
  struct  NODE *p;
  struct NODE *l;
  struct NODE *ri;
};
typedef struct NODE * node;
#define N NULL
node r;
void ins(int o){
  node a=N;
  node b=r;
  node c;
  c=malloc(sizeof(struct NODE));
  
  c->k = o;
  c->l = N;
  c->ri = N;
  while(b!=N){
    a = b;
    if(c->k < b->k){
      b=b->l;
    }
    else{
      b=b->ri;
    } 
  }
  c->p=a;
  if(a==N){
    r=c;
  }
  else{
    if(c->k < a->k){
      a->l=c;
    }
    else{
      a->ri=c;
    }
  }
}

void T(node R){
  if(R==N)return;
  T(R->l);
  printf(" %d",R->k);
  T(R->ri);
}

void S(node R){
  if(R==N)return;
  printf(" %d",R->k);
  S(R->l);
  S(R->ri);
}
node minimum(node x){
  while(x->l != N) x = x->l;
  return x;
}
node suc(node x){
  if(x->ri != N) return minimum(x->ri);

  node y = x->p;
  while (y != N && x == y->ri){
    x = y;
    y = y->p;
  }
  return x;
}
node s(node l,int c){

  while(l !=N && c != l->k){
    if(c < l->k) {
      l = l->l;
    }
    else {
      l = l->ri;
    }
  }
  return l;
}
void d(node x){
  node y,z;

  if(x->l == N || x->ri == N) y = x;
  else y = suc(x);

  if(y->l != N) z = y->l;
  else z = y->ri;

  if(z != N) z->p = y->p;

  if(y->p == N) r = z;
  else if(y == y->p->l) y->p->l = z;
  else y->p->ri = z;

  if(y != x) x->k = y->k;
}

int main(){
  int i,j,o,h;
  char O[10];
  scanf("%d",&o);
  for(i=0;i<o;i++){
    scanf("%s",O);
    if(strcmp(O,"insert")==0){
      scanf("%d",&h);
      ins(h);
    }
    else if(strlen(O)==4){
      scanf("%d",&h);
      node f = s(r,h);
      if(f != N)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(O,"delete")==0){
      scanf("%d",&h);
      d(s(r,h));
    }
    else{
      T(r);
      printf("\n");
      S(r);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20612
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const ll MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const ll MAX = 210000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(ll i = 1; i < n; i++) {
        (ans += i * (n - i) % MOD * m % MOD * m % MOD) %= MOD;
    }

    for(ll i = 1; i < m; i++) {
        (ans += i * (m - i) % MOD * n % MOD * n % MOD) %= MOD;
    }

    (ans *= COM(n * m - 2, k - 2)) %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define lowbit(x) ((x) & -(x))
using namespace std;

int n;
vector <int> gl[200010];
long long c[200010];
void add(const int &it, const int &val);
long long query(const int &it);

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		gl[max(u, v)].push_back(min(u, v));
	}

	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		add(i, i);
		for (int j = 0; j < gl[i].size(); ++j)
			add(gl[i][j], -gl[i][j]);
		ans += query(i);
	}
	printf("%lld\n", ans);
	return 0;
}

void add(const int &id, const int &val) {
	for (int i = id; i <= n; i += lowbit(i))
		c[i] += val;
	return;
}

long long query(const int &id) {
	long long ret = 0;
	for (int i = id; i > 0; i -= lowbit(i))
		ret += c[i];
	return ret;
}



Measured memory_bytes: 16216
#include <stdio.h>

int main()
{
	int i,j,k,memo,n,A[100];
	scanf("%d",&n);
	for(i = 0; i < n; ++i)
	{
		scanf("%d",&A[i]);
    }

    for (i = 0; i < n-1; ++i)
    {
    	printf("%d ", A[i]);
    }
    printf("%d\n", A[n-1]);

	for (i = 1; i < n; ++i)
	{
		memo = A[i]; 
		j = i-1;
		while(j >= 0 && A[j] > memo)
		{
			A[j+1] = A[j];
			A[j] = memo;
			j--;
		}

		for (k = 0; k < n-1; ++k)
		{
			printf("%d ", A[k]);
		}
		printf("%d\n", A[n-1]);

	}

	return 0;
}

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

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll min_price = 1e18;
    for(int c_num = 0; c_num <= 2 * max(X,Y); c_num = c_num + 2){
        ll x = max(0, X - c_num / 2);
        ll y = max(0, Y - c_num / 2);
        //cout << min_price <<endl;
        min_price = min(min_price, x * A + y * B + c_num * C);
    }
    cout << min_price << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

ll modpow(ll a, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) res = (res * a) % mod;
        p >>= 1;
        a = (a * a) % mod;
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    if(n == 1) {
        cout << "0\n";
        return;
    }
    ll total = modpow(10, n), no09 = modpow(8, n), no0 = modpow(9, n);
    total = (total - (2 * no0) + no09) % mod;
    if(total < 0) total += mod;
    cout << total;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	string tmp;
    int h,w;
    cin >> h >> w;
    vector<string> a;
    REP(i,h){
        cin >> tmp;
        a.push_back(tmp);
    }
	int cou[26]={};
    REP(i,h) REP(j,w) cou[a[i][j]-'a']++;
    int mo[4]={};
    REP(i,26) mo[cou[i]%4]++;
    bool ch = true;
    if(h%2==1&&w%2==1){
        if(mo[1]==1&&mo[3]==0){
            mo[1]--;
            mo[0]++;
        }
        else if(mo[1]==0&&mo[3]==1){
            mo[3]--;
            mo[2]++;
        }
        else ch = false;
        if(mo[2]>(h-1)/2+(w-1)/2) ch = false;
    }
    else if(h%2==1){
        if(mo[1]!=0||mo[3]!=0) ch = false;
        if(mo[2]>w/2) ch = false;
    }
    else if(w%2==1){
        if(mo[1]!=0||mo[3]!=0) ch = false;
        if(mo[2]>h/2) ch = false;
    }
    else{
        if(mo[1]!=0||mo[3]!=0||mo[2]!=0) ch = false;
    }
	if(ch)cout << "Yes" << endl;
	else cout <<"No"<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int x, y;
    std::cin >> x >> y;

    int a[12] = {1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
    if (a[x-1] == a[y-1]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include<iostream>

using namespace std;
int main() {
	int a[3000];
	int b[3000];
	for (int i = 0; i < 3000; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0) {
			break;
		}
	}
	for (int i = 0; i < 3000; i++) {
		if (a[i] == 0 && b[i] == 0) {
			break;
		}
		if (a[i] < b[i]) {
			cout << a[i] << " " << b[i] << endl;
		}
		else {
			cout << b[i] << " " << a[i] << endl;
		}
	}

}

Measured memory_bytes: 3092
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 3005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

int n, m, k;
long long dp[MAX][MAX][4];
vector <vector <int> > cost;

long long calc(int r, int c, int t) {
	if (r > n || c > m)
		return 0ll; 
	long long &val = dp[r][c][t];
	if (val != -1)
		return val;
	val = 0;
	if (t < 3) {
		val = max(val, calc(r, c + 1, t + 1) + cost[r][c]);
		val = max(val, calc(r + 1, c, 0) + cost[r][c]);
	} 
	val = max(val, calc(r, c + 1, t));
	val = max(val, calc(r + 1, c, 0));
	return val;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	cost.assign(n + 1, vector <int> (m + 1, 0));
	for (int i = 0; i < k; ++i) {
		int r, c, v;
		cin >> r >> c >> v;
		cost[r][c] = v;
	}
	memset(dp, -1, sizeof(dp));
	cout << calc(0, 0, 0) << '\n';
	return 0;
}


Measured memory_bytes: 321268
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
A = l()
print(max(A)-min(A))

Measured memory_bytes: 77416
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible\n";
  }
  else{
    cout<<"Impossible\n";
  }
}


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

using namespace std;
typedef long long ll;

int main()
{

    ll numbers[3];

    for (int i = 0; i < 3; i++)
    {
        cin >> numbers[i];
    }

    sort(numbers, numbers + 3);

    if (numbers[0] == 5 && numbers[1] == 5 && numbers[2] == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

#define ll long long
#define forn(i, n) for(int i=0; i<int(n); i++)
#define endl '\n'

const int N=1e5+1, M=1e5+1;
vector<vector<int>> adj(N);
int in[N], out[N];

void dfs(int v, vector<int>& dp) {
    if(dp[v] > 0)
        return;

    if(!out[v]) {
        dp[v] = 0;
        return;
    }

    for(int it: adj[v]) {
        dfs(it, dp);
        dp[v] = max(dp[v], dp[it]);
    }

    dp[v]++;
}

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

    int n, m, x, y;
    cin>>n>>m;

    forn(i, m) {
        cin>>x>>y;
        x--; y--;

        adj[x].push_back(y);
        in[y]++;
        out[x]++;
    }

    int res=0;
    vector<int> dp(n, 0);

    forn(i, n) {
        if(!in[i]) {
            dfs(i, dp);
            res = max(res, dp[i]);
        }
    }

    cout<<res<<endl;
}



Measured memory_bytes: 14512