akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

// sigma[i=0 to n-1] floor((a*i+b)/m)
template<typename T>
T sum_of_floor_of_linear(T n,T m,T a,T b){
    T ret=0;
    if(a>=m){
        ret+=(a/m)*n*(n-1)/2;
        a%=m;
    }
    if(b>=m){
        ret+=(b/m)*n;
        b%=m;
    }
    T y=(a*n+b)/m;
    if(y==0)return ret;
    T ax=m*y-b;
    T xn=(ax+a-1)/a;
    ret+=(n-xn)*y;
    ret+=sum_of_floor_of_linear(y,a,m,(a-ax%a)%a);
    return ret;
}



signed main(){
    int q;cin>>q;
    while(q--){
        ll n,m,a,b;cin>>n>>m>>a>>b;
        cout<<sum_of_floor_of_linear(n,m,a,b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
	map<char, int>s1, s2;
	for (auto v : s)s2[v]++;
	int ans = 0;
	rep(i, 0, s.size()) {
		int cnt = 0;
		s1[s[i]]++;
		s2[s[i]]--;
		for (auto p : s1) {
			if (p.second <= 0)continue;
			if (s2[p.first] > 0)++cnt;
		}
		chmax(ans, cnt);
	}
	cout << ans << "\n";

	return 0;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007



    ll mod_pow(ll a,ll b,ll m)
    {
        ll res=1;
        while(b)
        {
            if(b&1)
                res=(res*a)%m;

            a=(a*a)%m;
            b>>=1;
        }
        return res;
    }
    vector<vector<ll>> adj(1000000);
    vector<bool> vis(1000000,false);

    void dfs(ll u)
    {
        vis[u]=true;
        for(auto x:adj[u])
            if(!vis[x])
                dfs(x);
    }

void solve()
{
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<k;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans-1;
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    ll q;
    q=1;
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 31168
#include  <stdio.h>
#include <stdlib.h>
#include <string.h>

char s[100001] = { 0 };

int sort(const void *a, const void *b) {
	return strcmp((char*)a, (char*)b);
}

int main(void) {
	int len, cnt = 'a', i = 0;

	scanf("%s", &s);
	len = strlen(s);
	qsort(s, len, sizeof(char), sort);

	while (cnt <= 'z') {
		if (s[i] == cnt) {
			while (s[i] == s[i + 1]) i++;
			i++;
			cnt++;
		}
		else {
			printf("%c\n", cnt);
			return 0;
		}
	}

	printf("None\n");

	return 0;
}

Measured memory_bytes: 380
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> arr(n);
    ll sum = 0;
    for (auto &x : arr)
        cin >> x, sum += x;

    sort(arr.begin(), arr.end(), std::greater<int>());
    ll min = ceil(sum/(double)(4*m));

    if (arr[m-1] < min)
        cout << "No" << "\n";
    else
        cout << "Yes" << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
vector<vector<int>> edge;
vector<bool> visit;

void dfs(int n){
    if(visit[n]) return;
    visit[n]=true;
    for(int i=0;i<edge[n].size();i++){
        dfs(edge[n][i]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    edge.resize(N+M);
    REP(i,N){
        int k;cin>>k;
        edge[i].resize(k);
        REP(j,k){
            int l;cin>>l;
            l+=N-1;
            edge[i][j]=l;
            edge[l].push_back(i);
        }
    }
    visit.resize(N+M);
    dfs(0);
    REP(i,N) if(!visit[i]){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}

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

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

int main(){
	int k,x;
	cin >> k >> x;
	cout << (k*500 >= x ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 1100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
const int r2 = 21; 
struct th {
	vector<vi> s;
	int sum;
	void init(int k) {
		sum = 0;
		s.resize(k + 1);
		for (int i = 0; i <= k; i++) {
			s[i].resize(1 << i);
			for (int j = 0; j < s[i].size(); j++)
				s[i][j] = 0;
		}
	}
	void ch(pi pl, int num) {
		s[pl.fi][pl.se] += num, sum += num;
	}
}nr[1 << r2], sr[1 << r2];

vector<pi> nx[r2][2];
char inp[1 << r2];
int main() {
	for (int i = 0; i < r2; i++)
		for (int k = 0; k < 2; k++) {
			nx[i][k].resize(1 << i);
			for (int j = 0; j < (1 << i); j++) {
				if (i == 0) nx[i][k][j] = mp(-1, 0);
				else {
					int rr = j & (1 << (i - 1));
					if (rr && k) nx[i][k][j] = mp(i - 1, j ^ (1 << (i - 1)));
					else if (rr == 0 && k == 0) nx[i][k][j] = mp(i - 1, j);
					else nx[i][k][j] = nx[i - 1][k][j % (1 << (i - 1))];
				}
			}
		}
	int n, k;
	cin >> n >> k;
	int nl = 0, res = 0;
	nr[0].init(n);
	for (int i = 0; i <= n; i++) {
		scanf("%s", inp);
		for (int j = 0; j < (1 << i); j++)
			if (inp[j] == '1') nr[0].ch(mp(i, j), 1);
	}
	for (int tt = 1; tt <= n; tt++) {
	//	cout << "!!!" << tt << endl;
		for (int m = 0; m < (1 << tt); m++)
			sr[m].init(n - tt);
		for (int m = 0; m < (1 << (tt - 1)); m++)
			for (int s = 0; s <= n - tt + 1; s++)
				for (int q = 0; q < nr[m].s[s].size(); q++)
					for (int r = 0; r < 2; r++)
						if (!nr[m].s[s][q]) continue;
						else {
							pi ed = nx[s][r][q];
							if (ed.fi != -1)
								sr[m * 2 + r].ch(ed, nr[m].s[s][q]);
						}
		for (int m = 0; m < (1 << tt); m++)
			if (sr[m].sum >= k) {
				nl = tt;
				res = m;
				break;
			}
		for (int m = 0; m < (1 << tt); m++)
			nr[m] = sr[m];
	}
	vi otp(nl);
	for (int i = 0; i < nl; i++)
		otp[i] = res % 2, res /= 2;
	for (int i = nl - 1; i >= 0; i--)
		printf("%d", otp[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 355780
#include <bits/stdc++.h>
#define Rint register int
#define C(n,m) (n<m?0:1ll*fac[n]*invfac[n-m]%mod*invfac[m]%mod)
#define slope(i,j,k) (b[k].a-b[i].a)*(j-i)>=(b[j].a-b[i].a)*(k-i)
using namespace std;
int T,n,m,p,k,st[200010],t=0;
long long c[200010];
struct node{
	long long a;
	int b;
}a[200010],b[200010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i].a);
	for(int i=1;i<=n;i++) scanf("%d",&a[i].b);
	long long tmp=-1,id=0;
	for(int i=1;i<=n;i++) if(a[i].a>tmp) tmp=a[i].a,id=i;
	for(int i=id;i<=n;i++) b[i-id+1]=a[i];
	for(int i=1;i<id;i++) b[i+n-id+1]=a[i];
	b[++n]=b[1]; 
	c[1]=c[2]=0;
	for(int i=3;i<=n;i++) c[i]=2*(b[i-1].b+c[i-1])-c[i-2];
	for(int i=1;i<=n;i++) b[i].a-=c[i];
	for(int i=1;i<=n;i++){
		while(t>=2&&slope(st[t-1],st[t],i)) t--;
		st[++t]=i;
	}
	long long ans=0;
	for(int i=1;i<t;i++) ans+=b[st[i]].a*(st[i+1]-st[i]+1)+b[st[i+1]].a*(st[i+1]-st[i]-1);
	for(int i=1;i<n;i++) ans+=c[i]*2;
	printf("%.12lf\n",ans/(2*n-2.0));
}


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

#define V vector
typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f(i,a) for(int i = 0 ; i < a ; i++)
#define ff first
#define ss second
#define all(x) (x).begin() ,(x).end()

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1



int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
	{
		int n , d;
		int cnt = 0;

		cin >> n >> d;

		rep(i, 0, n)
		{
			ll x , y;
			cin >> x >> y;

			ll z = x * x + y * y;

			double D = sqrt(z);
			//cout << D << "\n";

			if (D <= (double)d )
				cnt++;
		}

		cout << cnt << "\n";
	}

	return 0;
}





Measured memory_bytes: 3600
/* 
 *     author-->@harshrajani460
 *     codeforces round-567
 *
 */
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define el endl
#define M 998244353 
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;
int dp[3003][3003][2],a[3003];
int solve(int l,int r,int f)
{
    if(l>r) return 0;
    if(dp[l][r][f]!=-1) return dp[l][r][f];
    int &ans=dp[l][r][f];
    if(f==0)
    return ans=max(a[l]+solve(l+1,r,f^1),a[r]+solve(l,r-1,f^1));
    else
    return ans=min(-a[l]+solve(l+1,r,0),-a[r]+solve(l,r-1,0));
}
int32_t main() 
{ 
    int n;
   cin>>n;
   FOR(i,1,n+1) cin>>a[i];
  memset(dp,-1,sizeof dp);
   cout<<solve(1,n,0);
   
} 

Measured memory_bytes: 141312
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> A;
void maxH(int i){
    int l = 2*i+1;
    int r = 2*i+2;
    int largest;
    if(l<n&&A[l]>A[i]){
        largest = l;
    }else{
        largest = i;
    }

    if(r<n&&A[r]>A[largest]){
        largest = r;    
    }
    if(largest!=i){
            swap(A[i],A[largest]);
            maxH(largest);
    }
}
void buildM(){
    for(int i=n/2;i>=0;i--){
        maxH(i);
    }
}
int main(){
    cin >> n;
    A.resize(n);
    for(auto &i:A) cin >> i;
    buildM();
    for(auto &i:A) cout << " " << i;
    cout << endl;
}


Measured memory_bytes: 4656
ans' :: Int -> Float -> Float -> Float -> Float -> Int
ans' n r0 w0 c r =
     let n' = fromIntegral n :: Float
     in
        if ( (n' * r + r0) / w0) >= c
        then n
        else ans' (n+1) r0 w0 c r

ans :: [[Float]] -> [Int]
ans ([0,0,0,0]:xs) = []
ans ([r0,w0,c,r]:xs) =
    (ans' 0 r0 w0 c r):(ans xs)

main = do
     c <- getContents
     let i = map (map read) $ map words $　lines c :: [[Float]]
         o = ans i
     mapM_ print o
     


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

int main(){
    int N,ans=0;;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end());
    
    while(A.at(0)>0){
        for(int i=0;i<N;i++){
            if(A.at(i)%2==0){
                A.at(i)/=2;
            }else{
                goto end;
            }
        }
        ans +=1;
    }
end:
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;

const int MXN=3005;

int n;
double p[MXN];
double dp[MXN][MXN];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i)scanf("%lf",p+i);
  dp[n][0]=1;
  for(int i=n-1;i>=0;--i){
    dp[i][0]=dp[i+1][0]*(1-p[i]);
    for(int j=1;j<=n;++j){
      dp[i][j]=p[i]*dp[i+1][j-1]+(1-p[i])*dp[i+1][j];
    }
  }
  double sol=0;
  for(int i=n/2+n%2;i<=n;++i)sol+=dp[0][i];
  printf("%.10lf\n",sol);
}


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

int asc(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main(){
    int N, M, X[100000];
    int i, Y[100000], ans;

    scanf("%d %d", &N, &M);

    if(N>=M){
        printf("0\n");
        return 0;
    }

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

    qsort(X, M, sizeof(int), asc);

    for(i=0; i<M-1; i++){
        Y[i] = X[i+1] - X[i];
    }

    qsort(Y, M-1, sizeof(int), asc);

    ans = X[M-1] - X[0];

    for(i=0; i<N-1; i++){
        ans = ans - Y[M-2-i];
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e8;
const int maxx = 1e6;

int main()
{
	int a, b, ans, ans1, ans2, ans3;
	while(~scanf("%d %d",&a, &b))
	{
		ans1 = ans2 = ans3 = 0;
		ans1 = a + b;
		ans2 = a - b;
		ans3 = a * b;
		ans = max(ans1, max(ans2, ans3));
	 	cout << ans << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
N = int(input())
TNow,ANow = (int(T) for T in input().split())
for TN in range(1,N):
    TNext,ANext = (int(T) for T in input().split())
    Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))
    TNow,ANow = TNext*Magn,ANext*Magn
print(TNow+ANow)

Measured memory_bytes: 9204
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){       
        ModOp.init();
        int n, k; {int[] a = in.ii(); n = a[0]; k = a[1];}
        int max = Math.min(n-1, k);
        long ans = 0;
        for(int i = 0; i <= max; i++){
            ans = (ans + ModOp.com(n, i) * ModOp.com(n-1, i)) % ModOp.MOD;
        }
        out.println(ans);
    }

    static class ModOp {
        final static long MOD = 1_000_000_007;
        final static int MAX = 200_000;
        static long[] fact;
        static long[] factInv;
        static long[] inv;

        static long pow(long a, long b){
            long ret = 1;
            while(b > 0){
                if(b%2 == 1){
                    ret = ret*a%MOD;
                }
                a = a*a%MOD;
                b /= 2;
            }
            return ret;
        }

        static long mul(int s, int e){
            long ret = 1;
            for(int i = s; i <= e; i++){
                ret = ret*i%MOD;
            }
            return ret;
        }

        static long fact(int n){
            return mul(1, n);
        }

        static long nCr(int n, int r){
            return mul(n-r+1, n) * pow(fact(r), MOD-2) % MOD;
        }

        static void init() {
            fact = new long[MAX+1];
            factInv = new long[MAX+1];
            inv = new long[MAX+1];
            fact[0] = fact[1] = factInv[0] = factInv[1] = inv[1] = 1;
            for (int i = 2; i <= MAX; i++){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[(int)(MOD%i)] * (MOD / i) % MOD;
                factInv[i] = factInv[i - 1] * inv[i] % MOD;
            }
        }

        static long com(int n, int k){
            return n < k || n < 0 || k < 0 ? 0 : 
                   fact[n] * (factInv[k] * factInv[n - k] % MOD) % MOD;
        }

    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 27732
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
#define endl cout << "\n"
#define bck \
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v;
    set<int> s;
    int N, K, d, A;
    cin >> N >> K;

    for(int i=1; i<=K; ++i){
    	cin >> d;
    	for(int j=1; j<=d; ++j){
    		cin >> A;
    		s.insert(A);
    	}
    }
    
    int sl = s.size();
    cout << N-sl << "\n";

    bye;
 }
    	
/* 3  2
 2
 1 3
 
 1
 3*/


Measured memory_bytes: 3664
/*
 * author: calgagi
 *         Calvin Gagliano 
 */
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define ar array
#define f first
#define s second
#define dd long double

void solve() {
    int n;
    cin >> n;
    vector<dd> a(n);
    for (dd& x : a) {
        cin >> x;
    }

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

    dd ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= a[i];
        if (ans > 1e18) {
            break;
        }
    }

    cout << fixed << setprecision(0);
    if (ans > 1e18) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }


    return;
}

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    
    int t = 1;
    /* cin >> t; */
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4808
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, M; std::cin >> N >> M;
	std::vector<std::vector<Int>> graph(N);
	std::vector<Int> H(N);
	rep(i, N)std::cin >> H[i];
	rep(i, M) {
		Int A, B; std::cin >> A >> B;
		A--; B--;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}
	Int ans = 0;
	rep(i, N) {
		auto& vec = graph[i];
		Int max = -1;
		rep(j, vec.size()) {
			max = std::max(max, H[vec[j]]);
		}
		if (H[i] > max || max == -1)ans++;
	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 9796
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n, t, min_=1000000001, m=0, c=1,f=1, x, y;
	cin>>n>>t;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		min_=min(min_,a[i]);
		if(a[i]-min_>m) m=a[i]-min_, c=1;
		else if(a[i]-min_==m) c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#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> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll a, b, k;
  cin >> a >> b >> k;

  REP(i, k) {
    if(i%2==0) {
      if(a%2) a--;
      b += a/2;
      a /= 2;
    } else {
      if(b%2) b--;
      a += b/2;
      b /= 2;
    }
  }
  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;   

const int mo = 1e9 + 7;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x
			* x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

const ll ni2 = ksm(2, mo - 2);

const int N = 2e5 + 5;

int n, a[N], d[N];
int cnt[N];
ll b[N], c[N];

int cmp(int x, int y) {
	return a[x] < a[y];
}

ll w[N];

ll sum, ans;
void dg(int x, int y, int u, int v) {
	if(u >= v) return;
	if(x == y) {
		ans = (ans + sum * (v - u + 1) % mo * (v - u) % mo * ni2 % mo * ni2) % mo;
		sort(d + u, d + v + 1);
		return;
	}
	int mi = x + y >> 1, m = u - 1;
	while(m < v && a[d[m + 1]] <= mi) m ++;
	dg(x, mi, u, m); dg(mi + 1, y, m + 1, v);

	w[mi] = 1;
	fd(i, mi - 1, x) w[i] = w[i + 1] * c[i + 1] % mo;
	w[mi + 1] = c[mi + 1];
	fo(i, mi + 2, y) w[i] = w[i - 1] * c[i] % mo;

	int l = u; ll s = 0;
	fo(i, m + 1, v) {
		while(l <= m && d[l] <= d[i]) s = (s + w[a[d[l]]]) % mo, l ++;
		ans = (ans + sum * s % mo * w[a[d[i]]] % mo * ni2) % mo;
	}
	l = m, s = 0;
	fd(i, v, m + 1) {
		while(l >= u && d[l] > d[i]) s = (s + w[a[d[l]]]) % mo, l --;
		ans = (ans + sum * (m - l) - sum * s % mo * w[a[d[i]]] % mo * ni2) % mo;
	}
	sort(d + u, d + v + 1);
}

int main() {
	scanf("%d", &n);
	fo(i, 1, n) {
		scanf("%d", &a[i]);
		if(a[i] > n) a[i] = n;
		cnt[a[i]] ++;
	}
	fd(i, n, 1) cnt[i] += cnt[i + 1];
	sum = 1;
	fo(i, 1, n) {
		b[i] = cnt[i] - n + i;
		sum = sum * max(0ll, b[i]) % mo;
	}
	fo(i, 1, n) {
		c[i] = ksm(b[i], mo - 2) * (b[i] - 1) % mo;
	} 
	fo(i, 1, n) d[i] = i;
	sort(d + 1, d + n + 1, cmp);
	dg(1, n, 1, n);
	ans = (ans % mo + mo) % mo;
	pp("%lld\n", ans);
}


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

int Stime = 0;
vector<int> edges[100];
bool visit[100];
int be[100]; //begin
int en[100]; //end


void dfs(int cur) //curを訪問
{
	//curの訪問時間を記録
	Stime++;
	visit[cur] = true;

	//cout << "visiting " << cur+1 << "  time:" << time << endl;
	be[cur] = Stime;

	for (int i = 0; i < edges[cur].size(); ++i)
	{
		if (!visit[edges[cur][i]])
		{
			dfs(edges[cur][i]);
		}
	}

	Stime++;

	//cout << "finished visiting " << cur+1 << "  time:" << time << endl;
	en[cur] = Stime;

}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 100; ++i)
	{
		visit[i] = false;
	}

	int u,k,v;
	for (int i = 0; i < n; ++i)
	{
		cin >> u >> k;

		for (int j = 0; j < k; ++j)
		{
			cin >> v;
			edges[i].push_back(v-1);
		}
	}

	int temp = 0;
	int flag = true; //未探索のノードがあるかどうか
	while(flag)
	{
		dfs(temp);
		flag = false;
		for (int i = 0; i < n; ++i)
		{
			if (!visit[i])
			{
				temp = i;
				flag = true;
				break;
			}
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cout << i+1 << " " << be[i] << " " << en[i] << endl;
	}
	return 0;
}


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

const int mod = 1000000007;

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

	string ans = "No";
	int cnt = 0;
	rep(i,n) {
		int a, b;
		cin >> a >> b;
		if (a == b) cnt++;
		else cnt = 0;

		if (cnt == 3) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
def prime_factorize(n):
    prime_fact = []
    while n%2 == 0:
        prime_fact.append(2)
        n//=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime_fact.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_fact.append(n)
    return prime_fact

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    prefix_gcd = a[0]
    dp = [0]*(max(a)+1)
    for i in range(n):
        prefix_gcd = math.gcd(prefix_gcd,a[i])

    for i in range(n):
        d = prime_factorize(a[i])
        d = set(d)
        for j in d:
            dp[j]+=1
    pair = True
    for i in range(len(dp)):
        if dp[i] > 1:
            pair = False
    if pair == True and prefix_gcd == 1:
        print("pairwise coprime")
    elif pair == False and prefix_gcd == 1:
        print("setwise coprime")
    else:
        print("not coprime")

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#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--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int a[100000];

int main()
{
	int N, x;
	int sub;
	ll ans = 0;

	cin >> N >> x;
	rep(i, N) cin >> a[i];

	rep(i, N - 1) {
		sub = a[i] + a[i + 1] - x;

		if (sub > 0) {
			if (a[i + 1] >= sub) a[i + 1] -= sub;
			else {
				a[i] -= sub - a[i + 1];
				a[i + 1] = 0;
			}
			ans += sub;
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

  vector<vector<int> > f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  }

  vector<vector<int> > p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) cin >> p[i][j];
  }

  int ans = -2000000000;
  for (int i = 1; i < (1 << 10); i++) {
    int tmp = 0;
    bitset<10> x(i);
    for (int j = 0; j < n; j++) {
      bitset<10> fb(0);
      for (int k = 0; k < 10; k++) {
        if (f[j][k]) fb.set(k);
      }
      fb &= x;
      tmp += p[j][fb.count()];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


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

int n, k, q[1005];

int main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> q[i];
  sort(q, q + n);
  int r = 0;
  for(int i = 0; i < k; i++) r += q[i];
  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
L = input().strip().split(" ")
S = L[0]
T = L[1]

K = ""
for i in range(N): 
    K += S[i]
    K += T[i]

print(K)

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,W;
    int dp[105][305] = {{}};
    Scd2(N,W);
    int w,v;
    int w_min = INF;
    Rep(i,N){
        Scd2(w,v);
        w_min = min(w,w_min);
        w -= w_min;
        for(int ai = i+1; ai >= 0; ai--)
        for(int bi = 300; bi >= 0; bi--){
            dp[ai+1][bi+w] = max( dp[ai+1][bi+w], dp[ai][bi]+v );
        }
    }

    int ans = 0;
    Rep(ai,N+2){
        if( ai*w_min > W ) break;
        Rep(bi,305){
            if( ai*w_min + bi > W ) break;
            ans = max(dp[ai][bi],ans);
        }
    }

    printf ("%d\n", ans);

    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S;

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

  cin >> S;
  bool flag = false;
  if (S.size()%2!=0) {
    cout << "No" << "\n";
    return 0;
  }

  for(int i=0; i < S.size()-1;i+=2) {
    if (S[i]=='h' && S[i+1]=='i') {
      continue;
    } else {
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}

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

int main(void){
	
	int n,m,k,check=0,i,j,x;

	scanf("%d %d %d",&n,&m,&k);
	
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			x=i*m+j*n-2*i*j;
			if(x==k){
				check=1;
			}
		}
	}
	
	if(check==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n,i,p=0,c=0;
  cin>>s;
  n=s.length();
  if(s.at(0)!='A') cout<<"WA"<<endl;
  else{
    for(i=1;i<n;i++){
      if('A'<=s.at(i)&&s.at(i)<='Z'){
        c++;
        if(s.at(i)=='C') p=i+1;
      }
    }
    if(c==1&&3<=p&&p<=n-1) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 3600
S = input()
N = len(S)

ans = 'Yes'
for i in range(N):
    if S[i] != S[N-i-1]:
        ans = 'No'
        #print(1)
    if i < (N-1)/2:
        if S[i] != S[N//2-i-1]:
            ans = 'No'
            #print(2)
    elif i >= N//2+1:
        if S[i] != S[N-i+N//2]:
            ans = 'No'
            #print(3)
print(ans)

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

using namespace std;

using ll = long long;

double calc(int n, int p) {
    return 100.0 * n / p;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, p;
    cin >> x >> p;
    double ans = 0;
    if (x % 2 == 0) {
        ans = calc(x / 2, p);
    } else {
        ans = calc((x-1)/2, p) * p / 100 + calc((x+1)/2,p) * (100-p)/100 + 1;
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

bool comp(pii a, pii b){
	if(a.fi == b.fi) return b.sc < a.sc;
	return a.fi < b.fi;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int res = 1;
	pii ar[m];
	for(int i=0; i<m; i++){
		int x, y;
		cin >> x >> y;
		ar[i] = mp(x, y);
	}
	
	sort(ar, ar+m);

	int l=0, r = n;
	for(int i=0; i<m; i++){
		l = max(l, ar[i].fi);
		r = min(r, ar[i].sc);
		if(l >= r){
			res++;
			l = ar[i].fi;
			r = ar[i].sc;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
fn main() {
    use proconio::input;
    use proconio::marker::Isize1;
    input!(h: usize, w: usize);
    let hi = h as isize;
    let wi = w as isize;
    input!(sx: Isize1, sy: Isize1);
    input!(gx: Isize1, gy: Isize1);
    input!(cells: [proconio::marker::Chars; h]);
    let index_of = |x: isize, y: isize| -> usize { (x + y * hi) as usize };
    let in_maze_p = |x: isize, y: isize| -> bool { 0 <= x && x < hi && 0 <= y && y < wi };
    let wall_p = |x: isize, y: isize| -> bool { cells[x as usize][y as usize] == '#' };

    let mut d = vec![-1; w * h];
    let mut q = std::collections::BinaryHeap::new();
    q.push((0, sx, sy));

    while let Some((cnt, x, y)) = q.pop() {
        let cnt = -cnt;
        if x == gx && y == gy {
            println!("{}", cnt);
            return;
        }
        if d[index_of(x, y)] != -1 {
            continue;
        }
        d[index_of(x, y)] = cnt;

        for (xx, yy) in vec![(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)] {
            if in_maze_p(xx, yy) {
                if !wall_p(xx, yy) {
                    q.push((-cnt, xx, yy));
                }
            }
        }

        for xd in -2..3 {
            for yd in -2..3 {
                let xx = x + xd;
                let yy = y + yd;
                if in_maze_p(xx, yy) {
                    if !wall_p(xx, yy) {
                        q.push((-cnt - 1, xx, yy));
                    }
                }
            }
        }
    }
    println!("{}", -1);
}


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

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: chars,
    }
    for &c in &n {
        if c == '1' {
            print!("9");
        } else if c == '9' {
            print!("1");
        } else {
            print!("{}", c)
        }
    }
    println!("");
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n, 0);
    rep(i, n) cin >> a[i];
    

    int count = 0;
    while(count < k){
        count++;
        vector<int> d(n+1, 0);
        rep(i, n){
            d[max(i-a[i], 0)] += 1;
            d[min(i+a[i], n-1)+1] -= 1;
        }
        rep(i, n) d[i+1] += d[i];
        rep(i, n) a[i] = d[i];
        bool fin = true;
        rep(i, n) if(a[i] < n) { fin = false; break; }
        if(fin) break;
    }
    rep(i, n) outs(a[i]); out("");
}

Measured memory_bytes: 4840
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll n;
ll a[2*1000005];
ll ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]); 
	}
	if(a[0]!=0){
		puts("-1");
		exit(0);
	}
	for(int i=0;i<n-1;i++){
		if(a[i+1]>=a[i]+2){
			puts("-1");
			exit(0);
		}
		if(a[i+1]==a[i]+1)ans++;
		else if(a[i+1]<=a[i])ans+=a[i+1]; 
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]] ~= s[1];
        G[s[1]] ~= s[0];
    }

    int root = -1;
    foreach (i; 0..N) if (G[i].length >= 3) root = i;
    if (root == -1) {
        writeln(1);
        return;
    }

    int dfs(int n, int p) {
        int ret = 0;
        int cnt = 0;
        int children = G[n].length.to!int - (p != -1);
        foreach (m; G[n]) {
            if (m == p) continue;
            int v = dfs(m, n);
            ret += v;
            cnt += v > 0;
        }
        if (cnt < children - 1) ret += children - 1 - cnt;
        return ret;
    }

    dfs(root, -1).writeln;
}

Measured memory_bytes: 13820
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double lod;
const int N=4e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
struct P{ int x,y; inline bool operator < (const P &b) const { return y<b.y; } }p[N];
int x[N],c[N];
int mn[N];
int main()
{
	int x1=gi(),y1=gi(),x2=gi(),y2=gi(),i;
	int n=gi(),t,k,sum=0,s;
	const lod pi=3.14159265358979323846;
	for (i=1;i<=n;i++)
		p[i].x=gi(),p[i].y=gi();
	if (x1>x2) { x1*=-1; x2*=-1; for (i=1;i<=n;i++) p[i].x*=-1; }
	if (y1>y2) { y1*=-1; y2*=-1; for (i=1;i<=n;i++) p[i].y*=-1; }
	for (i=1;i<=n;i++)
		if (p[i].x<x1||x2<p[i].x||p[i].y<y1||y2<p[i].y) p[i--]=p[n--];

	for (i=1;i<=n;i++) x[i]=p[i].x;
	sort(x+1,x+1+n);
	sort(p+1,p+1+n);
	for (i=1;i<=n;++i) mn[i]=0x7fffffff;
	mn[0]=0x80000000;
	sum=0;
	for (i=1;i<=n;++i) {
		k=lower_bound(mn,mn+n+1,p[i].x)-mn;
		mn[k]=p[i].x;
		sum=max(sum,k);
	}
	/*
	for (i=1;i<=n;i++) {
		k=lower_bound(x+1,x+1+n,p[i].x)-x;
		s=0;
		for (t=k;t;t^=t&-t) s=max(s,c[t]);
		sum=max(sum,++s);
		for (t=k;t<=n;t+=t&-t) c[t]=max(c[t],s);
		}*/
	cout << fixed << setprecision(15);
	double ans=100LL*(x2-x1+y2-y1);
	ans=ans-20*sum+5*pi*sum;
 	if (sum==abs(x1-x2)+1||sum==abs(y1-y2)+1)
		ans=ans+5*pi;
	cout<<ans<<endl;
	//printf("%.15lf\n",
	//cout<<100LL*(x2-x1+y2-y1)+(sum==min(y2-y1,x2-x1)+1?-(sum-1)*(20*5-pi)+10*pi-20:-sum*(20-5*pi));//);
	return 0;
}


Measured memory_bytes: 5248
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        //init
        int n = 0, x = 0;

        while(true){
            n = Integer.parseInt(in.next());
            x = Integer.parseInt(in.next());

            if(n == 0)break;

            int cnt = 0;

            for(int i = n; i >= 3; i--){
                for(int j = i - 1; j >= 2; j--){
                    int remainder = x - i - j;
                    if(remainder <= 0)continue;
                    else if(remainder >= j || remainder >= i)break;
                    cnt++;
                }
            }

            System.out.println(cnt);
        }
    }
}


Measured memory_bytes: 26200
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int gcd(int a, int b)
{
   if(a < b){
       swap(a,b);
   } 
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
    int K;
    int ANS;
    ANS =0;
    cin >>K;
    rep2(a,1,K+1){
        rep2(b,1,K+1){
            rep2(c,1,K+1){
                ANS += gcd(a,gcd(b,c));
            }
        }
    }
    cout << ANS<<endl;
}

Measured memory_bytes: 3592
from itertools import combinations
import math

N, D = map(int, input().split())
ans = 0
X = list()
for _ in range(N):
    X.append(list(map(int, input().split())))

for a, b in combinations(X, 2):
    dist = 0.0
    for d in range(D):
        dist += abs(a[d] - b[d])**2
    if math.sqrt(dist).is_integer():
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll z(ll a) {
  if(a > 0) {
    return a;
  } else {
    return -a;
  }
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
int idx = -1;
int main() {
  int N, T, A; cin >> N >> T >> A;
  ll x = 10000000000;
  int idx;
  for(int i = 0; i < N; i++) {
    ll H; cin >> H;
    if(chmin(x, z(T * 1000 - H * 6 - A * 1000))) {
      idx = i + 1;
    }
  }
  cout << idx << endl;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7

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

dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][1] = 1

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if A[i - 1][j - 1] == ".":
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]

print(dp[H][W] % mod)

Measured memory_bytes: 157452
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split();
		int A = int.Parse(input[0]);
		int B = int.Parse(input[2]);
		int ans = A + B;
		if (input[1] == "-")
		{
			ans -= 2 * B;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092