akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

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

	double a, b, h, m;
	cin >> a >> b >> h >> m;
	pdd p, q;
	p = pdd(sin((2 * pi / 720) * (h * 60 + m)) * a, cos((2 * pi / 720) * (h * 60 + m)) * a);
	q = pdd(sin((2 * pi / 60) * (h * 60 + m)) * b, cos((2 * pi / 60) * (h * 60 + m)) * b);

	cout << setprecision(12) << sqrt((p.first - q.first) * (p.first - q.first) + (p.second - q.second) * (p.second - q.second)) << "\n";

	return 0;
}



Measured memory_bytes: 4116
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

int main() {

    int r;
    cin >> r;

    int ans = r*r;

    cout << ans;
}

Measured memory_bytes: 256
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    j=N-i
    while j>0:
        cnt+=j%9
        j//=9
    ans = min(ans,cnt)
print(ans)

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

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

  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

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

using namespace std;

int main() {
    int k; cin >> k;
    int a, b; cin >> a >> b;
    
    if (k >= a && k <= b) {
        cout << "OK\n";
    }
    else if (k > b){
        cout << "NG\n";    
    }
    else {
        int ok = 0;
        for (int i = a; i <= b; i++) {
            if (i%k == 0) {
                ok = 1; break;
            }
        }
        if (ok) cout << "OK\n";
        else cout << "NG\n";
    }
    
    return 0;
}

Measured memory_bytes: 3636
s=int(input())
def f(x):
  if x%2==0:
    return x/2
  else:
    return 3*x+1
  
counter=1
nums=[s]
temp=f(s)
while any([temp==nums[i] for i in range(counter)])==False:
  nums.append(temp)
  counter+=1
  temp=f(temp)
  
print(counter+1)

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

int main() {
	string s; cin >> s;
	int q; cin >> q;
	string r = "", l = "";
	bool rev = false;
	for (int i = 0; i < q; i++)
	{
		int t; cin >> t;
		if(t == 1) rev = !rev;
		else{
			int f; char c;
			cin >> f >> c;
			if(f == 1) {
				if(!rev) r = c + r;
				else l = l + c;
			}
			else {
				if(!rev) l = l + c;
				else r = c + r;
			}
		}
	}

	if(!rev) cout << r + s + l << endl;
	else {
		string res = r + s + l;
		reverse(res.begin(), res.end());
		cout << res << endl;
	}
	return 0;
}


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int s,t=1;
    while(true){
        scanf("%d",&s);
        if(s==0) break;
        printf("Case %d: %d\n",t,s);
        t++;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>

int main()
{
    int s;
    std::cin >> s;
    std::cout << s / (60 * 60) << ":";
    s %= (60 * 60);
    std::cout << s / 60 << ":";
    s %= 60;
    std::cout << s << std::endl;
    return 0;
}

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


int main() {

 int N;
 cin >> N;

 vector<int> C(N),S(N),F(N);
 for(int i = 1;i < N;i++) {
   cin >> C.at(i) >> S.at(i) >> F.at(i);
 }

 for(int i = 1;i < N;i++) {
   int time = C.at(i) + S.at(i);
   for(int j = i + 1;j < N;j++) {
     time += max(0,S.at(j) - time);
     while(time % F.at(j) != 0)time++;
     time += C.at(j);
   }
   cout << time << endl;
 }

 cout << 0 << endl;

}



Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

from collections import Counter

N = int(input())

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

c = Counter(A)

s = 0
for key in c:
    s += c[key] * (c[key] - 1) // 2

for num in A:
    print(s - c[num] * (c[num]-1) // 2 + (c[num]-1) * (c[num]-2) // 2)

Measured memory_bytes: 84428
#include <iostream>
#include<cstring>

using namespace std;

int main()
{
    int k;
    cin>>k;
    string name="ACL";
    string s[10];

    
    for (int i=1;i<=k;i++){
        s[i]=s[i-1] + name ;
    }
    cout<<s[k];

    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);

    string s;
    cin >> s;

    vector<ll> w(N), e(N);
    if (s[0] == 'W')
    {
        w[0] = 1;
        e[0] = 0;
    }
    else
    {
        w[0] = 0;
        e[0] = 1;
    }

    for (ll i = 1; i < N; i++)
    {
        w[i] = w[i - 1];
        e[i] = e[i - 1];
        if (s[i] == 'W')
            w[i]++;
        else
            e[i]++;
    }

    ll minc = e[N - 1] - e[0];
    for (ll i = 1; i < N; i++)
    {
        minc = min(w[i - 1] + e[N - 1] - e[i], minc);
    }

    printf("%lld", minc);
}


Measured memory_bytes: 5380
// https://atcoder.jp/contests/abc128/tasks/abc128_c
package main

import "fmt"
import "bufio"
import "os"
import "strconv"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	M := NextInt()
	X := make([][]int, M) // M x N

	for i := range X {
		X[i] = make([]int, N)
		K := NextInt()
		for j := 0; j < K; j++ {
			n := NextInt()
			X[i][n-1] = 1
		}
	}

	P := make([]int, M)
	for i := range P {
		P[i] = NextInt()
	}

	state := make([]int, N)

	var rec func(int) int
	search := func(i int) int {
		if i == N {
			for i := range X {
				sum := 0
				for j := range X[i] {
					sum += X[i][j] * state[j]
				}
				if sum%2 != P[i] {
					return 0
				}
			}
			return 1
		}

		cnt := 0
		for x := 0; x < 2; x++ {
			state[i] = x
			cnt += rec(i + 1)
		}
		return cnt
	}
	rec = search

	fmt.Println(search(0))
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr ll INF=1e18;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct Edge{
	int src,dst;
	ll weight;
	Edge(int s,int d,ll w):src(s),dst(d),weight(w){}
};
using Graph=vector<vector<Edge>>;

template<typename T,typename Compare>
auto make_priority_queue(const Compare& comp)
{
	return priority_queue<T,vector<T>,Compare>(comp);
}

vl Dijkstra(const Graph& g,int s)
{
	int n=g.size();
	vl res(n,INF);
	auto pq=make_priority_queue<tuple<int,ll>>([](auto a,auto b){
		return get<1>(a)>get<1>(b);
	});
	pq.emplace(s,0);
	while(pq.size()){
		int u; ll w; tie(u,w)=pq.top(); pq.pop();
		if(res[u]<=w) continue;
		res[u]=w;
		for(auto e:g[u])
			pq.emplace(e.dst,w+e.weight);
	}
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m,s,t;cin>>n>>m>>s>>t&&n|m|s|t;){
		s--,t--;
		Graph gy(n),gs(n);
		rep(_,m){
			int u,v; cin>>u>>v; u--,v--;
			ll a,b; cin>>a>>b;
			gy[u].emplace_back(u,v,a);
			gy[v].emplace_back(v,u,a);
			gs[u].emplace_back(u,v,b);
			gs[v].emplace_back(v,u,b);
		}
		vl dys=Dijkstra(gy,s);
		vl dss=Dijkstra(gs,t);
		vl res(n);
		rep(i,n) res[i]=dys[i]+dss[i];
		per(i,n-1) chmin(res[i],res[i+1]);
		rep(i,n) cout<<ll(1e15)-res[i]<<endl;
	}
}


Measured memory_bytes: 18984
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int h,a;
  cin >> h >> a;
  cout << (h+a-1)/a << endl;
return 0;}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(r <= x && r <= y && x + r <= W && y + r <= H) 
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3116
k = int(input())
x, y = [int(item) for item in input().split()]

# Think 1st quadrant
x_minus = False
if x < 0:
    x *= -1
    x_minus = True
y_minus = False
if y < 0:
    y *= -1
    y_minus = True
# Think x >= y
y_lt_x = False
if y > x:
    x, y = y, x
    y_lt_x = True

# Even step cannot go to odd point
if k % 2 == 0 and (x + y) % 2 == 1:
    print(-1)
    exit()

step_num = ((x + y) + (k - 1)) // k
d = (step_num * k - x - y) // 2
while d != 0 and (k > x + d or k > y + d + x):
    step_num += 1
    d = (step_num * k - x - y) // 2
if step_num * k % 2 != (x + y) % 2:
    step_num += 1
    d = (step_num * k - x - y) // 2

# print(x, y, step_num, step_num * k)

ans = []
step_len = 0
on_top = False
for i in range(step_num):
    step_len += k
    if step_len <= y + d:
        ans.append([0, step_len])
    elif step_len <= y + d + x:
        on_top = True
        ans.append([step_len - y - d, y + d])
    else:
        ans.append([x, (y + d) - (step_len - y - d - x)])
        if not on_top:
            newx, newy = ans[-1]
            prevx, prevy = ans[-2]
            if newy > prevy:
                b = abs(prevy - newy)
                a = k - abs(prevx - newx) - abs(prevy - newy)
                ans.pop() 
                ans.append([newx + b + a // 2, newy - b - a // 2])
            else:
                a = k - abs(prevx - newx) - abs(prevy - newy)
                ans.pop() 
                ans.append([newx + a // 2, newy - a // 2])
            on_top = True
print(len(ans))
for x, y in ans:
    if y_lt_x:
        x, y = y, x
    if x_minus:
        x *= -1
    if y_minus:
        y *= -1
    print(x, y)

Measured memory_bytes: 35504
def main():
    N, M = [int(i) for i in input().split()]

    pos = 0
    ans = 1

    fib = [1 for _ in range(100002)]
    for i in range(2, 100002):
        fib[i] = fib[i-1] + fib[i-2]

    for _ in range(M):

        a = int(input())
        if a == pos:
            ans = 0
            pos = N
            break
        elif a == pos + 1:
            pos = a + 1
        else:
            ans *= fib[(a - 1 - pos)]
            pos = a + 1

    if pos + 1 < N:
        ans *= fib[(N - pos)]

    print(ans % 1_000_000_007)



if __name__ == "__main__":
    main()



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

int n,k,a[10];
string s;

int main() {
  cin >> n >> s;
  int r=0;
  for(auto c:s){
    if(c=='R') r++;
  }
  cout << (r>n-r ? "Yes" : "No") << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
T LCM(T a, T b) {
	return a / GCD(a, b) * b;
}
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	string a, b;
	cin >> a >> b;

	if (a.size() > b.size()) cout << "GREATER" << endl;
	else if (a.size() < b.size()) cout << "LESS" << endl;
	else {
		if (a > b) cout << "GREATER" << endl;
		else if (a < b) cout << "LESS" << endl;
		else cout << "EQUAL" << endl;
	}
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	string S;int K,i,j,n;cin>>S>>K;
	n=S.size();
	chmin(K,n);
	S.pub('0');
	static llint dp[601][601]={};//取った数、残り操作回数
	static llint ep[601][601]={};
	static llint fp[601][601]={};
	int kaz=0;
	dp[0][K]=1;
	for(auto c:S){
		for(i=n;i>=0;i--){
			for(j=0;j<=n;j++){
				ep[i][j]=dp[i][j]+ep[i+1][j];
			}
		}
		for(j=0;j<=n;j++){fp[0][j]=dp[0][j];}
		for(i=1;i<=n;i++){
			for(j=0;j<=n;j++){
				fp[i][j]=dp[i][j]+fp[i-1][j+1];
			}
		}
		if(c=='1'){kaz++;continue;}
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				dp[i][j]=ep[i+1][j]+fp[i][j]-ep[i+kaz+1][j]+(mod*65536);
				dp[i][j]%=mod;
			}
		}
		kaz=0;
	}
	llint ans=0;
	for(j=0;j<=n;j++){ans+=dp[0][j];}
	cout<<ans%mod<<endl;
	return 0;
}


Measured memory_bytes: 7864
#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX 1000000
#define MIN -1000000
int main(void)
{
    int n;
    long long total = 0, tmp, min = MAX, max = MIN;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        total += tmp;
        if (max < tmp)
            max = tmp;
        if (min > tmp)
            min = tmp;
    }
    printf("%ld %ld %ld\n", min, max, total);
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int h,w;
char c[30][30];

int mx[] = {-1,0,0,1};
int my[] = {0,1,-1,0};

int LongestDistance(int sx,int sy){
  int ret = 0;
  queue<tuple<int,int,int>> que;
  que.emplace(sx,sy,0);
  bitset<30> visited[30];
  while(!que.empty()){
    auto [x,y,d] = que.front();
    que.pop();
    if(visited[y][x])continue;
    visited[y][x] = 1;
    ChangeMax(ret,d);
    for(int i = 0; i < 4; ++i){
      auto [nx,ny,nd] = make_tuple(x+mx[i],y+my[i],d+1);
      if(clamp(nx,0,w-1)!=nx || clamp(ny,0,h-1)!=ny)continue;
      if(c[ny][nx] == '#')continue;
      que.emplace(nx,ny,nd);
    }
  }
  return ret;
}

int main(){
  cin >> h >> w;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      cin >> c[i][j];
  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(c[i][j] == '#')continue;
      ChangeMax(ans,LongestDistance(j,i));
    }
  }
  cout << ans << endl;

  return 0;
}


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

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

    int count =0;
    for(int i=0;i<n;i++){
        int score=0;
        for(int j=0;j<m;j++){
            score += a[i][j]*b[j];
        }
        score += c;
        if(score>0) count++;
    }

    cout << count <<endl;
}

Measured memory_bytes: 256
#解答１（解説と一緒）
N = int(input())
H = list(map(int,input().split()))
stp = 0
for i in range(N-1,0,-1):#for文を逆回し（右から見ていく）H[i]→H[i-1]の順
    if H[i]+1 == H[i-1]:#次が１高ければ１下げて、
        H[i-1] -= 1
    elif H[i] >= H[i-1]:#同じ高さ以下なら無問題、
        pass
    else:#２以上高ければアウト
        stp += 1
        print("No")
        break
if stp == 0:
    print("Yes")

Measured memory_bytes: 63856
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,w[100];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>w[i];
	int sum1=w[0],sum2=accumulate(w+1,w+n,0),ans=abs(sum2-sum1);
	for(int i=1;i<n-1;i++){
		sum1+=w[i];
		sum2-=w[i];
		ans=min(ans,abs(sum2-sum1));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
cnt=0
if sum(a) < x:
    print(n-1)
    exit()
for i in range(n):
    if x>=a[i]:
        cnt+=1
        x-=a[i]
    else:
        break
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int tr[4][13];

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        char s;
        int m;
        cin >> s >> m;
        if(s == 'S') tr[0][m-1] = 1;
        else if(s == 'H') tr[1][m-1] = 1;
        else if(s == 'C') tr[2][m-1] = 1;
        else tr[3][m-1] = 1;
    }
    rep(i, 4) {
        rep(j, 13){
            if(tr[i][j]) continue;
            else{
                if(i == 0) cout << 'S' << ' ' << j+1 << endl;
                else if(i == 1) cout << 'H' << ' ' << j+1 << endl;
                else if(i == 2) cout << 'C' << ' ' << j+1 << endl;
                else cout << 'D' << ' ' << j+1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define mian() main()
#define greater greater<int>()
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
using Graph=vector<vector<P> >;
int main(){
    ll x;cin>>x;
    ll ans=0;
    ll money=100;
    while(1){
        money+=money/100;
        ans++;
        if(money>=x){cout<<ans<<endl;return 0;}
    }
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

int main()
{
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  int i,j;
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<vector<ll>> ans(h,vector<ll>(w,0));
  ans[0][0]=1;
  rep(i,h)rep(j,w)
  {
    if(i==0&&j==0)continue;
    if(a[i][j]=='#')
    {
      ans[i][j]=0;
      continue;
    }
    if(i==0)
    {
      ans[i][j]=ans[i][j-1]%MOD;
    }
    else if(j==0)
    {
      ans[i][j]=ans[i-1][j]%MOD;
    }
    else
    {
      ans[i][j]=(ans[i-1][j]+ans[i][j-1])%MOD;
    }
  }
  cout<<ans[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
// https://atcoder.jp/contests/abc151/tasks/abc151_f
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// 最小外接円
// http://www.secmem.org/blog/2019/04/08/Smallest-Enclosing-Circle/
namespace cover_2d {
double eps = 1e-9;
using Point = complex<double>;
struct Circle {
  Point p;
  double r;
};
double dist(Point p, Point q) { return abs(p - q); }
double area2(Point p, Point q) { return (conj(p) * q).imag(); }
bool in(const Circle &c, Point p) { return dist(c.p, p) < c.r + eps; }
Circle INVAL = Circle{Point(0, 0), -1};
Circle mCC(Point a, Point b, Point c) {
  b -= a;
  c -= a;
  double d = 2 * (conj(b) * c).imag();
  if (abs(d) < eps) return INVAL;
  Point ans = (c * norm(b) - b * norm(c)) * Point(0, -1) / d;
  return Circle{a + ans, abs(ans)};
}
Circle solve(vector<Point> p) {
  mt19937 gen(0x94949);
  shuffle(p.begin(), p.end(), gen);
  Circle c = INVAL;
  for (int i = 0; i < p.size(); ++i)
    if (c.r < 0 || !in(c, p[i])) {
      c = Circle{p[i], 0};
      for (int j = 0; j <= i; ++j)
        if (!in(c, p[j])) {
          Circle ans{(p[i] + p[j]) * 0.5, dist(p[i], p[j]) * 0.5};
          if (c.r == 0) {
            c = ans;
            continue;
          }
          Circle l, r;
          l = r = INVAL;
          Point pq = p[j] - p[i];
          for (int k = 0; k <= j; ++k)
            if (!in(ans, p[k])) {
              double a2 = area2(pq, p[k] - p[i]);
              Circle c = mCC(p[i], p[j], p[k]);
              if (c.r < 0)
                continue;
              else if (a2 > 0 && (l.r < 0 || area2(pq, c.p - p[i]) >
                                                 area2(pq, l.p - p[i])))
                l = c;
              else if (a2 < 0 && (r.r < 0 || area2(pq, c.p - p[i]) <
                                                 area2(pq, r.p - p[i])))
                r = c;
            }
          if (l.r < 0 && r.r < 0)
            c = ans;
          else if (l.r < 0)
            c = r;
          else if (r.r < 0)
            c = l;
          else
            c = l.r <= r.r ? l : r;
        }
    }
  return c;
}
};  // namespace cover_2d

void solve() {
  int N;
  cin >> N;
  vector<complex<double>> v;
  REP(i, N) {
    double x, y;
    cin >> x >> y;
    v.emplace_back(x, y);
  }
  auto c = cover_2d::solve(v);
  cout << fixed << setprecision(12) << c.r << endl;
}

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3796
data = Array.new
while line = STDIN.gets
  a = line.split(/,/)
  for i in 0.. a.length-1
    a[i] = a[i].to_i
  end
  data.push(a)
end
out = [0,0]
for i in 0..data.length-1
  if data[i][0] == 0 || data[i][1] == 0 || data[i][2] == 0
    continue
  end
  if data[i][0]*data[i][0]+data[i][1]*data[i][1] == data[i][2]*data[i][2]
    out[0] += 1
  elsif data[i][0] == data[i][1]
    out[1] += 1
  end
end
puts out*"\n"

Measured memory_bytes: 2336
#include <stdio.h>
int main (){
int k,l,i,j,sum=0,c;
scanf ("%d %d",&k,&l);
int a[51];
for (i=0;i<k;i++){
scanf ("%d",&a[i]);
}
  for (i=0;i<k;i++){
for (j=k-1;j>i;j--){
 if (a[j-1]<a[j]){
  c=a[j-1];
  a[j-1]=a[j];
  a[j]=c;
  }
}
}
  for (i=0;i<l;i++){
  sum=sum+a[i];
  }
  printf ("%d",sum);
  return 0;
}

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

using namespace std;

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector < string > c(H);
	for (int i = 0; i < H; i++) {
		cin >> c[i];
	}

	int ans = 0;

	for (int bitH = 0; bitH < (1 << H); bitH++) {
		for (int bitW = 0; bitW < (1 << W); bitW++) {
			int black = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (((bitH >> i) & 1) == 0
					    && ((bitW >> j) & 1) == 0
					    && c[i][j] == '#') {
						black++;
					}
				}
			}
			if (black == K) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3604
// Problem : D. Omkar and Bed Wars
// Contest : Codeforces - Codeforces Global Round 10
// URL : https://codeforces.com/contest/1392/problem/D
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 200005;
const int MAXM = 20500;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template <typename T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}


// void solve()
// {
	
	
// }

int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	string n;
	cin>>n;
	ll sum = 0;
	rep (i,0,n.size()-1)
	{
		sum += n[i] - '0';
	}
	// debug(sum);
	if (sum%9==0)
		cout<<"Yes\n";
	else 
		cout<<"No\n";
    //cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

Measured memory_bytes: 3772
from math import sqrt

def cal(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def solve(N):
    ans = [0 for _ in range(N+1)]
    for x in range(1,int(sqrt(N))+1):
        for y in range(1,int(sqrt(N))+1):
            for z in range(1,int(sqrt(N))+1):
                tmp = cal(x,y,z)
                if tmp <= N:
                    ans[tmp] += 1
                else:
                    break

    return ans

def main():
    N = int(input())

    ans = solve(N)
    for i in range(1,N+1):
        print(ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 69752
#include<iostream>
int main(){
	while(true){
		int H, W,a,b;
		std::cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		else{
			for (a = 1; a <= H; a++){
				for (b = 1; b <= W; b++){
					if ((a+b)%2==0){
						std::cout << "#";
					}
					else{
						std::cout << ".";
					}
				}
				std::cout << "\n";
			}
		}
		std::cout << "\n";
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> a(n);
  rep(i, n) cin >> a.at(i);
  ll m;
  cin >> m;
  vector <ll> b(m);
  rep(i, m) cin >> b.at(i);
  if (a < b) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<cstring>
#define Number 1000000
typedef unsigned int uint;
using namespace std;

int table[Number];

void make_table(){
  memset(table,1,sizeof(table));
  table[0]=0;
  table[1]=0;
  for(int i=0;i<Number;i++){
    if(table[i]){
      for(int j=i+i;j<Number;j+=i){
	table[j]=0;
      }
    }
  }
}

int main(){
  int a,d,n;
  make_table();
  // for(int i=0;i<Number;i++)
  //   if(table[i])
  //     cout<<i<<" ";
  // cout<<endl;
  while(cin>>a>>d>>n,a){
    int num=a;
    int cnt=0;
    while(num<Number){
      if(table[num]) cnt++;
      if(cnt==n) break;
      num+=d;
    }
    cout<<num<<endl;
  }
  return 0;
}

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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;

#define pb push_back

const int N = 250000;
int n, a, b, c, d;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    
    string s;
    cin >> s;
    if (d > c) {
        for (int i = a; i < c; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') return cout << "No", 0;
        }
        for (int i = b; i < d; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') return cout << "No", 0;
        }
        cout << "Yes";
    } else {
        for (int i = a; i < c; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') return cout << "No", 0;
        }
        for (int i = b; i < d; ++i) {
            if (s[i] == '#' && s[i + 1] == '#') return cout << "No", 0;
        }
        for (int i = b - 1; i <= d - 1; ++i) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
                return cout << "Yes", 0;
        }
        cout << "No";
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool p = s[0] == 'R';
  bool q = s[1] == 'R';
  bool r = s[2] == 'R';
  if(p and q and r){
    cout << 3 << endl;
  } else if((p and q) or (q and r)){
    cout << 2 << endl;
  } else if(p or q or r){
    cout << 1 << endl;
  } else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int main(int argc, char* argv[])
{
    int Q;
    scanf("%d", &Q);

    map<int,int> mp;
    vector<vector<int> > z(Q);
    int i;
    for(i=0; i<Q; i++) {
        int t;
        scanf("%d", &t);
        z[i].push_back(t);
        if(t==1) {
            int a,b;
            scanf("%d%d", &a, &b);
            z[i].push_back(a);
            mp[a]=0;
            z[i].push_back(b);
        }
    }

    vector<ll> value;
    int num=0;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        num++;
        it->second=num;
        value.push_back(it->first);
    }

    ll ans=0;
    BIT<ll> bit(num);
    BIT<ll> bit0(num);
    
    ll sum=0;
    for(i=0; i<Q; i++) {
        if(z[i][0]==1) {
            bit.add(mp[z[i][1]], 1);
            bit0.add(mp[z[i][1]], z[i][1]);
            sum += z[i][2];
        }
        else {
            int l=0, r=num+1;
            while(r-l>1) {
                int m=(l+r)/2;
                if(bit.sum(m)>=(bit.sum(num)+1)/2) {
                    r=m;
                }
                else {
                    l=m;
                }
            }
            printf("%lld %lld\n", value[r-1], sum+ value[r-1]*bit.sum(r)-bit0.sum(r)+bit0.sum(num)-bit0.sum(r)-value[r-1]*(bit.sum(num)-bit.sum(r)));
        }
    }

    return 0;
}



Measured memory_bytes: 20724
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k % 2) {
    cout << b - a << "\n";
  } else {
    cout << a - b << "\n";
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a/gcd(a, b))*(b/gcd(a, b))*gcd(a, b);
}

int main(void){
   
    ll X;
    cin>>X;
    cout<<lcm(X, 360)/X<<endl;
    return 0;
}


Measured memory_bytes: 3604
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll K, N;
  cin >> K >> N;

  vec<ll> A(N);
  REP(i, N) { cin >> A[i]; }

  ll longest = 0;
  for (ll i = 0; i < N; i++) {
    if (i < N - 1) {
      const ll j = i + 1;
      longest = max(longest, A[j] - A[i]);
    } else {
      const ll j = 0;
      longest = max(longest, K + A[j] - A[i]);
    }
  }

  cout << K - longest << endl;

  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> city(N, 0);
  
  int ai, bi;
  for (int i = 0; i < M; i++) {
    cin >> ai >> bi;
    city.at(ai - 1)++;
    city.at(bi - 1)++;
  }
  
  for (int j = 0; j < N; j++) {
    cout << city.at(j) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int w[1001],v[10001];
  int dp[n+1][m+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++)dp[i][j]=0;
  }
  for(int i = 1;i <= n;i++) cin>> v[i] >> w[i];
  for(int i = 1;i <= n;i++){
    for(int j = 1; j <= m;j++){
      if(j < w[i]) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  cout << dp[n][m] << endl;
}
 

Measured memory_bytes: 7000
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();

		// 計算
		long result = 0;
		for(int i = 0; i < s.length(); i++){
		    if(s.charAt(i) != t.charAt(i)) result++;
		}

		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 30676
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  pair<string,pp> e=mk("a",mk(1,1));
  queue<pair<string,pp>> q;
  q.push(e);
  vector<string> a(0);
  while(!q.empty()){
    string f=q.front().first;
    int g=q.front().second.first,h=q.front().second.second;
    q.pop();
    if (h==n) {a.push_back(f);continue;}
    rep(i,g){
      string k=f;
      k.push_back('a'+i);
      q.push(mk(k,mk(g,h+1)));
    }
    string y=f;
    y.push_back('a'+g);
    q.push(mk(y,mk(g+1,h+1)));
  }
  rep(i,a.size()) cout << a[i] << endl;
}


Measured memory_bytes: 9852
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int M = 13;
const int INF = INT_MAX ; 
int main ( ){
fast_io();
int n ; 
cin >> n ; 
map<int , int > m ; 
for ( int i = 0 ; i < n  ;++ i ) 
{
	int x ; 
	cin >>x ;
	m[x]++ ; 
}

cout << ( (int)m.size()== n ? "YES"  :"NO" ) ;  
return 0 ;
 
}


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

int main(){
  int h, w;
  cin>>h >>w;
  char s[h][w];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];
  
  for(int i=0;i<h;i++)for(int j=0;j<w;j++){
    if(s[i][j]=='#'){
      if(s[i-1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'&&s[i+1][j]=='.'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int INF = 1 << 25;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K, C;
  string S;
  while (cin >> N >> K >> C >> S) {
    vector<int> points;
    for (int i = 0; i < N; i++) {
      if (S[i] == 'o') points.push_back(i);
    }
    int M = points.size();
    vector<int> L;
    for (int i = 0; i < M; i++) {
      if (L.empty() || points[L.back()] + C < points[i]) {
        L.push_back(i);
      }
    }
    vector<int> R;
    for (int i = M - 1; i >= 0; i--) {
      if (R.empty() || points[i] + C < points[R.back()]) {
        R.push_back(i);
      }
    }
    vector<int> notNeed(M + 1, 0);
    for (int x = 0; x <= K; x++) {
      int y = K - x;
      if (x > L.size() || y > R.size()) continue;
      if (x > 0 && y > 0 && points[L[x - 1]] + C >= points[R[y - 1]]) {
        continue;
      }
      int l = x == 0 ? 0 : L[x - 1] + 1;
      int r = y == 0 ? M - 1 : R[y - 1] - 1;
      if (l <= r) {
        notNeed[l]++;
        notNeed[r + 1]--;
      }
    }
    for (int i = 1; i < M; i++) notNeed[i] += notNeed[i - 1];
    for (int i = 0; i < M; i++) {
      if (!notNeed[i]) {
        cout << points[i] + 1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool has_key(T mp, U key) { return mp.find(key) != mp.end(); }
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<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll h(N);
        rep(i, 0, N) cin >> h[i];
        sort(all(h));
        ll mn = inf;
        rep(i, 0, N-K+1) {
                chmin(mn, h[i+K-1] - h[i]);
        }
        cout << mn << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
typedef long long LL;
namespace solveIt
{
//char buf[1<<21],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
LL read()
{
	LL x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')	f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')	x=(x<<3)+(x<<1)+(c^'0'),c=getchar();
	return x*f;
}
template<class Type>
void write(Type x)
{
	if(x<0)	putchar('-'),x=-x;
	if(x>9)	write(x/10);
	putchar(x%10+'0');
}
int n,a[105][2];
void MAIN()
{
	n=read();
	int ans=0,flag=0;
	for(int i=1;i<=n;++i)
	{
		if(read()==read())	flag++;
		else	flag=0;
		if(flag>=3)	ans=1;
	}
	puts(ans?"Yes":"No");
}
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	solveIt::MAIN();
	return 0;
}

Measured memory_bytes: 3056