akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

num n, a, b, ans;

bool inline chk1(num t) {
    if (t < n - b)  return 0;
    if (t >= n - a)  return 1;
    num da = n - (a + t);
    num db = da + n - b;
    return db <= t;
}

bool inline chk2(num t) {
    if (t < a)  return 0;
    if (t >= b)  return 1;
    num db = b - t;
    num da = db - 1 + a - 1;
    return da <= t;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> a >> b;
    ans = min(max(a - 1, b - 1), max(n - a, n - b));
    if (a > b) {
        swap(a, b);
    }
    if ((b - a) % 2 == 0) {
        ans = min(ans, (b - a) / 2);
    }
    num l = 0, r = n, md = (l + r) >> 1;
    for (; r - l > 1; md = (l + r) >> 1) {
        (chk1(md) ? r : l) = md;
    }
    ans = min(ans, r);
    l = 0, r = n, md = (l + r) >> 1;
    for (; r - l > 1; md = (l + r) >> 1) {
        (chk2(md) ? r : l) = md;
    }
    ans = min(ans, r);
    cout << ans << ln;
}

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

int main(){
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++){
		if (i >= 1 && i <= 9) ans++;
		else if (i >= 100 && i <= 999) ans++;
		else if (i >= 10000 && i <= 99999) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const long long INF=1LL<<60;
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; }
using namespace std;
int main(){
int n,k; 
 cin>>n>>k;
  long long h[1000100];
  long long dp[1000100];
  rep(i,n) cin>>h[i];
  rep(i,1000100) dp[i]=INF;
  dp[0]=0;
  for(int i=0;i<n;i++){
  	for(int j=1;j<=k;j++){
    	chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 12172
a = input().split()

n = int(a[0])
m = int(a[1])

y = input().split()

x = [int(i) for i in y]

if(sum(x) == n):
  print(0)
elif(sum(x) > n):
  print(-1)
else:
  print(n-sum(x))
  


Measured memory_bytes: 68156
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void chemthan() {
    int n, k; cin >> n >> k;
    long long res = 0;
    FOR(b, k + 1, n + 1) {
        for (int i = 0; i <= n; i += b) {
            int lo = max(1, i + k);
            int hi = min(n, i + b - 1);
            if (lo <= hi) {
                res += hi - lo + 1;
            }
        }
    }
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    ll ans = a1 + a2 + a3;
    ans = min(ans, abs(a2 - a1) + abs(a3 - a2));  // 123 or 321
    ans = min(ans, abs(a2 - a1) + abs(a3 - a1));  // 213 or 312
    ans = min(ans, abs(a3 - a1) + abs(a3 - a2));  // 132 or 231
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
#include <iostream>
#define pie acos(-1)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld %lld",&a,&b)
#define slll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define ss(st) scanf("%s",st)
#define sch(ch) scanf("%ch",&ch)
#define ps(a) printf("%s",a)
#define newLine() printf("\n")
#define pi(a) printf("%d",a)
#define pii(a,b) printf("%d %d",a,b)
#define piii(a,b,c) printf("%d %d %d",a,b,c)
#define pl(a) printf("%lld",a)
#define pll(a,b) printf("%lld %lld",a,b)
#define plll(a,b,c) printf("%lld %lld %lld",a,b,c)
#define pd(a) printf("%lf",a)
#define pdd(a,b) printf("%lf %lf",a,b)
#define pddd(a,b,c) printf("%lf %lf %lf",a,b,c)
#define pch(c) printf("%ch",c)
#define debug1(str,a) printf("%s=%d\n",str,a)
#define debug2(str1,str2,a,b) printf("%s=%d %s=%d\n",str1,a,str2,b)
#define debug3(str1,str2,str3,a,b,c) printf("%s=%d %s=%d %s=%d\n",str1,a,str2,b,str3,c)
#define debug4(str1,str2,str3,str4,a,b,c,d) printf("%s=%d %s=%d %s=%d %s=%d\n",str1,a,str2,b,str3,c,str4,d)
#define for0(i,n) for(i=0;i<n;i++)
#define for1(i,n) for(i=1;i<=n;i++)
#define forab(i,a,b) for(i=a;i<=b;i++)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define NL puts("")
#define sd(a) scanf("%lf",&a)
#define sdd(a,b) scanf("%lf %lf",&a,&b)
#define sddd(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define SP printf(" ")
#define LL long long int
#define ULL unsigned long long int
#define N 1000007
#define MOD 100000009
#define pub(x) push_back(x)
#define pob(x) pop_back(x)
#define mem(ara,value) memset(ara,value,sizeof(ara))
#define INF INT_MAX
#define eps 1e-8
#define checkbit(n, pos) (n & (1<<pos))
#define setbit(n, pos) (n | (1<<pos))
#define para(a,b,ara)\
for(int i=a;i<=b;i++){\
    if(i!=0){printf(" ");}\
    printf("%d",ara[i]);\
}\
printf("\n");
#define pvec(vec)\
for(int i=0;i<vec.size();i++){\
    if(i!=0){printf(" ");}\
    printf("%d",vec[i]);\
}\
printf("\n");
#define ppara(n,m,ara)\
for(int i=0;i<n;i++){\
    for(int j=0;j<m;j++){\
        if(j!=0){printf(" ");}\
        printf("%d",ara[i][j]);\
    }\
    printf("\n");\
}
#define ppvec(n,vec)\
for(int i=0;i<n;i++){\
    for(int j=0;j<vec[i].size();j++){\
        if(j!=0){printf(" ");}\
        printf("%d",vec[i][j]);\
    }\
    printf("\n");\
}
#define sara(a,b,ara)\
for(int i=a;i<=b;i++){\
    scanf("%d",&ara[i]);\
}
using namespace std;
int n,ma=0,ans;
vector <int>vec;
int nm=0;
map <int,int>mp;
void input(){
    int i,j,t;
    scanf("%d",&n);
	for0(i,n){
		scanf("%d",&t);
		if(!mp[t]){
			vec.push_back(t);
			nm++;
		}
		mp[t]++;
	}
	for0(i,nm){
		if(mp[vec[i]]<vec[i]){
			ans+=mp[vec[i]];
		}else if(mp[vec[i]]>vec[i]){
			ans+=mp[vec[i]]-vec[i];
		}
	}
	pi(ans);
//	return 0;
}
//void solve(){
//
//}
int main(){
//    freopen("input.txt","r",stdin);
    input();
    return 0;
}


Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  b *= 100;
  ll t = b + 0.001;

  a *= t;
  a /= 100;
  cout << a << endl;
}


Measured memory_bytes: 3724
#include<iostream>
#include<iomanip>
using namespace std;
double a, sum;
int main() {
	while (cin >> a) {
		sum = a;
		for (int i = 2; i < 11; i++) {
			if (i % 2 == 0) {
				a *= 2;
			}
			else {
				a /= 3;
			}
			sum += a;
		}
		cout << fixed << setprecision(15) << sum << endl;
	}
}

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

using namespace std;
const int maxn = 1005;
const int mod = 1e9+7;
typedef long long ll;
char A[maxn][maxn];
int dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N,M;
    cin >> N >> M;
    for (int i = 1; i <= N;i++){
        for (int j = 1; j <= M;j++){
            cin >> A[i][j];
        }
    }
    dp[1][1] = 1;
    for (int i = 1; i <= N;i++){
        for (int j =  1;j <= M;j++){
            if (A[i][j] == '#')continue;
            dp[i+1][j]= (dp[i+1][j]+dp[i][j]) % mod;
            dp[i][j+1]= (dp[i][j+1]+dp[i][j]) % mod;
        }
    }
    cout << dp[N][M];
    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

char buf[20];
vector<string> v;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	rep(i, n) {
		gstr(buf);
		v.pb(string(buf));
	}
	sort(all(v));
	int ans = 1;
	rep1(i, n-1) if(v[i] != v[i-1]) ans++;
	print(ans);
}


Measured memory_bytes: 13592
#include <iostream>
using namespace std;
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;
}
const long long INF = 1LL << 60;

const int MAX_N = 110;
const int MAX_V = 100100;
//入力
int N;
long long W, weight[MAX_N], value[MAX_N]; //品物の品質は100個なので少し余裕を持たせてサイズ110

//DPテーブル
long long dp[MAX_N][MAX_V];

int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; ++i)
        cin >> weight[i] >> value[i];

    //初期化
    for (int i = 0; i < MAX_N; ++i)
        for (int j = 0; j < MAX_V; ++j)
            dp[i][j] = INF;

    //初期条件
    dp[0][0] = 0;

    //DPループ
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
        {
            //i番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0)
            {
                chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }

            //i番目の品物を選ばない場合
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 86400
#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m;
  bitset<1001001> broken(0);
  for (int i = 0; i < m; i++) {
    int a; cin >> a;
    broken.set(a);
  }
  vector<int> ways(n + 1);
  ways[0] = 1; 
  if (!broken[1]) ways[1] = 1;
  for (int i = 2; i < n + 1; i++) {
    if (!broken[i]) ways[i] = (ways[i-1] + ways[i-2]) % MOD;
  }
  cout << ways[n] << '\n';
  return 0;
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    if (K == 0) {
        cout << 1LL * N * N << endl;
        return 0;
    }
    long long ans = 0LL;

    for (int b = K + 1; b <= N; ++b) {
        ans += (N / b) * (b - K);
        if (N % b >= K) {
            ans += N % b + 1 - K;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#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 main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        q.push(x);
    }
    ll sol = 0;
    while (!q.empty())
    {
        int x = q.top(); q.pop();
        if (m)
        {
            x /= 2;
            q.push(x);
            m--;
        }
        else
            sol += x;
    }
    cout << sol;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;
typedef long long ll;


int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k){
        cout << ":(";
    }else{
        cout << "Yay!";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 
#define P pair<int, int>

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if(A.size() == n+1) {
        int now = 0;
        rep(i, q) {
            if(A[b[i]] - A[a[i]] == c[i]) {
                now += d[i];
            }
        }
        ans = max(ans, now);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    ans = 0;
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))

A_list = collections.Counter(A)
ok = A_list.most_common()[0:K]

#print(ok)
ans2 = 0
for i in range(len(ok)):
  ans2 += ok[i][1]
  
print(N - ans2)




Measured memory_bytes: 39320
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std;

struct Egn{
	ll X, Y;
	double angle;
	Egn(ll inputtedX, ll inputtedY){
		X=inputtedX, Y=inputtedY;
		if(X==0 && Y==0) angle=0.0;
		else angle=atan2(Y, X);
	}
	bool operator<(const Egn &a){
		return angle < a.angle;
	}
};

int main() {
	int N;
	cin >> N;
	vector<Egn> p;
	for(int i=0; i<N; ++i){
		ll x, y;
		cin >> x >> y;
		p.push_back(Egn(x, y));
	}
	sort(p.begin(), p.end());
	double mx=0.0;
	for(int i=0; i<N; ++i){
		ll nx=0, ny=0;
		for(int j=0; j<N; ++j){
			nx += p[(i+j)%N].X;
			ny += p[(i+j)%N].Y;
			mx=max(mx, pow(nx*nx+ny*ny, 0.5));
		}
	}
	cout << setprecision(20) << mx << endl;
	return 0;
}

Measured memory_bytes: 512
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

n = gets.chomp.chars.last.to_i
puts 'hon' if hon.include?(n)
puts 'pon' if pon.include?(n)
puts 'bon' if bon.include?(n)

Measured memory_bytes: 14400
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> d){
  int ans=0;
  for (int i = 0; i < N-1; i++) {
    for (int l = i+1; l < N; l++) {
      ans += d[i]*d[l];
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

ll func(int N){
    ll sum=0;
    for(int i=1; i<=N; i++){
        int n=N/i;
        sum+=(ll)i*n*(n+1)/2;
    }
    return sum;
}

int main(){
    int N; cin >> N;
    ll res=func(N);
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const int INF = numeric_limits<int>::max()/2;

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

    int h,w;cin>>h>>w;
    vector<vector<int>> dis(10,vector<int>(10));
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin>>dis[i][j];
        }
    }
    for(int k=0;k<=9;k++){
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    ll res=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;cin>>a;
            if(a==-1) continue;
            res += dis[a][1];
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	char c;
	cin >> c;
	c ++;
	cout << c;
	return 0;
}

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

int main(){
  string s;
  std::cin >> s;

  ll sum=0;
  rep(i,s.size()){

    sum+=(s[i]-'0');
    sum%=9;
    
  }

  if(sum%9==0)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';



  return 0;
}


Measured memory_bytes: 3752
# = str(input())
A, B, C = map(int, input().split())
K = int(input())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

while K > 0:
    if C <= B:
        C = C*2
        K -= 1
        if K == 0:
            break
    elif B <= A:
        B = B*2
        K -= 1
        if K == 0:
            break
    else:
        C = C*2
        K -= 1
        if K == 0:
            break

if A < B and B < C:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
int n,a[MAX],b[MAX],s;
vector<pair<int,int> > T;
int main()
{
    n=read();
    for(int i=1;i<=n;++i)a[i]=read();
    sort(&a[1],&a[n+1]);
    for(int i=2;i<n;++i)b[i]=a[i]<0;
    b[1]=1;b[n]=0;
    for(int i=2;i<n;++i)
        if(b[i])T.push_back(make_pair(a[n],a[i])),a[n]-=a[i];
        else T.push_back(make_pair(a[1],a[i])),a[1]-=a[i];
    T.push_back(make_pair(a[n],a[1]));
    printf("%d\n",a[n]-a[1]);
    for(auto a:T)printf("%d %d\n",a.first,a.second);
    return 0;
}

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

int main() {
  int h, w, d;
  std::cin >> h >> w >> d;
  std::vector<std::pair<int, int>> a(h * w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int tmp;
      std::cin >> tmp;
      a[tmp - 1] = {i, j};
    }
  }
  std::vector<std::vector<int32_t>>
  dif(d, std::vector<int32_t>(h * w / d + 1, 0));
  for (int i = 0; i < d; i++) {
    for (int j = 1; j < h * w / d + 1; j++) {
      const auto after = j * d + i;
      const auto before = (j - 1) * d + i;
      if (after < h * w) {
        dif[i][j] = dif[i][j - 1]
          + std::abs(a[after].first - a[before].first)
          + std::abs(a[after].second - a[before].second);
      }
    }
  }

  int64_t q;
  std::cin >> q;
  for (int64_t i = 0; i < q; i++) {
    int l, r;
    std::cin >> l >> r;
    l--;
    r--;
    const auto m = l % d;
    const auto m1 = l / d;
    const auto m2 = r / d;
    std::cout << dif[m][m2] - dif[m][m1] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 6016
#include <cstdio>
#include <vector>
using namespace std;


int islands[50][100];
int w,h;

void dfs(int y,int x){

  islands[y][x] = 0;

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

  for(int i = 0;i < 8;i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h && islands[ny][nx] == 1)dfs(ny,nx);
  }

  return ;
}


int main(){

  vector<int> v;

  while(scanf("%d %d",&w,&h),w != 0 && h != 0){

    int ans = 0;

    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
        scanf("%d",&islands[i][j]);
      }
    }

    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
        if(islands[i][j] == 1){
          dfs(i,j);
          ans++;
        }
      }
    }


    v.push_back(ans);
  }

  for(int i = 0;i < v.size();i++){
    printf("%d\n",v[i]);
  }

  return 0;
}



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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) return 0;
    vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 1e9;
    for (int i = 0; i < n - 1; i++) res = min(res, a[i + 1] - a[i]);
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 3200
#include<cstdio>

typedef long long ll;
const int maxn = 300010;
const ll mod = 998244353;

ll n,a,b,k;
ll fac[maxn],inv[maxn];

ll qpow_mod(ll x,ll n){
	int s = 1;
	while(n){
		if(n&1) s=s*x % mod;
		x = x*x % mod;
		n >>= 1;
	}
	return s;
}
void csh(){
	fac[0] = 1;
	for(int i = 1; i<=300000; i++) fac[i] = fac[i-1]*i % mod;
	inv[300000] = qpow_mod(fac[300000],mod-2);
	for(int i = 300000; i>0; i--) inv[i-1] = inv[i]*i % mod;
}
ll C(ll n, ll a){//C n 取 a 
	return fac[n]*inv[a] %mod * inv[n-a] %mod; 
}
int main()
{
	csh();
	ll ans = 0;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(int i = 0; i<=n; i++){
		if((k - a*i)%b != 0 || (k - a*i)/b > n || (k - a*i)<0)continue;
		ans = (ans + C(n,i)*C(n,(k-a*i)/b))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

signed main(){
  int n,k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    double per=1.0/(double)n;
    int now=i;
    while(now<k){
      now*=2;
      per/=2.0;
    }
    ans+=per;
  }
  cout<<fixed<<setprecision(13)<<ans<<endl;
}

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

using P = pair<int, int>;

struct edge {
    int to; 
    long long cost;

    edge(int t, long long c): to(t), cost(c) {}
};

const long long INF = LONG_LONG_MAX;
const int MAX_V = 100000;
int V;
vector<edge> G[MAX_V + 1];
long long d[MAX_V + 1];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    V = n;
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back(edge(b, c));
        G[b].push_back(edge(a, c));
    }

    int q, k;
    cin >> q >> k;

    dijkstra(k);
    
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;

        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 9984
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		PriorityQueue<Integer> befQueue = new PriorityQueue<>();
		PriorityQueue<Integer> afQueue = new PriorityQueue<Integer>(new Comparator<Integer>() {
		    public int compare(Integer i1, Integer i2) {
		        return i2.intValue() - i1.intValue();
		    }
		});
		long befScore = 0;
		long afScore = 0;
		for (int i = 0; i < n * 3; i++) {
		    int x = sc.nextInt();
		    if (i < n) {
		        befQueue.add(x);
		        befScore += x;
		    } else if (i < 2 * n) {
		        arr[i - n] = x;
		    } else {
		        afQueue.add(x);
		        afScore += x;
		    }
		}
		long[] values = new long[n + 1];
		values[0] += befScore;
		values[n] -= afScore;
		for (int i = 0; i < n; i++) {
		    befQueue.add(arr[i]);
		    befScore += arr[i];
		    befScore -= befQueue.poll();
		    values[i + 1] += befScore;
		    afQueue.add(arr[n - i - 1]);
		    afScore += arr[n - i - 1];
		    afScore -= afQueue.poll();
		    values[n - i - 1] -= afScore;
		}
		Arrays.sort(values);
	    System.out.println(values[n]);
   }
}




Measured memory_bytes: 98960
#import copy

N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A, reverse=True)
m1 = B[0]
m2 = B[1]

for i in range(N):
    if A[i] == m1:
        print(m2)
    else:
        print(m1)

"""
# TLE
B = copy.copy(A) # B=AとするだけではAを変更した時にBも変更してしまう
for i in range(N):
    A[i] = 0
    print(max(A))
    A[i] = B[i]
"""

Measured memory_bytes: 14088
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>

int main(){
	//freopen("in.txt.txt","r",stdin);
	//freopen("out.txt.txt","w",stdout);
	int n;
	scanf("%d",&n);
	printf("%d",n%2==0 ? n/2 : (n+1)/2);
	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;



int main(){
    
    int N,L,taste;
    cin >> N >> L;
    
    if(L > 0){
        taste = (N-1) * (L+1 + L+N-1)/2;
    } else if(L + N - 1 < 0){
        taste = (N-1) * (L + L+N-2)/2;;
    } else {
        taste = N*(L + L+N-1)/2;
    }
    
    cout << taste << endl;
    
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
lli mod=1e9+7;

int main()
{
	lli H,W;
	cin>>H>>W;
	lli arr[H+1][W+1];
	lli i,j;
	string temp;

	for(i=1;i<=H;i++)
	{
        cin>>temp;
		for(j=1;j<=W;j++)
		{
			if(temp[j-1]=='#')
				arr[i][j]=0;
			else
				arr[i][j]=1;
		}
	}
	arr[H][W]=0;

	lli dp[H+1][W+1];
	for(i=0;i<=H;i++)
		for(j=0;j<=W;j++)
			dp[i][j]=0;

	dp[H][W]=1;


	for(i=H;i>=1;i--)
	{
		for(j=W;j>=1;j--)
		{
			if(arr[i][j]==1)
			{
			    if((i+1)>H)
				    dp[i][j]=(dp[i][j]%mod + dp[i][j+1]%mod)%mod;

				else if((j+1)>W)
					dp[i][j]=(dp[i][j]%mod + dp[i+1][j]%mod)%mod;

				else
					dp[i][j]=(dp[i][j]%mod + dp[i][j+1]%mod + dp[i+1][j]%mod)%mod;
			}
		}
	}


	cout<<dp[1][1];


	return 0;
}

Measured memory_bytes: 15872
def yaku(x, y):
    if (y == 0):
        return x
    return yaku(y ,x % y)


def calc(x, y, z):
    ny = x // y
    nz = x // z
    nyz = x // (y * z // yaku(y ,z))

    #print(ny, nz, nyz)
    #print(x - ny - nz + nyz)

    return (x - ny - nz + nyz)


a, b, c, d = list(map(int, input().split()))

rtn = calc(b,c,d) - calc(a-1,c,d)

print(int(rtn))


Measured memory_bytes: 3060
n,k=map(int,input().split())
s=input()

nums=[]

if(s[0]=='0'):
    nums.append(0)

num=s[0]
numi=0
for i in range(n):
    if(s[i]==num):
        numi+=1
    else:
        nums.append(numi)
        numi=1
        num=s[i]
else:
    nums.append(numi)

if(s[-1]=='1'):
    nums.append(0)

#print(nums)

ans=0
zero_num=len(nums)//2
if(zero_num<=k):
    print(sum(nums))
else:
    l=2*k
    sumi=sum(nums[:l+1])
    ans=sumi
    i=0
    while(l+2<len(nums)):
        sumi+=(nums[l+1]+nums[l+2])
        l+=2
        sumi-=(nums[i]+nums[i+1])
        i+=2
        ans=max(ans,sumi)
#    print(nums[-2*k:])
    ans=max(ans,sum(nums[-2*k:]))
    print(ans)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

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

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

bool isPrime(ll N) {
	for (ll i = 2; i*i <= N; i++) {
		if (N % i == 0) return (false);
	}
	return (true);
}

void Main() {
	ll N; cin >> N;
	bool prime[2000005];

	fill_n(prime, 2000005, true);
	prime[0] = prime[1] = false;
	vll values;
	for (ll i = 2; i < 2000005; i++) {
		if (prime[i]) {
			for (ll j = i*i; j < 2000005; j += i) {
				prime[j] = false;
			}
			for (ll j = i; j <= N; j *= i) {
				values.push_back(j);
			}
		}
	}
	sort(begin(values), end(values));
	
	set<ll> used;
	int cnt = 0;
	for (auto &val : values) {
		if (N % val == 0) {
			cnt++;
			N /= val;
			used.insert(val);
		}
	}
	for (int i = 2; i < 2000005; i++) {
		while (N % i == 0) N/=i;
	}

	if (N > 1 && used.count(N) == 0 && isPrime(N)) {
		cnt++;
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

using namespace std;

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v)
{
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

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

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int j = 0; j < n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for (int j = 0; j < n; j++) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;
int main()
{
    long long N, M;
    cin >> N >> M;

    if(N == 1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    else if(N == 1){
        cout << M - 2 << endl;
        return 0;
    }
    else if(M == 1){
        cout << N - 2 << endl;
        return 0;
    }

    cout << (N-2) * (M-2) << endl;
    return 0;
}


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

string ask(int x){
    cout<<x<<endl;
    string res;
    cin>>res;
    return res;
}

int main(void){
    int n;
    cin>>n;
    string ls = ask(0);
    if(ls == "Vacant") return 0;
    string rs = ask(n-1);
    if(rs == "Vacant") return 0;
    string ms = ask(n/2);
    int l=0,r=n-1,m=n/2;
    while(true){
        if(ms == "Vacant") break;
        if(((m-l)%2==0 && ms==ls) || ((m-l)%2==1 && ms!=ls)){
            l = m;
            ls = ms;
        }else{
            r = m;
            rs = ms;
        }
        m = (l+r)/2;
        ms = ask(m);
    }
    return 0;
}


Measured memory_bytes: 852
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int h=100, w = 100;
	int field[100][100];
	REP(i, h) {
		REP(j, w) {
			if (j < 50) {
				field[i][j] = 0;
			}
			else {
				field[i][j] = 1;
			}
		}
	}
	REP(i, 99) {
		REP(j, 19) {
			if (i % 2 == 0 && j % 2 == 0) {
				field[i][j] = 1;
			}
		}
	}
	SREP(i,1, 100) {
		SREP(j,81,100) {
			if (i % 2 == 1 && j % 2 == 1) {
				field[i][j] = 0;
			}
		}
	}
	SREP(j, 19, 50)field[0][j] = 1;
	SREP(j, 50, 81)field[99][j] = 0;
	REPS(i, 500-a) {
		if (i % 50 == 0) {
			field[99][(i / 50) * 2 + 80] = 0;
		}
		else {
			field[100 - (i % 50) * 2][(i / 50) * 2 + 81] = 0;
		}
	}
	REPS(i, 500 - b) {
		if (i % 50 == 0) {
			field[0][19-(i / 50) * 2] = 1;
		}
		else {
			field[-1 + (i % 50) * 2][18-(i / 50) * 2] = 1;
		}
	}
	printf("%d %d\n", 100, 100);
	REP(i, h) {
		REP(j, w) {
			if (field[i][j] == 0) {
				printf("%c", '.');
			}
			else {
				printf("%c", '#');
			}
		}
		puts("");
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  ll ret = 0;
  // 0 mod k
  ll amt = n/k;
  ret += amt * amt * amt;
  // k/2 mod k
  if(k%2 == 0) {
    amt = 0;
    for(int i = k/2; i <= n; i += k) amt++;
      ret += amt * amt * amt;
  }
  printf("%lld\n", ret);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for _ in range(n):
    l.append([])

for _ in range(m):
    a, b = map(int, input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

res = 0
for i in range(n):
    flag = True
    for j in l[i]:
        if h[i] <= h[j]:
            flag = False
            break
    if flag:
        res += 1

print(res)


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool bad = false;
    int lst = -1;
    for(int i = 0; i < 4; i++){
        if (s[i] - '0' == lst){
            bad = true;
        }
        lst = s[i] - '0';
    }
    if (bad){
        cout << "Bad";
    } else {
        cout << "Good";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 22868
// D - Powerful Discount Tickets
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);i++)
#define allr(x) (x).rbegin(),(x).rend()

int main(){
	int N,M;cin>>N>>M;

	vector<int> A(N);
	vector<pair<int,int>> B;
	rp(i,N){
		cin>>A[i];
		for(int a = A[i]; a>0; a>>=1)
			B.push_back(make_pair(a - (a>>1), i));
	}

	sort(allr(B));

	vector<int> counting(N);
	rp(i, min(M, (int)B.size())) counting[B[i].second]++;

	ll ans = 0;
	rp(i,N) ans += (ll)A[i]/(1<<counting[i]);
	cout<< ans <<endl;
}

Measured memory_bytes: 34916
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		int cnt = 0;
		for (int i = 0; i * i <= n; i++) {
			int m = n - i * i;
			for (int j = i; j * j <= m; j++) {
				int l = m - j * j;
				for (int k = j; k * k <= l; k++) {
					int x = l - k * k;
					int rx = sqrt((double)x);
					if (rx >= k && rx * rx == x)
						cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#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 (1 << 30 - 1)
#define LLINF (1LL << 60)
#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 >> M >> S;
    reverse(ALL(S));
    vi res;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < M; j++) {
            if (i + j + 1 == N) {
                tmp = j + 1;
                break;
            }
            if (S[i + j + 1] == '0') {
                tmp = max(tmp, j + 1);
            }
        }
        if (tmp == 0) {
            cout << -1 << endl;
            return 0;
        }
        i += tmp - 1;
        res.push_back(tmp);
    }
    RREP(i, res.size())
    cout << res[i] << endl;
}

Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

vector<vector<pair<ll, ll> > > G;
vector<ll> d;


void dfs(ll s) {
    for (int i = 0; i < G[s].size(); i++) {
        ll v = G[s][i].first;
        ll dist = G[s][i].second;
        if (d[v] < 0) {
            d[v] = (d[s] + dist);
            dfs(v);
        }
    }
}

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

    G.resize(n);

    for (int i = 0; i < n-1; i++) {
        ll x, y, w;
        cin >> x >> y >> w;
        G[x-1].push_back(pair<ll,ll> (y-1, w));
        G[y-1].push_back(pair<ll,ll> (x-1, w));
    }

    d.resize(n);
    for (int i = 0; i < n; i++)
        d[i] = -1;
    d[0] = 0;

    dfs(0);

    for(int i = 0; i < n; i++) {
        cout << d[i]%2 << endl;
    }
    return 0;
}

Measured memory_bytes: 9216
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
# from time import perf_counter


def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = np.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = np.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = np.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = np.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = np.minimum(values[y, :] + 1, values[y - 1, :])

    print(np.max(values))


if __name__ == '__main__':
    # st = perf_counter()
    main()
    # ed = perf_counter()
    # print(ed - st)

Measured memory_bytes: 29020
V = gets.chars.map(&:to_i)
[:+,:-].repeated_permutation(3).find do |op|
  if 3.times.inject(V[0]){|s,i| s.send(op[i],V[i+1]) } == 7
    puts "#{V[0]}#{op[0]}#{V[1]}#{op[1]}#{V[2]}#{op[2]}#{V[3]}=7"
    true
  end
end

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

int main(void)
{
    int N;
    cin >> N;
    int x;
    int y;

    x = int(N/1.08);
    

    if(int(x * 1.08) == N){
        cout << x;
    }else if(floor(x * 1.08) < N){
        y = x;
        for(; floor(y * 1.08) < N+1; y++){
            if(int(y * 1.08) == N){
                cout << y;
                goto OUT;
            }
        }
        cout << ":(";
    }
    else{
        cout << ":(";
    }

OUT:
return 0;

}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int W[N+1];
    for(int i=1;i<=N;i++)cin >> W[i];
    
    int ans = 1000000;
    for(int T=1;T<N;T++){
        int S1=0,S2=0;
        for(int i=1;i<=N;i++){
            if(i <= T)S1+=W[i];
            else S2+=W[i];
        }
        ans = min(ans,abs(S1-S2));
    }
    cout << ans;
    
}


Measured memory_bytes: 3180