akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	vector<bool> remove_y(h, false);
	vector<bool> remove_x(w, false);
	rep(i, h) {
		bool flag = true;
		rep(j, w) {
			if (s[i][j] == '#') flag = false;
		}
		if (flag) remove_y[i] = true;
	}
	rep(i, w) {
		bool flag = true;
		rep(j, h) {
			if (s[j][i] == '#') flag = false;
		}
		if (flag) remove_x[i] = true;
	}
	rep(i, h) {
		rep(j, w) {
			if (remove_y[i] || remove_x[j]) continue;
			cout << s[i][j];
		}
		if (!remove_y[i]) cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// ConsoleApplication2.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include"stdafx.h"
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;

	string a[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};
	int cnt = 0;
	for (int i = 0; i < 7; i++) {
		if (s != a[i]) {
			cnt += 1;
		}
		else {
			break;
		}

	}

	cout << 7 - cnt << endl;

	return 0;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    vector<ll> dp(W + 1);
    for(int j = 0; j < N; ++j) {
        cin >> w[j] >> v[j];
        for(int i = W; i >= 0; --i) {
            if(w[j] + i <= W) {
                dp[w[j] + i] = max(dp[w[j] + i], dp[i] + v[j]);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    if (n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s;
    cin >> s;
    if (s == "SUN")
    {
        cout << 7 << endl;
    }
    else if (s == "MON")
    {
        cout << 6 << endl;
    }
    else if (s == "TUE")
    {
        cout << 5 << endl;
    }
    else if (s == "WED")
    {
        cout << 4 << endl;
    }
    else if (s == "THU")
    {
        cout << 3 << endl;
    }
    else if (s == "FRI")
    {
        cout << 2 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
}

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

int bisearch(int S[],int n,int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid=(left + right) / 2;
    if(S[mid]==key)
      return 1;
    else if(key<S[mid])
      right = mid;
    else
      left = mid+1;
  }
  return 0;
}

int main() {
  
  int n;
  cin >> n;
  int S[n];
  for(int i=0;i<n;++i)
    cin >> S[i];

  int q;
  cin >> q;
  int T[q];
  for(int i=0;i<q;++i)
    cin >> T[i];
  
  int count = 0;
  for(int i=0;i<q;++i){
    if(bisearch(S,n,T[i]))
      count++;
  }
  
  cout << count << endl;
}

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

int main(){

  bool c;
  int i,n,num;
  char d,d1,d2;
  map<char,char> mp;

  while(cin >> n,n){  

    for(i=0;i<n;i++){
      cin >> d1 >> d2;
      mp.insert(make_pair(d1,d2));
    }

    cin >> n;

    for(i=0;i<n;i++){
      cin >> d;
      c=true;

      if(mp.find(d)!=mp.end()){
	pair<char,char> target=*mp.find(d);
	cout << target.second;
	c=false;
      }
    
      if(c) cout << d;
    }

    cout << endl;
    mp.clear();
  }
  
  return 0;
}

Measured memory_bytes: 3000
#include <iostream>
	using std::cin;
	using std::cout;
#include <string>
    using std::string;
#include <vector>
	using std::vector;

int main(){
	string str;

    cin >> str;

    int count = 0;
  	vector<char> temp;

    for(int i = 0;i < 4;++i){
        if(str[i] != 'n'){
            for(int j = 0;j < 4;++j){
                if(str[j] != 'n'){
                    if(i != j){
                        if(str[i] == str[j]){
                            count++;
                          	temp.push_back(str[i]);
                            str[i] = 'n';
                            str[j] = 'n';
                        }
                    }
                }
            }
        }
    }

    if(count == 2){
      	if(temp[0] != temp[1]){
        cout << "Yes";          
        }else{
        cout << "No";           
        }
    }else{
        cout << "No"; 
    }

	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;
typedef long long ll;

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h / 2;
    cout << fixed << setprecision(10) << ans << " ";
    if (w / 2 == x && h / 2 == y)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}
// Segment tree {{{
// O(N) 構築
// O(log(N)) update, query
// verified AOJ DSL_2_A
template <typename T>
struct SGT {
    vector<T> v;
    int n;
    T init;
    function<T(T, T)> f;
    SGT(vector<T> a, T init, function<T(T, T)> f){
        int m = a.size();
        n = 1;
        while(n < m) n <<= 1;
        this->init = init;
        this->f = f;
        v.resize(2*n-1, init);
        for(int i=0;i<m;i++) v[n-1+i] = a[i];
        for(int i=n-2;i>=0;i--) v[i] = min(v[i*2+1], v[i*2+2]);
    }
    void update(int i, T x) {
        i += n-1;
        v[i] = x;
        while(i>0){
            i = (i-1)/2;
            v[i] = f(v[i*2+1], v[i*2+2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return init;
        if(a <= l && r <= b) return v[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return f(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    SGT<int> sgt(a, INT_MAX, [](int a, int b){return min(a, b);});
    LL ans = 0;
    for(int i=0;i<n;i++){
        int l = i-1;
        int r = n;
        while(r-l>1){
            int c = (l+r)/2;
            if(sgt.query(i, c+1) == a[i]){
                l = c;
            }else{
                r = c;
            }
        }
        LL rr = r-i;
        l = -1;
        r = i+1;
        while(r-l>1){
            int c = (l+r)/2;
            if(sgt.query(c, i+1) == a[i]){
                r = c;
            }else{
                l = c;
            }
        }
        LL ll = i-r+1;
        ans += ll*rr*a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<string>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c;
if(b>a||b<1||a>20||a<1||c<0||c>20)
    return 0;
d=a-b;
d=c-d;
if(d<0)
    cout<<0;
else
cout<<d;
return 0;
}



Measured memory_bytes: 256
#!ruby -na
f=->n,m,a,b{s=a/m*n*~-n/2+b/m*n
b%=m
x=b-m*y=(b+n*a%=m)/m
s+=y>0?f[y,a,m,x%a]+y*=n+x/a:0}
p f[*$F.map(&:to_i)]if$.>1

Measured memory_bytes: 14336
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

//#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

int n, w;
std::vector<int> values(101), weights(10001);
int dp[101][10001];

int main() {
    std::cin >> n >> w;
    for (int i = 0; i < n; i++) {
        std::cin >> values[i] >> weights[i];
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            if (j < weights[i - 1]) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = std::max({dp[i][j - weights[i - 1]] + values[i - 1], dp[i - 1][j]});
        }
    }

    for (int i = -1; i <= n; i++) {
        if (i == -1) {
            printd("j:    ");
        } else {
            printd("i:%2d, ", i);
        }
        for (int j = 0; j <= w; j++) {
            if (i == -1) {
                printd("%2d  ", j);
                continue;
            }
            printd("%2d, ", dp[i][j]);
        }
        printd("\n");
    }

    std::cout << dp[n][w] << std::endl;
    
    return 0;
}



Measured memory_bytes: 7048
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int A, B, H;
    cin >> A >> B >> H;
    cout << (A + B) *H / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <atcoder/maxflow>

namespace ac = atcoder;

const std::vector<std::pair<int, int>>
    dxys{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::string> ss(n);
    for (auto& s : ss) std::cin >> s;

    int s = n * m, g = s + 1;
    auto enc = [&](int x, int y) { return x * m + y; };
    auto dec = [&](int v) { return std::make_pair(v / m, v % m); };

    ac::mf_graph<int> graph(n * m + 2);
    for (int x = 0; x < n; ++x) {
        for (int y = 0; y < m; ++y) {
            if (ss[x][y] == '#') continue;

            if ((x + y) % 2 == 0) {
                graph.add_edge(s, enc(x, y), 1);

                for (auto [dx, dy] : dxys) {
                    int nx = x + dx,
                        ny = y + dy;
                    if (nx < 0 || n <= nx ||
                        ny < 0 || m <= ny ||
                        ss[nx][ny] == '#') continue;
                    graph.add_edge(enc(x, y), enc(nx, ny), 1);
                }
            } else {
                graph.add_edge(enc(x, y), g, 1);
            }
        }
    }

    std::cout << graph.flow(s, g) << "\n";

    for (auto e : graph.edges()) {
        if (e.flow == 0) continue;

        auto [sx, sy] = dec(e.from);
        auto [gx, gy] = dec(e.to);
        if (sx >= n || gx >= n) continue;

        if (sx > gx || sy > gy) {
            std::swap(sx, gx);
            std::swap(sy, gy);
        }

        if (sx != gx) {
            ss[sx][sy] = 'v';
            ss[gx][gy] = '^';
        } else {
            ss[sx][sy] = '>';
            ss[gx][gy] = '<';
        }
    }

    for (const auto& v : ss) std::cout << v << "\n";
}

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

    solve();

    return 0;
}


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

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

    for(int i=0;i<k;i++) {
        a /= 2;
        b += a;
        i++;
        if(i==k) break;
        b /= 2;
        a += b;
    }

    cout << a << " " << b << endl;

    return 0;
}


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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

// nまでの素数のリストを作成(nを含む) O(N log log N)
vector<int> make_prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;

    vector<int> prime_list;
    for (int i = 2; i < n + 1; ++i) {
        if (!is_prime[i]) { continue; }
        prime_list.emplace_back(i);

        for (int j = i + i; j < n + 1; j += i) {
            is_prime[j] = false;
        }
    }
    return prime_list;  // 素数のリスト
    //return is_prime;  // すべての数値について素数かどうか
}

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

    while (true) {
        int n, x;
        cin >> n >> x;
        if (n == 0 and x == 0) { break; }

        VI v(n);
        FOR(i, 0, n) {
            cin >> v[i];
        }


        vector<bool> dp(x + 1, false);
        dp[0] = true;

        FOR(i, 0, dp.size()) {
            FOE(x, v) {
                if (dp[i] and i + x < dp.size()) {
                    dp[i + x] = true;
                }
            }
        }

        auto prime_list = make_prime_list(x + 1);
        int ans = 0;
        FOE(p, prime_list) {
            if (p <= x and dp[p]) {
                ans = max(ans, p);
            }
        }
        if (ans == 0) {
            print("NA");
        }
        else {
            print(ans);
        }
    }
}



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

using namespace std;

int main() {

	int i = 1;
	int x = 0;
	while (1) {
		cin >> x;
		if (x != 0) {
			cout << "Case " << i << ": " << x << endl;
			i++;
		}
		else {
			return 0;
		}
	}

}


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

int N, M;
vector<int> edges[1000];

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
    }

    vector<int> V;
    int ans = 1e9;
    for(int s=0; s<N; s++){
        queue<int> que;
        que.push(s);
        vector<int> d(N, -1), prv(N, -1);
        d[s] = 0;
        bool done = false;
        while(que.size() && !done){
            int i = que.front(); que.pop();
            for(int j : edges[i]){
                if(j == s){
                    int sz = d[i]+1;
                    cerr << s << " " << sz << endl;
                    if(sz < ans){
                        ans = sz;
                        V.clear();
                        while(true){
                            V.push_back(i);
                            if(i == s) break;
                            i = prv[i];
                        }
                    }
                    done = true;
                    break;
                }else if(d[j] == -1){
                    d[j] = d[i]+1;
                    prv[j] = i;
                    que.push(j);
                }
            }
        }
    }
    if(ans == 1e9){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
        for(int a : V) cout << a+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = I()

ans = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i

print(ans)
    


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

using namespace std;

#define SZ(x) ((int)x.size())

const int N = 100005;

int n, m;
int a[N];
int fa[N];

vector<int> val[N];

int getfa(int x) {
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

void merge(int x, int y) {
	x = getfa(x);
	y = getfa(y);
	if(SZ(val[x]) < SZ(val[y])) {
		swap(x, y);
	}
	for(auto v: val[y]) {
		val[x].push_back(v);
	}
	val[y].clear();
	fa[y] = x;
}

void input()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);

		val[i].push_back(a[i]);
		fa[i] = i;
	}
	for(int i = 1; i <= m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x++, y++;
		merge(x, y);
	}
}

void solve()
{
	long long ans = 0;

	int cnt = (n - 1 - m) * 2;

	if(cnt == 0) {
		puts("0");
		return;
	}

	vector<int> vec;
	for(int i = 1; i <= n; i++) {
		if(fa[i] == i) {
			sort(val[i].begin(), val[i].end());
			ans += val[i][0];
			cnt--;
			for(int j = 1; j < SZ(val[i]); j++) {
				vec.push_back(val[i][j]);
			}
		}
	}

	if(SZ(vec) < cnt) {
		puts("Impossible");
		return;
	}

	sort(vec.begin(), vec.end());
	for(int i = 0; i < cnt; i++) {
		ans += vec[i];
	}
	cout << ans << endl;
}

int main()
{
	input();
	solve();

	return 0;
}


Measured memory_bytes: 8184
#include<iostream>

using namespace std;

double dp[2][123][523];

int main(){
  int H,N,P,M,K;
  cin>>H>>N>>P>>M>>K;
  dp[H&1][P-1][K]=1;
  int AB[523]={};
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    AB[A]=B;
  }
  int nz[523]={};
  for(int i=1;i<=H;i++){
    nz[i]=nz[i-1]+!AB[i];
  }
  for(int i=H;i>0;i--){
    fill(*begin(dp[i-1&1]),*end(dp[i-1&1]),0);
    for(int j=0;j<N;j++){
      for(int k=0;k<=nz[i];k++){
	auto c=dp[i&1][j][k];
	if(AB[i]){
	  if(j==AB[i]-1){
	    dp[i-1&1][j+1][k]+=c;
	  }else if(j==AB[i]){
	    dp[i-1&1][j-1][k]+=c;
	  }else{
	    dp[i-1&1][j][k]+=c;
	  }
	}else{
	  double m=nz[i]?1.*k/nz[i]:0;
	  if(k){
	    int nn=0;
	    if(j){
	      dp[i-1&1][j-1][k-1]+=c*m/(N-1);
	      nn++;
	    }
	    if(j+1<N){
	      dp[i-1&1][j+1][k-1]+=c*m/(N-1);
	      nn++;
	    }
	    dp[i-1&1][j][k-1]+=c*m*(N-nn-1)/(N-1);
	  }
	  dp[i-1&1][j][k]+=c*(1-m);
	}
      }
    }
  }
  double mx=0;
  for(int i=0;i<N;i++){
    mx=max(mx,dp[0][i][0]);
  }
  cout<<fixed<<mx<<endl;
}

Measured memory_bytes: 2244
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[1000];
int b[1000];
int dp[10005];
int h, n;

int f(int h)
{
    if (h <= 0)
        return 0;
    
    int& sol = dp[h];
    if (sol != -1)
        return sol;

    sol = 1e9;
    for (int i = 0; i < n; ++i)
        sol = min(sol, b[i] + f(h - a[i]));
    return sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> n;
    vector<pair<int, int>> vp;
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    memset(dp, -1, sizeof dp);
    cout << f(h);
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

// ???????????????
int selectionSort(int A[], int n) {
	int cnt = 0;
	
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		if (i != minj)
			swap(A[i], A[minj]), cnt++;
	}
	return cnt;
}
int main() {
	int n, A[110];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	
	int cnt = selectionSort(A, n);
	for (int i = 0; i < n; i++)
		printf("%d%c", A[i], i == n - 1 ? '\n' : ' ');
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>

int main(void){
    int n, m, c, ans=0;
    std::cin >> n >> m >> c;
    std::vector<int> b(m);
    for (int i=0; i<m; ++i) std::cin >> b.at(i);

    for (int i=0; i<n; ++i){
        int cnt = 0;
        for (int j=0; j<m; ++j) {
            int tmp;
            std::cin >> tmp;
            cnt += b.at(j) * tmp;
        }
        if (cnt > -c) ++ans;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S, T;
	
	cin >> S >> T;
	
	vector<int> a(26), b(26);
	
	rep(i, S.length()){
		a[S[i] - 'a']++;
		b[T[i] - 'a']++;
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	rep(i, 26){
		if(a[i] != b[i]){
			cout << "No" << endl;
			return 0;
		}		
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define M (int)1e9
#define pi 3.1415926536
 
vector <int> SieveOfEratosthenes(int n) 
{ 
    vector<int> ans;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    if (prime[p] == true) 
    for (int i=p*p; i<=n; i += p) 
    prime[i] = false; 
        
  	for (int p=2; p<=n; p++) 
    if (prime[p]) 
    ans.push_back(p);
	return ans;
}
 
vector <int> fib(int n)
{
	vector<int> ans;
	int x=0,y=1,l=1;
	ans.push_back(x);
	ans.push_back(y);
	while(l<n)
	{
		l=x+y;
		x=y;y=l;
		ans.push_back(l);
	}
	return ans;
}
 
bool isPrime(int n) 
{ 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
 
	if (n%2 == 0 || n%3 == 0) return false; 
 
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
 
	return true; 
} 
 
 
long long power(int n,int k)
{
	if(k==0)	return 1;
	else return n*power(n,k-1);
}
 
int sdigit(int x)
{
	int ans=0;
	while(x)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}
 
long long lcm(int a,int b)
{
	return ((long long)a*(long long)b)/__gcd(a,b);
}
 
 bool aisekaro(string a,string b)
 {
    //cout<<a<<endl<<b<<endl;
 	int i=0;
 	char x=a[0];
	for(i;i<max(a.size(),b.size());i++)
	{
	    //cout<<a[i]<<" "<<b[i]<<endl;
		if(i<min(a.size(),b.size())){	
			if(a[i]>b[i])	return true;
			if(a[i]<b[i])	return false;
			if(a[i]==b[i])  continue;
			
			//x=a[i];
		}
		if(i>=a.size()){
			if(b[i]==x)	continue;
			else return b[i]<x;
		}
		if(i>=b.size()){
			if(a[i]==x)	continue;
			else  return a[i]>x;
		}

	}
	return true;
 }
 long long subArraySum(int arr[], int n, int sum) 
{ 
    int curr_sum = arr[0], start = 0, i; 
  
    for (i = 1; i <= n; i++) 
    { 
        while (curr_sum > sum && start < i - 1) 
        { 
            curr_sum = curr_sum - arr[start]; 
            start++; 
        } 
  
        
        if (curr_sum == sum) 
        {  
            cout << "Sum found between indexes " 
                 << start << " and " << i - 1; 
            return 1; 
        } 
  
        if (i < n) 
        curr_sum = curr_sum + arr[i]; 
    } 
  
    return -1; 
} 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	long double ah=h*30+.5*m,am=6*m;
	cout.precision(11);
	//cout<<cos((pi*(ah-am))/180)<<endl;
	cout<<(long double)sqrt(a*a+b*b-(2*a*b*cos((pi*(ah-am))/180)));
	return 0;
			
}

Measured memory_bytes: 4112
import java.util.Scanner;

//Drawing Lots
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int[] a = new int[w+1];
		for(int i=1;i<=w;i++)a[i]=i;
		int m = sc.nextInt();
		while(m--!=0){
			String[] s = sc.next().split(",");
			int l = Integer.parseInt(s[0]);
			int r = Integer.parseInt(s[1]);
			int t = a[l];
			a[l] = a[r];
			a[r] = t;
		}
		for(int i=1;i<=w;i++)System.out.println(a[i]);
	}
}



Measured memory_bytes: 26320
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1e9,LINF=1e18;
typedef pair<int,int> P;
typedef pair<P,int> PI;
P d[305][305];

signed main(){
  int N,M,L;cin>>N>>M>>L;
  vector<P> edge[N];
  for(int i=0;i<M;i++){
    int a,b,c;cin>>a>>b>>c;a--;b--;
    if(c>L)continue;
    edge[a].push_back(P(b,c));
    edge[b].push_back(P(a,c));
  }
  int Q;cin>>Q;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;i++){cin>>l[i]>>r[i];l[i]--;r[i]--;}
  priority_queue<PI,vector<PI>,greater<PI>> que;
  for(int i=0;i<305;i++){
    for(int j=0;j<305;j++){
      if(i==j)d[i][j]=P(0,0);
      else d[i][j]=P(LINF,LINF);
    }
  }
  for(int start=0;start<N;start++){
    que.push(PI(P(0,0),start));
    while(que.size()){
      PI p=que.top();que.pop();
      int charge=p.first.first,run=p.first.second,idx=p.second;
      if(d[start][idx]<P(charge,run))continue;
      for(auto q:edge[idx]){
        int fi,se;
        if(run+q.second>L)fi=charge+1,se=q.second;
        else fi=charge,se=run+q.second;
        if(d[start][q.first]>P(fi,se)){
          d[start][q.first]=P(fi,se);
          que.push(PI(d[start][q.first],q.first));
        }
      }
    }
  }
  for(int i=0;i<Q;i++){
    if(d[l[i]][r[i]].first>INF)cout<<-1<<endl;
    else cout<<d[l[i]][r[i]].first<<endl;
  }
}


Measured memory_bytes: 5760
import sys

a, b, c, x, y = map(int, input().split())

best_price = sys.maxsize


for i in range(0, max(x, y) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

print(best_price)



Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

string cnv(real w)
{
    if(w<=48) return "light fly";
    if(w<=51) return "fly";
    if(w<=54) return "bantam";
    if(w<=57) return "feather";
    if(w<=60) return "light";
    if(w<=64) return "light welter";
    if(w<=69) return "welter";
    if(w<=75) return "light middle";
    if(w<=81) return "middle";
    if(w<=91) return "light heavy";
    return "heavy";
}

void main()
{
    stdin.byLine().map!(s=>cnv(s.to!real())).join("\n").writeln();
}

Measured memory_bytes: 1080
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, K;
  cin>>H>>W>>K;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int ans = inf;
  int tmp;
  int index;
  bool out;
  bool outout;
  map<int, int> amap;
  for(int bit=0;bit<(1<<(H-1));++bit) {
    for(int i=0;i<H;++i) amap[i] = 0;
    outout = true;
    tmp = 0;
    for(int i=0;i<H-1;++i) {
      if((bit&(1<<i))!=0) tmp++;
    }
    for(int i=0;i<W;++i) {
      index = 0;
      out = true;
      for(int j=0;j<H;++j) {
        if(S[j][i]=='1') {
          amap[index]++;
          if(amap[index]>K) out = false;
        }
        if((bit&(1<<j))!=0) index++;
      } 
      if(!out) {
        if(!outout) break;
        tmp++;
        for(int j=0;j<H;++j) amap[j] = 0;
        i--;
        outout = false;
      }
      else outout = true;
    }
    if(!outout) continue;
    ans = min(ans, tmp);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int INF = 100000;
int main(){
    while(true){
        int N,M,L,K,A,H;
        //N=町の数,M=再冷凍を行うまでの制限時間,L=冷凍施設のある町の数,
        //K=町と町を直接結ぶ道路の数,A=本国の首都を表す番号,H=お姫様が搬送された病院のある町の番号
        cin >> N >> M >> L >> K >> A >> H;
        if(N == 0 and M == 0 and L == 0 and K == 0 and A == 0 and H == 0) break;
        vector<int> hospital;
        hospital.push_back(A);
        for(int i=0;i<L;i++){
            int x;
            cin >> x;
            hospital.push_back(x);
        }
        hospital.push_back(H);

        vector<vector<int> > allDist(N,vector<int>(N,INF));
        for(int i=0;i<K;i++){
            int x,y,t;
            cin >> x >> y >> t;
            allDist[x][y] = t;
            allDist[y][x] = t;
        }
        for(int i=0;i<N;i++){
            allDist[i][i] = 0;
        }
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    allDist[i][j] = min(allDist[i][j],allDist[i][k] + allDist[k][j]);
                }
            }
        }
        L += 2;
        vector<vector<int> > hd(L,vector<int>(L));
        for(int i=0;i<L;i++){
            for(int j=0;j<L;j++){
                hd[i][j] = allDist[hospital[i]][hospital[j]];
                if(hd[i][j] > M) hd[i][j] = INF;
            }
        }
        for(int k=0;k<L;k++){
            for(int i=0;i<L;i++){
                for(int j=0;j<L;j++){
                    hd[i][j] = min(hd[i][j],hd[i][k] + hd[k][j]);
                }
            }
        }
        if(hd[0][L-1] >= INF){
            cout << "Help!" << endl;
        }else{
            if(hd[0][L-1] > M){
                cout << hd[0][L-1] + hd[0][L-1] - M << endl;
            }else{
                cout << hd[0][L-1] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1304
n,a,b=map(int,input().split())
s=input()
c=a+b
A=0
B=0
for i in s:
    if A+B<c:
        if i=="a":
            A+=1
            print("Yes")
        elif i=="b" and B<b:
            B+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h){
    cin>>s[i];
  }
  rep(i,h){
    rep(j,w){
      bool fg=true;
      if(s[i][j]=='#'){
        rep(k,4){
          if(i+dx[k]>=0 && j+dy[k]>=0 && i+dx[k]<h && j+dy[k]<w){
            if(s[i+dx[k]][j+dy[k]]=='#'){
              fg=false;
            }
          }
        }
        if(fg){
          cout<<"No"<<'\n';
          return(0);
        }
      }
    }
  }
  cout<<"Yes"<<'\n';
  return(0);
}


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

int main() {
  int N;
  cin >> N;
  while(N >= 0) {
    if(N % 4 == 0) {
      cout << "Yes" << endl;
      return 0;
    } else {
      N = N - 7;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getList >>= putStrLn . which "YES" "NO" . ( == [ 5, 5, 7 ] ) . sort


Measured memory_bytes: 380
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int n,m;
int *dp;

int dfs(int s,vector<int>* graph){
  if(graph[s].size() == 0){
    dp[s] = 0;
    return dp[s];
  }
  int temp = -1;
  for(int i=0;i<graph[s].size();i++){
    int next = graph[s][i];
    if(dp[next] != -1){
      temp = max(temp,dp[next]+1);
    }
    else{
      temp = max(temp,dfs(next,graph)+1);
    }
  }
  dp[s] = temp;
  return temp;
}

int main(){
  cin >> n >> m;
  int x,y;
  vector<int> graph[n];
  int start[n];
  dp = new int[n];
  for(int i=0;i<n;i++){
    start[i] = 1;
    dp[i] = -1;
  }
  for(int i=0;i<m;i++){
    cin >> x >> y;
    graph[x-1].push_back(y-1);
    start[y-1] = 0;
  }
  
  for(int i=0;i<n;i++){
    dfs(i,graph);
  }

  int ans = -1;
  for(int i=0;i<n;i++){
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s;
    cin>>s;
    int counter=0;
    int n=s.size();
    rep(i,n-2) {
        counter++;
    }
    cout<<s.at(0)<<counter<<s.at(n-1)<<endl;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

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

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

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> cs(n);
    rep(i, n) cin >> cs[i];

    sort(cs.rbegin(), cs.rend());

    ll l = cs.front();
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ll now = min(cs[i], l - cs[i]);
        if (min(ans, l - ans) < now) {
            ans = cs[i];
        }
    }

    printf("%lld %lld\n", l, ans);

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
P a[101],b[101];
bool used[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].first,&a[i].second);
	}
	for(int i=0;i<n;i++){
		scanf("%d%d",&b[i].first,&b[i].second);
	}
	sort(a,a+n);
	sort(b,b+n);
	int cnt=0;
	for(int i=n-1;i>=0;i--){
		int v=-1;
		for(int j=0;j<n;j++){
			if(a[i].first<b[j].first && a[i].second<b[j].second){
				if(!used[j]){
					if(v==-1)v=j;
					else if(b[v].second>b[j].second)v=j;
				}
			}
		}
		if(v!=-1){
			used[v]=true;
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int t[N+1], x[N+1], y[N+1];
    t[0]=0; x[0]=0; y[0]=0;
    for(int i = 1; i <= N; i++)
        cin >> t[i] >> x[i] >> y[i];
    int rex[N+1], rey[N+1], ret[N+1];
    for(int i = 1; i <= N;  i++){
        rex[i]=x[i]-x[i-1]; rey[i]=y[i]-y[i-1]; ret[i]=t[i]-t[i-1];
            if((abs(rex[i])+abs(rey[i])-ret[i])%2!=0 || (abs(rex[i])+abs(rey[i]))>ret[i]){
                cout << "No" << endl;
            break;
       }
        if(i==N)
           cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
"""
カーテンが2枚、縦は無視していいというのをすぐ把握すること。
カーテンの長さの合計が窓の長さを上回った時0になる。
制約
A,Bは整数
1≦A≦100
1≦B≦100
"""
#入力
A, B = map(int, input().split())

#計算
ans = A - 2 * B 

#判別&出力
if ans < 0:
  print(0)
else:
  print(ans)

Measured memory_bytes: 2940
/*
g++ -std=c++14 -o2 -Wall ABC.cpp -o .\out\ABC.out
.\out\ABC.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int al[100005];
int ar[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans;
  if (a >= 13) ans = b;
  else if (a <= 12 && a >= 6) ans = b/2;
  else ans = 0;
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#define POS_MAX  10000
#define GRID     40
#define GRID_NUM 250 // POS_MAX / GRID


struct pos_t {
    pos_t() {}
    pos_t(int _x, int _y) : x(_x), y(_y) {}
    pos_t(std::istream *is) { (*is) >> x >> y; }
    int x, y;
};


void process(const int AN, const int BN, const int R)
{
    std::vector<pos_t> as(AN), bs(BN);
    for (int i = 0; i < AN; ++i) as[i] = pos_t(&std::cin);
    for (int i = 0; i < BN; ++i) bs[i] = pos_t(&std::cin);

    std::list<pos_t*> bs_grid[GRID_NUM][GRID_NUM];
    for (int i = 0; i < BN; ++i)
    {
        int gx(bs[i].x / GRID), gy(bs[i].y / GRID);
        bs_grid[gx][gy].push_back(&bs[i]);
    }

    int sum(0);
    for (int i = 0; i < AN; ++i)
    {
        pos_t &a = as[i];
        int gx(as[i].x / GRID), gy(as[i].y / GRID);

        for (int dx = -1; dx <= 1; ++dx)
        {
            int tx(gx + dx);
            if (tx < 0 or tx >= GRID_NUM) continue;
            
            for (int dy = -1; dy <= 1; ++dy)
            {
                int ty(gy + dy);
                if (ty < 0 or ty >= GRID_NUM) continue;

                for (auto b : bs_grid[tx][ty])
                {
                    int dx(b->x - a.x), dy(b->y - a.y);
                    if (dx*dx + dy*dy <= 16 * R * R)
                        ++sum;
                }
            }
        }
    }

    std::cout << sum << std::endl;
}


int main()
{
    int AN, BN, R;
    do
    {
        std::cin >> AN >> BN >> R;
        if (AN > 0 and BN > 0 and R > 0) process(AN, BN, R);
    }
    while(AN > 0);
    
    return 0;
}

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

using namespace std;

int main()
{
    int a[3], chk;

    while (cin >> a[0] >> a[1] >> a[2], a[0] || a[1] || a[2]) {
        sort(a, a + 3);
        chk = a[0] * a[0] + a[1] * a[1];

        int n;        
        cin >> n;
        while (n--) {
            int r;

            cin >> r;
            if (4 * r * r > chk)
                cout << "OK" << endl;
            else
                cout << "NA" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1172
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        Set noSet = new HashSet<Integer>();
        for (int i=1;i<=n;i++) {
            noSet.add(sc.nextInt());
        }

        for (int i=0;i<=100;i++) {
            if (!noSet.contains(x-i)) {
                System.out.println(x-i);
                return;
            }
            if (!noSet.contains(x+i)) {
                System.out.println(x+i);
                return;
            }
        }
    }
}


Measured memory_bytes: 35904
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

vector<int> to[200010];
int ans[200010];

void dfs(int now, int p = -1){
	for(int a : to[now]){
		if(p==a)
			continue;
		ans[a] += ans[now];
		dfs(a, now);
	}
}
int main()
{
	int n, q;
	cin >> n >> q;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i,q){
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i,n){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 23424
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,m,a,b;
  vector<ll> G[60];
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<n;i++){
    cout << G[i].size()<<endl;
  }
}


Measured memory_bytes: 256
import sys

S = input()

N = len(S)-1

for i in range(2**N):
    op = ["+"]*N

    for j in range(N):
        if (i>>j)&1:
            op[j] = "-"
    s = ""
    
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[N]
    if 7==eval(s):
        print(S[0]+op[0]+S[1]+op[1]+S[2]+op[2]+S[3]+"=7")
        sys.exit()

Measured memory_bytes: 3064
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> S >> T;
  ans = 0;
  rep(i, 3) if(S[i] == T[i]) ans++;

  cout << ans << endl;

}


Measured memory_bytes: 256