akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;

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

int n, m;
int s, g;
const double INF = 1e10;

struct edge {
    int to;
    int dist;
    int limit;
    edge() {}
    edge(int t, int d, int c) : to(t), dist(d), limit(c) {}
};

struct Node {
    int cur;
    int par;
    int v;
    double time;
    Node() {}
    Node(int a, int b, int c, double t) : cur(a), par(b), v(c), time(t) {}
};

bool operator<(const Node& lhs, const Node& rhs) {
    return lhs.time < rhs.time;
}
bool operator>(const Node& lhs, const Node& rhs) {
    return lhs.time > rhs.time;
}

vector<edge> G[32];

double solve(int s, int t) {
    double d[32][32][32];
    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
            for (int k = 0; k < 32; k++) {
                d[i][j][k] = INF;
            }
        }
    }
    d[s][0][0] = 0;
    priority_queue<Node, vector<Node>, greater<Node> > que;
    que.push(Node(s, 0, 0, 0));
    while (!que.empty()) {
        Node node = que.top(); que.pop();
        //cout << node.cur << "\t" << node.par << "\t" << node.v << "\t" << node.time << endl;
        if (node.cur == t && node.v == 1) return node.time;
        if (d[node.cur][node.par][node.v] < node.time) continue;
        for (int i = 0; i < G[node.cur].size(); i++) {
            edge e = G[node.cur][i];
            if (e.to == node.par) continue;
            for (int k = -1; k <= 1; k++) {
                int nv = node.v+k;
                if (nv <= 0) continue;
                if (nv > e.limit) break;
                double t = node.time + (1.0 * e.dist) / nv;
                if (t < d[e.to][node.cur][nv]) {
                    d[e.to][node.cur][nv] = t;
                    que.push(Node(e.to, node.cur, nv, t));
                }
            }
        }
    }
    return INF;
}

int main() {
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        cin >> s >> g;
        for (int i = 0; i < 32; i++) G[i].clear();
        for (int i = 0; i < m; i++) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            edge e(y, d, c);
            G[x].push_back(e);
            e.to = x;
            G[y].push_back(e);
        }
        double ans = solve(s, g);
        if (ans >= INF) cout << "unreachable" << endl;
        else printf("%.10lf\n", ans);
    }
}

Measured memory_bytes: 2000
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int g(long long x) {
  string s = to_string(x);
  int sum = 0;
  for (int i = 0; i < s.size(); i++)
    sum += s[i] - '0';
  return sum;
}
bool f(long long x, int k) { return x <= ((long long)pow(10, k)) * g(x); }
long long make(long long x, long long y) {
  return x * ((long long)pow(10, y)) + ((long long)pow(10, y) - 1);
}
int main() {
  int n;
  cin >> n;
  set<long long> s;
  for (int i = 0; i < 15; i++) {
    for (int j = 1; f(make(j, i), i); j++) {
      if (make(j, i) > 1000000000000000ll || make(j, i) < 0)
        break;
      s.insert(make(j, i));
    }
  }
  auto it = s.begin();
  for (int i = 0; i < n && it != s.end(); i++) {
    cout << *it << endl;
    it++;
  }

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd

n=int(input())
a=[int(i) for i in input().split()]
a1=[a[0]]
for i in range(1,n-1):
    a1.append(gcd(a1[-1],a[i]))
a2=[a[-1]]
for i in range(n-2,0,-1):
    a2.append(gcd(a2[-1],a[i]))
m=[]
for i in range(n-2):
    m.append(gcd(a1[i],a2[-i-2]))
m.append(a1[-1])
m.append(a2[-1])
print(max(m))
#print(a1)
#print(a2)
#print(m)


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

using namespace std;
typedef long long int ll;

template <typename T>
void print(T vec) { for(auto i : vec) cout<<i<<" ";}
template <typename T>
void print2D(T matrix) {for(auto vec:matrix) {print(vec);cout<<'\n';}}

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

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    for(int L = n-1; L >= 0; L--) {
        for(int R = L; R<n;R++) {
            if(L==R) dp[L][R] = A[L];
            else{
                dp[L][R] = max(A[L] - dp[L+1][R], A[R] - dp[L][R-1]);
            }
        }
    }
    //print2D(dp);
    //for(auto i : A) cout<<i<<" ";
    cout<<dp[0][n-1]<<'\n';
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int tmp = a * 100 + b * 10 + c;
  cout << (tmp%4==0 ? "YES" : "NO");
  
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int x,y;
int g[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
int main(){
    cin>>x>>y;
    if(g[x]==g[y])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<string> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}


	vector<vector<int> > L(N, vector<int>(M, 0));
	vector<vector<int> > R(N, vector<int>(M, 0));
	vector<vector<int> > U(N, vector<int>(M, 0));
	vector<vector<int> > D(N, vector<int>(M, 0));


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (A[i][j] == '#') {
				L[i][j] = -1;
			}
			else {
				if (j == 0) {
					L[i][j] = 0;
				}
				else {
					L[i][j] = L[i][j - 1] + 1;
				}
			}
		}

		for (int j = M - 1; j >= 0; j--) {
			if (A[i][j] == '#') {
				R[i][j] = -1;
			}
			else {
				if (j == M - 1) {
					R[i][j] = 0;
				}
				else {
					R[i][j] = R[i][j + 1] + 1;
				}
			}
		}
	}

	for (int j = 0; j < M; j++) {
		for (int i = 0; i < N; i++) {
			if (A[i][j] == '#') {
				U[i][j] = -1;
			}
			else {
				if (i == 0) {
					U[i][j] = 0;
				}
				else {
					U[i][j] = U[i - 1][j] + 1;
				}
			}
		}

		for (int i = N - 1; i >= 0; i--) {
			if (A[i][j] == '#') {
				D[i][j] = -1;
			}
			else {
				if (i == N - 1) {
					D[i][j] = 0;
				}
				else {
					D[i][j] = D[i + 1][j] + 1;
				}
			}
		}
	}


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (A[i][j] == '.') {
				res = max(res, 1 + L[i][j] + R[i][j] + D[i][j] + U[i][j]);
			}
		}
	}

	cout << res << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    for(int i = 0; i < n; i++){
        auto iter_1 = lower_bound(a.begin(), a.end(), b[i]);
        ll index_1 = iter_1 - a.begin();
        auto iter_2 = upper_bound(c.begin(), c.end(), b[i]);
        ll index_2 = c.end() - iter_2;
        ans += index_1*index_2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int n = sca.nextInt();
		String ans = "No";
		while(n != 0) {
			if(n % 10 == 7) {
				ans = "Yes";
			}
			n = n / 10;
		}
		System.out.println(ans);

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 35760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++){
        if(s[i-1]=='A' && s[i]=='C'){
            cout<<"Yes"<<"\n";
            return 0;
        }
    }
    cout<<"No"<<"\n";

}

Measured memory_bytes: 256
#include <cstdio>
#define LARGE_VALUE 2000000000
int S[500005];
int left_sub_S[250005], right_sub_S[250005];
int count = 0;
void merge(int left, int right, int mid)
{
    int n_1 = mid - left, n_2 = right - mid;
    for (int i = 0; i < n_1; i++)
        left_sub_S[i] = S[left + i];
    left_sub_S[n_1] = LARGE_VALUE;
    for (int i = 0; i < n_2; i++)
        right_sub_S[i] = S[mid + i];
    right_sub_S[n_2] = LARGE_VALUE;
    int j = 0, k = 0;
    for (int i = 0; i < n_1 + n_2; i++)
    {
        count++;
        if (left_sub_S[j] >= right_sub_S[k])
        {
            S[left + i] = right_sub_S[k];
            k++;
        }
        else
        {
            S[left + i] = left_sub_S[j];
            j++;
        }
    }
}

void mergeSort(int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, right, mid);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &S[i]);
    }
    mergeSort(0, n);
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", S[i]);
    }
    printf("%d\n", S[n - 1]);
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 6476
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 1010;
int n;
vi ans;
int x[N], y[N];
void gao(int x, int y) {
	vector<char> ret;
	for(int i = sz(ans) - 1; ~i; i--) {
		if(abs(x) > abs(y)) {
			ret.pb(x > 0 ? 'R' : 'L');
			x += (x > 0) ? -ans[i] : ans[i];
		} else {
			ret.pb(y > 0 ? 'U' : 'D');
			y += (y > 0) ? -ans[i] : ans[i]; 
		}
	}
	reverse(all(ret));
	for(auto & ch : ret)
		putchar(ch);
	puts("");
}
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d%d", x + i, y + i);
	rep(i, 1, n) if(abs(x[i] + y[i]) % 2 != abs(x[i - 1] + y[i - 1]) % 2) {
		puts("-1");
		return 0;
	}
	if(abs(x[0] + y[0]) % 2) {
		rep(i, 0, 31)
			ans.pb(1 << i);	
	} else {
		ans.pb(1);
		rep(i, 0, 31)
			ans.pb(1 << i);
	}
	printf("%d\n", sz(ans));
	rep(i, 0, sz(ans)) printf("%d%c", ans[i], " \n"[i + 1 == sz(ans)]);
	rep(i, 0, n)
		gao(x[i], y[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table.at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n, r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n) {
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    string w;
    cin >> w;
    bool f = true;
    sort(w.begin(), w.end());
    if (w.size() % 2 == 1) {
        f = false;
    }
    for (int i = 1; i <= w.size(); i+=2) {
        if (w[i - 1] != w[i]) {
            f = false;
        }
    }
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())

L = []
R = []
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

L.sort()
R.sort()

if L[-1] > R[0]:
    print(0)
else:
    print(R[0] - L[-1] + 1)


Measured memory_bytes: 11404
<?php
list($h,$w)=explode(" ",trim(fgets(STDIN)));
$ans=array_fill(0,$h+1,array_fill(0,$w+1,100000));
$ans[0][1]=0;
$map[]=array_fill(0,$w+1,0);
$i=1;
while($i<=$h){
  $s=trim(fgets(STDIN));
  $map[$i][]=0;
  $j=1;
  while($j<=$w){
    ($s[$j-1]==".")?$map[$i][$j]=0:$map[$i][$j]=1;
    $ans[$i][$j]=min($ans[$i-1][$j]+abs($map[$i-1][$j]-$map[$i][$j]),$ans[$i][$j-1]+abs($map[$i][$j-1]-$map[$i][$j]));
    ++$j;
  }
  ++$i;
}
echo ceil($ans[$h][$w]/2);

Measured memory_bytes: 6648
#include <iostream>
#include <map>
using namespace std;
int V[100005];
int N;
map<int,int> fr;
int rez;
int main() {
    cin >> N;
    for(int i = 1;i <= N;i++){
       cin >> V[i];
       fr[V[i]]++;
    }
    for(auto it:fr){
       if(it.first <= it.second){
          rez += it.second - it.first;
          it.second = it.first;
       }
       else {
          rez += it.second;
          it.second = 0;
       }
    }
    cout << rez;
    return 0;
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 305;

ll n, a[3];
double dp[N][N][N];

double solve(int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0)
        return 0;
    if (a == 0 && b == 0 && c == 0)
        return 0;
    double& ret = dp[a][b][c];
    if (ret == ret)
        return ret;
    ll cur = a  + b + c;
    ret = solve(a, b + 1, c - 1) * (1.0 * c) / cur + 
          solve(a + 1, b - 1, c) * (1.0 * b) / cur + 
          solve(a - 1, b, c) * (1.0 * a) / cur + 
          1.0 * n / cur;
    return ret;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

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

    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(15);
    cout << solve(a[0], a[1], a[2]) << endl;
}

Measured memory_bytes: 221952
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, l;
  cin >> n >> l;
  int sum = n * l + ((1 + n) * n / 2) - n;
  if (l >= 0) {
    cout << sum - l << "\n";
  } else {
    int num = min(abs(l), n - 1);
    cout << sum - (l + num) << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int R = sc.nextInt();
        int G = sc.nextInt();
        int B = sc.nextInt();
        int N = sc.nextInt();

        int ans = 0;

        for(int i=0;i< N / R+1;i++){
            for(int j=0; j < N / G+1;j++){
                if(i*R + j*G > N){
                    break;
                }
                if((N - i*R - j*G) % B == 0){
                    ans++;
                }

            }
        }

        System.out.println(ans);



    }

}


Measured memory_bytes: 21844
from math import factorial
from collections import defaultdict

n = int(input())
cnt = defaultdict(int)
n = factorial(n)
i = 2
while n >= i:
    if n % i == 0:
        n //= i
        cnt[i] += 1
    else:
        i += 1    
ans = 1
#print(cnt)
for k, v in cnt.items():
    ans *= v + 1

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3316
import numpy as np


def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    sol_tot, sol_tracker = -1e10, []
    for p in range(2):
        c = a.copy()

        idx = np.arange(p, n, 2)
        if len(idx) == 0:
            continue

        pick = max(idx, key=lambda i: c[i])
        if c[pick] <= 0:
            chosen = set([pick])
        else:
            chosen = set(filter(lambda i: c[i] > 0, idx))

        is_chosen, tot, tracker = [False] * n, 0, []
        for i in chosen:
            is_chosen[i] = True
            tot += c[i]

        for i in reversed(range(n)):
            if not is_chosen[i]:
                if i == 0 or i + 1 == len(c):
                    tracker += [i]
                    del c[i], is_chosen[i]
                elif is_chosen[i - 1] == is_chosen[i + 1]:
                    tracker += [i]
                    c[i - 1] += c[i + 1]
                    del c[i + 1], c[i], is_chosen[i + 1], is_chosen[i]

        if len(c) > 1 and not is_chosen[0]:
            tracker += [0]
            del c[0], is_chosen[0]

        if tot > sol_tot:
            sol_tot, sol_tracker = tot, np.array(tracker) + 1

    print(sol_tot, len(sol_tracker), *sol_tracker, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 12536
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	lint base = 1;
	int posneg = 1;
	stack<int> S;

	if (N == 0)
	{
		cout << 0 << endl;
		return;
	}

	for (; N != 0;)
	{
		lint absN = abs(N);
		if (absN % (base * 2))
		{
			N -= (base * posneg);
			S.push(1);
		}
		else
		{
			S.push(0);
		}

		base *= 2;
		posneg *= -1;
	}

	for (; !S.empty();)
	{
		cout << S.top();
		S.pop();
	}

	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean ans = true;
		StringBuffer sb = new StringBuffer();
		sb.append(S);
		
		//all
		StringBuffer reverce = sb.reverse();
		if(!S.equals(reverce.toString())) {
			ans = false;
		}
		
		//former
		String former = S.substring(0, (S.length() - 1) / 2);
		StringBuffer formerSb = new StringBuffer();
		formerSb.append(former);
		StringBuffer reverceFormer = formerSb.reverse();
		if(!former.equals(reverceFormer.toString())) {
			ans = false;
		}
		
		//latter
		String latter = S.substring((S.length() + 2) / 2, S.length());
		StringBuffer latterSb = new StringBuffer();
		latterSb.append(latter);
		StringBuffer reverceLatter = latterSb.reverse();
		if(!latter.equals(reverceLatter.toString())) {
			ans = false;
		}
		
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
	
}

Measured memory_bytes: 22228
n =  int(input())
dic = dict()
for j in range(n):
  i = int(input())
  if i in dic :
    if dic[i] == 1 :
      dic[i] = 0
    else:
      dic[i] = 1
  else :
    dic[i] = 1
print(sum(dic.values()))

Measured memory_bytes: 15072
import sys

n, u, v, *ab = map(int, sys.stdin.read().split())
graph = [[] for _ in range(n+1)]
for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [None] * (n + 1)
    dist[v] = 0
    stack = [v]
    while stack:
        x = stack.pop()
        for y in graph[x]:
            if dist[y] is None:
                dist[y] = dist[x] + 1
                stack.append(y)
    return dist

def main():
    dist_u = dfs(u)
    dist_v = dfs(v)

    d = 1
    for i in range(1, n+1):
        if dist_v[i] >= dist_u[i]:
            d = max(d, dist_v[i])
    ans = d - 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 31960
num=int(input())
A=[]
for i in range(num):
    lst=list(map(int,input().split()))
    if lst[0]==0:
        A.append(lst[1])
        
    elif lst[0]==1:
        print(A[lst[1]])
        
    elif lst[0]==2:
        del A[-1]
        


Measured memory_bytes: 13368
Imports System

Module practiceA
    Sub Main(ByVal args() As String)
        Dim S, W As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        S = arr(0)
        W = arr(1)

        If S > W Then
            Console.Write("safe")

        Else
            Console.Write("unsafe")
        End If

    End Sub
End Module

Measured memory_bytes: 28380
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    map<int,int> mp;
    int N;cin>>N;
    int a;
    for(int i=0;i<N;i++){
        cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->first>itr->second)ans+=itr->second;
        else ans+=itr->second-itr->first;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
n = int(input())
cap = [int(input()) for _ in range(5)]

min_cap = min(cap)

if n <= min_cap:
    print(5)
else:
    if (n - min_cap) % min_cap == 0:
        r = 0
    else:
        r = 1
    print((n - min_cap) // min_cap + r + 5)

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

int main() {
  long long  A, b;
  string B;
  char c;
  cin >> A;
  
  rep(i, 4){
    cin >> c;
    if(c !='.') B += c;
  }
  b = stoll(B);
  
  cout << (A*b)/100 << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys
s = input()
s = s[::-1]
A = ['dreamer','dream','eraser', 'erase']
for i in range(len(A)):
    A[i] = A[i][::-1]
while(len(s)!=0):
    cs = s
    for i in range(len(A)):
        if (s.startswith(str(A[i]))):
            #print(A[len(A[i])+1:])
            s = s[len(A[i]):]
            #print(s)
            break
    if (cs == s):
        print('NO')
        sys.exit()
print('YES')

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    vector<int> dp(n + 1);
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        int m = INT_MAX;
        int t = k;
        for (int j = i - 1; j >= 1 && t > 0; j--, t--)
        {
            m = min(dp[j] + abs(h[i] - h[j]), m);
        }
        dp[i] = m;
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
import itertools

n = int(input())
l = list(map(int, input().split()))

com = list(itertools.combinations(list(range(n)), 3))

cnt = 0
for i, j, k in com:
    a = [l[i], l[j], l[k]]
    if len(set(a)) != 3:
        continue
    if sum(a) > 2*max(a):
        cnt += 1
print(cnt)


Measured memory_bytes: 87260
#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it=x.begin();it!=x.end();it++)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si(x) x->second
#define fi(x) x->first
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------
 


signed main(){
	//FILEIO
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	

	
	
	






	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>

using namespace std; 

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

   int num[n];

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

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

   if(c==2 || c==0){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }

	return 0;
}

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

int main(){
    int64_t N,M,tmp=0,M_func=1,N_func=1;
    cin>>N>>M;
    if(N>M){
        tmp = N;
        N = M;
        M = tmp;
    }
    if(M>N+1){
        cout<<0<<endl;
    }else{
        for(int i=1;i<=M;i++){
            M_func = (M_func*i)%1000000007;
        }
        for(int i=1;i<=N;i++){
            N_func = (N_func*i)%1000000007;
        }
        if(N==M){
            cout<<(M_func*N_func*2)%1000000007<<endl;
        }else{
            cout<<(M_func*N_func)%1000000007<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    string s,t;cin>>s>>t;
    int ans=0;
    int n=s.length();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<nl;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3780
import java.util.Scanner;
import static java.lang.Math.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        
        int maxV = -1000000001;
        int minV = Integer.parseInt(sc.next());
        
        for(int i = 1; i < n; i++) {
            int rT = Integer.parseInt(sc.next());
            maxV = max(maxV, rT - minV);
            minV = min(minV, rT);
        }
        System.out.println(maxV);
    }

}


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

#define N 1000000

int main(void)
{
  char st[N],st1[N];
  int i,j,k,l,n,m,h;

  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      scanf("%s",st);

      for(i=1;i<=n;i++)
        {
          k=1;
          l=0;
          if(strlen(st)==1)
	    {
	      st1[l]=k+48;
	      st1[l+1]=st[l];
	      l=l+2;
	    }
          else
	    {
              for(j=1;j<=strlen(st)-1;j++)
	        {
	          if(st[j]==st[j-1])
	            {
	              k++;
	              if(j==strlen(st)-1)
	                {
		          if(k<=9)
		            {
	                       st1[l]=k+48;
	                       st1[l+1]=st[j-k+1];
			       l=l+2;
		            }
		          else
		            {
		              m=k/10;
		              h=k%10;
		              st1[l]=m+48;
		              st1[l+1]=h+48;
	                      st1[l+2]=st[j-k+1];
			      l=l+3;
		            }
		        }
	            }
	          else
	            {
	              if(k<=9)
		        {
	                  st1[l]=k+48;
	                  st1[l+1]=st[j-k];
	                  l=l+2;
		        }
	              else
		        {
		          m=k/10;
		          h=k%10;
	                  st1[l]=m+48;
        	          st1[l+1]=h+48;
	                  st1[l+2]=st[j-k];
		          l=l+3;
		        }
	              k=1;
	              if(j==strlen(st)-1)
		        {
		          st1[l]=k+48;
		          st1[l+1]=st[j];
		          l=l+2;
		        }
	            }
	        }
	    }
          st1[l]='\0';
          sscanf(st1,"%s",st);
	}
      printf("%s\n",st);
    }
  return 0;
}

Measured memory_bytes: 684
n = int(input())
l = [True for i in range(n+1)]
a = [0]
for i in range(n):
    a.append(int(input()))
i = 1
ans = 0
while l[i]:
    l[i] = False
    i = a[i]
    ans += 1
    if i==2:
        print(ans)
        import sys
        sys.exit()
print(-1)

Measured memory_bytes: 7860
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100003;
int n,k,a[MaxN];

inline int gcd(int a,int b) {
	int r;
	while (b) {
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}

int main() {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i) {
		scanf("%d",a+i);
		if (a[i]==k) {
			puts("POSSIBLE");
			return 0;
		}
	} 
	sort(a+1,a+n+1);
	if (a[n]<k) {
		puts("IMPOSSIBLE");
		return 0;
	}
	int g=a[1];
	for (int i=2;i<=n;++i)
		g=__gcd(g,a[i]);
	if (k%g==0) {
		puts("POSSIBLE");
	} else {
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
   input! {
       n: usize,
       x: isize,
       pos: [isize; n],
    }

    let first = x - pos[0];
    let ans = pos.iter().map(|c| (c-x).abs()).fold(first, |acc, x| gcd(acc, x));

    println!("{}", ans);
}

fn gcd(x: isize, y: isize) -> isize {
    return if y != 0 { gcd(y, x%y) } else { x };
}


Measured memory_bytes: 4352
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

def search(x,d)
  return 1 if(d >= @size)
  if(@memo[x][d] === false)
    p -1
    exit
  end
  return @memo[x][d] if(@memo[x][d] != nil)
  @memo[x][d] = false
  nx = @t[x][d]-1
  nd = @mem[nx][x]+1
  hyo = [search(nx,nd),search(x,d+1)].max + 1
  @memo[x][d] = hyo
  return hyo
end

n = inp[0]
@size = n-1
@t= []
@memo = na2(n,n-1,nil)
@mem = na2(n,n,nil)
n.times do
  @t.push(inp)
end
n.times do |i|
  (n-1).times do|j|
    @mem[i][@t[i][j]-1] = j
  end
end

ans = 0
n.times do |i|
  ans = [ans,search(i,0)].max
end

p ans-1


Measured memory_bytes: 27296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] L;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            L = Input.ReadIntArray();
            Array.Sort(L);

            if (L.Sum() - L.Last() > L.Last())
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
// https://atcoder.jp/contests/dp/tasks/dp_a

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define loop(i,a,b) for(int i = a;i < b; i++)
#define rloop(i,a,b) for(int i = b;i >= a; i--)
void solve(){
    ll n;
    cin>>n;
    vi v(n);
    loop(i,0,n)cin>>v[i];
    vi dp(n,INT_MAX);
    dp[0] = 0;
    loop(i,1,n){
        dp[i] = dp[i-1] + abs(v[i] - v[i-1]);
        if(i > 1)dp[i] = min(dp[i],dp[i-2] + abs(v[i] - v[i-2]));
    }
    // loop(i,0,n)cout<<dp[i]<<" ";
    // cout<<'\n';
    cout<<dp[n-1]<<'\n';
    return ;
}
int main(){
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main (){
  int N;
  int d[101];
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> d[i] ;
  }
  
  int num[101]={0};
  for(int i=0;i<N ;i++){
    num[d[i]]++;
  }
  
  int res = 0;
  for(int i=1;i<=100;i++){
    if(num[i]>0){
      res++;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI a(100005, 0);
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    int ans = a[0] + a[1];
    REP(i, 100003) ans = max(ans, a[i-1] + a[i] + a[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))

abs_list = list(map(abs, A))
abs = sum(abs_list)
x = len([i for i in A if i < 0]) 

if x % 2 ==0:
  print(abs)
 
else:
  min_abs = min(abs_list)
  print(abs - 2*min_abs)
  

Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  if (K > ((N - 1) * (N - 2)) / 2){
    cout << -1 << endl;
  }else{
    vector < pair<int, int> > ans;

    for (int i = 2; i <= N; i++){
      ans.push_back(make_pair(1, i));
    }
    
    int now = (N - 1) * (N - 2) / 2;

    int I = 2, J = 3;
    while (now != K){
      now--;
      ans.push_back(make_pair(I, J));

      if (J == N) {
        I++; J = I + 1;
      }else{
        J++;
      }
    }
    
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++){
      cout << ans[i].first << " " << ans[i].second << endl;
    }
    
  }
  return 0;
}


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

class Hello
{
    static void Main(string[] args)
    {
        var Input = System.Console.ReadLine();
        var Date = DateTime.Parse(Input);
        if (Date > new DateTime(2019, 4, 30))
        {
            Console.WriteLine("TBD");
        }
        else
        {
            Console.WriteLine("Heisei");
        }
    }
}

Measured memory_bytes: 11616
N,x=map(int,input().split())
S = [int(i) for i in input().split()]
pre,ans = 0,0
for i in range(N):
    tmp = pre+S[i]
    if tmp > x:
        ans += tmp-x
        S[i] -= tmp-x
    pre = S[i]
print(ans)

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

int main(){
	int n,m;
  cin>>n;
  cin>>m;
  int a = (m*(m-1))/2;
  int b = (n*(n-1))/2;
  int ans = a+b;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int main(){
	//freopen("in","r",stdin);
	int N=read();
	int ans=0;
	for(int i=1;i<=N/2;i++)
		if(N-i!=i)
			ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    int negative = 0;
    bool zero = false;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] == 0)   zero = true;
        if(a[i] < 0){
            ++negative;
            a[i] *= -1;
        }
        ans += a[i];
    }
    if(zero || negative % 2 == 0)   cout << ans << endl;
    else{
        ans -= *min_element(a.begin(), a.end()) * 2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define EPS 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define x real()
#define y imag()
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[105],b[105];
map<P,int>M;
typedef complex<double> pt;
bool eq(double a,double b){
  return (-EPS < a-b && a-b < EPS);
}
double dot(pt a,pt b){
	return (conj(a)*b).x;
}
double cross(pt a,pt b){
	return (conj(a)*b).y;
}
bool cmp(const pt& a,const pt& b){
	if(-EPS < a.x-b.x && a.x-b.x < EPS) return a.y < b.y;
	else return a.x < b.x;
}
int ccw(pt a,pt b,pt c){
	b -= a; c -= a;
	//cout<<cross(b,c)<<endl;
	if(cross(b,c) > EPS) return 1; // counter clockwise
	if(cross(b,c) < -EPS) return -1; // clockwise
	if(dot(b,c) < -EPS) return 2; //c-a-b
	if(norm(b) < norm(c)) return -2; //a-b-c
	return 0; //a-c-b
}
vector<pt>convex_hull(vector<pt>ps)
{
	sort(ps.begin(),ps.end(),cmp);
	int k=0,n = ps.size();
	vector<pt>qs(n*2);
	for(int i=0;i<n;i++)
	{
		while(k>1 && ccw(qs[k-2],qs[k-1],ps[i]) != 1) k--;
		qs[k++] = ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--)
	{
		while(k>t && ccw(qs[k-2],qs[k-1],ps[i]) != 1) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k-1);
	return qs;
}

double ans[105];
int main(){
	cin>>n;
	vector<pt>vec;
	rep(i,n){
		cin>>a[i]>>b[i];
		M[mp(a[i],b[i])] = i;
		vec.pb(pt((double)(a[i]),(double)(b[i])));
	}
	vector<pt>c = convex_hull(vec);
	if(c.size() == 2){
		int xx = floor(c[0].real()+0.5);
		int yy = floor(c[0].imag()+0.5);
		ans[M[mp(xx,yy)]] = 0.5;
		xx = floor(c[1].real()+0.5);
		yy = floor(c[1].imag()+0.5);
		ans[M[mp(xx,yy)]] = 0.5;
	}
	else{
		for(int i=0;i<c.size();i++){
			pt q = c[i];
			pt p = c[(i-1+c.size())%c.size()];
			pt r = c[(i+1)%c.size()];
			double v = arg((p-q)/(r-q));
			v = 3.141592653589 - v;
			int xx = floor(c[i].real()+0.5);
			int yy = floor(c[i].imag()+0.5);
			ans[M[mp(xx,yy)]] = v / (2.0*3.141592653589);
		}
	}
	rep(i,n){
		printf("%.12f\n",ans[i]);
	}
}

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

using namespace std;

typedef long long ll;

int main()
{
	int p = -1;
	for(int i = 0; i < 5; i++)
	{
		int x;
		cin >> x;
		if(!x)
		{
			p = i + 1;
		}
	}
	
	cout << p << endl;
}


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

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

    int iter_first[200100];
    for(int i=0; i<200100; i++){
        iter_first[i] = N;
    }
    iter_first[0] =0;
    int flag = 1;
    for(int i=1; i<N; i++){
        if(S.at(i)!=S.at(i-1)){
            iter_first[flag] = i;
            flag ++;
        }
    }

    int ans=0;

    for(int i=0; i<flag; i++){
        if(S.at(iter_first[i]) == '0'){
            ans = max(ans, iter_first[i+2*K]-iter_first[i]);
        }
        else{
            ans = max (ans, iter_first[i+2*K+1]-iter_first[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280