akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;

struct node {
    int v, next;
} e[200005];

int cnt;
int head[100005], sum[100005], use[100005];

void add(int u, int v) {
    e[cnt].v = v;
    e[cnt].next = head[u];
    head[u] = cnt++;
}

void DFS(int st, int cot) {
    for (int i = head[st]; i != -1; i = e[i].next) {
        if (use[e[i].v] == 0) {
            use[e[i].v] = cot;
            sum[cot]++;
            DFS(e[i].v, cot);
        }

    }
}

void solve() {
    cnt = 1;
    memset(head, -1, sizeof(head));

    int N, M, K, u, v, t = 0;
    int df[100005], db[100005], temp[100005][2];
    memset(df, 0, sizeof(df));
    memset(db, 0, sizeof(db));

    cin >> N >> M >> K;
    for (int i = 0; i < M; ++i) {
        cin >> u >> v;
        add(u, v);
        add(v, u);
        df[u]++, df[v]++;
    }
    for (int i = 0; i < K; ++i) {
        cin >> temp[i][0] >> temp[i][1];
    }

    for (int i = 0; i <= N; ++i) use[i] = 0, sum[i] = 1;

    for (int i = 1; i <= N; ++i) {
        if (!use[i]) {
            use[i] = ++t;
            DFS(i, t);
        }
    }

    for (int i = 0; i < K; ++i) {
        if (use[temp[i][0]] == use[temp[i][1]]) {
            db[temp[i][0]]++;
            db[temp[i][1]]++;
        }
    }
/*
    cout << t << endl;
    for (int i = 1; i <= N; ++i) cout << db[i] << " ";
    cout << endl;
*/
    for (int i = 1; i <= N; ++i) {
        cout << sum[use[i]] - df[i] - db[i] - 1 << " ";
    }
    cout << endl;
}

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


Measured memory_bytes: 5888
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-28-20.18.13 Saturday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = (int)1e4+1000;
i64 n, x, y, ans[maxn];

i64 myabs(i64 x) {return (x>0?x:-x);}
i64 dist(int u, int v) {
    int res1 = 0, res2 = 0, res3 = 0;
    res1 = v-u;
    res2 = myabs(x-u)+1+myabs(y-v);
    res3 = myabs(y-u)+1+myabs(x-v);
    return min(res1, min(res2, res3));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> x >> y;
    ms(ans, 0);
    for (int i = 1; i <= n; ++i) {
//        if (i > x && i < y) {
//            for (int j = i+1; j <= n; ++j) ++ans[j-i];
//        } else {
            for (int j = i+1; j <= n; ++j) {
                i64 temp = dist(i, j);
                ++ans[temp];
            }
        //}
    }
    for (int i = 1; i <= n-1; ++i) cout << ans[i] << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 384
using System;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int pos = 0;
        bool flag = false;

        for (int i = 2; i < s.Length - 1; i++)
        {
            if (s[i] == 'C' && flag == true)
            {
                flag = false;
                break;
            }
            if (s[i] == 'C')
            {
                flag = true;
                pos = i;
            }
        }

        if (s[0] != 'A' && flag == true) flag = false;

        if (flag)
        {
            for (int i = 1; i < s.Length; i++)
            {
                if (char.IsUpper(s[i]) == true && i != pos)
                {
                    flag = false;
                    break;
                }
            }
        }

        if (flag)
            Console.WriteLine("AC");
        else
            Console.WriteLine("WA");
    }
}

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

int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  
  if(x<0) x*=-1;
  
  if(k<=x/d) cout << x-d*k << endl;
  else{
    k-=x/d;
    x%=d;
    if(k%2) cout << d-x << endl;
    else cout << x << endl;
  }
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	string S, T;
	cin >> S >> T;

	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;

	if (S == U) {
		cout << A - 1 << " " << B << endl;
	}
	else {
		cout << A << " " << B - 1 << endl;
	}

	return 0;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> graph[n+1];
  for (int i = 2; i <= n; i++) {
    graph[i].emplace_back(i-1, 0);
  }
  for (int i = 0; i < m; i++) {
    int l, r, c;
    cin >> l >> r >> c;
    graph[l].emplace_back(r, c);
  }

  int d[n+1];
  for (int i = 1; i <= n; i++) d[i] = INT_MAX;

  priority_queue<pair<int, int>> pq;
  pq.emplace(0, 1);

  while (!pq.empty()) {
    int w = -pq.top().first;
    int v = pq.top().second;
    pq.pop();
    if (d[v] == INT_MAX) {
      d[v] = w;
      for (auto child : graph[v]) {
        if (d[child.first] == INT_MAX) {
          pq.emplace(-w - child.second, child.first);
        }
      }
    }
  }

  if (d[n] == INT_MAX) cout << -1;
  else cout << d[n];
}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    rep(i,n-1){
        ans+=(i+1);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int N = 0;
    int count = 0;

    scanf("%d", &N);

    char S[N];

    scanf("%s", S);

    for (int i = 0; i < (N - 2); i++){

        if ( S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C' ){

            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

bool is753(int n){
    string s = to_string(n);
    if ((int)s.size() < 3)  {
        return false;
    }

    vi a(3,0);
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '3') {
            a[0]++;
        }else if (s[i] == '5'){
            a[1]++;
        }else if (s[i] == '7'){
            a[2]++;
        }else{
            return false;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (a[i] == 0) {
            return false;
        }
    }
    return true;
}

int N;
int dfs(string s){
    if (stol(s) > N) {
        return 0;
    }

    int ret = is753(stoi(s)) ? 1 : 0;
    string cand = "753";
    for (int i = 0; i < 3; i++) {
        string stmp = {cand[i]};
        ret += dfs(s + stmp);
    }
    return ret;
}


void solve(){
    cin >> N;

    string a = "0";
    cout << dfs(a) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

int solve(int N){
    int av=0,in,mn,mx;
    for(int i=0;i<N;i++){
        cin >> in;
        av+=in;
        if(i==0){
            mn=in;
            mx=in;
        }
        if(mx<in)   mx = in;
        if(mn>in)   mn = in;
    }
    return (av-mx-mn)/(N-2);
}

int main(){
    int N;
    for(;;){
        cin >> N;
        if(N==0)
            break;
        cout << solve(N) << endl;
    }
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iostream>
#include <utility>
 
using namespace std;
using ll = long long;
using ld = long double;
using Vl = vector<ll>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
using vs = vector<string>;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)

ll N, W;
Vl w(N), v(N);
ll dp[101][100001]; //0

int main() {
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    ll maxValue = 0;
    REP(i,N){
        cin >> w[i] >> v[i];
        maxValue+=v[i];
    }


    REP(i,N) REP(vi,maxValue+1) dp[i][vi] = ll(1e18);//クソ重くしとく
    dp[0][0] = 0;

    REP(i,N) REP(vi,maxValue+1){
        if(vi>=v[i]){ //同価値で軽い人を入れる。
            dp[i+1][vi]=min(dp[i][vi],dp[i][vi-v[i]]+w[i]);
        } else { // 同価値のものが見つからないばやい
            dp[i+1][vi]=dp[i][vi];
        }
    }
    int ans=0; 
    REP(vi,maxValue+1){
        if(dp[N][vi]<=W)ans=vi; //viのときの重さ
    }

    cout << ans;
    
    return 0;
}

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

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

const int N = 1e5 + 5;

int cnt[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	for (int i = 0; i < 10; i++) {
		if(cnt[i] == 2) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

burger = [1] + [0 for i in range(50)]
niku = [1] + [0 for i in range(50)]
for i in range(50):
    burger[i+1] = 2 * burger[i] + 3
    niku[i+1] = 2 * niku[i] + 1

n, x = getMN()

def singleburger(x):
    if x <= 1:
        return 0
    elif x <= 4:
        return x-1
    else: return 3

def intonburger(n,x):
    if n == 1:
        return singleburger(x)
    if x <= 1:
        return 0
    elif x <= burger[n-1] + 1:
        return intonburger(n-1, x-1)
    elif x == burger[n-1] + 2:
        return niku[n-1] + 1
    elif x <= 2 * burger[n-1] + 2:
        return niku[n-1] + 1 + intonburger(n-1, x-burger[n-1]-2)
    else:
        return 2 * niku[n-1] + 1

print(intonburger(n,x))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10 ;
char s[maxn] ;
int main() {
	scanf("%s", s + 1) ;
	int n = strlen (s + 1) ;
	int ans = 0 ;
	for (int i = 2; i <= n; i ++) {
		if (s[i] != s[i - 1]) ans ++ ;
	}
	printf("%d\n", ans) ;
	return 0 ;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  A.emplace_back(1LL << 40);
  B.emplace_back(1LL << 40);
  C.emplace_back(1LL << 40);
  int64_t res = 0;
  for (int b = 0; b < N; b++) {
    int64_t a = (lower_bound(A.begin(), A.end(), B[b]) - A.begin()) - 1;
    int64_t c = lower_bound(C.begin(), C.end(), B[b] + 1) - C.begin();
    if (A[a] == B[b] || B[b] == C[c]) continue;
    res += (a + 1) * (N - c);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3456
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (y3-y2)
y4 = y3 + (x3-x2)

print(x3, y3, x4, y4)


Measured memory_bytes: 9004
#include<stdio.h>

int main(void) {
        int H, W, i, j;
        while(1) {
                scanf("%d %d", &H, &W);
                if(H==0 && W==0)        break;
                for(i=0;i<H;i++) {
                        for(j=0;j<W;j++) {
                                if((i%2==1 && j%2==1) || (i%2==0 && j%2==0)) {
                                        printf("#");
                                } else {
                                        printf(".");
                                }
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 572
import os

def main():
	n = int(input())
	flag = False
	for i in range(1,10):
		if (n%i == 0) and (n//i < 10):
			flag = True
			break
	if flag:
		print("Yes")
	else:
		print("No")	

if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
N = int(input())
counter = 0
listA = []
listB = []
for i in range(N):
    s = input()
    counter += s.count('AB')
    if s[-1] == 'A':
        listA += [i]
    if s[0] == 'B':
        listB += [i]
if listA == [] and listB == []:
    counter += 0
elif listA == listB:
    counter += len(listA)-1
else:
    counter += min(len(listA), len(listB))
print(counter)

Measured memory_bytes: 3572
#include <iostream> 
#include <string> 
#define ll long long
using namespace std;
int main(){
    ll score=0;
    int x=0;
    string a;
    cin >> a;
    for(int i=0; i<a.size(); i++){
        if(a[i]=='B'){
            x++;
        }
        else{
            score+=x;
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

//#include "atcoder/all"
//using namespace atcoder;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, n;
	cin >> h >> n;
	vector<int> dp(h+1, 1e9);
	dp[0] = 0;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		rep(j,h+1){
			int nj = min(j+a, h);
			chmin(dp[nj], dp[j] + b);
		}
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll A,ll M){return pow1(A,M-2,M);}
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll factmod(ll n,ll mod){ll s=1; for(ll i=1;i<=n;i++){s*=i;s%=mod;} return s;}
vll fact1tonmod(ll n,ll mod){vll  ans(n+1);ans[0]=ans[1]=1;
    for(ll i=2;i<=n;i++)ans[i]=(ans[i-1]*i)%mod;
    return ans;
}
ll ncrmod(ll n,ll r,ll mod){
    ll ans=((((factmod(n,mod)%mod)*(modinv(factmod(r,mod),mod)%mod))%mod)*(modinv(factmod(n-r,mod),mod)))%mod;
    return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
    ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
        for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
void solve(){
    ll i,j,k,n,l,m,x,y,z,r;
	cin>>n>>k;
	n++;
	vll fac(n+11);
	fac[0]=fac[1]=1;
	for(i=2;i<=n;i++){
		fac[i]=(i*fac[i-1])%MOD;
	}
	vll inv(n+11);
	inv[n]=modinv(fac[n],MOD);
	for(i=n-1;i>=0;i--){
		inv[i]=(i+1)*(inv[i+1]);
		inv[i]%=MOD;
	}
	ll ans=0;
	for(i=k;i<=n;i++){
		ll t1=(k-1)*(k);
		t1%=MOD;
		t1*=inv[2];
		t1%=MOD;
		ll t2=t1;
		t2+=((n-i)*i)%MOD;
		t2%=MOD;
		// cout<<t2<<" "<<t1<<endl;
		ans+=(t2-t1 + 1+MOD)%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
    
}
int main(){
    // FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
	// cin>>q;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6308
#include<iostream>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (B < A) {
        cout << 1 << endl;
        return 0;
    }
    B -= A;
    int ans = 1;
    ans += (B + A - 2) / (A - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# input = stdin.readline



def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main(){
int N,K;
cin>>N>>K;
vi a(N),r;
for(int &x:a)cin>>x;
sort(a.begin(),a.end());
for(int i=0;i<N-K+1;i++){
    r.push_back(a[i+K-1]-a[i]);
}
sort(r.begin(),r.end());
cout<<r[0];

return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>

using ll = long long;

ll n, a;
ll x[50];

ll memo[50 * 50 + 1][50 + 1][50 + 1];
ll dp(int i_,int j_,int k_)
{
	if (i_ < 0 || j_ < 0)return 0;
	return memo[i_][j_][k_];
}

int main()
{
	scanf("%lld %lld", &n, &a);
	memset(memo, 0, sizeof(memo));
	memo[0][0][0] = 1;
	for (int k = 0; k < n; ++k)scanf("%lld", x + k);
	for (int j = 1; j <= n; ++j)
	{
		for (int i = 0; i <= a * n; ++i)
		{
			for (int k = 0; k <= n; ++k)
			{
				memo[i][j][k] = dp(i - x[j - 1], j - 1, k - 1) + dp(i, j - 1, k);
			}
		}
	}
	ll ans = 0;
	for (int k = 1; k <= n; ++k)
	{
		ans += memo[a*k][n][k];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 50944
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		int i = 0;// ループ回数設定値 １行目で入力した数値をここに格納する

		// 1行目読み込み・ループ回数設定
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		i = Integer.parseInt(str);

		// 2行目読み込み・配列に格納
		str = scan.nextLine();
		String[] array = str.split(" ");

		// 1行目で読み込んだ値と配列の要素数が一致したときのみ出力
		if(i == array.length){
			for(int j = i ; j > 0; j--){
				if(j == 1){
					System.out.print(array[j-1]);
				}
				else{
					System.out.print(array[j-1] + " ");
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 26172
N, M = map(int, input().split())
R = [tuple(map(int, input().split())) for _ in range(M)]
C = [[] for _ in range(N)]
for r in R:
	C[r[0]-1].append(r[1]-1)
	C[r[1]-1].append(r[0]-1)
for c in C:
	print(len(c))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Solution();
	}

}

class Solution {

	private int n;

	public Solution() {
		this.setScanner();
		this.run();
	}

	private void setScanner() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sc.close();
	}

	private void run() {

		if (n < 4) {
			System.out.println("No");
			return;
		}

		for (int cake = 0; cake <= 100 / 4; cake++) {
			for (int donuts = 0; donuts <= 100 / 7; donuts++) {
				if (4 * cake + 7 * donuts == n) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");
	}

}

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

using namespace std;

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

  double den = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;

    den += 1.0 / a;
  }

  cout << fixed << setprecision(6) << 1.0 / den << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
pw = STR()
wlist = [pw]
for _ in range(n - 1):
    w = STR()
    if pw[-1] != w[0] or w in wlist:
        print('No')
        exit()
    wlist.append(w)
    pw = w
print('Yes')

Measured memory_bytes: 5712
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<long long> a(A), b(B), x(M), y(M), c(M);
  rep(i,A) cin >> a.at(i);
  rep(i,B) cin >> b.at(i);
  rep(i,M) cin >> x.at(i) >> y.at(i) >> c.at(i);
  long long  mini = 200000;
  rep(i,M){
    if((a.at(x.at(i)-1)+b.at(y.at(i)-1) - c.at(i)) <= mini ){
      mini = (a.at(x.at(i)-1)+b.at(y.at(i)-1) - c.at(i));
    }
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(mini > a.at(0)+b.at(0) ) mini = a.at(0) + b.at(0);
  cout << mini << endl;
}

Measured memory_bytes: 7200
#include <iostream>

using namespace std;

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x3 = (y1 - y2) + x2;
    y3 = - (x1 - x2) + y2;
    x4 = (y2 - y3) + x3;
    y4 = - (x2 - x3) + y3;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
    
    return 0;
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i <= int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int mod = 1000000007;

inline int add(int a, int b);
inline int mult(int a, int b);
inline int sub(int a, int b);

int up[100500];
int down[100500];
vector<int> gr[100500];

void calc_down(int v, int par = -1) {
    down[v] = 1;

    for (int x : gr[v])
        if (x != par) {
            calc_down(x, v);
            down[v] = mult(down[v], (1 + down[x]));
        }
}

void calc_up(int v, int par = -1) {
    if (par == -1)
        up[v] = 1;

    vector<int> children;
    for (int x : gr[v])
        if (x != par)
            children.push_back(x);

    vector<int> pref(children.size() + 1, 1);
    vector<int> suf(children.size() + 1, 1);

    for (int i = 0; i < children.size(); i++)
        pref[i + 1] = mult(pref[i], down[children[i]] + 1);

    for (int i = int(children.size()) - 1; i >= 0; i--)
        suf[i] = mult(suf[i + 1], down[children[i]] + 1);

    for (int i = 0; i < children.size(); i++)
        up[children[i]] = add(1, mult(up[v], mult(pref[i], suf[i + 1])));

    for (int x : children)
        calc_up(x, v);
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);

    int n;
    cin >> n >> mod;

    forn(i, n - 1) {
        int v, u;
        cin >> v >> u;
        v--; u--;
        gr[v].push_back(u);
        gr[u].push_back(v);
    }

    calc_down(0);
    calc_up(0);

    for (int i = 0; i < n; i++)
        cout << mult(up[i], down[i]) << "\n";

    return 0;
}

int add(int a, int b) {
    int result = a + b;
    if (result >= mod)
        result -= mod;
    return result;
}

int sub(int a, int b) {
    int result = a - b;
    if (result < 0)
        result += mod;
    return result;
}

int mult(int a, int b) {
    return (a * 1ll * b) % mod;
}

Measured memory_bytes: 22144
lst=[['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['####################'],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['####################'],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['####################'],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0],['',0,0,0,0,0,0,0,0,0,0]]
ls1=lst[0]
ls2=lst[1]
ls3=lst[2]
ls4=lst[3]
ls5=lst[4]
ls6=lst[5]
ls7=lst[6]
ls8=lst[7]
ls9=lst[8]
ls10=lst[9]
ls11=lst[10]
ls12=lst[11]
ls13=lst[12]
ls14=lst[13]
ls15=lst[14]
n=int(input())
for i in range(n):
    b,f,r,v=(int(x) for x in input().split())
    if b==1:
        if f==1:
            ls1[r]+=v
        elif f==2:
            ls2[r]+=v
        else:
            ls3[r]+=v
    elif b==2:
        if f==1:
            ls5[r]+=v
        elif f==2:
            ls6[r]+=v
        else:
            ls7[r]+=v
    elif b==3:
        if f==1:
            ls9[r]+=v
        elif f==2:
            ls10[r]+=v
        else:
            ls11[r]+=v
    else:
        if f==1:
            ls13[r]+=v
        elif f==2:
            ls14[r]+=v
        else:
            ls15[r]+=v
for l in lst:
    print(*l)


Measured memory_bytes: 5644
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
#define MOD 1e9+7
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int main()
{
    speed();
    ll a;
    cin>>a;
    if(a<30)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    
    
}



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

int main(){
  char a;
  cin >> a;
  if(int(a) - 90 > 0)
    cout << "a" << endl;
  else 
    cout << "A" << endl;
}


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


int main()
{
	int N;
	cin>>N;
	map<int,ll> m;
	vector<int> A(N);
	rep(i,N)
	{
		cin>>A[i];
		m[A[i]]++;
	}
	ll ans=0;
	for(auto p : m)
	{
		ans+=p.second*(p.second-1)/2;
	}
	for(int a : A)
	{
		ll v=m[a];
		cout<<ans-(v*(v-1)/2-(v-1)*(v-2)/2)<<endl;
	}
	return 0;
}


Measured memory_bytes: 11872
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n,qr;
	cin>>n>>qr;
	vector<ll>v[n+1];
	for(ll i=0;i<n-1;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<ll> arr(n+1,0),vis(n+1,0);
	while(qr--)
	{
		ll p,x;
		cin>>p>>x;
		arr[p]+=x;
	}
	
	queue<ll>q;
	
	q.push(1);
	vis[1]=1;

	while(q.size())
	{
		ll top=q.front();
		q.pop();
		for(ll i=0;i<v[top].size();i++)
		{
			if(!vis[v[top][i]])
			{
				arr[v[top][i]]+=arr[top];
				vis[v[top][i]]=1;
				q.push(v[top][i]);
			}
		}
	}
	
	for(ll i=1;i<=n;i++)
	cout<<arr[i]<<" ";
}

Measured memory_bytes: 19440
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(String.valueOf(a + b).length());
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

#define MAXN 2999

using namespace std;

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

    int n;
    long double p[MAXN+1];
    long double d[MAXN+1][MAXN+1];

    cin >> n;
    for(int i=1 ; i<=n ; i++) cin >> p[i];
    for(int i=0 ; i<=n ; i++)
        for(int j=0 ; j<=n ; j++)
            d[i][j] = 0;

    d[0][0] = 1;
    d[0][1] = 0;
    for(int i=1 ; i<=n ; i++)
    {
        d[i][0] = d[i-1][0] * (1 - p[i]);
        for(int j=1 ; j<=i ; j++)
        {
            d[i][j] = d[i-1][j-1] * p[i] + d[i-1][j] * (1 - p[i]);
        }
    }

    long double ans = 0;
    for(int i=n/2+1 ; i<=n ; i++) ans += d[n][i];

    cout << fixed << setprecision(10) << ans;

    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>

using namespace std;

vector<long long int> a;
vector<vector<long long int>> dp;

long long int find(int i, int j){
    if(dp[i][j]!=-1) return dp[i][j];

    if(i==j)
        dp[i][j] = a[i];
    else
        dp[i][j] = max(a[i] - find(i+1,j), a[j] - find(i,j-1));
    return dp[i][j];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n;
        cin >> n;
        a = vector<long long int> (n);
        for(int i=0 ; i<n ; i++){
            cin >> a[i];
        }
        
        dp = vector<vector<long long int>> (n,vector<long long int>(n,-1));

        cout << find(0,n-1) << "\n";
    }
    return 0;
}



Measured memory_bytes: 73924
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int k, x;
    cin >> k >> x;
    
    for(int i = x - (k - 1);i<=x + (k-1);i++)
    {
        cout << i;
        if(i < x + k - 1) cout << " ";
    }
    
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
main = do
    [a, b, c] <- map read . words <$> getLine
    putStrLn (if isOrd [a, b, c] then "Yes" else "No")
isOrd :: [Int] -> Bool
isOrd [a, b, c] | a < b && b < c = True
                | otherwise = False

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
	int X, Y;
	cin >> X >> Y;

	if (( Y - 2*X) % 2 == 0 ) {
		int a = (4 * X - Y) / 2;
		int b = (Y- 2 * X) / 2;
		if (a >= 0 && b >= 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long LL;
struct node
{
    LL x,y;
    friend bool operator<(node n1,node n2)
    {
        return n1.y<n2.y;
    }
}a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    LL x1,y1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",&x1,&y1);
        a[i].x=x1-y1;
        a[i].y=x1+y1;
    }
    sort(a,a+n);
    int cnt=1;
    LL t=a[0].y;
    for(int i=1;i<n;i++)
    {
        if(t>a[i].x) t=min(t,a[i].y);
        else cnt++,t=a[i].y;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 1792
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0] << '\n'; 
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();

        boolean ok=false;
        if(k==0) {
        	ok=true;
        	for (int i = 0; i < 1<<n; i++) {
                out.print(i+" ");
			}
        	for (int i = 0; i < 1<<n; i++) {
                out.print(((1<<n)-i-1)+" ");
			}
        	out.println();            
        } else if(k<1<<n && n>1) {
        	ok=true;
        	for (int i = 0; i < 1<<n; i++) {
        		if(i==k)continue;
                out.print(i+" ");
			}
            out.print(k+" ");
        	for (int i = 0; i < 1<<n; i++) {
        		if((1<<n)-i-1==k)continue;
                out.print(((1<<n)-i-1)+" ");
			}
            out.println(k);            
        }
        if(!ok)
        out.println(-1);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}


//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 41916
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

int m1[12][12];
char m[12][12];
char t;

void foo(int a,int b){
	if(a<0||a>11||b<0||b>11) return;
	if(m1[a][b]==0) return;
	m1[a][b]=0;
	foo(a+1,b);
	foo(a-1,b);
	foo(a,b+1);
	foo(a,b-1);
}

int main(){
	while(cin>>m[0][0]){
		int res=0;
		//cout<<m[0][0]<<endl;
		rep(i,11) cin>>m[0][i+1];
		rep(i,11){
			rep(j,12){
				cin>>m[i+1][j];
			}
		}
		rep(i,12){
			rep(j,12){
				m1[i][j]=m[i][j]-'0';
			}
		}
		rep(i,12){
			rep(j,12){
				if(m1[i][j]==1){
					foo(i,j);
					res++;
				}
			}
		}
		cout<<res<<endl;
	}
	//cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll k1 = v[n/2-1];
    ll k2 = v[n/2];
    cout<<k2-k1<<endl;



    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int w[6]={200,300,500,1000,1200,1500};
int v[6]={380,550,850,38*5*8,11*2*85,2244};

int main(){
	vector<int> dp(5500,1e9);
	dp[0]=0;
	for(int i=0;i<6;i++){
		for(int j=0;j+w[i]<5500;j++){
			if(dp[j]==1e9)continue;
			dp[j+w[i]]=min(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	int n;
	while(cin >> n,n){
		cout << dp[n] << endl;
	}
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[50000];
int main(){
  while(cin>>n&&n){
    ans=1e9;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++)ans=min(ans,a[i]-a[i-1]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
int main(void)
{
	double weight;

	while (scanf("%lf", &weight) != EOF) {
		if (48.00 >= weight) {
			printf("light fly\n");
		}else if(48.00 < weight && 51.00 >= weight){
			printf("fly\n");
		}else if(51.00 < weight && 54.00 >=weight){
			printf("bantam\n");
		}else if (54.00 < weight && 57.00 >= weight) {
			printf("feather\n");
		}else if (57.00 < weight && 60.00 >= weight) {
			printf("light\n");
		}else if (60.00 < weight && 64.00 >= weight) {
			printf("light welter\n");
		}else if (64.00 < weight && 69.00 >= weight) {
			printf("welter\n");
		}else if (69.00 < weight && 75.00 >= weight) {
			printf("light middle\n");
		}else if (75.00 < weight && 81.00 >= weight) {
			printf("middle\n");
		}else if (81.00 < weight && 91.00 >= weight) {
			printf("light heavy\n");
		}else if (91.00 < weight) {
			printf("heavy\n");
		}
	}

	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    set<int> s;
    REP(i, N) {
        cin >> A;
        s.insert(A);
    }
    if (s.size() == N)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 12972
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#include <iostream>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int a,b;
	cin>>a>>b;
	cout<<max(max(a-b,a*b),a+b)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		List<Rest> R = new ArrayList<Rest>();
		for(int i=0; i<N; i++) {
			String s = sc.next();
			int p = sc.nextInt();
			Rest r = new Rest(i,s,p);
			R.add(r);
		}
		Comparator<Rest> comparator = 
				Comparator.comparing(Rest::getName).thenComparing(Rest::getPoint, Comparator.reverseOrder());
		
		R.stream().sorted(comparator)
		.forEach(a ->
		System.out.println(a.getIndex()+1));
	}
}

class Rest {
	private int index;
	private String name;
	private int point;
	
	public Rest(int index, String name, int point) {
		this.index = index;
		this.name = name;
		this.point = point;
	}
	
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPoint() {
		return point;
	}
	public void setPoint(int point) {
		this.point = point;
	}
}


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

int main() {
    int N;
    cin >> N;
    int A[N] = {0};
    for (int i = 1; i < N; i++) {
        int Ai;
        cin >> Ai;
        A[Ai - 1] += 1;
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 4372
#include <stdio.h>

int main() {
	int ch1,ch2;
	int a = 0;
	scanf("%x %x", &ch1, &ch2);

	a = ch1 - ch2;

	if (a < 0)
	{
		printf("<");
	}
	else if (a == 0)
	{
		printf("=");
	}
	else
	{
		printf(">");
	}

	return 0;

}

Measured memory_bytes: 128