akhauriyash/Code-Regression huggingface dataset:
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++11 -D_GLIBCXX_DEBUG a.cpp -oa && ./a " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fr(i,n) for(int i=(n);i--;)
#define fv(i,v) f(i,sz(v))

main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin>>n;
	cout<<n/3<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
   char str1[10];
   scanf("%s", str1);
   int count = 0;

   for(int i = 0; i < 10; i += 2){
        if(str1[i] == '\0'){
            break;
        }
        if((str1[i] != 'h') || (str1[i + 1] != 'i')){
        count ++;
        } 
   }
   if(count){
       printf("No\n");
   }
   else{
       printf("Yes\n");
   }
   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=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; }
const ll INF=1LL<<60;

ll n,T;
vector<ll> t(200100);

int main(){
    cin>>n>>T;
    rep(i,0,n) cin>>t[i];
    ll ans=0;

    rep(i,0,n-1) ans+=min(T,t[i+1]-t[i]);
    ans+=T;
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

const int maxn = 2 * 1e2 + 10;
int l[maxn];

int main()
{
	int n,jav = 0;
	cin >> n;
	for (int i = 0; i < 2 * n; i ++)
	{
		cin >> l[i];
	}
	sort(l , l + 2 * n);
	for (int i = 0; i < 2 * n; i += 2)
	{
		jav += min(l[i],l[i + 1]);
	}
	cout << jav << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n], s = 0, mx = 0;
	forn(i, 0, n){
		cin>>a[i];
		s+=a[i];
		mx = max(mx, a[i]);
	}
	
	s-=mx;
	if(mx<s){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3620
from math import ceil
n,h = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] , b[i] = map(int,input().split())
bs = list(sorted(b,reverse=True))
ma = max(a)
ret = 0
while ret < n:
    if bs[0] > ma:
        h -= bs[0]
        bs.pop(0)
        ret += 1
        if h <= 0 : break
    else:
        break

if h > 0: ret += ceil(h/ma)
print(ret)


Measured memory_bytes: 13720
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()
print((n/3)**3)




Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
// using ll = long long;
#define int long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int lcm(int, int);
map<int,int> GetPrimeFactors(int);
bool IsPrime(int);
int Factorial(int);
int npr (int, int);
int ncr (int, int);

double calc(int N, int h, int n) {
  int a = N*h*n;
  int b = 4*h*n - N*n - N*h;
  if(b == 0) return -1;
  else return (double) a / b;
}

/***** MAIN *****/
void Main() {
  int N;
  cin >> N;
  REPS(h,1,3500) {
    REPS(n,1,3500) {
      double w = calc(N, h, n);
      if(w > 0 && ceil(w) == w) {
        int w_tmp = w;
        COUTS(h); COUTS(n); COUTB(w_tmp);
        return;
      }
    }
  }
}
/***** MAIN *****/

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

int lcm(int a, int b) { return a / __gcd(a,b) * b;}

map<int,int> GetPrimeFactors(int n) {
  map<int,int> mp;
  // dived by 2, 3, 5, ...
  for(int i=2; i*i<=n; i+=2) {
    if(i==4) i = 3;
    while(n%i == 0) {
      ++mp[i];
      n /= i;
    }
  }
  if(n!=1) ++mp[n];

  return mp;
}

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

int Factorial(int n){
  int ans = 1;
  while(n > 1){
    ans *= n;
    --n;
  }
  return ans;
}

int npr(int n, int r) {
  return Factorial(n)/Factorial(n-r);
}

int ncr (int n, int r){
  return npr(n,r)/Factorial(r);
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#define int long long
int seg_tree[seg_size*4];
int seg_sub[seg_size*4];
int seg_set(int now,int cnt){
    if(seg_sub[now*2] != -10000){
        seg_tree[now*2] = seg_sub[now*2] * cnt;
        seg_sub[now*2*2] = seg_sub[now*2];
        seg_sub[now*2*2+1] = seg_sub[now*2];
        seg_sub[now*2] = -10000;
    }
    if(seg_sub[now*2+1] != -10000){
        seg_tree[(now*2+1)] = seg_sub[(now*2+1)] * cnt;
        seg_sub[(now*2+1)*2] = seg_sub[(now*2+1)];
        seg_sub[(now*2+1)*2+1] = seg_sub[(now*2+1)];
        seg_sub[(now*2+1)] = -10000;
    }
    seg_tree[now] = seg_tree[now*2] + seg_tree[now*2+1];
    if(now > 1){
        seg_set(now/2,cnt*2);
    }
    return 0;
}
int seg_find(int now,int n_l,int n_r,int w_l,int w_r){
    if(seg_sub[now] != -10000){
        seg_tree[now] = seg_sub[now] * (n_r - n_l);
        seg_sub[now*2] = seg_sub[now];
        seg_sub[now*2+1] = seg_sub[now];
        seg_sub[now] = -10000;
    }
    if(w_l <= n_l&&n_r <= w_r) return seg_tree[now];
    if(n_r <= w_l||w_r <= n_l) return 0;
    return seg_find(now*2,n_l,(n_l+n_r)/2,w_l,w_r)+seg_find(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r);
}
int seg_add(int now,int n_l,int n_r,int w_l,int w_r,int setting){
    if(seg_sub[now] != -10000){
        seg_tree[now] = seg_sub[now] * (n_r - n_l);
        seg_sub[now*2] = seg_sub[now];
        seg_sub[now*2+1] = seg_sub[now];
        seg_sub[now] = -10000;
    }
    if(w_l <= n_l&&n_r <= w_r){
        seg_sub[now] = setting;
        seg_set(now/2,n_r - n_l);
        return seg_tree[now];
    }
    if(n_r <= w_l||w_r <= n_l) return (1LL << 31LL) - 1LL;
    return min(seg_add(now*2,n_l,(n_l+n_r)/2,w_l,w_r,setting),seg_add(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r,setting));
}
#undef int
int main(){
#define int long long
    int n,m;
    cin >> n >> m;
    REP(i,seg_size*4){
        seg_tree[i] = 0;
        seg_sub[i] = -10000;
    }
    REP(i,m){
        int a;
        cin >> a;
        if(a == 0){
            int b,c,d;
            cin >> b >> c >> d;
            seg_add(1,0,seg_size,b,c+1,d);
        }else{
            int b,c;
            cin >> b >> c;
            cout << seg_find(1,0,seg_size,b,c+1) << endl;
        }
    }
}


Measured memory_bytes: 35876
import java.util.Arrays;
import java.util.Scanner;

/**
 * ABC118C
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        int min0 = A[0];
        int min = min0 + 1;
        int tmp = 0;
        while (tmp != min) {
            tmp = min;
            for (int i = 0; i < N; i++) {
                if (A[i] % min < min && A[i] % min != 0) {
                    min = A[i] % min;
                }
            }
        }

        System.out.println(min);

        sc.close();
    }
}

Measured memory_bytes: 49280
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long r, d, x;
int main(){
	scanf("%ld%ld%ld", &r, &d, &x);
	for(int i = 0; i < 10; i++){
		x = r * x - d;
		printf("%ld\n", x);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void juge(int *f,int *g,int *h);

void juge(int *f,int *g,int *h){
	if(*f<*g && *g<*h){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
}

int main(){
	int a,b,c;
	int *x,*d,*e;
	
	scanf("%d %d %d",&a,&b,&c);
	x = &a;
	d = &b;
	e = &c;
	
	juge(x,d,e);


return 0;
}


	

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if(s=="RRR") cout<<3<<"\n";
	else if(s=="RRS" || s=="SRR") cout<<2<<"\n";
	else if(s=="SSS") cout<<0<<"\n";
	else cout<<1<<"\n";
	return 0;
}

Measured memory_bytes: 3608
function main(input){
    input = input.split(' ')
    sx = parseInt(input[0], 10); sy = parseInt(input[1], 10)
    gx = parseInt(input[2], 10); gy = parseInt(input[3], 10)

    ans = ""
    for(var i = 0; i < (gy - sy); i++) ans = ans + 'U';
    for(var i = 0; i < (gx - sx); i++) ans = ans + 'R';
    for(var i = 0; i < (gy - sy); i++) ans = ans + 'D';
    for(var i = 0; i < (gx - sx) + 1; i++) ans = ans + 'L';
    for(var i = 0; i < (gy - sy) + 1; i++) ans = ans + 'U';
    for(var i = 0; i < (gx - sx) + 1; i++) ans = ans + 'R';
    ans = ans + 'D'; ans = ans + 'R'
    for(var i = 0; i < (gy - sy) + 1; i++) ans = ans + 'D';
    for(var i = 0; i < (gx - sx) + 1; i++) ans = ans + 'L';
    ans = ans + 'U'
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 26180
N = int(input())

# def make_array(shape, defval=0, dtype=int):
#     res = np.zeros(shape, dtype)
#     res[:] = defval
#     return res.tolist()


# memo = make_array((15, N + 1), N * 2)
memo = [[N * 2] * (N + 1) for _ in range(15)]
memo[0][0] = 0

values = []

i = 1
while i <= N:
    values.append(i)
    i *= 6
i = 9
while i <= N:
    values.append(i)
    i *= 9

for i in range(len(values)):
    v = values[i]
    for w in range(N + 1):
        if v > w:
            memo[i + 1][w] = memo[i][w]
        else:
            memo[i + 1][w] = min(memo[i][w], memo[i + 1][w - v] + 1)
print(memo[len(values)][N])

Measured memory_bytes: 25332
import java.util.Scanner;

class Main {
    
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int m, f, r;
    	
    	while(true) {
    		m = sc.nextInt();
    		f = sc.nextInt();
    		r = sc.nextInt();
    		
    		if(m == -1 && f == -1&& r == -1) break;
    		//System.out.println("");
    		
    		if(m == -1 || f == -1) {
    			System.out.println("F");
    		} else if(m + f >= 80) {
    			System.out.println("A");
    		} else if(m + f < 80 && m + f >= 65) {
    			System.out.println("B");
    		} else if(m + f < 65 && m + f >= 50) {
    			System.out.println("C");
    		} else if(m + f < 50 && m + f >= 30) {
    			if(r >= 50) {
    				System.out.println("C");
    			}else System.out.println("D");
    		} else if(m + f < 30) {
    			System.out.println("F");
    		}
    	}
    }
}


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

const ll MOD = 1'000'000'007;
const int LEN = 60;

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

  vector<bitset<LEN>> a;
  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    a.emplace_back(x);
  }

  vector<ll> c(LEN);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < LEN; ++j) {
      c[j] += a[i][j];
    }
  }

  auto f = [&](int i) {
    ll res = c[i] * (n - c[i]) % MOD;
    for (int j = 0; j < i; ++j) {
      res *= 2;
      res %= MOD;
    }
    return res;
  };

  ll ans = 0;
  for (int i = 0; i < LEN; ++i) {
    ans += f(i);
    ans %= MOD;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <pair <int, int> > p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first;
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i].second;
    }
    int ans = 0;
    for (int msk = 0; msk < (1 << n); msk++) {
        int cur = 0;
        for (int i = 0; i < n; i++) {
            if (msk & (1 << i)) {
                cur += p[i].first - p[i].second;
            }
        }
        ans = max(ans, cur);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/



void proc() {
	LOAD(int, N);
	LOAD(int, K);
	std::string S;
	cin >> S;
	S[K - 1] += 'a' - 'A';
	cout << S << endl;
}


#endif


Measured memory_bytes: 888
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

ans=0
anst=10e7
for i,j in enumerate(h):
    avg=t-j*0.006
    if anst>abs(a-avg):
        anst=abs(a-avg)
        ans=i+1
print(ans)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n;
    cin >> n;
    int cnt = 0;
    for (i = 1; i < n; i++) {
        cnt += (n-1) / i;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3648
s = int(input())
l = []

def calc(n):
  if n % 2 == 0:
    n = int(n/2)
  else:
    n = 3 * n + 1
  return n

for i in range(1000000):
  if i == 0:
    l.append(s)
  else:
    s = calc(l[i-1])
    if s in l:
      break
    else:
      l.append(s)
      
print(len(l)+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piiii pair<pii,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define logg2 0.30102999566398119521373889472449L
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=2e5;
ll dp[maxn+1][13];
ll p=1;
void solve(){
    string s;
    cin>>s;
    int n=s.size();
    s=' '+s;

    memset(dp,0,sizeof dp);
    if(s[n]=='?'){
        for(int i=0;i<=9;i++) dp[n][i]++;
    }
    else dp[n][s[n]-'0']++;
    for(int i=n-1;i>=1;i--){
        p=(p*10)%13;
        if(s[i]!='?') {
            int k=s[i]-'0';
            for(int j=0;j<=12;j++){
                dp[i][(j+k*p)%13]=(dp[i][(j+k*p)%13]+dp[i+1][j])%MAX;
            }
        }
        else{
            for(int k=0;k<=9;k++){
                for(int j=0;j<=12;j++){
                    dp[i][(j+k*p)%13]=(dp[i][(j+k*p)%13]+dp[i+1][j])%MAX;
                }
            }
        }
    }
    cout<<dp[1][5];
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 24052
s = input()
min_A = 200000
max_Z = 0
flag_A = False
for i in range(len(s)):
    if(flag_A==False and s[i] == 'A'):
        flag_A = True
        min_A = i
    if(s[i] == 'Z'):
        max_Z = i
print(max_Z-min_A + 1)


Measured memory_bytes: 3516
package main

import "fmt"

func main() {
	var N int
	var a int
	checkMap := make(map[int]bool)
	fmt.Scan(&N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if checkMap[a] {
			delete(checkMap, a)
		} else {
			checkMap[a] = true
		}
	}
	fmt.Print(len(checkMap))
}


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

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

        int answer = 1;
        for(int i = 0; i < n; ++i) {
                if(answer < k)
                        answer *= 2;
                else
                        answer += k;
        }
        cout << answer;
        return 0;
}

Measured memory_bytes: 256
import itertools
import collections

def check(itr_list,N):
    tmp = collections.Counter(itr_list)
    if tmp[3] > 0 and tmp[5] > 0 and tmp[7] > 0:
        s_N = ''
        for i in itr_list:
            s_N += str(i)
        if int(s_N) <= N:
            return True

    return False


S = input()
N = int(S)

tmp = [7,5,3]
ans = 0

for keta in range(3,len(S)+1):
    itr = []
    itr = list(itertools.product(tmp, repeat=keta))

    for i in itr:
        if check(i,N):
#            print(i)
            ans += 1
print(ans)


Measured memory_bytes: 6508
<?php



fscanf(STDIN,"%d",$N);
$takoyakis = explode(" ",trim(fgets(STDIN)));

$sum = 0;

for($i=0;$i<=$N;$i++){
    for($j=0;$j<$N;$j++){
        if($i<$j){
            $sum += $takoyakis[$j]*$takoyakis[$i];
        }
    }
}

echo $sum."\n";


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


int main() 
{
    int N;
    int A[2][100];
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[0][i];
    for (int j = 0; j < N; j++)
        cin >> A[1][j];

    int max = 0;

    for (int k = 0; k < N; k++)
    {
        int sum = 0;
        for (int a = 0; a <= k; a++)
        {
            sum = sum + A[0][a];
        }
        for (int b = k; b < N; b++)
        {
            sum = sum + A[1][b];
        }

        if (sum > max)
            max = sum;
    }

    cout << max;

    return 0;
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r,t){"use strict";e.exports=function(e){var r=Number(e[0]),t=e[1].split(" ").map(function(e){return Number(e)}),n=0,o=1,u=t[0];function i(e,r){return(e^t[r])==(e|t[r])}for(var f=0;f<r;f++){for(;i(u,o)&&o<r;)u^=t[o],o++;f!=o?(n+=o-f,u^=t[f]):o++}console.log(n)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 22256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    string S;cin>>S;
    bool f=true;
    while(true){
        int n = S.size();
        //cerr << n << "\t" << S << endl;
        if(n<5){
            if(n!=0){f=false;}
            break;
        }
        if(S.rfind("dream")+5==n && std::string::npos!=S.rfind("dream")){
            //cerr << "aaaa" << S.rfind("dream") << endl;
            S = S.erase(S.rfind("dream"));
        }else if(S.rfind("dreamer")+7 == n && std::string::npos!=S.rfind("dreamer")){
            //cerr << "iiii" << S.rfind("dreamer") << endl;
            S = S.erase(S.rfind("dreamer"));
        }else if(S.rfind("erase")+5==n && std::string::npos!=S.rfind("erase")){
            //cerr << "uuuu" << S.rfind("erase") << endl;
            S = S.erase(S.rfind("erase"));
        }else if(S.rfind("eraser")+6==n && std::string::npos!=S.rfind("eraser")){
            //cerr << "eeee" << S.rfind("eraser") << endl;
            S = S.erase(S.rfind("eraser"));
        }else{
            //cerr << "oooo" << endl;
            f=false;
            break;
        }
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
#coding:utf-8
n, t_u = map(int,input().split())
name_pro_dict = {}
for i in range(n):
    name, pro = input().split()
    name_pro_dict[name] = int(pro)

t = 0
while name_pro_dict:
    keys = list(name_pro_dict.keys())
    for key in keys:
        if name_pro_dict[key] <= t_u:
            t += name_pro_dict[key]
            print(key, t)
            del name_pro_dict[key]
        else:
            name_pro_dict[key] -= t_u
            t += t_u
            


Measured memory_bytes: 11888
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

typedef vector<char> vc;
typedef vector<vc> Pic;

class Bit{
	int bit;
	public:
	Bit() : bit(0) { }
	bool at(int i, int j){
		return ( bit >> (i * 4 + j) ) & 1;
	}
	void set(int i, int j){
		bit |= 1 << (i * 4 + j);
	}
	int get(){
		return bit;
	}
};

const char color[] = {'R', 'G', 'B'};

bool canDelete(Pic& pic, Bit& b, pair<int, int> s, int y, int x, char c){
	bool f = false;
	range(i,y,y + s.first){
		range(j,x,x + s.second){
			if(i < 0 or j < 0 or i >= 4 or j >= 4) continue;
			if(not b.at(i,j)) f = true;
			if(pic[i][j] != c and not b.at(i,j)) return false;
		}
	}
	return f;
}
void output(Bit b){
}

Bit getUpdatedBit(Bit& b, pair<int, int> s, int y, int x){
	Bit res = b;
	range(i,y,y + s.first){
		range(j,x,x + s.second){
			if(i < 0 or j < 0 or i >= 4 or j >= 4) continue;
			res.set(i,j);
		}
	}
	return res;
}

struct P{
	int cnt;
	Bit bit;
	P(int cnt, Bit bit) : cnt(cnt), bit(bit) {}
	bool operator < ( const P &right ) const {
		return cnt < right.cnt;
	}
	bool operator > ( const P &right ) const {
		return cnt > right.cnt;
	}
};

void bfs(vector<pair<int, int>>& stamps, Pic& pic){
	priority_queue<P, vector<P>, greater<P>> q;
	//queue<P> q;
	q.emplace(0, Bit());

	vector<int> dis(1 << 16, 1e9);
	dis[0] = 0;

	while(not q.empty()){
		P tmp = q.top(); q.pop();

		Bit b = tmp.bit;
		int cnt = tmp.cnt;


		//if(dis.at(b.get()) <= cnt) continue;
		//dis[b.get()] = cnt;

		if((1 << 16) - 1 == b.get()){
			cout << cnt << endl;
			return;
		}

		rep(c,3){
			rep(i,stamps.size()){
				range(y, 1 - stamps[i].first, 4){
					range(x, 1 - stamps[i].second, 4){
						if(canDelete(pic, b, stamps[i], y, x, color[c])){
							Bit tmp = getUpdatedBit(b, stamps[i], y, x);
							if(dis.at(tmp.get()) > cnt + 1){
								dis[tmp.get()] = cnt + 1;
								q.emplace(cnt + 1, getUpdatedBit(b, stamps[i], y, x));
							}
						}
					}
				}
			}
		}
	}
}

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

	vector<pair<int, int>> stamps(n);
	rep(i,n){
		cin >> stamps[i].first >> stamps[i].second;
	}

	Pic pic(4, vc(4));
	rep(i,4) rep(j,4) cin >> pic[i][j];

	bfs(stamps, pic);
}



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

const int MAX = 100;
const int INFINITY = 2 << 21;
int n;
int G[MAX][MAX];
int distances[MAX];
int states[MAX];

void dijkstra() {
  int id = 0;
  distances[id] = 0;

  while (1) {
    int min = INFINITY;

    for (int i = 0; i < n; i++) {
      if (states[i] == 0 && distances[i] < min) {
        min = distances[i];
        id = i;
      }
    }

    if (min == INFINITY) break;

    for (int i = 0; i < n; i++) {
      if (states[i] != 0 || G[id][i] == -1) continue;
      if (distances[id] + G[id][i] < distances[i]) {
        distances[i] = distances[id] + G[id][i];
      }
    }

    states[id] = 1;
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (distances[i] == INFINITY ? -1 : distances[i]) << endl;
  }
}

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

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) G[i][j] = INFINITY;
  }

  int u, k, v, c;
  for (int i = 0; i < n; i++) {
    distances[i] = INFINITY;
    states[i] = 0;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      G[i][v] = c;
    }
  }

  dijkstra();

  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> pn;


    for (int a = 0; a < n; ++a) {
        int t;
        cin >> t;

        pn.push_back(t);
    }


    int count = 0;
    int min_value = 1145141919;
    for (int a = 0; a < n; ++a) {
        if(min_value > pn[a]){
            min_value = pn[a];
            ++count;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1400
from sys import stdin
A,B = [int(x) for x in stdin.readline().rstrip().split()]

def f(n):
    res = 0
    tmp = 1
    while tmp <= n:
        tmp *= 2
        num = ((n+1)//tmp)*(tmp//2)
        num += max(0,(n+1)%tmp - tmp//2)
        if num % 2 != 0:
            res += (tmp//2)
    return res

print(f(A-1)^f(B))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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


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

	ll x, k, d;
	cin >> x >> k >> d;
	//vector<int> l(n);
	//rep(i,n) {cin >> l[i];}

	long double xd = x, kd = k, dd = d;

	if (abs(xd) > round(kd*dd)) { cout << abs(x) - abs(k * d) << endl; }
	else { if ((k - abs(x) / d) % 2 == 0) cout << abs(x) % abs(d) << endl; else cout << abs(abs(x) % abs(d) - d) << endl; }

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n,k;cin>>n>>k;
  string s;cin>>s;

  int dif = 0;
  int count = 1;
  ll ans = 0;
  REP(i,n-1){
    if(s[i]!=s[i+1]){
      dif++;
      ans += count-1;
      count = 1;
    }else{
      count++;
    }
  }
  ans += count-1;

  if(k>=dif/2){
    ans += (int)(dif/2) * 2;
    if(k>dif/2&&dif % 2 == 1){
      ans++;
    }
  }else{
    ans += k * 2;
  }

  cout<<ans<<endl;


 

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>
#include<tuple>

using namespace std;

#define reep(i, s, n) for(int i=s;i<(int)n;i++)
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define REP(i, n) for(int i=0;i<(int)n;i++)
#define all(v) v.begin(), v.end()
#define tyd typedef
#define vc vector
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int INF = 1<<28;	

int T, n, m, nat, len;

struct UnionFind{
	vector<int> d;
	UnionFind(int n):d(n, -1){}
	bool unite(int x, int y){
		if((x = root(x)) != (y = root(y))){
			if(d[y] < d[x]) swap(x, y);
			d[x] += d[y]; d[y] = x;
		}
		return x != y;
	}
	int root(int x){return d[x] < 0 ? x : d[x] = root(d[x]);}
};

vi bfs(const vector<vi> &g, vi s){
	vi dp(n+1, INF);
	queue<int> q;
	for(int u : s){
		q.push(u);
		dp[u] = 0;
	}
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int v : g[u])if(dp[u]+1 < dp[v]){
			q.push(v);
			dp[v] = dp[u] + 1;
		}
	}
	return dp;
}


int main(){
	cin >> T;
	while(T--){
		cin >> n >> m >> nat >> len;
		vector<vi> g(n+1);
		UnionFind uf(n+1);
		REP(i, m){
			int u, v; char c;
			cin >> u >> v >> c;
			if(c == 'N'){
				g[u].pb(v);
				g[v].pb(u);
			}else{
				uf.unite(u, v);
			}
		}
		if(uf.root(0) == uf.root(len)){
			puts("0");
			continue;
		}
		vi s1, s2;
		REP(i, n+1) if(uf.root(i) == uf.root(len)) s1.pb(i);
		REP(i, n+1) if(uf.root(i) == uf.root(0)) s2.pb(i);
		auto d1 = bfs(g, s1);
		auto d2 = bfs(g, s2);
		auto d3 = bfs(g, vi({nat}));
		REP(i, n)if(uf.root(i) == 0){
			d1[i] = d1[0];
			d2[i] = d2[0];
			d3[i] = d3[0];
		}
//		cout << "uf: " ;REP(i, n+1) cout << uf.root(i) << ", "; cout << endl;
//		cout << "d1: " ;REP(i, n+1) cout << d1[i] << ", "; cout << endl;
//		cout << "d2: " ; REP(i, n+1) cout << d2[i] << ", "; cout << endl;
//		cout << "d3: " ; REP(i, n+1) cout << d3[i] << ", "; cout << endl;
		int ans = INF;
		REP(i, n) ans = min(ans, d1[i] + d2[i] + d3[i]);
		if(ans < INF) printf("%d\n", ans);
		else puts("-1");
	}
	return 0;
	
}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        int x; cin >> x;
        v[i]=x;
    }
    long long ans=0;
    for(int l=0;l<=K;l++){ //左からいくつ取るかを決定
        for(int r=0;r<=K-l;r++){ //右からいくつ取るかを決定
            if(l+r>N) continue;
            int d=K-l-r; //捨てる個数
            vector<int> t(N);
            long long tmp=0;
            for(int i=0;i<l;i++){ //左からl個までをtに追加
                tmp+=v[i];
                t.push_back(v[i]);
            }
            for(int i=N-r;i<N;i++){ //右からr個をtに追加
                tmp+=v[i];
                t.push_back(v[i]);
            }
            sort(t.begin(),t.end());
            for(int i=0;i<d;i++){ //負の数をd個まで捨てる
                if(i>=t.size()) break;
                if(t[i]>0) break;
                tmp-=t[i];
            }
            ans=max(tmp,ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

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

  int n;
  cin >> n;
  ++ n;
  cout << n / 2 << endl;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut r = String::new();
    stdin().read_line(&mut r).unwrap();
    println!("{}", match r.trim().parse::<i32>().unwrap() {
        R if R < 1200 => "ABC",
        R if R < 2800 => "ARC",
        _             => "AGC",
    });
}


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

class Stack {
  private :
    long data[1000];
    int top;
  public :
    Stack(){data[0]={0};top=0;};
    long pop(){top--;return data[top+1];};
    void push(long x){data[++top]=x;};
};

int main(){
  Stack s;
  int a,b;
  char c[100];
  while(scanf("%s",c)!=EOF){
    switch(c[0]){
      case '+':
        a=s.pop();
        b=s.pop();
        s.push(a+b);
        break;
      case '*':
        a=s.pop();
        b=s.pop();
        s.push(a*b);
        break;
      case '-':
        a=s.pop();
        b=s.pop();
        s.push(b-a);
        break;
      default :
        s.push(atoi(c));
        break;
    }
  }
  cout << s.pop() << endl;
      
  return 0;
}


Measured memory_bytes: 3232
import java.io.*
import java.util.*

fun solve(s: String){
    val l = s.length - 2
    print(s[0])
    print(l)
    println(s.last())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val s = sc.next()
    solve(s)
}



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

using namespace std;

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

    int original = 0;
    for (int i = 1; i <= n; ++i)
        original += l + i - 1;

    int after_eat = original - (l + 1 - 1);
    for (int i = 2; i <= n; ++i) {
        int tmp = original - (l + i - 1);

        if (abs(original - after_eat) > abs(original - tmp))
            after_eat = tmp;
    }
    cout << after_eat << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;
 
const int K = 38;
const int N = K * (K - 1) + 1;

int c[N][N];

int check()
{
	for (int i = 0; i < N; i ++)
	{
		int aa = 0, bb = 0;
		for (int k = 0; k < N; k ++)
		{
			aa += c[i][k];
			bb += c[k][i];
		}
		if (aa != K || bb != K) return 0;
	}

	for (int i = 0; i < N; i ++)
	{
		int used[N];
		for (int k = 0; k < N; k ++)
			used[k] = 0;

		for (int k = 0; k < N; k ++)
			if (c[i][k])
			{
				for (int j = i + 1; j < N; j ++)
					if (c[j][k])
					{
						used[j] ++;
						if (used[j] >= 2) return 0;
					}
			}
	}
	return 1;
}

void Work()
{
	printf("%d %d\n", N, K);
	for (int i = 0; i < K; i ++)
	{
		c[i][0] = c[0][i] = 1;
		for (int j = 0; j < K - 1; j ++)
			c[i][j + (K - 1) * i + 1] = c[j + (K - 1) * i + 1][i] = 1;
	}
	for (int i = 0; i < K - 1; i ++)
		for (int j = 0; j < K - 1; j ++)
		{
			int si = K + (K - 1) * i;
			int sj = K + (K - 1) * j;
			int delta = i;
			//c[si][sj] = 5;
			for (int ii = 0; ii < K - 1; ii ++)
				c[si + ii][sj + (ii + delta * j) % (K - 1)] = 1;
		}
	
	if (! check()) while (1);

	for (int i = 0; i < N; i ++)
	{
		for (int j = 0; j < N; j ++)
			if (c[i][j])
				printf("%d ", j + 1);
		printf("\n");
	}

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

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

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

int main(){
    int n; string str; int s[50] = {0}; int s2[50];
    for (int i = 0; i < 50; i++)
        s2[i] = 50;
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> str;
        for (int j = 0; j < str.size(); j++)
            s[str[j] - 'a'] += 1;
        for (int j = 0; j < 50; j++){
            s2[j] = min(s2[j], s[j]);
            s[j] = 0;
            }
    }
    for (int i = 0; i < 50; i++){
        for(int j = 0; j < s2[i]; j++)
            cout << char(i + int('a'));
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a,s=1e9,c;
main(){
  cin>>n;
  for(;cin>>a;){
    c=0;
    while(a%2<1)c++,a/=2;
    s=s<c?s:c;
  }
  cout<<s<<endl;
}

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

using namespace std;

const int maxn = 50 + 2;

int n , a[maxn] , P;
long long dp[maxn][2];

int main( int argc , char * argv[] ){
	cin >> n >> P;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> a[i],
		a[i]%=2;
	dp[0][0] = 1;
	for(int i = 0 ; i < n ; ++ i)
		for(int j = 0 ; j < 2 ; ++ j){
			dp[i + 1][j] += dp[i][j];
			int z = (j + a[i + 1]) %2;
			dp[i + 1][z] += dp[i][j];
		}
	cout << dp[n][P] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;

	//IntStack yStack;
	//charStack Stack;

	cin >> a;
	cin >> b;
	cin >> c;
	cout << min(b, c) << endl;
	cout<<max(-a+(b+c),ll(0))<<endl;
	//cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

MAX = 10000
eat = 10000
for i in range(1, N+1):
    if abs(L+i-1) < MAX:
        MAX = abs(L+i-1)
        eat = L + i - 1

num = [L+i-1 for i in range(1, N+1)]
result = sum(num)
print(result-eat)


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

long double dp[303][303][303];

long double solve(int a, int b, int c, int N)
{
    if(a + b + c == 0)
        return 0;
    
    if(dp[a][b][c] > -0.5)
        return dp[a][b][c];
    
    long double ans = N;
    
    if(a >= 1)
        ans += solve(a-1, b, c, N) * a;
    if(b >= 1)
        ans += solve(a+1, b-1, c, N) * b;
    if(c >= 1)
        ans += solve(a, b+1, c-1, N) * c;
    
    return dp[a][b][c] = ans / (a + b + c);
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    int a = 0, b = 0, c = 0;
    
    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        
        a += (x == 1), b += (x == 2), c += (x == 3);
    }
    
    for(int i=0; i<=N; i++)
        for(int j=0; j<=N; j++)
            for(int k=0; k<=N; k++)
                dp[i][j][k] = -1;
    
    cout << fixed << setprecision(12) << solve(a, b, c, N) << "\n";
    return 0;
}

Measured memory_bytes: 432512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int H,W;
  cin >> H>>W;
  vector<vector<char>> data(H, vector<char>(W));
  rep(i,H) {
    rep(j,W) {
      cin >> data.at(i).at(j);
    }
  }
 
  vector<bool> h(H);
  for (int i = 0; i < H; i++) {
    h.at(i)=false;
    for (int j = 0; j < W; j++) {
      if(data.at(i).at(j)=='#'){
        h.at(i)=true;
      }
    }
  }
  vector<bool> w(W);
  for (int i = 0; i < W; i++) {
    w.at(i)=false;
    for (int j = 0; j < H; j++) {
      if(data.at(j).at(i)=='#'){
        w.at(i)=true;
      }
    }
  }
  
  rep(i,H){
    if(h.at(i)){
      rep(j,W){
        if(w.at(j)){
          cout<<data.at(i).at(j);
        }
      }
      cout<<endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
const int maxn = 2e5+10;

int main(){
    int n,a[maxn],num[maxn];
    cin>>n;
    for(int i = 2;i <= n;i++){
        cin>>a[i];
        num[a[i]]++;
    }
    for(int i = 1;i <= n;i++){
        cout<<num[i]<<endl;
    }
    return 0;
}


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


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

  
  int ans=100000000;
  for(int p=0;p<=100;p++){
    int sum=0;
    for(int i=0;i<n;i++){
     sum+=(x[i]-p)*(x[i]-p);
    }
    if(ans>sum){
      ans=sum;
    }
  }

  cout<<ans<<endl;
  
}


Measured memory_bytes: 256