akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int h,w;cin>>h>>w;
	vector<vector<char> >grid(h,vector<char>(w));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>grid[i][j];
		}
	}
	int p = 1000000007;
	int dp[h+1][w+1];
	for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			dp[i][j] = 0;
		}
	}
	dp[1][1] = 1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i != 1 || j != 1){
				if(grid[i-1][j-1] != '#')
				dp[i][j] = (dp[i-1][j]%p+dp[i][j-1]%p)%p;
			}
		}
	}
	if(h == 1 && w == 1){
		cout<<0;
	}
	else{
		cout<<dp[h][w];
	}
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

template <typename T>
struct edge {
	int from, to;
	T cost;
	edge (int f, int t, T c) : from(f), to(t), cost(c) {}
};

template <typename T>
struct BellmanFord {
	T INF;
	int V;
	vector<edge<T>> edges;
	vector<T> d;
	BellmanFord(vector<edge<T>> e, int v, T inf) :
		edges(e), V(v), INF(inf), d(v, inf)
	{}

	bool find_negative_loop() {
		for (int i = 0; i < V; ++i) { d[i] = 0; }
		for (int i = 0; i < V; ++i) {
			for (auto e : edges) {
				if (d[e.to] > d[e.from] + e.cost) {
					if (i == V - 1) { return true; }
					d[e.to] = d[e.from] + e.cost;
				}
			}
		}
		return false;
	}
	bool run(int s) {
		for (int i = 0; i < V; ++i) { d[i] = INF; }
		d[s] = 0;

		for (int i = 0; i < V; ++i) {
			bool update = false;
			for (auto e : edges) {
				if (d[e.from] == INF || d[e.to] <= d[e.from] + e.cost) {
					continue;
				}
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
			if (!update) { return true; }
		}
		return false;
	}
	T dist(int v) { return d[v]; }
};

void dfs(int v, const vector<vector<int>>& g, vector<bool>& visited) {
	visited[v] = true;
	for (int u : g[v]) {
		if (!visited[u]) { dfs(u, g, visited); }
	}
}

int main() {
	int N, M; Int P;
	cin >> N >> M >> P;
	vector<vector<int>> rG(N);
	vector<edge<Int>> E;
	for (int i = 0; i < M; ++i) {
		int a, b; Int c;
		cin >> a >> b >> c;
		--a; --b;
		rG[b].push_back(a);
		E.emplace_back(a, b, -(c - P));
	}

	vector<bool> visited(N, false);
	dfs(N - 1, rG, visited);

	vector<edge<Int>> edges;
	for (auto e : E) {
		if (visited[e.from] && visited[e.to]) { edges.push_back(e); }
	}

	BellmanFord<Int> bf(edges, N, 1e10);
	if (bf.run(0)) {
		cout << max(Int(0), -bf.dist(N - 1)) << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 768
import math
def isprime(x):
  if x == 2:
    return True

  if x < 2 or x % 2 == 0:
    return False

  i = 3
  while i <= math.sqrt(x):
    if x % i == 0:
      return False
    i = i + 2

  return True


count = 0
n = int(input())
for i in range(0, n):
  if isprime(int(input())):
    count += 1

print(count)

Measured memory_bytes: 7776
n,k = map(int,input().split())
s = input()
flag = [0]*n
f = s[0]
cnt  = 0
for i,t in enumerate(s):
    if t == 'L':
        if i != 0 and s[i-1] == 'L':
            flag[i] = 1
    if t == 'R':
        if i != n-1 and s[i+1] == 'R':
            flag[i] = 1
    if t == f and i != n-1 and s[i+1] != f:
        cnt += 1
ans = sum(flag)
if s[-1] == f:
    ans += min(k,cnt)*2
else:
    ans += 2*cnt - 1 if cnt <= k else 2*k
print(ans)


Measured memory_bytes: 41584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int N,tmp,ans;
    int x[3][100005];
    cin>>N;  
    for(int i=0;i<N;i++){
        cin >>x[0][i];
    }
    for(int i=0;i<N;i++){
        cin >>x[1][i];
    }

    for(int i=0;i<N;i++){
        tmp=0;
        for(int j=0;j<=i;j++){
            tmp+=x[0][j];
        }
        for(int j=i;j<N;j++){
            tmp+=x[1][j];
        }
        if(ans<tmp){
            ans=tmp;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MAXN = 2e5 + 5;
LL ans , vis[MAXN] , res , num;
LL N , X , M;

int main() {
	scanf("%lld %lld %lld" , &N , &X , &M);
	vis[X] = 1;num = 1;
	LL tmp = X;
	while(1) {
		X = X * X % M;
		num ++;
		if(vis[X]) break;
		vis[X] = num; 
	}
	LL now = 0;
	for (int i = 1; i < vis[X]; ++i) now += tmp , tmp = tmp * tmp % M;
	LL cir = 0 , cur = X , siz = num - vis[X];
	for (int i = 1; i <= siz; ++i) cir += cur , cur = cur * cur % M;
	LL ans = (N - vis[X] + 1) / siz * cir + now;
	N = (N - vis[X] + 1) % siz;
	while(N -- > 0) ans += X , X = X * X % M;
	printf("%lld" , ans);
	return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
typedef long long lint;
const int N=2e5+5;
int n,lnk[N];
char str[N];
std::vector <int> cbuk[26];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace B{
	int tr[N];
	inline void add(int x,const int v){
		for(; x<=n; x+=x&-x) tr[x]+=v;
	}
	inline int ask(int x){
		int ans=0;
		for(; x; x-=x&-x) ans+=tr[x];
		return ans;
	}
}

lint solve(){
	for(int cnt=0,i=0; i<26; ++i){
		if(cbuk[i].size()&1){
			if(cnt++) return -1;
		}
		const int sz=cbuk[i].size();
		for(int j=0; j<<1<sz; ++j){
			lnk[cbuk[i][j]]=cbuk[i][sz-1-j];
		}
	}
	lint ans=0;
	for(int cnt=0,i=1; i<=n; ++i){
		//i+B::ask(i)意义不明
		if(lnk[i]==i&&cnt<n>>1){
			++lnk[i];
			std::swap(lnk[i+1],lnk[i]);
			if(lnk[i]) ++ans;
		}
		if(!lnk[i]||lnk[i]==i) continue;
		++cnt;
		int lp=i+B::ask(i),rp=lnk[i]+B::ask(lnk[i]);
		int tgt=n-lp+1;
		assert(rp<=tgt);
		B::add(lnk[i],-1);
		ans+=tgt-rp;
	}
	return ans;
}

int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1; i<=n; ++i){
		cbuk[str[i]-'a'].push_back(i);
	}
	printf("%lld\n",solve());
	return 0;
}


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

string S;

int main(void) {
  cin >> S;

  ll ans = S.length();
  REP(i, 0, S.length() - 1) {
    if(S[i] != S[i + 1]) {
      ans = min(ans, max(i + 1, (ll) S.length() - (i + 1)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<set>
#include<unordered_map>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	int n;
	cin>>n;
	cout<<(n^1);


}



Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_146
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            long n = nk[0];
            long k = nk[1];
            long[] array = ReadLongs();
            if (k == 1)
            {
                WriteLine(0);
                return;
            }
            for (int i = 0; i < n; i++) array[i] = (array[i] + k - 1) % k;
            long[] sum = new long[n];
            sum[0] = array[0];
            for (int i = 1; i < n; i++) sum[i] = (sum[i - 1] + array[i]) % k;
            var dict = new Dictionary<long, long>();
            dict.Add(0, 1);
            long res = 0;
            for(int i = 0; i < n; i++)
            {
                if (dict.ContainsKey(sum[i]))
                {
                    res += dict[sum[i]];
                    dict[sum[i]]++;
                }
                else
                {
                    dict.Add(sum[i], 1);
                }
                if (i == k - 2)
                {
                    dict[0]--;
                    if (dict[0] == 0) dict.Remove(0);
                }
                if (i >= k - 1)
                {
                    dict[sum[i - k + 1]]--;
                    if (dict[sum[i - k + 1]] == 0) dict.Remove(sum[i - k + 1]);
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 47460
#include <stdio.h>
#include <inttypes.h>

int N;
int A[114514];
int Q;
int B[114514];
int C[114514];

int count[114514];

int main(void) {
	int i;
	int64_t wa;
	int saidai = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		if (A[i] > saidai) saidai = A[i];
	}
	if (scanf("%d", &Q) != 1) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d%d", &B[i], &C[i]) != 2) return 1;
		if (B[i] > saidai) saidai = B[i];
		if (C[i] > saidai) saidai = C[i];
	}
	for (i = 0; i < N; i++) count[A[i]]++;

	wa = 0;
	for (i = 0; i <= saidai; i++) wa += (int64_t)i * count[i];

	for (i = 0; i < Q; i++) {
		int64_t hiku, tasu;
		hiku = (int64_t)B[i] * count[B[i]];
		tasu = (int64_t)C[i] * count[B[i]];
		wa = wa - hiku + tasu;
		count[C[i]] += count[B[i]];
		count[B[i]] = 0;
		printf("%" PRId64 "\n", wa);
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 384
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 10000009
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// ============================================================


int main() {
    get3(n,d,a);
    vector<pll> A(n);
    vector<ll> B(n), st(n+5,0);

    rep(i,n) {
        get2(b,c);
        A[i] = {b,c};
    }
    sort(ALL(A));
    rep(i,n) {
        B[i] = A[i].fi;
    }
    ll maxd = B[n-1];

    ll curr = 0, ans = 0;
    rep(i,n) {
        curr += st[i];
        if(curr>=A[i].se) continue;
        else {
            ll diff = A[i].se-curr;
            ll q = (ll)ceil(diff/(double)a);
            ans+=q;
            ll idx = upper_bound(ALL(B),B[i]+2*d)-B.begin();
            st[idx] -= a*q;
            curr += a*q;
        }
    }

    printf("%lld\n", ans);
    return 0;  
}   

Measured memory_bytes: 6528
N = int(input())

S = {}
s = 0
n = 1
while s <= N:
    S[s] = n
    s += n
    n += 1

if N not in S.keys():
    print("No")
else:
    print("Yes")
    k = S[N]
    res = [[] for i in range(k)]

    num = k - 1
    now = 1
    for i in range(k - 1):
        num = k - 1 - i
        res[i] += [now + p for p in range(num)]
        for r in range(num):
            res[i + r + 1].append(now + r)

        now += num

    print(k)
    for l in res:
        print("{0} {1}".format(str(k - 1), " ".join(map(str, l))))

Measured memory_bytes: 12348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N;
    cin >> N;
    ll A[100000], ans = 0, min = LLONG_MAX;
    for(int i=0;i<N;i++){
        cin >> A[i];
        ans += abs(A[i]);
        if(abs(A[i]) < min)
            min = abs(A[i]);
    }
    
    
    vector<ll> vec;
    for(int i=0;i<N;i++){
        if(A[i] < 0)
            vec.push_back(A[i]);
    }
    int size = vec.size();
    // 降順ソート
    sort(A, A + N, greater<int>());
    
    
    if(size % 2 == 0)
        cout << ans << endl;
    else
        cout << ans - 2*min << endl;
    
}

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

#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int> 

int main(){
    int n;
    cin>>n;
    int a,b;
    pair<int,int> ans[n];
    for(int i=0;i<n;i++){
        cin>>a>>b;
        ans[i].ff = b;
        ans[i].ss = a;
    }
    sort(ans,ans+n);
    int sum =0;
    int flg = 1;
    for(int i=0;i<n;i++){
        sum += ans[i].ss;
        if(sum>ans[i].ff){
            flg =0;
            break;
        }
    }
    if(flg) cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
}

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

using namespace std; 

int arr[1005];

void findMaxHappy(int n , int x){
    int count = 0;
    for(int i = 0; i < n; i++){
        if(x >= arr[i]){
            if(i == n - 1 && (x - arr[i])!=0){
                cout << count << endl;
                exit(0);
            }
            else{
                count++; 
                x = x - arr[i]; // Update x value
            }
        }
    }
    cout << count << endl;
}

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

    for(int i = 0; i < n; i ++){
        cin >> arr[i];
    }
    sort(arr , arr + n); // Sort array

    findMaxHappy(n , x);
}

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

int main(){

    string S;
    cin >> S;

    string s1 = S.substr(0,(S.length()-1)/2);
    string s2 = S.substr((S.length()+3)/2-1,S.length()-1);

    for(int i=0;i<S.length();i++){
        if(S[i]!=S[S.length()-i-1]){
            cout << "No" <<endl;
            return 0;
        }
    }
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s1[s1.length()-i-1]){
            cout << "No" <<endl;
            return 0;
        }
    }
    for(int i=0;i<s2.length();i++){
        if(s2[i]!=s2[s2.length()-i-1]){
            cout << "No" <<endl;
            return 0;

        }
    }

    cout << "Yes" <<endl;


    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



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

        String[] lineString = br.readLine().split(" ");
        int M = Integer.valueOf(lineString[1]);
        
        Map<Integer, List<Integer>> orgMap = new HashMap<Integer, List<Integer>>();
        
        String[] cityYear = null;
        int[][] count = new int[M][2];
        int area = 0;
        int city = 0;
        for (int i = 0; i < M; i++) {
            cityYear = br.readLine().split(" ");
            area = Integer.valueOf(cityYear[0]);
            city = Integer.valueOf(cityYear[1]);
            
            if (!orgMap.containsKey(area)) {
                orgMap.put(area, new ArrayList<Integer>());
            }
            orgMap.get(area).add(city);
            count[i][0] = area;
            count[i][1] = city;
        }
        
        List<Integer> citys = null;
        Map<Integer, Map<Integer, String>> sortMap = new HashMap<Integer, Map<Integer, String>>();
        for (Integer key : orgMap.keySet()) {
            citys = orgMap.get(key);
            Collections.sort(citys);
            
            if (!sortMap.containsKey(key)) {
                sortMap.put(key, new HashMap<Integer,String>());
            }
            
            for (int i = 1; i <= citys.size(); i++) {
                sortMap.get(key).put(citys.get(i - 1), getId(String.valueOf(i)));
            }
        }
        orgMap.clear();
        for (int i = 0; i < M; i++) {
            String temp = getId(String.valueOf(count[i][0]));
            System.out.println(temp + sortMap.get(count[i][0]).get(count[i][1]));
        }
        
    }
    
    private static String getId(String v){
        String result = "";
        for (int i = 0; i < 6 - v.length(); i++) {
            result += "0";
        }
        return result += v;
    }
}


Measured memory_bytes: 141668
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
ans = 0
if n == 1:
    print(0)
    exit()

base = a[0]
for i in range(1, n):
    if base > a[i]:
        ans += base - a[i]
    else:
        if a[i] > base:
            base = a[i]
print(ans)


Measured memory_bytes: 32272
N,K=(int(i) for i in input().split())

res=list()

for i in range(0,K):
    res.append(0)

j=0
i=0

while N>0:
    j=0
    while j<len(res):
        if N<=0:
            break
        res[j]=res[j]+1
        N=N-1
        j+=1
        #print(str(N)+"::"+str(res))


MinCount=min(res)

MaxCount=max(res)

print(MaxCount-MinCount)

        


Measured memory_bytes: 3064
import sys
N, K = map(int, input().split())
input = sys.stdin.readline
wd = [tuple(map(int, input().split())) for i in range(N)]
wd.sort()
d = 0
dp = [0]*N
l = 0
r = wd[0][0] + wd[0][1]*K
while(r - l > 1):
    tmp = (l+r)//2
    num = 0
    for w, d in wd:
        if w <= tmp:
            num += ((tmp - w) // d) + 1
    if num >= K:
        r = tmp
    else:
        l = tmp

print(r)


Measured memory_bytes: 58260
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    int K,T; cin >> K >> T;
    int A[T];
    rep(i,T){
        cin >> A[i];
    }
    sort(A,A+T);
    if(A[T-1]*2-K<=1) cout << 0 << endl;
    else cout << A[T-1]*2-K-1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args){
    		Scanner scan = new Scanner(System.in);
    		long a = scan.nextLong();
    		double b = scan.nextDouble();
    		long c = (long) (a*b);
    		System.out.println(c);
    	}
    }

Measured memory_bytes: 28904
from collections import defaultdict
n = int(input())
d = {}
di = defaultdict(list)
for i in range(n):
    tmp = input().split()
    s, p = tmp[0], int(tmp[1])
    d[(s, p)] = i+1
    di[s].append(int(p))
dii = list(di.items())
dii.sort(key=lambda x: x[0])

for i in dii:
    si, pi = i[0], i[1]
    pi.sort(reverse=True)
    for j in pi:
        print(d[(si, j)])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i;i<j;i++)
#define print(t) cout<<t<<endl
typedef long long ll;
typedef string str;

int main(){
	int n;cin>>n;
	vector<int> a,b;
	ll sum=0;
	rep(i,n+1){
		int c;cin>>c;
		a.push_back(c);
	}
	rep(i,n){
		int c;cin>>c;
		b.push_back(c);
	}
	rep(i,n){
		int x = min(a[i],b[i]);
		sum+=x;
		b[i]-=x;
		x=min(a[i+1],b[i]);
		sum+=x;
		a[i+1]-=x;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

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

long long int lcm(long long int a, long long int b) {
	long long int L;
	L = a / gcd(a, b);
	L *= b;
	return L;
}

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	for (int i = 2; i * i <= n; i++) {
		;
		if (is_prime.at(i)) {
			for (int j = i * i; j <= n; j += i) {
				is_prime.at(j) = false;
			}
		}
		Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int keta(long long int N) {
	int k = 0;
	while (N > 0) {
		N /= 10;
		k++;
	}
	return k;
}



int Combination(int n, int m) {
	long long int s = 1, t = 1;
	int tmp = n;
	while (n - m != tmp) {
		s *= tmp;
		tmp--;
	}
	tmp = m;
	while (tmp != 1) {
		t *= tmp;
		tmp--;
	}
	return s / t;
}


int main() {
	long long int n, k = 0, j = 1, c = 0;
	string s, t;

	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n ; i++) {
		if (a.at(i) == j) {
			k++;
			j++;
		}
		else
			c++;
	}
	if (n == c)
		cout << -1 << endl;
	else
		cout << n - k << endl;
}


/*
int main() {
	int n; cin >> n;
	vector<int> f(n);
	vector<int> t(n,1);
	int x[15][15], y[15][15];
	int p[15][15], q[15][15];
	vector<int> a(n);
	int count = 0, ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> f.at(i);
		for (int j = 0; j < f.at(i); j++) {
			cin >> p[i][j] >> q[i][j];
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			a.at(i) = f.at(i);
			for (int j = 0; j < a.at(i); j++) {
				x[i][j] = p[i][j]; y[i][j] = q[i][j];
			}
		}

		for (int i = 0 ; i < n; i++) {
			if (t.at((i+k)%n) == 0) {
				for (int j = 0; j < a.at((i + k) % n); j++) {
					if (y[(i + k) % n][j] == 1)
						y[(i + k) % n][j] = 0;
					else
						y[(i + k) % n][j] = 1;
				}
			}
			for (int j = 0; j < a.at(i); j++) {
				a.at(x[(i + k) % n][j] - 1) *= y[(i + k) % n][j];
			}
		}
		count = 0;
		for (int i = 0; i < n; i++) {
			if (a.at(i) == 1)
				count++;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
}
*/

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int n, m, sum=0;
    cin >> n >> m;
    int *a = new int[n];
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n);
    if(a[n-m]*4*m<sum){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    m=0;
    int p=n;
    while(p){
        m=m*10+(p%10);
        p/=10;
    }
    if(n==m)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, d = list(map(int,ipti().split()))
    print(math.ceil(n/(2*d+1)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]
aT = list(zip(*a))
aT = [x for x in aT if "#" in x]
a = list(zip(*aT))

for i in a:
    print("".join(i))


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			String t = sc.next();
			
			
			char[] sChar = s.toCharArray();
			char[] tChar = t.toCharArray();
			
			int len = tChar.length;
			for(int i = 0 ; i < s.length() - t.length() + 1; i++ ) {
				
				int cLen = 0;
				for(int j = 0 ; j < t.length() ; j++ ) {
					if ( sChar[i+j] != tChar[j]) {
						cLen++;
					}
					
				}
				
				if ( cLen < len ) {
					len = cLen;
				}
			}
			
			System.out.println(len);
		
		}
	}

}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<vll, vll> pvll;

struct state {
  ll d, v, p;

public:
  bool operator<(const state s) const { return d > s.d; }
};

const ll S = 0, G = 1;
ll N, M, A[100000], B[100000], C[100000];
vector< vector<pll> > E1(100000), E2(100000);

pvll dijkstra(vector< vector<pll> > &E, ll s) {
  vll dist(N, INF), cnt(N, 0);
  priority_queue<state> q;
  q.push((state) { 0, s, -1 });

  while(q.size()) {
    ll d = q.top().d, v = q.top().v, p = q.top().p;
    q.pop();

    if(dist[v] < d) continue;
    (cnt[v] += (p != -1 ? cnt[p] : 1)) %= MOD;

    if(dist[v] > d) {
      dist[v] = d;
      REP(i, 0, E[v].size()) {
        ll u = E[v][i].first, c = E[v][i].second;
        if(dist[u] > d + c) q.push((state) { d + c, u, v });
      }
    }
  }

  return pvll(dist, cnt);
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) {
    cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;
    E1[A[i]].push_back(pll(B[i], C[i]));
    E2[B[i]].push_back(pll(A[i], C[i]));
  }

  pvll d1 = dijkstra(E1, S), d2 = dijkstra(E2, G);
  vll dist1 = d1.first, dist2 = d2.first, cnt1 = d1.second, cnt2 = d2.second;

  ll orgd = dist1[G];
  ll orgc = cnt1[G];

  REP(i, 0, M) {
    ll u = A[i], v = B[i], cost = C[i];
    if(dist1[v] + cost + dist2[u] < orgd) cout << "HAPPY" << endl;
    else if(dist1[u] + cost + dist2[v] == orgd && (cnt1[u] * cnt2[v]) % MOD == orgc) cout << "SAD" << endl;
    else cout << "SOSO" << endl;
  }
}

Measured memory_bytes: 22304
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
//const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
const int MOD=998244353;
std::vector<int> v(1000000);
std::vector<int> w(1000000);
int pw(int n,int k){
  int res=1;
  while(k){
    if(k%2)res*=n;res%=MOD;
    k/=2;
    n*=n;n%=MOD;
  }
  return res;
}
int nCk(int n,int k){
  int res=v[n];
  res*=w[k];res%=MOD;
  res*=w[n-k];res%=MOD;
  return res;
}
//main
signed main(){
  int N,A,B,K;cin>>N>>A>>B>>K;
  v[0]=1;for(int i=1;i<1000000;i++)v[i]=v[i-1]*i%MOD;
  for(int i=0;i<1000000;i++)w[i]=pw(v[i],MOD-2);
  int ans=0;
  for(int a=0;a<=N;a++){
    if(K-A*a<0)break;
    if((K-A*a)%B)continue;
    int b=(K-A*a)/B;
    if(b>N)continue;
    ans+=nCk(N,a)*nCk(N,b);
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1E9;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s, t;
    cin >> n >> s >> t;
    vector<int> x {0}, y {0};
    for (int i = 1; i < n; ++i)
        if (s[i] != s[i - 1])
            x.push_back(i);
    for (int i = 1; i < n; ++i)
        if (t[i] != t[i - 1])
            y.push_back(i);
    x.push_back(n);
    y.push_back(n);
    int ans = INF;
    for (int i = -(int)x.size() + 1; i < (int)y.size(); ++i) {
        if ((i & 1) == (s[0] == t[0]))
            continue;
        int cnt = 0;
        for (int j = max(0, -i); j < min((int)y.size() - i, (int)x.size()); ++j)
            cnt += abs(x[j] - y[i + j]);
        for (int j = 0; j < -i; ++j)
            cnt += x[j];
        for (int j = (int)y.size() - i; j < (int)x.size(); ++j)
            cnt += n - x[j];
        for (int j = 0; j < i; ++j)
            cnt += y[j];
        for (int j = (int)x.size() + i; j < (int)y.size(); ++j)
            cnt += n - y[j];
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a=0;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v.at(i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<k;i++){
    a+=v.at(i);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

//けんちょん式 Union-Find
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;
        else
            return par[x] = root(par[x]);
    }

    bool 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;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

//pairのsecond順にsortするよう比較関数を定義
bool compare_by_x(tuple<ll, ll, ll> a, tuple<ll, ll, ll> b)
{
    if (get<1>(a) != get<1>(b))
    {
        return get<1>(a) < get<1>(b);
    }
    else
    {
        return get<2>(a) < get<2>(b);
    }
}

bool compare_by_y(tuple<ll, ll, ll> a, tuple<ll, ll, ll> b)
{
    if (get<2>(a) != get<2>(b))
    {
        return get<2>(a) < get<2>(b);
    }
    else
    {
        return get<1>(a) < get<1>(b);
    }
}

struct edge
{
    ll from;
    ll to;
    ll weight;
    edge(ll u, ll v, ll w) : from(u), to(v), weight(w) {}
};

bool comp(const edge &e1, const edge &e2)
{
    return e1.weight < e2.weight;
}

int main()
{
    ll n;
    cin >> n;
    vector<tuple<ll, ll, ll>> XY(n); //id,x,yの順
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        XY[i] = make_tuple(i, x, y);
    }

    vector<edge> es;
    sort(XY.begin(), XY.end(), compare_by_x);
    rep(i, n - 1)
    {
        ll i1, x1, y1, i2, x2, y2;
        tie(i1, x1, y1) = XY[i];
        tie(i2, x2, y2) = XY[i+1];
        es.push_back(edge(i1,i2,min(abs(x1-x2),abs(y1-y2))));
    }

    sort(XY.begin(), XY.end(), compare_by_y);
    rep(i, n - 1)
    {
        ll i1, x1, y1, i2, x2, y2;
        tie(i1, x1, y1) = XY[i];
        tie(i2, x2, y2) = XY[i + 1];
        es.push_back(edge(i1, i2, min(abs(x1 - x2), abs(y1 - y2))));
    }

    UnionFind uf(n);
    sort(es.begin(), es.end(), comp);
    ll res = 0;
    rep(i, es.size())
    {
        edge h = es[i];
        if (!uf.issame(h.from, h.to))
        {
            uf.merge(h.from, h.to);
            res += h.weight;
        }
    }
    cout << res << endl;
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< ul > ao(n), bo(n);
  for (int i=0; i<n; ++i) cin >> ao[i];
  for (int i=0; i<n; ++i) cin >> bo[i];
  bool flg = false;
  vector< tuple< ul, ul > > ab(n);
  for (int i=0; i<n; ++i) {
    ab[i] = make_tuple(bo[i], ao[i]);
  }
  sort(ab.begin(), ab.end());
  vector< tuple< ul, ul > > a(n), b(n);
  for (int i=0; i<n; ++i) {
    a[i] = make_tuple(get<1>(ab[i]), i);
  }
  for (int i=0; i<n; ++i) {
    b[i] = make_tuple(get<0>(ab[i]), i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i=0; i<n; ++i) {
    ul ai=get<0>(a[i]), bi=get<0>(b[i]);
    if (ai > bi) {
      cout << "No" << endl;
      return 0;
    }
    if (i > 0 && ai <= get<0>(b[i-1])) {
      flg = true;
    }
    if (get<1>(a[i]) == get<1>(b[i])) {
      flg = true;
    }
  }
  if (flg) {
    cout << "Yes" << endl;
    return 0;
  }

  vector< tuple< int, int > > loop(n);
  for (int i=0; i<n; ++i) loop[i] = make_tuple(get<1>(a[i]), i);
  sort(loop.begin(), loop.end());
  int l = 0;
  int cur = 0;
  while (true) {
    int next = get<1>(loop[cur]);
    l += 1;
    if (next == 0) break;
    cur = next;
  }
  cout << (l < n ? "Yes" : "No") << endl;

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


Measured memory_bytes: 7296
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=6000+100;
struct node {
	int l,r;
};
int n;
int sum[maxn],ma[maxn];
char s[maxn];
vector<node>a;
vector<int>sa,sb;
string dp[maxn];

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

string solve(int l,int r) {
	string ans="";
	if (s[l]=='a') {
		For (i,l,r)
			if (s[i]=='a') {
				string ss="ab";
				int p=ma[i]+1;
				while (p<=r) {
					while (p<=r && s[p]=='b') ++p;
					if (p>r) break;
					ss=ss+"ab"; p=ma[p]+1;
				}
				if (ss>ans) ans=ss;
			}
	}
	else {
		For (i,l,r)
			if (s[i]=='b') {
				string ss="";
				int p=i,R=ma[i];
				while (p<=R && p<=r) {
					if (s[p]=='b') ss=ss+"b",chkmax(R,ma[p]);
					if (s[p]=='a' && ma[p]>=i) ss=ss+"a";
					++p;
				}
				if (ss>ans) ans=ss;
			}
	}
	return ans;
}

int main() {
//	file();
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1,l=1;i<=2*n;++i) {
		if (s[i]=='a') {
			sum[i]=sum[i-1]+1;
			sa.push_back(i);
		}
		else {
			sum[i]=sum[i-1]-1;
			sb.push_back(i);
		}
		if (sum[i]==0) {
			a.push_back((node){l,i}); l=i+1;
		}
	}
	For (i,0,n-1) ma[sa[i]]=sb[i],ma[sb[i]]=sa[i];
//	For (i,1,2*n) printf("%d ",ma[i]); cout << endl;
//	For (i,0,a.size()-1)
//		cout << a[i].l << " " << a[i].r << endl;
	For (i,0,a.size()-1) dp[i]=solve(a[i].l,a[i].r);
	Forr (i,a.size()-2,0) dp[i]=max(dp[i]+dp[i+1],dp[i+1]);
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN                ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll                 long long int
#define           ull                unsigned long long int

int main()
{
    ll  a,b,c,d,e,f,i,j,k,cnt1=0,cnt2=0,sum1=0,sum2=0,chk1=0,chk2=0,T;
    cin >> a >> b >> c ;
    ll x = b ;
    ll y = c ;
    ll gap = abs(b-c);

    if(gap%2==0)
    {
        cout<<gap/2ll<<endl;
    }
    else
    {
        ll p = a - c ;
        b+=p;
        c+=p;
        b++;
        p++;
        gap = abs(b-c);
        p+=(gap/2);
        ll ans = p ;
        b=x;
        c = y ;
        p = b - 1 ;
        b-=p;
        c-=p;
        c--;
        p++;
        gap = abs(b-c);
        p+=(gap/2);
        ans = min(ans,p);

        cout<<ans<<endl;
    }

    return 0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
		//?????°
		public static int x;
		//????????????
		public static void solve(){
			Scanner sc = new Scanner(System.in);
			x=sc.nextInt();
			System.out.println(x*x*x);
		}
		public static void main(String[] args) {
			solve();

		}

	}

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

class Main {
    static int cnt = 0;

    static void insertionSort(int[] A, int n, int g) {
        for (int i = g; i < n; i++) {
            int v = A[i];
            int j = i - g;
            while(j >= 0 && A[j] > v){
                A[j+g] = A[j];
                j -= g;
                cnt++;
            }
            A[j+g] = v;
        }
    }

    static void shellSort(int[] A, int n){
        int[] G = new int[15];
        int h = 1;
        int m = 0;
        
        for(int i = 1; i <= n; i = i*3 + 1){
            G[m] = i; // シェルソートの幅はこれが良いとされているらしい(Knuth)
            m++;
        }
        System.out.println(m);

        for(int i = m-1; i >= 0; i--){
            System.out.print((i == m-1 ? "" : " ") + G[i] + (i == 0 ? "\n" : ""));
        }

        for(int i = m-1; i >= 0; i--){
            insertionSort(A, n, G[i]);
        }
    }

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

        int n = Integer.parseInt(br.readLine());
        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = Integer.parseInt(br.readLine());
        }

        shellSort(array, n);

        System.out.println(cnt);
        for(int i : array){
            System.out.println(i);
        }
    }
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    int a[2002], b[2002];
    vector<int> v[2002];
    for(int i = 0; i < n - 1; i++){
        cin >> a[i] >> b[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    queue<int> que;
    int d[2003];
    int ans = 0;
    if(k % 2 == 0) for(int i = 1; i <= n; i++){
        fill(d, d + n + 1, -1);
        int count = 0;
        que.push(i);
        d[i] = 0;
        while(que.size()){
            int now = que.front();
            que.pop();
            if(d[now] <= k / 2 - 1){
                for(int next : v[now]){
                    if(d[next] == -1){
                        d[next] = d[now] + 1;
                        que.push(next);
                    }
                }
            }
            count++;
        }
        ans = max(ans, count);
    }
    if(k % 2 == 1) for(int i = 0; i < n - 1; i++){
        fill(d, d + n + 1, -1);
        int count = 0;
        que.push(a[i]);
        que.push(b[i]);
        d[a[i]] = 0;
        d[b[i]] = 0;
        while(que.size()){
            int now = que.front();
            que.pop();
            if(d[now] <= k / 2 - 1){
                for(int next : v[now]){
                    if(d[next] == -1){
                        d[next] = d[now] + 1;
                        que.push(next);
                    }
                }
            }
            count++;
        }
        ans = max(ans, count);
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()

{
 int a,b;

 cin >> a >> b;
 if(a>b)
    cout <<"a > b"<< endl;
 else if (a<b)
    cout <<"a < b"<< endl;
 else
    cout <<"a == b"<< endl;

 return 0;
}



Measured memory_bytes: 3092
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let s = iterator.next().unwrap();

    let mut chars = s.chars();
    let mut prev = chars.next().unwrap();
    let mut ans: usize = 1;

    for _i in 1..n {
        let current = chars.next().unwrap();
        if prev != current {
            prev = current;
            ans += 1;
        }
    }

    return format!("{}", ans);
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"10
aabbbbaaca"
        ),
        "5"
    );
    assert_eq!(
        solve(
            r"5
aaaaa"
        ),
        "1"
    );
    assert_eq!(
        solve(
            r"20
xxzaffeeeeddfkkkkllq"
        ),
        "10"
    );
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char a= scan.next().charAt(0);
		char b = scan.next().charAt(0);
		if((int)a<(int)b) System.out.println("<");
		else if((int)a>(int)b) System.out.println(">");
		else System.out.println("=");

	}

}


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

vector<vector<pair<ll,ll>>> v(100100);

ll mod;
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

bool isprime(ll n){
    if(n<=1) return false;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

vector<ll> visited(100010);

bool dfs(int p,ll mo){
    bool ret = true;
    for(auto i:v[p]){
        ll nx = i.first,cost = i.second;
        ll now = visited[p];
        if(cost<0){
            now *= modinv(-cost);
        }
        else{
            now *= cost;
        }
        now %= mod;
        if(visited[nx] && visited[nx] != now){
            return false;
        }
        if(!visited[nx]){
            visited[nx] = now;
            ret &= dfs(nx,mo);
        }
    }
    return ret;
}

signed main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,-c));
    }

    for(mod = 1e9+9;mod<1e9+200;mod++){
        if(isprime(mod)){
            for(int i=0;i<n;i++){
                if(!visited[i]){
                    visited[i] = 1;
                    if(dfs(i,mod) == false){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
            visited = vector<ll>(100010);
        }
    }


    cout << "Yes" << endl;
    return 0;

}


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

int main() {
	int ans = 0, hmx = 0;

	int N;
	cin >> N;

	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
		if (H.at(i) >= hmx) {
			ans++;
			hmx = max(H.at(i), hmx);
		}
	}

	cout << ans << endl;
	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long cnt = 0;
		long[] X = new long[M];
		for(int i=0;i<M;i++){
			long t0 = 0;
			X[i] = last(D[i], C[i], ref t0);
			cnt += t0;
		}
		long v = X[0];
		for(int i=1;i<M;i++){
			cnt++;
			v = (X[i] + v);
			if(v >= 10){
				cnt++;
				v =(v % 10 + v / 10);
			}
		}
		Console.WriteLine(cnt);
		
		
	}
	
	long last(long d, long c, ref long t){
		
		t = 0;
		if(c == 1){
			return d;
		}
		List<long> rem = new List<long>();
		
		long n = c;
		long v = d;
		while(n >= 1){
			if(n % 2 == 1){
				rem.Add(v);
				n--;
			}
			t += n / 2;
			v = v * 2;
			if(v >= 10){
				t += n / 2;
				v = (v % 10 + v / 10);
			}
			n /= 2;
		}
		
		v = rem[0];
		for(int i=1;i<rem.Count;i++){
			t++;
			v = (rem[i] + v);
			if(v >= 10){
				t++;
				v =(v % 10 + v / 10);
			}
		}
		return v;
	}
	
	
	
	
	int M;
	long[] D,C;
	public Sol(){
		M = ri();
		D = new long[M];
		C = new long[M];
		for(int i=0;i<M;i++){
			var d = rla();
			D[i] = d[0]; C[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 20852
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n==0)break;
   var wh=arr.shift().split(" ").map(Number);
   var w=wh[0];
   var h=wh[1];
   var XY=[];
   for(var i=0;i<w;i++){
      XY[i]=[];
      for(var j=0;j<h;j++){
         XY[i][j]=0;
      }
   }
   while(n--){
      var xy=arr.shift().split(" ").map(Number);
      XY[xy[0]-1][xy[1]-1]=1;
   }
   var st=arr.shift().split(" ").map(Number);
   var s=st[0];
   var t=st[1];
   var max=0;
   for(var i=0;i<=w-s;i++){
      for(var j=0;j<=h-t;j++){
         var sum=0;
         for(var x=0;x<s;x++){
            for(var y=0;y<t;y++){
               sum+=XY[i+x][j+y];
            }
         }
         max=Math.max(sum,max);
      }
   }
   console.log(max);
}

Measured memory_bytes: 20728
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    bool has = false;
    while (n)
    {
      has |= n % 10 == 7;
      n /= 10;
    }
    printf("%s\n", has ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3764