akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll r, b, g, k;
	cin>>r>>g>>b>>k;
	if(b>g && g>r) cout<<"Yes";
	else{
		while(k){
			if(g<=r){
				g*=2;
				k--;
			}
			else break;
		}
		while(k){
			if(b<=g){
				b*=2;
				k--;
			}
   			else break;
		}
		if(b>g && g>r) cout<<"Yes";
		else cout<<"No";
	}
	
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> a(h);
    for(auto& e : a) cin >> e;

    string hf = string(w + 2, '#');
    cout << hf << endl;
    for(auto& e : a){
        cout << "#" + e + "#" << endl;
    }
    cout << hf << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n,x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i,n){
    cin >> v[i];
  }
  v.push_back(x);
  sort(v.begin(), v.end());
  vector<int> dist(n);
  rep(i, n)
  {
    dist[i] = v[i + 1] - v[i];
  }
  int ans = dist[0];
  rep(i, n - 1)
  {
    ans = __gcd(ans, dist[i+1]);
  }
  cout << ans << endl;
}

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

const int INF = 5000;

int main() {

        int dp[41][405][405];
        for (int i=0; i<=40; ++i) {
                for (int j=0; j<405; ++j) {
                        for (int k=0; k<405; ++k) {
                                dp[i][j][k] = INF;
                        }
                }
        }
        dp[0][0][0] = 0;



        int n, ma, mb;
        cin >> n >> ma >> mb;

        int a[40], b[40], c[40];
        for (int i=0; i<n; ++i) {
                cin >> a[i] >> b[i] >> c[i];
        }

        for (int i=0; i<n; ++i) {
                // int a, b, c;
                // cin >> a >> b >> c;
                for (int j=0; j<405; ++j) {
                        for (int k=0; k<405; ++k) {
                                if (dp[i][j][k]==INF) continue;

                                        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                                        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);


                        }
                }
        }

        int ans = INF;
        for (int i=1; i*ma<=400 && i*mb<=400; ++i) {
                ans = min(ans, dp[n][i*ma][i*mb]);
        }
        if (ans<INF) {
                cout << ans << endl;
        } else {
                cout << -1 << endl;
        }
        return 0;
}


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

const double g = 9.8;
const double eps = 1e-8;

double calc(double vy, double t) {
    return vy * t - g * t * t / 2;
}

int cmp(double lb, double ub, double a) {
    return a < lb + eps ? -1 : (a > ub - eps ? 1 : 0);
}

int main() {
    int n, v, x, y; cin >> n >> v >> x >> y;
    vector<int> l(n), B(n), r(n), t(n);
    for(int i = 0; i < n; ++i) {
        cin >> l[i] >> B[i] >> r[i] >> t[i];
        r[i] = min(x, r[i]);
    }

    // tx, ty を通るように打ち出してぶつけられるか
    auto check = [&] (double tx, double ty) {
        const double a = g * g / 4,
                     b = g * ty - v * v,
                     c = tx * tx + ty * ty;
        double D = b * b - 4 * a * c;
        if(D < 0 && D > -eps) D = 0;
        if(D < 0) return false;
        for(int d = -1; d <= 1; d += 2) {
            const double t2 = (-b + d * sqrt(D)) / (2 * a);
            if(t2 <= 0) continue;
            const double tt = sqrt(t2);
            const double vx = tx / tt, vy = (ty + g * tt * tt / 2) / tt;
            const double yt = calc(vy, x / vx);
            if(yt < y - eps) continue;

            bool ok = true;
            for(int i = 0; i < n; ++i) {
                if(l[i] >= x) continue;
                if(r[i] == x && y <= t[i] && B[i] <= yt) ok = false;
                const int yl = cmp(B[i], t[i], calc(vy, l[i] / vx));
                const int yr = cmp(B[i], t[i], calc(vy, r[i] / vx));
                const int xh = cmp(l[i], r[i], vx * (vy / g));
                const int yh = cmp(B[i], t[i], calc(vy, vy / g));
                if(xh == 0 && yh >= 0 && yl < 0) ok = false;
                if(yl * yr <= 0) ok = false;
            }
            if(ok) return true;
        }
        return false;
    };

    bool ok = check(x, y);
    for(int i = 0; i < n; ++i) {
        ok |= check(l[i], t[i]);
        ok |= check(r[i], t[i]);
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3112
n, k = map(int, input().split())
f = lambda i: (n + 1) * i * (i - 1) // 2 - i * (i - 1) * (2 * i - 1) // 6 
print((n - k + 2 + f(n + 2) - f(k)) % (10**9 + 7))


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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int dif='A'-'a';
  cout<<(char)(a[0]+dif)<<(char)(b[0]+dif)<<(char)(c[0]+dif)<<endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    if(n == 2){
        print(1);
        ret;
    }
    vl v;
    for(ll i=2; i*i<=n; i++){
        if(n%i == 0){
            v.pb(i);
        }
    }
    // printc(v);
    ll y = n-1;
    vl v2;
    for(ll i=2; i*i<=y; i++){
        if(y%i == 0){
            v2.pb(i);
            if(i*i != y){
                v2.pb(y/i);
            }
        }
    }
    // printc(v2);
    ll ans = 2;
    for(auto x: v){
        ll temp = n;
        while(temp%x == 0){
            temp /= x;
        }
        if(temp % x == 1) ans++;
    }
    // trace(ans);
    ans += v2.size();
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

#define rep(i, n) for(int i=0; i<n; i++)

const int mod=1e9+7;
inline int add(int x,int y){
  x+=y;
  if (x>=mod) return x-mod;
  return x;
}
inline int sub(int x,int y){
  x-=y;
  if (x<0) return x+mod;
  return x;
}
inline int mul(int x,int y){
  return (x*1ll*y)%mod;
}
inline int power(int x,int y){
  int ans=1;
  while(y){
    if (y&1) ans=mul(ans,x);
    x=mul(x,x);
    y>>=1;
  }
  return ans;
}
inline int inv(int x){
  return power(x,mod-2);
}

int main()
{
  IOS;
  ll n, k;
  cin >> n >> k;
  cout << min(n%k, k-n%k) << endl;
  return 0;
}


Measured memory_bytes: 3640
// AOJ 2408

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(void)
{
	int n, k;
	vector < vector <int> > boat;
	
	cin >> n >> k;
	for (int i = 0; i < k; i++){
		int m; cin >> m;
		vector <int> jap(m);
		for (int j = 0; j < m; j++) cin >> jap[j];
		boat.push_back(jap);
	}
	
	int r, a, b;
	cin >> r;
	bool ng[55][55];
	for (int i = 0; i < 55; i++) fill (ng[i], ng[i] + 55, false);
	for (int i = 0; i < r; i++){
		cin >> a >> b;
		ng[a][b] = ng[b][a] = true;
	}
	
	map <int, int> ret;
	for (int i = 0; i < k; i++){
		for (int j = 0; j < boat[i].size(); j++){
			for (int k = 0; k < boat[i].size(); k++){
				if (ng[boat[i][j]][boat[i][k]] == true){
					ret[boat[i][j]] = 1;
					ret[boat[i][k]] = 1;
					ng[boat[i][j]][boat[i][k]] = ng[boat[i][k]][boat[i][j]] = false;
				}
			}
		}
	}
	
	cout << ret.size() << endl;
	
	#if 0
	if (ngnum.size() == 0){
		cout << "0" << endl;
	}
	else {
		ngnum.push_back(1000000);
		sort(ngnum.begin(), ngnum.end());
		puts("");
		for (int i = 0; i < ngnum.size(); i++) cout << ngnum[i] << " ";
		puts("");
		int ret = ngnum[0], prev = ngnum[0];
		for (int i = 0; i < ngnum.size(); i++){
			if (prev != ngnum[i] && ngnum[i] <= 50){
				ret++;
				prev = ngnum[i];
			}
		}
		cout << ret << endl;
	}
	#endif
	
	return 0;
}

Measured memory_bytes: 1220
N,M,X,Y = map(int,input().strip().split())

x_max = max(list(map(int,input().strip().split())))
y_min = min(list(map(int,input().strip().split())))

for p in range(X + 1,Y + 1):
    if x_max < p and p <= y_min:
        print("No War")
        exit()

print("War")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main()
{
  string code;
  int N,Q;
  cin >> N >> Q >> code;
  int  hold=0;
  vector<int> ruiseki(100005,0);
  
  rep(i, 100005){
    if(i!=0)
      ruiseki[i]=ruiseki[i-1];
    
    if(hold==1&&code[i]=='C'){
      ruiseki[i]++;
      hold=0;
      continue;
    }
    
    if(code[i]=='A'){
      hold=1;
      continue;
  }
    hold=0;
  }
  
  int l,r;
  rep(i, Q){
  cin >> l >> r;
    cout << ruiseki[r-1]-ruiseki[l-1]<< endl;
  }
  
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#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()

int main() {
    int n,cnt=0,maxcnt=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            cnt++;
            maxcnt=max(cnt,maxcnt);
        }
        else if(s[i]=='D'){
            cnt--;
        }
            
    }
    cout<<maxcnt<<endl;
    
}

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

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  if (S.at(K-1) == 'A') {
    S.at(K-1) = 'a';
  }
  else if (S.at(K-1) == 'B') {
    S.at(K-1) = 'b';
  }
  else if (S.at(K-1) == 'C') {
    S.at(K-1) = 'c';
  }
  cout << S << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vi a,b,c;

int main(){
	cin>>n;
	a=b=c=vi(n-1);
	for(int i=0;i<n-1;i++) cin>>a[i]>>b[i]>>c[i];
	for(int i=0;i<n;i++){
		int t=0;
		for(int j=i;j<n-1;j++){
			if(t<b[j]) t=b[j];
			else t=(t-b[j]-1)/c[j]*c[j]+b[j]+c[j];
			t+=a[j];
		}
		cout<<t<<endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    long long N,K;
    cin >> N >> K;
    long long H[N];
    for(int i=0;i<N;i++) cin >> H[i];
    sort(H,H+N);
    long long sum = 0;
    for(int i=0;i<N;i++){
        if(i>N-K-1) H[i] = 0;
        sum += H[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122C
{
    class Program
    {
        public static int N, Q;
        public static string S;
        public static int[] l, r;
        public static List<int> acs = new List<int>();
        static void Main(string[] args)
        {
            string[] on = Console.ReadLine().Split(' ');
            N = int.Parse(on[0]);
            Q = int.Parse(on[1]);
            S = Console.ReadLine();
            l = new int[Q]; r = new int[Q];
            for (int i = 0; i < Q; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                l[i] = int.Parse(str[0]) - 1;
                r[i] = int.Parse(str[1]) - 1;
            }


            //検索
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'C') { acs.Add(i); }
            }

            for (int i = 0; i < Q; i++)
            {
                int h = binary_search(l[i]);
                int g = binary_search2(r[i] - 1);
                Console.WriteLine(g-h);
            }
            Console.ReadLine();
        }

        static bool isOK(int index, int key)
        {
            if (acs[index] >= key) { return true; }
            return false;
        }
        static bool isOK2(int index, int key)
        {
            if (acs[index] > key) { return true; }
            return false;
        }
        static int binary_search(int key)
        {
            int ng = -1;
            int ok = acs.Count();
            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (isOK(mid, key)) {
                    ok = mid;
                }
                else { ng = mid; }
            }
            return ok;

        }
        static int binary_search2(int key)
        {
            int ng = -1;
            int ok = acs.Count();
            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;
                if (isOK2(mid, key))
                {
                    ok = mid;
                }
                else { ng = mid; }
            }
            return ok;

        }
    }
}


Measured memory_bytes: 17596
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


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

  int count = 0;

  rep(i, s.size()){
    if(i % 2 == 0){
      if(s[i] == '0'){
        count++;
      }
    }else{
      if(s[i] == '1'){
        count++;
      }
    }
  }
  int n = s.size() - count;
  cout << min(count, n) << endl;
  return 0;
}


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

int main()
{
	int n = 0;
	cin >> n;
	vector<int> list(n);
	for (int i = 0; i < n; i++)
	{
		cin >> list[i];
	}
	int h = list[0];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (list[i] >= h)
		{
			ans++;
		}
		h = max(h, list[i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
S = input()

if int(S[0:2]) >= 13 and 1 <= int(S[2:4]) <= 12:
    ans ="YYMM"
elif int(S[0:2]) == 00 and 1 <= int(S[2:4]) <= 12:
    ans = "YYMM"
elif 1 <= int(S[0:2]) <= 12 and int(S[2:4]) >= 13:
    ans = "MMYY"
elif 1 <= int(S[0:2]) <= 12 and int(S[2:4]) == 00:
    ans = "MMYY"
elif int(S[0:2]) == 00 and 1 <= int(S[2:4]) <= 12:
    ans = "YYMM"
elif 1 <= int(S[0:2]) <= 12 and int(S[2:4]) <= 12:
    ans = "AMBIGUOUS"
elif int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
    ans = "AMBIGUOUS"
else:
    ans = "NA"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    cout << (n - 1 + k - 2) / (k - 1) << '\n';

    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b) {
    cout<<c<<endl;
  }
  if(b==c) {
    cout<<a<<endl;
  }
  if(a==c) {
    cout<<b<<endl;
  }
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll left = 4 * a * b, right = (c - a - b) * (c - a - b);
    if (left < right && c - a - b > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

int main() {

	int n; cin >> n;
	double ans;
	if (n % 2 == 0) ans = 0.5;
	else {
		int tmp = n / 2 + 1;
		ans = (double)tmp / n;
	}
	cout << fixed << setprecision(11) << ans << endl;
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
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; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//ctrl + command + e -> 変数一括変更



int main() {
    
    
   
    int n; cin >> n;
    int table[n]; fill_n(table, n, inf); //0からの距離
    table[0] = 0;
    vector<vector<pii> > edge(n);
    rep(i, n) {
        int u, k; cin >> u >> k;
        rep(j, k) {
            int v, c; cin >> v >> c;
            edge[u].eb(v, c);
        }
        
    }
    
    while (1) {
        int update = 0;
        rep(from, n) {
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                int cost = edge[from][j].S;
                
                if (table[to] > table[from] + cost) {
                    update = 1;
                    table[to] = table[from] + cost;
                }
            }
        }
        if (update == 0) break;
    }
    
    out(0 << " " << 0);
    rep3(i, 1, n) out(i << " " << table[i]);
        
        
    
    
    
}



Measured memory_bytes: 7504
#include<stdio.h>

int main()
{
	long n,a,b,l,m;

	scanf("%ld%ld%ld",&n,&a,&b);
	l=a+b;
	if(n%l==0)
		m=a*(n/l);
	else if(n%l>=a)
		m=a*(n/l)+a;
	else
		m=a*(n/l)+n%l;
	printf("%ld",m);
	return 0;
}

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



vector<int> veca;
vector<int> vecb;
vector<int> vecc;

int fun(int a,int b){
	if(a==1){
		return veca[b];
	}
	if(a==2){
		return vecb[b];
	}
	if(a==3){
		return vecc[b];
	}
}
int dfs(int index,vector<vector<int>>&dp,int k){
	int n=veca.size();
	if(index>=n){
		return 0;
	}
	// if(index==n-1){
	// 	return max({veca[index],vecb[index],vecc[index]});
	// }
	if(dp[index][k-1]!=-1){
		return dp[index][k-1];
	}
	int ans=INT_MIN;
	for(int i=1;i<=3;i++){
		if(i!=k){
			ans=max(ans,fun(i,index)+dfs(index+1,dp,i));	
		}	
	}
	dp[index][k-1]=ans;
	return ans;
}
int32_t main(){
	int n;
	cin>>n;
	veca.resize(n);
	vecb.resize(n);
	vecc.resize(n);
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		veca[i]=a;
		vecb[i]=b;
		vecc[i]=c;
	}
	vector<vector<int>> dp(n,vector<int>(3,-1));
	// dfs(0,vec,dp);
	int ans=INT_MIN;
	for(int i=1;i<=3;i++){
		ans=max(ans,fun(i,0)+dfs(1,dp,i));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14720
n=int(input())
def f(x):
    z=1
    while not(z*(z+1)<=2*x<(z+1)*(z+2)):
        z+=1
    return z

x=[-1]*(10**6+1) #2以上の自然数に対して最小の素因数を表す
x[0]=0
x[1]=1
i=2
prime=[]
while i<=10**6:
    if x[i]==-1:
        x[i]=i
        prime.append(i)
    for j in prime:
        if i*j>10**6 or j>x[i]:break
        x[j*i]=j
    i+=1
if n==1:
    print(0)
    exit()
y=0
j=2
while j*j<=n:
    if n%j==0:
        y=1
    j+=1
if y==0:
    print(1)
    exit()
a=[]
q=0
for i in range(len(prime)):
    p=prime[i]
    while n%p==0:
        q+=1
        n=n//p
    if q>0:a.append(q)
    q=0

ans=0
for i in range(len(a)):
    ans+=f(a[i])
print(ans if n==1 else ans+1)


Measured memory_bytes: 84016
import numpy as np
N = int(input())
H = np.array([h for h in input().split()],dtype=int)
cnt = 0
maximum = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        cnt+=1
    if cnt>maximum:
        maximum = cnt
    if H[i]<H[i+1]:
        cnt=0
print(maximum)

Measured memory_bytes: 24616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		if(n%k == 0) {
			System.out.println("0");
		} else {
			System.out.println("1");
		}
		
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String str = br.readLine();
			String[] st = str.split(" ",0);
			int N =  Integer.parseInt(st[0]);
			int M = Integer.parseInt(st[1]);
			int[] count = new int[N];
			Arrays.fill(count,0);
			for(int i = 0;i <M;i++){
				str = br.readLine();
				st = str.split(" ",0);
				int a =  Integer.parseInt(st[0]);
				int b = Integer.parseInt(st[1]);
				count[a-1]++;
				count[b-1]++;
			}
			for(int i = 0; i < N ;i++){
				System.out.println(count[i]);
			}
		}catch(Exception ex){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 21204
// Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

		if(n==0&&m==0)
			break;

		int N[100], M[100];

		int N_sum = 0;
		int M_sum = 0;

		for(int i=0; i<n; i++){
			cin >> N[i];
			N_sum += N[i];
		}
		for(int i=0; i<m; i++){
			cin >> M[i];
			M_sum += M[i];
		}

//		cout << N_sum << ' ' << M_sum << endl;

		sort(N, N+n);
		sort(M, M+m);
/*
		for(int i=0; i<n; i++)
			cout << N[i] << ' ';
		cout << endl;
		for(int i=0; i<m; i++)
			cout << M[i] << ' ';
		cout << endl;
*/

		int N_sel = -1;
		int M_sel = -1;

		bool flg = false;
		for(int i=0, j=0; i<n&&j<m; ){
			if(N_sum-N[i]+M[j]==M_sum-M[j]+N[i]){
				N_sel = N[i];
				M_sel = M[j];
				flg = true;
				break;
			}
			else if(N_sum-N[i]+M[j]>M_sum-M[j]+N[i]){
				i++;
			}
			else{
				j++;
			}
		}

		if(flg){
			cout << N_sel << ' ' << M_sel << endl;
		}
		else{
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N;
int a[220000], b[220000];
int b_mod[30][220000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    for (int i = 0; i < 30; i++) {
        int mod = 1 << (i + 1);
        for (int j = 0; j < N; j++) b_mod[i][j] = b[j] % mod;
        sort(b_mod[i], b_mod[i] + N);
    }
    int ans = 0;
    for (int i = 0; i < 30; i++) {
        int cur = 0;
        int T = 1 << i;
        for (int j = 0; j < N; j++) {
            int A = a[j] % (T << 1);
            cur += lower_bound(b_mod[i], b_mod[i] + N, 2 * T - A) - lower_bound(b_mod[i], b_mod[i] + N, 1 * T - A);
            cur += lower_bound(b_mod[i], b_mod[i] + N, 4 * T - A) - lower_bound(b_mod[i], b_mod[i] + N, 3 * T - A);
        }
        ans += (cur % 2) << i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 54912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template <typename T>
struct BIT {
    vector<T> bit;
    // 単位元
    const T neutral = 0;
    // 要素数
    int n;
    BIT(int n_ = 1e5) { init(n_); }
    void init(int sz) { 
        n=1; while(n < sz) n*=2;
        bit.assign(n+1, neutral); 
    }
    void update(int i, T w) {
        for(int x=i+1; x<bit.size(); x += x&-x) bit[x] += w;
    }
    // [0,i]
    T query(int i) {
        T ret = neutral;
        for(int x=i+1; x>0; x -= x&-x) ret += bit[x];
        return ret;
    }
    // 合計がw以上の最小の位置
    int lower_bound(T w) {
        int x = 0;
        for(int k=n; k>0; k>>=1) {
            if(x+k <= n && bit[x+k] < w) {
                w -= bit[x+k];
                x += k;
            }
        }
        return x;
    }
};

int main(void) {
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i], p[i]--;

    ll ret = 0;
    BIT<ll> bit(n);
    REP(i, n) {
        bit.update(p[i], 1);
        if(bit.query(p[i]) == 1) {
            ret++;
            dump(i);
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,h,max,x;
int main(){
	cin >> n >> h;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i];
	sort(a,a+n,greater<int>());
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++){
		if(h<=0){
			cout << x;
			return 0;
		}
		if(b[i]>a[0]){
			h-=b[i];
			x++;
		}
		else break;
	}
	if(h<=0)cout << x;
	else if(h%a[0]==0)cout << x+h/a[0];
	else cout << x+h/a[0]+1;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=3.14159265358979323846;

vector<ll> calc_divisor(ll n) {
    vector<ll> res;
    for (ll i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
void solve(){
    ll n; cin >> n;
    vector<ll> div = calc_divisor(n);
    ll l = div.size();
    ll tmp = 1e18;
    for(ll i=0; i<l; i++){
        for(ll j=0; j<l; j++){
            if(div[i]*div[j] == n){
                tmp = min(tmp, div[i]+div[j]-2);
            }
        }
    }
    cout << tmp << endl;
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 105;

int n, m, i, j, tab[N][N], res[N][N], r1, r2;
char t[N];

int main() {
scanf("%d %d", &n, &m);
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<m;j++) tab[i][j] = (t[j] == '.');
}
res[0][0] = 1 - tab[0][0];
for (j=1;j<m;j++) if (tab[0][j] || !tab[0][j - 1]) res[0][j] = res[0][j - 1]; else res[0][j] = res[0][j - 1] + 1;
for (i=1;i<n;i++) if (tab[i][0] || !tab[i - 1][0]) res[i][0] = res[i - 1][0]; else res[i][0] = res[i - 1][0] + 1;
for (i=1;i<n;i++) for (j=1;j<m;j++) {
	r1 = res[i - 1][j];
	if (tab[i - 1][j] && !tab[i][j]) r1++;
	r2 = res[i][j - 1];
	if (tab[i][j - 1] && !tab[i][j]) r2++;
	res[i][j] = min(r1, r2);
	
}
/*for (i=0;i<n;i++) {
	for (j=0;j<m;j++) printf("%d ", res[i][j]);
	printf("\n");
}*/
printf("%d\n", res[n - 1][m - 1]);
}





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

int main(){
  int N;
  cin >> N;
  long double sum=0;
  long double x=0;
  for(int i=0;i<N;i++){
    cin >> x;
    sum += 1/x;
  }
  sum = 1/sum;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 0; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]){
	c[i][j] = c[i - 1][j - 1] + 1;
      } else{
	c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Measured memory_bytes: 7076
import collections
import itertools

a = int(input())

s = [input() for i in range(a)]

counter = collections.Counter(s)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

l = []

for k, v in it:
  l.append(k)

l = sorted(l)
  
for i in l:
  print(i)

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

using namespace std;

int n, m;

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (char j = 'A'; j < 'A' + m; j++){
			string s;	cin >> s;
			if (s == "snuke"){
				cout << j<<i+1<<endl;
				return 0;
			}
		}
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#define gcd(x,y,z) __gcd(__gcd(x,y),z)
using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int sum = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++) {
                sum = sum + gcd(i,j,k);
            }
        }
    }
    cout<<sum;
    
    return 0;
}

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

int main() {

  int map[14][14] = {0};
  char input;

  while(true) {

    bool flag = false;
    for ( int i = 3; i < 11; i++ ) {

      for ( int j = 3; j < 11; j++ ) {

	cin >> input;
	if ( cin.eof() ) {
	  flag = true;
	  break;
	}
	map[j][i] = input - '0';

      }
      if ( flag ) break;

    }
    if ( flag ) break;

    for ( int i = 3; i < 11; i++ ) {
      for ( int j = 3; j < 11; j++ ) {

	if ( map[j][i] != 0 ) {
	  if ( map[j][i+3] != 0 ) {
	    cout << "B";
	  }else if ( map[j+3][i] != 0 ) {
	    cout << "C";
	  }else if ( map[j-1][i+2] != 0 ) {
	    cout << "D";
	  }else if ( map[j+2][i+1] != 0 ) {
	    cout << "E";
	  }else if ( map[j+1][i+2] != 0 ) {
	    cout << "F";
	  }else if ( map[j-1][i+1] != 0 ) {
	    cout << "G";
	  }else {
	    cout << "A";
	  }
	  cout << endl;
	  flag = true;
	  break;
	}

      }
      if ( flag ) break;
    }

  }

  return 0;

}

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

int main() {
	int a, b, c;
	cin>>a>>b>>c;
	int x;
	for(int i=1;i<b;i++){
		x=a*i;
		if (x%b==c){ 
			cout<<"YES";
			return 0;
		}
		
		}
	cout<<"NO";
	return 0;
	
		
	
	return 0;
}

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

using namespace std;

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

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

    int max_length = a[0] + k - a[n-1];
    
    for(int i = 1; i < n; i++){
        if(max_length < (a[i] - a[i-1])){
            max_length = a[i] - a[i-1];
        }
    }

    cout << k - max_length << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const int mod = 1e9+7;
const int N = 1e5+10; 
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
vi G[N];
int vis[N];
int flag;
void dfs(int v,int c){
	vis[v] = c;
	for(auto it : G[v]){
		if(vis[it] == 0){
			dfs(it,1^2^c);
		}
		else if(vis[it] == c){
			flag = 0;
		}
	}
}
int main(){
  fast;
  int n,m;cin >> n >> m;
  FOR(i,1,m){
  	int u,v;cin >> u >> v;
  	G[u].pb(v);G[v].pb(u);
  }
  fill(vis,0);
  int bip = 0;
  int nbip = 0;
  int iso = 0;
  FOR(i,1,n){
  	if(vis[i] == 0){
  		if(sz(G[i]) == 0){
  			iso++;
  			continue;
  		}
  		flag = 1;
  		dfs(i,1);
  		if(flag)bip++;
  		else nbip++;
  	}
  }
  ll ans = 0;
  //cout << bip << " " << nbip << " " << iso << "\n";
  ans += 2LL*n*iso;
  ans -= 1LL*iso*iso;
  ans += 2LL*bip*bip;
  ans += 2LL*(bip)*(nbip);
  ans += 1LL*(nbip)*(nbip);
  cout << ans << "\n";
  return 0;
}

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

int main(){
	int a,b,c,d,e,k;
	std::cin>>a>>b>>c>>d>>e>>k;
	if( e-a <= k){
		std::cout<<"Yay!"<<std::endl;
		return 0;
	}else{
	std::cout<<":("<<std::endl;
	return 0;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int H, W;
	while(scanf("%d %d", &H, &W))
	{
		if(H == 0 && H == W)
		{
				break;
		}
		for(int i = 0;i < H;i++)
		{
			
			for(int j = 0;j < W;j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
} 


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

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

void print(vector<long long> vec){
  for(auto& v : vec){
    cout << v << ' ';
  }
  cout << endl;
}

void solve(long long N, std::vector<long long> A){
  vector<long long> left(N);
  vector<long long> right(N);
  left.at(0) = A.at(0);
  right.at(N - 1) = A.at(N - 1);

  for(int i = 1; i < N; ++i){
    left.at(i) = gcd(left.at(i - 1), A.at(i));
    right.at(N - 1 - i) = gcd(right.at(N - i), A.at(N - 1 - i));
  }

  //print(left);
  //print(right);

  long long max_gcd = 0;

  for(int i = 0; i < N; ++i){
    long long temp = 0;
    if(i == 0){
      temp = right.at(1);
    } else if(i == N - 1){
      temp = left.at(N - 2);
    } else{
      temp = gcd(left.at(i - 1), right.at(i + 1));
    }
    max_gcd = max(max_gcd, temp);
  }

  cout << max_gcd << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N; i++){
      scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    vector<char> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> d[i];
    }
    double uu = -INF, ud = -INF, um = -INF;
    double du = INF, dd = INF, dm = INF;
    double lle = INF, lr = INF, lm = INF;
    double rl = -INF, rr = -INF, rm = -INF;
    for (int i = 0; i < n; ++i) {
        if (d[i] == 'U') {
            chmax(uu, y[i]);
            chmin(du, y[i]);
            chmax(rm, x[i]);
            chmin(lm, x[i]);
        } else if (d[i] == 'D') {
            chmax(ud, y[i]);
            chmin(dd, y[i]);
            chmax(rm, x[i]);
            chmin(lm, x[i]);
        } else if (d[i] == 'L') {
            chmax(um, y[i]);
            chmin(dm, y[i]);
            chmax(rl, x[i]);
            chmin(lle, x[i]);
        } else if (d[i] == 'R') {
            chmax(um, y[i]);
            chmin(dm, y[i]);
            chmax(rr, x[i]);
            chmin(lr, x[i]);
        }
    }
    double lastx = 1e20, lasty = 1e20;
    double ret = 1e20;
    for (int i = 0; i <= 400000000; ++i) {
        double time = 0.5 * i;
        double u    = max({uu + time, ud - time, um});
        double d    = min({du + time, dd - time, dm});
        double l    = min({lr + time, lle - time, lm});
        double r    = max({rr + time, rl - time, rm});
        double xx   = r - l;
        double yy   = u - d;
        chmin(ret, xx * yy);
        if (xx > lastx && yy > lasty)
            break;
        lastx = xx;
        lasty = yy;
    }
    cout << fixed << setprecision(15) << ret << "\n";
    return 0;
}

Measured memory_bytes: 1920
# 53
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, m = LI()
a = SR(n)
b = SR(m)
ans = 'No'
for h in range(n - m + 1):
    for w in range(n - m + 1):
        is_ok = True
        for i in range(m):
            for j in range(m):
                if a[h + i][w + j] != b[i][j]:
                    is_ok = False
                    break
        if is_ok:
            ans = 'Yes'
            break
print(ans)


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

typedef long long int int64;

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

void msort(int *a,int n,int *tmp){
  if(n<=1) return;
  int m=n/2;
  msort(a,m,tmp);
  msort(a+m,n-m,tmp);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n) tmp[k++]=a[j++];
  for(i=0;i<n;i++) a[i]=tmp[i];
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int *b=(int *)malloc(sizeof(int)*n);
  int *tmp=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) b[i]=a[i];
  msort(b,n,tmp);
  int l=b[n/2-1];
  int r=b[n/2];
  if(l==r){
    for(i=0;i<n;i++) printf("%d\n",l);
  } else {
    for(i=0;i<n;i++){
      printf("%d\n",a[i]<=l?r:l);
    }
  }
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 4480
N,Q = [int(w) for w in input().split()]
i = 0
x = []
y = []
count = 0
while i < N:
    a,b = [int(w) for w in input().split()]
    x.append(a)
    y.append(b)
    i +=1
for i in range(N):
    m = (x[i]**2 + y[i]**2)**(1/2)
    if  m <= Q:
        count += 1
    else:
        count += 0
print(count)

Measured memory_bytes: 24888
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e15;
const int inf = 1e9;
const int nmax = 2e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


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

    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int ds = abs(a-b);
    int dv = v-w;
    if(ds <= 1LL * dv * t) cout<<"YES\n";
    else cout<<"NO\n";

}
/*
*/


Measured memory_bytes: 3636