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

using namespace std;

typedef pair<int,int> pii;
#define mp(x,y) (make_pair(x,y))

int main()
{
    int n;

    while(cin>>n)
    {
        vector<int> h(n),l(n),r(n);
        for(int i=0;i<n;i++)
        {
            cin>>h[i];
        }
        stack<pii> st;
        for(int i=0;i<n;i++)
        {
            while(!st.empty()&&st.top().first>=h[i])
            {
                st.pop();
            }
            if(!st.empty())
            {
                l[i]=st.top().second+1;
            }else
            {
                l[i]=0;
            }
            st.push(mp(h[i],i));
        }
        while(!st.empty())
        {
            st.pop();
        }
        for(int i=n-1;i>=0;i--)
        {
            while(!st.empty()&&st.top().first>=h[i])
            {
                st.pop();
            }
            if(!st.empty())
            {
                r[i]=st.top().second;
            }else
            {
                r[i]=n;
            }
            st.push(mp(h[i],i));
        }
        long long area=0;
        for(int i=0;i<n;i++)
        {
            area=max(area,1LL*h[i]*(r[i]-l[i]));
        }
        cout<<area<<endl;
    }

    return 0;
}



Measured memory_bytes: 4920
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

const ll mod = 2019;

int main() {
    ll L, R;
    cin >> L >> R;

    bool mod0exists = ((L + mod - 1) / mod) <= ((R) / mod);
    if (mod0exists) {
        write(0);
    }
    else {
        ll ans = mod;
        ll l = L % mod, r = R % mod;
        rep(i, l, r) rep(j, i + 1, r + 1) {
            ans = min(ans, i * j % mod);
        }

        write(ans);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
using namespace std;
typedef long long ll;

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, dp[1 << 21];
bool a[21][21];

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

    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];

    dp[0] = 1;
    FOR(S, 1, 1 << n) {
        int i = __builtin_popcount(S);
        rep(j, n) if(((S >> j) & 1) == 1 && a[i - 1][j] == 1) dp[S] =
            (dp[S] + dp[S ^ (1 << j)]) % mod;
    }

    cout << dp[(1 << n) - 1] << endl;

    return 0;
}

Measured memory_bytes: 8448
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

namespace str{
    vector<ll> Manacher(const string &s){
        vector<ll> ret(s.size(),0);
        int j=0;
        for(int i=0;i<s.size();){
            while(i>=j && i+j<s.size() && s[i-j]==s[i+j]){j++;}
            ret[i]=j;
            int k=1;
            while(k<j && ret[i-k]+k<j){ret[i+k]=ret[i-k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    vector<ll> Z_Algorithm(const string &s){
        vector<ll> ret(s.size(),0);
        ret[0]=s.size();
        int j=0;
        for(int i=1;i<s.size();){
            while(i+j<s.size() && s[j]==s[i+j]){j++;}
            ret[i]=j;
            if(j==0){i++; continue;}
            int k=1;
            while(k+ret[k]<j){ret[i+k]=ret[k]; k++;}
            i+=k; j-=k;
        }
        return ret;
    }
    
    vector<ll> MP(const string &s){
        vector<ll> ret(s.size()+1,-1);
        ll j=-1;
        for(int i=0;i<s.size();i++){
            while(j>=0 && s[i]!=s[j]){j=ret[j];}
            j++;
            ret[i+1]=j;
        }
        return ret;
    }
};


using namespace str;


bool judge(string &s,ll t){
    if(s.size()%t!=0){return false;}
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[i%t]){return false;}
    }
    return true;
}





int main(){
    string s;
    cin>>s;
    if(judge(s,1)){cout<<s.size()<<endl<<1<<endl; return 0;}
    bool j=false;
    for(ll i=2;i<s.size();i++){
        if(judge(s,i)){j=true;}
    }
    if(!j){cout<<1<<endl<<1<<endl; return 0;}
    vector<ll> ret=MP(s);
    vector<bool> judge(s.size()+1,true);
    judge[0]=false;
    for(int i=1;i<s.size();i++){
        if(i<=ret[i]*2 && i%(i-ret[i])==0){judge[i]=false;}
    }
    reverse(s.begin(),s.end());
    reverse(judge.begin(),judge.end());
    ret=MP(s);
    judge[0]=false;
    for(int i=1;i<s.size();i++){
        if(i<=ret[i]*2 && i%(i-ret[i])==0){judge[i]=false;}
    }
    ll count=0;
    for(int i=0;i<=s.size();i++){
        if(judge[i]){count++;}
    }
    cout<<2<<endl<<count<<endl;
    
    
    return 0;
}


Measured memory_bytes: 8708
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
l = Counter(a)
all_xor = 0
if N % 3 != 0:
    if l[0] != N:
        print("No")
        exit()
    else:
        print("Yes")
        exit()
for _l in l.keys():
    if l[_l] == N // 3:
        continue
    if _l == 0:
        if l[0] == N:
            print("Yes")
            exit()
        if l[0] != N // 3 or len(l) != 2:
            print("No")
            exit()
    if l[_l] == (2 * N) // 3 and l[0] == N // 3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
for i in range(N):
    all_xor = a[i] ^ all_xor
if all_xor == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 94652
n=int(input())
a_ls=list(map(int,input().split()))
b_ls=list(map(int,input().split()))
ans=0
for i in range(n):
    first_monster=a_ls[i]
    second_monster=a_ls[i+1]
    beats=b_ls[i]
    if first_monster>=beats:
        a_ls[i]=first_monster-beats
        ans+=beats
    elif first_monster+second_monster<beats:
        a_ls[i],a_ls[i+1]=0,0
        ans+=first_monster+second_monster
    else:
        rest=beats-first_monster
        a_ls[i]=0
        a_ls[i+1]-=rest
        ans+=beats
print(ans)

Measured memory_bytes: 82020
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    
    int ok = 0;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if(a == b) {
            ok++;
            if(ok == 3) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            ok = 0;
        }
    }

    cout << "No" << endl;    

    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    
    if(n == 1)
    {
        printf("Hello World\n");
    }
    else if(n == 2)
    {
        int A, B;
        scanf("%d %d", &A, &B);
        printf("%d\n", A + B);
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Double D = sc.nextDouble();
        Double T = sc.nextDouble();
        Double S = sc.nextDouble();
        
        if (D/S <= T){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 37288
def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    num = list(range(0, 102))

    ans = [0] * len(num)
    inf = 1000
    for i, n in enumerate(num):
        if n in p:
            ans[i] = inf
        else:
            ans[i] = abs(n-X)

    print(ans.index(min(ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	vector<string> d(7);
	d[0] = "SUN"; d[1] = "MON"; d[2] = "TUE"; d[3] = "WED"; d[4] = "THU";
	d[5] = "FRI"; d[6] = "SAT";
	rep(i,7){
		if(s==d[i]) cout << 7-i;
	}


  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
int a[10];
int main(){
	for(int i=0;i<10;i++)scanf("%i",&a[i]);
	std::sort(a,a+10);
	printf("%i\n%i\n%i\n",a[9],a[8],a[7]);
	return 0; 
}


Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
 long long mod =1000000007;
int main()
{

    long long int n;
    cin>>n;
    vector<long long int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<long long int> suff(n);
    suff[n-1]=arr[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suff[i]=(arr[i]+suff[i+1])%mod;
    }
    long long int ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans+=(arr[i]*suff[i+1])%mod;
    }
    cout<<(ans+mod)%mod<<endl;
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll w[1000001];
    fill(w,w+1000001,0);
    ll gy[1000001];
    rep(i,1,1000001)gy[i]=gyaku(i,mod2);
    rep(i,1,1000001){
        (w[i]+=gy[i])%=mod2;
        for(int j=2*i;j<=1000000;j+=i){
            (w[j]+=-w[i]+mod2)%=mod2;
        }
    }
    ll ans=0;
    ll cnt[1000001];
    fill(cnt,cnt+1000001,0);
    rep(i,0,n){
        cnt[a[i]]++;
    }
    rep(i,1,1000001){
        ll ni=0,wa=0;
        for(int j=i;j<=1000000;j+=i){
            (wa+=cnt[j]*j)%=mod2;
            (ni+=cnt[j]*j*j)%=mod2;
        }
        wa*=wa;
        wa%=mod2;
        wa+=-ni+mod2;
        wa%=mod2;
        wa*=gy[2];
        wa%=mod2;
        wa*=w[i];
        (ans+=wa%mod2)%=mod2;
    }
    cout<<ans<<endl;
}








Measured memory_bytes: 25216
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { r, d, l, u };
int dx[] = { 0, 1, 0,-1 };
int dy[] = { 1, 0,-1, 0 };

//enum diR { d, r, u, l , dr, ur, dl, ul };
int dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D matrix to 1D array. (Zero-indexed)
int ord(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D matrix . (One-indexed)
ii rord(int n, int nCol) {
	int r = n%nCol, c = n / nCol;
	if (n%nCol == 0) c--, r = nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

ll nCr(ll n, ll r) {
	if (n < r)
		return 0;
	if (r == 0)
		return 1;
	return n * nCr(n - 1, r - 1) / r;
}

const int N = 11000;
int dp[N][110][2][2];
int D;
string l,r;
ll solve(int idx, int rem, int ls, int rs) {
	if (idx >= sz(r)) return rem == 0;
	int& ret = dp[idx][rem][ls][rs];
	if (~ret) return ret;
	ret = 0;
	lop(i, 10) {
		if (!ls && i < l[idx] - '0') continue;
		if (!rs && i > r[idx] - '0') continue;
		ret = (ret + solve(idx + 1, (rem+i)%D, ls || i > l[idx] - '0', rs || i < r[idx]-'0') % MOD) % MOD;
	}
	return ret;
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r >> D;
	lop(i, sz(r) - 1) l += '0';
	l += '1';
	mem(dp, -1);
	cout << solve(0, 0, 0,0) << endl;


	return 0;
}


Measured memory_bytes: 20352
import java.util.Arrays;
import java.util.Scanner;

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

		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		
		System.out.println(arr[n - 1] - arr[0]);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>

using namespace std;

int main() {
	int a, b, n;
	int ans = 1;
	int count = 0;


	cin >> a >> b;

	a--;

	while (ans < b) {
		ans += a;
		count++;
	}


	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void SS()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
const int N = 1e5 + 5;
vector <int> graph[N];
int u, v;
int n;
int dp[N][2];
int add(lli a, lli b) {
	return ((a % mod) + (b % mod)) % mod;
}
int mul(lli a, lli b) {
	return ((a % mod) * (b % mod)) % mod;
}
void dfs(int node, int par) {
	dp[node][1] = 1;
	dp[node][0] = 1;
	for (lli i : graph[node]) {
		if (i == par) continue;
		dfs(i, node);
		dp[node][0] = mul(dp[node][0], add(dp[i][1], dp[i][0]));
		dp[node][1] = mul(dp[node][1], dp[i][0]);
	}

}
void solve() {
	cin >> n;
	for (int i = 0, u, v; i < n - 1; i++) {
		cin >> u >> v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(1, 0);
	cout << add(dp[1][0], dp[1][1]) << endl;
}
int main()
{
	SS();
	solve();
	return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
#include<math.h>
#include <string.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;





using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  IOS;


  int a;

  cin >> a;

  double pie = 3.14159265;

  double ans = 2 * a * pie;

  cout << setprecision(9) << ans;



  return 0;
}





Measured memory_bytes: 3780
import sys
import bisect
import math
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from operator import itemgetter
inf=10**20
v,e=map(int,readline().split())
#print(v,e)
d=[[inf for j in range(v)] for i in range(v)]
for i in range(v):
    d[i][i]=0
for i in range(e):
    a,b,c=map(int,readline().split())
    d[a][b]=c

for k in range(v):
    for i in range(v):
        for j in range(v):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ng=0
for i in range(v):
    if d[i][i]<0:
        ng=1
        break
#print(d[2])

if ng:
    print("NEGATIVE CYCLE")
else:
    for i in range(v):
        ans=""
        for j in range(v):
            if d[i][j]>2e9:
                ans+="INF"+" "
            else:
                ans+=str(d[i][j])+" "
        print(ans.rstrip())
            



Measured memory_bytes: 6300
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> A[i]; sum+=A[i];
  }
  int n=0;
  for(int i=0;i<N;i++){
    if(sum<=A[i]*4*M) ++n;
  }
  if(M<=n) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int n;
const int maxn = 1e5 + 5;

int dp[maxn];
int h[maxn];

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%d", &h[i]);
        dp[i] = 1e9 + 7;
    }
    dp[1] = 0;
    for(int i = 2;i <= n;i++){
        if(i - 2 >= 1){
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
a=lnii()

ok=max(a)
ng=0

while ok-ng>1:
  m=(ok+ng)//2

  num=0
  for i in a:
    if i%m!=0:
      num+=(i//m)
    else:
      num+=(i//m)-1

  if num<=k:
    ok=m
  else:
    ng=m

print(ok)

Measured memory_bytes: 30936
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A
// Heuristic Search - 8 Queens Problem
// status:

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int N = 8;
const int FREE = -1;
const int NOT_FREE = 1;


// dpos: 左下, dneg: 右下
// row[y], col[x], dpos[y + x], dneg[y - x + (N - 1)]
int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool board[N][N];

void init() {
    for (int i = 0; i < N; ++i) row[i] = FREE, col[i] = FREE;
    for (int i = 0; i < 2 * N - 1; ++i) dpos[i] = FREE, dneg[i] = FREE;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            board[i][j] = false;
        }
    }
}

void print_board() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            // 入力に対応するケース以外の解の場合はreturn
            if (board[i][j] && row[i] != j) return;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {
        print_board();
        return;
    }

    for (int j = 0; j < N; ++j) {
        // (i, j)が他のQに襲撃されているので無視
        if (col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + (N - 1)] == NOT_FREE) continue;

        // (i, j)にQを配置
        row[i] = j, col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = NOT_FREE;

        // 次の行を試す
        recursive(i + 1);

        // (i, j)に配置されているQを取り除く
        row[i] = col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = FREE;
    }

    // fail
}


int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(2
2 2
5 3
)";
    stringstream stream(program_input_str);
#endif
    init();

    int n;
    stream >> n;

    int y, x;
    for (int i = 0; i < n; ++i) {
        stream >> y >> x;
        board[y][x] = true;
    }

    recursive(0);
    return 0;
}


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

int main(){
  ll n,d,ans=0;
  cin>>n;
  long double a[n];
  vector<ll> b(n),c(n,(ll)1e9);
  map<tuple<ll,ll,ll,ll>,ll> mas; 
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)b[i]=(a[i]+(long double)0.00000000001)*(ll)1e9;
  for(int i=0;i<n;i++){
    int e=0,f=0,g=0,h=0;
    d=gcd(b[i],c[i]);
    b[i]/=d;
    c[i]/=d;
    while(b[i]%2==0){
      b[i]/=2;
      e++;
    }
    e=min(e,9);
    while(b[i]%5==0){
      b[i]/=5;
      f++;
    }
    f=min(f,9);
    while(c[i]%2==0){
      c[i]/=2;
      g++;
    }
    while(c[i]%5==0){
      c[i]/=5;
      h++;
    }
    mas[{e,f,g,h}]++;
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        for(int l=0;l<10;l++){
          ll tmpans=mas[{k,l,i,j}];
          for(int v=i;v<10;v++){
            for(int w=j;w<10;w++){
              for(int x=0;x<=k;x++){
                for(int y=0;y<=l;y++){
                  ans+=tmpans*mas[{v,w,x,y}];
                }
              }
            }
          }
        }
      }
    }
  }
  for(int k=0;k<10;k++){
    for(int l=0;l<10;l++){
      ans-=mas[{k,l,0,0}];
    }
  }
  cout<<ans/2<<endl;
}


Measured memory_bytes: 10404
n, k = gets.strip.split.map(&:to_i)
xs = gets.strip.split.map(&:to_i)

h = Hash.new
h.default = 0
xs.each {|x| h[x] += 1}

ys = h.to_a.sort {|a,b| a[1] <=> b[1]}
z = ys[0...ys.length-k].map{|x| x[1]}.inject(:+)
z = z == nil ? 0 : z
puts z


Measured memory_bytes: 42224
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
int to[100000];
int from[100000];

int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int N;
	int ans = 0;

	cin >> N;
	rep(i, N) cin >> A[i];

	to[0] = A[0];
	from[N - 1] = A[N - 1];

	rep(i, N - 1) {
		to[i + 1] = gcd(to[i], A[i + 1]);
		from[N - 2 - i] = gcd(from[N - 1 - i], A[N - 2 - i]);
	}

	ans = max(from[1], to[N - 2]);

	repc(i, 1, N - 2) {
		ans = max(ans, gcd(to[i - 1], from[i + 1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
main :: IO()
main = do
  ss <- getLine :: IO String
  putStrLn $ if solve ss then "Yes" else "No"

solve :: String -> Bool
solve ss = mod (read ss) sn == 0
  where
    sn = f ss 0
    f :: String -> Int -> Int
    f [] n = n
    f (s:ss) n = f ss (read [s] + n)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    ll mod = 1000000007;
    rep(i, n){
        ans *= i + 1;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N,K,Q; cin >> N >> K >> Q;
    vector<int> member(100010, 0);
    vector<int> point(100010, 0);

    rep(i,Q){
        int a; cin >> a;

        if(a==1){
            member[2]-=1;
        }else if(a==N){
            member[1]-=1;
            member[N]+=1;
        }else{
            member[1]-=1;
            member[a]+=1;
            member[a+1]-=1;
        }

    }

    for(int i=1; i<= N+1; i++){
        member[i]+=member[i-1];
    }

    for(int i=1; i<=N; i++){
        if(member[i]+K>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  int ispoor=0;
  if(a==b && b!=c)
    ispoor=1;
  if(b==c && c!=a)
    ispoor=1;
  if(c==a && a!=b)
    ispoor=1;
  
  if(ispoor){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
} 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n;
    cin >> n;

    ll l = 0;
    ll r = 1001001001001001;

    while(l + 1 < r){
        ll m = (l + r) / 2;
        ll mm = m;
        int c = 0;
        while(mm > 0){
            c++;
            mm /= 10;
        }
        mm = m;
        int f[c] = {};
        drep(i,c){
            f[i] = mm % 10;
            mm /= 10;
        }
        ll dp[c][10];
        int flag = 1;
        rep(i,c)rep(j,10)dp[i][j] = 0;
        rep(i,c){
            if(i == 0){
                srep(j,1,10){
                    if(j < f[i])dp[i][j] = 1;
                }
            }else{
                srep(j,1,10)dp[i][j] = 1;
                if(flag == 1){
                    if(f[i] == f[i-1]){
                        if(f[i-1] > 0)dp[i][f[i-1]-1]++;
                    }else if(f[i] == f[i-1] + 1){
                        dp[i][f[i-1]]++;
                        if(f[i-1] > 0)dp[i][f[i-1]-1]++;
                    }else if(f[i] > f[i-1] + 1){
                        dp[i][f[i-1]+1]++;
                        dp[i][f[i-1]]++;
                        if(f[i-1] > 0)dp[i][f[i-1]-1]++;
                    }
                }
                if(abs(f[i] - f[i-1]) > 1)flag = 0;
                rep(j,10){
                    if(j == 0)dp[i][j] += dp[i-1][0] + dp[i-1][1];
                    else if(j == 9)dp[i][j] += dp[i-1][8] + dp[i-1][9];
                    else dp[i][j] += dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1];
                }
            }
        }
        ll cnt = 0;
        rep(i,10){
            cnt += dp[c-1][i];
        }
        cnt += flag;

        // cout << m << ' ' << cnt << endl;

        if(cnt >= n)r = m;
        else l = m;
    }

    cout << r << endl;
    return 0;
}
 
 


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

int main(){
	int a, c;
	char b;
	
	while(true){
		cin >> a >> b >> c;
		
		if(b == '?') break;

		if(b == '+') cout << a + c << endl;
		else if(b == '-') cout << a - c << endl;
		else if(b == '*') cout << a * c << endl;
		else cout << a / c << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main(){
    int w,n;
    int i,j;
    char c;
    cin >> w;
    cin >> n;
    vector<pair<int,int> > yokos(n+1);
    vector<int> result(w);
    for(i=0;i<n;++i){
        cin >> yokos[i].first >> c >> yokos[i].second;
    }
    for(i=1;i<=w;++i){
        int current = i;
        for(j=0;j<n;++j){
            if(yokos[j].first == current)
                current = yokos[j].second;
            else if(yokos[j].second == current)
                current = yokos[j].first;
        }
        result[current-1] = i;
    }
    for(i=0;i<w;++i){
        cout << result[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
import sys
def p(s):
  sys.stderr.write(str(s)+"\n")

n = int(input())
a = [int(i) for i in input().split()]

ans=1000000000

for i in a:
  p(i)
  count=0
  while i%2==0:
    count+=1
    if count>ans:
      break
    i /= 2
    p("i="+str(i))
  
  ans = min(ans, count)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define NMAX 101
#define WMAX 100001

long long v[NMAX], w[NMAX];
long long N, W, sum;

using namespace std;

int main()
{
    cin>>N>>W;
    for(int i = 1 ; i <= N ; i++){
        cin>>w[i]>>v[i];
        sum += v[i];
    }

    long long cost[N + 1][sum + 1];
    for(int i = 0 ; i <= N ; i++)
            for(int j = 0 ; j <= sum ; j++)
                cost[i][j] = W + 1;
    cost[0][0] = 0;

    for(int i = 1 ; i <= N ; i++){
        for(int j = 0 ; j <= sum ; j++){
            cost[i][j] = cost[i - 1][j];
            if(j >= v[i])
                cost[i][j] = min(cost[i][j], cost[i - 1][j - v[i]] + w[i]);
        }
    }

    for(int i = sum ; i >= 0 ; i--)
        if(cost[N][i] <= W)
        {
            cout << i;
            return 0;
        }
    cout<<0;
    return 0;
}


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

int main(){
  long long X;
  cin >> X;
  for(long long i=-200;i<201;i++){
    for(long long j=-200;j<201;j++){
      if(i*i*i*i*i-j*j*j*j*j==X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}
  

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



int main(void){
    int n,l;
    cin >> n >> l;
    int ap[n+1];
    int sum = 0;
    for(int i=1;i<=n;i++){
        ap[i] = l+i-1;
        sum += ap[i];
    }
    int min = 10000;
    for(int i=1;i<=n;i++){
        if(abs(ap[i]) < abs(min)){
            min = ap[i];
        }
    }
    sum = sum-min;
    
    cout << sum << endl;
    
    return 0;
}


















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

using namespace std;
typedef pair<int,int> P;


int times[10010][2];
int train[10010];

int main(){
		int n;
		while(true){
				vector<pair<int,int> > times;
				cin >> n;
				if(n == 0)break;
				for(int i = 0;i < n;i++){
						int a1,a2,a3,b1,b2,b3;
						scanf("%d:%d:%d %d:%d:%d",&a1,&a2,&a3,&b1,&b2,&b3);
						int a = a3 + a2*100 + a1*10000,b = b3 + b2*100 + b1*10000;
						times.push_back(P(b,a));
				}
				sort(times.begin(),times.end());
				vector<int> train;
				train.push_back(0);
				for(int i = 0;i < n;i++){
						int ban=-1,mintime = 1000000;
						for(int j = 0;j < train.size();j++){
								int diff = times[i].second - train[j];
								if(diff >= 0 && diff < mintime){
										mintime = diff;
										ban = j;
								}
						}
						if(ban == -1){
								train.push_back(times[i].first);
						}else{
								train[ban] = times[i].first;
						}
				}
				cout << train.size() << endl;
		}
}




Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define mod 1000000007	 


int main(){
		
	ll n;
	cin>>n;
	ll ar[n];
	for(int i=0;i<n;i++){
	 	cin>>ar[i];
	}
	
	ll ans = 0;	
	for(int i=0;i<60;i++){
		ll num = 1ll<<i;
		ll ones = 0,zeroes = 0;
		for(int j=0;j<n;j++){
			if(num&ar[j]){
				ones++;
			}else{
				zeroes++;
			}	
		}
		ll curr = ((ones%mod)*(zeroes%mod))%mod;
		curr = ((curr%mod)*(num%mod))%mod;
		ans = ((curr%mod)+(ans%mod))%mod;	
	}
	cout<<ans%mod;

	
	
	return 0;
}


Measured memory_bytes: 5956
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

ll sum_d (ll n) {
	ll ret = 0;
	while (n!= 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

int main () {
	int K; cin >> K;
	
	set < ll > cnd;
	cnd.insert(1);
	cnd.insert(2);
	cnd.insert(3);
	cnd.insert(4);
	cnd.insert(5);
	cnd.insert(6);
	cnd.insert(7);
	cnd.insert(8);
	cnd.insert(9);
	cnd.insert(19);
	cnd.insert(29);
	cnd.insert(39);
	cnd.insert(49);
	cnd.insert(59);
	cnd.insert(69);
	cnd.insert(79);
	cnd.insert(89);
	cnd.insert(99);
	cnd.insert(199);
	cnd.insert(299);
	cnd.insert(399);
	cnd.insert(499);
	cnd.insert(599);
	cnd.insert(699);
	cnd.insert(799);
	cnd.insert(899);
	cnd.insert(999);

	ll base = 9;
	ll power = 10;
	while (base < 1e13) {
		for (ll i = 1; i <= 999; i++) {
			ll cnd_t = power * i + base;
			cnd.insert(cnd_t);
		}
		power *= 10;
		base *= 10;
		base += 9;
	}

	vector < ll > ans;
	vector < ll > v_cnd;

	for (auto x : cnd) v_cnd.push_back(x);

	for (int i = 0; i < v_cnd.size(); i++) {
		for (int j = i + 1; j < v_cnd.size(); j++) {
			ll a = v_cnd[i];
			ll b = v_cnd[j];
			if (sum_d(b) * a > sum_d(a) * b) {
				goto nxt;
			}
		}
		ans.push_back(v_cnd[i]);
		nxt:;
	}

	REP(i,K) {
		cout << ans[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 1024
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

vi a[N];
ll int vis[N];

void dfs(ll node)
{
	vis[node]=1;
	for(auto i:a[node])
	if(!vis[i])
	dfs(i);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m;
		cin>>n>>m;
		while(m--)
		{
			ll int x,y,z;
			cin>>x>>y>>z;
			a[x].pb(y);
			a[y].pb(x);
		}
		ll int ncc=0;
		for(ll int i=1;i<=n;i++)
		{
			if(!vis[i])
			{
				ncc++;
				dfs(i);
			}
		}
		cout<<ncc;
	}
	return 0;
}

Measured memory_bytes: 9600
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    int a[200000];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    vector<int> field;
    
    int now=-1;
    for(int i=1;i< n;i++){
        if(((a[i-1]> a[i] && now==0) ||
            (a[i-1]< a[i] && now==1) ||
            (a[i-1]==a[i] && now==2) )&& i!=n-1){
            //??????????????????
        }
        else{
            if(now!=-1)field.pb(now);
            if(a[i-1]> a[i])now=0;
            if(a[i-1]< a[i])now=1;
            if(a[i-1]==a[i])now=2;
        }
    }
    field.pb(now);

    int ans[5]={};
    for(int i=2;i<field.size();i++){
        if(field[i-2]==1 && field[i-1]==2 && field[i]==0 )ans[0]++;
        if(field[i-2]==0 && field[i-1]==2 && field[i]==1 )ans[1]++;
        if((field[i-2]==1 && field[i-1]==2 && field[i]==1 ) || (field[i-2]==0 && field[i-1]==2 && field[i]==0 ))ans[2]++;
    }
    
    for(int i=1;i<field.size();i++){
        if(field[i-1]==1 && field[i]==0 )ans[3]++;
        if(field[i-1]==0 && field[i]==1 )ans[4]++;
    }
    
    
    cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<" "<<ans[4]<<endl;
    
    return 0;
}


Measured memory_bytes: 2072
N, K = map(int, input().split())
S = []
T = []
A = []
for i in range(N):
    x, y = map(int, input().split())
    S.append(x)
    T.append(y)
    A.append([x, y])

S.sort()
T.sort()
ans = float("inf")
for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            for l in range(k+1, N):
                c = 0
                for x, y in A:
                    if S[i] <= x <= S[j]:
                        if T[k] <= y <= T[l]:
                            c += 1
                if c >= K:
                    ans = min(ans, (S[j] - S[i])*(T[l] - T[k]))
print(ans)

Measured memory_bytes: 69344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    vi ans;
    if(a==b){
        for(int i=1;i<a+1;i++){
        if(a%i==0) ans.push_back(i);
        }
    }
    else{
        for(int i=1;i<max({a,b});i++){
        if(a%i==0 && b%i==0) ans.push_back(i);
        }
    }
    sort(rall(ans));
    cout<<ans[k-1]<<endl; 
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (s.at(i) == t.at(j)) chmax(dp.at(i+1).at(j+1), dp.at(i).at(j) + 1);
            chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
            chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
        }
    }
    string res = "";
    int x = n, y = m;
    while (x > 0 && y > 0) {
        if (dp.at(x).at(y) == dp.at(x-1).at(y)) {
            x--;
        } else if (dp.at(x).at(y) == dp.at(x).at(y-1)) {
            y--;
        } else {
            x--; y--;
            res = s.at(x) + res;
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,k,dp[105][105][305],v[105],w[105],ans;
int main()
{
	memset(dp,-120,sizeof(dp));
	cin>>n>>m;
	fz1(i,n)
	{
		cin>>w[i]>>v[i];
	}
	dp[0][0][0]=0;
	for (i=0;i<n;i++)
	{
		for (j=0;j<=i;j++)
		{
			for (k=0;k<=300;k++)
			{
				if (1ll*j*w[1]+k>1ll*m) continue;
				dp[i+1][j+1][k+w[i+1]-w[1]]=max(dp[i+1][j+1][k+w[i+1]-w[1]],dp[i][j][k]+v[i+1]);
				dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
			}
		}
	}
	for (i=0;i<=n;i++)
	{
		for (j=0;j<=300;j++)
		{
			if (1ll*i*w[1]+j>1ll*m) continue;
			ans=max(ans,dp[n][i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13440
#include<cstdio>
#include<algorithm>

int main(){
	int n;
	int arr[100100];
	int cnt[100100];
	for(int j = 0; j < 100000; j++)
		cnt[j] = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) {
		scanf("%d",&arr[i]);
		cnt[arr[i]]++;
		cnt[arr[i]-1]++;
		cnt[arr[i]+1]++;
	}
	std::sort(&cnt[0],&cnt[100000]);
	printf("%d\n",cnt[99999]);
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<bool> issosu(300001,false);
  for(int i=0;i<=43000;i++){
    if(7*i+1<=300000) issosu[7*i+1]=true;
    if(7*i+6<=300000) issosu[7*i+6]=true;
  }
  issosu[1]=false;
  for(int i=0;i<43000;i++){
    if(issosu[7*i+1]){
      for(int j=2*(7*i+1);j<=300000;j+=7*i+1){
        issosu[j]=false;
      }
    }
    if(issosu[7*i+6]){
      for(int j=2*(7*i+6);j<=300000;j+=7*i+6){
        issosu[j]=false;
      }
    }
  }
  while(1){
    int n;
    cin >> n;
    if(n==1) return 0;
    vector<int> ans(100000);
    int now=0;
    for(int i=0;i<43000;i++){
      if(n%(7*i+1)==0&&issosu[7*i+1]){
        ans[now]=7*i+1;
        now++;
      }
      if(n%(7*i+6)==0&&issosu[7*i+6]){
        ans[now]=7*i+6;
        now++;
      }
    }
    cout << n << ": ";
    for(int i=0;i<now-1;i++) cout << ans[i] << " ";
    cout << ans[now-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3516
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int n;cin>>n;
  string s;cin>>s;
  if(n%2==1) {
    p("No");
  } else {
    if(s.substr(0,n/2)==s.substr(n/2,n/2)) {
      p("Yes");
    } else {
      p("No");
    }
  }
  return 0;
}



Measured memory_bytes: 256