akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]"):
    conns = [[] for _ in range(N)]
    for i in range(N - 1):
        conns[a[i] - 1].append((b[i] - 1, i))
        conns[b[i] - 1].append((a[i] - 1, i))
    k = 0
    for i in range(N):
        k = max(k, len(conns[i]))
    ret = [0] * (N - 1)
    def dfs(idx, prev, visited):
        visited[idx] = True
        color = 0 if prev != 0 else 1
        for node, idx in conns[idx]:
            if not visited[node]:
                ret[idx] = color + 1
                dfs(node, color, visited)
                color += 1
                if color == prev:
                    color += 1
    visited = [False] * N
    dfs(0, -1, visited)
    print(k)
    for r in ret:
        print(r)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()


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

int main() {
  std::ptrdiff_t n, k, q;
  std::cin >> n >> k >> q;

  std::vector<std::ptrdiff_t> a(q);
  for (std::ptrdiff_t i = 0; i < q; ++i) std::cin >> a[i];

  std::vector<std::ptrdiff_t> p(n, k - q);
  for (auto&& ai : a) ++p[ai - 1];
  for (auto&& pi : p) std::cout << (pi > 0 ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 2176
#include <iostream>


#define ll long long
using namespace std;

ll mem[100009][4]{};
ll arr[100005][3]{};

ll n;
int maxHappy(ll i , ll prev)
{

if(i==n)
{
    return 0;
}

ll &ret = mem[i][prev];
if(ret!=-1)
    return ret;

ret = 0 ;
ll choice0 = 0 ;
ll choice1 = 0 ;
ll choice2 = 0 ;

if(prev!=0)
{
    choice0 = arr[i][0] + maxHappy(i+1 , 0);
}
if(prev!=1)
{
    choice1 = arr[i][1] + maxHappy(i+1 , 1);
}
if(prev!=2)
{
    choice2 = arr[i][2] + maxHappy(i+1 , 2);
}

ret = max(ret , choice0);
ret = max(ret , choice1);
ret = max(ret , choice2);


return ret;
}

int main()
{

    cin >>n;
    for(int i = 0 ; i<100009 ; i++)
    {
        for(int j = 0 ; j<4 ; j++)mem[i][j] = -1;
    }
    for(int i = 0 ; i<n ; i++)
    {
        for(int j = 0 ; j<3 ; j++)
            cin>>arr[i][j];
    }



    cout<<maxHappy(0,3)<<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int h[n+5],dp[n+5];
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<=n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>

int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }

    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    return b;
}




int main(void){
  int n;
  scanf("%d",&n);
  int g=0;
  int f=1000;
  int i;
  for(i=0;i<n;i++){
      int a;
      scanf("%d",&a);
      if(a<f){
          f=a;
      }
      if(g<a){
          g=a;
      }
  }

  printf("%d\n",g-f);

  return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#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             1e9
#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 all(v)          v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
    return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
    return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
    lli res = 1;

    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;


        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return n;


    lli pro = 1, k = n;
    while (k > r)
    {
        pro *= k;
        pro %= p;
        --k;
    }

    k = 2;
    while (k <= (n - r))
    {
        pro *= power(k, (p - 2), p);
        pro %= p;
        ++k;
    }

    return pro;
}


string num_str(lli n, lli k)
{
    string str = "";
    lli x = n;
    while (x != 0)
    {
        string s = to_string(x % k);
        str = s + str;
        x /= k;
    }

    return str;
}


lli first_big(lli n, lli k, lli arr[])
{
    lli l = 0;
    lli r = n - 1;

    lli leftGreater = n;

    while (l <= r) {
        lli m = l + (r - l) / 2;

        if (arr[m] > k) {
            leftGreater = m;
            r = m - 1;
        }

        else
            l = m + 1;
    }

    return leftGreater;
}

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
}

int main()
{
    c_p_c();

    lli n;
    cin >> n;

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

    sort(all(v));

    lli ans = 0;
    ans += v[n - 1];
    lli rem = (n - 2), j = (n - 2);

    while (rem > 0)
    {
        if (rem >= 2)
        {
            ans += 2 * v[j];
            rem -= 2;
        }
        else
        {
            ans += v[j];
            rem -= 1;
        }
        --j;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4772
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    ac = [0]*N
    for i in range(1,N):
        if(S[i-1:i+1] == 'AC'):
            ac[i] = ac[i-1]+1
        else:
            ac[i] = ac[i-1]

    ans = [0]*Q
    for i in range(Q):
        ans[i] = ac[r[i]-1] - ac[l[i]-1]

    for i in ans:
        print(i)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


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

long merge_sort(vector<int>& A, int l, int r) {
    long cnt = 0;
    if (l >= r) return 0;
    int m = (l + r) / 2;
    cnt += merge_sort(A, l    , m);
    cnt += merge_sort(A, m + 1, r);
    vector<int> B1(m - l + 2);
    for (int i = 0; i < m - l + 1; i++) B1[i] = A[i+l];
    B1[m-l+1] = 1e9 + 1;
    vector<int> B2(r - m + 1);
    for (int i = 0; i < r - m; i++) B2[i] = A[i+m+1];
    B2[r-m] = 1e9 + 1;
    int j1 = 0;
    int j2 = 0;
    for (int i = l; i <= r; i++) {
        if (B1[j1] <= B2[j2]) {
            A[i] = B1[j1++];
        } else {
            A[i] = B2[j2++];
            cnt += m - l + 1 - j1;
        }
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    cout << merge_sort(A, 0, n - 1) << endl;
    return 0;
}

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

int main(){
    ll x;
	cin>>x;
	for(ll i=-2000;i<=2000;i++){
		for(ll j=-2000;j<=2000;j++){
			if(pow(i,5)-pow(j,5)==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4168
import sys

def main():

    input = sys.stdin.readline

    N = int(input())
    c = str(input())[:-1]

    top_index = 0
    bottom_index = N - 1

    ans = 0

    while top_index < bottom_index:
        if(c[top_index] == "W") and (c[bottom_index] == "R"):
            ans += 1
            top_index += 1
            bottom_index -= 1
            continue

        if c[top_index] == "R":
            top_index += 1
        if c[bottom_index] == "W":
            bottom_index -= 1


    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9348
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 100005
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll k; cin>>k;
    ll sum=0;
    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=k;j++){
            for(ll m=1;m<=k;m++){
                sum+=(__gcd(m,__gcd(i,j)));
            }
        }
    }
    cout<<sum;
 
    return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (n & 1) cout << b[n / 2] - a[n / 2] + 1 << endl;
	else cout << (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1 << endl;

	return 0;
}

Measured memory_bytes: 4840
#pragma GCC optimize("Ofast")
#include<stdio.h>
char c;
int main(void)
{
	long n = 0;
	c=getchar();
	while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar();}
    ++n;
    long ans = n - 1;
	for (int i = 2; i < n; ++i)
	{
        int u = 0, v = 0;
	    c=getchar();
	    while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar();}
	    c=getchar();
	    while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar();}
        switch(u > v)
        {
            case true: ans += i * (n - i) - v * (n - u); break;
            default: ans += i * (n - i) - u * (n - v);
        }
        
	}
	printf("%ld", ans);
  
    return 0;
}


Measured memory_bytes: 1600
let () =
  let s = read_line () in
  let t = read_line () in
  Array.init (String.length s) (fun i -> i)
  |> Array.to_list
  |> List.exists (fun i ->
      Array.init (String.length s) (fun j -> j)
      |> Array.to_list
      |> List.for_all (fun j ->
          s.[(i + j) mod String.length s] = t.[j]))
  |> (function true -> "Yes" | false -> "No")
  |> print_endline


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

n = int(input().rstrip('\n'))
s = input().rstrip('\n')
l = [c for c in s]
q = int(input().rstrip('\n'))
Q = [input().rstrip('\n').split() for _ in range(q)]

class SegTree():
    def __init__(self, n_):
        self.n = 1
        while self.n < n_:
            self.n *= 2
        self.tree = [2 for _ in range(2 * self.n - 1)]
    def update(self, k, a):
        k += self.n - 1
        self.tree[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.tree[k] = min(self.tree[k * 2 + 1], self.tree[k * 2 + 2])
    def query(self, l, r):
        l += self.n - 1
        r += self.n - 2
        res = 2
        while r-l>1:
            if l&1 == 0:
                res = min(res,self.tree[l])
            if r&1 == 1:
                res = min(res,self.tree[r])
                r -= 1
            l = l//2
            r = (r-1)//2
        if l == r:
            res = min(res,self.tree[l])
        else:
            res = min(min(res,self.tree[l]),self.tree[r])
        return res

d = { c: SegTree(n) for c in "abcdefghijklmnopqrstuvwxyz"}

for i, c in enumerate(s):
    d[c].update(i, 1)


for a, b, c in Q:
    if a == "1":
        b = int(b) - 1
        d[l[b]].update(b, 2)
        d[c].update(b, 1)
        l[b] = c
    else:
        res = 0
        b, c = int(b), int(c)
        for key in d:
            if d[key].query(b-1, c) == 1:
                res += 1
        print(res)


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

template <typename T, T (*op)(T, T), T (*e)()>
struct segtree {
  segtree() : segtree(0) {}
  segtree(int n) : segtree(vector<T>(n, e())) {}
  segtree(vector<T> &v) : _n((int)v.size()) {
    log = 0;
    size = 1;
    while (size < _n) {
      size <<= 1;
      log++;
    }
    d = vector<T>(2 * size, e());
    for (int i = 0; i < _n; i++) {
      d[size + i] = v[i];
    }
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }

  void set(int p, T x) {
    assert(0 <= p && p < _n);
    p += size;
    d[p] = x;
    for (int i = 1; i <= log; i++) {
      update(p >> i);
    }
  }

  T prod(int l, int r) {
    assert(0 <= l && l <= r && r <= _n);
    T sml = e(), smr = e();
    for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
      if ((l & 1) == 1) {
        sml = op(sml, d[l++]);
      }
      if ((r & 1) == 1) {
        smr = op(d[--r], smr);
      }
    }
    return op(sml, smr);
  }

  template <bool (*f)(T)>
  int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }

  template <typename F>
  int max_right(int l, F f) {
    assert(0 <= l && l <= _n);
    assert(f(e()));
    if (l == _n) {
      return _n;
    }
    l += size;
    T sm = e();
    do {
      for (; (l & 1) == 0; l >>= 1) {
      }
      if (!f(op(sm, d[l]))) {
        while (l < size) {
          l = 2 * l;
          if (f(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }

 private:
  int _n, size, log;
  vector<T> d;

  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};

int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int target;

bool f(int v) { return v < target; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  segtree<int, op, e> seg(a);
  while (q--) {
    int ti;
    cin >> ti;
    if (ti == 1) {
      int xi, vi;
      cin >> xi >> vi;
      xi--;
      seg.set(xi, vi);
    } else if (ti == 2) {
      int li, ri;
      cin >> li >> ri;
      li--;
      cout << seg.prod(li, ri) << '\n';
    } else {
      int xi;
      cin >> xi >> target;
      xi--;
      cout << seg.max_right<f>(xi) + 1 << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 6084
#include <stdio.h>

int main(void){
	int a=100000;
	int n;
	int i;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		a*=1.05;
		if(a%1000!=0){
			a/=1000;
			a++;
			a*=1000;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

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

    int q;
    cin >> q;
    set<string> st;
    while (q--)
    {
        string s;
        cin >> s;
        string str;
        cin >> str;
        if (s == "insert")
        {
            st.insert(str);
        }
        else
        {
            if (st.find(str) == st.end())
            {
                cout << "no" << endl;
            }
            else
            {
                cout << "yes" << endl;
            }
        }
    }
}



Measured memory_bytes: 29072
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))

print(lcm_list(l))

Measured memory_bytes: 9500
def ceil(a, b):
  return a // b + (a % b > 0)

N = int(input())
T = A = 1
for i in range(N):
  t, a = map(int, input().split())
  m = max(ceil(T, t), ceil(A, a))
  T = t * m
  A = a * m
print(T + A)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(true)
	{
		c -= b;
		if(c <= 0)
		{
			cout << "Yes";
			return 0;
		}
		a -= d;
		if(a <= 0)
		{
			cout << "No";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	while(true){
		int n,m,a[100],b[100],sa=0,sb=0,ansa=1e7,ansb=1e7;
		scanf("%d%d",&n,&m);
		if(n==0) break;
		rep(i,n) { scanf("%d",a+i); sa+=a[i]; }
		rep(i,m) { scanf("%d",b+i); sb+=b[i]; }
		rep(i,n) rep(j,m){
			if(sa-a[i]+b[j]==sb-b[j]+a[i]){
				if(ansa+ansb>a[i]+b[j]) ansa=a[i],ansb=b[j];
			}
		}
		if(ansa==1e7) printf("-1\n");
		else printf("%d %d\n",ansa,ansb);
	}
	return 0;
}

Measured memory_bytes: 1020
sa=input();sb=input();sc=input()
s=[1,0,0]
ss=[sa,sb,sc]
now = sa[0]

la=len(sa);lb=len(sb);lc=len(sc)
ans=["A","B","C"]
l=[la,lb,lc]
if la<=1:
    print("A")
    exit()

p2n={'a':0,'b':1,'c':2}

while 1:
    nxt=p2n[now]
    if s[nxt]>=l[nxt]:
        print(ans[nxt])
        exit()
    tmp=ss[nxt][s[nxt]]
    s[nxt]+=1
    now=tmp

Measured memory_bytes: 62040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        StringBuffer buffer = new StringBuffer();
        int position = -1;
        for (char c : s.toCharArray()) {
            if (c == 'B') {
                if (buffer.length() != 0) {
                    buffer.deleteCharAt(position--);
                }
            } else {
                buffer.insert(++position, c);
            }
        }
        System.out.println(buffer);
    }
}

Measured memory_bytes: 27008
N,M = map(int, input().split())
key = []
key_i = []
for i in range(M):
  key.append(list(map(int, input().split())))
  key_i.append(list(map(int, input().split())))
keybin = [0]*M
for j in range(M):
  for x in key_i[j]:
    keybin[j] += 2**(x-1)
INF = float("inf")
DP = [[INF] * (2**N) for _ in range(M+1)]

DP[0][0] = 0
for i in range(1,M+1):
  for j in range(2**N):
    x = keybin[i-1]
    DP[i][j] = min(DP[i][j],DP[i-1][j])
    DP[i][j|x] = min(DP[i][j|x],DP[i-1][j|x], DP[i-1][j]+key[i-1][0])
if DP[-1][-1] >10**18:
  print(-1)
else:
  print(DP[-1][-1])

Measured memory_bytes: 133976
using namespace std;
#include<bits/stdc++.h>
#define debug(x) clog<<#x<<" = "<<x<<'\n'
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define sz(c) ((int)c.size())
#define all(c) (c).begin(),(c).end()
#define MASK(i) (1LL<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define fn "B"  /// ___FILE_NAME_HERE___
#define rep(c,it) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define __rep(c,it) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();it++)

template <class T,class U>
void maximize(T &x,U y)
{
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y)
{
    if(x > y)x=y;
}
template <class T>
T Abs(T x)
{
    return (x < 0 ? -x : x);
}
template <class T>
T safe_sqrt(T x)
{
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD)
{
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD)
{
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD)
{
    return (ll)x*y%MOD;
}
/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

const int N=1e5+5;
char s[N];
int cnt[30];
bool used[30];

void solve()
{
    scanf("%s",&s);
    for(int i=0;s[i];++i)
        used[s[i]-'a'] = true;
    for(int i=0;i<26;++i)
        if(!used[i])
          printf("%c",char(i + 'a')),exit(0);
    puts("None");
}}

int main(void)
{
    task::solve();
}


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

int main(){
    int n, a[101];
    cin >> n;

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

    sort(a, a + n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }

    cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  int total = 0;
  for(int i = 1;i<=(1e7);i++){
    total = ((total*10)+7)%k;
    if(total==0){
    cout<<i<<endl;
    return 0;
    }
  }
  cout<<"-1"<<endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    int n;
    cin >> n;

    int sum = 0;
    int tmp = n;
    while (tmp != 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int f(string X) {
  int s = 0;
  for (int i = 0; i < X.size(); i++) {
    s += X[i] - '0';
  }

  return s;
}

int main() {
  string N;
  cin >> N;
  int NX = stoi(N);
  int s = f(N);

  if (NX % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	
	if(a==1&&b==1) cout<<"Draw"<<endl;
	else if(a==1) cout<<"Alice"<<endl;
	else if(b==1) cout<<"Bob"<<endl;
	else if(a>b) cout<<"Alice"<<endl;
	else if(a<b) cout<<"Bob"<<endl;
	else cout<<"Draw"<<endl;
	
	return 0;
}


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

signed main(void)
{
	int n;
	long long k, cnt, cnt_loop;
	cin >> n >> k;
	int a[n], label[n];
	int pre, tmp;
	vector<bool> visit(n, false);
	vector<int> ans;

	rep(i, n) 
	{
		cin >> a[i];
		a[i]--;
	}
	queue<int> que;
	que.push(a[0]);
	pre = -1;
	cnt = 1;
	label[0] = cnt;
	visit[0] = true;
	while(true)
	{
		int now = que.front();
		que.pop();
		if (visit[now])
		{
			cnt_loop = label[pre] - label[now] + 1;
			tmp = now;
			break;
		}
		if (cnt >= k)
		{
			cout << now + 1 << endl;
			return 0;
		}
		cnt++;
		label[now] = cnt;
		visit[now] = true;
		que.push(a[now]);
		pre = now;
	}
	ans.push_back(tmp + 1);
	rep(i, cnt_loop - 1)
	{
		int now = a[tmp];
		tmp = now;
		ans.push_back(tmp + 1);
	}
	k -= (cnt - cnt_loop);
	k %= cnt_loop;
	cout << ans[k] << endl;
	return 0;
}


Measured memory_bytes: 5792
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_094
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] xs = ReadInts();
            var numbers = new int[n][];
            for (int i = 0; i < n; i++)
            {
                numbers[i] = new int[2];
                numbers[i][0] = i;
                numbers[i][1] = xs[i];
            }
            Array.Sort(numbers, (a, b) => a[1] - b[1]);
            int medMin = numbers[n / 2 - 1][1];
            int medMax = numbers[n / 2][1];
            for (int i = 0; i < n; i++)
            {
                if (xs[i] <= medMin)
                {
                    Console.WriteLine(medMax);
                }
                else
                {
                    Console.WriteLine(medMin);
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 45632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;
  using std::vector;
  using std::count_if;

  int n, m;
  cin >> n >> m;
  vector<int> liked(m, 0);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      ++liked[a - 1];
    }
  }

  cout << count_if(liked.begin(), liked.end(), [n](int c){ return c == n; });

  return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)scanf("%d",&arr[i]);
    vector<bool>dp(k+1,false);
    dp[0]=false;
    for(int i=1;i<k+1;i++){
        for(int j=0;j<n && arr[j]<=i;j++)
        dp[i] = dp[i] || !dp[i-arr[j]];
    }/*
    for(int i=0;i<k+1;i++){
        if(dp[i])printf("1 ");
        else printf("0 ");
    }
    cout<<"\n";*/
    if(dp[k])
    printf("First");
    else
    printf("Second");
    return 0;
}

Measured memory_bytes: 3804
n = gets.to_i

dishes = gets.split.map(&:to_i)
scores = gets.split.map(&:to_i)
bonus = gets.split.map(&:to_i)

res = 0

last_dish = -2
dishes.each_with_index do |dish, idx|
    dish -= 1
    res += scores[dish]
    res += bonus[last_dish] if dish - last_dish == 1
    last_dish = dish
end

puts res


Measured memory_bytes: 1788
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    ll w,a,b;cin>>w>>a>>b;
    if(a+w<b) cout<<b-(a+w)<<endl;
    else if(b+w<a) cout<<a-(b+w)<<endl;
    else cout<<0<<endl;
}


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

    cnt = 0
    for i in range(len(A)):
        if A[i]!=i+1:
            cnt+=1

    if cnt == 0 or cnt ==2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()

print("Yes" if "A" in s and "B" in s else "No")

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

int main()
{
	int		n,a;
	char	yomi[4];

	scanf("%d", &n);
	a = n % 10;

	switch(a)
	{
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			strcpy(yomi, "hon");
			break;
			
		case 0:
		case 1:
		case 6:
		case 8:
			strcpy(yomi, "pon");
			break;

		default:
			strcpy(yomi, "bon");
	}

	printf("%s\n", yomi);

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<nint> check(1e5 + 3, 0);
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        temp++;
        check[temp + 1]++;
        check[temp - 1]++;
        check[temp]++;
    }
    int out = 0;
    for (int i = 0; i < 1e5 + 3; i++) {
        chmax(out, check[i]);
    }
    cout << out << endl;
    return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

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

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll x,fromx, tox, n, a, b, ans;

int main(){
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(fromx == 0)  fromx = x;
        else{
            tox = x;
            if(tox-fromx <= b/a)    ans += (tox-fromx)*a;
            else    ans += b;
            fromx = tox;
        }
    }

    printf("%lld\n", ans);
}

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

const int BIG_NUM = 1e9;

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

    string s;
    cin >> s;
    int len = s.size();
    int sum = 0;
    for(int i = 0; i < len; i++) {
        sum += s[i] - '0';
    }
    if(sum % 9 == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){

	string N;
	cin >> N;
	if(N[0] == '7' || N[1] == '7' || N[2] == '7') print("Yes");
	else print("No");
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





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

using namespace std;

using ll = long long;
const ll MOD = 1000000007;

ll solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  ll ans = 0;

  ll combi = ((K * (K - 1)) / 2) % MOD;

  for (ll i = 0; i < N; i++) {
    ll CL = 0;
    ll CR = 0;

    for (ll j = 0; j < N; j++) {
      if (A[j] < A[i]) {
        if (j < i) {
          CL++;
        } else {
          CR++;
        }
      }
    }

    ans += (K * CR) % MOD + (combi * (CL + CR)) % MOD;
    ans = ans % MOD;
  }
  return ans % MOD;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<queue>
using namespace std;
 
#define what_is(x) cerr << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 10000000009
#define eps 1e-9
#define MAX 10
//#define N 100001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX]; 
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

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

 
ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
ll rand(ll a,ll b){
    return a+rand()%(b-a+1);
}
const int p = 31; 
const ll m = 1e10 + 9;

void solve(ll ttt){
    ll n,d;
    cin>>n>>d;
    vpll a(n);
    ll ans=0;
    rep(i,0,n){
        cin>>a[i].fi>>a[i].se;
        ll temp=(a[i].fi*a[i].fi)+(a[i].se*a[i].se);
        if(temp<=d*d)
            ans++;
    }
    cout<<ans<<endl;

}
int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
     // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     // cin>>t;
    fix(12);
    rep(q,1,t+1){
        // cout<<"Case #"<<q<<": ";
         solve(q);
        //solve2();
    }
    return 0;
    
}        




Measured memory_bytes: 6360
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

struct UnionFind
{
    vector<int> par,sz;
    UnionFind(int N){
        par.resize(N); sz.resize(N);
        for(int i=0;i<N;i++){
            par[i]=i; sz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]<sz[y]) swap(x,y);
        par[y]=x; sz[x]+=sz[y];
    }
    int size(int x){
        return sz[find(x)];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

signed main()
{
    int N,M; cin>>N>>M;
    UnionFind tree(N);
    while(M--){
        int x,y,z; cin>>x>>y>>z;
        x--; y--;
        tree.unite(x,y);
    }
    set<int> st;
    for(int i=0;i<N;i++){
        st.insert(tree.find(i));
    }
    cout<<st.size()<<endl;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    int ans = M;
    rep(i, N - M + 1) {
        string U = S.substr(i, M);
        if(U.size() < M) break;
        int cnt = 0;
        rep(j, M) if(U[j] != T[j]) cnt++;
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>p(n);
  for(int i=0;i<n;i++) cin>>p[i];
  double ans=0.0;
  double pre=(p[0]+1)/2.0;
  for(int i=0;i<k;i++) ans+=(p[i]+1)/2.0;
  double preans=ans;
  for(int i=1;i<n-k+1;i++){
    double sub=(p[i+k-1]+1)/2.0-pre;
    preans+=sub;
    ans=max(preans,ans);
    pre=(p[i]+1)/2.0;
  }
  cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 1024
x = int(input())

lower = -1
upper = -1
for i in range(100000000):
    pow5 = pow(i, 5)
    if lower == -1 and pow5 >= x:
        lower = i - 1
        break

for i in range(lower, 100000000):
    pow5 = pow(i, 5)
    if upper == -1 and pow5 - pow(i-1, 5) >= x:
        upper = i
        break

for a in range(-upper-1, upper+1):
    a5 = pow(a, 5)
    for b in range(-upper-1, upper+1):
        if a5 - pow(b, 5) == x:
            print(a, b)
            exit(0)

# 0, 0
print(0, 0)


Measured memory_bytes: 9136
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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

  int sum = 0;
  bool flag = false;
  for (int i = 0; i < n; ++i)
  {
    sum += l + i;
    if (l + i == 0)
      flag = true;
  }
  if (!flag)
    sum -= (abs(l) < abs(l + n - 1)) ? l : (l + n - 1);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <map>

using namespace std;

string make_id(int p, int y){
    string Pid, Yid;
    Pid = to_string(p);
    for(int i = Pid.size(); i < 6; ++i){
        Pid = "0" + Pid;
    }
    Yid = to_string(y);
    for(int i = Yid.size(); i < 6; ++i){
        Yid = "0" + Yid;
    }

    string id = Pid + Yid;
    return id;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> PY(M);
    for(int i = 0; i < M; ++i){
        int p, y;
        cin >> p >> y;
        PY[i] = make_tuple(p, y, i);
    }
    sort(PY.begin(), PY.end());
    vector<string> ans(M);
    map<int, int> cnt;
    for(int i = 0; i < M; ++i){
        tuple<int, int, int> tmp = PY[i];
        cnt[get<0>(tmp)] += 1;
        string id = make_id(get<0>(tmp), cnt[get<0>(tmp)]);
        ans[get<2>(tmp)] = id;
    }
    for(auto i : ans){
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>

int main()
{
	int a, b;

	std::cin >> a >> b;
	if (a < -1000 || a > 1000 || b < -1000 || b > 1000)	return 0;

	if (a < b)
	{
		std::cout << "a < b" << std::endl;
	}
	else if (a > b)
	{
		std::cout << "a > b" << std::endl;
	}
	else
	{
		std::cout << "a == b" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3088
// https://atcoder.jp/contests/dp/tasks/dp_c

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define em emplace_back
#define M 1000000007
ll solve(ll n, ll a[], ll b[], ll c[]);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll a[n], b[n], c[n];
	for (ll i = 0; i < n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	ll dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (size_t i = 1; i < n; i++)
	{
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
	}

	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}


Measured memory_bytes: 8316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int w,a,b; cin>>w>>a>>b;
	int a2=min(a,b);
	int b2=max(a,b);
	if(w+a2>b2) cout<<0;
	else cout<<b2-(w+a2);
	
	return 0;
}

Measured memory_bytes: 256
def combi_three(n):
    if n < 3:
        return 0
    else:
        return int((n * (n - 1) * (n - 2)) / 6)

def quest_d():
    N = int(input())
    S = input()

    index_dict = {'R':0, 'G':0, 'B':0 }
    for index in range(N):
        index_dict[S[index]] = index_dict[S[index]] + 1

    if index_dict['R'] * index_dict['G'] * index_dict['B'] == 0:
        print(0)
        return

    rrr = combi_three(index_dict['R'])
    ggg = combi_three(index_dict['G'])
    bbb = combi_three(index_dict['B'])
    rrg = combi_three(index_dict['R'] + index_dict['G'])
    ggb = combi_three(index_dict['G'] + index_dict['B'])
    bbr = combi_three(index_dict['B'] + index_dict['R'])

    i = 0
    sum = 0
    while i < N:
        a = S[i]
        j = i
        while j < N - 1:
            j += 1
            if S[j] == a:
                continue

            k = 2 * j - i
            if k < N:
                b = S[j]
                if S[k] != a and S[k] != b:
                    sum += 1
        i += 1
    print(combi_three(N) - sum - rrg - bbr - ggb + rrr + ggg + bbb)

if __name__ == '__main__':
    quest_d()


Measured memory_bytes: 9284
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, h[N], dp[N];

inline void readInput() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
}

inline void solve() {
	h[0] = h[1];
	for (int i = 2; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[n] << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int mod = 1e9 + 7;
	vector<vector<int>> cs(2001, vector<int>(2001));
	for (int i = 0; i <= 2000; ++i) {
		cs[i][0] = 1;
		cs[0][i] = 0;
	}
	cs[0][0] = 1;
	for (int i = 1; i <= 2000; ++i) {
		for (int j = 1; j <= 2000; ++j)
			if (j > i) cs[i][j] = 0;
			else cs[i][j] = (cs[i - 1][j - 1] + cs[i - 1][j]) % mod;
	}
	for (int i = 1; i <= k; ++i) {
		long long res = cs[k - 1][i - 1];
		res = (res * cs[n - k + 1][i]) % mod;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 16000
D, N = map(int, input().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N * 100)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(N * 10000)

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

int main(){
    string s;
    int64_t k;
    cin >> s >> k;
    bool same = true;
    for(int i=0;i<s.size();++i) same = same && (s[0] == s[i]);
    if(same){
        int64_t len = k * s.size();
        cout << len / 2 << endl;
    }else if(s[0] == s[s.size()-1]){
        vector<size_t> cont;
        char prev = s[0];
        size_t cur = 0;
        for(int i=0;i<s.size();++i){
            if(s[i] == prev) ++cur;
            else{
                prev = s[i];
                cont.push_back(cur);
                cur = 1;
            }
        }
        cont.push_back(cur);
        int64_t ans = cont[0]/2 + cont[cont.size()-1]/2;
        for(int i=1;i+1<cont.size();++i) ans += cont[i]/2 * k;
        ans += (cont[0]+cont.back())/2 * (k-1);
        cout << ans << endl;
    }else{
        vector<size_t> cont;
        char prev = s[0];
        size_t cur = 0;
        for(int i=0;i<s.size();++i){
            if(s[i] == prev) ++cur;
            else{
                prev = s[i];
                cont.push_back(cur);
                cur = 1;
            }
        }
        cont.push_back(cur);
        int64_t ans = 0;
        for(int i=0;i<cont.size();++i) ans += cont[i]/2 * k;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256