akhauriyash/Code-Regression huggingface dataset:
s = input()

if 1 <= int(s[2:4]) <= 12 and 1 <= int(s[0:2]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[2:4]) <= 12:
    print('YYMM')
elif 1 <= int(s[0:2]) <= 12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
bool a[10];
bool check(int num)
{
    while(num)
    {
        if(a[num%10]) return false;
        num /= 10;
    }
    return true;
}
int main()
{
    int n,k,num;
    cin>>n>>k;
    for(int i=0;i<k;++i)
    {
        cin>>num;
        a[num]=true;
    }
    while(true)
    {
        if(check(n))
        {
            cout<<n<<endl;
            break;
        }
        ++n;
    }
    return 0;
}

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

class union_find {
 private:
  vector<int> parent;
  vector<int> rank;
  vector<int> sizes;

 public:
  union_find(int n) : parent(n), rank(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) parent[i] = i;
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      parent[b] = a;
      if (rank[a] == rank[b]) rank[a]++;
    }
    sizes[find(a)] = sizes[a] + sizes[b];
  }
  int find(int a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
  int size(int a) { return sizes[find(a)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(m);
  for (auto& e : a) {
    cin >> e.first >> e.second;
    e.first--;
    e.second--;
  }
  union_find uf(n);
  vector<ll> r(m);
  r[m - 1] = (ll)n * (n - 1) / 2;
  for (int i = m - 1; i >= 1; i--) {
    r[i - 1] = r[i];
    if (uf.find(a[i].first) != uf.find(a[i].second)) {
      r[i - 1] -= (ll)uf.size(a[i].first) * uf.size(a[i].second);
      uf.unite(a[i].first, a[i].second);
    }
  }
  for (auto e : r) {
    cout << e << endl;
  }
}

Measured memory_bytes: 4096
//organize and stay in moment - Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
#define MAXN (int)2e5+5
#define pb push_back
#define ld long double
int mod= 1e9+7;
int mod2=998244353;
int arr[MAXN];
int as;
void input(){
  cin>>as;
  f(i,0,as) cin>>arr[i];
}
int nc2(int n){
	if(n<2)
	return 0;
	int p=n-1;
	if(n&1)
		p/=2;
	else n/=2;
	p*=n;
	return p;
}
bool isPallin(string s){
	int n=s.size();
	f(i,0,n/2)
	if(s[i]!=s[n-i-1])
	return 0;
	return 1;
}
void solve(){
	int n; cin>>n;
	int a[n]; f(i,0,n) cin>>a[i];
	map<int,int> mp;
	f(i,0,n)
		++mp[a[i]];
	int ans=0;
	for(auto it: mp)
		ans+=nc2(it.second);
	f(i,0,n){
		int pp=mp[a[i]];
		int temp=ans;
		temp-=nc2(pp);
		temp+=nc2(pp-1);
		cout<<temp<<"\n";
	}
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t; t=1; //cin>>t;
  while(t--) solve();
  return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct aUnionFind {
	vector<pair<int, long long int>> data;
	aUnionFind(int size) : data(size, make_pair(-1, 0)) { }

	//y is w bigger than x
	bool unionSet(const int x, const int y, const long long int w) {
		const int rx(root(x).first), ry(root(y).first);
		if (rx != ry) {
			data[rx].first += data[ry].first; data[ry].first = rx;
			data[ry].second = w + data[x].second - data[y].second;
			return true;
		}
		else {
			return root(x).second + w == root(y).second;
		}
	}
	bool findSet(const int x, const int y) {
		return root(x) == root(y);
	}

	//x is belong to first
	//x is second bigger than first
	pair<int, long long int> root(const int x) {
		if (data[x].first < 0) {
			return make_pair(x, 0);
		}
		else {
			pair<int, long long int>ndata;
			ndata.first = root(data[x].first).first;
			ndata.second = data[x].second + root(data[x].first).second;
			return data[x] = ndata;
		}
	}
	int size(const int x) {
		return -data[root(x).first].first;
	}
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<int>ids(N);
	iota(ids.begin(), ids.end(), 0);
	int num = N;
	aUnionFind uf(N+Q);
	while (Q--) {
		string st; cin >> st;
		if (st == "COMPARE") {
			int a, b; cin >> a >> b;
			a--; b--;
			int ap = ids[a];
			int bp = ids[b];
			const auto ar = uf.root(ap);
			const auto br = uf.root(bp);
			if (ar.first == br.first) {
				cout << br.second - ar.second << endl;
			}
			else {
				cout << "WARNING" << endl;
			}
		}
		else {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			int ap = ids[a];
			int bp = ids[b];
			const auto ar = uf.root(ap);
			const auto br = uf.root(bp);
			if (ar.first == br.first) {
				const int sa = br.second - ar.second;
				assert(sa == c);
				uf.unionSet(bp, num,sa);
				ids[b] = num;
				ids[a] = bp;
			}
			else {
				const int sa = c;
				uf.unionSet(ap, bp, c);
				uf.unionSet(bp, num, sa);
				ids[b] = num;
				ids[a] = bp;
			}
			num++;
		}
	}
	return 0;
}

Measured memory_bytes: 6196
#include<cstdio>
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
stack<char>s;
string a;
int main()
{
    cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++)
        s.push(a[i]);
    bool ju=1;
    for(int i=0;i<n;i++)
    {
        char top=s.top();
        if(top=='b')
            top='d';
        else if(top=='d')
            top='b';
        else if(top=='p')
            top='q';
        else if(top=='q')
            top='p';
        if(top==a[i])
        {
            ju=1;
            s.pop();
        }
        else
        {
            ju=0;
            break;
        }
    }
    if(ju==0)
        printf("No");
    else
        printf("Yes");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

string s, t;
int ans;

int main() {
	fastio; cin >> s >> t;
	FOR(i, 0, s.length()-1) ans += (s[i] != t[i]);
	cout << ans;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

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

void solve(long long H, long long W, long long N, long long s_r, long long s_c, std::string S, std::string T){
    int l = 0, r = W - 1;
    loop (N, i) {
        char s = S[N - 1 - i];
        if (s == 'L') l++;
        if (s == 'R') r--;
        if (l < 0 || l > r || r > W - 1) {
            cout << NO << endl;
            return;
        }

        if (i == N - 1) continue;
        char t = T[N - 2 - i];
        if (t == 'R') l = max(0, l - 1);
        if (t == 'L') r = min((int)W - 1, r + 1);

        // cout << "i:" << i << endl;
        // cout << "(l, r): (" << l << "," << r << ")" << endl;
    }
    if (s_c - 1 < l || s_c - 1 > r) {
        cout << NO << endl;
        return;
    }


    l = 0, r = H - 1;
    loop (N, i) {
        char s = S[N - 1 - i];
        if (s == 'U') l++;
        if (s == 'D') r--;
        if (l < 0 || l > r || r > H - 1) {
            cout << NO << endl;
            return;
        }

        if (i == N - 1) continue;
        char t = T[N - 2 - i];
        if (t == 'D') l = max(0, l - 1);
        if (t == 'U') r = min((int)H - 1, r + 1);
    }
    if (s_r - 1 < l || s_r - 1 > r) {
        cout << NO << endl;
        return;
    }

    cout << YES << endl;
}

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



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << 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; }

int main()
{   
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    int r = 0;
    ll ans = 0, x = 0, sum = 0;
    rep(l, n) {
        while(r < n && (x^a[r]) == (sum+a[r])) {
            x ^= a[r];
            sum += a[r];
            r++;
        }
        //cout << l << " " << r << endl;
        ans += r-l;
        if(l==r) r++;
        else {
            x ^= a[l];
            sum -= a[l];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4820
from itertools import combinations

n = int(input())
m = 1
while m * (m+1) // 2 <= n:
    m += 1
m -= 1
if m * (m+1) // 2 == n:
    print("Yes")
    k = n*2 // m
    print(k)
    ans = [[] for i in range(k)]
    c = tuple(i for i in range(k))
    for i, comb in enumerate(combinations(c, 2)):
        ans[comb[0]].append(i+1)
        ans[comb[1]].append(i+1)
    for i in ans:
        print(m, *i)

else:
    print("No")

Measured memory_bytes: 12624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

const long nmax=1000000;


long long fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(long i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}

ll com(ll n, ll k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

ll mod_pow(ll x, ll n){
 ll res=1;
  while(n>0){
   if(n&1) res=res*x%mod;
   x=x*x%mod;
   n>>=1;
}
return res;
}

 
void solve(){
  ll n,m,k;
  cin >> n >> m >> k;
  comint();
  
  ll res=0;
  rep(c,0,k+1) {
    res+=(((m*com(n-1,c))%mod)*mod_pow(m-1,n-1-c))%mod;
    res%=mod;
  }
  cout << res << endl;
}

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


Measured memory_bytes: 27092
#include <stdio.h>
#include <ctype.h>
#include <string.h>

void print_int(int n)
{
    printf("%d\n",n);
}

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void sort(int a[], int n)
{
    for(int i = 1; i < n; i++)
    {
        int j = i-1;
        while(j >= 0 && a[j+1] > a[j])
        {
            swap(&a[j+1],&a[j]);
            j--;
        }
        
    }
    
}

char s[10000000];
int main(void)
{
    scanf("%s", s);
    int j = 0 ,k = 0;
    int count = strlen(s);
    

    for(int i = 0; i < count; i++)
    {
        if(s[i] != (i % 2 == 0 ? '1' : '0'))
        {
            j++;
        }
    }

    for(int i = 0; i < count; i++)
    {
        if(s[i] != (i % 2 == 0 ? '0' : '1'))
        {
            k++;
        }
    }
    
    print_int(j > k ? k : j);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int N, K;
    cin >> N >> K;
    vector<int> v;

    for (int i = 0; i < N; i++) {
        v.push_back(0);
    }

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        v[a - 1] += 1;
    }

    int numOfKinds = 0;

    for (int i = 0; i < N; i++) {
        if (v[i] > 0) {
            numOfKinds += 1;
        }
    }

    if (numOfKinds <= K) {
        cout << "0" << "\n";
        return 0;
    }

    sort(v.begin(), v.end());

    int result = 0;

    for (int i = 0; i < N; i++) {

        if (v[i] > 0) {
            result += v[i];
            numOfKinds -= 1;
            if (numOfKinds <= K) {
                break;
            }
        }
    }

    cout << result << "\n";

    return 0;

}

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

int  main()
{
	int n, k; cin >> n >> k;
	vector<int> h(n);
	int ans = 0;
	rep(i,n)
	{
		int d;
		cin >> d;
		if (d >= k)
			ans++;
	}
	cout << ans << endl;
	return (0);
}


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


long long F(long long n){
    stringstream ss;
    ss << n;
    string s = ss.str();
	return s.size();
}

int main() {
	long long n,a,ans=1e9;
	cin >> n;
	for(long long i=1;i*i<=n;i++){
		if(n%i==0){
			a = max(F(n/i), F(i));
			ans = min(ans,a);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
int bel[1005][1005], cnt = 0, h, w;
char s[1005][1005];
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
set <int> g[1000005];
queue <int> q;
inline void dfs(int x, int y) {
	bel[x][y] = cnt;
	for (int i = 0; i < 4; i ++) {
		int xi = x + dx[i], yi = y + dy[i];
		if (!bel[xi][yi] && s[xi][yi] == '.') dfs(xi, yi);
	}
}
inline void ext(int x, int y) {
	for (int i = -2; i <= 2; i ++) {
		if (x + i <= 0 || x + i > h) continue; 
		for (int j = -2; j <= 2; j ++) {
			if (y + j <= 0 || y + j > w) continue;
			if (s[x + i][y + j] == '.' && bel[x + i][y + j] != bel[x][y]) {
				g[bel[x][y]].insert(bel[x + i][y + j]);
				g[bel[x + i][y + j]].insert(bel[x][y]);
			}
		}
	}
}
int dis[1000005];
int main() {
	int ch, cw, sh, sw;
	readin(h); readin(w);
	readin(ch); readin(cw); readin(sh); readin(sw);
	for (int i = 1; i <= h; i ++) {
		scanf("%s", s[i] + 1);
	}
	for (int i = 1; i <= h; i ++) {
		for (int j = 1; j <= w; j ++) {
			if (!bel[i][j]) {
				cnt ++;
				dfs(i, j);
			}
		}
	}
	for (int i = 1; i <= h; i ++) {
		for (int j = 1; j <= w; j ++) {
			if (s[i][j] == '.') ext(i, j);
		}
	}
	q.push(bel[ch][cw]);
	for (int i = 1; i <= cnt; i ++) dis[i] = 1e9;
	dis[bel[ch][cw]] = 0;
	while(!q.empty()) {
		int d = q.front();
		q.pop();
		if (d == bel[sh][sw]) break;
		int u;
		for (set <int> :: iterator it = g[d].begin(); it != g[d].end(); it ++) {
			u = *it;
			if (dis[u] == 1e9) {
				dis[u] = dis[d] + 1;
				q.push(u);
			}
		}
	}
	if (dis[bel[sh][sw]] == 1e9) puts("-1");
	else writeln(dis[bel[sh][sw]], '\n');
	return 0;
}




Measured memory_bytes: 77028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string x;
    cin >> x;
    int count = 0,del = 0;
    for(int i = 0;i < x.size();i++)
    {
        if(x[i] == 'S')
        {
            count++;
        }
        else if(count > 0)
        {
            count--;
            del++;
        }
    }
    cout << x.size() - del * 2 << "\n";

    return 0;
}

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

# aの要素すべてのXOR、sを求めます
s = a[0]
for num in a[1:]:
    s ^= num

# i番目のすぬけくんは、s xor a_iです
res = [0] * n
for i, num in enumerate(a):
    res[i] = s ^ num

print(*res)

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

#define nax 3009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> vi;

int main(){
	string a,b;
	int dp[nax][nax];

	cin>>a>>b;

	REP(i,nax){
		dp[i][0] = 0;
		dp[0][i] = 0;
	}

	int n = int(a.size()), m = int(b.size());
	FOR(i,1,n+1){
		FOR(j,1,m+1){
			if(a[i-1]==b[j-1]){
				dp[i][j] = max(dp[i-1][j-1]+1,
					max(dp[i-1][j],dp[i][j-1]));
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	string ans;
	int i = n,j = m;
	while(i>0&&j>0){
		if(dp[i][j]==(dp[i-1][j-1]+1)&&(a[i-1]==b[j-1])){
			ans = ans+a[i-1];
			i = i-1;
			j = j-1;
		}else if(dp[i-1][j]==dp[i][j]){
			i = i-1;
		}else{
			j = j-1;
		}
	}
	reverse(ans.begin(),ans.end());

	cout<<ans;

	return 0;
}

Measured memory_bytes: 35584
#include<stdio.h>

void trace(int A[],int N){
  int i;
  for (i=0; i<N; i++){
    if(i>0)
      printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int i,j,v;
  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

  scanf("%d",&N);
  for(i=0; i<N; i++)
    scanf("%d",&A[i]);

  trace(A,N);
  insertionSort(A,N);

  return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    if ((A == B && B != C) || (B == C && C != A) || (C == A && A != B)) {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
//#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

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

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
    	   ll m,d;
    	   cin>>m>>d;
    	   ll c=0;
    	   if(d<=21)
    	   cout<<0<<endl;
    	   else
    	   {
    	       for(ll i=22;i<=d;i++)
    	       {
    	           ll p=i;
    	           ll g=i%10;
    	           ll h=i/10;
    	           if(g>=2&&h>=2)
    	           {
    	               if(g*h<=m)
    	               c++;
    	           }
    	       }
    	       cout<<c<<endl;
    	   }
    	   

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        s: Chars,
        t: Chars,
    };

    let res = s
        .into_iter()
        .zip(t.into_iter())
        .map(|(a, b)| format!("{}{}", a, b))
        .join("");
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2244
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    int a, b, C;
    cin >> a >> b >> C;
    double S, L, h;
    h = b * sin(C * M_PI / 180.0);
    S = a * h / 2.0;
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C *M_PI / 180.0));
    cout << fixed << setprecision(5);
    cout << S << endl;
    cout << L << endl;
    cout << h << endl;
}

Measured memory_bytes: 1236
k = int(input())
d1 = k % 10
mae = 0
sd = [0]*10
cnt = 0
if not d1 in (1, 3, 7, 9):
  print(-1)
  exit()
for i in range(1,10) :
  sd[d1 * i % 10] = i
#print(sd)

for j in range(999999):
  d2 = 7 - mae % 10
  s = str(sd[d2] * k + mae)
#  print("mae ", mae,"",sd[d2] * k )
#  print("s1=",s)
  for i in range(len(s)-1, -1, -1):
#    print("s[",i,"]=",s[i])
    if (s[i]) == "7":
      cnt += 1
    else:
      s = s[0:i+1]
      mae = int(s)
#      print("s2=",s)
      break
#    print("i= ",i)
    if i == 0 :
      print(cnt)
      exit()

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

int main() {
  int h,w;
  string l="";
  cin>>h>>w;
  
  vector<string> A(h);
  
  for(int i;i<h;i++){
    cin>>A.at(i);
  }
  
  for(int i;i<w+2;i++){
    l+="#";
  }
  cout<<l<<endl;
  for(int i;i<h;i++){
    cout<<"#"+A.at(i)+"#"<<endl;
  }
  cout<<l<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
typedef pair<string,string>P;
 
int n,ans;
string s;
map<pair<string,string> ,int>M;
 
 
signed main(){
	cin>>n>>s;
	string t=s.substr(n);
	for(int i=0;i<(1<<n);i++){
		int x=__builtin_popcount(i);
		string y="",z="";
		for(int j=0;j<n;j++)if((1<<j)&i)y+=t[j];
			else z+=t[j];
		reverse(y.begin(),y.end());
		reverse(z.begin(),z.end());
		M[P(y,z)]++;
	}
	t=s.substr(0,n);
	for(int i=0;i<(1<<n);i++){
		int x=__builtin_popcount(i);
		int z=n-x;
		string y="",Z="";
		for(int j=0;j<n;j++)if((1<<j)&i)y+=t[j];
			else Z+=t[j];
		if(y>Z)swap(y,Z);
		if(y.size()==1&&Z.size()==1){
			ans+=M[P(y,Z)];
			ans+=M[P(Z,y)];
		}
		else if(y.size()==1&&Z.size()!=1){
			ans+=M[P(y,Z)];
			ans+=M[P(Z,y)];
		}
		else{
			ans+=M[P(y,Z)];
			ans+=M[P(Z,y)];
		}
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 72320
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M;
  cin>>N>>M;
  lint ans;
  if(N>=M/2)ans=M/2;
  else ans=N+(M-2*N)/4;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n + 1);
  vec[0] = 0;
  for (int i = 1; i <= n;i++){
    cin >> vec[i];
  }
  int cnt = 0;
  vector<bool> totori(n + 1, false);
  for (int i = 1; i <= n;i++){
    if(vec[vec[i]] ==i ){
      totori[i] = true;
    }
      if(totori[i]){
        cnt++;
      }
  }
  cout << cnt/2 << endl;
}


Measured memory_bytes: 3780
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 K = sc.nextInt();
		int result = 0;

		for(int i = Math.min(A,B); K > 0; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				result = i;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 25172
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, D1, D2 = reads()
NN = 2 * N

def deg(x):
  return next(i for i in count() if x >> i & 1 == 1)

p1 = deg(D1)
p2 = deg(D2)

def group(x, y, p):
  hp = p >> 1
  if p & 1 == 0:
    return (x >> hp & 1) ^ (y >> hp & 1)
  else:
    return x >> hp & 1

pts = [(x, y) for x in range(NN) for y in range(NN) if group(x, y, p1) == 0 and group(x, y, p2) == 0]
for x, y in pts[:N**2]:
  print(x, y)


Measured memory_bytes: 21696
a,b,c = gets.split.map(&:to_i)
list = Array.new
list[0] = a+b
list[1] = b+c
list[2] = c+a

min = 10000000000000
for i in 0..2
 if min > list[i]
  min = list[i]
 end
end

puts(min) 

Measured memory_bytes: 1788
N,M=map(int,input().split())
points=[]
ppp=[]
ppm=[]
pmp=[]
mpp=[]
for _ in range(N):
    x,y,z=map(int,input().split())
    ppp.append(x+y+z)
    ppm.append(x+y-z)
    pmp.append(x-y+z)
    mpp.append(-x+y+z)
ppp.sort()
ppm.sort()
pmp.sort()
mpp.sort()
points.append(abs(sum(ppp[:M])))
points.append(abs(sum(ppm[:M])))
points.append(abs(sum(pmp[:M])))
points.append(abs(sum(mpp[:M])))
points.append(abs(sum(ppp[-M:])))
points.append(abs(sum(ppm[-M:])))
points.append(abs(sum(pmp[-M:])))
points.append(abs(sum(mpp[-M:])))
if M==0:
    print(0)
else:
    print(max(points))

Measured memory_bytes: 3188
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

    bool can = false;
    for(int i=1;i<=b;++i){
        if((i*a)%b==c){
            can = true;
        }
    }
    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 75;
const int mod = 1000000007;
int n, m, posr[N], cr, a[N], fact[301], ifact[301], inv[301];
char S[N];
int ans;
inline void Init() {
	inv[1] = 1;
	for (int i = 2; i <= 300; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= 300; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
		ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
	}
}
inline void calc(int cnt, int sum) {
	if (!cnt) { ans = (ans + 1) % mod; return; }
	if (cr < cnt) return;
	int R[N], B[N], vis[N];
	for (int i = 1; i <= m; i++) vis[i] = 0;
	int fir1 = cnt + 1;
	for (int i = 1, posb = 1; i <= cnt; i++) {
		if (a[i] == 1) {
			fir1 = i;
			while (i <= cnt) {
				R[i] = B[i] = posr[i];
				vis[R[i]] = 1;
				i++;
			}
			break;
		}
		if (posb < posr[i]) posb = posr[i] + 1;
		while (posb <= m && S[posb] != 'b') posb++;
		if (posb > m) return;
		R[i] = posr[i];
		B[i] = posb;
		vis[R[i]] = vis[B[i]] = 1;
		posb++;
	}
	for (int i = fir1 - 1, j = m, ss = 0, ps = 0; i; i--) {
		while (j > B[i]) {
			if (!vis[j]) ss++;
			j--;
		}
		if (ss - ps < a[i] - 2) return;
		ps += a[i] - 2;
	}
	int res = fact[cnt], cp = 1;
	for (int i = 1, j = 0; i <= cnt; i++) {
		j++;
		cp += a[i] * 2;
		if (i == cnt || a[i] != a[i + 1]) {
			res = 1ll * res * ifact[j] % mod;
			j = 0;
		}
	}
	res = 1ll * res * fact[n - sum + cp] % mod * ifact[cp - 1] % mod * ifact[n - sum + 1] % mod;
	ans = (ans + res) % mod;
}
void go(int d, int mx, int sum) {
	calc(d - 1, sum);
	if (sum + 1 <= n) {
		a[d] = 1;
		go(d + 1, 1, sum + 2);
	}
	for (int i = 2; i <= mx; i++) {
		if (sum + 2 * i - 3 <= n) {
			a[d] = i;
			go(d + 1, i, sum + 2 * i - 2);
		}
	}
}
int main() {
	Init();
	scanf("%d%d %s", &n, &m, S + 1);
	cr = 0;
	for (int i = 1; i <= m; i++) {
		if (S[i] == 'r') posr[++cr] = i;
	}
	go(1, (n + 3) >> 1, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        t_: u64,
        t: [u64; n],
    }
    let mut ans = 0;
    for i in 0..n - 1 {
        ans += min(t_, t[i + 1] - t[i])
    }
    ans += t_;
    println!("{}", ans);
}


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

int main() {
  int n, taro = 0, hana = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    string tcard, hcard;
    cin >> tcard >> hcard;
    if(tcard == hcard) {
      taro++;
      hana++;
    }else if(tcard > hcard) taro += 3;
    else hana += 3;
  }
  printf("%d %d\n", taro, hana);
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

map<int, int> mp;
void prime_factor(int n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n] += 1;
}

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

  int n;
  cin >> n;
  rep(i, 1, n + 1) prime_factor(i);

  ll ans = 1;
  for (auto m : mp) {
    ans *= m.second + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
}


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

from pprint import pprint

INF = float('inf')

n_nodes, m_edges = map(int, input().split())
edges = []
for _ in range(m_edges):
    u, v, w = map(int, input().split())
    edges.append([u, v, w])
# pprint(edges)

edges_sorted = sorted(edges, key=lambda e: e[2])
# pprint(edges_sorted)


# Kruskal's algorithm
def find_root(v, parents):
    if v == parents[v]:
        return v
    parents[v] = find_root(parents[v], parents)
    return parents[v]


def has_same_root(u, v, parents):
    return find_root(u, parents) == find_root(v, parents)


def unite(u, v, parents):
    root_u = find_root(u, parents)
    root_v = find_root(v, parents)
    parents[root_u] = root_v
    return parents


parents = [i for i in range(n_nodes)]
res = 0
for u, v, w in edges_sorted:
    if not has_same_root(u, v, parents):
        res += w
        parents = unite(u, v, parents)
print(res)



Measured memory_bytes: 27572
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

int n, a[101000];

int main()
{
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    int st = n;
    for (int i = 1; i <= n; i++)
        if (a[i] < i)
        {
            st = i - 1;
            break;
        }
    bool u = 1, r = 1;
    u = (a[st] - st - 1) & 1;
    for (int i = st + 1; i <= n; i++)
        if (a[i] == st) r = !r;
    if (!u || !r) puts("First"); else puts("Second");
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = 0; i < ty - sy; i++) printf("U");
    for(int i = 0; i < tx - sx; i++) printf("R");
    for(int i = 0; i < ty - sy; i++) printf("D");
    for(int i = 0; i < tx - sx; i++) printf("L");
    printf("L");
    for(int i = 0; i < ty - sy + 1; i++) printf("U");
    for(int i = 0; i < tx - sx + 1; i++) printf("R");
    printf("D");
    printf("R");
    for(int i = 0; i < ty - sy + 1; i++) printf("D");
    for(int i = 0; i < tx - sx + 1; i++) printf("L");
    puts("U");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  int s=0;
  vi v;

  if(n<6){
    cout<<2<<' '<<5<<' '<<63;
    if(n>3) cout<<' '<<20;
    if(n>4) cout<<' '<<30;
    cout<<endl;
    return 0;
  }


  int i=2;
  while(v.size()<n){
    if(i%2==0||i%3==0){
      s+=i;
      v.PB(i);
    }
    i++;
  }

  if(s%6==2){
    v.erase(find(all(v),8));
    while(i%6) i++;
    v.PB(i);
  }else if(s%6==3){
    v.erase(find(all(v),9));
    while(i%6) i++;
    v.PB(i);
  }else if(s%6==5){
    v.erase(find(all(v),9));
    while(i%6!=4) i++;
    v.PB(i);
  }

  rep(i,v.size()){
    cout<<v[i]<<' ';
  }
  cout<<endl;


}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    char s[200];
    int i;
    int co = 0,all = 0;
    scanf("%s", s);
    for(i = 0;s[i] != '\0';i ++){
        all ++;
    }
    for(i = 0;i < all / 2;i ++){
        if(s[i] != s[all - (i + 1)]){
            co ++;
        }
    }
    printf("%d\n", co);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <set>

int main () {
    long long n, d, ans = 0;
    std::cin >> n >> d;
    long long x, y;
    for(int i = 0; i < n; ++i){
        std::cin >> x >> y;
        if(std::sqrt(x*x+y*y) <= d) ++ans;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3592
import itertools

A = "MARCH"
c = {a: 0 for a in A}
N = int(input())
for _ in range(N):
    S = input()
    if S[0] in A:
        c[S[0]] += 1

print(sum([c[cb[0]] * c[cb[1]] * c[cb[2]]
           for cb in itertools.combinations(A, 3)]))


Measured memory_bytes: 3060
def main():
    n = int(input())
    a = list(map(int, input().split()))
    l = max(a)
    r = 0
    chk = 10**9+1
    for x in a:
        if abs(x-l//2) < chk and x != l:
            r = x
            chk = abs(x-l//2)
    print(l, r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19964
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
ll dp[101][100001];
ll dp1[101][100001];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= k; ++j)
        {
            if(i==0 and j==0){dp[i][j]=1;dp1[i][j]=1;}
            else if(i==0){dp[i][j]=0;dp1[i][j]=((dp1[i][j-1])%mod+(dp[i][j]%mod))%mod;}
            else if(j==0){dp[i][j]=1;dp1[i][j]=1;}
            else 
            {
                if(j-a[i-1]-1<0)dp[i][j]=dp1[i-1][j];
                else dp[i][j]=((dp1[i-1][j]%mod)-(dp1[i-1][j-a[i-1]-1]%mod)+mod)%mod;
                dp1[i][j]=((dp1[i][j-1]%mod)+(dp[i][j]%mod))%mod;
                //dp[i][j]%=mod;dp1[i][j]%=mod;
            }
        }
    }
    /*for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= k; ++j)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    cout << "/////////////////////////";
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= k; ++j)
        {
            cout << dp1[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[n][k];
    }

Measured memory_bytes: 158080
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(str(int(d[i]))for i in zip(*[iter(t[m*3+1:])]*2)))
main()

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

int main(){
  int N, a[110];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a, a + N, greater<int>());
  int Alice_sum = 0, Bob_sum = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice_sum += a[i];
    } else {
      Bob_sum += a[i];
    }
  }

  cout << Alice_sum - Bob_sum << endl;

  return 0;
}

/* int main(){ */
/*   int a[200], N; */
/*   int alice_sum = 0, bob_sum = 0; */
/*   cin >> N; */
/*   for (int i = 0; i < N; i++) { */
/*     cin >> a[i]; */
/*   } */
/*   for (int i = N-1; i > 0; i--) { */
/*     if(a[i] >= a[i-1]){ */
/*       int tmp = a[i]; */
/*       a[i] = a[i-1]; */
/*       a[i-1] = tmp; */
/*     } */
/*   } */
/*   for (int i = 0; i < N; i++) { */
/*     if(i % 2 == 0){ */
/*       alice_sum += a[i]; */
/*     } else { */
/*       bob_sum += a[i]; */
/*     } */
/*   } */

/*   cout << alice_sum - bob_sum << endl; */
/* } */



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll maki = 1 << n;
    vector<ll> a(maki);
    for(int i=0;i<maki;i++) cin >> a[i];
    vector<ll> dp(maki, 0);
    for(int i=1;i<maki;i++){
    	dp[i] = max(dp[i-1], dp[i]);
    	for(int j=0;j<n;j++)if(i>>j & 1){
    		dp[i] = max(dp[i], a[i] + a[i-(1<<j)]);
    		int num = i-(1<<j);
    		for(int k=j+1;k<n;k++)if(i>>k & 1){
    			if((num|(i-(1<<k))) <= i){
    				if(a[num&(i-(1<<k))] == a[num] && a[num] == a[i-(1<<k)]) continue;
    				dp[i] = max(dp[i], a[num] + a[i-(1<<k)]);
    			}
    		}
    		
    	}
    	for(int j=0;j<n;j++)if(i>>j & 1){
    		a[i] = max(a[i], a[i-(1<<j)]);
    	}
    }
    for(int i=1;i<maki;i++){
    	cout << dp[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7168
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()
if  s == t[:-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 65092
#!/usr/bin/env python3

N, M = map(int, input().split())
H = list(map(int, input().split()))

G = {}

for i in range(1, N+1):
    G[i] = []
for i in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

ans = 0
for n, miti in G.items():
    f = True
    if len(miti)==0:
        ans += 1
        continue
    miti = list(set(miti))
    for m in miti:
        if H[n-1] <= H[m-1]:
            f = False
            break
    if f:
        ans += 1

print(ans)



Measured memory_bytes: 102844
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100005

ll ar[N],dp[N];

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;cin>>n>>k;
   for(int i=1;i<=n;i++) cin>>ar[i];
   dp[n]=0;
   for(int i=n-1;i>=1;i--){
      dp[i]=INT_MAX;
      for(int j=1;j<=k&&i+j<=n;j++){
         dp[i]=min(dp[i],dp[i+j]+abs(ar[i]-ar[i+j]));
      }
   }
   cout<<dp[1]<<"\n";
   return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n,m,k; cin >> n >> m >> k;
    rep(i,m+1){
        int num = i*n;
        rep(j,n+1){
            if(num+((m-i)-i)*j == k){
                yes();
                return 0;
            }
        }
    }
    no();
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<long int> > a(n, vector<long int>(n));
	vector<vector<long int> > p(n, vector<long int>(n, 1));


	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			cin >> a[i][j];
		}
	}
	int f=0;
	for(int i=0; i<n; ++i){
		for(int j=0; j<i; ++j){
			for(int k=0; k<n; ++k){
				if(a[i][k]+a[k][j]<a[i][j]){
					f=1;
				}else if(a[i][k]+a[k][j]==a[i][j] && k!=i && k!=j){
					p[i][j]=0;
				}
			}
		}
	}
	if(f==1){
		cout << -1 << endl;
	}else{
		long int r=0;
		for(int i=0; i<n; ++i){
			for(int j=0; j<i; ++j){
				if(p[i][j]==1) r+=a[i][j];
			}
		}
		cout << r << endl;
	}

	return 0;

}







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

int main() {
  string S; 
  cin>>S;
  if(S.at(2)==S.at(3) &&S.at(5)==S.at(4)){
  cout <<"Yes" << endl; 
  }
  else{
  cout <<"No "<< endl; 
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    if(s=="Sunny")cout << "Cloudy" << endl;
    else if(s=="Cloudy")cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256