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

int main() {
    int N;
    cin >> N;
    int maxv = 0;
    int sum = 0;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
        maxv = max(maxv, L[i]);
        sum += L[i];
    }
    cout << ((sum - maxv) > maxv ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

dist = abs(a - b)
vd = v - w

if vd > 0:
    if 0 <= dist/vd/t <= 1:
        print("YES")
    else:
        print("NO")
elif vd == 0 and dist == 0:
    print("YES")
else:
    print("NO")

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

vector<ll> mid; 
vector<ll> mid2; 


int main(void){
    ll x,y,z,k;
    vector<ll> a, b, c;
    ll m = 10000000000000000LL;
    cin >> x >> y >> z >> k;
    a.resize(x);b.resize(y);c.resize(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    mid.reserve(x * y);

    rep(i,x)rep(j,y){
        mid.push_back(a[i] + b[j]);
    }

    sort(mid.begin(), mid.end(), greater<ll>());

    rep(i, min((ll)mid.size(), k)){
        rep(j, z){
            mid2.push_back(mid[i] + c[j]);
        }
    }
    sort(mid2.begin(), mid2.end(), greater<ll>());
    rep(i, k){
        cout << mid2[i] << endl;
    }

    return 0;
}

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

int main() {
  int A,B,C,D,a,b,c,d,i;
  cin >> A >> B >> C >> D;
  i = 1;
  while(true){
    C = C - B;
    A = A - D;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    else if(A <= 0 && C > 0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    int a,b,c=0,d=0,e,i;
 scanf("%d%d",&a,&b);
    for(i=a-1;i>0;i--)
     {
         c=c+i;

     }
     for(i=b-1;i>0;i--)
     {
         d=d+i;
     }
     e=c+d;
     printf("%d",e);

}


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

using namespace std;

int main(){
    string  S,T;    
    cin >> S >> T;
    
    int cnt = 0;
    rep(i, 3) {
        if(S[i] == T[i]) {
            cnt++;
        } 
            
    }
    
    cout << cnt << endl;
    
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int N, M, Q;
ll A[MAX], psum[MAX], K;
vector<ll> vt;
int seg[4 * MAX];

int update(int node, int l, int r, int p, int val) {
	if (p < l || p > r) return seg[node];
	if (l == r) return seg[node] += val;
	int m = (l + r) >> 1;
	return seg[node] = update(2 * node, l, m, p, val) + update(2 * node + 1, m + 1, r, p, val);
}

int query(int node, int l, int r, int ql, int qr) {
	if (r < ql || l > qr) return 0;
	if (ql <= l && r <= qr) return seg[node];
	int m = (l + r) >> 1;
	return query(2 * node, l, m, ql, qr) + query(2 * node + 1, m + 1, r, ql, qr);
}

int newidx(ll num) {
	return lower_bound(vt.begin(), vt.end(), num) - vt.begin();
}

int main()
{
	int i, j, k;
	scanf("%d%lld", &N, &K);
	for (i = 0; i < N; ++i) {
		scanf("%lld", &A[i]);
		A[i] -= K;
		psum[i + 1] = psum[i] + A[i];
		vt.push_back(psum[i + 1]);
	}
	sort(vt.begin(), vt.end());
	vt.erase(unique(vt.begin(), vt.end()), vt.end());

	ll cnt = 0;
	for (i = 1; i <= N; ++i) {
		if (psum[i] >= 0) cnt++;
		cnt += (ll)query(1, 0, vt.size()-1, 0, newidx(psum[i]));
		update(1, 0, vt.size()-1, newidx(psum[i]), 1);
	}
	printf("%lld", cnt);
}

Measured memory_bytes: 8176
/* Press F to pay respects */
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 200;
const ld PI = 3.1415926535898;
void add(int &a, int b) {
	a += b;
	if(a >= MOD)	
		a -= MOD;
	if(a < 0)
		a += MOD;
}
bool comp(int x, int y) {
	if(__builtin_popcountll(x) == __builtin_popcountll(y))	return x < y;
	return __builtin_popcountll(x) < __builtin_popcountll(y);
}
int dp[16][(1LL<<16)];
int32_t main()
{
	SYNC
	int n; cin >> n;
	int a[100][100];
	memset(a,0,sizeof a);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int mx_len = (1LL<<n);
	vi dp(mx_len,0);
	vi v;
	rep(i,0,mx_len)	v.pb(i);
	sort(all(v),comp);
	auto cost_merge = [&] (int group, int node) -> int 
	{
		int cost = 0;
		for(int i = 0; i < n; i++) {
			if((1LL<<i)&group) {
				cost += a[i][node];
			}
		}
		return cost;
	};
	for(int mask : v)
	{
		for(int nv = 0; nv < n; nv++) {
			if(!((1LL<<nv)&mask)) {
				int new_mask = mask|(1LL<<nv);
				dp[new_mask] = dp[mask] + cost_merge(mask, nv);
			}
		}
	}
	for(int mask : v) {
		for(int i = mask; i >= 1; i = (i-1)&mask)
		{
			dp[mask] = max(dp[mask],dp[i]+dp[mask^i]);
		}
	}
	cout << dp[mx_len-1];
    return 0;
}

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


int main(){
  using tisi = tuple<int, string, int>;
  int N;
  cin >> N;
  tisi A[100];
  //get<1>(A[i])でi番目の市名,get<2>(A[i])でi番目の店名
  
  for (int i = 0; i < N; i++){
    get<0>(A[i]) = i+1 ;
    cin >> get<1>(A[i]) >> get<2>(A[i]);
  }
  bool flag = 1;
  tisi x;//一時的に保存する
  for(int i = 0; flag; i++){
    flag = 0;
    for(int j = N-1; j > i; j--){
      
      if( get<1>(A[j]) < get<1>(A[j-1]) ){ //A[i]の市名がA[i-1]よりアルファベット順で後なら
        flag = 1;
        x = A[j];
        A[j] = A[j-1];
        A[j-1] = x;
      }
      //市名が同じとき点数で比較する
      else if(get<1>(A[j]) == get<1>(A[j-1]) ){
        
        if(get<2>(A[j]) > get<2>(A[j-1]) ){
          flag = 1;
          x = A[j];
          A[j] = A[j-1];
          A[j-1] = x;
        }
      }
    }
    
    
  }
  for(int i =0; i < N ;i++){
  	cout << get<0>(A[i]) << endl;
  }
  
}


Measured memory_bytes: 256
// Problem : B - Varied
// Contest : AtCoder - AtCoder Beginner Contest 063
// URL : https://atcoder.jp/contests/abc063/tasks/abc063_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
string s;cin>>s;
map<int,int> mp;
for(char c:s)
mp[c]++;
if(size(mp)==size(s))
cout<<"yes";
else
cout<<"no";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<climits>
using namespace std;
 
int main(){
	long long n,a,ans=0;
    cin >> n;
    cin >> a;
    ans = a;

    for(long long i = 1; i < n; i++){
        cin >> a;
        if(a == 0){
            cout << 0 << endl;
            return 0;
        }
        ans *= a;
    }    

    if((ans == 0) || (ans > 1000000000000000000)){
        ans = -1;
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3640
# coding: utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))

    splits = []
    j = 0
    i = 2
    while i < N:
        if A[i-2] <= A[i-1] and A[i-1] > A[i]:
            splits.append(A[j:i])
            j = i
            i += 2
        else:
            i += 1

    splits.append(A[j:])
    S = len(splits)

    if S == 0:
        if A[0] >= A[-1]:
            return 1000
        else:
            n = 1000 // A[0]
            return n * A[-1]

    money = 1000
    for xs in splits:
        n = money // min(xs)
        money = money % min(xs)
        money += n * xs[-1]

    return money

    # rest_max = [None] * N
    # now_max = A[-1]
    # rest_max[-1] = now_max
    # for i in range(N-2, -1, -1):
    #     if A[i] > now_max:
    #         now_max = A[i]
    #     rest_max[i] = now_max


print(main())


Measured memory_bytes: 9224
#include <iostream>
#include <cmath>
#include <cstdio>
//#include <vector>
#include <string>
 
using namespace std;
 
int main() {
    string othello;
    bool flag = 0;
    int count = 0;
    int piece;
 
    cin >> othello;
 
 
    //if (othello[0] == 'B' )
    //{
    //    piece = BLACK;
    //}
    //else
    //{
    //    piece = WHITE;
    //}
 
    for (int i = 1; i < othello.length() ; i++)
    {
        if (othello[i] != othello[i - 1])
        {
            count++;
        }
    }
 
    cout << count << endl;
 
 
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
    int n;
    cin>>n;
    int f=0;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(mp.count(x)) f=1;
        mp[x]=i;
    }
    if(f) cout<<"NO";
    else cout<<"YES";
}

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

using namespace std;

string s;

bool N, S, E, W;

int main()
{
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        if(s[i] == 'N')
            N = true;
        else if(s[i] == 'S')
            S = true;
        else if(s[i] == 'E')
            E = true;
        else
            W = true;
    if(N != S || E != W)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())

counter = 0

for i in range(B-A+1):
    n = A + i
    s = list(str(n))
    st = ""
    for j in range(5):
        st += s[4-j]
    if int(st) == n:
        counter += 1
    else:
        continue

print(counter)


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

int main () {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  
  ll a = A * C;
  ll b = A * D;
  ll c = B * C;
  ll d = B * D;
  ll ans = max(a, max(b, max(c, d)));
  cout << ans << endl;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
A = {}
B = {}

for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

C = [(k, A[k]) for k in sorted(A, key=A.get)]

total = 0

for key, value in C:
    if (M < 0):
        break
    if (M > B[key]):
        total = total + A[key]*B[key]
    else:
        total = total + A[key]*M
    M -= B[key]
    # print(key, A[key], B[key], total, M)

print(total)


Measured memory_bytes: 33444
n,m = map(int,input().split())
y = [list(map(int,input().split())) for _ in range(m)]
y.sort(key=lambda x:x[1])
s = y[0][1]-0.5
ans = 1
for i in range(1,m):
    a,b = y[i]
    if a < s < b:
        continue
    else:
        ans += 1
        s = b-0.5
print(ans)

Measured memory_bytes: 28656
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;

 int main()
 {
   int n;
   cin>>n;
   int arr_min[8];
   int arr_max[8];
   while(n--)
   {
     int a;
     cin>>a;
     for(int i=0;i<8;i++)
     {
       arr_min[i]=a%10;
       a/=10;        
     }       
     sort(arr_min,arr_min+8);
     int min,max;
     min=max=0;
     for(int i=0;i<8;i++) arr_max[i]=arr_min[8-i-1];
     for(int i=0;i<8;i++)
     {
       min=10*min+arr_min[i];
       max=10*max+arr_max[i];          
     }  
     cout<<(max-min)<<endl;
   }
   //while(1);
   return 0;
 }

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
}

const int MAXN=1e5+7;

static int a,b,c;

inline void init()
{
	read(a),read(b),read(c);
}

inline void solve()
{
	cout<<b+min(a+b+1,c)<<endl;
}

int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // force size of x to be bigger than that of y
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

        return true;
    }

    ll size(int x) {
        return -par[root(x)];
    }
};

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

    ll n, m; cin >> n >> m;

    vector<int> a(m), b(m);
    REP(i, m) cin >> a[i] >> b[i];

    reverse(ALL(a));
    reverse(ALL(b));

    UnionFind uf(n + 1);

    vector<ll> ans(m, 0);
    ans[0] = n * (n - 1) / 2;
    REP(i, m - 1) {
        ll t = uf.size(a[i]) * uf.size(b[i]);
        if (uf.issame(a[i], b[i])) t = 0;
        uf.merge(a[i], b[i]);
        ans[i + 1] = ans[i] - t;
    }

    reverse(ALL(ans));

    for(auto &e: ans) print(e);

}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main()
{
	
	string str;cin >> str;
	
	REP(i,str.size()-1){
		if(str[i] == 'A' && str[i+1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split('/');
            int nen = int.Parse(s[0]);
            int getu = int.Parse(s[1]);
            int nichi = int.Parse(s[2]);

            Console.WriteLine(
                nen>2019||getu>04||nichi>30? "TBD": "Heisei"
                );
        }
    }
}


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

using namespace std;

const int N = 2e5; 

int a[N];
int f[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		if(i==2)
		{
			f[i]=abs(a[i]-a[i-1]);
			continue;
		}
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<f[n];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d",&n);
	int arr[n];
	for(int i=0;i<n;i++)
		scanf("%d",&arr[i]);
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]%2==1)
			c++;
	}
	if(c%2==0)
		printf("YES\n");
	else 
		printf("NO\n");
}

Measured memory_bytes: 640
# coding:utf-8
import sys 
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, [input() for i in range(n)]))
    a_count = Counter(a)
    ans = []

    for i in a_count.items():
        if i[1] % 2 != 0:
            ans.append(i[0])

    print(len(ans))
    
if __name__ == '__main__' :
    main()

Measured memory_bytes: 18044
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

const int N_MAX = 2999;

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

	vector<double> p(N);
	for(auto &x : p) {
		cin >> x;
	}

	// q[i][n]: i番目までのコインで表がちょうどn回出る確率
	static double q[N_MAX][N_MAX + 1];

	for(int i = 0; i < N; i++) {
		for(int n = 0; n <= N; n++) {
			if(i == 0) {
				if(n == 0) {
					q[i][n] = (1 - p[i]);
				} else if(n == 1) {
					q[i][n] = p[i];
				} else {
					q[i][n] = 0;
				}
			} else if(n == 0) {
				q[i][n] = q[i - 1][n] * (1 - p[i]);
			} else {
				q[i][n] = q[i - 1][n] * (1 - p[i])
					+ q[i - 1][n - 1] * p[i];
			}
		}
	}

	const int majority = (N + 1) / 2;

	double result = 0;
	for(int n = majority; n <= N; n++) {
		result += q[N - 1][n];
	}

	cout << fixed << setprecision(10);
	cout << result << endl;

	return 0;
}


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

// 
int main() {
    int X;
    cin >> X;
    vector<bool> primeNumbers(X * 2, true);
    for (int i = 2; i < X; i++) {
        if (!primeNumbers[i]) continue;
        int j = 2;
        int result = i;
        while (result < X * 2) {
            primeNumbers[result] = false;
            // cout << result << endl;  // debug
            j++;
            result = i * j;
        }
    }
    // debug
    // for (int i = 2; i < X * 2; i++) {
    //     cout << i << ":" << primeNumbers[i] << endl;
    // }
    for (int i = X; i < X * 2; i++) {
        if (primeNumbers[i]) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        final String s = scanner.next();

        int count = 0;
        for (int i = 0; i < s.length() - 2; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C') {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b,c;cin>>a>>b>>c;

    if(a<=c && c<=b){
      cout<<"Yes"<<endl; return 0;
    }

    cout<<"No"<<endl;
    return 0;
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < max(a,b); ++i){
cout << min(a,b);
  }
  cout << "\n";
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	sum := 0
	for i := 0; i < len(n); i++ {
		a := int(n[i] - '0')
		sum += a
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

bool solve(int y, int x, bool turn) {
    if (y < 2 && x < 2) return !turn;

    for (int i = 1; 2 * i <= y; i++) {
        bool ok = solve(y - (2 * i), x + i, !turn);
        if (ok == turn) return turn;
    }

    for (int i = 1; 2 * i <= x; i++) {
        bool ok = solve(y + 1, x - (2 * i), !turn);
        if (ok == turn) return turn;
    }

    return !turn;
}

int main() {
    ll a, b;
    cin >> a >> b;
//    bool ok = solve(a, b, true);
    bool ok = abs(a - b) > 1;
    string ans = ok ? "Alice" : "Brown";
    cout << ans << endl;
    ret();
    rep(i, 10) {
        rep(j, 10) {
            printf("%d %d %s\n", i, j, solve(i, j, true) ? "Alice" : "Brown");
        }
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF+7;
const LL LLINF = 1e18;

LL dp[101][3][3][3];
//dp[?????\???][?????\][?????\][????????\];
const LL mo = 10000;

int main(void) {
	int N, K;
	cin >> N >> K;
	VI menu(N, -1);
	REP(i, K) {
		int a, b;
		cin >> a >> b;
		menu[a - 1] = b - 1;
	}
	REP(i, 101)REP(j, 3)REP(k, 3)REP(l, 3) dp[i][j][k][l] = 0;
	//0??\???
	if (menu[0] == -1) {
		REP(i, 3) {
			dp[0][i][0][0] = 1;
		}
	} else {
		dp[0][menu[0]][0][0] = 1;
	}
	//1??\???
	if (menu[1] == -1) {
		REP(i, 3) REP(j, 3) {
			dp[1][i][j][0] = dp[0][j][0][0];
		}
	} else {
		REP(i, 3) dp[1][menu[1]][i][0] = dp[0][i][0][0];
	}
	//2??\???
	if (menu[2] == -1) {
		REP(i, 3)REP(j, 3)REP(k, 3) {
			if (i == j && j == k) continue;
			dp[2][i][j][k] = dp[1][j][k][0];
		}
	} else {
		REP(i, 3)REP(j, 3) {
			if (menu[2] == i && i == j) continue;
			dp[2][menu[2]][i][j] = dp[1][i][j][0];
		}
	}
	FOR(day, 3, N) {
		if (menu[day] != -1) {
			REP(i, 3)REP(j, 3) {
				if (menu[day] == i && i == j) dp[day][menu[day]][i][j] = 0;
				else {
					LL num = 0;
					REP(k, 3) num = (num + dp[day - 1][i][j][k]) % mo;
					dp[day][menu[day]][i][j] = num;
				}
			}
		} else {
			REP(i, 3)REP(j, 3)REP(k, 3) {
				if (i == j && j == k) dp[day][i][j][k] = 0;
				else {
					LL num = 0;
					REP(l, 3) num = (num + dp[day - 1][j][k][l]) % mo;
					dp[day][i][j][k] = num;
				}
			}
		}
	}
	LL ans = 0;
	REP(i, 3)REP(j, 3)REP(k, 3) {
		ans = (ans + dp[N - 1][i][j][k]) % mo;
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  ll x,sum=0;
  cin>>n>>x;
  ll vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  sort(vec,vec+n);
  int ans=0;
  for(int i=0;i<n;i++){
    sum+=vec[i];
    if(sum<=x){
      ans++;
    }
  }
  if(ans==n){
    if(sum!=x){
      ans--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
const int MAX = 1e5;
int main(){
    vector<int>lis(MAX,0);
    vector<int>isp(MAX,true);
    int sq = floor(pow(MAX,0.5));
    isp[0]=false,isp[1]=false;
    for(int i=2;i<sq;i++){
        for(int j=2;i*j<MAX;j++){
            isp[i*j]=false;
        }
    }
    for(int i=1;i<MAX;i++){
      if(isp[i]&&isp[(i+1)/2]){
            lis[i]=lis[i-1]+1;
        }else{
            lis[i]=lis[i-1];
        }
    }
    int q;cin>>q;
    int l,r;
    fol(i,q){
      cin>>l>>r;
      cout << lis[r]-lis[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint dp(n+1,0);
    REP(i,m){
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0]=1;
    for(int i=1;i<=n;++i){
        if(dp[i]==-1) continue;
        if(dp[i-1]>=0){
            dp[i]+=dp[i-1];
            dp[i]%=mod;
        }
        if(i>=2&&dp[i-2]>=0){
            dp[i]+=dp[i-2];
            dp[i]%=mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	map<ll,int> mp;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		mp[a[i]]++;
	}
	bool ok = true;
	rep(i,n){
		if(mp[a[i]]>= 2) ok = false;
	}
	if(ok){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
    return 0;
}



Measured memory_bytes: 14336
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

void solve()
{
	int n;
	cin >> n;
	int count = 0;
	unordered_map<string, int> mp;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		mp[s]++;
		if (mp[s] == 1)
			count++;
	}
	cout << count << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("../input.txt", "r", stdin);
	freopen("../output.txt", "w", stdout);
#endif
	fast
	int t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 17644
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M, K;
string S[77];
vi va, vb;
pair<string, int> s[77];
string X;
void input() {
  cin >> N;
  rep(i, 0, N - 1) { cin >> s[i].first >> s[i].second; }

  cin >> X;

  ;
  ;
}
void solve() {
  int cnt = 0;
  int ind;
  rep(i, 0, N - 1) {
    if (s[i].first == X) ind = i;
  }
  rep(i, ind + 1, N - 1) { cnt += s[i].second; }
  cout << cnt << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] s = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
		}
		if (sum % 10 == 0) {
			Arrays.sort(s);
			for (int i = 0; i < n; i++) {
				if (s[i] % 10 != 0) {
					sum = sum - s[i];
					break;
				}
			}
		}
		if (sum % 10 != 0) {
			System.out.println(sum);
		} else {
			System.out.println(0);
		}
	}
}


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


int main()
{
  int n,x,i,p;
  cin>>x>>n;
  int m[1000]={0};
  for(i=0;i<n;i++)
  {
    cin>>p;
    m[p]++;
  }
  int dif=100000;
  int dif1;
  int ans;
  for(i=0;i<=110;i++)
  {
    dif1=x-i;
    if(dif1<0)
    {
      dif1=-dif1;
    }
    if(dif>dif1 && m[i]==0)
    {
      ans=i;
      dif=dif1;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 3620
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  int ans = 0;

  int num500 = X/500;
  ans += num500 * 1000;

  X -= 500 * num500;

  ans += (X/5)*5;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    int c = 0;
    int s[100000];
    cin >> a >> b;
    for(int j=0; j<a; j++){
        cin >> s[j];
    }
    for(int i=0; i<a; i++){
        if(s[i] >= b){
            c++;
        }
    }
    cout << c << endl;
}

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

using namespace std;

int main(){
	int a,fc=0,N,mini=0,mx=0;
	bool color[8]={0,0,0,0,0,0,0,0};
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a;
		if(a<400){color[0]=true;}
		else if(a<800){color[1]=true;}
		else if(a<1200){color[2]=true;}
		else if(a<1600){color[3]=true;}
		else if(a<2000){color[4]=true;}
		else if(a<2400){color[5]=true;}
		else if(a<2800){color[6]=true;}
		else if(a<3200){color[7]=true;}
		else{fc++;}
	}
	for(int i=0;i<8;i++){
		if(color[i]==true){
			mini++;mx++;
		}
	}
	cout << max(mini,1) << " " << mx+fc << endl;
	return 0;
}

Measured memory_bytes: 256
import queue

H, W=list(map(int, input().split()))
S = []
for _ in range(H):
    S.append( input() )

max_dist = 0
for h in range(H):
    for w in range(W):
        q = queue.Queue()
        visited=[[False for w in range(W)] for h in range(H)]
        q.put((h, w))
        visited[h][w]=True
        distance = {}
        distance[(h, w)]=0

        while not q.empty():
            x, y = q.get()
            if S[x][y]=='#':
                continue

            if 0<=x-1 and x-1<=H-1 and 0<=y and y<=W-1:
                if visited[x-1][y]==False and S[x-1][y]=='.':
                    visited[x-1][y]=True
                    q.put((x-1,y))
                    distance[(x-1,y)]=distance[(x,y)]+1
            if 0<=x and x<=H-1 and 0<=y-1 and y-1<=W-1:
                if visited[x][y-1]==False and S[x][y-1]=='.':
                    visited[x][y-1]=True
                    q.put((x,y-1))
                    distance[(x,y-1)]=distance[(x,y)]+1
            if 0<=x+1 and x+1<=H-1 and 0<=y and y<=W-1:
                if visited[x+1][y]==False and S[x+1][y]=='.':
                    visited[x+1][y]=True
                    q.put((x+1,y))
                    distance[(x+1,y)]=distance[(x,y)]+1
            if 0<=x and x<=H-1 and 0<=y+1 and y+1<=W-1:
                if visited[x][y+1]==False and S[x][y+1]=='.':
                    visited[x][y+1]=True
                    q.put((x,y+1))
                    distance[(x,y+1)]=distance[(x,y)]+1
        temp_max_dist = max(distance.values())
        if max_dist<temp_max_dist:
            max_dist = temp_max_dist
print(max_dist)


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

int main_()
{
    vector<int> mins;
    copy_n(istream_iterator<int>(cin), 5, back_inserter(mins));
    sort(mins.begin(), mins.end(), [](int a, int b) {
        return ((b % 10) == 0 ? 10 : (b % 10)) > ((a % 10) == 0 ? 10 : (a % 10));
    });
    int ans = accumulate(
        mins.begin() + 1, mins.end(), mins.front(),
        [](int acc, int n) {
            return acc + n + (((n % 10) > 0) ? (10 - n % 10) : 0);
        });

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int i,j,k;
    int count[4][3][10]; 
    int n, b,f,r,v;
    
    //?????????
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                count[i][j][k]=0;
            }
        }
    }
    
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        count[b-1][f-1][r-1]+=v;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d", count[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3) printf("####################\n");
    }
    
    
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    string s; cin >> s;
    ll res = 1;
    char pre = s[0];
    rep1(i,s.size()){
        if(s[i] != pre){
            pre = s[i];
            res++;
        }
    }
    cout << res -1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int dp[100005];  //! [i-th stair] => the combination count to reach the i-th stair
bool broken[100005];

int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    dp[0] = 1;
    if (!broken[1]) {
        dp[1] = 1;
    }
    for (int i = 2; i <= N; ++i) {
        if (broken[i]) {
            dp[i] = 0;
        } else {
            dp[i] = (dp[i-2] + dp[i-1]) % MOD;
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 768
eval"N,*A="+`dd`.split*?,;p N*2-1;b,a=A.minmax;N.times{|i|puts (a>-b ?[A.index(a)+1,i+1,i,i+1]:[A.index(b)+1,j=N-i,j+1,j])[0,4-2*1[i]]}

Measured memory_bytes: 4092
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

vector<pair<int, int> > edge[1000];
char str1[100];
char str2[100];
int dist[1000];

bool dfs(int now, int cost) {
  if (dist[now] != 0x0f0f0f0f) {
    return dist[now] == cost;
  }
  dist[now] = cost;
  FORIT(it, edge[now]) {
    if (!dfs(it->first, cost + it->second)) { return false; }
  }
  return true;
}

int main() {
  int n;
  while (scanf("%d", &n), n) {
REP(i, 1000) { edge[i].clear(); }
  map<string, int> open;
  int m = 0;
  REP(i, n) {
    int cost;
    scanf(" 1 %s = 10^ %d %s", str1, &cost, str2);
    if (!open.count((string)str1)) { open[(string)str1] = m++; }
    if (!open.count((string)str2)) { open[(string)str2] = m++; }
    int l = open[(string)str1];
    int r = open[(string)str2];
    edge[l].push_back(make_pair(r, -cost));
    edge[r].push_back(make_pair(l, cost));
  }
  MEMSET(dist, 0x0f);
  REP(i, m) {
    if (dist[i] != 0x0f0f0f0f) { continue; }
    if (dfs(i, 0)) {
    } else {
      puts("No");
      goto next;
    }
  }
  puts("Yes");
next:;
}
}

Measured memory_bytes: 0
#include <stdio.h>

int stack[100];
int n = 0;

int pop(void);
void push(int);

int main(){
  int a, b, x, y;
   while ((a = getchar())!='\n'){

     if (isdigit(a)){
       ungetc(a, stdin);
       scanf("%d", &b);
       push(b);
     }
     else {
       switch(a) {

       case '+':
	 x = pop();
	 y = pop();
	 push(x + y);
	 break;

       case '-':
	 x = pop();
	 y = pop();
	 push(y - x);
	 break;

       case '*':
	 push(pop()*pop());
	 break;

       }
     }
   }

   printf("%d\n",stack[1]);
   
   return 0;
  
}

int pop(){
  int A = stack[n];
  n--;
  return A;
}

void push(int p){
  n++;
  stack[n] = p;
}


  



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

using namespace std;
struct Edge {
    int next, to;
} edge[200005 << 1];
int head[200005], n, ss, vis[200005], minn;

inline void add(int x, int y) {
    static int cnt = 1;
    edge[cnt].to = y, edge[cnt].next = head[x], head[x] = cnt++;
}

void DFS(int x, int s) {
    if (s > minn)minn = s, ss = x;
    for (int i = head[x]; i; i = edge[i].next) {
        if (vis[edge[i].to] == 0)vis[edge[i].to] = 1, DFS(edge[i].to, s + 1);
    }
}

queue<int> que;

int main() {
    cin >> n;
    for (int i = 1, x, y; i < n; i++) {
        cin >> x >> y;
        add(x, y), add(y, x);
    }
    DFS(1, 0), minn = 0, memset(vis, 0, sizeof(vis)), DFS(ss, 0);
    if ((minn + 1) % 3 == 2)cout << "Second";
    else cout << "First";
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<map>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<cmath>
using namespace std;
long long lj,a,n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		lj+=a;
	}
	if(lj%2) cout<<"NO\n"; else cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = 0
cc = 0
for i in range(1,n+1):
    tmp = i
    cnt = 0
    while True:
        if tmp%2==0:
            tmp //= 2
            cnt += 1
        else:
            break
    if cnt >= cc:
        cc = cnt
        res = i
print(res)      

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

#define rep2(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) rep2(i,0,n)
#define all(a) a.begin(),a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n,k;cin >> n >> k ;
    string s; cin >> s;
    s[k-1] = s[k-1] + 'a' -'A';
    cout << s << endl;
    

    return 0;
}

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

int main(){
    int A[55] = {2, 7, 17, 37, 47,
                 67, 97, 107, 127, 137,
                 157, 167, 197, 227, 257,
                 277, 307, 317, 337, 347,
                 367, 397, 457, 467, 487,
                 547, 557, 577, 587, 607,
                 617, 647, 677, 727, 757,
                 787, 797, 827, 857, 877,
                 887, 937, 947, 967, 977,
                 997, 1087, 1097, 1117, 1187,
                 1217, 1237, 1277, 1297, 1307,
    };
    int N;
    cin >> N;
    rep(i, N){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <cstring>

int main(){
    std::string W, T;
    int Anser = 0;
    std::cin >> W;
    std::cin >> T;
    std::transform(W.begin(), W.end(), W.begin(), toupper);
    while(T != "END_OF_TEXT"){
        std::transform(T.begin(), T.end(), T.begin(), toupper);
        if(T == W) Anser++;
        std::cin >> T;
    }
    std::cout << Anser << std::endl;
    return 0;
}


Measured memory_bytes: 3164