akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,p;
  cin >> n >> p;
  if(n>50){
    print(1);
    return 0;
  }
  if(n==1){
    print(p);
    return 0;
  }
  ll num = 1;
  for (ll i = 1; i<= p;i++){
    ll tmp = 1;
    rep(j,n){
      tmp *= i;
      if(tmp>p){
        i = INF;
        break;
      }
    }
    if (p % tmp == 0){
      num *= i;
      p /= tmp;
      if(i>1){
        i--;
      }
    }
  }
  print(num);
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int count = 0;
    rep(r, N + 1) {
        rep(g, N + 1) {
            int b = (N - r * R - g * G) / B;
            if (b * B + r * R + g * G == N && b >= 0 && g >= 0 && r >= 0) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
al=[chr(ord('a')+i) for i in range(26)]
ansd={x:100 for x in al}
for i in range(n):
    d={x:0 for x in al}
    s=input()
    for a in s:
        d[a]+=1
    for x in al:
        ansd[x]=min(ansd[x],d[x])
a=''
for x in al:
    num=ansd[x]
    for i in range(num):
        a+=x
print(a)

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

long calcNumOfCombination(long n, long r){
        long num = 1;
        for(long i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

void solve(int N, std::vector<std::string> s) 
{
  for(auto& i: s)
  {
    std::sort(i.begin(), i.end());
  }
  std::sort(s.begin(), s.end());
  long count = 0;
  long result = 0;
  for (int i = 1; i < N; i++)
  {
    if(s[i-1]==s[i])
    {
      count++;
      result += count;
    }
    else
    {
      count=0;
    }
  }
  std::cout << result << std::endl;
}
int main(void) {
  int N;
  std::cin >> N;
  std::vector<std::string> s(N);
  for(auto i0 = 0; i0 < N; ++i0)
  {
    std::cin >> s[i0];
  }
  solve(N,s);
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b,c=0,d=0,e,n,m,ans=0;
  string s,t;
  bool f=false;
  cin>>a>>b>>c;
  co(c<<" "<<a<<" "<<b);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
#define chmax(x,y) x = max(x,y)
const ll mod = 1000000007;

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

    vector<pair<int, int>> p(n);
    rep(i,n) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());

    int dp[3010][3010];
    int ans = 0;
    rep(i, n) {
        rep(j, t) {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = j + p[i].first;
            if(nj < t) {    
                chmax(dp[i+1][nj], dp[i][j] + p[i].second);
            } 
        }
        int now = dp[i][t-1] + p[i].second;
        chmax(ans, now);
    }

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

Measured memory_bytes: 35584
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;


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


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;



#define FAVOR(N,M)	(((N)/(M))==((N)%(M)))

int main(){
	int N;	cin >> N;
	int aa = N /100;
	int bb = N%100;

	if(1 <= aa && aa <= 12){
		if(1 <= bb && bb <= 12) cout << "AMBIGUOUS" << endl;
		else	cout << "MMYY" << endl;
	}else{
		if(1 <= bb && bb <= 12) cout << "YYMM" << endl;
		else	cout << "NA" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

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

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//ifstream f(".in");
//ofstream g(".out");

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif

  int n;
  cin >> n;
  vector<int> a(n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  const long long INF = 1e18L + 5;
  vector<vector<long long>> dp(n + 2, vector<long long>(n + 2, -INF));
  // dp[l][r] = maximum diff to be made by the player moving next
  for (int i = 1; i <= n; ++i) {
    dp[i][i] = a[i];
    for (int j = 1; j <= i - 1; ++j) {
      dp[i][j] = -INF;
    }
  }
  for (int l = n; l >= 1; --l) {
    for (int r = l + 1; r <= n; ++r) {
      uax(dp[l][r], max(a[l] - dp[l + 1][r],
                        a[r] - dp[l][r - 1]));
    }
  }

  cout << dp[1][n] << ' ';

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


Measured memory_bytes: 70784
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <string.h>
#include <cmath>
#include <queue>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>

using namespace std;

int D,a,b,c,p,q,r,s,g1,g2;

bool cek;

/*int gcd(int a,int b)
{
	return b!=0? gcd(b,a%b): a;
}

/*bool cek()
{
	for(int z=1;z*z<=D;z++)
	{
		if(z*z==D) 
		{
			printf("tes\n");
			return true;
		}
	}
	return false;
}*/

int main()
{
	while(scanf("%d%d%d", &a,&b,&c),(a||b||c))
	{
		cek=true;
		D=b*b-(4*a*c);
		if(a==0&&b==0&&c==0)break;
		for(int z=0;z*z<=D;z++)
		{
			if(z*z==D) 
			{
				//printf("tes\n");
				cek=false;
				break;
			}
		}
		if(D<0||cek)
		{
			printf("Impossible\n");
			continue;
		}
		//printf("%d\n",D);
		else
		{
			p=2*a;
			q=-(-b+sqrt(D));
			r=2*a;
			s=-(-b-sqrt(D));
			g1=__gcd(p,q);
			g2=__gcd(r,s);
			p/=g1;
			q/=g1;
			r/=g2;
			s/=g2;
			if(p<0)
			{
				p*=-1;
				q*=-1;
			}
			if(r<0)
			{
				r*=-1;
				s*=-1;
			}
			if(p<r||(p==r&&q<s))
			{
				swap(p,r);
				swap(q,s);
				//swap(g1,g2);
			}
			printf("%d %d %d %d\n",p,q,r,s);
		}
	}
	return 0;
}

Measured memory_bytes: 1196
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
using namespace std;
int main()
{
   ll a,b,l=0;
   cin>>a;
   l+=(a/500)*1000;
   a%=500;
   l+=(a/5)*5;
   cout<<l<<endl;


    return 0;
}


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

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

const int INF = 1e9;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  vector<int> v{P, Q, R};
  sort(ALL(v));
  cout << v[0] + v[1] << endl;

  return 0;
}


Measured memory_bytes: 256
from functools import lru_cache
from sys import setrecursionlimit

n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))

mod = 10**9+7
setrecursionlimit(mod)

@lru_cache(maxsize=n)
def stairway(i) :
    if i in a :
        return 0
    elif i == 0 :
        return 1
    elif i == 1 :
        return stairway(0)
    else :
        return (stairway(i-1)+stairway(i-2))%mod
    
print(stairway(n))

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

vector<P>E[100000];
int d[100000],b[100000],cnt[200001],u[200000],v[200000],r[200000];
int main(){
	int n,m,q;scanf("%d%d%d",&n,&m,&q);
	rep(i,m)scanf("%d%d",&u[i],&v[i]),u[i]--,v[i]--,r[i]=q;
	rep(i,q){
		int a;scanf("%d",&a);a--;r[a]=i;
	}
	rep(i,m){
		E[u[i]].push_back(P(v[i],r[i]));E[v[i]].push_back(P(u[i],r[i]));
	}
	d[0]=1;b[0]=q;
	queue<int>que;que.push(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(P v:E[p]){
			if(d[v.first]==0){
				d[v.first]=d[p]+1;b[v.first]=min(b[p],v.second);
				que.push(v.first);
			}
			else if(d[v.first]==d[p]+1&&b[v.first]<min(b[p],v.second)){
				b[v.first]=min(b[p],v.second);
			}
		}
	}
	rep(i,n)cnt[b[i]]++;
	int ans=0;
	rep(i,q){
		ans+=cnt[i];
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 15528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S[1] == S[0] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad" << endl;
  }
    else {
      cout << "Good" << endl;
    }
  
  
}
  

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

using namespace std;

struct UnionFind {
  std::vector<int> parent;
  int __size;
  UnionFind(int n) : parent(n, -1), __size(n) {}
  void unite(int x, int y) {
    if ((x = root(x)) != (y = root(y))) {
      if (parent[y] < parent[x]) { std::swap(x, y); }
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  int size(int x) { return -parent[root(x)]; }
  int size() { return __size; }
};

int main() {
  int N, M, K; cin >> N >> M >> K;
  UnionFind uf_tree(N);

  vector<vector<int>> friends(N, vector<int>());
  vector<vector<int>> blocks(N, vector<int>());

  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    uf_tree.unite(a, b);
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  for (int i = 0; i < K; i++) {
    int c, d; cin >> c >> d;
    c--; d--;
    blocks[c].push_back(d);
    blocks[d].push_back(c);
  }

  for (int i = 0; i < N; i++) {
    int ans = uf_tree.size(i) - 1;
    set<int> cand;
    // 友達は友達候補ではない
    for (int j = 0; j < friends[i].size(); j++) {
      cand.insert(friends[i][j]);
    }
    // 同じ連結成分に含まれていてもブロック関係なら友達にはなれない
    for (int j = 0; j < blocks[i].size(); j++) {
      if ( uf_tree.same(i, blocks[i][j]) ) {
        cand.insert(blocks[i][j]);
      }
    }
    ans -= cand.size();
    cout << ans << ((i == N-1) ? "\n" : " ");
  }

  return 0;
}

Measured memory_bytes: 16888
mod=10**9+7
def mod_combination(n, k, mod):
    def ext_gcd(a, b):
        if b == 0:return a, 1, 0
        else:d,x,y = ext_gcd(b,a%b);x-=(a//b)*y 
        return d,y,x
    p,q=1,1
    for i in range(n-k+1,n+1):
        p=(p*i)%mod
    for i in range(2,k+1):
        q=(q*i)%mod
    return int(p*(ext_gcd(q, mod)[1]%mod)%mod)


n,m,k=map(int,input().split())
print(((pow(m,2,mod)*mod_combination(n*m-2,k-2,mod)*sum((n-i)*i%mod for i in range(1,n))%mod)+pow(n,2,mod)*mod_combination(n*m-2,k-2,mod)*sum((m-i)*i%mod for i in range(1,m))%mod)%mod)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A));
    ll left = -1e18-1;
    ll right = 1e18+1;
    while (right - left > 1) {
        ll mid = (right + left) / 2;
        ll cnt = 0;
        rep(i,N) {
            if (A[i] < 0) {
                int L = i;
                int R = N;
                while (R - L > 1) {
                    int M = (L+R)/2;
                    if (A[i]*A[M] > mid) L = M;
                    else R = M;
                }
                cnt += N-R;
            } else if (A[i] == 0) {
                if (mid >= 0) cnt += N-1-i;
            } else {
                int L = i;
                int R = N;
                while (R - L > 1) {
                    int M = (L+R)/2;
                    if (A[i]*A[M] <= mid) L = M;
                    else R = M;
                }
                cnt += L-i;
            }
        }
        //cout << cnt << ln;
        if (cnt < K) left = mid;
        else right = mid;
    }
    cout << right << ln;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    int ans = (n-1)*(m-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    map<string, int> a;
    REP(i, n){
        IN(string, s);
        a[s]++;
    }
    int m = 0;
    for (auto x : a) {
        m = max(m, x.second);
    }
    for (auto x : a) {
        if (x.second==m) {
            COUT(x.first);
        }
    }
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A,B;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
    B = fetch_vec<ll>(N);
}
#define YES do{cout <<"Yes" << endl;return 0;}while(false);
#define NO do{cout <<"No" << endl;return 0;}while(false);

int solve(){
    if(A==B) YES
    ll as = accumulate(A.begin(),A.end(),0LL);
    ll bs = accumulate(B.begin(),B.end(),0LL);
    if(as>=bs) NO
    ll diff = bs-as;
    ll diff_a=0;
    ll diff_b=0;
    for (int i = 0; i < N; i++)
    {
        if(B[i]<A[i]) diff_b+=(A[i]-B[i]);
        else diff_a+=(B[i]-A[i]);
    }
    if(diff_b>diff) NO
    if(diff_b==0) YES
    diff_a -= 2*diff_b;
    if(diff_a<0) NO
    vector<ll> DiffA(N,0);
    for (int i = 0; i < N; i++)
    {
        if((B[i]-A[i])>=0) DiffA[i] = (B[i]-A[i]);
    }
    ll diff_A = 0;
    for (int i = 0; i < N; i++)
    {
        diff_A += DiffA[i]/2;
    }
    diff_A -= diff_b;
    if(diff_A<0) NO
    
    
    YES
    return 0;
}   

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

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

#define MAX 1001

int LCSLength(char *,char *);

int main(){
  int i,q,maxlen[MAX];
  char X[MAX],Y[MAX];

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%s%s",X,Y);
    printf("%d\n",LCSLength(X,Y));
  }


  return 0;
}

int LCSLength(char *X,char *Y){
  int i,j,k,m,n;
  int c[MAX][MAX];

  m=strlen(X);
  n=strlen(Y);
  
  for(i=0;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i][j-1]<=c[i-1][j]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }

  return c[m][n];
}



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

int main(){
    string N;
    cin >> N;
    size_t size = N.length();
    int size_N = (int)size;
    int sum=0;
    for(int i=0;i<size_N;i++){
        sum+=N[i]-'0';
    }
    if(sum%9==0){
        cout << "Yes"   <<endl;
    }
    else{
        cout << "No"    <<endl;
    }
}

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

using namespace std;
#define ll long long int

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

 ll max = a * c;

 ll r1 = b*c;
 ll r2 = a*d;
 ll r3 = b*d;

  if (max<r1)max=r1;
  if (max<r2)max=r2;
  if (max<r3)max=r3;
   
  cout << max;

 return 0;
}





Measured memory_bytes: 3628
n=input()
n=int(n)

b = [int(e) for e in input().split()]
count=0
flag=0

#print(b[0])

while True:
    for i in range(n):
        if(b[i]%2 != 0):
            flag=1
            break
    if(flag==1):
        break
    count += 1
    for i in range(n):
        b[i]=b[i]/2

print(count)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

int main() {
  string s;
   cin >> s;
  if(s=="AAA" || s=="BBB"){cout << "No" << endl;
                          return 0;}
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,num=0,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a; i<=b; i++){
    if(c%i==0)num+=1;
  }
  printf("%d\n",num);
  return 0;
}



Measured memory_bytes: 2712
import sys

sys.setrecursionlimit(10 ** 9)


def extgcd(a, b):
    x, y = 0, 0

    def f(a, b):
        nonlocal x, y
        if b == 0:
            x = 1
            y = 0

            return a

        g = f(b, a % b)
        q = a // b
        next_x = y
        y = x - q * y
        x = next_x
        return g

    g = f(a, b)
    return x, y, g


fact = [0] * 200010
invfact = [0] * 200010
mod = 10 ** 9 + 7


def nCr(n, r):
    ret = fact[n]
    ret = (ret * invfact[n - r]) % mod
    ret = (ret * invfact[r]) % mod
    return ret


fact[0] = 1
for i in range(1, 200000 + 1):
    fact[i] = (fact[i - 1] * i) % mod
for i in range(200000 + 1):
    x, y, g = extgcd(fact[i], mod)
    while x < 0:
        x += mod
    invfact[i] = x % mod

H, W, A, B = [int(_) for _ in input().split()]

ans = 0
for i in range(B, W):
    tmp = nCr((H - A - 1) + i, H - A - 1)
    tmp = tmp * nCr((A - 1) + (W - i - 1), A - 1) % mod
    ans = (ans + tmp) % mod
print(ans)


Measured memory_bytes: 18968
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=5e5+10;
char s[maxn];
int dp[30][maxn];
int n,q,a,l,r;
char c;
int lowbit(int x)
{
	return x&-x;
}
void update(int x,int add,int *a)
{
	for(int i=x;i<=n;i+=lowbit(i))a[i]+=add;
}
int sum(int x,int *a)
{
	int s=0;
	for(int i=x;i>=1;i-=lowbit(i))s+=a[i];
	return s;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	for(int i=1;i<=n;i++)
	{
		update(i,1,dp[s[i]-'a']);
	}
//	for(int i=0;i<26;i++)
//	{
//		for(int j=0;j<=n;j++)
//		cout<<dp[i][j]<<' ';
//		cout<<endl;
//	}
//	return 0;
	cin>>q;
	while(q--)
	{
		cin>>a;
		if(a==1)
		{
			cin>>l>>c;
			update(l,-1,dp[s[l]-'a']);
			update(l,1,dp[c-'a']);
			s[l]=c;
		}
		else
		{
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<26;i++)
			{
				if(sum(r,dp[i])-sum(l-1,dp[i])>0)
				ans++;
			}
			cout<<ans<<endl;
		}
	}
}


Measured memory_bytes: 51968
#include<stdio.h>
int main(void)
{
	int n,i;
	char s[101];
	scanf("%d %s", &n, s);
	if(n%2==1)
	printf("No\n");
	else
	{
		for(i=0; i<n/2; i++)
		{
			if(s[i]!=s[i+n/2])
			{
				printf("No\n");
				break;
			}
			if(i==n/2-1)
			printf("Yes\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	string s;
	cin >> s;
	if (s[0] != s[1] || s[1] != s[2] || s[0] != s[2]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 1001001001;
int n,k,r,s,p;
string t;

int point(char x){
  if(x == 'r'){
    return p;
  }else if(x=='s'){
    return r;
  }else{
    return s;
  } 
}

int main(){
  cin >> n >> k >> r >> s >> p >> t;
  vector<string> tt(n,"");
  for(int i=0;i<n;i++){
    char a = t.at(i);
    tt.at(i%k).push_back(a);
  }
  int ans = 0;
  for(int i=0;i<k;i++){
    ans += point(tt.at(i).at(0));
    bool flag = 0;
    for(int j=1;j<tt.at(i).size();j++){
      if(tt.at(i).at(j) == tt.at(i).at(j-1) && flag == 0){
        flag = 1;
        continue;
      }
      ans += point(tt.at(i).at(j));
      flag = 0;
    }
  }
  cout << ans << endl;
}

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

int main() {
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	
	const int maxn = n*1000+1;
	vector<vector<long long>> dp(n+1, vector<long long>(maxn, 1e15));
	
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = maxn-1; j >= 0; j--) {
			if (dp[i][j] == 1e15) continue;
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if (j + v[i] < maxn) {
				dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
			}
		}
	}
	
	int res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < maxn; j++) {
			if (dp[i][j] <= W) {
				res = max(res, j);
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 80256
#include <stdio.h>
int main(void)
{
    int m, f, r;
    while (1) {
	scanf("%d %d %d", &m, &f, &r);
	if (m == -1 && f == -1 && r == -1) {
	    break;
	} else if (m == -1 || f == -1) {
	    printf("F\n");
        } else if (m + f >= 80) {
	    printf("A\n");
        } else if (m + f >= 65 && m + f < 80) {
	    printf("B\n");
	} else if (m + f >= 50 && m + f < 65) {
	    printf("C\n");
	} else if (m + f >= 30 && m + f < 50) {
	    if (r >= 50) {
		printf("C\n");
	    } else {
		printf("D\n");
	    }
	} else {
	    printf("F\n");
	}
    }
	return 0;
}

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

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double p = 0;  // 砂糖水の濃度
    int maxw = a;  // 水の量の最大値の100分の1
    int maxs = 0;  // 砂糖の量の最大値
    int w = 0;  // 水の量の100分の1
    int s = 0;  // 砂糖の量
    bool q = false;

    // 操作1をi回行う( i = 0 ～ f/(100*a) )
    rep(i, f/(100*a) + 1) {
        // 操作2をj回行う( j = 0 ～ f/(100*b) )
        rep(j, f/(100*b) + 1) {

            // 操作1をi回, 操作2をj回行ったときの水の量の100分の1
            w = i*a + j*b;

            // 水の量がf以上のときはダメ
            if(100*w >= f) {
                break;
            }

            // 操作3をk回行う( k = 0 ～ e*w/c )
            rep(k, e*w/c + 1) {
                // 操作4をl回行う( l = 0 ～ e*w/d )
                rep(l, e*w/d + 1) {

                    // 操作3をk回, 操作4をl回行ったときの砂糖の量
                    s = k*c + l*d;

                    // 水と砂糖の量の合計がfより大きいときはダメ
                    if(100*w + s > f) {
                        break;
                    }

                    // 水と砂糖の量の合計がf以下で、水の量が0でないとき
                    if(100*w + s <= f && w != 0) {
                        
                        // 砂糖が溶け残らずpより濃度の高い砂糖水が作れるとき
                        if(e*w > s && p < s/(double)w) {
                            // 現時点での水の最大値の100分の1をwに設定
                            maxw = w;
                            // 現時点での砂糖の最大値をsに設定
                            maxs = s;
                            // 現時点での濃度の最大値をpに設定
                            p = s/(double)w;
                        }

                        // 理論上最適な砂糖水が作れるとき
                        if(e*w == s && p < s/(double)w) {
                            // 水の最大値の100分の1をwに設定
                            maxw = w;
                            // 砂糖の最大値をsに設定
                            maxs = s;
                            // 濃度の最大値をpに設定
                            p = s/(double)w;
                            // qをtrueにして4重ループを抜ける
                            q = true;
                            break;
                        }
                    }
                    if(q) { break; }
                }
                if(q) { break; }
            }
            if(q) { break; }
        }
        if(q) { break; }
    }

    cout << 100*maxw + maxs << " " << maxs << endl;
    return 0;
}

Measured memory_bytes: 256
import math

a, b = list(map(int, input().split()))

gcd = math.gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

fact = prime_factorize(gcd)
print(len(set(fact)) + 1)


Measured memory_bytes: 63096
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int x = 0; x < k+1; x++) {
    for (int y = 0; y < k+1; y++) {
      int  hoge = s - x - y;
      if(0 <= hoge && hoge <= k) {
        cnt++;
      }
    }
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++) printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2076
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
const ll mod=1000000007;
using namespace std;
int n,a[2005];
ll h[2005],g[2005],ans,m;
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			if(a[j]<a[i]){
				g[i]++;
				if(j>i)h[i]++;
			}
		ans=(ans+(h[i]*m)%mod)%mod;
		ans=(ans+(g[i]*((m*(m-1)/2)%mod))%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  ll A[N+1]={};
  RREP(i,N) cin>>A[i];
  
  ll left=1,right=1,xsum=A[1],sum=A[1];
  for(left=1; left<=N; ++left){
    while(right<N && (xsum^A[right+1])==sum+A[right+1]){
      xsum=xsum^A[right+1];
      sum=sum+A[right+1];
      right++;
    }
    ans+=right-left+1;
    xsum^=A[left];
    sum-=A[left];
  }
  
  cout<<ans<<endl;
  return 0;
}

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

bool visit[100010];
vector<int> graph[100010];
vector<int> path,path2;

void dfs(int t)
{
	visit[t]=true;
	path.push_back(t);
	for(int nxt:graph[t])
	{
		if(visit[nxt]==false)
		{
			dfs(nxt);
			return;
			}
		}
	}	

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		}
		
	dfs(1);
	swap(path,path2);
	dfs(1);
	
	printf("%zd\n",path.size()+path2.size()-1);
	for(int i=(int)path2.size()-1;i>=1;i--)
	{
		cout<<path2[i]<<" ";
		}
	for(int t:path)
	{
		cout<<t<<" ";
		}	
	cout<<endl;	
	return 0;
	}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    ll r, D;
    cin >> r >> D;
    ll X;
    cin>>X;

    ll ans;

    ll temp= X;


    for (int i = 0; i <10 ; ++i) {
        temp = r * temp - D;
        cout << temp << endl;
    }

    // cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	map<int64, set<pair<int, char> > > xx, yy, ru, lu;
	REP(i, N) {
	  int x, y;
	  char u;
	  cin >> x >> y >> u;
	  xx[y].emplace(x, u);
	  yy[x].emplace(y, u);
	  ru[x-y].emplace(x, u);
	  lu[x+y].emplace(x, u);
	}
	int64 res = INF_LL;
	for (auto st : xx) {
	  map<char, int> rec;
	  for (auto e : st.sc) {
	    if (e.sc == 'L' && rec.count('R') != 0) {
	      chmin(res, abs(e.fs - rec['R']) * 5);
	    } else if (e.sc == 'R') {
	      rec['R'] = e.fs;
	    }
	  }
	}
  for (auto st : yy) {
    map<char, int> rec;
    for (auto e : st.sc) {
      if (e.sc == 'D' && rec.count('U') != 0) {
        chmin(res, abs(e.fs - rec['U']) * 5);
      } else if (e.sc == 'U') {
        rec['U'] = e.fs;
      }
    }
  }
  for (auto st : ru) {
    map<char, int> rec;
    for (auto e : st.sc) {
      if (e.sc == 'L' && rec.count('U') != 0) {
        chmin(res, abs(e.fs - rec['U']) * 10);
      } else if (e.sc == 'D' && rec.count('R') != 0) {
        chmin(res, abs(e.fs - rec['R']) * 10);
      } else if (e.sc == 'R' || e.sc == 'U') {
        rec[e.sc] = e.fs;
      }
    }
  }
  for (auto st : lu) {
    map<char, int> rec;
    for (auto e : st.sc) {
      if (e.sc == 'U' && rec.count('R') != 0) {
        chmin(res, abs(e.fs - rec['R']) * 10);
      } else if (e.sc == 'L' && rec.count('D') != 0) {
        chmin(res, abs(e.fs - rec['D']) * 10);
      } else if (e.sc == 'R' || e.sc == 'D') {
        rec[e.sc] = e.fs;
      }
    }
  }
  if (res == INF_LL) cout << "SAFE" << endl;
  else cout << res << endl;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

constexpr int MAXN = 101010;

vi g[MAXN];
vi dp(MAXN, -1);

int rec(int x)
{
	if(dp[x] != -1)
		return dp[x];
		
	int mx = 0;
	for_each(all(g[x]), [&](int pr) { mx = max(mx , rec(pr)); });
	return dp[x] = mx + 1;
}



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

	int n , m;
	cin >> n >> m;
	
	rep(i , m)
	{
		int u , v;
		cin >> u >> v;
		g[v - 1].pb(u - 1);
	}
	
	int ans = 0;
	rep(i , n)
	{
		ans = max(ans , rec(i));
	}
	
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 12160
M, D = map(int, input().split())
ans = 0
for m in range(1,M+1):
  for d in range(22,D+1):
    d = str(d)
    if m == int(d[0])*int(d[1]) and int(d[0]) >= 2 and int(d[1]) >= 2:
      ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>a;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	vector<ll>b;
	while(a.size()!=0){
	for(int i=a.size()-1;i>=0;i--){
		ll now=a[i];
		if(now==i+1){
			b.push_back(now);
			a.erase(a.begin()+i);
			break;
		}
		if(now>i+1){
			cout << -1;
			return 0;
		}
	}
	}
	reverse(b.begin(),b.end());
	for(int i=0;i<n;i++){
		cout << b[i]<< " ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll n; cin >> n;
	ll total = 0, bmin = 1e18;
	bool eq = true;
	rep( i, n )
	{
		ll a, b; cin >> a >> b;
		if ( a != b ) eq = false;
		if ( a > b ) chmin( bmin, b );
		total += a;
	}

	if ( eq ) cout << 0 << endl;
	else cout << total - bmin << endl;

	return ( 0 );
}


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

int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v.at(i);
    }
    int m = 10000000;
    int count = 0;
    rep(i, n){
        if(m < v.at(i)) continue;
        count++;
        m = min(m, v.at(i));
    }
    cout << count << endl;
    return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n,k;cin>>n>>k;

	vector<ll> V(n);

	rep(i, n){
		cin>>V[i];
	}
	ll ans =0;
	for(int i=0; i<= min(n,k); i++){
		for(int j=0; i+j<=min(n,k); j++){

			vector<ll> s;
			ll  sum=0;
			for(int p=0 ; p<i; p++){
				s.push_back(V[p]);
				sum += V[p];
			}
			for(int p=0 ; p<j; p++){
				s.push_back(V[n-1-p]);
				sum += V[n-1-p];
			}
			sort(s.begin(),s.end());
			for(int p =0; p<min((k-i-j),(int)s.size()); p++){
				if(s[p] <0) sum-=s[p];
			}

			ans = max(ans,sum);
		}
	}

	writeln(ans);


}


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

int main(void){
    int N;
    cin >> N;
    int grundy=0;
    for(int i=0; i<N; ++i){
        int A, K;
        cin >> A >> K;
        while(A%K>0 && A>=K){
            A -= (A/K+1)*((A%K+A/K)/(A/K+1));
        }
        grundy ^= A/K;
    }
    cout << (grundy>0 ? "Takahashi" : "Aoki") << endl;
    return 0;
}


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

typedef pair<int, int> P;

//dp[i][j][k]
// N以下でi桁目までで0でない数字をj個含む（k=0なら一致，k=1なら未満）
ll dp[105][4][2];

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;

    dp[0][0][0] = 1;
    rep(i, n) rep(j, K + 1) rep(k, 2)
    {
        int d = s.at(i) - '0';
        for (int nd = 0; nd < 10; nd++) {
            int ni = i + 1, nj = j, nk = k;
            if (nd != 0) {
                nj++;
            }
            if (nj > K)
                continue;
            if (k == 0) {
                if (nd > d)
                    continue;
                if (nd < d)
                    nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }

    ll ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
}


Measured memory_bytes: 256
import bisect
 
n = int(input())
l = sorted(list(map(int, input().split())))
count = 0
 
for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        ab = a + b
        index_c = bisect.bisect_left(l, ab)#二分探索,abをlの中のどこに挿入するか
        count += index_c - j -1

print(count)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] t = sc.IntArray();

        int sum = t.Sum();

        int m = sc.NextInt();

        for (int i = 0; i < m; i++)
        {
            int p = sc.NextInt();
            int x = sc.NextInt();
            Console.WriteLine(sum - t[p - 1] + x);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A;
	cin>>B;
	if (A!=1 && B!=1){
		cout<<1<<endl;
	}else if (A!=2 && B!=2){
		cout<<2<<endl;
	}else if (A!=3 && B!=3){
		cout<<3<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()
for i in range(n):
    a[i] = (a[i],i+1)
a = sorted(a)
for i in range(n):
    print(str(a[i][1]) + " ",end = "")

Measured memory_bytes: 60524
#include<bits/stdc++.h>
#define ll long long 
#define ld long long double
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;  
int main() 
{
	FAST
	ll n,k,ans=0,val;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		cin>>val;
		if(val>=k) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
n, y = map(int, input(). split())
l = []
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            l = [i, j, n-i-j]
            break
if l == []:
    print(' '.join(map(str, [-1, -1, -1])))
else:
    print(' '.join(map(str, l)))

Measured memory_bytes: 3064