akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

int main(){
  string s;cin>>s;
  int cnt=0;
  rep(i,s.size()/2){
    if(s.at(i)!=s.at(s.size()-i-1)){
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    int n = s.size();
    for(int i=n-1;i>=2;i--) {
        if(i%2==0) {
            if(s.substr(0,i/2) == s.substr(i/2, i/2)) {
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
from collections import Counter

N, K = map(int, input().split())
*A, = map(int, input().split())
MOD = 10**9+7
S = [0]*(N+1)
c = Counter()
c[0] = 1
ans = 0

for i in range(N):
    S[i+1] = (S[i]+A[i]-1)%K
    if i+1-K>=0:
        c[S[i+1-K]] -= 1
    ans += c[S[i+1]]
    c[S[i+1]] += 1

print(ans)


Measured memory_bytes: 40456
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


ll shridharacharya(ll c)
{
	ll d = (ll)((sqrt(1 + 4 * c) - 1) / 2.0);
	return d;
}


void factorize(ll n)
{
	ll count = 0;
	ll out = 0;
	while (!(n % 2))
	{
		n >>= 1;
		count++;
	}
	if (count)
		out += shridharacharya(2 * count);

	ll lim = sqrt(n) + 1;
	for (ll i = 3; i < lim; i += 2)
	{
		count = 0;
		while (n % i == 0)
		{
			count++;
			n = n / i;
		}
		if (count)
			out += shridharacharya(2 * count);
	}
	if (n > 2)
		out += shridharacharya(2);
	cout << out << "\n";
}


int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//ios_base& scientific (ios_base& str);
	ll n;
	cin >> n;
	//cout << shridharacharya(200 ) << "\n";

	factorize(n);
	return 0;
}

Measured memory_bytes: 3672
a, b, M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = min(A)+min(B)
for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1]+B[y-1]-c)

print(ans)

Measured memory_bytes: 24844
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int h, w;
    cin >> h >> w;
    vector< vector<char> > s(h+2);
    for(int i = 0 ; i < w + 2 ; i++){
        s[0].push_back('.');
        s[h+1].push_back('.');
    }
    for(int i = 1 ; i <= h ; i++){
        s[i].resize(w+2);
        for(int j = 1 ; j <= w ; j++){
            cin >> s[i][j];
        }
    }
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    bool ans = true;
    for(int i = 1 ; i <= h ; i++){
        for(int j = 1 ; j <= w ; j++){
            if(s[i][j] == '#'){
                int cnt = 0;
                for(int k = 0 ; k < 4 ; k++){
                    if(s[i+dy[k]][j+dx[k]] == '#'){
                        cnt++;
                    }
                }
                if(cnt == 0){
                    ans = false;
                    break;
                }
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    int left[n+1];
    int right[n+1];
    left[0] = 0;
    right[n] = 0;
    for(int i=0;i<n;i++){
        left[i+1] = left[i] + a[i];
        right[n-i-1] = right[n-i] + b[n-i-1];
    }
/*
    for(int i=0;i<n;i++){
        cout << left[i] << " ";
    }
    cout << endl;
    
    for(int i=0;i<n;i++){
        cout << right[i] << " ";
    }
    cout << endl;
  */  int ans = 0; 
    for(int i=0;i<n;i++){
        if(ans < left[i+1] +right[i] ){
            ans = left[i+1] + right[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Char

splitBy :: (a -> Bool) -> [a] -> [[a]]
splitBy pred []  = []
splitBy pred str = a : (splitBy pred $ dropWhile pred b)
                 where (a, b) = break pred str

solve :: String -> Int
solve str = do
	let [x1, y1, r1, x2, y2, r2] = map read $ splitBy isSpace str :: [Double]
	let d = sqrt $ (dx * dx + dy * dy)
		where dx = x1 - x2
		      dy = y1 - y2
	check d r1 r2 where
		check d r1 r2
			| d > (r1 + r2)  = 0
			| (r2 + d) < r1  = 2
			| (r1 + d) < r2  = (-2)
			| otherwise      = 1
	
main :: IO ()
main = do
	n <- readLn :: IO Int
	lines <- replicateM n getLine
	mapM_ print $ map solve lines	

Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define ll long long 
ll mod=1e9+7;

using namespace std;


int n,m;
char arr[1000][1000];
ll dp[1000][1000];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   cin>>n>>m;
   for(int i=0;i<n;i++)
   {
   	for(int j=0;j<m;j++)
   	{
   		cin>>arr[i][j];
    }
   }
   
   for(int i=1;i<n;i++)
   {
   	if(arr[i][0]!='#')
   	{
   		dp[i][0]=1;
	}
	else break;
   }
   for(int i=1;i<m;i++)
   {
   	if(arr[0][i]!='#')
   	{
   		dp[0][i]=1;
	}
	else break;
   }
   
   for(int i=1;i<n;i++)
   {
   	for(int j=1;j<m;j++)
   	{
   		if(arr[i][j]!='#')
   		dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
	}
   }
  
   cout<<dp[n-1][m-1]<<endl;
   
   

	return 0;
	
	
}

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

int main(void){
	while(1){
		int month, day;
		int days_from_new_year = 0;
		cin >> month >> day;
		if(month == 0 && day == 0) break;
		for(int i = 1; i < month; i++){
			if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) days_from_new_year += 31;
			else if(i == 4 || i == 6 || i == 9 || i == 11) days_from_new_year += 30;
			else if(i == 2) days_from_new_year += 29;
		}
		days_from_new_year += day;
		int mod = days_from_new_year % 7;
		if(mod == 0) cout << "Wednesday";
		else if(mod == 1) cout << "Thursday";
		else if(mod == 2) cout << "Friday";
		else if(mod == 3) cout << "Saturday";
		else if(mod == 4) cout << "Sunday";
		else if(mod == 5) cout << "Monday";
		else if(mod == 6) cout << "Tuesday";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int n,i,a[200005],mx,nmx;
int main() {
	scanf("%d",&n);
	for(i=1; i<=n; i++) {
		scanf("%d",&a[i]);
		if(a[i]>mx)nmx=mx,mx=a[i];
		else if(a[i]>nmx)nmx=a[i];
	}
	for(i=1; i<=n; i++)
		if(a[i]==mx)printf("%d\n",nmx);
		else printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int N, A;
    long double inverse = 0.0L;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> A;
        inverse += 1.0L/A;
    }
    cout << setprecision(10) << 1.0L/inverse << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t,a[102],b[102],ans=1005;
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		if(b[i]<=t&&a[i]<ans)
		ans=a[i];
	}
	if(ans==1005)
	cout<<"TLE";
	else cout<<ans;
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n, a, ans = 0;
    cin >> n;
    vector <int> x[15], y[15];
    for (int i = 0; i < n; i++) {
        cin >> a;
        for (int j = 0; j < a; j++) {
            int tmpx, tmpy;
            cin >> tmpx >> tmpy;
            tmpx--;
            x[i].emplace_back(tmpx);
            y[i].emplace_back(tmpy);
        }
    }

    for (int bit = 0; bit < (1<<n); bit++) {
        bool isOK = true;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                cnt++;
                for (int j = 0; j < int(x[i].size()); j++) {
                    if (y[i][j]) {
                        if ((bit & (1<<x[i][j])) == 0) isOK = false;
                    } else {
                        if ((bit & (1<<x[i][j]))) isOK = false;
                    }
                }
            }
        }
        if (isOK) ans = max(ans, cnt);
    }
    
    cout << ans << endl;
    
    return 0;
}



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

const int MAX_M = 100000;
int n, m, k;
int a[MAX_M], b[MAX_M], c[MAX_M], d[MAX_M];
int friendsNum[MAX_M], blockNum[MAX_M], groupNum[MAX_M];

struct UnionFind {
    int par[MAX_M];
    int rank[MAX_M];

    UnionFind(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

void solve() {
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        uf.unite(a[i] - 1, b[i] - 1);
        friendsNum[a[i] - 1]++;
        friendsNum[b[i] - 1]++;
    }

    for (int i = 0; i < n; i++) {
        groupNum[uf.find(i)]++;
    }

    for (int i = 0; i < k; i++) {
        if (uf.same(c[i] - 1, d[i] - 1)) {
            blockNum[c[i] - 1]++;
            blockNum[d[i] - 1]++;
        }    
    }

    for (int i = 0; i < n; i++) {
        cout << groupNum[uf.find(i)] - friendsNum[i] - blockNum[i] - 1 << " ";
    }
    cout << endl;
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
    }
    solve();
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int a, b, c; cin>>a>>b>>c;
    if(a & 1 || b & 1 || c & 1) return cout << 0 << endl, 0;
    int x, y, z, f = 1, cnt = 0, ans = -1;
    while(!(a==b && b==c)){
        cnt++;
        if(f){
            x = b/2+c/2, y = a/2+c/2, z = a/2+b/2;
            if(x & 1 || y & 1 || z & 1){
                ans = cnt;
                break;
            }
        }
        else{
            a = y/2+z/2, b = x/2+z/2, c = x/2+y/2;
            if(a & 1 || b & 1 || c & 1){
                ans = cnt;
                break;
            }
        }
        f^=1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << (double)W*(double)H / 2.0 << " ";

	if (x * 2 == W && y * 2 == H) cout << 1;
	else cout << 0;

	return 0;
}

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

int main(){
 int n,m; cin >> n >> m;
 vector<int> check(n,0);
 vector<int> che(n,0);
 int wa=0; int ac=0;
 rep(i,m){
     int p; string s; cin >> p >> s;
     if(che[p-1]==0){
         if(s=="WA") check[p-1]++;
         else {
             ac++;
             che[p-1]=1;
         }
     }
 }
rep(i,n) if(che[i] == 1) wa+=check[i];
 cout << ac << ' ' << wa << endl;
 return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int n;
	cin >> n;
	
	ll ans = 0;
	
	for(int i = 0; i < n; i++) {
		ans += (i + 1) * 1ll * (n - i);
	}
	
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v; u--; v--;
		
		ans -= (min(u, v) + 1) * 1ll * (n - max(u, v));
	}	
	
	cout << ans << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m;
  cin>>n>>m;
  cout<<(1800*m+100*n)*(1<<m)<<endl;
  return 0 ;
}


Measured memory_bytes: 256
/*-------------------------------*
| Name: Ayush Kumar              |
| Site: atcoder                  |
| Email: ayushkr667@gmail.com    |
*-------------------------------*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF (ll) 1e18
const double PI = 3.141592653589793238460;

ll weigh[101], val[101];
ll dp[101][100001];
ll solve(ll n, ll w)
{
    for (ll i = 0; i <= n; i++)
    {
        dp[i][0] = 0;
    }
    
    for (ll i = 0; i <= w; i++)
    {
        dp[0][i] = 0;
    }

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= w; j++)
        {
            if(weigh[i] > j)
            {
                dp[i][j] = dp[i-1][j];
            }

            else
            {
                dp[i][j] = max( (val[i] + dp[i-1][j-weigh[i]]), dp[i-1][j]);
            }  
        } 
    }  
    return dp[n][w];
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    memset(dp, -1, sizeof(dp));
    ll w, n;
    cin>>n>>w;
    for (ll i = 1; i <= n; i++)
    {
        cin>>weigh[i]>>val[i];
    }
    cout<<solve(n, w);
    return 0;
}


Measured memory_bytes: 82500
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	auto check = [&](int m, int y) {
		if (1 <= m && m <= 12) {
			return true;
		} else {
			return false;
		}
	};
	bool my = check(a, b);
	bool ym = check(b, a);
	if (my && ym) {
		cout << "AMBIGUOUS\n";
	} else if (my) {
		cout << "MMYY\n";
	} else if (ym) {
		cout << "YYMM\n";
	} else {
		cout << "NA\n";
	}
}

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

int main() {
#ifdef LOCAL_DEFINE
  //freopen("data.in", "rt", stdin);
  //freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	string n;
	cin >> n;
	for(char c : n) {
		if(c == '9') {
			cout << '1';
		} else {
			cout << '9';
		}
	}
	cout << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
   val list = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
   for(i in 0 until list.size - 1) {
      for(j in list.size - 1 downTo i + 1) {
        if(list[j] < list[j - 1]) {
           val temp = list[j]
           list[j] = list[j - 1]
           list[j - 1] = temp
        }
      }
    }
   println(list.joinToString(" "))
}


Measured memory_bytes: 32100
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n; cin >> n;
  for(int i; i<3; i++){
  if(n.at(i)=='1') n.at(i)='9';
  else if(n.at(i)=='9') n.at(i)='1';
  }
  cout << n << endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

x = readint()

if x>=30:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61756
#include <bits/stdc++.h>
using namespace std;
int n , m , a , b , grid[2000][2000];
int main(){
	cin >> n >> m >> a >> b;
	for(int i = 1 ; i <= b ; i++){
		for(int j = a + 1 ; j <= m ; j++){
			grid[i][j] = 1;
		}
	}
	for(int i = b + 1 ; i <= n ; i++){
		for(int j = 1 ; j <= a ; j++){
			grid[i][j] = 1;
		}
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cout << grid[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

vector<vector<int> > g;
vector<bool> visited;

pair<int64_t,int64_t> Search(int start) {
  pair<int64_t, int64_t> counts;
  int V = g.size() / 2;
  queue<int> q;
  
  q.push(start);
  visited[start] = true;
  if (start < V) counts.first += 1;
  else counts.second += 1;
  
  while (not q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : g[x]) {
      if (not visited[y]) {
	q.push(y);
	visited[y] = true;
	if (y < V) counts.first += 1;
	else counts.second += 1;
      }
    }
  }
  
  return counts;
}

int main() {
  int N;
  cin >> N;
  int V = 100005;
  g = vector<vector<int> >(2 * V);
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(V + y);
    g[V + y].push_back(x);
  }
  visited = vector<bool>(2 * V);
  int64_t ans = 0;
  for (int i = 0; i < 2 * V; ++i) {
    pair<int64_t, int64_t> counts = Search(i);
    ans += counts.first * counts.second;
  }
  cout << ans - N << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
  int main(void){
    int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


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

int main(int argc, char* argv[]) {
	int x;
	for (int i = 1; i <= 5; i++) {
		cin >> x;
		if (x == 0) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define MC(n,m) memcpy((n),(m),sizeof(n))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define IOS do { ios_base::sync_with_stdio(0);cin.tie(0); } while (0)
#define SZ(x) ((int)(x).size())
#ifndef OFFLINE
    #define ONLINE_JUDGE
#endif
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
    do { \
        freopen(name".in", "r", stdin); \
        freopen(name".out", "w", stdout); \
    } while (0)
#else
    #define FILEIO(name) do { } while(0)
#endif

#define _TOKEN_CAT2(x, y) x ## y
#define _TOKEN_CAT(x, y) _TOKEN_CAT2(x, y)
#define _MACRO_OVERL3(_1, _2, _3, _N, ...) _N
#define _RANGE1(a) int _TOKEN_CAT(_t, __LINE__)=0; _TOKEN_CAT(_t, __LINE__)<(a); (_TOKEN_CAT(_t, __LINE__))++
#define _RANGE2(i, a) int (i)=0; (i)<(a); (i)++
#define _RANGE3(i, a, b) int (i)=(a); (i)!=(b); (i)+=((b)>(a)?1:-1)
#define loop(...) for (_MACRO_OVERL3(__VA_ARGS__, _RANGE3, _RANGE2, _RANGE1)(__VA_ARGS__))

#ifdef OFFLINE
template<typename T>
void _dump(const char* s, T&& head) { 
    cerr << s << " = " << head << " <<" << endl; 
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c = 0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{' || *s=='<') c++;
        if (*s==')' || *s==']' || *s=='}' || *s=='>') c--;
        cerr << *s++;
    }
    cerr << " = " << head << ", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    cerr << "\033[32m>> " << __LINE__ << ": " << __PRETTY_FUNCTION__ << endl; \
    cout << "   "; \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
    cout << "\033[0m"; \
} while (0)
#else
#define dump(...) 
#endif

#define au auto
template<class T>
using vec = vector<T>;

template<typename Iter>
ostream& _IterOutput_(ostream &o, Iter b, Iter e, const string ss="", const string se="") {
    o << ss;
    for (auto it=b; it!=e; it++) o << (it==b ? "" : ", ") << *it;
    return o << se;
}

template<typename T1, typename T2>
ostream& operator << (ostream &o, const pair<T1, T2> &pair) {
    return o << "(" << pair.F << ", " << pair.S << ")";
}

template<typename T>
ostream& operator << (ostream &o, const vector<T> &vec) {
    return _IterOutput_(o, ALL(vec), "[", "]");
}

template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    return _IterOutput_(o, ALL(st), "{", "}");
}

template<typename T, size_t N>
ostream& operator << (ostream &o, const array<T, N> &arr) {
    return _IterOutput_(o, ALL(arr), "|", "|");
}

template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->F << ":" << it->S;
    }
    o << "}";
    return o;
}

#define int long long

int A, B, C;

int32_t main() {
    IOS;
    cin >> A >> B >> C;

    if (A%2 == 0 or B%2 == 0 or C%2 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << min(A*B, min(B*C, A*C)) << endl;

    return 0;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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 dif(int d1, int d2){
    return min(abs(d1-d2), abs(24-abs(d1-d2)));
}

int mind(int pos, VI& v){
    int r = pos, l = pos;
    int dr = 0, dl = 0;
    while(r<24 && v[r]==0){r++; dr++;}
    if(r == 24){
        r = 0;
        while(v[r]==0){r++; dr++;}
    }
    while(l>-1 && v[l]==0){l--; dl++;}
    if(l == -1){
        l = 23;
        while(v[l]==0){l--; dl++;}
    }
    return min(dr,dl);
}

int main(void){
    int N; cin >> N;
    VI D(N+1,0); REP(i,N) cin >> D[i];
    SORT(D); REVERSE(D);
    int l = 0, r = 13, n = (l+r)/2;
    while(r-l>1){
        VI loc(24,0); loc[12] = 1;
        bool flag = true;
        REP(i,N){
            if(mind(12-D[i], loc) >= n) loc[12-D[i]] = 1;
            else if(mind((12+D[i])%24, loc) >= n) loc[(12+D[i])%24] = 1;
            else{
                flag = false;
                break;
            }
        }
        if(flag) l = n;
        else r = n;
        n = (l+r)/2;
    }
    int ans = l;
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		String s = cin.next();

		now.getAsLong();

		String ans = solve(s);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static String solve(String s) {
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < s.length(); i++)
			if (i % 2 == 0)
				ans.append(s.charAt(i));
		return ans.toString();
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n,pp,ss;
  	cin>>n;
  	int ar[n];
  	for(int i=0;i<n;i++)
    {
      	cin>>ar[i];
    }
    if(n%2==0)
    {
        sort(ar,ar+n);
        pp=n/2;
        ss=pp-1;
        cout<<abs(ar[ss]-ar[pp])<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
  	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.System;

public class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String s;
        int week;
        double total;

        while((s = r.readLine()) != null) {
            week = Integer.parseInt(s);
            total = 100000;
            for(int i = 0; i < week; i++) {
                total *= 1.05;
                total /= 1000;
                total = Math.ceil(total) * 1000;
            }
            System.out.printf("%.0f\n", total);
        }
    }
}

Measured memory_bytes: 17108
import java.util.Scanner;
 
public class Main {
  public static void main ( String[] args ) {

    Scanner sc = new Scanner ( System.in ); 

    int N = sc.nextInt();

    int[] arrive = new int[N];
    
    for (int i=0;i<N;i++){
    	int number = sc.nextInt();
        arrive[number-1] = i+1;
    }
    
    for (int j=0; j<N; j++){
     	System.out.println(arrive[j]);
 	}
  }
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

struct UnionFind
{
  vector<int> uf;
  UnionFind(int n) : uf(n) {
    for (int i = 0; i < n; i++) uf[i] = i;
  }
  
  int find(int x) {
    return (uf[x] == x) ? x : (uf[x] = find(uf[x]));
  }
  
  bool merge(int x, int y) {
    int res1 = find(x), res2 = find(y);
    if (res1 == res2) return false;
    uf[res2] = res1;
    return true;
  }
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;
  int K,L; cin >> K >> L;
  
  UnionFind A(n);
  for(int i=0;i<K;i++){
    int u,v; cin >> u >> v; u--; v--;
    A.merge(u,v);
  }
  
  UnionFind B(n);
  for(int i=0;i<L;i++){
    int u,v; cin >> u >> v; u--; v--;
    B.merge(u,v);
  }
  
  map<pair<int,int>,int> M;
  for(int i=0;i<n;i++)
    M[make_pair(A.find(i),B.find(i))]++;
  
  for(int i=0;i<n;i++)
    cout << M[make_pair(A.find(i),B.find(i))] << " ";
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 13568
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

N = input()
N = int(N)
l = [input() for i in range(N)]
a = 0
for i in range(0,len(l)):
    if is_prime(int(l[i])) == True:
         a += 1
print(a)



Measured memory_bytes: 6272
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

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

    ll sum=0;
    for (int i=1; i<= n; ++i){
        if(i%3==0 or i%5==0){
            continue;
        }
        sum += i;
    }
    cout<<sum<<endl;

} // end of main

//実行は、Opt + Ctl + N

Measured memory_bytes: 3620
#include<iostream>
#define MAX 100
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    int R[MAX] = {};
    int C[MAX] = {};
    char A[MAX][MAX];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] == '#') {
                R[i] = 1;
                C[j] = 1;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        if (R[i] > 0) {
            for (int j = 0; j < W; j++) {
                if (C[j] > 0) cout << A[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
ll M=1;
std::vector<ll> seg;
void init(ll N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    seg.push_back(0);
  }
}
void update(ll l, ll r, ll x, ll k){
  k+=(M+1)/2-1;
  seg[k] = (seg[k]>x?seg[k]:x);
  while(k>0){
    k = (k-1)/2;
    seg[k] = max(seg[k*2+1], seg[k*2+2]);
  }
}
ll query(ll a, ll b, ll l, ll r, ll k){
  if(r<=a || b<=l) return 0;
  if(a<=l && r<=b) return seg[k];
  ll A = query(a, b, l, (l+r)/2, k*2+1);
  ll B = query(a, b, (l+r)/2, r, k*2+2);
  return max(A, B);
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  ll N, ans = 0;
  std::cin >> N;
  map<ll, ll> num;
  init(N+1);
  std::vector<ll> s(N);
  vvl ha = vv(N, 2, 0, ll);
  for(int i=0;i<N;i++) {
    std::cin >> ha[i][0];
    s[i] = ha[i][0];
  }
  sort(s.begin(), s.end());
  for(int i=0;i<N;i++) if(num.find(s[i])==num.end()) num.emplace(s[i], num.size());
  for(int i=0;i<N;i++) std::cin >> ha[i][1];
  for(int i=0;i<N;i++){
    ll tmp = query(0, num.at(ha[i][0]), 0, (M+1)/2, 0);
    ans = max(ans, ha[i][1]+tmp);
    update(0, (M+1)/2, ha[i][1]+tmp, num.at(ha[i][0]));
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 29420
N=int(input())
a=list(map(int, input().split()))
 
a=sorted(a)[::-1] 
ans =a[0]

if len(a)%2 !=0:
    for i in range(1,int((len(a))/2)+1):
        for j in range(2):
            ans +=a[i]
    print(ans-a[int((len(a))/2)])
else:
    for i in range(1,(len(a))//2):
        for j in range(2):
            ans +=a[i]
    print(ans)

Measured memory_bytes: 31536
import Data.List

main = do
    x <- read <$> getLine
    print $ exponential x

exponential x = maximum [pow | b <- [1..x], let pow = maxPower b 2, pow <= x]
    where
        maxPower 1 p = 1
        maxPower b p =
            if (b^(p+1) <= x)
                then maxPower b (p + 1)
                else b^p

Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B), x(M), y(M), c(M);
	int amin = 1000000;
	int bmin = 1000000;
	for (int i = 0; i < A; ++i) {
		cin >> a.at(i);
		amin = std::min(amin, a.at(i));
	}
	for (int i = 0; i < B; ++i) {
		cin >> b.at(i);
		bmin = std::min(bmin, b.at(i));
	}
	for (int i = 0; i < M; ++i) {
		cin >> x.at(i) >> y.at(i) >> c.at(i);
	}
	int min = amin + bmin;
	for (int i = 0; i < M; ++i) {
		min = std::min(min, a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i));
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 2176
N, M = map(int, input().split())

i = 1
ans = 1
while i ** 2 <= M:
    if M % i == 0:
        if i * N <= M:
            ans = max(i, ans)
        x = M // i
        if x  * N <= M:
            ans = max(x, ans)
    
    i += 1

print(ans)

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

using namespace std;

const int N = 1e5+7;
int d[N];
bool vis[N];

int main()
{
    int n,m; cin >> n >> m;
    for(int i =1 ; i <= n;  i ++) cin >> d[i];
    
    while(m --)
    {
        int a,b;
		cin>>a>>b;
		if(d[a]<d[b]) vis[a]=1;
		if(d[b]<d[a])  vis[b]=1;
		if(d[b]==d[a]) vis[a]=1,vis[b]=1;
    }
        long long  s=0;
    	for(int i=1;i<=n;i++)
    	if(vis[i]==0)
    	s++;
        cout<<s<<endl;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<' '<<a<<' '<<b<<endl;

	return 0;
}



Measured memory_bytes: 256
use std::collections::VecDeque;
use std::io::BufRead;

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
struct Pos { y: usize, x: usize }

fn main() {
    let stdin = std::io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let (h, w) = to_pair(&buf);

    let mut map: Vec<Vec<u8>> = stdin.lock().lines().map(|l| l.unwrap().into_bytes()).collect();
    let mut qq: VecDeque<VecDeque<Pos>> = VecDeque::new();
    let mut startq: VecDeque<Pos> = VecDeque::new();
    for i in 0..h {
        for j in 0..w {
            if map[i][j] == b'#' {
                startq.push_back(Pos { y: i, x: j });
            }
        }
    }
    if !startq.is_empty() {
        qq.push_back(startq);
    }

    let mut cnt = 0;
    while !qq.is_empty() {
        let mut q = qq.pop_front().unwrap();
        let mut new_q = VecDeque::new();
        while let Some(pos) = q.pop_front() {
            for &(dy, dx) in &[(1, 0), (-1, 0), (0, 1), (0, -1)] {
                let nx_y = pos.y as i32 + dy;
                let nx_x = pos.x as i32 + dx;
                if nx_y < h as i32 && nx_y >= 0 && nx_x < w as i32 && nx_x >= 0
                    && map[nx_y as usize][nx_x as usize] == b'.' {
                    map[nx_y as usize][nx_x as usize] = b'#';
                    new_q.push_back(Pos { y: nx_y as usize, x: nx_x as usize});
                }
            }
        }
        if !new_q.is_empty() {
            cnt += 1;
            qq.push_back(new_q);
        }
    }

    println!("{}", cnt);

}

// fn print_map(map: &Vec<Vec<u8>>) {
//     for v in map.iter() {
//         println!("{}", std::str::from_utf8(v).unwrap());
//     }
// }

fn to_pair(s: &str) -> (usize, usize) {
    let v: Vec<usize> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    let (l, r) = (v[0], v[1]);
    (l, r)
}


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

int main() {
    int a, b, c;
    cin >> a >> b;
    int d,r;
    double f;
    d = a/b;
    r = a%b;
    f = 1.0 * a/b;
    cout << d << " " << r << " " << fixed << setprecision(7) << f << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int[] prog;
			prog = new int[n];

			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line);

			for (int i = 0; i < n; i++) {
				prog[i] = Integer.parseInt(st.nextToken());
			}

			// 出現頻度操作
			int op = 0;
			while (true) {

				// 数え上げ
				int[] freq = new int[n];
				boolean[] chk = new boolean[n];

				for (int i = 0; i < n; i++) {
					if (!chk[i]) {
						int f = 1, t = 1;
						int[] idx = new int[n];
						chk[i] = true;
						idx[0] = i;
						for (int j = 0; j < n; j++) {
							if (!chk[j] && prog[i] == prog[j]) {
								chk[j] = true;
								f++;
								idx[t] = j;
								t++;
							}
						}
						for (int j = 0; j < t; j++) {
							freq[idx[j]] = f;
						}
					}
				}
				//
				if (!Arrays.equals(prog, freq)) {
					prog = freq;
					op++;
				} else {
					prog = freq;
					break;
				}
			}
			System.out.println(op);
			for (int i = 0; i < n; i++) {
				if (i != n - 1) {
					System.out.print(prog[i] + " ");
				} else
					System.out.println(prog[i]);
			}
		}
	}
}

Measured memory_bytes: 19036
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;

int main() {FIN
    
    int t = 0;
    char e;
    vs nm = {"A", "B", "C"};
    vs ply(3);
    vi pos(3, 0);
    cin >> ply[0];
    cin >> ply[1];
    cin >> ply[2];
    
    while (true) {
		if ((int)ply[t].size() == pos[t]) break;
		e = ply[t][pos[t]];
		pos[t]++;
		t = (e - 'a');
	}
    cout << nm[t] << "\n";
    
    return 0;
}


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

void fnInput(vector<double>& rvnValue)
{
  int nValueSiz;
  cin >> nValueSiz;
  rvnValue.resize(nValueSiz);

  for(double& rnValue : rvnValue)
    cin >> rnValue;
}
  
double fnMaxValueGet(const vector<double>& cnrvnValue)
{
  vector<double> vnAscValue(cnrvnValue);

  while (vnAscValue.size() > 1)
  {
    sort(begin(vnAscValue), end(vnAscValue));
    auto it = begin(vnAscValue);
    double nAveValue = (double)( *it + *(it + 1) ) / 2;

    vnAscValue.erase(it, it + 2);
    vnAscValue.push_back(nAveValue);
  }
  return vnAscValue[0];
}
  
int main()
{
  vector<double> vnValue;

  fnInput(vnValue);
  cout << fnMaxValueGet(vnValue) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int check(int a,int b,int c){
	return (a*a==b*b+c*c||b*b==a*a+c*c||c*c==b*b+a*a)?1:0;
}
int main(){
	int x,y,a,b,c;
	scanf("%d",&x);
	int *ans;
	ans=(int*)malloc(sizeof(int)*x);
	for(y=0;y<x;y++){
		scanf("%d %d %d",&a,&b,&c);
		if(1==check(a,b,c))ans[y]=1;
		else ans[y]=0;
	}
	for(y=0;y<x;y++){
		if(ans[y])printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

std::vector<std::pair<int, int>> factorize(long long n) {
  std::vector<std::pair<int, int>> res;
  for (long long p = 2; p * p <= n; ++p) {
    int exp = 0;
    while (n % p == 0) {
      n /= p;
      ++exp;
    }
    if (exp)
      res.push_back(std::make_pair(p, exp));
  }
  if (n != 1)
    res.push_back(std::make_pair(n, 1));
  return res;
}

class Combination {
private:
  const int max;
  const int mod;
  std::vector<long long> fac;  // fac[k] = k! in Fp
  std::vector<long long> finv; // finv[k] = (k!)^-1 in Fp
public:
  Combination(int max, int mod)
      : max(max), mod(mod), fac(max, -1), finv(max, -1) {
    std::vector<long long> inv(max, -1); // inv[k] = k^-1 in Fp
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < max; ++i) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  long long operator()(int n, int k) const {
    if (n < k || n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main() {
  int N, M;
  std::cin >> N >> M;

  const int MAX = 1000000;
  const int MOD = 1000000007;
  Combination comb(MAX, MOD);

  long long res = 1;
  auto factors = factorize(M);
  for (auto &factor : factors) {
    // int p = factor.first;
    int e = factor.second;
    // std::cout << "e: " << e << std::endl;
    res = (res * comb(e + N - 1, e)) % MOD;
  }
  std::cout << res << std::endl;
}


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

int main()
{
    cin >> N >> M;
    vector<int> v[N];
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
    }

    bool ans = false;
    for (auto first : v[0])
    {
        for (auto second : v[first])
        {

            if (second == N - 1)
            {
                ans = true;
            }
        }
    }

    if (ans)
    {
        cout << "POSSIBLE" << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 11908