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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

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

    struct D {
        int w, s; ll v;
    };
    int n;
    cin >> n;
    V<D> blocks(n);
    for (int i = 0; i < n; i++) {
        cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
    }
    sort(blocks.begin(), blocks.end(), [&](D a, D b) {
        return a.w + a.s < b.w + b.s;
    });

    V<ll> dp(20100, -TEN(18)); dp[0] = 0;
    for (auto block: blocks) {
        int w = block.w, s = block.s; ll v = block.v;
        for (int i = s; i >= 0; i--) {
            dp[i + w] = max(dp[i + w], dp[i] + v);
        }
    }
    ll ans = -TEN(18);
    for (ll d: dp) ans = max(ans, d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    w,h,x,y = LI()
    area = w * h
    ans1 = area /2
    ans2 = 0
    if w == 2*x and h == 2*y:
        ans2 = 1

    print(ans1,ans2)

main()

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

const int N = 100005;

vector<int> adj[N];
int vis[N], cnt = 0;

void MAIN() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  queue<ii> q; q.push(ii(1, 1));
  while (q.size()) {
    ii i = q.front(); q.pop();
    if (vis[i.fi]) continue;
    vis[i.fi] = i.sc; cnt++;
    for (auto &j : adj[i.fi]) q.push(ii(j, i.fi));
  }
  if (cnt == n) {
    cout << "Yes" << '\n';
    for (int i = 2; i <= n; i++) {
      cout << vis[i] << '\n';
    }
  }
  else cout << "No" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 17184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> name(n);
  long int M,A,R,C,H; 
  M = A = R = C = H = 0;
  for(int i = 0;i < n;i++){
    cin >> name[i];
    string unqname = name[i];
    if(unqname[0] == 'M') M++;
    else if(unqname[0] == 'A') A++;
    else if(unqname[0] == 'R') R++;
    else if(unqname[0] == 'C') C++;
    else if(unqname[0] == 'H') H++;
  }
  long long int answer = 0;
  answer += M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
  cout << answer << endl;
}


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

using namespace std;

template <typename type>
type BaseChange(type num, type base, type digit)
{
    for(type i=0;i<digit;i++){
        num/=base;        
    }
    return num%base;
}

int main()
{
    // 基本データ入力
    long long n, m, x;
    cin >> n >> m >> x;
    
    // コストとデータ入力
    vector<long long> c(n);
    vector<vector<long long>> a(n,vector<long long>(m));
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(long long j=0;j<m;j++) cin >> a[i][j];
    }

    long long ans=(1<<30);

    // ビット全探索
    for(long long i=1;i<(1<<n);i++){
        long long cost=0;
        vector<long long> state(m,0);
        for(long long j=0;j<n;j++){
            // 検索文字がhit
            // cout << BaseChange(i,2,j);
            if(BaseChange(i,2LL,j)==1){
                cost+=c[j];
                for(long long k=0;k<m;k++){
                    state[k]+=a[j][k];
                }
            }
        }
        // cout << endl;
        // デバッグ用
        // cout << " " << cost << " ";
        // for(int j=0;j<m;j++) cout << state[j] << " ";
        // cout << endl;
        bool check=true;
        for(long long j=0;j<m;j++){
            if(state[j]<x) check=false;
        }
        if(check) ans = min(ans, cost);
    }
    if(ans==(1<<30)) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n,m;
  vector<int> v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&m);
    v.push_back(m);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n-1;i++){
    if(v[i]==v[i+1]){
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 1400
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int len = sc.nextInt();
			Set<Integer> set = new HashSet<>(len);
			for (int i = 1; i <= len; i++) {
				set.add(i);
			}
			int a = 1;
			for (int i = 1; i < len; i++) {
				int next = sc.nextInt();
				a += factorial(len - i) * count(set, next) - 1;
				set.remove(next);
			}
			sc.nextInt();
			set = new HashSet<>(len);
			for (int i = 1; i <= len; i++) {
				set.add(i);
			}
			int b = 1;
			for (int i = 1; i < len; i++) {
				int next = sc.nextInt();
				b += factorial(len - i) * count(set, next) - 1;
				set.remove(next);
			}
			System.out.print(Math.abs(b - a));
		}
	}

	private static int count(Set<Integer> set, int num) {
		int ans = 0;
		for (int i = 1; i <= num; i++) {
			if (set.contains(i)) {
				ans++;
			}
		}
		return ans;
	}

	private static int factorial(int num) {
		int ans = 1;
		for (int i = num; i >= 1; i--) {
			ans *= i;
		}
		return ans;
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;

#define endl '\n'

ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	ll a,b,g,cnt;
	cin>>a>>b;
	g=gcd(a,b);
	cnt=1;
	ll m=sqrt(g+0.5);
	for(int i=2;i<=m;i++){
		if(g%i==0){
			cnt++;
			while(g%i==0) g/=i;
		}
		if(i>g) break; 
	}
	if(g>1) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline void chmax(S &a, T b){
  if(a<b){
    a=b;
  }
}
int N, W, gain[4][100], sum[4][101], sz[4], v[100], w[100];
int main(){
  int a, b, c, d, i, j, res=0, tmp;
  long long minw, r;
  rd(N);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(w[Lj4PdHRW]);
      rd(v[Lj4PdHRW]);
    }
  }
  minw = w[0];
  for(i=0;i<N;i++){
    j = w[i] - minw;
    gain[j][sz[j]++] = v[i];
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY= 0;KL2GvlyY< (3) + 1;KL2GvlyY++){
      sort(gain[KL2GvlyY], gain[KL2GvlyY]+sz[KL2GvlyY]);
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS= 0;Q5VJL1cS< (3) + 1;Q5VJL1cS++){
      reverse(gain[Q5VJL1cS], gain[Q5VJL1cS]+sz[Q5VJL1cS]);
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY= 0;e98WHCEY< (3) + 1;e98WHCEY++){
      {
        int cTE1_r3A;
        for(cTE1_r3A= 1;cTE1_r3A< (sz[e98WHCEY]) + 1;cTE1_r3A++){
          sum[e98WHCEY][cTE1_r3A] += sum[e98WHCEY][cTE1_r3A - (1) + (0)] + gain[e98WHCEY][cTE1_r3A - (1) + (0)];
        }
      }
    }
  }
  for(a=0;a<sz[0]+1;a++){
    for(b=0;b<sz[1]+1;b++){
      for(c=0;c<sz[2]+1;c++){
        r = W - (long long)minw*a - (long long)(minw+1)*b - (long long)(minw+2)*c;
        if(r < 0){
          break;
        }
        d = min(r / (minw+3), (long long)sz[3]);
        chmax(res, sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d]);
      }
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170429-1

// --- original code ---
// int N, W, w[100], v[100];
// int gain[4][100], sum[4][101], sz[4];
// {
//   int res = 0, tmp;
//   int i, j, a, b, c, d;
//   ll r, minw;
//   rd(N, W, (w,v)(N));
//   minw = w[0];
//   rep(i,N){
//     j = w[i] - minw;
//     gain[j][sz[j]++] = v[i];
//   }
//   sort(gain[0..3], gain[0..]+sz[0..]);
//   reverse(gain[0..3], gain[0..]+sz[0..]);
// 
//   sum[0...3][1..sz[0...]] += sum[0...][0..] + gain[0...][0..];
// 
//   rep(a,sz[0]+1) rep(b,sz[1]+1) rep(c,sz[2]+1){
//     r = W - (ll)minw*a - (ll)(minw+1)*b - (ll)(minw+2)*c;
//     if(r < 0) break;
//     d = min(r / (minw+3), (ll)sz[3]);
//     res >?= sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
//   }
//   wt(res);
// }


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

struct Dice{
        vector<int>A;
        int t;
        void North(vector<int>&A){
            t=A[1],A[1]=A[2],A[2]=A[6],A[6]=A[5],A[5]=t;
        }
        void South(vector<int>&A){
            t=A[1],A[1]=A[5],A[5]=A[6],A[6]=A[2],A[2]=t;
        }
        void East(vector<int>&A){
            t=A[1],A[1]=A[4],A[4]=A[6],A[6]=A[3],A[3]=t;
        }
        void West(vector<int>&A){
            t=A[1],A[1]=A[3],A[3]=A[6],A[6]=A[4],A[4]=t;
        }
        void Spin(vector<int>&A){
            t=A[2],A[2]=A[3],A[3]=A[5],A[5]=A[4],A[4]=t;
        }
};
    
int main(){
    vector<int>N(7);
    for(int i=1;i<7;i++) cin>>N[i];
    int n; cin>>n;
    for(int i=0;i<n;i++){
        int a,b;cin >>a>>b;
        Dice d;
        while(N[1]!=a){
            d.North(N);
            if(N[1]!=a) d.East(N);
        }
        while(N[2]!=b) d.Spin(N);
    
        cout << N[3] << endl;
    }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[2005],b[2005],d[2005][2005],mod=1e9+7;
int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	for(int i=2;i<=n+1;i++){
		cin>>a[i];
	}
	for(int i=2;i<=m+1;i++){
		cin>>b[i];
	}
	d[1][1]=1;
	for(int i=1;i<=n+1;i++){
		for(int j=1;j<=m+1;j++){
			d[i][j]=(d[i][j]%mod+d[i][j-1]%mod+d[i-1][j]%mod-d[i-1][j-1]%mod)%mod;
			if(a[i]==b[j]) d[i][j]=(d[i][j]%mod+d[i-1][j-1]%mod)%mod;
		}
	}
	cout<<(d[n+1][m+1]%mod+mod)%mod<<endl;
}

Measured memory_bytes: 31616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<atcoder/all>
using namespace atcoder;

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;

long long myPow(lint x,lint n){
    lint res=1;
    lint cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
        }
        n/=2;cur*=cur;
    }
    return res;
}
map<long long,int> GetPrimes(long long n){
  long long buf=n;
  map<long long,int> res;
  for(long long i=2;i*i<=n;++i){
    while(buf%i==0){
      buf/=i;res[i]+=1;
    }
  }
  if(buf>1)res[buf]+=1;
  return res;
}
signed main(){
  lint n;cin>>n;
  map<lint,int> prime=GetPrimes(n*2);

  vector<pair<lint,int>> primes;
  for(auto& val:prime){
    primes.push_back({val.first,val.second});
  }
  lint num=primes.size();
  lint res=inf;
  //if(n%2==1)res=n-1;
  //else res=2*n-1;
  for(lint bit=0;bit<(1<<num);++bit){
    lint a=1;lint b=1;
    for(int i=0;i<num;++i){
      if(bit&(1<<i)){
        a*=myPow(primes[i].first,primes[i].second);
      }
      else{
        b*=myPow(primes[i].first,primes[i].second);
      }
    }
    vector<lint> r(2),m(2);
    r[0]=0;m[0]=a;
    r[1]=b-1;m[1]=b;
    auto p=crt(r,m);
    if(p.first==0)p.first=n*2;
    res=min(res,p.first);
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3664
<?php
list($r, $d, $x) = explode(' ', trim(fgets(STDIN)));

$i = 0;
amountOfAlgae($r, $d, $x, $i);

function amountOfAlgae($r, $d, $x, $i) {
	$nextX = $r * $x - $d;
  	echo $nextX, PHP_EOL;
  	$i++;
  
  	if ($i < 10) {
    	amountOfAlgae($r, $d, $nextX, $i);
    }
}

Measured memory_bytes: 4728
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){

    unsigned short *A,*B;

   int C[VMAX+1];
   int n,j,i;
   scanf("%d",&n);
   
   A=malloc(sizeof(short)  * n+1);
   B=malloc(sizeof(short)  * n+1);

   for(i=0;i<= VMAX;i++) C[i] =0;

   for(i=0; i < n; i++){
   scanf("%hu",&A[i+1]);
   C[A[i+1]]++;
   }
 
   for(i=1;i<= VMAX;i++) C[i] =C[i] +C[i-1];

   for(j=1; j <= n; j++){
   B[C[A[j]]] = A[j];
   C[A[j]]--;
   }
   
   for(i=1; i <= n; i++){
   if(i>1) printf(" ");
   printf("%d",B[i]);
   }
   printf("\n");
   return 0;
  }



Measured memory_bytes: 9560
n,d = map(int,input().split())
pnt = [list(map(int,input().split())) for _ in range(n)]
 
def dst(i, j):
    a = pnt[i]
    b = pnt[j]
    ret = 0
    for p, q in zip(a, b):
        ret += (p - q) ** 2
    r = int(ret ** (0.5))
    if r ** 2 == ret:
        return True
    else:
        return False
 
ret = 0
for i in range(n):
    for j in range(i + 1, n):
        tmp = dst(i, j)
        if tmp:
            ret += 1
print(ret)

Measured memory_bytes: 3064
W, H, N = list(map(int, input().split()))
x_min, x_max = 0, W
y_min, y_max = 0, H
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if x_min < x:
            x_min = x
    elif a == 2:
        if x < x_max:
            x_max = x
    elif a == 3:
        if y_min < y:
            y_min = y
    elif a == 4:
        if y < y_max:
            y_max = y
if x_max < x_min:
    print(0)
elif y_max < y_min:
    print(0)
else:
    print((x_max - x_min) * (y_max - y_min))

Measured memory_bytes: 3064
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
	
using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///=====code start here=====///

signed main() {
	fastio;
	int n; cin >> n;
	if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon";
	if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon";
	if(n % 10 == 3) cout << "bon";
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define lli long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
lli powm(lli a,lli b ,lli mod){if(b==0) return 1;if(b%2==0){ lli tmp = powm(a,b/2,mod); return (tmp*tmp)%mod;}else return (a%mod * powm(a,b-1,mod))%mod;}
lli invm(lli a, lli mod) {return powm(a,mod-2,mod); } //fermats's method // mod has to be a prime


inline void solve(){
	string s;
	cin>>s;
	cout<<(s[2]==s[3 ]&& s[4]==s[5] ? "Yes":"No")<<endl;
}

int main(){
	fastio;lli  t=1;
	//cin>>t;
	while(t--){solve();}return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		String ans = a == b && b == c
				  || a != b && b != c && c != a ? "No" : "Yes";
		System.out.println(ans);
	}


}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 100;

int h, w;
bool _h[N], _w[N];
string s[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) cin >> s[i];
  FOR(i, 0, h)FOR(j, 0, w) if(s[i][j]=='#'){
    _h[i]=true;
    _w[j]=true;
  }
  FOR(i, 0, h)if(_h[i]){
    FOR(j, 0, w)if(_w[j]) cout << s[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdint.h>

using namespace std;

int32_t main()
{
  uint64_t a, b, x;
  cin >> a >> b >> x;

  if (a == 0) {
    cout << b / x + 1 << endl;
  } else {
    cout << b / x - (a - 1) / x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    string S, T;
    int n, a, b;
    a = b = 0;
    cin >> n;
    rep(i, n) {
        cin >> S >> T;
        if(S == T) {
            a += 1;
            b += 1;
        } else if(S > T) {
            a += 3;
        } else {
            b += 3;
        }
    }
    cout << a << " " << b << endl;
}


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

constexpr int mod = 1e9 + 7;

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

  vector<vector<int64_t>> dp(334, vector<int64_t>(334, 0));
  dp[n - 1][1] = 1;

  for (int i = 0; i < m; ++i) {
    vector<vector<int64_t>> dp2(334, vector<int64_t>(334, 0));
    for (int j = 0; j < n; ++j) {
      for (int k = 1; k <= n; ++k) {
        (dp2[j][n - j] += k * dp[j][k] % mod) %= mod;
        if (j) (dp2[j - 1][k] += j * dp[j][k]) %= mod;
        (dp2[j][k] += (n - j - k) * dp[j][k]) %= mod;
      }
    }

    dp = dp2;
  }

  cout << dp[0][n] << endl;
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	int n;
	string s="0";
	cin>>n;
	rep(i,n)
	{
		bool flag=0;
		rep(j,s.size())
			if(s[j]!='9')flag=1;
		if(!flag)
		{
			rep(j,s.size())s[j]='0';
			s='1'+s;
			 }	 
		else
		{
			int k=0;
			fore(j,s.size()-1,1)
			{
				if(s[j]!=s[j-1]+1&&s[j]!='9')
				{
					flag=0;
					s[j]++;
					k=j;
					break;
				}
			}
			if(flag)
			{
			s[0]++;
			k=0;}	
			forn(j,k+1,s.size()-1)
			{
				if(s[j-1]=='0')s[j]='0';
				else s[j]=s[j-1]-1;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 0
a_pre = a[0]
cnt = 1
for i in range(1, n):
    ai = a[i]
    if ai == a_pre:
        cnt += 1
    else:
        if cnt > a_pre:
            ans += cnt - a_pre
        if cnt < a_pre:
            ans += cnt
            
        cnt = 1
        a_pre = ai
        
    if i==n-1:
        if cnt > a_pre:
            ans += cnt - a_pre
        if cnt < a_pre:
            ans += cnt  

if len(a)==1 and a[0]!=1:
    ans = 1
print(ans)


Measured memory_bytes: 14268
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	x := 1.0 // 分母
	for _, aa := range a {
		x *= aa
	}

	y := 0.0 // 分子
	for _, aa := range a {
		y += x / aa
	}

	ans := x / y
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ull h, w;
	cin >> h >> w;
	if(h == 1 || w == 1){
		cout << 1 << endl;
		return 0;
	}
	cout << (h * w + 1ULL) / 2ULL << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n, ans=0;
int a[N];
map<int, int> m;

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	for(int i=32;i>=0;i--)
	{
		for(auto &it:m)
		{
			int other=(1LL<<i)-it.first;
			if(other==it.first)
			{
				int take=it.second/2;
				it.second%=2;
				ans+=take;
				continue;
			}
			if(m.find(other)!=m.end())
			{
				int take=min(it.second, m[other]);
				ans+=take;
				it.second-=take;
				m[other]-=take;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14336
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    A = LI()

    memo = {}
    for a in A:
        # memo[a] = memo.get(a, 0) + 1
        memo[a] = memo.setdefault(a, 0) + 1

    def choose2(a):
        if a == 0: return 0
        return a * (a-1) // 2

    # print(memo)
    ans = 0
    for k, v in memo.items():
        ans = ans + choose2(v)
    # print(ans)

    for a in A:
        print(ans - choose2(memo[a]) + choose2(memo[a] - 1))


if __name__ == '__main__':
    solve()


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,i;
    cin>>n;
    int a[n];
    REP(i,0,n-1) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    if(n>1) ans+=a[n-1];
    i=n-3;
    int j=n-2;
    while(i>=0){
    	if(i>=1){
    		ans+=2*a[j];
    		j--;
    		i-=2;
    	}else{
    		ans+=a[j];
    		i--;
    		j--;
    	} 	
    }
    cout<<ans;
    return 0;   
}




Measured memory_bytes: 4420
#include <iostream>
#include <string>

std::string S;

int main() {
  std::cin >> S;
  int sum = 0;
  for (int i = 0; i < S.size(); ++i)
    sum += (S[i] - '0');
  std::cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";

  return 0;
}


Measured memory_bytes: 3752
N = int(input())
A = sorted(map(int, input().split()))

colors = [0] * 9
for a in A:
    idx = a // 400
    if idx >= 8:
        idx = 8
    colors[idx] += 1
ans = 0
for i in range(8):
    if colors[i] > 0:
        ans += 1
max_ans = ans
if colors[8] > 0:
    max_ans += colors[8]

if ans == 0 and max_ans > 0:
    ans += 1
print(ans, max_ans)

Measured memory_bytes: 8984
#include <iostream>
#include <string>

std::string s;
int days;

int main() {
    std::cin >> s;
    if (s == "SUN") {
        days = 7;
    }
    else if (s == "MON") {
        days = 6;
    } else if (s == "TUE") {
        days = 5;
    } else if (s == "WED") {
        days = 4;
    } else if (s == "THU") {
        days = 3;
    } else if (s == "FRI") {
        days = 2;
    } else if (s == "SAT") {
        days = 1;
    } else {
        days = 0;
    }
    std::cout << days << std::endl;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    vector<map<ll, ll>> memo(n + 1);
    for (int c = n - 1; c > 0; c--) {
        int x = n - c;
        if (x % 2 == 0) {
            auto z = memo[x / 2];
            z[2]++;
            memo[x] = z;
        } else if (x % 3 == 0) {
            auto z = memo[x / 3];
            z[3]++;
            memo[x] = z;
        } else if (x % 5 == 0) {
            auto z = memo[x / 5];
            z[5]++;
            memo[x] = z;
        } else if (x % 7 == 0) {
            auto z = memo[x / 7];
            z[7]++;
            memo[x] = z;
        } else {
            auto d = prime_factorization(x);
            memo[x] = d;
        }
        if (x == 1) ans++;
        else {
            int s = 1;
            for (auto t : memo[x]) s *= t.second + 1;
            ans += s;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 228328
def main():
    s = input()
    K = int(input())
    lst = sorted(set(s))
    ans = ""
    cnt = 0

    def dfs(sub):
        nonlocal cnt, ans
        if cnt < K:
            ans = sub
            cnt += 1
            for li in lst:
                if sub + li in s:
                    dfs(sub + li)

    for li in lst:
        dfs(li)
    print(ans)
    return


main()


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll sum = 0, s = 0;
    REP(i,0,N) {
        s = (s + A[i]) % MOD;
        sum = (sum + s * A[i]) % MOD;
    }
    REP(i,0,N) sum = (sum - A[i] * A[i]) % MOD;
    PR((sum+MOD)%MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string S;
    cin>>S;
    rep(i,0,2){
        string p;
        if(i==1) p+="A";
        p+="KIH";
        rep(j,0,2){
            string q;
            if(j==1) q+='A';
            q+='B';
            rep(k,0,2){
                string r;
                if(k==1) r+='A';
                r+='R';
                rep(l,0,2){
                    string s;
                    if(l==1) s+='A';
                    if(p+q+r+s==S){
                        cout<<"YES"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,A,B;cin>>N>>A>>B;
    if(abs(A-B)%2==0)cout<<abs(A-B)/2<<endl;
    else cout<<min(min(max(A,B)-1,N-min(A,B)),min(N-B+1+(N-(A+N-B+1))/2,A+(B-A-1)/2))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2001;
const int N = 4001;
inline int lowbit(int x) {return x & -x;}
struct BIT
{
    int c[N];
    void update(int x, int v) {for (; x < N; x += lowbit(x)) c[x] += v;}
    int get(int x, int res = 0) {for (; x > 0; x -= lowbit(x)) res += c[x]; return res;}
}T;
int posw[MAXN], posb[MAXN];
int dp[MAXN][MAXN];
int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= 2 * n; i++)
    {
        char c; int a;
        scanf(" %c %d", &c, &a);
        if (c == 'W') posw[a] = i;
        else posb[a] = i;
        T.update(i, 1);
    }
    memset(dp, 0x3f3f3f3f, sizeof(dp));
    dp[0][0] = 0; 
    for (int i = 0; i <= n; i++)
    {
        if (posw[i]) T.update(posw[i], -1);
        for (int j = 0; j <= n; j++) if (i || j)
        {
            if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + T.get(posb[j] - 1));
            if (posb[j]) T.update(posb[j], -1);
            if (i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + T.get(posw[i] - 1));
            // printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
        }
        for (int j = 1; j <= n; j++) T.update(posb[j], 1);
    }
    printf("%d\n", dp[n][n]);
    return 0;
}

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

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

    int n; string s;
    cin>>n>>s;

    int l = 0, r = n-1, ans = 0;
    while(l<r){
        if(s[l]=='W' && s[r]=='R'){
            l++;
            r--;
            ans++;
        }
        
        if(s[l]=='R') l++;
        if(s[r]=='W') r--;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3704
from collections import deque
import copy

n = int(input())
s = str(input())

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(i+1,n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Measured memory_bytes: 45968
#abc.py
K,N = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
m=K-abs(A[1]-A[N])
for i in range(1,N):
    if m < abs(A[i]-A[i+1]):
        m=abs(A[i]-A[i+1])
print(K-m)

Measured memory_bytes: 26444
#include<stdio.h>
#include<stdlib.h>

int main(void) 
{
	int a, b, c;
	int max,min;
	int totel = 0;
	scanf("%d %d %d", &a, &b, &c);
	totel = (a + b+ c);
    if(a > b && a > c )
    {
    	max = a;
	}
	else if(b > a && b > c) 
	{
		max = b;
	}
	else
	{
		max = c;
	}
	if(a < b && a < c )
    {
    	min = a;
	}
	else if(b < a && b < c) 
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, totel - max - min,max);
	
    return 0;
}


Measured memory_bytes: 2756
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int dfs(vvi &V, vi &D, int p){
	if(D[p]>0 || V[p].size()<=0) return D[p];
	for(int c:V[p]) D[p] = max(D[p], dfs(V,D,c)+1);
	return D[p];
}

int in(){int x;cin>>x;return x;}

int main(){
	int N,M; cin>>N>>M;

	vvi V(N+1);
	while(M--) V[in()].push_back(in());

	vi D(N+1);
	for(int p=1; p<=N; p++) if(D[p]<=0) D[0] = max(D[0], dfs(V,D,p));

	cout<< D[0] <<endl;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

const long long MOD = 1000000007;

int n, m, a[1055], b[1055], row[1000055], col[1000055];
long long ans = 1, fixedCnt, fixedRow, fixedCol, flexCnt;

int main() {
	
	scanf("%d%d", &n, &m);
	
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		if (row[a[i]]) {
			printf("0\n");
			return 0;
		}
		row[a[i]] = i;
	}
	
	for (int i = 1; i <= m; i++) {
		scanf("%d", b + i);
		if (col[b[i]]) {
			printf("0\n");
			return 0;
		}
		col[b[i]] = i;
	}
	
	for (int i = n * m; i >= 1; i--) {
		if (row[i] && col[i]) {
			fixedRow++;
			fixedCol++;
			fixedCnt++;
		} else
		if (row[i]) {
			fixedRow++;
			fixedCnt++;
			ans *= fixedCol;
			ans %= MOD;
		} else
		if (col[i]) {
			fixedCol++;
			fixedCnt++;
			ans *= fixedRow;
			ans %= MOD;
		} else {
			long long remained = fixedRow * fixedCol - fixedCnt - flexCnt;
			if (remained <= 0) {
				printf("0\n");
				return 0;
			}
			ans *= remained;
			ans %= MOD;
			flexCnt++;
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int ans[200010];
vi tree[200010];

int flag[200010];

void dfs(int parent){
	for(auto x: tree[parent]){
		if(!flag[x]){
			flag[x] = 1;
			ans[x] += ans[parent];
			dfs(x);
		}
	}
}

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

	int a,b;
	rep(i,n-1){
		cin >> a >> b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	int p,x;
	rep(i,q){
		cin >> p >> x;
		ans[p] += x;
	}

	flag[1] = 1;
	dfs(1);

	for(int i = 1; i <= n; i++){
		cout << ans[i];
		cout << (i != n ? ' ' : '\n');
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  
  if(n==1){
    cout << "Yes" << endl;
    return(0);
  }
  
  for(int i=h.size()-1;i>=1;i--){
    if(h.at(i-1)-1 > h.at(i)){
      cout << "No" << endl;
      return(0);
    }else if(h.at(i-1)-1 == h.at(i)){
      h.at(i-1)--;
    }
  }
  
  cout << "Yes" << endl;
  
  return(0);
}

Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define MAX_N 100001
using namespace std;

using ll = long long;
typedef pair<int,ll> p;
bool color[MAX_N];
vector< p > g[MAX_N];
int n;
void dfs(int pre, int now, ll dis) 
{
    for(p &e:g[now]){
        if(e.first == pre)continue;
        if(e.second%2){
            color[e.first] = !color[now];
        }
        else{
            color[e.first] = color[now];
        }
        dfs(now,e.first,dis);
    }
}


void solve()
{
    dfs(0,1,0);
    for(int i = 1;i<=n;i++){
        if(color[i]){
            cout<<1<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
}

int main()
{
    cin>>n;
    int a,b;ll c;
    for(int i=0;i<n-1;i++){
        cin>>a>>b>>c;
        g[a].push_back(p(b,c));
        g[b].push_back(p(a,c));
    }
    solve();
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include<string.h>
using namespace std;
int main(void){
    // Your code here!
    int n,ans=0;
    char mozi[11];
    cin>>mozi;
    cin>>n;
    char moziretu[22];
    for(int i=0;i<n;i++){
        cin>>moziretu;
        strcat(moziretu,moziretu);
        if(strstr(moziretu,mozi)!=NULL){
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3088
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 typedef long long ll;



 int main()
 {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s) a--;
    else b--;
    cout << a << " " << b << endl;

     return 0;
 }

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


def solve(N: int, A: "List[int]"):
    d = dict()
    for i in A:
        d[i] = 1 + d.get(i, 0)

    d_sel = dict()
    total = 0
    for k,v in d.items():
        sel = v * (v-1) // 2
        d_sel[k] = sel
        total += sel

    for i in range(N):
        print(total - d_sel[A[i]] + (d[A[i]]-1) * (d[A[i]]-2)//2)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44732
from collections import deque

n = int(input())
al = list(map(int, input().split()))
asum = sum(al)

first_q = al[1:n:2]
last_ind = n-2
curr_sum = sum(first_q)
q = deque(first_q)


ans = [0]*n
ans[0] = asum - curr_sum*2
for i in range(2,n,2):
    next_ind = (last_ind+2)%n
    next_a = al[next_ind]
    poped_a = q.popleft()
    curr_sum -= poped_a
    curr_sum += next_a
    ans[i] = asum - curr_sum*2
    last_ind = next_ind


first_q = al[2:n:2]
last_ind = n-1
curr_sum = sum(first_q)
q = deque(first_q)
ans[1] = asum - curr_sum*2
for i in range(3,n,2):
    next_ind = (last_ind+2)%n
    next_a = al[next_ind]
    poped_a = q.popleft()
    curr_sum -= poped_a
    curr_sum += next_a
    ans[i] = asum - curr_sum*2
    last_ind = next_ind

print(*ans)

Measured memory_bytes: 93752
from math import factorial
N,M = map(int,input().split())
if N <= 1:
    n_count = 0
else:
    n_count = factorial(N) / factorial(2) / factorial(N-2)
if M <= 1: 
    m_count = 0
else:
    m_count = factorial(M) / factorial(2) / factorial(M-2)



print(int(n_count+m_count))


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
 
public class Main {
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;		
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}
 
	}
 
	public static void main(String[] args) throws Exception {
 
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String a=sc.next();
		String b=sc.next();
		int A=sc.nextInt();
		int B=sc.nextInt();
		String c=sc.next();
		if(a.equals(c)) {
			A--;
		}
		else if (b.equals(c)) {
			B--;
		}
		System.out.println(A+" "+B);
		pw.close();
		
		
	}
 
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
			
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
 
}


Measured memory_bytes: 21076