akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N;
ll jon[10];

int main()
{
    cin >> N;
    for (int i = 1; i <= 5; i++) cin >> jon[i];

    //cout << endl;

    ll cnt = 0;
    ll lagto = 0;

    for (int i = 1; i <= 5; i++) {
        ll lagbe = ceil( (double)N/jon[i]);

        //cout << lagbe << endl;
        if (i == 1) {lagto = lagbe, cnt = lagbe; continue;}

        if (lagbe > lagto) cnt = max(i + lagbe - 1, cnt+1);
        else cnt = cnt + 1;

        //cout << lagto << "-> " << lagbe << "  ~"<<cnt << endl;
        lagto = lagbe;
    }

    cout << cnt << endl;
}

/*
5
5 4 3 2 1
*/


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long LL;

const LL M = 1e18;

int main(){
  int n;
  cin >> n;
  LL a[n];
  LL ans = 1;
  
  rep(i, n){
    cin >> a[i];
	if(0 == a[i]){
      cout << 0 << endl;
      return 0;
    }
  }
  
  rep(i, n){
    if(a[i] > M/ans){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}


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

vector<vector<int>> G; 
vector<int> colors;
vector<int> seen;
map<pair<int,int>,int> m;
int max_color = 1;

void dfs(int v,int p = -1,int ban_color=-1){
  seen[v] = true;
  int color = 1;
  for(auto next_v : G[v]){
    if(seen[next_v]) continue;
    if(color == ban_color) color++;
    if(v<next_v) m[{v,next_v}] = color;
    else m[{next_v,v}] = color;
    dfs(next_v,v,color);
    color++;
  }
}

int main(){
  int N;cin>>N;
  G.resize(N);
  colors.resize(N);
  seen.resize(N,false);
  vector<int> A(N-1),B(N-1);
  rep(i,N-1){
    int a,b;cin>>a>>b;a--,b--;
    A[i] = a;B[i] = b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0);
  for(auto x : m){
    max_color = max(max_color,x.second);
  }
  cout << max_color << endl;
  rep(i,N-1){
    cout<<m[{A[i],B[i]}]<<endl;
  }
}

Measured memory_bytes: 17432
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N;
	while (cin >> N, N != 0) {
		vector<vector<lint>>A(N, vector<lint>(N));
		lint I = N / 2 + 1;
		lint J = N / 2;
		rep(i, N * N) {
			while (A[I][J] != 0) {
				I++;
				J--;
				if (I == N) {
					I = 0;
				}
				if (J == -1) {
					J = N - 1;
				}
			}
			A[I][J] = i + 1;
			I++;
			J++;
			if (I == N) {
				I = 0;
			}
			if (J == N) {
				J = 0;
			}
		}
		rep(i, N) {
			rep(j, N) {
				cout << right << setw(4) << A[i][j];
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string n;
    cin >> n;
    rep(i, n.length()) {
        if ( n[i] == '9' ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
const int Maxn=1e5+5;
const int inf=1e9;
int k,dist[Maxn];
bool used[Maxn];
std::deque <int> q;
inline void add_front(int x,int d)
{
	if (d<dist[x])
	{
		dist[x]=d;
		q.push_front(x);
	}
}
inline void add_back(int x,int d)
{
	if (d<dist[x])
	{
		dist[x]=d;
		q.push_back(x);
	}
}
int main()
{
	__builtin_scanf("%d",&k);
	std::fill(dist,dist+100000,inf);
	add_front(1,0);
	while (!q.empty())
	{
		int x=q[0];
		q.pop_front();
		if (used[x])
		{
			continue;
		}
		used[x]=1;
		int d=dist[x],cx=x*10%k;
		add_front(cx,d);
		cx=(x+1)%k;
		add_back(cx,d+1);
	}
	__builtin_printf("%d\n",dist[0]+1);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void){

  int N;
  int ans = 0;
  int count = 0;
  scanf("%d", &N);
  
  for(int i = 1; i <= N ; i += 2){
    for(int j = 1; j <=i ; j++){

      if(i % j == 0)  count++;

     }

    if(count == 8)     ans++;
    count = 0;
  }

  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N,T;
    cin >> N >> T;
    ll ans = 0;
    ll bef = -1;
    ll now = 0;
    REP(i,N){
        cin >> now;
        // calc 一個前の流れていた時間を足す
        if ( i != 0 )ans += min(T,now - bef);
        bef = now;
    }
    // 最後は必ず全部流れる
    ans += T;
    cout << ans << endl;
}

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

Measured memory_bytes: 3420
//  g++ -g -std=gnu++14 -I . main.cpp -o main
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;
const char nl = '\n';

//	modNの計算をするクラス
template <int mod> struct mint {
    int data;
    mint( void ) :data(0) {}
    mint( int n ) :data( n>=0 ? n%mod : (mod - (-n)%mod) %mod ) {}
    operator int() { return data; }
    friend istream &operator>>(istream&is,mint&m){int n; is>>n; m=n; return is;}
    friend ostream &operator<<(ostream&os,mint&m){os<<(int)m; return os;}
    mint operator+ ( int n ) { return (data + n) % mod; }
    mint operator+ (mint m ) { return *this + (int)m; }
    void operator+=( int n ) { data = *this +      n; }
    void operator+=(mint m ) { data = *this + (int)m; }
    mint operator* ( int n ) { return (lint)data * n % mod; }
    mint operator* (mint m ) { return *this * (int)m; }
    void operator*=( int n ) { data = *this *      n; }
    void operator*=(mint m ) { data = *this * (int)m; }
    mint operator/ ( int n ) { return *this * mint(n).inv(); }
    mint operator/ (mint m ) { return *this * m.inv(); }
    void operator/=( int n ) { data = data * mint(n).inv(); }
    void operator/=(mint m ) { data = data * m.inv(); }
    bool operator==( int n ) { return data == n; }
    bool operator==(mint m ) { return data == m.data; }
    bool operator!=( int n ) { return data != n; }
    bool operator!=(mint m ) { return data != m.data; }
    mint pow(int n){mint a=1,b=data;while(n>0){if(n&1)a*=b;b*=b;n>>=1;}return a;}
    mint pow(mint m){ return (*this).pow((int)m); }
    mint inv(){int a=data,b=mod,c=1,d=0,e;while(b){e=a/b;swap(a-=e*b,b);swap(c-=e*d,d);}return c;}
};
using mint_7 = mint<1000000007>;


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    mint_7 dp[101][4][4][4] = {0};
    dp[0][3][3][3] = 1;

    rep( len, N ) {
        rep( i, 4 ) {
        rep( j, 4 ) {
        rep( k, 4 ) {
        rep( l, 4 ) {
            if( j==0 && k==1 && l==2 ) continue;
            if( j==1 && k==0 && l==2 ) continue;
            if( j==0 && k==2 && l==1 ) continue;
            if( i==0 && k==1 && l==2 ) continue;
            if( i==0 && j==1 && l==2 ) continue;

            dp[len+1][j][k][l] += dp[len][i][j][k];
        }
        }
        }
        }
    }

    mint_7 ans = 0;
    rep( i, 4 ) {
    rep( j, 4 ) {
    rep( k, 4 ) {
        ans += dp[N][i][j][k];
    }
    }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e9;



signed main(){
	int r;
	cin >> r;
	printf("%.20lf\n",2 * r * acos(-1));
}

Measured memory_bytes: 3768
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    LL n, k;
    cin >> n >> k;

    // LL x = k / (2 * n);
    LL cnt = 0;
    LL cnt2 = 0;
    if (k % 2 != 0) {
        for (LL i = 1; i <= n; i++) {
            if (i % k == 0) cnt++;
        }
    } else {
        for (LL i = 1; i <= n; i++) {
            if (i % k == 0) cnt++;
            if ((i % k) == (k / 2)) cnt2++;
        }
    }

    cout << cnt * cnt * cnt  + cnt2 * cnt2 * cnt2 << endl;
    return 0;
}


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

void solve()
{
    using namespace std;

    int n;
    cin >> n;

    vector<vector<bool>> edges(n, vector<bool>(n));

    for (int i = 0; i < n; ++i)
    {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j)
        {
            int v;
            cin >> v;
            edges[u - 1][v - 1] = true;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            cout << (edges[i][j] ? 1 : 0);
            if (j + 1 != n)
                cout << " ";
        }
        cout << endl;
    }
}

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


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
 
int main() {
  int n,m,x1,y1,x2,y2,mod=100000007;
  cin >> n >> m >> x1 >> y1 >> x2 >> y2;
  ll d[n][m],c[n][m];
  memset(c,0,sizeof(c));
  for(int i=0;i<n;i++)for(int j=0;j<m;j++)d[i][j]=mod;
  d[x1][y1]=0;
  c[x1][y1]=1;
  priority_queue<PP,vector<PP>,greater<PP> > que;
  que.push(PP(0,P(x1,y1)));
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int xx=p.S.F,yy=p.S.S,cc=p.F;
    if(d[xx][yy]<cc) continue;
    for(int i=0; i<4; i++) {
      int x=xx+dx[i],y=yy+dy[i];
      if(x<0) x=n-1;
      if(x>=n) x=0;
      if(y<0) y=m-1;
      if(y>=m) y=0;
      if(d[x][y]>d[xx][yy]+1) {
        c[x][y]=c[xx][yy];
        d[x][y]=d[xx][yy]+1;
        que.push(PP(d[x][y],P(x,y)));
      } else if(d[x][y]==d[xx][yy]+1) {
        c[x][y]+=c[xx][yy];
        c[x][y]%=mod;
      }
    }
  }
  cout << c[x2][y2] << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    cout << (n % 2 == 0 ? n : 2 * n) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, D[510][510], res, U[510][510], dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
struct point{
    int x, y;
}w[251000], Q[251000], T[251000];
void Free(int x, int y){
    D[x][y]--;
    U[x][y]=0;
    res += D[x][y];
    int tail=0, tt=0, i, j;
    Q[++tail]={x,y};
    while(tail){
        tt = 0;
        for(i=1;i<=tail;i++){
            point t = Q[i];
            for(j=0;j<4;j++){
                int tx = t.x+dx[j], ty = t.y+dy[j];
                if(!U[tx][ty] && D[tx][ty] > D[t.x][t.y]){
                    Q[++tail]={tx,ty};
                    D[tx][ty]=D[t.x][t.y];
                }
            }
        }
        for(i=1;i<=tail;i++){
            point t = Q[i];
            for(j=0;j<4;j++){
                int tx = t.x+dx[j], ty = t.y+dy[j];
                if(U[tx][ty] && D[tx][ty] > D[t.x][t.y] + 1){
                    T[++tt]={tx,ty};
                    D[tx][ty]=D[t.x][t.y] + 1;
                }
            }
        }
        for(i=1;i<=tt;i++)Q[i]=T[i];
        tail=tt;
    }
}
int main(){
    int i, j;
    scanf("%d",&n);
    for(i=1;i<=n*n;i++){
        int a;
        scanf("%d",&a);
        a--;
        w[i].x=a/n+1;
        w[i].y=a%n+1;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            U[i][j]=1;
            D[i][j] = min(min(i,j),min(n-i+1,n-j+1));
        }
    }
    for(i=1;i<=n*n;i++){
        Free(w[i].x,w[i].y);
    }
    printf("%d\n",res);
}


Measured memory_bytes: 7532
A, B, Q = gets.chomp.split(" ").map(&:to_i)
S = Array.new(A).map{gets.to_i}
T = Array.new(B).map{gets.to_i}
R = Array.new(Q).map{gets.to_i}

S.unshift(-10**10); S.push(2*10**10)
T.unshift(-10**10); T.push(2*10**10)
i, j, X = 1, 1, []
while i<=A || j<=B do
  if S[i] < T[j] then
    X << [S[i], [S[i]-T[j-1], T[j]-S[i]].min]
    i += 1
  else
    X << [T[j], [T[j]-S[i-1], S[i]-T[j]].min]
    j += 1
  end
end

R.each{|q|
  idx = X.bsearch_index{|x| x[0] > q}
  if idx.nil? then
    puts q - X[-1][0] + X[-1][1]
  elsif idx == 0
    puts X[0][0] - q + X[0][1]
  else
    puts [q-X[idx-1][0]+X[idx-1][1], X[idx][0]-q+X[idx][1]].min
  end
}


Measured memory_bytes: 29660
#include <iostream>
#include <string>
int main() {
    std::string s;
    std::cin >> s;
    s += 'X';
    int ans = 0;
    int n = 0;
    for (auto c: s) {
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
            n++;
        } else {
            ans = std::max(ans, n);
            n = 0;
        }
    }
    std::cout << ans;
}

Measured memory_bytes: 256
#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() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    vector<pair<int, int>> ans;

    for (int i = 1; i < n - 1; i++){
        if(a[i] > 0){
            ans.emplace_back(a[0], a[i]);
            a[0] -= a[i];
        } else {
            ans.emplace_back(a[n - 1], a[i]);
            a[n - 1] -= a[i];
        }
    }
    ans.emplace_back(a[n - 1], a[0]);
    cout << a[n - 1] - a[0] << endl;
    for(auto p : ans){
        cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 4696
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))

def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

s = S()
t = S()
if s==t[:-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 71020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int t;
	// cin>>t;
	t=1;
	while(t--)
	{
		ld a,b,c;
		cin>>a>>b>>c;
		c=c-a-b;
		c/=2.000;
		ld xx=a*b;
		xx=sqrtl(xx);
		c/=xx;
		if(c>1)
		cout<<"Yes";
		else
		cout<<"No"; 
	}
	
}

Measured memory_bytes: 256
n = int(input())
mp_l = [list(map(int,input().split())) for i in range(n)]
div = 1
for i in range(1,n+1):
    div *= i
all_cnt = 0
from itertools import permutations
import math
m_l = [[0]*n for i in range(n)]
def calc(a,b):
    if(m_l[a][b]!=0):
        return m_l[a][b]
    num = (mp_l[a][0]-mp_l[b][0])**2+(mp_l[a][1]-mp_l[b][1])**2
    d = math.sqrt(num)
    m_l[a][b],m_l[b][a] = d,d
    return d

for l in permutations(range(n),n):
    for i in range(n-1):
        all_cnt += calc(l[i],l[i+1])

print(all_cnt/div)

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

/////////////////////////////////

int const MAX = 100 * 1000 + 41;

int n;
int a[MAX];
int suf[MAX];
int pref[MAX];
int ans[MAX];

void solve() {
	fi(1, n) {
		pref[i] = pref[i - 1] + abs(a[i] - a[i - 1]);
	}
	fdi(n, 1) {
		suf[i] = suf[i + 1] + abs(a[i] - a[i + 1]);
	}
	fi(1, n) {
		ans[i] = pref[i - 1] + suf[i + 1] + abs(a[i - 1] - a[i + 1]);
	}
	fi(1, n) {
		printf("%d\n", ans[i]);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A%K==0 || B%K==0){
            System.out.println("OK");
        }else{

        if((B-A)>=K){
            System.out.println("OK");
        }else{
            int p = A%K;
            if((K-p)<=(B-A)){
                System.out.println("OK");
            }else {
                System.out.println("NG");
            }
        }}
        



    }


}





Measured memory_bytes: 35796
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <array>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>

/* ----- Type Alias ----- */
using lint = long long int;
using ldouble = long double;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
T ndvec(T v) { return v; }

template <class T, class... Ts>
auto ndvec(size_t l, Ts... ts) {
    return std::vector<decltype(ndvec<T>(ts...))>(l, ndvec<T>(ts...));
}

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;
template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    int precision;
    explicit Fout(int precision) : precision(precision) {}
};

std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}

/* ----- Constants ----- */
// constexpr int INF = std::numeric_limits<int>::max() / 3;
// constexpr int MOD = 1000000007;
// const Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    int r;
    std::cin >> r;
    std::cout << r * r << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
for i in reversed(range(n-1)):
    if h[i] > h[i+1]:
        h[i] -= 1
        if h[i] > h[i+1]:
            ans = 'No'
            break
print (ans)

Measured memory_bytes: 14224
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int N; cin >> N;
    ll A[N], B[N+1];
    F0R(i, N+1) cin >> B[i];
    F0R(i, N) cin >> A[i];
 
    ll ans = 0;
    F0R(i, N) {
        ll V = min(A[i], B[i]); A[i] -= V; B[i] -= V; ans += V;
 
        V = min(A[i], B[i+1]); A[i] -= V; B[i+1] -= V; ans += V;
    }
    cout << ans << endl;
 
    return 0;
}

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

#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; rep(i_debug, v.size()) { cout << v[i_debug] << ",";}cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; rep(i_debug, m.size()) { rep(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } cout << endl; } }

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<int> l(N);
    vector<int> r(N);
    l[0] = A[0];
    r[N-1] = A[N-1];
    rep(i,N) l[i] = gcd(l[i-1],A[i]);
    for(int i=N-2;i>=0;i--) r[i] = gcd(r[i+1],A[i]);
    int ans = max(l[N-2],r[1]);
    for(int i=1;i<=N-2;i++){
        ans = max((ll)ans,gcd(l[i-1],r[i+1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,x,t = readInts()

ans = n//x

if n%x!=0:
	ans+=1

print(ans*t)

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int x=0;
    rep(i,n){
        cin>>a[i];
        x^=a[i];
    }
    rep(i,n){
        int ans=x^a[i];
        if(i!=n-1)cout<<ans<<" ";
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 3984
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int A, P;
	cin >> A >> P;
	P += A*3;
	cout << P / 2 << endl;


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int n;
string s;
vector<char> arr;

bool solve(char fst, char scd)
{
    arr.clear();

    arr.push_back(fst);
    arr.push_back(scd);

    FOR(i, 1, n - 1)
    {
        if (arr[i] == 'S')
        {
            if (s[i] == 'o')
                arr.push_back(arr[i - 1]);
            else
            {
                arr.push_back(arr[i - 1] == 'S' ? 'W' : 'S');
            }
        }
        else
        {
            if (s[i] == 'x')
                arr.push_back(arr[i - 1]);
            else
            {
                arr.push_back(arr[i - 1] == 'S' ? 'W' : 'S');
            }
        }
    }

    if (arr[n - 1] == 'S')
    {
        if ((s[n - 1] == 'o' && arr[0] == arr[n - 2]) ||
            (s[n - 1] == 'x' && arr[0] != arr[n - 2]))
        {
            if (arr[0] == 'S')
            {
                if ((s[0] == 'o' && arr[1] == arr[n - 1]) ||
                    (s[0] == 'x' && arr[1] != arr[n - 1]))
                {
                    return true;
                }
                else
                    return false;
            }
            else
            {
                if ((s[0] == 'x' && arr[1] == arr[n - 1]) ||
                    (s[0] == 'o' && arr[1] != arr[n - 1]))
                {
                    return true;
                }
                else
                    return false;
            }
        }
        else
            return false;
    }
    else
    {
        if ((s[n - 1] == 'x' && arr[0] == arr[n - 2]) ||
            (s[n - 1] == 'o' && arr[0] != arr[n - 2]))
        {
            if (arr[0] == 'S')
            {
                if ((s[0] == 'o' && arr[1] == arr[n - 1]) ||
                    (s[0] == 'x' && arr[1] != arr[n - 1]))
                {
                    return true;
                }
                else
                    return false;
            }
            else
            {
                if ((s[0] == 'x' && arr[1] == arr[n - 1]) ||
                    (s[0] == 'o' && arr[1] != arr[n - 1]))
                {
                    return true;
                }
                else
                    return false;
            }
        }
        else
            return false;
    }
}

int main()
{

    cin >> n >> s;

    if (!solve('S', 'S'))
        if (!solve('S', 'W'))
            if (!solve('W', 'S'))
                if (!solve('W', 'W'))
                {
                    cout << -1 << endl;
                    return 0;
                }

    REP(i, n)
    {
        cout << arr[i];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 int n, l;
string tab[101];
int main() {
cin >> n >> l;
for (int i = 0; i < n; i++) cin >> tab[i];
sort(tab, tab+n);
for (int i = 0; i < n; i++) cout <<tab[i];
cout <<"\n";
return 0;
}

Measured memory_bytes: 256
#107_C
N,K=map(int,input().split())
X=list(map(int,input().split()))

#全探索
Ans=10**9
for i in range(N-K+1):
    XL,XR=X[i],X[i+K-1]
    if XL*XR>0:
        Ans=min(Ans,max(abs(XR),abs(XL)))
    else:
        Ans=min(Ans,abs(XR)*2+abs(XL),abs(XL)*2+abs(XR))
print(Ans)

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

const int maxn = 1e5 + 10;

bool good[maxn];
int h[maxn];

bool repeat[maxn];

map<ll, pair<ll, ll> > m;

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();
    int a, b, x; cin >> x;
    for (ll i = -1000; i <= 1000; i++) {
        m[i*i*i*i*i] = mp(1, i);
    }
    for (ll i = -1000; i <= 1000; i++) {
        if (m[x - i*i*i*i*i].fi != 0) {
            cout << i << ' ' << -m[x - i*i*i*i*i].se;
            break;
        }
    }
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    vector<string> k = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++)
    {
        reverse(k[i].begin(), k[i].end());
    }
    bool a = true;
    for (int i = 0; i < s.size();)
    {
        bool b = false;
        for (int j = 0; j < 4; j++)
        {
            if (s.substr(i, k[j].size()) == k[j])
            {
                b = true;
                i += k[j].size();
            }
        }
        if (!b){
            a = false;
            break;
        }
    }
    cout << (a ? "YES" : "NO") << endl;
}

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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=n;
  for(int i=0;i<t;i++,x+=c[i])
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt--,used[j]=1,x--;
    }
  return !cnt;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3160
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
cnt = [0] * (10 ** 5 + 10)

for i in a:
    cnt[i] += 1
    cnt[i + 1] += 1
    cnt[i + 2] += 1

print(max(cnt))

Measured memory_bytes: 19052
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	S := sc.NextToken()
	A := int('A')
	Z := int('Z')
	for _, c := range S {
		r := rune(((int(c) - A + N) % (Z - A + 1)) + A)
		fmt.Print(string(r))
	}
	fmt.Println()
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc: sc}
}

func (r *Scanner) SetBufferSize(size int) {
	buf := make([]byte, size)
	r.sc.Buffer(buf, size)
}

func (r *Scanner) NextToken() string {
	r.sc.Scan()
	return r.sc.Text()
}

func (r *Scanner) NextInt64() int64 {
	n, e := strconv.ParseInt(r.NextToken(), 10, 64)
	if e != nil {
		panic(e)
	}
	return n
}

func (r *Scanner) NextInt() int {
	n, e := strconv.ParseInt(r.NextToken(), 10, 32)
	if e != nil {
		panic(e)
	}
	return int(n)
}

func (r *Scanner) NextInt64Array(size int) []int64 {
	a := make([]int64, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt64()
	}
	return a
}

func (r *Scanner) NextIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt()
	}
	return a
}


Measured memory_bytes: 896
#include <stdio.h>

int Adj[100][100];

int main(void){
  int n,i,j,k,v,u;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j==n){
        if(Adj[i][j]!=0) printf("1");
        else
          printf("0");
        break;
      }
      if(Adj[i][j]!=0) printf("1 ");
      else printf("0 ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

template <typename T>
class Segtree {
private:
    int n;
    vector <T> tr;
    T neutral_tr = -1e18;

    T merge(T a, T b) {
        return max(a, b);
    }

    template <typename U>
    void build(const vector <U>& a) {
        forn (i, 0, n) 
            tr[i + n] = a[i];
        for (int i = n - 1; i > 0; i--)
            tr[i] = merge(tr[2 * i], tr[2 * i + 1]);
    }
public:
    template <typename U>
    Segtree(const vector <U>& a) : n(sz(a)) {
        tr.resize(2 * n, neutral_tr);
        build(a);
    }

    Segtree(int _n) : n(_n) {
        tr.resize(2 * n, neutral_tr);
    }

    T get(int l, int r) {
        T ans = neutral_tr;
        for (l += n, r += n; l < r; l /= 2, r /= 2) {
            if (l % 2)
                ans = merge(ans, tr[l++]);
            if (r % 2)
                ans = merge(ans, tr[--r]);
        }
        return ans;
    }
    
    void upd(int i, T x) {
        for (i += n, chkmax(tr[i], x); i /= 2; i > 0)
            tr[i] = merge(tr[2 * i], tr[2 * i + 1]);
    }
};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> h(n);
    forn (i, 0, n)
        cin >> h[i];
    vector <int> a(n);
    cin >> a;
    Segtree <long long> tr(n + 1);
    tr.upd(0, 0);
    forn (i, 0, n)
        tr.upd(h[i], tr.get(0, h[i]) + a[i]);
    cout << tr.get(0, n + 1);
    return 0;
}

Measured memory_bytes: 4992
a,v  = map(int,input().split())
b,w  = map(int,input().split())
t = int(input())
    
    
if v<=w:
    print('NO')
elif a<b and (b-a)/(v-w)<=t:# and (b-a)/(v-w)==(b-a)//(v-w):
    print('YES')
elif b<a and (a-b)/(v-w)<=t:# and (a-b)/w-v:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9196
#include<iostream>

using namespace std;

int main() {


	int a, b;
	cin >> a >> b;
	int ans[4] = { 0 };

	ans[a ] = ans[b] = 1;

	for (int i = 1; i <= 3; i++) {
		if (ans[i] == 0)cout << i << endl;
	}
	return 0;



}

Measured memory_bytes: 256
#include <stdio.h>
int less(int a, int b){
    if(a > b) return b;
    else return a;
}
int get(int m, int n){
    int r = m % n;
    int q = m / n;
    if(r != 0) return q+1;
    else return q;
}

int main(void){
    int A, B, X, total1=0, total2=0, total3=0;
    scanf("%d %d %d", &A, &B, &X);
    int n = X / 1000;
    int q1 = get(X - 1000 * n, 500);
    total1 = A * n + B * q1;
    int q2 = get(X, 500);
    total2 = B * q2;
    int q3 = get(X, 1000);
    total3 = A * q3;
    int result = less(less(total1, total2), total3);
    printf("%d\n", result);
}



Measured memory_bytes: 2768
#include<iostream>
#include<cstdio>
using namespace std;
#define mod 1000000007
#define LL long long

int n;

int main()
{
    while(~scanf("%d",&n))
    {
        LL ans=1;
        for(int i=1;i<=n;++i)
            ans=((ans%mod)*(i%mod))%mod;
        printf("%lld\n",ans);
    }
}


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

using namespace std;

int cost[101][101];
int n,m;
int mincost[101];
bool used[101];
int V;

const int INF=10000000;

int prim(){
	for(int i = 0; i < V; i++){
		mincost[i]=INF;
		used[i]=false;
	}
	mincost[0]=0;
	int res=0;

	while(1){
		int v=-1;
		for(int u = 0; u < V; u++){
			if(!used[u]&&(v==-1||mincost[u]<mincost[v]))
				v=u;
		}
		if(v==-1)
			break;
		used[v]=true;
		res+=mincost[v];
		for(int u = 0; u < V; u++){
			mincost[u]=min(mincost[u],cost[v][u]);
		}
	}
	return res;
}

int main(){

	while(cin>>n&&n!=0){
		cin>>m;
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				cost[i][j]=INF;
		for(int i = 0; i < m; i++){
			int from,to,ct;
			char c;
			cin>>from>>c>>to>>c>>ct;
			ct-=100;
			cost[from][to]=ct;
			cost[to][from]=ct;
		}
		V=n;
		cout<<prim()/100<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define lrep(i,n) for(long int i=0;i<(n);i++)
using namespace std;
int main(){
	long int n;
	cin >>n;
	long long int a,ans=1;
	lrep(i,n){
		cin >>a;
		if(a==0){
			ans=0;
			break;
		}
		if(ans==-1)continue;
		if(a>1000000000000000000/ans){
			ans=-1;
			continue;
		}
		ans*=a;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
template< typename T = long long >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    auto c=make_v<string>(h);
    rep(i,h)cin>>c[i];
    int ret=0;
    for(int bith=0;bith<(1<<h);bith++){
        for(int bitw=0;bitw<(1<<w);bitw++){
            auto s=c;
            for(int i=0;i<h;i++){
                if(bith&(1<<i))for(int j=0;j<w;j++)s[i][j]='R';
            }
            for(int i=0;i<w;i++){
                if(bitw&(1<<i))for(int j=0;j<h;j++)s[j][i]='R';
            }
            int cnt=0;
            for(int i=0;i<h;i++){
                rep(j,w){
                    if(s[i][j]=='#')cnt++;
                }
            }
            if(cnt==k)ret++;
        }
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 3628
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <iostream>
#include <map>
using namespace std;
int main() {
	string s, a;
	a = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')a += '0';
		if (s[i] == '1')a += '1';
		if (s[i] == 'B'&&a != "") a.pop_back();
	}
	cout << a << endl;
}

Measured memory_bytes: 256
import math

def Colon():

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

    angle_1 = (num[2]/12.)*360. + (num[3]/(60.*12.))*360.

    angle_2 = (num[3]/60.)*360.
    
    length = math.sqrt(num[0]*num[0] + num[1]*num[1] - 2.*num[0]*num[1]*math.cos(math.radians(angle_2 - angle_1)))

    print(length)

if __name__ == '__main__':
    Colon()



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


ll count_pair(ll x, ll a, vector<ll> &audiences) {
    ll need_b = x - a;
    auto it = lower_bound(audiences.begin(), audiences.end(), need_b);
    ll count = audiences.end() - it;
    return count;
}

ll get_max_x(vector<ll> &audiences, ll m) {
    ll floor = 2;
    ll ceil = INF;

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        ll ans = 0;
        for (ll a : audiences) {
            ans += count_pair(mid, a, audiences);
        }
        if (m <= ans) {
            floor = mid;
        } else {
            ceil = mid;
        }
    }
    return floor;
}

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

ll sum_pair(ll count, ll a, CumulativeSum &cs) {

    ll a_sum = a * count;
    ll b_sum = cs.getSum(count - 1);

    ll sum = a_sum + b_sum;

    return sum;
}


int main() {

    ll n, m;
    cin >> n >> m;

    vector<ll> audiences(n);
    rep(i, n) cin >> audiences[i];
    sort(audiences.begin(), audiences.end());

    ll max_x = get_max_x(audiences, m);

    CumulativeSum cs(n);
    vector<ll> rev = audiences;
    reverse(rev.begin(), rev.end());
    rep(i, n) cs.set(i, rev[i]);
    cs.calculate();


    ll sum = 0;
    ll total_count = 0;
    for (auto a : audiences) {
        ll count = count_pair(max_x, a, audiences);
        total_count += count;
        sum += sum_pair(count, a, cs);
    }

    ll diff = (total_count - m) * max_x;
    ll ans = sum - diff;

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define int long long
#define pi 3.141592
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int a,b,c,x,cnt=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x)cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, M;
	Node[] nodes;

	static class Node {
		int id;
		int parent = -2;
		Set<Integer> conns;

		Node(int id) {
			this.id = id;
			this.conns = new HashSet<>();
		}
	}

	static class Edge {
		int src, dst;

		Edge(int src, int dst) {
			this.src = src;
			this.dst = dst;
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		this.nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			this.nodes[i] = new Node(i);
		}
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			int a = Integer.parseInt(tokens[0]) - 1;
			int b = Integer.parseInt(tokens[1]) - 1;
			nodes[a].conns.add(b);
			nodes[b].conns.add(a);
		}
	}

	void mark(int current, int parent) {
		if (nodes[current].parent != -2) {
			return;
		}
		nodes[current].parent = parent;
		for (Integer i : nodes[current].conns) {
			if (i.equals(parent)) {
				continue;
			}
			mark(i, current);
		}
	}

	void calc() {
		Deque<Edge> que = new ArrayDeque<>();
		for (Integer dst : nodes[0].conns) {
			que.add(new Edge(0, dst));
		}
		Set<Integer> markedNodes = new HashSet<>();
		markedNodes.add(0);
		nodes[0].parent = -1;
		while (!que.isEmpty()) {
			Edge edge = que.poll();
			if (!markedNodes.contains(edge.dst)) {
				nodes[edge.dst].parent = edge.src;
				markedNodes.add(edge.dst);
				for (Integer dst : nodes[edge.dst].conns) {
					if (markedNodes.contains(dst)) {
						continue;
					}
					que.add(new Edge(edge.dst, dst));
				}
			}
		}
		System.out.println("Yes");
		for (int i = 1; i < N; ++i) {
			System.out.println((nodes[i].parent + 1));
		}
	}

	void showResult() {
	}

}


Measured memory_bytes: 113576
N, L = map(int, input().split())
num_min = L + 1 - 1
num_max = L + N - 1
if 0 < num_min:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_min
elif num_max < 0:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_max
else:
    s = sum([L + i - 1 for i in range(1, N+1)] )
print(s)

Measured memory_bytes: 3060