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

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

using namespace std;

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

int main() {
    ll h, w;
    cin >> h >> w;
    string ans;
    rep(i, h) {
        rep(j, w) {
            string temp;
            cin >> temp;
            if (temp == "snuke") {
                ans += char('A' + j);
                ans += to_string(i + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3644
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include<queue>

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//2

int main(void) {
	int n,m,x;
	cin >> n >> m >> x;
	int az = 0, an = 0;
	rep(0, m) {
		int value = 0;
		cin >> value;
		if (value < x) az++;
		else if (x < value) an++;
	}
	cout << min(az, an) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

int main() {
	int v[100];
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	for (int i = n-1; i >= 0; --i) {
		if (i != n-1) cout << " ";
		cout << v[i];
	}
	cout << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int num, a, sum = 0, ma = 0, i = 0;
	cin >> num;
	for (; i < num; i++) {
		scanf("%d", &a);
		sum += a;
		ma = max(ma, a);
	}
	printf("%d\n", sum - (ma / 2));
	return 0;
}

Measured memory_bytes: 256
def resolve():
    H,N=(int(i) for i in input().split())
    magics=[[int(i) for i in input().split()] for j in range(N)]
    mx=2**31
    dpt=[mx for i in range(H+1)]
    dpt[-1]=0
    for i in range(H,0,-1):
        
        current=dpt[i]
        if current> dpt[0]:
            continue
        for m in magics:
            dpt[max(0,i-m[0])]=min(dpt[max(0,i-m[0])],current+m[1])
    print(dpt[0])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 41200
#include <iostream>
#include <vector>
#include <tuple>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long ll;

// d, t, i
using Sushi = tuple<ll, ll, ll>;

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

    vector<Sushi> all(n);
    vector<Sushi> best(n);
    set<ll> kinds;
    for(int i = 0; i < n; ++i){
        ll t, d;
        cin >> t >> d;
        t--;
        all.at(i) = make_tuple(d, t, i);
        kinds.insert(t);
        if(get<0>(best.at(t)) < d){
            best.at(t) = make_tuple(d, t, i);
        }
    }

    sort(all.begin(), all.end(), greater<Sushi>());

    vector<Sushi> best2;
    for(ll t : kinds){
        best2.push_back(best.at(t));
    }
    sort(best2.begin(), best2.end(), greater<Sushi>());

    vector<ll> cs_best2(best2.size(), 0);
    for(int i = 0; i < best2.size(); ++i){
        cs_best2.at(i) += get<0>(best2.at(i));
        if(i > 0){
            cs_best2.at(i) += cs_best2.at(i - 1);
        }
    }

    vector<ll> cs_all;
    for(int i = 0; i < all.size(); ++i){
        if(all.at(i) != best.at(get<1>(all.at(i)))){
            if(cs_all.size() == 0){
                cs_all.push_back(
                    get<0>(all.at(i))
                );
            }else{
                cs_all.push_back(
                    cs_all.back() + 
                    get<0>(all.at(i))
                );
            }
        }
    }

    ll ans = 0;
    for(ll i = 0; i < min(k, (ll)(cs_best2.size())); ++i){
        ll tmp = (i + 1) * (i + 1);
        tmp += cs_best2.at(i);
        if((k - i - 2) >= 0 && cs_all.size() > 0){
            tmp += cs_all.at(min(k - i - 2, (ll)(cs_all.size()) - 1));
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12788
while True:
    h, w = map(int, input().split())

    if h == 0 and w == 0:
        break

    c1 = '#'
    c2 = '.'
    for i in range(h):
        for j in range(w):
            if j % 2 == 0:
                print(c1, end='')
            else:
                print(c2, end='')
        print()
        c1, c2 = c2, c1
    print()


Measured memory_bytes: 7012
#include<iostream>

using namespace std;

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

int a[100];

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

for (int i = 0; i < n - 1; i++)
cout << a[n - 1 - i] << ' ';

cout << a[0];
cout << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

string s;
ll k;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> s >> k;
    ll vt = -1;
    FOR(i,0,sz(s)-1)
        if (s[i] != '1') {
            vt = i;
            break;
        }
    if (vt == -1) cout << 1;
    else {
        if (k <= vt) cout << 1;
        else cout << s[vt];
    }
    return 0;
}


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

int main(void) {

    int N, M, P;
    while (cin >> N >> M >> P, N || M || P) {
        vector<int> X(N);
        double sum = 0;
        for (int i = 0; i < N; i++) {
            cin >> X[i];
            sum += X[i]*100;
        }

        sum -= sum*(P/100.0);

        if (X[M-1] != 0) {
            cout << floor(sum/X[M-1]) << endl;
        } else {
            cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3220
#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 in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

vi c1, c2;
vvi adj1, adj2;

void dfs1(int node, int color) {
	if(c1[node]) return;
	else c1[node] = color;
	for(int i : adj1[node]) dfs1(i, color);
}

void dfs2(int node, int color) {
	if(c2[node]) return;
	else c2[node] = color;
	for(int i : adj2[node]) dfs2(i, color);
}

void solve() {
	int n, k, l;
	cin >> n >> k >> l;
	
	c1.resize(n, 0); c2.resize(n, 0);
	adj1.resize(n); adj2.resize(n);
	
	for(int i = 0; i < k; i++) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		
		adj1[p].pub(q);
		adj1[q].pub(p);
	}
	
	for(int i = 0; i < l; i++) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		
		adj2[r].pub(s);
		adj2[s].pub(r);
	}
	
	for(int i = 0; i < n; i++) {
		dfs1(i, i + 1);
		dfs2(i, i + 1);
	}
	
	map<ii, int> cnt;
	for(int i = 0; i < n; i++) {
		cnt[{c1[i], c2[i]}]++;
	}
	
	for(int i = 0; i < n; i++) {
		cout << cnt[{c1[i], c2[i]}] << " ";
	}
	
	cout << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int H, N; cin >> H >> N;
    int weight[N+1], value[N+1];
    rep(i, N){
        cin >> value[i+1] >> weight[i+1];
    }
    int max_value = 0;
    rep(i, N) max_value = max(max_value, value[i+1]);
    int loop = (H+1) + max_value;
    int dp[loop][N+1];
    for(int i = 0; i < loop; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = mod;
        }
    }
    for(int i = 0; i <= N; i++) dp[0][i] = 0;
    for(int i = 1; i < loop; i++){
        for(int j = 1; j <= N; j++){
            //商品jを使って価値i以上を実現する最小コスト
            if(i - value[j] >= 0) dp[i][j] = min(dp[i][j-1], dp[i-value[j]][j] + weight[j]);
            else dp[i][j] = dp[i][j-1];
        }
    }
    int ans = dp[H][N];
    for(int i = H+1; i < loop; i++) ans = min(ans, dp[i][N]);
    cout << ans << endl;
    return 0;
}

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

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

void solve(){
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++){
		dp[i][0] = dp[i-1][0] * p[i];
		dp[0][i] = dp[0][i-1] * (1.0-p[i]);
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j + i <= n; j++){
			dp[i][j] = dp[i-1][j] * p[i+j] + dp[i][j-1] * (1.0-p[i+j]);
		}
	}
//	for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) 
//		printf("%.5lf%c",dp[i][j], " \n"[j==n]);
	double ans = 0;
	for (int i = n; i > n-i; --i){
		ans += dp[i][n-i];
	}
	printf("%.12lf\n",ans);
}
int main(){
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		scanf("%lf",p+i);
	solve();
	return 0;
}


Measured memory_bytes: 70016
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n;
	vector<int> cubic, tetra;
	const int MAX = 1512000;
	for (int i = 0; i*i*i <= MAX; ++i)
		cubic.push_back(i*i*i);
	for (int i = 0; i*(i+1)*(i+2)/6 <= MAX; ++i)
		tetra.push_back(i*(i+1)*(i+2)/6);

	while (cin >> n, n)
	{
		int res = 0;
		for (int i = 0; i < cubic.size(); ++i)
			for (int j = 0; j < tetra.size() && cubic[i] + tetra[j] <= n; ++j)
				max_swap(res, cubic[i] + tetra[j]);
		cout << res << endl;
	}
}

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

int main() {
	int N ;
	cin >> N;
	vector<int>X(N);
	vector<int>Y(N);
	vector<int>H(N);
	int i;
	for (int n = 0;n<N;++n) {
		cin >> X[n] >> Y[n] >> H[n];
		if (H[n] > 0) {
			i = n;
		}
	}
	for (int x = 0;x<=100;++x) {
		for (int y = 0;y<=100;++y) {
			bool next = true;
			int High = H[i] + abs(X[i] - x) + abs(Y[i] - y);
			for (int n = 0;n<N;++n) {
				if ((H[n]>0)&&(High != H[n] + abs(X[n] - x) + abs(Y[n] - y))) {
					next = false;
					break;
				}
				if ((H[n]==0)&&((High > abs(X[n] - x) + abs(Y[n] - y)))) {
					next = false;
					break;
				}
			}
			if(next){
				cout << x<<" "<<y<<" "<<High<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
    ll k;
    cin >> k;
    if (k == 1 || k == 7) {
        cout << 1 << endl;
        return 0;
    }
    ll num = 7;
    for (ll a = 1; a <= k; a++) {
        if (num == 0) {
            cout << a << endl;
            return 0;
        }
        num *= 10;
        num += 7;
        num %= k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

int N;
vector<long long> A;
vector<long long> sum;

int main() {
    cin >> N; 
    A.resize(N); sum.resize(N+1); sum[0] = 0;
    for (int i = 0; i < N; ++i) cin >> A[i], sum[i+1] = sum[i] + A[i];

    long long res = 1LL<<60;
    for (int i = 0; i <= N; ++i) {
        // P < Q となる最大の切れ目を求める: 二分探索を終えた時の left_low
        int low = 0, high = i;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (sum[mid] >= sum[i] - sum[mid]) high = mid;
            else low = mid;
        }
        long long P = sum[low], Q = sum[i] - sum[low]; // 候補1
        long long P2 = sum[high], Q2 = sum[i] - sum[high]; // 候補2
        long long left_min = min(P, Q), left_max = max(P, Q);
        if (abs(P2-Q2) < abs(P-Q)) left_min = min(P2, Q2), left_max = max(P2, Q2);

        // R < S となる最大の切れ目を求める
        low = i, high = N;
        while (high - low > 1) {
            int mid = (low + high) / 2;
            if (sum[mid] - sum[i] >= sum[N] - sum[mid]) high = mid;
            else low = mid;
        }
        long long R = sum[low] - sum[i], S = sum[N] - sum[low]; // 候補1
        long long R2 = sum[high] - sum[i], S2 = sum[N] - sum[high]; // 候補2
        long long right_min = min(R, S), right_max = max(R, S);
        if (abs(R2-S2) < abs(R-S)) right_min = min(R2, S2), right_max = max(R2, S2);

        // 真ん中の切れ目が i であるときの暫定解
        long long tmp = max(left_max, right_max) - min(left_min, right_min);
        res = min(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
ll inf = 100000000000001;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int mt[9] = {2,5,5,4,5,6,3,7,6};
int miti[100001];
ll solve(ll se,ll sw,ll te,ll tw,ll x){
   // cout<<se<<" "<<sw<<" "<<te<<" "<<tw<<endl;
    ll s[2]={se,sw};ll t[2]={te,tw};
    ll a1=abs(x-max(se,te))+abs(se-te);
    ll a2=abs(x-min(sw,tw))+abs(sw-tw);
    ll a3=abs(tw-se)+min(abs(x-se),abs(tw-x));
    ll a4=abs(te-sw)+min(abs(x-sw),abs(te-x));
    return min({a1,a2,a3,a4});
}


int main(){
   
    ll A,B,Q;
    cin>>A>>B>>Q;
    
    vector<ll> s(A);vector<ll> t(B);
    rep(i,A){
        cin>>s[i];
    }
    rep(i,B){
        cin>>t[i];
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    
    rep(i,Q){
        ll x;
        cin>>x;
        ll se,sw,te,tw;
        if(x>=s[A-1]){se=s[A-1];sw=inf;
        }else if(x<=s[0]){se=inf;sw=s[0];
        }else{
            se=s[lower_bound(s.begin(),s.end(),x)-s.begin()-1];
            sw=s[lower_bound(s.begin(),s.end(),x)-s.begin()];
        }
        if(x>=t[B-1]){te=t[B-1];tw=inf;
        }else if(x<=t[0]){te=inf;tw=t[0];
        }else{
            te=t[lower_bound(t.begin(),t.end(),x)-t.begin()-1];
            tw=t[lower_bound(t.begin(),t.end(),x)-t.begin()];
        }
    
    cout<<solve(se,sw,te,tw,x)<<endl;
    }
    
return 0;
}


Measured memory_bytes: 2944
n = int(input())

def NumToAlpha(n):
    if n<=26:
        return chr(96+n)
    elif n%26==0:
        return NumToAlpha(n//26-1)+chr(122)
    else:
        return NumToAlpha(n//26)+chr(96+n%26)
        
N = NumToAlpha(n)
print(N)

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
set<string> s;
void solve()
{
	ll n;
	cin>>n;
	string str;
	for(ll i=0;i<n;i++)
	{
		cin>>str;
		s.insert(str);
	}
	cout<<s.size();
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 19216
#include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

int CreateKeta(int keta){
	int i;
	int Output = 1;
	for(i = 0 ; i < keta ; i++)
		Output *= 10;

	return Output;
}

int main(){
	stack<int> st;
	int k;
	int i,j;
	int keta;
	int result;
	bool IsNum = false;
	char c;
	while(scanf("%c", &c) != EOF)
	{
		if(c == '\n')
		{
			break;
		}
		else if(c == ' ')
		{
			IsNum = false;
		}
		else if(c == '+') /* ?¶??????? */
		{
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i + j;
			st.push(result);

		}
		else if ( c == '-') /* ????????? */
		{
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = j - i;
			st.push(result);

		} 
		else if ( c == '*') /* ????????? */
		{
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i * j;
			st.push(result);

		}
		else /* ??°??? */
		{
			k = (int)(c - '0');
			if (IsNum)
			{
				i = st.top();
				st.pop();
				k = (i * 10) + k;
				st.push(k);

			} else
			{
			st.push(k);
			IsNum = true;
			}
		}
	}
	cout << st.top() << endl;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <algorithm>

using namespace std;

int n,m,r;
int a,b,c;
int d[200][200];
int R[8];
bool used[8];
int sum=0;
int res =100000000;
void dfs(int c, int las, int dist){
  if(c==r+1){
    if(res>dist) res=dist;
    return;
  }
  for(int i=0;i<r;i++){
    if(!used[i]){
      used[i]=true;
      if(las==-1) dfs(c+1,i,0);
      else dfs(c+1,i,dist+d[R[las]-1][R[i]-1]);
      used[i]=false;
    }
  }
}
int main(){
  scanf("%d %d %d",&n,&m,&r);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j){
        d[i][j]=0;
      }else{
        d[i][j] = 100000000;
      }
    }
  }
  for(int i=0;i<r;i++){
    scanf("%d",&R[i]);
  }
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    d[a-1][b-1] = c;
    d[b-1][a-1] = c;
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  for(int i=0;i<r;i++){
    used[i]=false;
  }
  dfs(1,-1,0);
  printf("%d\n", res);
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H =  list(map(int, input().split()))
T = [0]*N

for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        T[B-1] += 1
    elif H[A-1] <H[B-1]:
        T[A-1] += 1
    else:
        T[A-1] += 1
        T[B-1] += 1

print(T.count(0))

Measured memory_bytes: 20116
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int coin = 0;
    if(a>=b){
      coin = coin + a;
      if(a-1>=b){
        coin = coin + (a-1);
      }else{
        coin = coin + b;
      }
    }else{
      coin = coin + b;
      if(b-1>=a){
        coin = coin + (b-1);
      }else{
        coin = coin + a;
      }
    }
    System.out.println(coin);
 }
}

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    int len = s.size();
    s = '1' + s;
    for(int i=1; i<1+len; i++){
        if(s[i] == s[i+1]){
            printf("%d %d\n", i, i+1);
            return 0;
        }
        else if(s[i] == s[i+2]){
            printf("%d %d\n", i, i+2);
            return 0;
        }
    }

    printf("-1 -1\n");

}

Measured memory_bytes: 512
#include <stdio.h>

int top(int x){
   while (x>=10) x/=10;
   return x;
}

int main(){
   int n,i,a,b,j;
   long ans;
 
   scanf("%d",&n);
   ans=0;
   for (i=n;i>0;i--) {
      a=top(i);
      b=i%10;
      if (b==0) continue;
      j=b*100000+a;
      if (j+99990<=n) ans+=10000;
      else if (j<=n) ans+=(n-j+10)/10;
      j=b*10000+a;
      if (j+9990<=n) ans+=1000;
      else if (j<=n) ans+=(n-j+10)/10;
      j=b*1000+a;
      if (j+990<=n) ans+=100;
      else if (j<=n) ans+=(n-j+10)/10;
      j=b*100+a;
      if (j+90<=n) ans+=10;
      else if (j<=n) ans+=(n-j)/10;
      j=b*10+a;
      if (j<=n) ans++;
      if (a==b) {
         j=a;
         if (j<=n) ans++;
      }
   }
   printf("%ld\n",ans);
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }
int prime[250000];
bool is_prime[250000+1];
int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++) is_prime[i]=1;
	is_prime[0]=is_prime[1]=0;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i) is_prime[j]=0;
		}
	}
	return p;
}
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		cout<<sieve(2*n)-sieve(n)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3396
<?php
    fscanf(STDIN,"%d %d",$a1,$b1);
    fscanf(STDIN,"%d %d",$a2,$b2);
    fscanf(STDIN,"%d %d",$a3,$b3);
    $c =array();
    $c[$a1]++;
    $c[$a2]++;
    $c[$a3]++;
    $c[$b1]++;
    $c[$b2]++;
    $c[$b3]++;
    
    $d=0;
    for($i=1;$i<=4;$i++){
      if($c[$i]==3){
        $d=1;
      }
    }
    if($d==1){
      printf("NO\n");
    }else{
      printf("YES\n");
    }
  ?>

Measured memory_bytes: 4604
ab_list = list(map(int, input().split()))

if ab_list[0] == ab_list[1]:
    print("Draw")
elif ab_list[0] == 1:
    print("Alice")
elif ab_list[1] == 1:
    print("Bob")
elif ab_list[0] > ab_list[1]:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <boost/algorithm/string.hpp>
using namespace std;


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


#define Vec(a) vector<a>

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

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

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN


void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }
ll fact(int n ){

long long fact =1;

for (int i =2 ;i<=n;++i)

{
    fact*=i;
}
return fact;
}


ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int a[4];

int main()
{
    init();

    int n,a, b; cin>>n>>a>>b;

    for(int i = a ; i<=b ;++i)

    {
        if (i %n == 0) {cout << "OK" ;return 0;}
    }

    cout << "NG";
}



Measured memory_bytes: 3696
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i = 0; i < N - 1; i++) cin >> B[i];
    vector<int> A(N);
    A[0] = B[0];
    A.back() = B.back();
    for(int i = 1; i < N - 1; i++){
        A[i] = min(B[i - 1], B[i]);
    }
    int sum = 0;
    for(int a : A) sum+= a;
    cout << sum << endl;
}

Measured memory_bytes: 3612
import numpy as np
n = int(input())
a = list(map(int, input().split()))
flag = 0
mizu = 0

while True:

    for b in range(n):
        if a[b] == 0 and flag == 1:
            break

        if a[b] > 0:
            a[b] -= 1
            flag = 1
    
    if flag == 1:
        mizu += 1
        flag = 0
    else: break

print(mizu)

Measured memory_bytes: 12664
import math
N = int(input())
A = sorted([int(_) for _ in input().split()], reverse=True)
dp = {}
for a in A:
    dp[a] = dp.get(a, 0) + 1
ans = 0
for a in A:
    if dp[a]:
        dp[a] -= 1
        if dp.get(2**int(math.log2(a) + 1) - a, 0) > 0:
            dp[2**int(math.log2(a) + 1) - a] -= 1
            ans += 1
print(ans)


Measured memory_bytes: 33168
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main ()
{
	int n, p;
	while (readf (" %s %s", &n, &p) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		auto f = new long [2] [n + 1];
		f[0][0] = 1;
		foreach (i; 0..n)
		{
			foreach (j; 0..2)
			{
				f[i + 1][(j + a[i]) & 1] += f[i][j];
				f[i + 1][j] += f[i][j];
			}
		}
		writeln (f[n][p]);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int S;
  cin >>S;
  int a,b;
  a = S/100;
  b = S%100;
  if(1<=a&&a<=12){
    if(1<=b&&b<=12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else{
    if (1<=b&&b<=12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int a[n];

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + n);

    long long mid = a[n/2];//(n%2 ? a[n/2] : (a[n/2] + a[n/2]) / 2);

    long long sum = 0;
    for(int i = 0; i < n; ++i) sum += abs(a[i] - mid);
    cout << sum;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int l=0,r=n-1;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  //bool flag
  while(r-l>=1){
    if(s[l]==s[r]){
      l++;
      r--;
    }else if(s[l]=='x'){
      l++;
      ans++;
    }else if(s[r]=='x'){
      r--;
      ans++;
    }else{
      ans = -1;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
N, K = map(int,input().split())

A = list(map(int,input().split()))

"""

for i in range(len(A)):
    if A[i] == 1:
        point = i

left = point
right = N - point - 1

ans = 0

if left % (K-1) == 0:
    ans += left // (K - 1)
else:
    ans += left // (K - 1) + 1

if right % (K-1) == 0:
    ans += right // (K - 1)
else:
    ans += right // (K - 1) + 1
"""

if (N - 1) % ( K - 1 ) == 0:
    ans = (N-1) // (K-1)
else:
    ans = (N-1) // (K-1) + 1

print (ans)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 1e5 + 55;
int n;
int a[N], b[N];
void solve() {
	cin >> n; 
	for (int i = 1; i <= n + 1; ++i)
		cin >> a[i];
	for (int i = 1; i <= n; ++i)
		cin >> b[i];
	int kill = 0;
	for (int i = 1; i <= n; ++i) {
		int here_kill = min(a[i], b[i]);
		kill += here_kill;
		a[i] -= here_kill;
		b[i] -= here_kill;
		here_kill = min(a[i + 1], b[i]);
		kill += here_kill;
		a[i + 1] -= here_kill;
		b[i] -= here_kill;
	}
	cout << kill;
}	

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

using namespace std;

string s;

bool is_pal (string s) {
	string rs = s;
	reverse(rs.begin(), rs.end());
	return (rs == s);
}

int main() {

	cin >> s;

	bool flag = false;

	if (is_pal(s)) {
		int l = s.length();
		string a = s.substr(0, (l - 1) / 2);
		string b = s.substr((l + 3) / 2 - 1);
		if (is_pal(a) && is_pal(b)) {
			flag = true;
		}
	}

	cout << ((flag) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> sum(n);
  sum[0] = a[0];
  for(int i=1;i<n;i++) sum[i]= sum[i-1]+a[i];
  ll max_sum = sum[k-1];
  for(int i =1; i<(n-k+1);i++){
    max_sum=max(sum[i+k-1]-sum[i-1],max_sum);
    //cout << sum[i+k-1]-sum[i-1] << endl;
  }
  double ans = max_sum+k;
  ans /=2;
  cout<<setprecision(25)<<ans<<endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int d = Integer.parseInt(str[0]);
    int x = Integer.parseInt(str[1]);
    int[] a = new int[n];
    int sum = 0;
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
      for(int j=0; (j*a[i]+1)<=d; j++) {
        sum++;
      }
    }
    System.out.println(sum+x);
  }
}

Measured memory_bytes: 32712
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost; 
    map<int,int> mp; 
    rep(i,1,10)
    {
        rep(j,1,10)
        {
            mp[i*j]=1;
        }
    }
    cin>>n;
    if(mp[n])cout<<"Yes";
    else cout<<"No";
    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    int cnt = 0, ans = 0;

    rep(i, N) {
        cnt = 0;
        if (i % 2 != 0) {
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    cnt++;
                }
                if (j == i && cnt == 8) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
 
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 1000000007;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int digit(int a){
    int ans = 0;
    while(a!=0){
        ans++;
        a/=10;
    }
    return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    a[0]--;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            cout << "No" << endl;
            return 0;
        }
        if(a[i]>a[i-1])a[i]--;
    }
    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
 
        int h = Integer.parseInt(s1[0]);
        int w = Integer.parseInt(s1[1]);
 
        String s[][] = new String[h][w];
        for (int i = 0;i < h;i++) {
        	String row = sc.nextLine();
        	for (int j = 0;j < w;j++) {
        		s[i][j]=String.valueOf(row.charAt(j));
        	}
        }
 
        String result="Yes";
        for (int i = 0;i < h;i++) {
        	for (int j = 0;j < w;j++) {
        		if (".".equals(s[i][j])) {
        			continue;
        		}
        		boolean flg=false;
        		//上
        		if (i != 0 && s[i][j].equals(s[i-1][j])) {
        			flg=true;
        		}
        		//下
        		if (i != h-1 && s[i][j].equals(s[i+1][j])) {
        			flg=true;
        		}
        		//左
        		if (j != 0 && s[i][j].equals(s[i][j-1])) {
        			flg=true;
        		}
        		//右
        		if (j != w-1 && s[i][j].equals(s[i][j+1])) {
        			flg=true;
        		}
 
        		if (flg==false) {
        			result="No";
        		}
        	}
        }
 
        System.out.println(result);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll now = 1;
    ll res = 0;
    rep(i, n) {
        if(a[i] == now) now++;
        else res++;
    }
    if(res == n) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long sum = 0;

        for(int i=1;i<=N;i++){
            if(i%3==0) {
                sum += 0;
            } else if(i%5==0) {
                sum += 0;
            } else {
                sum += i;
            }
        }

        System.out.println(sum);
        sc.close();
    }

}


Measured memory_bytes: 35800
from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
visited = [[0 for i in range(w)] for j in range(h)] # いったところ
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque([(Ch, Cw)])
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]

while True:
  # 移動A
  stemp = set()
  while len(d) != 0:
    Th, Tw = d.popleft()
    # s.add((Th, Tw))
    stemp.add((Th, Tw))
    if (Th,Tw) == (Dh, Dw):
      print(ans)
      exit()
    for i, j in a:
      _h,_w = Th + i, Tw + j
      _p = (_h, _w)
      if 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
        d.append(_p)
        visited[_h][_w] = 1
  # 移動B
  ans += 1
  for Th,Tw in stemp:
    for i in range(-2, 3) :
      for j in range(-2, 3) :
        _h,_w = Th + i, Tw + j
        _p = (_h, _w)
        if 0 <= _h < h and 0 <=  _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
          d.append(_p)
          visited[Th][Tw] = 1
  if len(d) == 0:
    print('-1')
    exit()


Measured memory_bytes: 187836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
int main() {
	int N, A, B;
	std::cin >> N;
	int sum = 0;
	std::vector<int>a(N);
	for (int i = 0;i < N;++i) {
		std::cin >> a[i];
		A = *std::max_element(a.begin(), a.end());
		B = A / 2;
		sum += a[i];
	}
	std::cout << sum - B << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	ll x, y;
	cin >> x >> y;
	int ans = 0;
	while(x <= y) {
		x <<= 1;
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b,ans=0,x;
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++){
        x= (i/10000)+((i%10000)/1000)+((i%1000)/100)+((i%100)/10)+(i%10);
        if(a<=x && b>=x){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    bool cb;
    cb = true;
    for (int i = A; i < D - 1; i++)
    {

        if ((S[i - 1] == '#') && (S[i] == '#'))
        {
            cb = false;
            break;
        }
    }
    if (cb == false)
    {
        cout << "No" << endl;
        return 0;
    }
    if (C > D)
    {
        bool check = false;
        for (int i = B - 1; i < D; i++)
        {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
            {
                check = true;
            }
        }
        if (check)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll x,a;
	cin>>x>>a;
	if(x<a)
	cout<<0;
	else
	cout<<10;
}

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

int main(){
    string s;
    cin >> s;
    if(s.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    int l = 0, r = s.size() - 1;
    int cnt = 0;
    while(l < r){
        if(s[l] == s[r]) l++, r--;
        else{
            cnt++;
            if(s[l] != 'x' && s[r] != 'x'){
                cout << -1 << endl;
                return 0;
            }
            if(s[l] == 'x') l++;
            else if(s[r] == 'x') r--;          
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int a;
    cin >> a;
    a %= 10;
    if (a == 3)cout << "bon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8)cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3596