akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX/10;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


#define MAX_N 16
int n;
int d[MAX_N][MAX_N];

int dp[1<<MAX_N][MAX_N];

int rec(int S,int v){//??¢????????£??????????????????S??¨???????????????v
	
	if(dp[S][v]>=0){//??¢?????????S????????????v??????????????????????????????
		return dp[S][v];
	}
	if(S==(1<<n)-1&&v==0){//S?????¨??????????????????????????¶?????§???????????????????????£?????????
		dp[S][v]=0;
		return 0;
	}
	int res=INF;
	for(int u=0;u<n;u++){
		if(!(S>>u & 1)){//??????u??????????????£??????????????¨???
			res=min(res,rec(S|1<<u, u)+d[v][u]);//??????u???S???????????????u->v????????????????????????????????´?????¨????????¨???res????????????
		}
	}
	dp[S][v]=res;
	//cout<<res<<endl;
	return res;
}
int main(){
	memset(dp,-1,sizeof(dp));
	
	int V,E;
	cin>>V>>E;
	n=V;
	REP(i,n)REP(j,n)d[i][j]=INF;
	REP(i,E){
		int s,t,cost;
		cin>>s>>t>>cost;
		d[s][t]=cost;		
	}
	int res=rec(0,0);
	if(res<INF)cout<<res<<endl;
	else cout<<-1<<endl;	
	return 0;
}

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

int arr[100000];

int main()
{
    int n,x,_max=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        arr[x]++;
    }

    for(int i=0;i<=100000-2;i++)
    {
        _max = max(_max, arr[i] + arr[i+1] + arr[i+2]);
    }

    cout<<_max<<endl;


}


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

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

    int A;
    int count[N] = {};

    for (int i = 0; i < Q; i++) {
        cin >> A;
        count[A - 1]++;
    }

    for (int j = 0; j < N; j++) {
        if (Q - count[j] < K) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int shu[100];
	int i = 0, j = 0, k = 0;
	char ch[5] = "";
	char s[15] = "";
	scanf("%s", s);
	for(i = 0; s[i] != '\0' && s[i + 2] != '\0'; i++)
	{
		k = i;
		for(j = 0; j < 3; j++, k++)
		{
			ch[j] = s[k];
		}
		k = atoi(ch);
		if(k < 753)
			shu[i] =  753 - k;
		else
			shu[i] = k - 753;
		memset(ch, 0x00, sizeof(char) * 5);
	}
	j = shu[0];
	for(k = 1; k < i; k++)
	{
		if(shu[k] < j)
			j = shu[k];
	}
	printf("%d\n", j);
	return 0;
}

Measured memory_bytes: 128
// Problem : F - Snuke's Coloring 2
// Contest : AtCoder Regular Contest 063
// URL : https://atcoder.jp/contests/arc063/tasks/arc063_d
// Memory Limit : 256 MB
// Time Limit : 4000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

struct point {
	int x, y;
	bool operator < (const point &o) const {
		return x < o.x;
	}
} p[N];

int w, h, n, ans = 0;

struct segtree {
	#define lc (id << 1)
	#define rc (lc | 1)
	#define mid ((l + r) >> 1)
 
	int lazy[N << 2], tree[N << 2];
 
	void init() {
		for (int i = 1; i < N << 2; i++) {
			tree[i] = lazy[i] = 0;
		}
	}
 
	void push(int id, int l, int r) {
		tree[id] += lazy[id];
		if (l < r) {
			lazy[lc] += lazy[id];
			lazy[rc] += lazy[id];
		}
		lazy[id] = 0;
	}
	 
	void update(int L, int R, int V, int id = 1, int l = 1, int r = n) {
		push(id, l, r);
		if (l > R || r < L || L > R) {
			return;
		}
		if (L <= l && r <= R) {
			lazy[id] = V;
			push(id, l, r);
			return;
		}
		update(L, R, V, lc, l, mid);
		update(L, R, V, rc, mid + 1, r);
		tree[id] = max(tree[lc], tree[rc]);
	}
	
	#undef lc
	#undef rc
	#undef mid
} seg;

void solve() {
	seg.init();
	stack<int> up, down;
	up.push(0);
	down.push(0);
	sort(p + 1, p + n + 1);
	seg.update(1, n, h << 1);
	for (int r = 1; r <= n; r++) {
		seg.update(1, r - 1, (p[r].x - p[r - 1].x) << 1);
		ans = max(ans, seg.tree[1]);
		if (p[r].y > (h >> 1)) {
			seg.update(up.top(), r - 1, (p[r].y - h) << 1);
			while (up.top() && p[up.top()].y > p[r].y) {
				int d = up.top();
				up.pop();
				seg.update(up.top(), d - 1, (p[r].y - p[d].y) << 1);
			}
			up.push(r);
		} else {
			seg.update(down.top(), r - 1, -p[r].y << 1);
			while (down.top() && p[down.top()].y < p[r].y) {
				int d = down.top();
				down.pop();
				seg.update(down.top(), d - 1, (p[d].y - p[r].y) << 1);
			}
			down.push(r);
		}
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> w >> h >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i].x >> p[i].y;
	}
	p[(++n)++] = {w, h};
	solve();
	for (int i = 1; i <= n; i++) {
		swap(p[i].x, p[i].y);
	}
	swap(h, w);
	solve();
	cout << ans;
}


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

using namespace std;

int main(){
    int N, K;
    int h[100000];
    int diff_min = INT32_MAX;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h, h+N);
    for(int i = 0; i <= N-K; i++){
        diff_min = min(diff_min, h[i+K-1] - h[i]);
    }
    cout << diff_min << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int R,G;
	int x;
	

	scanf("%d", &R);
	fflush(stdin);

	scanf("%d", &G);
	fflush(stdin);
	
	x = (G*2) - R;
	
	printf("%d", x);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    bool ary[200010];
    rep(i,200010) ary[i] = true;
    REP(j,2,200010)
    {
        if (!ary[j]) continue;
        int tmp_j = j*2;
        while (tmp_j<=100010)
        {
            ary[tmp_j] = false;
            tmp_j+=j;
        }
    }
    vector<int> prime_number;
    REP(j,2,200010)
    {
        if (ary[j]) prime_number.push_back(j);
    }
    for (auto itr=prime_number.begin();itr!=prime_number.end();++itr)
    {
        if (n<=*itr)
        {

            cout << *itr << endl;
            break;
        }
    }

    
}




Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// Segment tree
struct F { // min func
  typedef ll TT;
  TT d;
  F(TT d=0):d(d) {}
  F& operator+=(const F& f) {
    maxs(d, f.d);
    return *this;
  }
  F operator+(const F& f) const { return F(*this) += f;}
};
struct seg {
  vector<F> d; int n;
  seg(){}
  seg(int mx) {
    n = 1; while (n < mx) n <<= 1;
    d = vector<F>(n<<1);
  }
  void upd(int i) { d[i] = d[i<<1]+d[i<<1|1];}
  F& operator[](int i) { return d[n+i];}
  void init() { for(int i=n-1;i;--i) upd(i);}
  void set(int i, F f) {
    i+=n; d[i] = f;
    for (i>>=1;i;i>>=1) upd(i);
  }
  F get(int l, int r) {
    l += n; r += n;
    F lf, rf;
    while (l < r) {
      if (l&1) lf += d[l++];
      if (r&1) rf = d[--r] + rf;
      l >>= 1; r >>= 1;
    }
    return lf += rf;
  }
};
//


int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  cin>>a>>b;
  seg t(n+5);
  ll ans = 0;
  rep(i,n) {
    ll now = t.get(0,a[i]).d + b[i];
    maxs(ans,now);
    t.set(a[i],F(now));
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 5888
#include <stdio.h>


int main()
{		
	int n, k, ans, x, i;
		
	scanf("%d%d", &n, &k);
	ans = k, x = k - 1;
	for(i = 1; i < n; i++) ans *= x;
	printf("%d\n", ans);
		
	return 0;
}

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

using namespace std;

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

    map<string, int> counter;

    string vote;
    int Max = 0;
    while (n --) {
        cin >> vote;
        if (counter.count(vote) > 0) {
            counter[vote] ++;
        } else {
            counter[vote] = 1;
        }

        Max = max(counter[vote], Max);
    }

    for (auto p: counter) {
        if (p.second == Max)
            cout << p.first << endl;
    }

    return 0;
}

Measured memory_bytes: 26496
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())

if N == 0:
    print(0)
    exit()
elif N == 1 and A==B:
    print(1)
    exit()
elif N == 1 and A!=B:
    print(0)
    exit()
elif A>B:
    print(0)
    exit()
elif N==2:
    print(1)
    exit()
else:
    n = N-2
    ans = B*n - A*n +1
    print(ans)
    exit()
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    static final long MOD = 1000000007;
    static final int ALN = 26;
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int n = sc.nextInt();
        String s = sc.next();
        long[] appearance = new long[ALN];
        for(int i = 0; i < n; ++i) {
            char c = s.charAt(i);
            int windex = (int)(c - 'a');
            ++appearance[windex];
        }
        long ans = 1;
        for(int i = 0; i < ALN; ++i) {
            ans *= appearance[i] + 1;
            ans %= MOD;
        }
        --ans;
        System.out.println(ans);
    }
}


Measured memory_bytes: 24364
#include <iostream>
#include <cstdlib>
#include <list>
using namespace std;
int main()
{
    list<int> a;
    auto itr = a.end();
    int q, query, tmp;
    cin >> q;
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> tmp;
                itr = a.insert(itr, tmp);
                break;
            case 1:
                cin >> tmp;
                while(tmp!=0){
                    if(tmp > 0){
                        itr++;
                        tmp--;
                    }
                    else if (tmp < 0){
                        itr--;
                        tmp++;
                    }
                }
                break;
            case 2:
                itr = a.erase(itr);
                break;
        }
    }
    for (auto j=a.begin(); j != a.end(); ++j){
        cout << *j << endl;
    }
}


Measured memory_bytes: 18568
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#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
int main()
{
	SPEED
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	int max_length = 0;
	int cur_length = 0;
	for (int i = 0; i < n-1; ++i)
	{
		if (h[i+1]<=h[i])
		{
			cur_length++;
			if (cur_length>max_length)
			{
				max_length = cur_length;
			}
		}
		else
			cur_length=0;
	}
	cout << max_length;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n;
  string s;
  cin >> n >> s;
  vecint r, g, b;
  REP(i, n) {
    if (s[i] == 'R') {
      r.push_back(i);
    } else if (s[i] == 'G') {
      g.push_back(i);
    } else {
      b.push_back(i);
    }
  }
  // cout << "R" << endl;
  // REP(i, r.size()) { cout << r[i] << " " << endl; }
  // cout << "G" << endl;
  // REP(i, g.size()) { cout << g[i] << " " << endl; }
  // cout << "B" << endl;
  // REP(i, b.size()) { cout << b[i] << " " << endl; }
  // REP(i, r.size()) {
  //   auto itr = lower_bound(all(g), i);
  //   int k = itr
  // }
  ll ans = 0;
  REP(i, r.size()) {
    REP(j, g.size()) {
      int x = min(r[i], g[j]);
      int y = max(r[i], g[j]);
      int z;
      int tmp = 0;
      if ((x + y) % 2 == 0) {
        z = (x + y) / 2;
        auto itr = lower_bound(all(b), z);
        if (itr != b.end() && *itr == z) {
          tmp++;
        }
      }
      z = 2 * y - x;
      auto itr = lower_bound(all(b), z);
      if (itr != b.end() && *itr == z) {
        tmp++;
      }
      z = 2 * x - y;
      itr = lower_bound(all(b), z);
      if (itr != b.end() && *itr == z) {
        tmp++;
      }
      ans += b.size() - tmp;
      // REP(k, b.size()) {
      //   int a1 = min({r[i], g[j], b[k]});
      //   int a3 = max({r[i], g[j], b[k]});
      //   int a2 = r[i] + g[j] + b[k] - a1 - a3;
      //   // cout << a1 << " " << a2 << " " << a3 << endl;
      //   if (a1 + a3 != 2 * a2) {
      //     ans++;
      //   }
      // }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

const ll MOD = 1e9+7;

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

    map<int, ll> cnt;
    for(int n = 1; n <= N; n++){
        int x = n;
        for(int i = 2; i*i <= x; i++){
            while(x % i == 0) {
                cnt[i]++;
                x = x/i;
            }
        }
        if(x != 1) cnt[x]++;
    }

    ll ans = 1;
    for(int i = 2; i <= N; i++){
        ans *= (cnt[i]+1);
        ans %= MOD;
       // printf("%d:%lld\n", i, cnt[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, A, B, C=map(int,input().split())
l=[int(input())for i in range(N)]
INF=10**9
def dfs(cur, a, b, c):
	if cur==N:
		if min(a, b, c)>0:
			return abs(a-A)+abs(b-B)+abs(c-C)-30  
		else:
	 		return INF 
	ret0=dfs(cur+1, a, b, c)
	ret1=dfs(cur+1, a+l[cur], b, c)+10
	ret2=dfs(cur+1, a, b+l[cur], c)+10
	ret3=dfs(cur+1, a, b, c+l[cur])+10
	return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace  std;
typedef long long ll;
int main(){
  ll N;
  cin >> N;
  ll nx = 0; ll ny = 0; ll nt = 0;
  bool ans = true;
  for(int i=0;i<N;i++){
    ll t, x, y;
    cin >> t >> x >> y;
    ll rest = t - nt - (abs(x - nx) + abs(y - ny));
    if(rest < 0 || rest % 2)
      ans = false;
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]
xs = 0
ys = 0
for i in range(N):
    if W - xs <= 0 or H - ys <= 0:
        print(0)
        quit()
    if xya[i][2] == 1:
        xs = max(xs, xya[i][0])
    elif xya[i][2] == 2:
        W = min(W, xya[i][0])
    elif xya[i][2] == 3:
        ys = max(ys, xya[i][1])
    else:
        H = min(H, xya[i][1])
if W - xs <= 0 or H - ys <= 0:
    print(0)
else:
    print((W - xs) * (H - ys))

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

int main(){
	int n;
	cin >> n;
	int countAC = 0;
	int countWA = 0;
	int countTLE = 0;
	int countRE = 0;
	for(int i = 0; i < n; i++){
	string a;
	cin >> a;
	if(a == "AC") countAC++;
	else if(a == "TLE") countTLE++;
	else if(a == "WA") countWA++;
	else countRE++;
	}
	cout << "AC x " << countAC << endl;
	cout << "WA x " << countWA << endl;
	cout << "TLE x " << countTLE << endl;
	cout << "RE x " << countRE << endl;
return 0;
}

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

using Graph = vector<vector<int>>;

ll cnt;

vector<bool> seen;
void dfs(const Graph &G, int v) {
  seen[v] = true;  // v を訪問済にする
  cnt++;

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;  // next_v が探索済だったらスルー
    dfs(G, next_v);              // 再帰的に探索
  }
}

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

  ll ans = 0;
  seen.assign(n, false);  // 全頂点を「未訪問」に初期化
  for (int i = 0; i < n; i++) {
    cnt = 0;
    if (!seen[i]) {
      dfs(G, i);
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23408
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

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

ll solve(ll N, ll K, auto& A){
    for(ll i = 0; i < N; ++i){
        if(A[i] == K)return true;
    }
    
    ll maxValue = A[0], minValue = 0xFFFFFFFFFFFFLL, com = A[0];
    for(ll i = 1; i < N; ++i){
        com = gcdr(com, A[i]);
        maxValue = max(maxValue, A[i]);
    }
    
    if(K % com)return false;
    
    ll diff = maxValue - com;
    
    if(diff < K){
        return false;
    }
    return true;
}

int main(){
    
    ll N, K;
    array<ll, 100005> A;
    
    cin >> N >> K;
    for(ll i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    cout << (solve(N, K, A) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    
    return 0;
}

Measured memory_bytes: 1024
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int s=0, w=1;

	char ch=getchar();

	while(ch<'0' || ch>'9')
	{
		if(ch='-')
		{
			w=-w;
		}

		ch=getchar();
	}

	while(ch>='0' && ch<='9')
	{
		s=(((s*10ll))+(ch-'0'));

		ch=getchar();
	}

	return s;
}

int a[11]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2}; 
int b[11]={0, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5};
int c[11]={0, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4};
int d[3]={0, 1, 51};

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long int n;
	
	cin>>n;
	
	if(n<=10)
	{
		cout<<a[n]<<endl;
	}
	else if(n<=20)
	{
		cout<<b[n-10]<<endl;
	}
	else if(n<=30)
	{
		cout<<c[n-20]<<endl;
	}
	else
	{
		cout<<d[n-30]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
cnt = [0] * (N)

for i in range(N - 1):
    cnt[i + 1] = cnt[i] + (1 if S[i:i + 2] == "AC" else 0)


for i in range(Q):
    l, r = map(int, input().split())
    print(cnt[r - 1] - cnt[l - 1])


Measured memory_bytes: 9540
def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

def factorial(n, mod)
  fs = [1]
  (1..n).each{ |k| fs << (fs[-1] * k) % mod }
  fs
end

def inv_factorial(n, mod)
  fs = [1]
  f = 1
  (1..n).each{ |k|
    f = f * k % mod
    fs << invmod(f, mod)
  }
  fs
end


N,A,B,C = gets.split.map &:to_i
Mod = 10**9 + 7

fs = factorial(2*N+2, Mod) 
is = inv_factorial(2*N+2, Mod)

Q = A+B
InvQ = invmod(Q, Mod)
Inv100 = invmod(100, Mod)
ans = 0
[[A,B],[B,A]].each{ |a,b|
  an = powmod(a, N, Mod)
  bn = 1
  inv100nm = powmod(InvQ, N, Mod)
  (0...N).each{ |m|
    v = fs[N+m-1] * is[N-1] % Mod * is[m] % Mod * an % Mod * bn % Mod * inv100nm % Mod
    ans = (ans + v*(N+m)) % Mod
    bn = bn * b % Mod
    inv100nm = inv100nm * InvQ % Mod
  }
}
p ans * 100 % Mod * invmod(100 - C, Mod) % Mod


Measured memory_bytes: 4988
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    cin >> n >> k;

    vector <ll> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end());

    ll ans = 0;
    for (int i = 0; i < n - k; i++) ans += h[i];

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N, K;
  cin>>N>>K;
  string S; cin>>S;
  vector<int> rec;
  for(int i = 1; i < N; i++) {
    if(S[i-1] != S[i]) rec.push_back(i-1);
  }
  rec.push_back(N);
  //pp(rec,rec.size());                                                                          
  int M	= rec.size();
  int ans = N -	M;
  REP(i,K) {
    if(M > 2) {
      M -= 2;
      ans += 2;
    } else if(M	== 2) {
      M -= 1;
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
import sys
input = sys.stdin.readline

mod = 10**9+7
n, m = map(int, input().split())
l = [0]*n
for _ in range(m):
  l[int(input())-1] = 1

t, s = 1, 0

for i in range(n):
  if l[i]:
    t, s = 0, t
  else:
    t, s = (s+t)%mod, t

print(t)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    
    for(int i=0;i<n;i++){
        if(a[i]%2==1){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
    
    
}
 
   

Measured memory_bytes: 640
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	s = readline() |> chomp
	t = zeros(Int,n)
	dp = zeros(Int,n)
	r = zeros(Int,n+1)
	g = zeros(Int,n+1)
	b = zeros(Int,n+1)
	for i in 1:n
		r[i+1]=r[i]
		g[i+1]=g[i]
		b[i+1]=b[i]
		if s[i]=='R'
			r[i+1]+=1
		elseif s[i]=='G'
			g[i+1]+=1
			t[i]=1
		else
			b[i+1]+=1
			t[i]=2
		end
	end
	for i in 1:n
		if s[i]=='R'
			dp[i]=g[i]*(b[n+1]-b[i+1])+b[i]*(g[n+1]-g[i+1])
			for j in 1:min(i-1,n-i)
				if t[i-j]!=t[i+j]&&t[i-j]!=t[i]&&t[i+j]!=t[i]
					dp[i]-=1
				end
			end
		elseif s[i]=='G'
			dp[i]=r[i]*(b[n+1]-b[i+1])+b[i]*(r[n+1]-r[i+1])
			for j in 1:min(i-1,n-i)
				if t[i-j]!=t[i+j]&&t[i-j]!=t[i]&&t[i+j]!=t[i]
					dp[i]-=1
				end
			end
		else
			dp[i]=r[i]*(g[n+1]-g[i+1])+g[i]*(r[n+1]-r[i+1])
			for j in 1:min(i-1,n-i)
				if t[i-j]!=t[i+j]&&t[i-j]!=t[i]&&t[i+j]!=t[i]
					dp[i]-=1
				end
			end
		end
	end
	println(sum(dp))
end

main()

Measured memory_bytes: 165372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




struct warshall_floyd {
    vector<vector<ll>> d;
    int V;
    warshall_floyd(int v){
        V = v;
        d.assign(V,vector<ll>(V,infi));
        rep(i,V) d[i][i] = 0;
    }
    void solve_d(){
        rep(k,V) rep(i,V) rep(j,V) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
    ll dir(int a, int b){
        return d[a][b];
    }
};





int main()
{
    int N;
    cin >> N;
    warshall_floyd G(N);
    ve<vl> gg(N,vl(N));
    rep(i,N) rep(j,N){
        cin >> gg[i][j];
        G.d[i][j] = gg[i][j];
    }
    G.solve_d();
    rep(i,N) rep(j,N){
        if(gg[i][j] != G.d[i][j]){
            cout << -1 << endl;
            return 0;
        }
    }
    
    ll ans = 0;
    
    rep(i,N){
        reps(j,i+1,N){
            ll a = gg[i][j];
            bool f = false;
            rep(k,N){
                if(k == i || k == j) continue;
                ll b = gg[i][k] + gg[k][j];
                if(a == b) f = true;
            }
            if(!f) ans += a;
            
            
        }
    }
    

    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep0(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;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int N,X;
    cin >> N >> X;
    int input[N];
    rep0(i,N){
        cin >> input[i];
        X-=input[i];
    }
    sort(input,input+N);
    int res = N;
    cout << res+X/input[0] << endl;

}


Measured memory_bytes: 3616
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	ll sum = 0;
	vll A(n);
	rep(i, 0, n)
	cin >> A[i];
	ll dp[n + 1] = {0};

	// rep(i, 1, n)
	// {
	// 	dp[i] = dp[i - 1] + A[i - 1];
	// }


	// revrep(i, 1, n)
	// {
	// 	sum += (A[i]%mod  * dp[i]%mod) % mod;
	// }
	ll suffix_sum = A[n - 1] % mod;
	
	for (ll i = n - 2; i >= 0; i--)
	{

		sum += (suffix_sum % mod * A[i] % mod) % mod;
		sum = sum%mod;
		suffix_sum += A[i] % mod;
		suffix_sum = suffix_sum % mod;
	}

	cout << sum << endl;

	return 0;
}







Measured memory_bytes: 6348
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

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


Measured memory_bytes: 3620
<?php
    list($n, $m) = explode(" ", trim(fgets(STDIN)));
    for($i = 0; $i < $m; $i++){
        $con[$i] = explode(" ", trim(fgets(STDIN)));
    }
    for($i = 0; $i < 1000; $i++){
        $num = str_split($i);
        if(count($num) != $n){
            continue;
        }
        $ok = TRUE;
        for($j = 0; $j < $m; $j++){
            $k = $con[$j][0] - 1;
            if($num[$k] != $con[$j][1]){
                $ok = FALSE;
            }
        }
        if($ok){
            echo $i;
            return;
        }
    }
    echo -1;
?>

Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int a[200000];
int64_t c[200001];

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

    for (int i = 0; i <= n; ++i)
    {
        c[i] = 0;
    }

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

        c[a[i]]++;
    }

    int64_t ans = 0;
    for (int i = 0; i <= n; ++i)
    {
        ans += c[i]*(c[i]-1)/2;
    }

    for (int i = 0; i < n; ++i)
    {
        cout << (ans - c[a[i]] + 1) << "\n";
    }

    return 0;
}

Measured memory_bytes: 4992
import collections


def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    ad = [0] * n
    q = collections.deque([[0, i] for i in range(n)])
    for i in range(10 ** 20):
        fq = collections.defaultdict(list)
        while True:
            if len(q) != 0:
                d, p = q.popleft()
                if d == i:
                    if p not in fq:
                        tp = a[p][ad[p]]
                        if tp not in fq:
                            if p == a[tp][ad[tp]]:
                                fq[tp]
                                fq[p]
                                ad[tp] += 1
                                ad[p] += 1
                                if ad[tp] < n - 1:
                                    q.append([d+1, tp])
                                if ad[p] < n - 1:
                                    q.append([d+1, p])
                else:
                    q.appendleft([d, p])
                    break
            else:
                if sum(ad) == n * (n - 1):
                    print(i + 1)
                else:
                    print(-1)
                exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 70236
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;




int main(void) {
	long long int N, M, mi, distan;
	
	mi = 400000001; 
	cin >> N >> M;
	vector<long long int> a(N), b(N), c(M), d(M);
	for (int i = 0; i < N; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++)cin >> c[i] >> d[i];

	map<long long int, long long int>mp;
	for (long long int i = 0; i < N; i++) {

		for (long long int j = 0; j < M; j++) {
			distan = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			mi = min(mi, distan);

			if (mp[mi] == 0)mp[mi] = j + 1;

		}

		cout << mp[mi] << endl;
		mp.clear();
		mi = 400000001;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

string s;
int N, K;

int main(int argc, char* argv[])
{
    cin >> s;
    cin >> K;
    N = s.length();
    string list[5];

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j <= N; j++) {
            string t = s.substr(i, j - i);
            int k;
            for (k = 4; k >= 0; k--) {
                if (list[k].length() == 0) continue;
                if (list[k] == t) {
                    k = -2;
                    break;
                }
                if (list[k] < t) break;
            }
            k++;
            if (k == -1 || k == 5) continue;
            for (int l = 4; l > k; l--) {
                list[l] = list[l - 1];
            }
            list[k] = t;
        }
    }
    cout << list[K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
import queue

N, M = map(int, input().split())
parent = [-1] * N # -1なら未訪問
adj = [[] for _ in range(N)] # 隣接リスト作成
for i in range(M):
  a, b = map(int, input().split())
  adj[a-1].append(b)
  adj[b-1].append(a)
q = queue.Queue() # 自分の部屋、親の部屋
q.put([1, 0]) # 1の親は0
while not q.empty():
  x, y = q.get()
  if parent[x-1] != -1: # もし自分の部屋が訪問済みなら
    continue
  parent[x-1] = y # 自分の部屋の親yを指定
  for i in adj[x-1]:
    if parent[i-1] == -1:
      q.put([i, x])
print('Yes')
for j in parent[1:]:
  print(j)

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

namespace ABC099 {
	class ABC099_A {
		static void Main(string[] args) {
			var input = int.Parse(Console.ReadLine());
			Console.WriteLine(input < 1000 ? "ABC" : "ABD");
		}
	}
}


Measured memory_bytes: 13140
// Problem : A - Takahashikun, The Strider
// Contest : AtCoder - AtCoder Grand Contest 046
// URL : https://atcoder.jp/contests/agc046/tasks/agc046_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;
    
    n = __gcd(360 , n);
    cout << 360 / n << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #define f(i,l,r) for(int i=l;i<=r;i++)
    #define rf(i,r,l) for(int i=r;i>=l;i--)    

    #define bp __builtin_popcountll
    #define inf 3e18
    
    const int N=1e5+5; 
    const int M=1e9;
    #define pi 3.14159265359
    void solve()
    {
    	int n,m;
    	cin>>n>>m;
    	int sum=0;
    	f(i,1,m)
    	{
    		int t1;
    		cin>>t1;
    		sum+=t1;
    	}
    	int ans=n-sum;
    	if(sum>n)
    	cout<<-1;
    	else
    	cout<<ans;
    }
      signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        for(int tc=1;tc<=t;tc++)
        {
    		// cout<<"Case #"<<tc<<": ";
    		solve();
        }
    }



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    vector< LL > v(n);
    for( int i = 0; i < n; ++i ) cin >> v[i];

    LL s = 0;
    for( int i = 0; i < k; ++i ) {
        s += v[i];

    }
    int l = 0, r = k - 1;
    int mx = s;

    for( int i = k; i < n; ++i ) {
        s -= v[i - k];
        s += v[i];
        if( mx < s ) {
            l = i - k + 1;
            r = i;
            mx = s;

        }
    }

    long double res = 0;
    for( int i = l; i <= r; ++i ) {
        LL tmp = v[i] * (v[i] + 1) / 2;
        res += (long double)tmp / v[i];

    }
    printf("%.10Lf\n", res);

    return 0;
}



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

    class Program
    {
        static void Main(string[] args)
        {
            int ans;
            int[] wab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x, y;
            x = Math.Min(wab[1], wab[2]);
            y = Math.Max(wab[1], wab[2]);
            if (x + wab[0] >= y) { ans = 0; }
            else { ans = y - (x + wab[0]); }
            Console.WriteLine(ans.ToString());
        }
    }



Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {+0,+1,+1,+1,+0,-1,-1,-1};
static const int ty[] = {-1,-1,+0,+1,+1,+1,+0,-1};

char stage[1001][1001];
int cost[1001][1001];
int H,W;

class State {
public:
  int x;
  int y;
  int cost;

  State(int x, int y, int cost){
    this->x = x;
    this->y = y;
    this->cost = cost;
  }

  bool operator<(State s) const {
    return cost < s.cost;
  }

  bool operator>(State s) const {
    return cost > s.cost;
  }
};

bool is_new_vacant_lot(int x, int y,int current_cost){
  if(stage[y][x] == '.') return false;

  int count = 0;
  int strongness = stage[y][x] - '0';

  for(int i = 0; i < 8; i++){
    int dx = x + tx[i];
    int dy = y + ty[i];
    if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
    if(stage[dy][dx] == '.' && current_cost > cost[dy][dx]){
      count++;
    }
  }
  return (count >= strongness);
}

int main(){
  while(~scanf("%d %d",&H,&W)){
    memset(cost,0x3f,sizeof(cost));
    priority_queue<State,vector<State>,greater<State> > que;
    for(int y = 0; y < H; y++){
      char line[1001];
      scanf("%s",line);
      for(int x = 0; x < W; x++){
        stage[y][x] = line[x];
        if(line[x] == '.'){
          que.push(State(x,y,0));
          cost[y][x] = 0;
        }
      }
    }


    int res = 0;
    while(!que.empty()){
      State s = que.top();
      que.pop();
      res = max(s.cost,res);

      for(int i = 0; i < 8; i++){
        int dx = s.x + tx[i];
        int dy = s.y + ty[i];
        if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
        if(cost[dy][dx] <= s.cost + 1) continue;
        if(!is_new_vacant_lot(dx,dy,s.cost + 1)) continue;
        
        stage[dy][dx] = '.';
        cost[dy][dx] = s.cost + 1;
        que.push(State(dx,dy,s.cost + 1));
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 6492
#include<bits/stdc++.h>
using namespace std;
int n,a[500010];
bool work()
{
	int even=0,odd=0;
	for (int i=1;i<=n;i++) {even+=(!(a[i]&1));odd+=(a[i]&1);}
	if (even&1) return true;
	if (odd>1) return false;
	for (int i=1;i<=n;i++) if (a[i]&1)
	{
		if (a[i]==1) return false;
		a[i]--;break;
	}
	int g=a[1];for (int i=2;i<=n;i++) g=__gcd(g,a[i]);
	for (int i=1;i<=n;i++) a[i]/=g;
	return !work();
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	puts(work()?"First":"Second");
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int ans = 0;
  rep(i, n)rep(j, n)rep(k, n) {
    if (i < j && j < k) {
      if (l[i] == l[j] ) continue;
      if (l[i] == l[k] ) continue;
      if (l[k] == l[j] ) continue;
      if ((ll)l[i]+l[j]+l[k] <= max({l[i], l[j], l[k]}) * 2) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int ret = 0;

    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) {
            ret++;
            a[i] /= 2;
        }
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 384
m_list = list()
for k in range(5):
    m = int(input())
    m_list.append(m)
num = int(input())

x_list = list()
count = 0
for i in range(0, len(m_list)-1):
    for j in range(i+1, len(m_list)):
        x_list.append(m_list[j] - m_list[i])

for a in range(len(x_list)):
    if x_list[a] > num:
        count += 1

if count >= 1:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    
    if(N >= 64){
        printf("64\n");
    }else if(N >= 32){
        printf("32\n");
    }else if(N >= 16){
        printf("16\n");
    }else if(N >= 8){
        printf("8\n");
    }else if(N >= 4){
        printf("4\n");
    }else if(N >= 2){
        printf("2\n");
    }else{
        printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	string s;
    cin>>s;
    bool fl=false;
    REP(i,SZ(s)-1){
        if(s[i]==s[i+1]){
            fl=true;
            break;
        } 
    }
    if(fl) OUT("Bad");
    else{
        OUT("Good");
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (char c1 = '0'; c1 <= '9'; c1++) {
		int i = 0;
		while (i <= N - 1 && S[i] != c1) i++;
		if (i > N - 3) continue;
		i++;
		for (char c2 = '0'; c2 <= '9'; c2++) {
			int j = i;
			while (j <= N - 1 && S[j] != c2) j++;
			if (j > N - 2) continue;
			j++;
			for (char c3 = '0'; c3 <= '9'; c3++) {
				int k = j;
				while (k <= N - 1 && S[k] != c3) k++;
				if (k <= N - 1) ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int j;
	int n;
	int count;
	static char num[1000001];
	
	num[2] = 1;
	for (i = 3; i < 1000000; i += 2){
		num[i] = 1;
	}
	for (i = 3; i < 1000; i += 2){
		if (num[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				num[i * j] = 0;
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		count = 0;
		for (i = 2; i <= n; i++){
			if (num[i] == 1){
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 0