akhauriyash/Code-Regression huggingface dataset:
n = int(input())
A = [int(input()) for _ in range(n)]

# 間隔gを指定した挿入ソート
def insertSort(A, g):
	n = len(A)
	global cnt
	for i in range(g, n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j + g] = A[j]
			j -= g
			cnt += 1
		A[j + g] = v
	return 0

def shellSort(A):
	n = len(A)
	G = []
	# G = {1, 4, 13, 40, 121, 364,...}
	h = 1
	while h <= n:
		G.append(h)
		h = 3 * h + 1
	for i in range(len(G) - 1, -1, -1):
		insertSort(A, G[i])
	return G

cnt = 0
G = shellSort(A)
print(len(G))
print(*G[::-1])
print(cnt)
for v in A: print(v)


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

using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int solve(int x) {
    int n = 1;
    while(true)
    {
        if((n + 1) * (n + 2) / 2 <= x) {
            n += 1;
            continue;
        }
        return n;
    }
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);

    int ans = 0;
    for (auto p : res) {
        //for (int i = 0; i < p.second; ++i) cout << " " << p.first;
        //cout << ' ' << solve(p.second) << endl;
        ans += solve(p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }

    let strw = s.as_str();
    if strw == "SSS" {
        println!("0");
    } else if strw == "SSR" || strw == "SRS" || strw == "RSS" || strw == "RSR" {
        println!("1");
    } else if strw == "RRS" || strw == "SRR" {
        println!("2");
    } else {
        println!("3");
    }
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <stdio.h>
#define N 8
#define FREE 1
#define NOT_FREE 0

int   A[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void print(){
	int i,j;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(A[i][j]){
				if(row[i]!=j)
					return ;
			}
		}
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(row[i]==j)
				printf("Q");
			else
				printf(".");
		}
		printf("\n");
	}
}


void setqueen(int i){
	int j;
	if(i==N){
		print();
	return ;
    }
	for(j=0;j<N;j++){
		if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE)
			continue;
		row[i]=j;
		col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
		setqueen(i+1);			
		row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
	}
}
int main(){
	int i,j,k,r,c;
	for(i=0;i<N;i++){
		row[i]=FREE;
		col[i]=FREE;
	}
	for(i=0;i<2*N-1;i++){
		dpos[i]=FREE;
		dneg[i]=FREE;
	}

	scanf("%d",&k);
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			A[i][j]=NOT_FREE;
		}
	}
	for(i=0;i<k;i++){
		scanf("%d%d",&r,&c);
		A[r][c]=FREE;
	}
	setqueen(0);

	return 0;
}



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


const int Interval = 512;
struct SqrtDecomp{
  typedef long long Type;
  const int n;
  vector<Type> arr,buc;
  const Type ide;

  Type func(Type a,Type b){
    return min(a,b);
  }

  Type update_func(Type a,Type x){
    return x;
  }

  SqrtDecomp(const vector<Type>& init,const Type& ide_) : n(init.size()),ide(ide_),arr(init),buc((int)init.size() / Interval + 10,ide_){
    for(int i = 0;i < n;i++){
      buc[i / Interval] = func(buc[i / Interval],arr[i]);
    }
  }

  Type get_inter(int l,int r){
    Type res = ide;
    while(l < r){
      if(l % Interval == 0 && l + Interval <= r){
        res = func(res , buc[l / Interval]);
        l += Interval;
      }
      else{
        res = func(res , arr[l]);
        l++;
      }
    }
    return res;
  }

  void update(int idx,const Type& x){
    arr[idx] = update_func(arr[idx] , x);
    buc[idx / Interval] = ide;
    int start = idx - idx % Interval;
    int end = min(start + Interval , (int)arr.size());
    for(int i = start;i < end;i++){
      buc[idx / Interval] = func(buc[idx / Interval],arr[i]);
    }
  }
};
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
int main(){
  int n,q;
  cin >> n >> q;
  SqrtDecomp srd(vector<i64>(n,(1LL << 31) - 1),(1LL << 31) - 1);
  vector<i64> ans;
  for(int i = 0;i < q;i++){
    i64 com,x,y;
    cin >> com >> x >> y;
    if(com == 0){
      srd.update(x,y);
    }
    else{
      ans.push_back(srd.get_inter(x,y + 1));
    }
  }

  for(int i = 0;i < ans.size();i++){
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 4500
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    if(n!=a)cout<<1<<"\n";
    else cout<<0<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <tuple>
#define ed "\n"
using namespace std;
struct P
{
    int x;
    int y;
};
int main()
{
    int n;
    cin >> n;
    vector<P> m(n);
    if (n == 1)
    {
        cout << "1" << ed;
        return 0;
    }
    //入力
    for (int i = 0; i < n; i++)
    {
        cin >> m[i].x >> m[i].y;
    }
    // sort(m.begin(), m.end(), [](const P &a, const P &b) { if(a.x == b.x){ return a.y < b.y; } return a.x < b.x; });
    map<tuple<int, int>, int> memo;
    int max = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            P t;
            if (m[i].x - m[j].x > 0)
                t = {m[i].x - m[j].x, m[i].y - m[j].y};
            else if(m[i].x - m[j].x < 0){
                t = {-(m[i].x - m[j].x), -(m[i].y - m[j].y)};
            } else {
                t = {0, abs(m[i].y - m[j].y)};
            }
            cerr << m[i].x << "-" << m[j].x << " " << i << " " << j << "\n";
            memo[make_tuple(t.x, t.y)]++;
            if (max < memo[make_tuple(t.x, t.y)])
                max = memo[make_tuple(t.x, t.y)];
        }
    }
    cout << n - max << ed;
    
    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
typedef long long LL;
 
const int maxn = 400005;
int last[2 * maxn],pre[2 * maxn],other[2 * maxn];
LL cost[2 * maxn],dis[maxn];
bool vis[maxn];
int que[maxn];
int all = -1;
 
void build(int x,int y,LL z){
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = z;
}
 
bool dfs(int x){
	vis[x] = 1;
	int dt = last[x];
	while(dt != -1){
		int dr = other[dt];
		if(vis[dr] == 0){
			dis[dr] = dis[x] + cost[dt];
			if(!dfs(dr)) return false;
		}
		if(vis[dr] == 1){
			if(dis[dr] != dis[x] + cost[dt]) return false;
		}
		dt = pre[dt];
	}
	return true;
}
 
int main(){
	int n,m;
	cin >> n >> m;
	memset(last,-1,sizeof(last));
	int cnt = 0;
	for(int i = 1;i <= m;i++){
		int x,y;
		LL z;
		cin >> x >> y >> z;
		if(vis[x] == 0) vis[x] = 1,que[++cnt] = x;
		if(vis[y] == 0) vis[y] = 1,que[++cnt] = y;
		build(x,y,z);
		build(y,x,-z);
	}
	memset(vis,0,sizeof(vis));
	for(int i = 1;i <= cnt;i++){
		if(vis[que[i]] == 0){
			dis[que[i]] = 0;
			if(dfs(que[i]) == false){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 21632
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define upadj(i,adj) if (adj.size()>0) up(i,0,adj.size()-1)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << "=" <<X << endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 1e5+10;
int n,p[N];
void input()
{
    cin>>n;
    up(i,1,n) cin>>p[i];
}

void solve()
{
    int r=0;
    int i=1;
    while (i<=n)
    {
        if (p[i]!= i) i++;
        else
        {
            r++; i+= 2;
        }
    }
    cout<<r;
}

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

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int inf = 0x3f3f3f3f;
int n;
ll num[maxn],ans,a[maxn];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	rep(i,1,n) {
		int x;
		cin>>x;
		a[i]=x;
		num[x]++;
	}
	rep(i,1,n) {
		ans+=num[i]*(num[i]-1)/2;
	}
	rep(i,1,n) {
		cout<<ans-num[a[i]]+1<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, k, d;
  cin >> x >> k >> d;
  if(x < 0) {
    ll tmp = x;
    x += min(k, (abs(x) + d - 1) / d) * d;
    k -= min(k, (abs(tmp) + d - 1) / d);
  }
  else {
    ll tmp = x;
    x -= min(k, abs(x) / d) * d;
    k -= min(k, abs(tmp) / d);
  }
  k %= 2;
  x -= k * d;
  cout << abs(x) << endl;
    // cout << x << ' ' << k << ' ' << d << endl;

}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int cnt[100010];
int res[100010];
int a[100010];
int main(){
	int n,m;
	cin>>n>>m;
	int b=0;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		cnt[b]=abs(a[i]-m);
		b++;
	}
	sort(cnt,cnt+n);
	int x=cnt[0];
	int c=0;
	for(int i=1;i*i<=x;i++){
		if(x%i==0){
			res[c]=i;
			c++;
			res[c]=x/i;
			c++;
		}
	}
	sort(res,res+c);
	for(int i=c-1;i>=0;i--){
		bool flag=true;
		int ans=m;
		for(int j=0;j<n;j++){
			if(abs(a[j]-ans)%res[i]!=0){
				flag=false;
				break;
			}
			ans=a[j];
		}
		if(flag){
			cout<<res[i]<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if(a.back()!=b.front()) {
    cout << "NO" << endl;
    return 0;
  }
  if(b.back()!=c.front()) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
l = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for i in range(len(s) - 1):
    num = (26 - l.index(s[i])) % 26
    if k >= num:
        ans += "a"
        k -= num
    else:
        ans += s[i]
ans += l[(l.index(s[-1]) + k) % 26]
print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int diff(string a, string b)
{
    int ret = 0;
    int n = a.size();
    for(int i = 0; i < n; i++)
    {
        if(a[i] != b[i]) ret++;
    }
    return ret;
}

void solve()
{
    int n; cin>>n;
    vi v;
    // ll sm = 0;
    vl sm(n+3);
    rep(i, n)
    {
        int x; cin>>x;
        v.pb(x);
        // sm += x;
    }
    REPR(i, n-1, 0)
    {
        sm[i] = (sm[i+1] + v[i+1]) % mod;
    }
    ll ans = 0;
    rep(i, n) {
        ll put = (1LL*v[i]*(sm[i])) % mod;
        ans = (ans + put) % mod;
    }
    cout<<ans;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





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

int main()
{
  int n;
  cin >> n;
  ll ans = -1e9, nmin;
  cin >> nmin;
  for (int i = 1; i < n; ++i)
  {
    ll val;
    cin >> val;
    ans = max(ans, val - nmin);
    nmin = min(nmin, val);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 char a[200010],b[200010];sc(a);sc(b);
 ll len=strlen(a);
 rep(i,0,len){
  if(a[i]!=b[i])ans++;
 }
  
 pr(ans);
return 0;}

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

int main(){
    int N; cin >> N;
    int V[N], C[N];
    
    for(int i=0; i<N; ++i) cin >> V[i];
    for(int i=0; i<N; ++i) cin >> C[i];

    int ans=0;
    for(int i=0; i<N; ++i){
        if(V[i] > C[i]) ans+=V[i]-C[i];
    }

    cout << ans << endl;
}

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

int n;
int x[10],y[10];

double dist(int i,int j)
{
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    
    return pow(dx*dx + dy*dy,0.5);
}

void solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>x[i]>>y[i];
    
    double sum=0.0;
    vector<int> v(n);
    
    for(int i=0;i<n;i++)
    v[i]=i+1;
    
    do
    {
        for(int i=0;i<n-1;i++)
        sum+=dist(v[i],v[i+1]);
        
    }while(next_permutation(v.begin(),v.end()));
    
    int fac=1;
    
    for(int i=2;i<=n;i++)
    fac*=i;
    
    cout<<fixed<<setprecision(10)<<sum/fac<<endl;
    return;
}

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

Measured memory_bytes: 640
n,k= map(int, input().split())
d=[0]*k
A=[0]*k
p=[0]*(n+1)
for i in range(k):
    d[i]=int(input())
    A[i] = list(map(int, input().split()))

for i in range(k):
    for j in range(d[i]):
        p[A[i][j]]=1
print(n-sum(p))

Measured memory_bytes: 9208
# coding: utf-8
# user: herp_sy

import math
import statistics

cnt = 0
keta = []
a,b = map(int, input().split())
for i in range(a,b + 1):
  n = i
  for j in range(5):
    keta.append(n % 10)
    n = n // 10
  if keta[0] == keta[4] and keta[1] == keta[3]:
    cnt = cnt + 1
  keta = []
print(cnt)


Measured memory_bytes: 5724
#include <iostream>
#include <string>
#include<math.h>


using namespace std;



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

    long long total = 0;
    if(2*N <= M){
        total = N + floor((M - 2 * N) / 4);
    }
    else{
        total = floor(M / 2);
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];

  int cnt = 0;
  ll in = 1e+12;
  ll sum = 0;
  rep(i,n){
    sum += a[i];
    if(a[i]>b[i]){
      in = min(in,b[i]);
    }
    else if(a[i]<b[i]){
      continue;
    }
    else cnt++;
  }
  if(cnt==n){
    cout << 0 << "\n";
    return 0;
  }
  cout << sum - in << "\n";
  return 0;
}


Measured memory_bytes: 512
#https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_b

N = int(input())
S = str(input())
K = int(input())

Sarray = list(S)
a = Sarray[K - 1]
Sprc = ''

for i in range(len(Sarray)):
    if Sarray[i] != a:
        Sarray[i] = '*'
    Sprc += Sarray[i]

print(Sprc)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;

int dp[40000];int a[1000+1],b[1000+1]; 

int main(){
	fastio;
	int n,h;
	cin>>h>>n;
	rb(i,1,n){
		cin>>a[i]>>b[i];
	}
	memset(dp,0x3f,sizeof(dp));
	dp[h]=0;
	int res=INF;
	rb(i,1,n){
		rl(j,h,0){
			dp[max(j-a[i],0)]=min(dp[max(j-a[i],0)],dp[j]+b[i]);
		}
		res=min(res,dp[0]);
	}cout<<res;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n, k, l1, l2, l3, z;
ll a[maxn], b[maxn], c[maxn];

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        ll x;
        scanf("%lld", &x);
        if (x > 0) a[++l1] = x;
        if (x < 0) b[++l2] = x;
        if (x == 0) z++;
        c[++l3] = abs(x);
    }
    sort(a + 1, a + 1 + l1);
    sort(b + 1, b + 1 + l2, greater<ll>());
    ll res = 1;
    if (l1 + l2 / 2 * 2 >= k && (k % 2 == 0 || l1)) {// 正数
        if (k % 2) {
            res = res * a[l1] % mod;
            l1--;
            k--;
        }
        while (k) {
            ll v1 = (l1 > 1 ? a[l1] * a[l1 - 1] : 0);
            ll v2 = (l2 > 1 ? b[l2] * b[l2 - 1] : 0);
            if (v2 >= v1) {
                res = v2 % mod * res % mod;
                l2 -= 2;
            } else {
                res = v1 % mod * res % mod;
                l1 -= 2;
            }
            k -= 2;
        }
    } 
    else if (z) res = 0;// 零
    else {// 负数
        sort(c + 1, c + 1 + n);
        for (int i = 1; i <= k; i++) res = res * c[i] % mod;
        res = (-res + mod) % mod;
    }
    printf("%lld\n", res);

    return 0;
}

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

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

    int n,k;
    while(cin >> n >> k){
            int ck;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a == 1)ck = i;
    }
    int pk = n - ck + 1;
    if(k == 2)cout<<n-1<<endl;
    else if (k == n)cout<<1<<endl;
   else  if(pk % k == 0 || ck % k == 0)
    cout<<n/(k-1)<<endl;
    else
        cout<<n/(k-1) + 1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h_array = list(map(int, input().split()))


c_array = [0] * N
c_array[0] = 0

for i in range(1, N):
    c_min = 10 ** 10
    for k in range(1, K + 1):
        if i - k >= 0:
            c_min = min(c_min, c_array[i - k] +
                        abs(h_array[i - k] - h_array[i]))
    c_array[i] = c_min


print(c_array[-1])


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

int main(void){
  char s[1001],t[1001];
  scanf("%s",s);
  scanf("%s",t);
  
  int S=strlen(s);
  int T=strlen(t);
  int min=T;
  for(int i=0;i<=S-T;i++){
    int c=0;
    for(int j=0;j<T;j++){
      if(t[j]!=s[i+j]){
        c++;
      }
     }
     if(min>c){
        min=c;
      }
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
using namespace std;
#define M 1000000007

long long fib(int m) {
    long long a = 2, b = 1;
    //cerr << m << ' ';
    if (m <= 0) return 1;
    while (--m) { long long t = a; a = a + b; b = t; if (a >= M) a -= M; }
    //cerr << a << ' ' << b << endl;
    return a;
}

int main(int argc, char** argv) {
    int h, w, k; cin >> h >> w >> k;
    long long dp[h+1][w+1] = {};
    dp[0][1] = 1;
    for (int i = 0; i < h; i++)
        for (int j = 1; j <= w; j++) {
            (dp[i+1][j] += dp[i][j] * fib(j-2) % M * fib(w-j-1) % M) %= M;
            if (j > 1) (dp[i+1][j-1] += dp[i][j] * fib(j-3) % M * fib(w-j-1) % M) %= M;
            if (j < w) (dp[i+1][j+1] += dp[i][j] * fib(j-2) % M * fib(w-j-2) % M) %= M;
        }
    cout << dp[h][k] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<pii> a(n - 1);
	vector<vector<int>> g(n,vector<int>());
	rep(i,n - 1){
		cin >> a.at(i).first >> a.at(i).second;
		a.at(i).first--;
		a.at(i).second--;
		g.at(a.at(i).first).pb(a.at(i).second);
		g.at(a.at(i).second).pb(a.at(i).first);
	}
	map<pii,int> m;
	queue<pii> q;
	q.push(mp(0,0));
	int K = 0;
	while(!q.empty()){
		int cur = q.front().first, col = q.front().second;
		q.pop();
		int c = 1;
		rep(i,g.at(cur).size()){
			int next = g.at(cur).at(i);
			if(m[mp(cur,next)] > 0) continue;
			if(c == col) c++;
			m[mp(cur,next)] = c;
			m[mp(next,cur)] = c;
			q.push(mp(next,c));
			K = max(K,c);
			c++;
		}
	}
	cout << K << endl;
	rep(i,n - 1){
		cout << m[mp(a.at(i).first,a.at(i).second)] << endl;
	}
}


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

ll return_gcd(ll a, ll b){
    if(b == 0) return a;
    return return_gcd(b, a%b);
}

ll return_lcm(ll a, ll b){
    ll gcd = return_gcd(a,b);
    return a / gcd * b;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n,m;
    cin >> n >> m;
    
    string s,t;
    cin >> s >> t;
    
    ll x = return_lcm(n, m);
    
    bool flag = true;
    
    if(s[0] != t[0]) flag = false;
    for(ll i = 1;; i++){
        if(i * x / m >= n and i * x / n >= m) break;
        if(s[i * x / m] != t[i * x / n]) {
            flag = false;
            break;
        }
    }
    
    if(flag) cout << x << endl;
    else cout << -1 << endl;
}

 



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            if (A - 2 * B <= 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(A - 2 * B);
            }
        }
    }
}


Measured memory_bytes: 27484
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main() {
  ll n;
  cin>>n;
  clr(d,0);
  rep(i,0,n){
  	ll a;
  	cin>>a;
  	d[a]++;
  }
  ll mx = 0;
  rep(i,1,100050){
  	mx = max(mx,d[i-1]+d[i]+d[i+1]);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 1024
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){
    init();
	ll n,C;cin>>n>>C;
	vector<ll>x(n+2);
	vector<ll>v(n+2);
	vector<ll>Lm(n+2,0);
	vector<ll>Rm(n+2,0);
	for(int i=1;i<=n;i++){
		cin>>x[i]>>v[i];

	}
	ll ans = 0, qz = 0;
	for(int i = 1; i <= n; ++i) {
		qz += v[i];
		Lm[i] = max(Lm[i - 1], qz - x[i]);
	}
	qz = 0;
	for(int i = n; i >= 1; --i) {
		qz += v[i];
		Rm[i] = max(Rm[i + 1], qz - (C - x[i]));
	}
	ans = max(ans, max(Lm[n], Rm[1]));
	qz = 0;
	for(int i = 1; i <= n; ++i) {
		qz += v[i];
		ans = max(ans, qz - x[i] * 2 + Rm[i + 1]);
	}
	qz = 0;
	for(int i = n; i >= 1; --i) {
		qz += v[i];
		ans = max(ans, qz - (C - x[i]) * 2 + Lm[i - 1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main () {
  int a, b, c;
  int hishi = 0, rect = 0;
  
  while(cin >> a){
    cin.ignore();
    cin >> b;
    cin.ignore();
    cin >> c;

    if(a == b)
      hishi++;
    if(a * a + b * b == c * c)
      rect++;
  }

  cout << rect << endl << hishi << endl;

}

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

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

    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,l[100005],r[100005];
long long ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	n=read();
	for(int i=0;i<n;++i) l[i]=read(),r[i]=read();
	sort(l,l+n+1); sort(r,r+n+1);
	for(int i=0;i<n;++i){
		if(l[n-i]-r[i]<1) break;
		ans+=l[n-i]-r[i];
	}
	printf("%lld",ans<<1);
}

Measured memory_bytes: 1024
# Input the amount of money Takahashi paid
N = int(input())

# Check if the price before tax is X, for X = 1, 2, 3, ..., N
ans = 0
for i in range(1, N + 1):
	if int(i * 1.08) == N:
		ans = i

# Print answer
if ans != 0:
	print(ans)
else:
	print(":(")


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

int main() {
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i = 0; i < N; i++){
        if(i != p[i] - 1){
            count++;
        }
    }
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6



int32_t main()
{


    int n;
    cin >> n;

    vector<int> v;

    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      v.PB(x);
    }


    sort(all(v));

    int ans = 0;

    for(int i = 0;i < v.size() - 1; i++)
    {
      ans += v[i];
    }

    ans += v[v.size()-1]/2;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
a, b=input().split(" ")
a=int(a)
b=int(b)

total=a*(b-1)+a*(a+1)/2

c=abs(b)
d=1
for i in range (1, a+1):
    if abs(b+i-1)<c:
        d=i
        c=abs(b+i-1)

print(int(total-(b+d-1)))

Measured memory_bytes: 3064
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main() {

	fast
	int n,k;
	cin>>n>>k;
	int hash[n+1]={0};
	rep(i,k)
	{
		int d;
		cin>>d;
		rep(i,d)
		{
			int a;
			cin>>a;
			hash[a]=1;
		}
	}
	int c=0;
	repe(i,1,n+1)
	{
		if(hash[i]==0)
			c++;
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int  main(){
	ll n,weight;
	cin>>n>>weight;
	ll w[109];
	ll v[109];
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
		sum+=v[i];

	}
	ll dp[sum+1];
	fill(dp,dp+sum+1,1e9+9);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=sum;j>=v[i];j--){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}

	}
	ll ans=0;

	for(ll i=1;i<=sum;i++){
		if(dp[i]<=weight)
		ans=max(ans,i);
	}
	cout<<ans;

	return 0;

}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n,a,b; cin >> n >> a >> b;
    if(n==1) cout << "Hello World" << ln;
    else cout << a + b << ln;
    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);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] ws = new int[n];

        int sum = 0;
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            sum += ws[i];
        }

        int right = sum;
        int left = 0;
        while (right - left > 1) {
            int center = (right + left) / 2;
            int wsn = check(ws, k, center);
            if (wsn >= n) {
                right = center;
            } else {
                left = center;
            }
        }

        System.out.println(right);
    }

    static int check(int[] ws, int k, int p) {
        int i = 0;
        for (int j = 0; j < k; j++) {
            int sum = 0;
            while (sum + ws[i] <= p) {
                sum += ws[i];
                i++;
                if (i == ws.length) return ws.length;
            }
        }
        return i;
//        int sum = 0;
//        for (int i = 0; i < ws.length; i++) {
//
//            if (ws[i] > p) {
//                return UNAVAILABLE;
//            }
//            if (k == 0) {
//                return i + 1;
//            }
//            sum += ws[i];
//            if (i == ws.length - 1) {
//                k--;
//                continue;
//            }
//            if (sum + ws[i + 1] > p) {
//                k--;
//                sum = 0;
//            }
//        }
//        return ws.length;
    }


}



Measured memory_bytes: 70488
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ;
using namespace std;
#define MAX 100003
bool check(vector<int> v)
{
    for(int i=0;i<v.size();i++){
        if(v[i]>1) return false;
    }
    return true;
}
int main()
{
    ll n; cin>>n;
    if(n==1)  { cout<<1<<endl; return 0; }
    bitset<22> dp[n+2];
    for(int i=1;i<=n;i++){
        ll a; cin>>a;
        bitset<22> bs(a);
        dp[i]=bs;
    }
    int start=1;
    int end=2;
    vector<int> v(22,0);
    ll ans=0;
    for(int i=0;i<22;i++) v[i]+=dp[1][i]+dp[2][i];
    while(start<=n){
        while(end<=n){
            int flag=0;
            if(!check(v)) break;
            end++;
            for(int i=0;i<22;i++){
                v[i]+=dp[end][i];
            }
        }
        // cout<<start<<" "<<end<<endl;
        ans+=end-start;
        for(int i=0;i<22;i++){
            v[i]-=dp[start][i];
        }
        // for(int i=0;i<22;i++) cout<<v[i]<<" ";
        // cout<<endl;
        start++;
    }
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 1792
a,b,k = map(int,input().split())

if (b+a)/2 - a < k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b-k+1,b+1):
    print(i)

Measured memory_bytes: 3060
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
  cand_num_a = bisect_left(A, B[i])
  cand_num_c = N - bisect_right(C, B[i])
  ans += cand_num_a * cand_num_c

print(ans)

Measured memory_bytes: 23232
#include <stdio.h>
int main(void){
    int n, i, max = 0, min = 99999;
    int a[1000];
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    for(i = 0; i < n; i++){
        if(max <= a[i]){
            max = a[i];
        }
    }
    //printf("%d\n", max);
    
    for(i = 0; i < n; i++){
        if(min >= a[i]){
            min = a[i];
        }
    }
    //printf("%d\n", min);
    printf("%d\n", max - min);
    
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int h, w;
    cin >> h >> w;
    int row = 0, col = 0;
    vector<string> grid(h);
    int grid_row = 0;
    int grid_col_now = w;
    set<int> skip_col;
    rep(i, h){
        string s;
        cin >> s;
        bool all_white = true;
        rep(j, w){
            if(s[j] == '#') all_white = false;
        }
        if(!all_white){
            grid[grid_row++] = s;
        }
    }

    rep(i, w){
        bool all_while = true;
        rep(j, grid_row){
            if(grid[j][i] == '#') all_while = false;
        }
        if(all_while){
            grid_col_now--;
            skip_col.insert(i);
        }
    }

    rep(i, grid_row){
        rep(j, w){
            if(skip_col.find(j) != skip_col.end()) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b>=a-b&&a+b>=a*b){
    cout<<a+b<<endl;
  }else if(a-b>=a+b&&a-b>=a*b){
    cout<<a-b<<endl;
  }else{
    cout<<a*b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl "\n"
#define sz(u) (int)(u.size())
typedef long long ll;
using namespace std;
void solve(){
int a,b;
    cin>>a>>b;
    if(a<=b)
        cout<<"unsafe";
    else
        cout<<"safe";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();

}


Measured memory_bytes: 3648
// ナニソレイミワカンナイ

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int main(){
    int R, C;
    while(std::cin >> R >> C, R && C){
        if(R % 2 == 1 && C % 2 == 1){
            std::cout << "no" << std::endl;
        }else{
            std::cout << "yes" << std::endl;
        }
    }
}

Measured memory_bytes: 1156
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	//cout << "size = " << s.size() << endl;

	int cur = 0;
	vector<int> v;
	int now = 1;
	int cnt = 0;
	rep(i, s.size())
	{
		if (s[i] == (char)('0' + now))
		{
			cnt++;
		}
		else
		{
			v.pb(cnt);
			cnt = 1;
			now = 1-now; // now ^= 1;
		}
	}
	if (cnt)
	{
		v.pb(cnt);
	}

	if (v.size() % 2 == 0)
	{
		v.pb(0);
	}

	int ans = 0;

	// 尺取り法
	int left = 0;
	int right = 0;
	int tmp = 0;
	int add = 2 * K + 1;
	for (int i = 0; i < v.size(); i+=2)
	{
		int nextleft = i;
		int nextright = min(i + add, (int)v.size());
		while(nextleft > left)
		{
			tmp -= v[left];
			left++;
		}

		while(nextright > right)
		{
			tmp += v[right];
			right++;
		}

		ans = max(ans, tmp);
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 1020
import java.util.Scanner;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int x, i = 0;
		while(true) {
			x = sc.nextInt();
			if(x == 0) break;
			i++;
			System.out.println("Case " + i + ": " + x);
		}
	}
}



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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;

bool solve(){
    int r, n;
    cin >> r >> n;
    if(!r)
        return false;

    // center: 50
    vector<int> v(100, 0);
    for(int i = 0; i < n; ++i){
        int l, r, y;
        cin >> l >> r >> y;
        l += 50, r += 50;
        for(int j = l; j < r; ++j)
            v[j] = max(v[j], y);
    }

    auto f = [&](double h){
        for(int i = 0; i < 100; ++i){
            double x = min(abs(i - 50 + 1e-8), abs(i - 50 + 1 - 1e-8));
            // r^2 = x^2 + y^2
            // sqrt(r^2 - x^2)
            if(r - x < 0)
                continue;
            if(sqrt(r * r - x * x) + h - r > v[i])
                return false;
        }
        return true;
    };

    double ok = 0, ng = 10000;
    for(int i = 0; i < 64; ++i){
        double mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    printf("%.20lf\n", ok);
    return true;
}

signed main(){
    while(solve());
}



Measured memory_bytes: 3144