akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long int dpjump(int n,int a[],int k)
{
    long long int dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[1]-a[0]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i-j>=1)
        dp[i]=min(abs(a[i-1]-a[i-1-j])+dp[i-j],dp[i]);
        }
    }
    return dp[n];



}
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<dpjump(n,a,k);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX_V = 2000 + 10;

int V;
vector<int> G[MAX_V];
bool used[MAX_V];
int match[MAX_V];

void add_edge(int v,int u){
    G[v].push_back(u);
    G[u].push_back(v);
}

bool dfs(int v){
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i];
        int w = match[u];

        if(w < 0 || (!used[w]&&dfs(w))){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int ret = 0;
    memset(match,-1,sizeof(match));

    for(int v = 0; v < V; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v)) ret++;
        }
    }
    return ret;
}

int main(){
  int N, M, L;
  while(cin >> N >> M >> L && N){
    int d[100][100] = {};
    REP(i, N) REP(j, N) d[i][j] = (i != j ? INF : 0);
    REP(i, M){
      int u, v, c;
      scanf("%d %d %d", &u, &v, &c);
      d[u][v] = d[v][u] = c;
    }
    REP(k, N) REP(i, N) REP(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int p[1000], t[1000];
    REP(i, L){
      scanf("%d %d", &p[i], &t[i]);
    }
    V = 2 * L;
    REP(i, V) G[i].clear();
    REP(i, L) FOR(j, i + 1, L) if(t[i] > t[j]) { swap(t[i], t[j]); swap(p[i], p[j]); }
    REP(i, L) FOR(j, i + 1, L){
      if(t[i] + d[p[i]][p[j]] <= t[j]) add_edge(i, L + j);
    }
    cout << L - bipartite_matching() << endl;
  }
  return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 1;

  rep(i,n) {
    int bai = ans*2;
    int plu = ans+k;
    if (bai <= plu) ans *= 2;
    else ans += k;
  }

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

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    int t;
    REP(i, n) {
        cin >> t;
        if (t < a || t >= b) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#coding:utf-8
N,M=map(int,raw_input().split())
P=[]
for i in range(M):
    a,b=map(int,raw_input().split())
    P.append((a,b))
P.sort()
ans=0
l=-1
r=-1
for a,b in P:
    if r<=a:
        ans+=1
        l=a
        r=b
        continue
    l=a
    r=min(b,r)
print(ans)    



Measured memory_bytes: 19828
while 1:
    n = int(input())
    count = 0
    if n == 0:
        break
    L = [list(map(int,input().split())) for i in range(n+1)]

    for i in range(n):
        if L[i][1] <= L[n][0] and L[i][2] <= L[n][1]  and L[i][3] <= L[n][2] and L[i][1] * 4 + L[i][2] * 9 +L[i][3] * 4 <= L[n][3] :
            print(L[i][0])
            count += 1

    if count == 0:
        print("NA")


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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 1e5 + 5, kD = 12;

int n, m, c[kN], t[kN][kD];
std::vector <int> E[kN];

int main() {
	rd(n, m);
	for(int i = 1; i <= m; ++i) {
		int x, y; rd(x, y);
		E[x].push_back(y); E[y].push_back(x);
	}
	int q; rd(q);
	for(int i = 1; i <= q; ++i) {
		int v, d; rd(v, d, c[i]);
		t[v][d] = i;
	}
	for(int k = 1; k <= 10; ++k) 
		for(int i = 1; i <= n; ++i)
			for(auto v : E[i])
				for(int j = 0; j <= 10 - k; ++j)
					t[v][j] = std::max(t[i][j + 1], t[v][j]);
	for(int i = 1; i <= n; ++i) {
		int x = 0;
		for(int j = 0; j <= 10; ++j) x = std::max(x, t[i][j]);
		printf("%d\n", c[x]);
	}
	return 0;
}

Measured memory_bytes: 11512
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin >>n;
  ll cnt_a=0;
  ll cnt_b=0;
  ll sum_a =0;
  ll sum_b =0;
  ll sign_a = 1;
  ll sign_b = -1;
  for(int i=0;i<n;++i){
    ll t;cin >> t;
    sum_a +=t;
    sum_b +=t;
    if (sum_a * sign_a <= 0){
      cnt_a += abs(sum_a) + 1;
      sum_a = sign_a;
    }
    if (sum_b * sign_b <= 0){
      cnt_b += abs(sum_b) + 1;
      sum_b = sign_b;
    }
    sign_a *=-1;
    sign_b *=-1;
  }
  cout << min(cnt_a,cnt_b) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        
        int n = std.nextInt();
        int[] hs = new int[n];
        for (int i = 0; i < n; i++) {
            hs[i] = std.nextInt();
        }

        int v = 0;
        int e = 0;

        for (int i = 0; i < n; i++) {
            int h = hs[i];
            v += h;
        }

        for (int i = 1; i < n; i++) {
            e += Math.min(hs[i], hs[i - 1]);
        }

        System.out.println(v - e);
    }
}


Measured memory_bytes: 23252
# D
import math
X = int(input())

B = -math.floor(math.pow(X, 0.2))
for b in range(B, 100000):
    tmp = math.pow(X + b ** 5, 0.2)
    if math.floor(math.floor(tmp+1.0e-6) - tmp + 1.0e-6) == 0:
        break
        
tmp = math.floor(tmp + 1.0e-6)
print(tmp, b)

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

struct item {
    int len, nexti, nextj, num;
};

int main() {
    int i,j;
    string s, t;
    cin >> s >> t;
    vector<vector<int>> nexts(s.size()+1, vector<int>(2, s.size()));
    vector<vector<int>> nextt(t.size()+1, vector<int>(2, t.size()));
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '0') {
            for (int j = 0; j <= i; j++) {
                nexts[j][0] = i;
            }
        } else {
            for (int j = 0; j <= i; j++) {
                nexts[j][1] = i;
            }
        }
    }
    for (int i = t.size() - 1; i >= 0; i--) {
        if (t[i] == '0') {
            for (int j = 0; j <= i; j++) {
                nextt[j][0] = i;
            }
        } else {
            for (int j = 0; j <= i; j++) {
                nextt[j][1] = i;
            }
        }
    }
    int m = s.size(), n = t.size();
    vector<vector<item>> dp(m + 1, vector<item>(n + 1));

    dp[m][n]={0, -1, -1, 0};

    for (int i = m; i >= 0; i--) {
        for (int j = n; j >= 0; j--) {

            //if(i==m&&j==n) continue;

            int aa0,ab0,aa1,ab1;

            aa0=nexts[i][0]+1;
            ab0=nextt[j][0]+1;
            aa1=nexts[i][1]+1;
            ab1=nextt[j][1]+1;


            int a0=min(aa0,m);
            int a1=min(aa1,m);
            int b0=min(n,ab0);
            int b1=min(n,ab1);

            int ze=dp[a0][b0].len;
            if(aa0==m+1&&ab0==n+1) ze=0;
            int on=dp[a1][b1].len;
            if(aa1==m+1&&ab1==n+1) on=0;

            if(ze<=on){
                if(aa0==m+1&&ab0==n+1) dp[i][j]={1,-1,-1,0};
                else dp[i][j]={1+ze,a0,b0,0};
                
            }
            else{
                if(aa1==m+1&&ab1==n+1) dp[i][j]={1,-1,-1,1};
                else dp[i][j]={1+on,a1,b1,1};
            }
        }
    }

    int ans=dp[0][0].len;
    int fs=0,ft=0;
    vector<int> v; 
    while(dp[fs][ft].nexti>=0){

        v.push_back(dp[fs][ft].num);
        
        int tfs=fs;
        int tft=ft;
        fs=dp[tfs][tft].nexti;
        ft=dp[tfs][tft].nextj;
    }

    v.push_back(dp[fs][ft].num);


    int cnt=0;
    for(i=0;i<v.size();i++){
       if(v[i]>=0) cnt++;
    }
    for(i=0;i<cnt;i++){
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;

  vector<int> p(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    if (p[i] != i + 1) {
      cnt++;
    }
  }

  cout << (cnt > 2 ? "NO\n" : "YES\n");
  return 0;
}

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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((100 * r + 10 * g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
ll p[2*N]={}, q[N]={}, r[N]={};

int main(){
	int x, y, a, b, c;  scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	REP(i, a) scanf("%lld", p+i+1);
	REP(i, b) scanf("%lld", q+i+1);
	REP(i, c) scanf("%lld", r+i+1);

	sort(p+1, p+a+1, greater<ll>());
	sort(q+1, q+b+1, greater<ll>());
	sort(r+1, r+c+1, greater<ll>());

	REP(i, y) p[1+x+i] = q[1+i];
	sort(p+1, p+x+y+1, greater<ll>());

	REP(i, x+y) DEBUG("%lld ", p[i+1]); DEBUG("\n");
	REP(i, c) DEBUG("%lld ", r[i+1]); DEBUG("\n");

	REP(i, x+y) p[i+1] += p[i];
	REP(i, c) r[i+1] += r[i];

	ll ans = 0;
	REP(i, min(x+y, c) + 1){
		LAR(ans, p[x+y-i] + r[i]);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3200
a = list(map(int, input().split(" ")))
n = a[0]
x = a[1]

d = []

for v in range(n):
    s = int(input())
    d.append(s)
    x -= s
min_d = min(d)
ad_d = x // min_d
ans = n + ad_d
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll
int w,h;

void f(int c[100][100],bool b[100][100],int y,int x){

  if(y<0||x<0||y>h||x>w||!c[y][x]||b[y][x]) return;
  b[y][x]=true;
  f(c,b,y+1,x);
  f(c,b,y-1,x);
  f(c,b,y,x+1);
  f(c,b,y,x-1);
  f(c,b,y+1,x+1);
  f(c,b,y+1,x-1);
  f(c,b,y-1,x+1);
  f(c,b,y-1,x-1);
}



signed main(){
  while(1){
    
    cin>>w>>h;
    if(w==0) break;

    int c[100][100]={};
    rep(i,h){
      rep(j,w){
        cin>>c[i][j];
      }
    }

    bool b[100][100]={};

    int s=0;

    rep(i,h){
      rep(j,w){
        if(c[i][j]&&!b[i][j]){
          f(c,b,i,j);
          s++;
        }
      }
    }

    cout<<s<<endl;
  }
}


Measured memory_bytes: 3396
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1};
vector<int> y4 = {1, 0, -1, 0};
vector<int> x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


struct edge {int to, cost; edge(int to,int cost) : to(to), cost(cost){}};
typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号

int N; // 頂点数
const int MAX_N = 100000;
vector<vector<edge>> G1(MAX_N), G2(MAX_N);
vector<ll> d1(MAX_N), d2(MAX_N); // 頂点sからの最短距離

void dijkstra(vector<vector<edge>> &G, vector<ll> &d, int s){
  priority_queue<P, vector<P>, greater<P> > que; // 小さい順に取り出す
  rep(i, N) d[i] = INF;
  d[s] = 0;
  que.push(P(0, s));

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

int main() {
  cin >>N;
  int M,s,t; cin >>M >>s >>t; s--; t--;
  ll money = 1000000000000000;
  rep(i, M){
    int u,v; cin >>u >>v; u--; v--;
    int a,b; cin >>a >>b;
    G1[u].push_back(edge(v,a));
    G1[v].push_back(edge(u,a));
    G2[u].push_back(edge(v,b));
    G2[v].push_back(edge(u,b));
  }
  dijkstra(G1,d1,s); // 都市sからどこかの両替都市までの最短コスト(円)
  dijkstra(G2,d2,t); // 都市tからどこかの両替都市までの最短コスト(スヌーク)
  // 都市sを出発し都市aで両替を行って都市tへ移動するとすると最短合計コストはd1[a]+d2[a]となる
  // d1[i]+d2[i] = d3[i]としておく
  /* 都市を1-indexedでなく0-indexedとする
  0年後には都市0以降全ての都市で両替が行える...min(d[0],d[1],d[2]...d[n-1])
  1年後には都市1以降全ての都市で両替が行える...min(d[1],d[2]...d[n-1])
  n-1年後には都市n-1でのみ両替が行える...d[n-1]
  */
  vector<ll> d(N);
  rep(i, N) d[i] = d1[i]+d2[i];
  vector<ll> res(N);
  ll ans = INF;
  for (int i=N-1; i>=0; i--){
    chmin(ans, d[i]);
    res[i] = ans;
  }
  rep(i, N){
    cout <<money - res[i] <<endl;
  }
}



Measured memory_bytes: 17084
n = int(input())
h = list(map(int, input().split()))

dp = [0]

for i in range(1,n):
  dp.append(dp[i-1] + abs(h[i] - h[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[n-1])

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

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    vector<int> p(M);

    for (int i = 0; i < M; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            int val;
            cin >> val;
            s[i].push_back(val);
        }
    }

    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    
    vector<int> swStat(N,0);
    ll ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        for (int j = 0; j < N; j++)
        {
            swStat[j] = (i >> j) & 1;
        }
        
        bool allOn = true;
        for (int i = 0; i < M; i++)
        {
            int ons = 0;
            for (int j = 0; j < k[i]; j++)
            {
                ons += swStat[s[i][j]-1];
            }
            if(p[i] != (ons % 2)) {
                allOn = false;
                break;
            }
        }

        if(allOn) ans++;
    }
    
    cout << ans << endl;

    return 0;
}


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


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}




// Graph------------------------------------------------------------------------
int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
// Never GIVE UP !!!!



	int x, n;
	cin >> x >> n;
	mk(arr, n, int);
	set<int> h;
	for (int i = 0; i < n; i++)
	{	cin >> arr[i];
		h.insert(arr[i]);
	}

	sort(arr, arr + n);
	if (h.count(x) == 0)
		cout << x << endl;
	else
	{
		int mn = INT_MAX;
		int ans;
		for (int i = 0; i <= 101; i++)
		{
			if (h.count(i) == 0 && abs(x - i) < mn)
			{
				mn = abs(x - i);
				ans =	i;
			}
		}
		cout << ans << endl;
	}





}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    string S[H]; rep(i, H) cin >> S[i];
    char grid[H+2][W+2]; rep(i, H+2) rep(j, W+2) grid[i][j] = '.';
    rep(i, H) rep(j, W) grid[i+1][j+1] = S[i][j];
    int x = 1, y = 1;
    bool visited[H+2][W+2]; rep(i, H+2) rep(j, W+2) visited[i][j] = false;
    while(true){
        visited[x][y] = true;
        if(grid[x+1][y] == '#'){
            x++;
        }
        else if(grid[x][y+1] == '#'){
            y++;
        }
        else break;
    }
    bool ok = true;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(grid[i][j] == '#' && !visited[i][j]) ok = false;
        }
    }
    if(ok) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;
	ll ar[n+1],s=0;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		s+=ar[i];
	}

	ll c=0;
	for(i=1;i<=n;i++){
		if(ar[i]*4*m>=s){
			c++;
		}
	}
	if(c>=m){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
i = bisect.bisect_left(a,0)
if i % 2 == 1:
    i -= 1
for j in range(i):
    a[j] *= -1
if i == n-1 or i == n:
    print(sum(a))
else:
    if a[i] + a[i+1] >= 0:
        print(sum(a))
    else:
        a[i] *= -1
        a[i+1] *= -1
        print(sum(a))

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

int main()
{ //A
/*
    int a,b,c;
    cin>>a>>b>>c;
    int t,u;
    t=a;
    a=b;
    b=t;

    u=a;
    a=c;
    c=u;

    cout<<a<<" "<<b<<" "<<c<<endl;
*/
//B
int n,m;cin>>n>>m;
vector<int> a(n);
int sum=0;
rep(i,0,n) {
    cin>>a[i];
    sum+=a[i];
}
sort(a.begin(),a.end());
reverse(a.begin(),a.end());

//cout<<a[m-1]<<endl;
//cout<<1/4.0/(float)m<<endl;
if(a[m-1]<sum*1/4.0/(float)m) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
/*
問題文
とある世界では、今日は 12月 D日です。
D=25なら Christmas, D=24なら Christmas Eve, D=23なら Christmas Eve Eve, D=22なら Christmas Eve Eve Eve と出力
制約
22<=D<=25
Dは整数
*/
		System.out.print("Christmas");
		int D = sc.nextInt();
		for (int i = 0; i < 25 - D; i++){
			System.out.print(" Eve");
		}
	}
}


Measured memory_bytes: 21076
import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] = A[i]/2
            else:
                print(t)
                sys.exit()
        t += 1

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
long long n,a[405],s[405][405],res;
main()
{
    cin>>n;
    for(long long i=1; i<=n; i++)
        {
            cin>>a[i];
            a[i]=a[i-1]+a[i];
        }
        for(long long i=1;i<=n;i++)
            for(long long j=1;j<=n;j++)
            s[i][j]=100000000000000000;
        for(long long i=1;i<=n;i++)
            s[i][i]=0;
        for(long long l=1;l<=n;l++)
            for(long long i=1;i<=n-l+1;i++)
            for(long long k=1;k<l;k++)
        {
            s[i][i+l-1]=min(s[i][i+l-1],s[i][i+k-1]+s[i+k][i+l-1]+a[i+l-1]-a[i-1]);
        }
        cout<<s[1][n];

}


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

int main(){
  ll n,k,now=1; cin >>n >>k;
  int a[200001],b[200001];
  rep(i,n) cin >>b[i];
  for(;k>0;k/=2){
    if(k%2) now=b[now];
    rep(i,n) a[i]=b[b[i]];
    rep(i,n) b[i]=a[i];
  }
  cout << now << endl;
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int H, W;cin >> H >> W;
    int h, w;cin >> h >> w;
    cout << H*W - h*W - w*H + h*w << endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of Allah

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define mp make_pair
#define pb push_back

const ll MAX = 1e2 + 5, mod = 1e9 + 7, inf = 1e17 + 100;

string s;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	cin >> s;
	int l = 0, r = s.size()-1, res = 0;
	while (l < r)
	{
		if (s[l] == 'x' && s[r] != 'x')
			res ++, l ++;
		else if (s[l] != 'x' && s[r] == 'x')
			res ++, r --;
		else if (s[l] == s[r])
			r --, l ++;
		else
			return cout << -1 << endl, 0;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
n=int(input())
if n < 10:
    print(n)
elif 10 <= n < 100:
    print(9)
elif 100 <= n < 1000:
    print(9 + n - 99)
elif 1000 <= n < 10000:
    print(909)
elif 10000 <= n < 100000:
    print(909 + n - 9999)
else:
    print(90909)

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

int main() {
  int n;
  cin >> n;
  double sum;
  rep(i, n) {
    int a;
    cin >> a;
    sum += 1.0 / a;
  }
  double ans = 1/sum;
  cout << fixed << setprecision(6);
  cout << ans;
}


Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    M,D = inputMap()
    ans = 0
    
    for i in range(2,M+1):
        for j in range(10,D+1):
            tmp = str(j)
            
            d1 = int(tmp[1])
            d10 = int(tmp[0])
            
            if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
                #print("{}月 {} {}".format(i,d10,d1))
                ans += 1
                
    print(ans)
    
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 41712
from sys import stdin,stdout
I = lambda : map(int,stdin.readline().split())
P = lambda x: stdout.write(str(x)+" ") 

n = input()
d = [0]*n
h = I()
d[1] = abs(h[0] - h[1])
for i in range(2,n):
	d[i] = min(d[i-1] + abs(h[i-1] - h[i]),d[i-2] + abs(h[i-2] - h[i]))
print d[n-1]

Measured memory_bytes: 12172
R=range;N,K=map(int,input().split());Q=R(N+1);d=[[0]*2**i for i in Q];f=[[0]*2**i for i in Q]
for i in Q:
 for j,c in enumerate(input()):d[i][j]=int(c)
for i in R(1,N+1):
 for j in R(1<<i):
  t=j>>i-1&1;r=0
  while r<i and j>>i-1-r&1==t:r+=1
  f[i][j]=r
for i in Q:
 for k in R(i+1,N+1):
  z=k-i;m=(1<<z)-1
  for j in R(1<<k):
   d[i][j>>z]+=d[k][j];r=f[z][j&m]
   if r!=z:d[k-r][j>>z<<z-r|j&(1<<z-r)-1]+=d[k][j]
 for j in R(1<<i):
  if d[i][j]>=K:I=i;J=j;break
print(''if I==J==0else bin(J)[2:].zfill(I))

Measured memory_bytes: 100828
import math
N = int(input())
data =[]
point = 0
for i in range(N):
    data.append([int(j) for j in input().split()])
#print(data)
    
for i in range(N):
    for j in range(i+1,N):
        point+= math.sqrt((data[i][0]-data[j][0])**2 + (data[i][1]-data[j][1])**2)
        #print(point)

print(point*2/N)

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;

	int ak[200010];

	{
		int at[200010];
		at[n] = n;
		for(int i = n-1;i >= 0;i--){
			at[i] = (s[i] == 'o' ? i : at[i+1]); 
		}

		int idx = at[0];
		for(int i = 0;i < k;i++){
			ak[i] = idx+1;
			idx = at[idx+c+1];
		}
	}

	reverse(s.begin(), s.end());

	int bk[200010];

	{
		int at[200010];
		at[n] = n;
		for(int i = n-1;i >= 0;i--){
			at[i] = (s[i] == 'o' ? i : at[i+1]); 
		}

		int idx = at[0];
		for(int i = 0;i < k;i++){
			bk[k-i-1] = n-idx;
			idx = at[idx+c+1];
		}
	}

	for(int i = 0;i < k;i++){
		if(ak[i] == bk[i]){
			cout << ak[i] << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 6532
from collections import deque
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    L = [[0] for _ in range(n)]
    for _ in [0] * m:
        a, b = map(int, input().split())
        L[a-1].append(b-1)
        L[b-1].append(a-1)
    L[0][0] = 1
    ans = [0] * n
    dq = deque([0])
    while dq:
        t = dq.popleft()
        for i in range(1, len(L[t])):
            next = L[t][i]
            if ans[next] != 0:
                continue
            ans[next] = t + 1
            dq.append(next)
        else:
            L[t][0] = 1
    print('Yes')
    print(*ans[1:], sep='\n')

main()


Measured memory_bytes: 41480
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
    int K, S, ans = 0, temp = 0;

    cin >> K >> S;

    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            if ((i + j) <= S && (S - (i + j)) <= K)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




i64 n, a[10101], b[10101];
P d[10101];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		d[i] = P(a[i]-b[i], i);
	}
	sort(d,d+n);
	
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		int I = d[i].second;
		if(a[I] == b[I]) continue;
		if(a[I] > b[I]){
			cnt -= a[I]-b[I];
			if(cnt >= 0) continue;
			cout << "No" << endl;
			return;
		}
		cnt += (b[I]-a[I])/2;
	}
	cout << "Yes" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int main(){
  ll x,k,d;
  
  cin>>x>>k>>d;
  
  ll a_x=abs(x);
  ll c=a_x/d;
  
  ll ans=-1;
  
  if(c>=k){
    ans=a_x-d*k;
  }
  else{
    int temp=(k-c)%2;
    if(temp==0){
      ans=a_x-d*c;
    }
    else{
      ans=abs(a_x-d*c-d);
    }
  }
  
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 3628
/*input
3 20
2 80
9 1
16 120
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll n,c;
pll p[maxn];
ll ans=0;

ll QAQ[maxn];
ll OAO[maxn];

void gogo(){
	//REP(i,n+1) cout<<p[i]<<" \n"[i==n];
	QAQ[0]=0;
	REP(i,n+1) if(i) QAQ[i]=QAQ[i-1]-2*(p[i].F-p[i-1].F)+p[i].S;
	OAO[0]=0;
	for(int i=1;i<=n;i++){
		if(i==1) OAO[i]=p[n].F+p[n].S-c;
		else OAO[i]=OAO[i-1]-(p[n-i+2].F-p[n-i+1].F)+p[n-i+1].S;
	}
	//REP(i,n+1) cout<<OAO[i]<<" \n"[i==n];
	//REP(i,n+1) cout<<QAQ[i]<<" \n"[i==n];
	for(int i=1;i<=n;i++) OAO[i]=max(OAO[i],OAO[i-1]);
	for(int i=1;i<=n;i++) QAQ[i]=max(QAQ[i],QAQ[i-1]);
	for(int i=0;i<=n;i++) ans=max(ans,QAQ[i]+OAO[n-i]);
}

int main()
{
	//IOS;
	cin>>n>>c;
	REP(i,n) cin>>p[i].F>>p[i].S;
	p[n]=MP(0,0);
	sort(p,p+n+1);

	gogo();
	REP(i,n) p[i+1].F=c-p[i+1].F;
	sort(p,p+n+1);
	gogo();
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 7168
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

struct UinonFindTree {
private:
  vector<LL> UFT;
public:
  UinonFindTree(LL N) {
    UFT.resize(N);
    for (LL i = 0; i < N; i++) {
      UFT[i] = -1; // 0未満は親である
    }
  }

  LL root(LL i) { // 親を返す
    if (UFT[i] < 0) { // 0未満は親である
      return i;
    }
    else {
      LL j = root(UFT[i]);
      UFT[i] = j;
      return j;
    }
  }

  bool same(LL i, LL j) { // 同じ親であるか
    return (root(i) == root(j));
  }

  void unite(LL i, LL j) // 統合する
  {
    LL root_i = root(i);
    LL root_j = root(j);
    if (root_i != root_j) {
      if (size(root_i) < size(root_j)) { // サイズが大きい方を親とする
        swap(root_i, root_j);
      }
      UFT[root_i] += UFT[root_j];
      UFT[root_j] = root_i;
    }
  }

  LL size(LL i) { // 属する要素数を返す
    return -UFT[root(i)];
  }

  LL get_root_num() { // 親の個数を返す
    set<LL> roots;
    for (LL i = 0; i < UFT.size(); ++i) {
      roots.insert(root(i));
    }
    return (LL)roots.size();
  }

  map<LL, vector<LL>> get_root_child() {
    map<LL, vector<LL>> a;
    for (LL i = 0; i < UFT.size(); ++i) {
      LL j = root(i);
      a[j].push_back(i);
    }
    return a;
  }

  void print() { // 親を表示
    for (LL i = 0; i < UFT.size(); ++i) {
      cerr << root(i) << " ";
    }
    cerr << endl;
  }
};


void func() {

  LL N, M;
  cin >> N >> M;
  UinonFindTree uft(N);

  REP(i, M){
    LL x, y, z;
    cin >> x;
    cin >> y;
    cin >> z;
    x--;
    y--;
    uft.unite(x, y);
  }
  cout << uft.get_root_num();
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;
long long N, S[105];

int main() {
  cin>>N;
  long long sumd = 0, sum = 0;
  REP(i,0,N){
    cin>>S[i];
  }

  sort(S,S+N);
  RREP(i,0,N){
    long long  tsumd = sumd + S[i];
    long long  tsum = sum + S[i];
    if(tsumd % 10 == 0) sumd = max(sumd, tsumd);
    if(tsum % 10 == 0) sumd = max(sumd, tsum);
    if(tsumd % 10 != 0) sum = max(sum, tsumd);
    if(tsum % 10 != 0) sum = max(sum, tsum);
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll K;
  cin >> K;
  ll ans = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        ans += euclidean_gcd(euclidean_gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
_, k = gets.chomp.split(' ').map(&:to_i); sum = 0; max = 0; arr = []; s = gets.chomp; (s.each_char.chunk {|x| x}.to_a + [["1", []]]).each{|key, a| arr << a.size; sum += a.size; sum -= arr[arr.size - (k * 2 + 2)] if arr.size > k * 2 + 1; max = [sum, max].max if key == '1' }; puts max

Measured memory_bytes: 26492
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
      int a[3];
      cin >> a[0] >> a[1] >> a[2];
      sort(a, a + 3);
      if(a[0] == 5 && a[1] == 5 && a[2] == 7)
        cout<<"YES\n";
      else cout<<"NO\n";
      return 0;
    }

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

int64_t calc(int64_t x) {
    return x * x;
}

int main() {
    int N;
    std::cin >> N;
    
    if (N==1)
        std::cout << 1 << std::endl;
    
    for (int64_t i=N/2; i>=1; i--) {
        if (calc(i) <= N) {
            std::cout << i*i << std::endl;
            break;
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+2);
  rep(i,n) cin >> a[i+1];

  vector<int> d(n+1), d2(n);
  int v = 0;
  rep(i,n+1) v += d[i] = abs(a[i]-a[i+1]);
  rep(i,n) d2[i] = abs(a[i]-a[i+2]);

  rep(i,n) cout << v-d[i]-d[i+1]+d2[i] << endl;
}


Measured memory_bytes: 2432
n,m,q = (int(i) for i in input().split())
x = [[0 for i in range(n)] for i in range(n+1)]
for _ in range(m):
	l,r = (int(i) for i in input().split())
	x[0][r-1]+=1
	x[l][r-1]-=1
for i in range(n+1):
	for j in range(1,n): x[i][j]+=x[i][j-1]
for i in range(n):
	for j in range(1,n+1): x[j][i]+=x[j-1][i]
for _ in range(q):
	p,q = (int(i) for i in input().split())
	print(x[p-1][q-1])

Measured memory_bytes: 11256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int A = in.nextInt();
        int B = in.nextInt();
        int K = in.nextInt();

        int smallest[] = new int[K];
        int largest[] = new int[K];
        ArrayList<Integer> combined = new ArrayList<Integer>();


        for (int i = 0; i < K; i++) {
            smallest[i] = A + i;
        }
        for (int i = 0; i < K; i++) {
            largest[i] = B - i;
        }

        for (int i = 0; i < smallest.length; i++) {
            combined.add(smallest[i]);
        }
        for (int i = 0; i < largest.length; i++) {
            combined.add(largest[i]);
        }
        
        Set<Integer> hs = new HashSet<>();
        hs.addAll(combined);
        combined.clear();
        combined.addAll(hs);
        Collections.sort(combined);
        for (int i = 0; i < combined.size(); i++) {
            if (combined.get(i) >= A && combined.get(i) <= B) {
                System.out.println(combined.get(i));
            }
        }
    }


    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 21332
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>


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

  int h, w;
  std::cin >> h >> w;
  std::vector<std::string> matrix;
  for (int i = 0; i < h; i++) {
    std::string s;
    std::cin >> s;
    if (s.find('#') != std::string::npos) {
      matrix.push_back(std::move(s));
    }
  }

  for (int i = w - 1; i != -1; i--) {
    auto isIgnore = true;
    for (int j = 0, jm = static_cast<int>(matrix.size()); j < jm; j++) {
      if (matrix[j][i] == '#') {
        isIgnore = false;
        break;
      }
    }
    if (isIgnore) {
      for (int j = 0, jm = static_cast<int>(matrix.size()); j < jm; j++) {
        matrix[j].erase(i, 1);
      }
    }
  }

  for (const auto& row : matrix) {
    std::cout << row << std::endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int n ;
    cin >> n ;
    vector < ll> a(n) ;
    for( int i = 0 ; i < n ; i++) cin >> a[i] ;
    int f = 1 ;
    ll sum = 0 ;
    for( int i = 0 ; i < n ; i++){
        if(f==1)
            sum += 2*a[i] ;
        else
            sum -= 2*a[i] ;
        f ^= 1 ;
    }
    vector < ll > ans(n);
    ans[0] = sum / 2 ;
    for( int i = 1 ; i < n  ; i++){
        ans[i] = 2*a[i-1]-ans[i-1];
    }
    for( int i = 0 ; i < n ; i++) cout << ans[i] << " " ;


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1 ;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 2944
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(103)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i] = 1

for i in range(0, 102):
    temp_abs = abs(x-i)
    if n_abs > temp_abs and p_list[i] != 1:
        n_abs = temp_abs
        ans = i

print(ans)


Measured memory_bytes: 9076
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int X;

  std::cin >> X;

  bool valid[111111];

  memset(valid, 0, sizeof(valid));

  valid[0] = 1;

  for (int i = 0; i < X; i ++)
    if (valid[i])
      for (int k = 0; k <= 5; k ++) {
        int ii = i + 100 + k;
        
        if (ii == X) {
          std::cout << 1 << std::endl;
        
          return 0;
        }

        valid[ii] = true;
      }

  std::cout << 0 << std::endl;

  return 0;
}


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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var res = 0;

            var items = Console.ReadLine().Split(' ');

            var num1 = int.Parse(items[0]);
            var num2 = int.Parse(items[1]);

            for (int i = 0; i < 2; i++)
            {
                if (num1 > num2)
                {
                    res += num1;
                    num1--;
                }
                else
                {
                    res += num2;
                    num2--;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140