akhauriyash/Code-Regression huggingface dataset:
h, w = map(int, input().split())
s = [input() for _ in range(h)]

l = [[0 for _ in range(w)] for _ in range(h)]
r = [[0 for _ in range(w)] for _ in range(h)]
u = [[0 for _ in range(w)] for _ in range(h)]
d = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        l[i][j] = 0 if s[i][j] == '#' else (1 if j == 0 else l[i][j-1] + 1)
    for j in range(w-1, -1, -1):
        r[i][j] = 0 if s[i][j] == '#' else (1 if j == w-1 else r[i][j+1] + 1)
for j in range(w):
    for i in range(h):
        u[i][j] = 0 if s[i][j] == '#' else (1 if i == 0 else u[i-1][j] + 1)
    for i in range(h-1, -1, -1):
        d[i][j] = 0 if s[i][j] == '#' else (1 if i == h-1 else d[i+1][j] + 1)

m = 0
for i in range(h):
    for j in range(w):
        k = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        if k > m:
            m = k

print(m)

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

#define ever ;true;
#define Dbug(x) cout << "Debug: " << #x << " = " << x << endl
#define _ << ", " << 
#define ll long long
#define int ll
#define all(v) v.begin(), v.end()

int n;

map<int, int> cnt, smallest_idx;
vector<int> freq;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin >> n; freq.resize(n + 1);
    for (int i = 1, inp; i <= n; i++) {
        cin >> inp, cnt[inp]++;
        if (!smallest_idx.count(inp))
            smallest_idx[inp] = i;
    }

    for (auto it = cnt.rbegin(); it != cnt.rend(); it++) {
        auto nxt = it; nxt++;
        int val = (*it).first, times = (*it).second;
        int val_nxt = (*nxt).first;
        if (nxt == cnt.rend()) {
            freq[smallest_idx[val]] += times * (val - 0);
            continue;
        }
        freq[smallest_idx[val]] += times * (val - val_nxt);
        cnt[val_nxt] += times;
        smallest_idx[val_nxt] = min(smallest_idx[val], smallest_idx[val_nxt]);
    }

    for (int i = 1; i <= n; i++)
        cout << freq[i] << "\n";
    
}

Measured memory_bytes: 14336
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
x = min(c1)
y = min(c2)
z = min(c3)
for i in range(3):
    c1[i] -= x
    c2[i] -= y
    c3[i] -= z
print('NYoe s' [c1 == c2 == c3::2])


Measured memory_bytes: 3060
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        n:usize,
        k:i64,
        xs:[Usize1;n],
    }
    // loopを探す
    let mut paths   = vec![0];
    let mut visited = vec![false;n]; // loop確認検索用
    let mut curr = 0usize;
    visited[0] = true;
    let v0 = loop {
        let next = xs[curr];
        if visited[next] { // すでに登録済み = ループした
            break next;
        }
        visited[next] = true;
        paths.push(next);
        curr = next;
    };
    let i0 = paths.iter().position(|&v| v == v0).unwrap();
    let cycle = (paths.len() - i0) as i64;
    if k <= (i0 as i64) {
        println!("{}", paths[k as usize] + 1); 
    } else {
        println!("{}", paths[i0 + ((k-(i0 as i64)) % cycle) as usize] + 1);
    }
}

Measured memory_bytes: 6596
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<ctype.h>
#include<cstdio>
using namespace std;
main(){
  int n,m;
  int target[101]={0};
  int yosou[101][101]={0};
  int tensu[101]={0};
  int hazure=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>target[i];
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin>>yosou[i][j];
      if(target[i]==yosou[i][j]){
	tensu[j]=tensu[j]+1;
      }
      else{
	hazure=hazure+1;
      }
    }
    tensu[target[i]-1]=tensu[target[i]-1]+hazure;
    hazure=0;
  }
  for(int i=0;i<n;i++){
    cout<<tensu[i]<<endl;
  }
}

Measured memory_bytes: 1208
#include <iostream>
using namespace std;
 
int main(){
        double x1,x2,y1,y2,x3,x4,y3,y4;
     
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4){
        double a = (x2-x1)*(x4-x3),b = (y2-y1)*(y4-y3);
        if((float)a+(float)b==0) cout << "YES" << endl;
        else cout << "NO" << endl;
 
    }
     
    return 0;
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int cntIndex(char c) {
	if (c == 'M') {
		return 0;
	} else if (c == 'A') {
		return 1;
	} else if (c == 'R') {
		return 2;
	} else if (c == 'C') {
		return 3;
	} else if (c == 'H') {
		return 4;
	}

	return -1;
}

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

	int n;
	cin >> n;

	vector<ll> cnt(5);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
			cnt[cntIndex(s[0])]++;
		}
	}

	ll ans = 0;
	for (int i = 0; i <= 2; i++) {
		for (int j = i + 1; j <= 3; j++) {
			for (int k = j + 1; k <= 4; k++) {
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int n = sc.nextInt();
        for(int i = 1; i <= n; i++) {
            if(i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35764
n, x, y = list(map(int, input().split()))
cnt = []
for i in range(n-1):
  cnt.append(0)
for i in range(1,n):
  for j in range(i+1, n+1):
    if i <= x and y <= j:
      cnt[x-i+j-y] += 1
    elif i <= x:
      a = min(j-i-1, x-i+y-j)
      cnt[a] += 1
    elif y <= j:
      a = min(j-i-1, i-x+j-y)
      cnt[a] += 1
    else: 
      a = min(j-i-1, i-x+y-j) 
      cnt[a] += 1
for i in range(n-1):
  print(cnt[i])

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

int main(){
	int a, b, c;
  int t;
  bool flg = false;
	cin >> a >> b >> c;
  while (flg == false) {
    flg = true;
    if(a > b) {
      t = a;
      a = b;
      b = t;
      flg = false;
    }
      
    if(b > c) {
      t = b;
      b = c;
      c = t;
      flg = false;
    }
  }
  
  cout << a << " " << b << " " << c << endl;
  
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}

ll N;
ll a[3030];
ll dp[3030][3030][2];

ll rec(ll l, ll r, ll t){
    // cout << l << " " << r <<" "<< t << endl;
    if (dp[l][r][t] != -1) return dp[l][r][t];
    if (l == r){
        dp[l][r][t] = a[l] * (1 - 2 * t);
    }else{
        if (!t) dp[l][r][t] = max(rec(l + 1, r, 1) + a[l], rec(l, r - 1, 1) + a[r]);
        else dp[l][r][t] = min(rec(l + 1, r, 0) - a[l], rec(l, r - 1, 0) - a[r]);
    }
    return dp[l][r][t];
}


int main(){
    cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N) rep(j, N) rep(k, 2) dp[i][j][k] = -1;
    cout << rec(0, N - 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 143744
<?php
$NT = fgets(STDIN);
$N = (int)explode(" ",$NT)[0];
$T = (int)explode(" ",$NT)[1];
$ct_dic = [];
foreach(range(1,$N) as $num){
    $ct = fgets(STDIN);
    $ct_dic[explode(" ",$ct)[0]] = explode(" ",$ct)[1];
}
ksort($ct_dic);
foreach($ct_dic as $key=>$value){
    if($value <= $T){
        echo $key;
        exit();
    }
}
echo "TLE";

Measured memory_bytes: 4728
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef string::const_iterator state;
class parse_error {};

void cmpinc(state &it, char expected) {
	if (*it == expected) {
		it++;
	}
	else {
		cerr << "Expected '" << expected << "',";
		cerr << "got '" << *it << "'";

		cout << endl;
		throw parse_error();
	}
}

/*

BNF

<formula> ::= 0 | 1 | 2 | P | Q | R |
-<formula> | (<formula>*<formula>) | (<formula>+<formula>)

*/

int i; //?????°??¨
int NOT[3] = { 2,1,0 },
AND[3][3] = { {0,0,0},{0,1,1},{0,1,2} },
OR[3][3] = { {0,1,2},{1,1,2},{2,2,2} };

int formula(state &it) {
	int ret, L, R;

	//while (true) {
	switch (*it) {

	case '(':
		it++;
		L = formula(it);

		switch (*it) {
		case '*':
			it++;
			R = formula(it);
			ret = AND[L][R];
			break;
		case '+':
			it++;
			R = formula(it);
			ret = OR[L][R];
			break;
		default:
			break;
		}

		cmpinc(it, ')'); //)
		break;
	case '-':
		it++;
		ret = NOT[formula(it)];
		break;


	case 'P':
		ret = i % 3;
		it++;
		break;
	case 'Q':
		ret = (i / 3) % 3;
		it++;
		break;
	case 'R':
		ret = (i / 9) % 3;
		it++;
		break;

	default:
		if (*it >= '0'&&*it <= '2') {
			ret = *it - '0';
			it++;
		}
		break;
	}
	//}

	return ret;
}

int main() {
	for (string s; getline(cin, s), s != "."; ) {

		int cnt = 0;

		for (i = 0; i < 27; i++) {
			state it = s.begin();

			int L, R;
			L = formula(it);

			//cerr << L << endl;

			if (L == 2)
				cnt++;

		}

		cout << cnt << endl;

	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int a[n];
    int maxv=0,g=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        maxv=max(maxv,a[i]);
        g=__gcd(g,a[i]);
    }
    vector<set<int>> num(maxv+5);
    bool used[maxv+5]={};
    for(int i=2;i<=maxv;i++){
        if(used[i])continue;
        for(int j=i;j<=maxv;j+=i){
            used[j]=true;
            num[j].insert(i);
        }
    }
    map<int,int> mp;
    for(int i=0;i<n;i++){
        for(auto x:num[a[i]]){
            mp[x]++;
        }
    }
    bool flag=true;
    for(auto x:mp){
        if(x.second>1)flag=false;
    }
    if(flag)cout<<"pairwise coprime"<<endl;
    else if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 192360
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	ll x, now = 100;
	cin >> x;
	int cnt = 0;
	while (now < x) {
		++cnt;
		now += now / 100;
	}
	cout << cnt << '\n';
}



Measured memory_bytes: 3648
/*
  This C++ Source Is
  Writen By syksykCCC
  (2020)
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for(register int i = x; i < y; i++)
#define REP(i, x, y) for(register int i = x; i <= y; i++)
#define per(i, x, y) for(register int i = x; i > y; i--)
#define PER(i, x, y) for(register int i = x; i >= y; i--)
#define repl(i, x, y) for(register long long i = x; i < y; i++)
#define REPL(i, x, y) for(register long long i = x; i <= y; i++)
#define perl(i, x, y) for(register long long i = x; i > y; i--)
#define PERL(i, x, y) for(register long long i = x; i >= y; i--)
#define LLL __int128
#define int128 __int128
#define DEBUG(x) cerr << #x << " : " << x << endl
using namespace std;
typedef unsigned int uint;
typedef long long int64;
typedef long long LL;
typedef unsigned long long uint64;
typedef long long ULL;
typedef long double LLF;
template<typename T> inline void read(T &val)
{
	val = 0; char c = getchar(); int f = 1;
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { val = (val << 3) + (val << 1) + (c ^ 48); c = getchar(); }
	val *= f;
}
template<typename T> void write_(T val) { if(!val) return; write_(val / 10); putchar(val % 10 + 48); }
template<typename T> inline void write(T val)
{
	if(val == 0) putchar(48);
	else if(val < 0) { putchar('-'); write_(-val); }
	else write_(val);
}

int main()
{
#ifdef LOCAL
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	LL A, B, N;
	cin >> A >> B >> N;
	cout << (A * min(N, (B - 1)) / B) << endl;
	return 0;
}


Measured memory_bytes: 3648
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    sp1=min(q,h,s)
    dp2=min(2*q,2*h,2*s,d)

    if n%2==0:
        c=n//2
        print(c*dp2)
    elif n%2!=0:
        c=n//2
        print(c*dp2+sp1)
    else:
        print(n*sp1)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 9068
n = gets.chomp.to_i
letter = []
letter[1] = ['.',',','!','?',' ']
letter[2] = ['a','b','c']
letter[3] = ['d','e','f']
letter[4] = ['g','h','i']
letter[5] = ['j','k','l']
letter[6] = ['m','n','o']
letter[7] = ['p','q','r','s']
letter[8] = ['t','u','v']
letter[9] = ['w','x','y','z']
letter[0] = ['']

n.times do
    input_data = gets.chomp
    
    f = 0
    count = 0
    input_data.length.times do |i|
        g = input_data[i].to_i
        if g != 0
            f = g
            count += 1
        else
            print letter[f][(count - 1) % letter[f].length]
            f = 0
            count = 0
        end
    end
    puts
end



Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif

struct edge{
    int to;
    LL cost;
    edge(): to(0), cost(0) {}
    edge(int to, LL cost): to(to), cost(cost) {}
    bool operator < (const edge& other) const{
        return cost > other.cost;
    }
};

const LL INF = 1e15;
int n, m;

vector<LL> calc(vector<vector<edge>> adj, int s){
    vector<LL> ans(n+1, INF);
    ans[s] = 0;
    priority_queue<edge> pq;
    pq.emplace(s, 0);
    while(not pq.empty()){
        int to; LL cost;
        edge d = pq.top(); pq.pop();
        to = d.to; cost = d.cost;
        if(ans[to] != cost) continue;
        for(edge e:adj[to]){
            if(ans[e.to] > cost + e.cost){
                ans[e.to] = cost + e.cost;
                pq.emplace(e.to, ans[e.to]);
            }
        }
    }
    return ans;
}

int main() {
    cin >> n >> m;
    int s, t; cin >> s >> t;
    vector<vector<edge>> yen(n+1), snuuk(n+1);
    for(int i=0; i<=m; i++){
        int u, v; LL a, b;
        cin >> u >> v >> a >> b;
        yen[u].emplace_back(v, a);
        yen[v].emplace_back(u, a);
        snuuk[u].emplace_back(v, b);
        snuuk[v].emplace_back(u, b);
    }
    
    vector<LL> cyen = calc(yen, s);
    vector<LL> csnuuk = calc(snuuk, t);
    
    vector<LL> ans(n+1, INF);
    LL cost = INF;
    for(int i=n; i>0; i--){
        cost = min(cost, cyen[i] + csnuuk[i]);
        ans[i] = INF - cost;
    }
    for(int i=1; i<=n; i++) cout << ans[i] <<  '\n';
    return 0;
}


Measured memory_bytes: 26684
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 

 
int main() {
    int n;
    cin >> n;
    cout << n * n * n;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d;
        cin>>n>>d;
        ll x=2*d+1;
        
        cout<<ceil(n,x)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=998244353;
const ll mod=1e9+7;
//Combination
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[2000010],finv[2000010],inv[2000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,2000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%mod;
        b/=2;
        x=x*x%mod;
    }
    return res;
}
signed main(){
    ll k;cin>>k;
    string s;cin>>s;
    ll n=s.size();
    combinit();
    ll ans=0;
    REP(i,1,n+k+1){
        if(i>=n){
            ans=(ans+comb(i-1,n-1)%mod*rui(25,i-n)%mod*rui(26,n+k-i)%mod)%mod;
        }
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 51240
#include<iostream>
#include<cmath>
#include<iomanip>
#define ll long long
using namespace std;
int a[200005];
int m[200005];
ll ans=0;
int main() {
	int n;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>a[i];
		if(i==0) m[i]=a[i];
		else {
			if(a[i]>m[i-1]) m[i]=a[i];
			else m[i]=m[i-1];
		}
	}
	for(int i=0; i<n; i++) {
		ans+=m[i]-a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
int N;
const int W = 5;
const int H = 5;
const int M = 5;
int a[5][5];
int score[5];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool valid(int x) {
    return 0 <= x && x < 5;
}

int eval() {
    int b[5][5];
    memcpy(b, a, sizeof(a));
    int bonus = 0;
    int ans = 0;
    while(true) {
        bool update = false;
        bool remove[5][5] = {};
        REP(y, H) for(int sx = 0; sx + 2 < W; sx++) {
            if(b[y][sx] == b[y][sx+1] && b[y][sx] == b[y][sx+2]) {
                if(b[y][sx] != 0) {
                    REP(xd, 3) remove[y][sx+xd] = true;
                }
            }
        }
        REP(x, W) for(int sy = 0; sy + 2 < H; sy++) {
            if(b[sy][x] == b[sy+1][x] && b[sy][x] == b[sy+2][x]) {
                if(b[sy][x] != 0) {
                    REP(yd, 3) remove[sy+yd][x] = true;
                }
            }
        }
        REP(y, H) REP(x, W) if(remove[y][x]) {
            assert(b[y][x] != 0);
            ans += score[b[y][x]-1] * (bonus + 1);

            b[y][x] = 0;
            update = true;
        }
        int c[5][5] = {};
        REP(x, 5) for(int y = 4, cy = 4; y >= 0; y--) {
            if(b[y][x] != 0) {
                c[cy--][x] = b[y][x];
            }
        }
        memcpy(b, c, sizeof(b));

        if(!update) break;
        bonus += 1;
    }
    return ans;
}

int dfs(int x, int y, int k) {
    int res = eval();
    if(k == N) return res;
    REP(r, 4) {
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(valid(nx) && valid(ny)) {
            swap(a[y][x], a[ny][nx]);
            res = max(res, dfs(nx, ny, k+1));
            swap(a[y][x], a[ny][nx]);
        }
    }
    return res;
}

int main(){
    while(cin >> N && N != -1) {
        REP(y, H) REP(x, W) cin >> a[y][x];
        REP(i, M) cin >> score[i];

        int ans = INT_MIN;
        REP(sy, H) REP(sx, W) {
            ans = max(ans, dfs(sx, sy, 0));
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A>> B;

    int p[N+10];
    for (int i=0; i<N; ++i) cin >> p[i];
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;

    for (int i=0; i<N; ++i) {
        if (1<=p[i] && p[i]<=A) ++count1;

        else if (A<p[i] && p[i]<=B) ++count2;

        else ++count3;
    }
    int answer = min(min(count1, count2),count3);

    if (count1==0 || count2==0 || count3==0) cout << 0 <<endl;
    else cout << answer << endl;

    
    /*
    int count = 0;
    for (int i=1; i<=A; ++i) {
        for (int j=A+1; j<B; ++j) {
            for (int k=B+1; k<20; ++k) {
                if ( i==j || j==k || k==i) continue;
                else ++count;
            }
        }
    }
    cout << count << endl;
    */


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <sstream>

using namespace std;


int n;
string line;

map<string,int> strCnt;

string point(int x,int y,string field){

	bool cont=false;
	int s;
	int f;
	bool isFirstname=true;
	string firstName="";
	string name;

	for(int i = 0; i < field.size(); i++){
		if(field[i]=='<'){
			s=i+1;
		}
		else if(field[i]=='>'){
			name = field.substr(s,i-s);
			firstName=name;
			// gðÆè¾·
			field=field.substr(name.size()+2,field.size()-2*(name.size()+2)-1);
			break;
		}
	}

	// ÀWðØèæè
	string points;
	string back;
	bool fff=false;
	for(int i = 0; i < field.size(); i++){
		if(field[i]=='<'){
			points=field.substr(0,i);
			back=field.substr(i);
			fff=true;
			break;
		}
	}
	if(!fff){
		points=field;
	}
	int bc=0;
	int cc=0;
	vector<int> pp;
	for(int i = 0; i < points.size(); i++){
		if(points[i]==','){
			bc=cc;
			pp.push_back(atoi(points.substr(bc,i-bc).c_str()));
			cc=i+1;
		}
	}
	pp.push_back(atoi(points.substr(cc,points.size()-cc).c_str()));

	int minx = pp[0];
	int miny = pp[1];
	int maxx = pp[2];
	int maxy = pp[3];

	if(minx > x || miny > y || maxx < x || maxy < y){
		if(name=="main")
			return "OUT OF MAIN PANEL 1";
		else
			return "";
	}
	else{
		// panelãÉ¢­ÂÌ^Oª é©¦é
		string tagName;
		int sk;
		// e^Oð½Çé
		int cnt=0;
		for(int i = 0; i < back.size(); i++){
			if(back[i] == '<'){
				if(tagName==""){
					sk=i;
					for(int j = i; ;j++){
						if(back[j]=='>'){
							tagName=back.substr(i+1,j-i-1);
							i=j;
							break;
						}
					}
				}
				else{
					if(back[i+1]!='/')
						continue;
					int fk;
					string ts;
					for(int j = i; ;j++){
						if(back[j]=='>'){
							ts=back.substr(i+1,j-i-1);
							i=j;
							fk=j;
							break;
						}
					}
					if(ts.substr(1)==tagName){
						cnt++;
						tagName="";
					}
					else{
					}
				}
			}
		}
		strCnt[name]=cnt;
		tagName="";
		// e^Oð½Çé
		for(int i = 0; i < back.size(); i++){
			if(back[i] == '<'){
				if(tagName==""){
					sk=i;
					for(int j = i; ;j++){
						if(back[j]=='>'){
							tagName=back.substr(i+1,j-i-1);
							i=j;
							break;
						}
					}
				}
				else{
					if(back[i+1]!='/')
						continue;
					int fk;
					string ts;
					for(int j = i; ;j++){
						if(back[j]=='>'){
							ts=back.substr(i+1,j-i-1);
							i=j;
							fk=j;
							break;
						}
					}
					if(ts.substr(1)==tagName){
						string ret=point(x,y,back.substr(sk,fk-sk+1));
						if(ret!="")
							return ret;
						tagName="";
					}
				}
			}
		}

	}
	string retStrTmp = name + " ";
	stringstream ss;
	ss << strCnt[name];
	retStrTmp += ss.str();
	return retStrTmp;
}

int main(){

	while(cin>>n&&n!=0){
		cin>>line;
		for(int i = 0; i < n; i++){
			int x,y;
			cin>>x>>y;
			cout<<point(x,y,line)<<endl;
		}
		strCnt.clear();
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

class V {
  long x, y, z;
  V() {
    x = y = z = 0;
  }
  V(long ax, long ay, long az) {
    x = ax;
    y = ay;
    z = az;
  }
}

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int M = in.nextInt();
    ArrayList<V> xyz = new ArrayList<V>();
    for (int i = 0; i < N; i++) {
      long x = in.nextLong();
      long y = in.nextLong();
      long z = in.nextLong();
      xyz.add(new V(x, y, z));
    }
    in.close();

    int[][] sgn = {
      {-1, -1, -1},
      {-1, -1,  1},
      {-1,  1, -1},
      {-1,  1,  1},
      { 1, -1, -1},
      { 1, -1,  1},
      { 1,  1, -1},
      { 1,  1,  1}
    };
    long ans = 0;
    for (int[] s: sgn) {
      long[] t = new long[N];
      for (int i = 0; i < N; i++) {
        V v = xyz.get(i);
        t[i] = s[0] * v.x + s[1] * v.y + s[2] * v.z;
      }
      Arrays.sort(t);
      long sum = 0;
      for (int i = 0; i < M; i++) {
        sum += t[N - i - 1];
      }
      ans = Math.max(ans, sum);
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 26860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    vector<ll> x(n);rep(i,n)cin>>x[i];
    ll ans = INF;
    for(int i=0; i+k-1<n; i++){
        ll l = x[i], r = x[i+k-1];
        ll a;
        if(r<0)a=-l;
        else if(l<0)a=min(r-2*l, 2*r-l);
        else a=r;
        ans = min(ans, a);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3960
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final int MAX = 100;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] x = new int[n], y = new int[n], h = new int[n];
			IntStream.range(0, n).forEach(i -> {
				x[i] = scanner.nextInt();
				y[i] = scanner.nextInt();
				h[i] = scanner.nextInt();
			});
			for (int i = 0; i <= MAX; i++) {
				for (int j = 0; j <= MAX; j++) {
					int ch = check(n, x, y, h, i, j);
					if (ch > 0) {
						System.out.println(i + " " + j + " " + ch);
					}
				}
			}
		}
	}

	/**
	 * 指定されたcx,cyでHを計算する
	 * 
	 * @param n  座標数
	 * @param x  X座標の一覧
	 * @param y  Y座標の一覧
	 * @param h  hの一覧
	 * @param cx
	 * @param cy
	 * @return 指定されたcx,cyで計算したH、計算できない場合は−1
	 */
	private static int check(int n, int[] x, int[] y, int[] h, int cx, int cy) {
		int ch = -1;
		for (int i = 0; i < n; i++) {
			if (h[i] > 0) {
				ch = Math.abs(x[i] - cx) + Math.abs(y[i] - cy) + h[i];
				break;
			}
		}
		for (int i = 0; i < n; i++) {
			if (h[i] != Math.max(ch - Math.abs(x[i] - cx) - Math.abs(y[i] - cy), 0)) {
				return -1;
			}
		}
		return ch;
	}
}


Measured memory_bytes: 40100
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, a, b, c, d, e = sc.nextLong()
    val min = List(a, b, c, d, e).min
    val m = if (n % min == 0) n / min else n / min + 1
    println(5L + m - 1L)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 27324
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int x,h,m,s;
	scanf("%d", &x);
	h = x / 3600;
	m = (x % 3600) / 60;
	s = (x % 3600) % 60;
	printf("%d:%d:%d\n",h ,m, s);
	return 0;
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<string> A(H);
  for(int i=0;i<H;i++)
    cin>>A[i];
  vector<vector<int>> B(H,vector<int>(W));
  int k=0;
  for(int i=0;i<H;i++){
    int l=-1;
    for(int j=0;j<W;j++){
      if(A[i][j]=='#'){
        k++;
        l=k;
      }
      B[i][j]=l;
    }
    if(B[i][W-1]==-1){
      if(i>0 && B[i-1][W-1]!=-1)
        B[i]=B[i-1];
    }
    for(int j=W-2;j>=0;j--)
      if(B[i][j]==-1)
        B[i][j]=B[i][j+1];
  }
  for(int i=H-2;i>=0;i--)
    if(B[i][0]==-1)
      B[i]=B[i+1];
  for(vector<int> v:B)
    for(int i=0;i<W;i++){
      cout<<v[i];
      if(i==W-1)
        cout<<'\n';
      else
        cout<<' ';
    }
}

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

int main(){
  int n; cin >> n;
  int a[n], b[n];
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i){
    cin >> b[i];
  }
  int ans = 0;
  for(int i = 0; i < n;++i){
     ans += (a[i] >= b[i] ? a[i] - b[i] : 0);
   }
   cout << ans << '\n';
}

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

 class C4{
   public static void Main(){
     while(true){
       string  str = Console.ReadLine();
       if(string.IsNullOrEmpty(str)) break;

       HashSet<string> ht = new HashSet<string>();
       int n  = int.Parse(str);
       for(int i = 0;i < n;i++){
         string[] command  = Console.ReadLine().Split(' ');
         switch(command[0]){
           case "insert":
           ht.Add(command[1]);
           break;
           case "find":
           if(ht.Contains(command[1])){
             Console.WriteLine("yes");
           }else{
             Console.WriteLine("no");
           }
           break;
         }
       }
     }
   }
 }



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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N;cin>>N;
    ll res = 0;
    rep1(i,N-1){
        res += (N-1)/i;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3624
from collections import Counter

n = int(input()) #n行の入力をリストに入れる
S = [''.join(sorted(input())) for i in range(n)] #inputの文字列をソートできる
counter = Counter(S) #Sの中の文字列を集計し、dict型で返せる

ans =0 
for i in counter.values():
    ans += i*(i-1)//2

print(ans)

""""
l = []
for i in range(n):
    l.append(input()) 

def get_counter(s):
    return Counter(s.upper().replace(' ', ''))

def verify_anagrams(first_word, second_word):
    return get_counter(first_word) == get_counter(second_word)

count =0 
for i in range(n):
    for j in range(i+1,n):
        if verify_anagrams(l[i],l[j])==True:
            count += 1


print(count)

#print(verify_anagrams(l[0],l[2]))
"""

Measured memory_bytes: 19764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();

        TreeMap<Integer, Integer> map = primeFactorize(n);

        out.print(n + ":");
        Set<Integer> set = map.keySet();
        for (int x : set) {
            for (int i = 0; i < map.get(x); i++) {
                out.print(" " + x);
            }
        }
        out.println();
    }

    TreeMap<Integer, Integer> primeFactorize(int n) {
        Prime p = new Prime((int) Math.sqrt(n) + 1);
        ArrayList<Integer> primes = p.getPrimes();

        TreeMap<Integer, Integer> ret = new TreeMap<>();
        for (int i = 0; i < primes.size(); i++) {
            int x = primes.get(i);
            if (n % x == 0) {
                int cnt = 0;
                while (n % x == 0) {
                    cnt++;
                    n /= x;
                }
                ret.put(x, cnt);
            }
        }
        if (n > 1) {
            ret.put(n, 1);
        }

        return ret;
    }

    class Prime {
        int n;
        boolean[] isPrime;
        ArrayList<Integer> primes;

        Prime(int n) {
            this.n = n;
            isPrime = new boolean[n + 1];
            primes = new ArrayList<>();
            sieve();
        }

        void sieve() {
            for (int i = 2; i < n; i++) {
                if (!isPrime[i]) {
                    primes.add(i);
                    for (long j = (long) i * i; j < n; j += i) {
                        isPrime[(int) j] = true;
                    }
                }
            }
        }

        ArrayList<Integer> getPrimes() {
            return primes;
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24716
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int n, k, i, j;
	n = getint();
	k = getint();
	int h[n];
	int dp[n];
	ROOP(i, n) {
		h[i] = getint();
		dp[i] = 1E9;
	}
	dp[0] = 0;
	for(i = 1; i < n; i++) {
		for(j = 1; j <= k; j++) {
			if (i - j < 0) break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
		}
	}
	showint(dp[n-1]);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 896
import heapq

def dijkstra(graph, node, target):
  INF = float("inf")
  dist = [INF] * node
  dist[target] = 0
  que = [(0, target)]
  while que:
    co, one_node = heapq.heappop(que)
    for next_c, next_n in graph[one_node]:
      dist_candi = dist[one_node] + next_c
      if dist_candi < dist[next_n]:
        dist[next_n] = dist_candi
        heapq.heappush(que, (dist[next_n], next_n))
  return dist


class SetGraph:
  def __init__(self, node_num):
    self.n = node_num
    self.graph = [[] for _ in range(self.n)]

  def add_one_edge(self, start, end, cost):
    self.graph[start].append((cost, end))
    self.graph[end].append((cost, start))

  def get_graph(self):
    return self.graph 
  

n, m = map(int, input().split(" "))
graph_set = SetGraph(n)
for i in range(m):
  a, b, c = map(int, input().split(" "))
  graph_set.add_one_edge(a - 1, b - 1, c)
graph = graph_set.get_graph()

cost = []
for i in range(n):
  temp_cost = dijkstra(graph, n, i)
  cost.append(temp_cost)

result = 0
for i in range(n):
  for c, node in graph[i]:
    if cost[i][node] != c:
      result += 1

print(result // 2)

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < s.size(); i++) {
        set<int> l, r;
        for (int j = 0; j < i; j++) {
            l.insert(s[j]);
        }
        for (int j = i; j < s.size(); j++) {
            r.insert(s[j]);
        }
        int cnt = 0;
        for (auto k : r) {
            if (l.find(k) != l.end()) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int ,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
ans = "No"
for h in range(N-M+1):
    for w in range(N-M+1):
        if A[h][w]==B[0][0]:
            k = 1
            for h1 in range(M):
                for w1 in range(M):
                    if A[h+h1][w+w1]!=B[h1][w1]:
                        k=0
                        break
                if not k:break
            if k:ans="Yes"
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> sumA(N+1, 0);
	REP(i, N) cin >> sumA[i+1];
	REP(i, N) sumA[i+1] += sumA[i];
	map<ll, ll> mp;
	REP(i, N+1) mp[sumA[i]]++;
	ll res = 0;
	for(auto itr=mp.begin();itr!=mp.end();itr++){
		ll x = itr->second;
		res += x*(x-1)/2;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
  	cin>>a[i];
  }
  ll sum = 0;
  ll best = a[0];
  for(ll i=1;i<n;i++){
  	if(a[i]<best){
  		sum+=abs(best-a[i]);
  		//cout<<sum<<"**";
	  }
	  best = max(best,a[i]);
  }
  cout<<sum<<"\n";
  return 0;
}

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;	cin>>N;
	string S;
	set<string> st;
	while(N--){
		cin>>S;
		st.insert(S);
	}
	
	cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 19244
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int a, b;
    cin >> a >> b;

    int dif = a - b*2;
    cout << (dif < 0 ? 0 : dif) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    //変数：リングの文字列「 ringStr 」と確認の文字列「 checkStr 」置く
    string ringStr, checkStr;
    
    //入力：リングの文字列「 ringStr 」と確認の文字列「 checkStr 」を入力する
    cin >> ringStr >> checkStr;
    
    //連結：リングは常に回っているこれを物理的に作る為にabcのときはabcabcと連結している
    ringStr += ringStr;
    
    //判定：stringを使用しているときは　➡　「　検索されたい変数名．find(検索する変数名)　」　であるか判定できる
    if( ringStr.find(checkStr) == -1) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    
}


/*****************************　　stringの検索方法　　********************************************


    find関数を使用する
    
        使い方：検索されたい変数名．find(検索する変数名)　と書く
        
        出力結果⓵：文字列あり　➡　　文字列がある場所を出力
        出力結果⓶：文字列なし　➡　　－１を出力

        
        ####################　　　　例（開始）　　　　#################
        
        
        
        #include <iostream>
        #include <string>
        using namespace std;

        
        int main(){
        
        string str = "maneron"
        string checkStr1 = "mane"
        string checkStr2 = "abcd"
        
        cout << str.find(checkStr1) << endl    // 4 と表示される　※ポイント：最初の文字を１番目となっている
        cout << str.find(checkStr2) << endl    // -1 と表示される
        
        return 0;
        
        }
        
        #####################　　　　例（終了）　　　　##############
        
        
     

**********************************************************************************/


Measured memory_bytes: 3220
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(i=a;i<b;i++)
    #define rfo(i,b,a) for(i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 3e3 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int dp[MAX][MAX];
    string s,st,str;
    int nn;
    void solve()
    {
        cin>>s;
        cin>>st;
        n=s.length();
        nn=st.length();
        fo(i,1,n+1)
        {
            fo(j,1,nn+1)
            {
                if(s[i-1]==st[j-1])dp[i][j]=1+dp[i-1][j-1];
                else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    // 	cout<<dp[n][nn];
    	i=n;
    	j=nn;
    	 while(i>=1 && j>=1)
    	 if(dp[i][j]==max(dp[i-1][j],dp[i][j-1]))
    	 {
    	     if(dp[i-1][j]>dp[i][j-1])
    	     i--;
    	     else
    	     j--;
    	 }
    	 else
    	 {
    	     str.append(string(1,s[i-1]));
    	     i--;
    	     j--;
    	 }
    	 reverse(str.begin(),str.end());
    	 cout<<str<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
      	
      	// int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
      	ios_base::sync_with_stdio(0);
      	cin.tie(NULL);
      	
      	// cin>>t;while(t--)
      	solve();
      	
    	return 0;
      }

Measured memory_bytes: 70784
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

int N;
int min_dist[SIZE],adj[SIZE];

void dfs(int node_id,int dist){

	if(min_dist[adj[node_id]] > dist+1){

		min_dist[adj[node_id]] = dist+1;
		dfs(adj[node_id],dist+1);
	}
}

int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){

		min_dist[i] = BIG_NUM;
	}
	min_dist[0] = 0;

	int to;

	for(int from = 0; from < N; from++){

		scanf("%d",&to);
		to--;
		adj[from] = to;
	}

	dfs(0,0);

	if(min_dist[1] == BIG_NUM){

		printf("-1\n");
	}else{

		printf("%d\n",min_dist[1]);
	}

	return 0;
}


Measured memory_bytes: 4588
N = int(input())
A = [int(a) for a in input().split()]
    
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

L = [1]*N
for i in range(1, N):
    L[i] *= L[i-1]*i
    L[i] %= mod
    
ans = 0
for i in range(1, N):
    ans += cmb(N-1, N-i, mod)*L[i-1]*L[N-i-1]*(A[N-1]-A[i-1])
    ans %= mod
        
L2 = [0]*(N-1)
for i in range(N-1):
    L2[i] = A[i+1]-A[i]

S = [0]*N
for i in range(N-1):
    S[i+1] = S[i] + L2[i]
    
L3 = [0]*N
for i in range(1, N):
    if N-i-1 >= i:
        L3[i] = L3[i-1] + S[N-i-1] - S[i-1]
    else:
        L3[i] = L3[N-i-1]

for t in range(1, N-1):
    ans += cmb(N-1, t+1, mod)*L[N-t-2]*L[t-1]*L3[t]
    ans %= mod
        
print(ans)

Measured memory_bytes: 78616
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))
a = [0]*3
b = [0]*3
for i in range(101):
  a[0] = i
  for j in range(3):
    b[j] = r1[j]-a[0]
    
  a[1] = r2[0] - b[0]
  a[2] = r3[0] - b[0]

  flag = False
  for j in range(3):
    if r1[j]==a[0]+b[j] and r2[j]==a[1]+b[j] and r3[j] == a[2]+b[j]:
      flag = True
    else:
      flag = False
      break
  if flag:
    break
    
print("Yes") if flag else print("No")

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;
    cin >> n;
    double a,ans = 0;
    REP(i, n)
    {
        //double a;
        cin >> a;
        ans += 1 / a;
    }

    ans = 1 / ans;
    cout << std::setprecision(20)<< ans << "\n";

    return 0;
}

Measured memory_bytes: 256