akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int sum = 0;
  int A[N];
  for(int i=0;i<N;++i) {
    cin>>A[i];
    sum += A[i];
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(4*M*A[i]>=sum) ans++;
  }
  if(ans>=M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a + b + c >= 22) {
		cout << "bust" << "\n";
	}
	else {
		cout << "win" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#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];
  sort(p.begin(),p.end());
  long long ans=0;
  for(int i=0;i<k;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,A,T=0,R=1000;
	cin >> N;
	
	for (int i=0;i<N;i++){
		cin >> A;
		while (A%2 == 0) {
			A /= 2;
			T += 1;
		}
		
		if (T < R){
			R = T;
		}
		
		T = 0;
	}
	
	cout << R << endl;
}

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

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

  int n;

  cin >> n;

  vector<int> ans(n + 1);

  for (int i = 0; i < n - 1; i++) {
    int tmp;
    cin >> tmp;
    ans[tmp]++;
  }

  for (int i = 1; i < n + 1; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 4052
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	 char s[1000];
	 while(scanf("%s",s)!=EOF)
	 {  int flag=0,count=0,count1=0;
	 	  int len=strlen(s);
	     
	 	  if(s[0]=='A')
	 	  {    
	 	     
	 	  	for(int i=2;i<len-1;i++)
	 	  	  {if(s[i]=='C')count++;
	 	  	  
				 }
				 for(int i=1;i<len;i++)
					 if(isupper(s[i]))count1++;
				  
	 	  	  if(count==1&&count1==1)
	 	  	  printf("AC\n");
	 	  	  else
	 	  	  printf("WA\n");
				  
		   }
		   else
		   {
		   	 printf("WA\n");
		   }
	 }
	
}

Measured memory_bytes: 128
x,y,z,k = map(int,input().split())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))

Alist.sort(reverse=True)
Blist.sort(reverse=True)
Clist.sort(reverse=True)

ABlist = [i + j for i in Alist[:k] for j in Blist[:k]]

ABlist.sort(reverse=True)

ABClist = [l + m for l in ABlist[:k] for m in Clist[:k]]

ABClist.sort(reverse=True)

print(*ABClist[:k], sep = '\n')


Measured memory_bytes: 206136
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
long long int t,c;

int main()
{
	cin >> t >> c;
	if(t <= c) cout << "Yes" << endl;
	else {
		if(t % 500 <= c)cout << "Yes" <<endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H
        else:
            continue


Measured memory_bytes: 2696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    int x;
    int ans = 0;
    rep(i, 0, N)
    {
        cin >> x;
        ans += min(x, K - x) * 2;
    }
    cout << ans << endl;
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

int h, w;
char arr[10][10] = {};

bool dfs(int y, int x)
{
    if (y == h && x == w)
    {
        // cout << "aaa" << endl;
        return true;
    }
    else
    {
        bool f = false;
        if (x + 1 <= w && arr[y][x + 1] == '#')
            f |= dfs(y, x + 1);
        if (y + 1 <= h && arr[y + 1][x] == '#')
            f |= dfs(y + 1, x);
        return f;
    }
}

signed main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < w; j++)
            arr[i + 1][j + 1] = tmp[j];
    }
    bool f = true;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (i - 1 >= 1 && j + 1 <= w)
            {
                if (arr[i][j] == '#' && arr[i - 1][j + 1] == '#')
                    f = false;
            }
        }
    }
    if (dfs(1, 1) && f)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

D, G = list(map(int, sys.stdin.readline().split()))
P, C = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(D)]))

P = np.array(P, dtype=int)
C = np.array(C, dtype=int)
A = np.arange(1, D + 1, dtype=int) * 100  # 1問のスコア
comp_scores = P * A + C

# ans = P.sum()
# for i in range(D):
#     # i: 途中まで解く
#     # comp: True ならその問題は全部解く
#     for comp in itertools.product([True, False], repeat=D):
#         comp = np.array(comp)
#         comp[i] = False
#         cnt = P[comp].sum()
#         score = comp_scores[comp].sum()
#         add_cnt = max(0, min(P[i] - 1, math.ceil((G - score) / A[i])))
#         add_score = A[i] * add_cnt
#         if score + add_score >= G:
#             ans = min(ans, cnt + add_cnt)
# print(ans)


ans = P.sum()
for i in range(D):
    # i: 途中まで解く
    # True なら全部解く、False なら 1 問も説かない
    patterns = np.array(list(itertools.product([True, False], repeat=D)))
    patterns[:, i] = False
    cnt = np.dot(patterns, P)
    score = np.dot(patterns, comp_scores)
    add_cnt = np.maximum(0, np.minimum(P[i] - 1, np.ceil((G - score) / A[i])))
    add_score = A[i] * add_cnt
    ok = score + add_score >= G
    if any(ok):
        ans = min(ans, ((cnt + add_cnt)[ok]).min())
print(int(ans))


Measured memory_bytes: 12532
#include <stdio.h>

int main(void)
{
  int n;
  int a[10000];
  int i,j,k;
  int minj;
  int temp;
  int cnt=0;

  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%d",&a[i]);
  }

  for (i=0; i<n; i++) {
    minj=i;
    for (j=i; j<n; j++) {
      if (a[j]<a[minj]) {
        minj=j;
      }
    }
    if (minj!=i) {
      temp=a[minj];
      a[minj]=a[i];
      a[i]=temp;
      cnt++;
    }
  }

  for (i=0; i<n; i++) {
    if (i!=n-1) printf("%d ",a[i]);
    else printf("%d\n",a[i]);
  }
  printf("%d\n",cnt);


  return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<long long> A;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    /*
    cout << "A: " << A << endl;
    for (auto a: A)
        cout << bitset<31>(a) << endl;
    */
    int m = 62;
    vector<int> B(m, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (A[i] & (1ll<<j))
                B[j]++;
        }
    }
    /*
    for (int i = 0; i < m; i++)
        cout << "B[" << i << "]; " << B[i] << endl;
    */
    long long ans = 0;
    for (int i = 0; i < m; i++) {
        long long val = (1ll<<i) % mod * B[i] % mod * (n - B[i]) % mod;
        ans = (ans + val) % mod;
    }
    cout  << ans << endl;
    return 0;
}


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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    int p = 0;
    for(int i=0;i<s.size();++i) {
        if(s[i]=='B') continue;
        ans += i-p;
        p++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
Int solve(){
  Int n,m;
  cin>>n>>m;
  if(n==m) return 0;

  Int a=0,b=1;
  while(m/2){
    assert(n<=m);
    Int x=m/2;
    // (x, m]
    if(x<n){
      return (~(m-n)&1)?a:b;
    }
    Int p=(x*2==m)?a:b;
    Int q=(~(m-(x+1))&1)?a:b;
    set<Int> ss;
    ss.emplace(p);
    ss.emplace(q);
    Int na=0;
    while(ss.count(na)) na++;

    if(x==1){
      assert(n==1);
      return na;
    }

    set<Int> st;
    st.emplace(p);
    st.emplace(na);
    Int nb=0;
    while(st.count(nb)) nb++;

    a=na;
    b=nb;
    m=x;
  }
  assert(0);
}

signed main(){
  Int t;
  cin>>t;
  Int ans=0;
  while(t--) ans^=solve();
  cout<<(ans?"mo3tthi":"tubuann")<<endl;
  return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define mod 1000000007
#define MAXN 200001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void next(string a,vector<string> &s)
{
    int len = a.length();
    int last_digit = a[len-1]-'0';
    string p,q,r;
    p = a;
    q = a;
    r = a;
    if(last_digit == 0)
    {
        p.pb('0');
        q.pb('1');
        s.pb(p);
        s.pb(q);
        return;
    }
    if(last_digit == 9)
    {
        p.pb('8');
        q.pb('9');
        s.pb(p);
        s.pb(q);
        return;
    }
    p.push_back(last_digit-1+'0');
    q.pb(last_digit+'0');
    r.pb(last_digit+1+'0');
    s.pb(p);
    s.pb(q);
    s.pb(r);
}

void solve()
{
    int k;
    cin>>k;
    vector<string> s;
    s.pb("1");
    s.pb("2");
    s.pb("3");
    s.pb("4");
    s.pb("5");
    s.pb("6");
    s.pb("7");
    s.pb("8");
    s.pb("9");
    int i = 0;
    while(s.size() < k)
    {
        next(s[i],s);
        i++;
    }
    // for(int i = 0 ; i < k ;i++)
    cout<<s[k-1]<<endl;
}

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

Measured memory_bytes: 6900
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    /**
     * A to Z String
     * @param 1 ≦ |s| ≦ 200,000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            String s = sc.next();
            String array[] = s.split("");
            int a = -1;
            int z = 0;
            for (int i = 0; i < array.length; i++) {
                if (a < 0) {
                    if (array[i].equals("A")) {
                        a = i;
                    }
                } else {
                    if (array[i].equals("Z")) {
                        z = i;
                    }
                }
            }
            System.out.println(z - a + 1);
        }
    }
}

Measured memory_bytes: 53300
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <ctype.h>
#include <cmath>
#include <iomanip>
#include <ios>
#include <set>

using namespace std;

int main(void){
    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2;
    
    return 0;
}




Measured memory_bytes: 256
s = input()
n = len(s)

a = [0] * (n + 1)

for i in range(n):
    if s[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
for i in range(n - 1, -1, -1):
    if s[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)

print(sum(a))


Measured memory_bytes: 28884
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 1000005

const int INF = 1e9+7;


/*素数のみの配列を返す*/
vector<ll> Eratosthenes(ll n,vector<ll>& arr){
 
    for(ll i = 0; i < n;i++){
        arr[i] = 1;
    }
 
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    vector<ll> prime;
    for(int i = 2;i < arr.size();i++){
        if(arr[i]){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){


    vector<ll> prime(ARRAY_MAX,0);
    prime = Eratosthenes(1e6,prime);
    
    for(int i = 0;i < prime.size()-1;i++){
        prime[i+1] += prime[i];
    }
    ll n;
    while(cin >> n,n){

        cout << prime[n-1] << endl;
    }








    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    vector<vector<int>> c(100000,vector<int>());
    for(int i=0;i<m;i++){
        int p,y;
        cin>>p>>y;
        p--;
        v[i]=make_pair(p,y);
        c[p].push_back(y);
    }
    for(int i=0;i<n;i++) sort(c[i].begin(),c[i].end());
    for(int i=0;i<m;i++){
        int p=v[i].first;
        int y=find(c[p].begin(),c[p].end(),v[i].second)-c[p].begin();
        p++;
        y++;
        printf("%06d%06d\n",p,y);
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,k;
	cin>>n>>k;

	vector<lli> h(n);
	REP(i,0,n)cin>>h[i];
	sort(h.begin(),h.end());

	lli ans = INF;
	REP(i,0,n-k+1){
		ans = min(ans,h[i+k-1]-h[i]);
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

int main()
{
    int n, h, w;
    ci >> n >> h >> w;

    int a, b;
    
    rep(i, n) {
	ci >> a >> b;

	if(a >= h && b >= w) cnt++;
    }


    co << cnt << en;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define love emplace_back
using vi=vector<int>;
template<class T> void I_love(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,s;
  cin>>n>>k>>s;
  vi MIIHI;
  rep(i,k) MIIHI.love(s);
  if(s==1000000000) rep(i,n-k) MIIHI.love(1);
  else rep(i,n-k) MIIHI.love(s+1);
  I_love(MIIHI);
}


Measured memory_bytes: 2296
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a;
	cin>>a;
	int out=0;

	loop(i,1,a+1){
        int c=a/i;
        out+=c*(c+1)/2*i;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int N = 0;
	int K = 0;
	int kosuu = 0;
	int max, min = 0;
	int total = 0;


	scanf("%d %d", &N, &K);

	kosuu = N - K;

	max = kosuu + 1;
	min = 1;

	total = max - 1;
	if (K == 1)
	{
		printf("%d\n", 0);
	}
	else
	{
		printf("%d\n", total);
	}

	return 0;

}


Measured memory_bytes: 128
N, Q = map(int, input().split())
S = input()
Sum = [0]*(N+1)
for i in range(N-1):
	if S[i] == 'A' and S[i+1] == 'C':
		Sum[i+1] = Sum[i] + 1
	else:
		Sum[i+1] = Sum[i]
Sum[-1] = Sum[-2]

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


Measured memory_bytes: 6060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N;
    vector<int> X;
    cin >> N;
    X.resize(N);
    for (int i=0; i<N; i++) cin >> X[i];

    // resolve
    double ave;
    for (int i=0; i<N; i++) {
        ave += X[i];
    }
    ave /= N;
    int avei = round(ave);
    ll ans = 0;
    for (int i=0; i<N; i++) {
        ans += pow((X[i]-avei),2);
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int a[100005];
Int b[100005];

int main(){
    cin.tie(0);

    Int N; cin >> N;
    Int SUM = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        SUM += a[i];
    }
    for (int i = 0; i < N; i++){
        if (i == N-1){
            b[i] = a[0] - a[i];
            continue;
        }
        b[i] = a[i+1] - a[i];
    }
    if (SUM % ((N+1)*N/2)){
        cout << "NO" << endl;
        return 0;
    }
    Int CNT = SUM / ((N+1)*N/2);
    for (int i = 0; i < N; i++){
        b[i] -= CNT;
    }
    Int cnt = 0;
    for (int i = 0; i < N; i++){
        if (b[i] <= 0){
            if (b[i] % (-N) == 0){
            cnt += b[i] / (-N);
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    if (cnt > CNT){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 2424
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+9;
typedef long long ll;
int a[N];
ll ans,n;
int main(){
  cin>>n;
  for(int i=1;i<=n+1;i++)cin>>a[i];
  for(int i=1,t;i<=n;i++){
    cin>>t;
    if(t<=a[i]){ans+=t;continue;}
    ans+=a[i];t-=a[i];
    if(t<=a[i+1]){ans+=t,a[i+1]-=t;continue;}
    ans+=a[i+1],a[i+1]=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
 int getgcd(int n, int m)
 {
 int r;
 if (n > m) {
 int t = m;
 m = n;
 n = t;
 }
 while ((r = m % n) != 0) {
 m = n;
 n = r;
 }
 return n;
 }
int main(int argc, const char * argv[]) {
 
 
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    /////////////////////
    int k,a,b,c,gcd,sum = 0;
    
    cin >>k;
    
    for(a = 1;a <= k;a++){
        for(b =1;b <=k;b++){
            for(c = 1;c <=k;c++){
                gcd = getgcd(getgcd(a,b),c);
                sum += gcd;
                
            }
        }
        
    }
    printf("%d\n",sum);
    
    
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 500;
char lis[MAX][MAX];

int main() {
    
    ll h,w;
    cin >> h >> w;
    for (ll i=0;i<h;i++){
        string s;
        cin >> s;
        for (ll j=0;j<w;j++){
            lis[i][j] = s[j];
        }
    }
    for (ll i=0;i<h;i++){
        if(i%2 == 0){
            for (ll j=0;j<w-1;j++){
                cout << '#';
            }
            cout << '.';
            cout << endl;
        }else{
            for (ll j=0;j<w;j++){
                if(j==0){
                    cout << '#';
                }else{
                    cout << lis[i][j];
                }
            }
            cout << endl;
        }
    }
    cout << endl;

    for (ll i=0;i<h;i++){
        if(i%2 == 1){
            cout << '.';
            for (ll j=1;j<w;j++){
                cout << '#';
            }
            cout << endl;
        }else{
            for (ll j=0;j<w;j++){
                if(j==w-1){
                    cout << '#';
                }else{
                    cout << lis[i][j];
                }
            }
            cout << endl;
        }
    }
    cout << endl;


}




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

int n,m;
string str;
int p[MAXN][2],id[MAXN],cover[MAXN];
string f[MAXN],g[MAXN],s[MAXN];

void init(){
	int na=0,nb=0;
	for(int i=1;i<=m;i++){
		if(str[i]=='a') p[id[i]=++na][0]=i;
		else p[id[i]=++nb][1]=i;
	}
	for(int i=1;i<=n;i++)
		if(p[i][0]>p[i][1])
			swap(p[i][0],p[i][1]);
	for(int i=1;i<=n;i++){
		if(str[p[i][0]]=='a'){
			for(int j=i;j<=n && p[j][0]<=p[i][1];j++)
				cover[i]=j;
		}else{
			int cur=p[i][1];
			cover[i]=i;
			for(int j=i+1;j<=n && p[j][0]<=cur;j++){
				cover[i]=j;
				cur=p[j][1];
			}
			for(int j=p[i][0];j<=p[cover[i]][1];j++)
				if(id[j]>=i)
					s[i].push_back(str[j]);
		}
	}
}

void dp(){
	for(int i=n;i>=1;i--){
		if(str[p[i][0]]=='a'){
			f[i]="ab"+g[cover[i]+1];
		}else{
			f[i]=s[i]+g[cover[i]+1];
		}
		g[i]=max(f[i],g[i+1]);
	}
}

int main(){
#ifdef DEBUG
	freopen("C.in","r",stdin);
#endif
	cin>>n;
	m=n<<1;
	cin>>str;
	str=" "+str;
	init();
	dp();
	cout<<g[1]<<endl;
}


Measured memory_bytes: 16384
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var comb = input.split('\n');
 
var set;
while (set = comb.shift()) {
    var count = 0;
    var num = +set;
    for (var i1 = 0; i1 <= 9; i1++){
    	for (var i2 = 0; i2 <= 9; i2++){
    		for (var i3 = 0; i3 <= 9; i3++){
    			for (var i4 = 0; i4 <= 9; i4++){
        			if (i1 + i2 + i3 + i4 == num)
            			count++;
    				}
				}
			}
		}
    console.log(count);
}

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

int main()
{
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a == b){
        cout << "YES" << endl;
        return 0;
    }
    if(v <= w){
        cout << "NO" << endl;
        return 0;
    }
    ll c = abs(a - b);
    ll d = abs(v - w);
    if(c > t*d){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
readints()=parse.(Int,split(readline()))

function main()
    H,W,K=readints()
    cs=Vector{String}(undef,W)
    c=zeros(Bool,H,W)
    for i in 1:H    
        cs[:]=split(readline(),"")
        for j in 1:W
            cs[j]=="#" && (c[i,j]=true)
        end
    end

    nOK=0

    for i in 0:(2^(H+W)-1)
        d=copy(c)
        for j in 1:H
            if (i >> (j-1)) & 1== 1
                d[j,:].=false
            end
        end
        for j in 1:W
            (i >> (j+H-1)) & 1 ==1 && (d[:,j].=false)
        end
        sum(d)==K && (nOK+=1)
    end
    print(nOK)
end
main()

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

int main() {
  int a,b;
  cin >>a >> b;
  int i,m;
  i=0;
  m=1;
  while( m<b){
    m=m+a-1;
    i++;
  }
  cout << i <<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
int main(void){
    int prime[100010]={};
    for(int i=2;i<=100000;i++){
        if(prime[i]==0){
            prime[i]=1;
            for(int j=2*i;j<=100000;j+=i){
                prime[j]=-1;
            }
        }
    }
    int lprime[100010]={};
    for(int i=0;i<=100000;i++){
        if(prime[i]==1&&prime[(i+1)/2]==1&&i%2==1)lprime[i]=1;
    }
    for(int i=1;i<=100000;i++)lprime[i]+=lprime[i-1];
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<lprime[r]-lprime[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1536
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[]s = sc.nextLine().toCharArray();
        if (s[2]==s[3]&&s[4]==s[5]){
            pw.println("Yes");
        }
        else pw.println("No");
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

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


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

	vector<string> vec;

	for (int i = 0; i < (int)S.size(); i++) {
		for (int k = 0; k < 5; k++) {
			vec.push_back(S.substr(i, k+1));
		}
	}

	sort(vec.begin(), vec.end());
	unique(vec.begin(), vec.end());
	cout << vec[K-1] << endl;

	return 0;
}



Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	init();
	ll A,P;cin>>A>>P;
	P+=A*3;
	cout<<P/2<<endl;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,s;
    cin>>n>>s;
    Array a(n);
    REP(i,n) cin>>a[i];

    Matrix dp(n+1,Array(s+1,0));
    dp[0][0]=1;

    REP(i,n){
        REP(j,s+1){
            if(dp[i][j]==0) continue;
            (dp[i+1][j]+=dp[i][j]*2%MOD)%=MOD;
            if(j+a[i]<=s) (dp[i+1][j+a[i]]+=dp[i][j])%=MOD;
        }
    }
    cout<<dp[n][s]<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 73648
import java.util.*;

class Main{
    public static void main(String[] arg){
      Scanner sc = new Scanner(System.in);
      String S = sc.nextLine();
      String a ;String b;String c;
      a = S.substring(0,1);
      b = S.substring(S.length()-1,S.length());
      System.out.println(a + (S.length()-2) +b);
    }
}


Measured memory_bytes: 21972
from collections import defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
x = inl()
h = defaultdict(int)
for y in x:
    h[y] += 1
od = [0]*m
ev = [0]*m
for y in h:
    od[y%m] += h[y]%2
    ev[y%m] += h[y]-h[y]%2
ans = (ev[0]+od[0])//2
if m%2==0:
    ans += (ev[m//2]+od[m//2])//2
for i in range(1,m//2+m%2):
    a = od[i]
    b = ev[i]
    c = od[m-i]
    d = ev[m-i]
    if a>c+d:
        ans += c+d+b//2
    elif c>a+b:
        ans += a+b+d//2
    else:
        ans += (a+b+c+d)//2
print(ans)


Measured memory_bytes: 63852
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	v, e := 0, 0

	for l := 1; l <= n; l++ {
		v += (n - (l - 1)) * l
	}

	for i := 0; i < n-1; i++ {
		u, v := nextInt(), nextInt()
		if u > v {
			u, v = v, u
		}
		e += (n - (v - 1)) * u
	}

	ans := v - e

	puts(ans)
}


Measured memory_bytes: 5040
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	int a, b, c;
	cin >> a >> b >> c;
	int d = min(a, min(b, c));
	int e = max(a, max(b, c));
	cout << e - d << endl;
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
   val S = readLine()!!.toInt()
   val s = S / 60
   val m = s/ 60
   val ans_s = S % 60
   val ans_m = s % 60
   val ans_h = m % 60
   val ans = listOf(ans_h, ans_m, ans_s)
   println(ans.joinToString(":"))
}


Measured memory_bytes: 29640
#include<stdio.h>

int main() {
	int i, d, n;
	i = scanf("%d%d", &d, &n);
	if (i == 0) return 1;
	if (n == 100) n++;
	i = 1;
	while (d > 0) {
		i *= 100;
		d--;
	}
	printf("%d", i * n);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    cout << (ll)((h*w+1)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a;
  int five,seven;
  five=seven=0;
  for (int i = 0; i < 3; i++)
  {
    scanf("%d", &a);
    if(a==5)five++;
    if(a==7)seven++;
  }
  if(five==2 && seven==1){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  

  return 0;
}

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

sys.setrecursionlimit(300000)



def update(i, val, n, bi_tree, sign=1):
    i += 1
    while i < n:
        bi_tree[i][val] += (1 * sign)
        i += i & -i


def get_sum(i, bi_tree):
    ans = [0] * 26
    while i > 0:
        tmp = bi_tree[i]
        for j in range(26):
            ans[j] += tmp[j]
        i -= i & -i
    return ans


def get_range_sum(left, right, bi_tree):
    r_sum = get_sum(right, bi_tree)
    l_sum = get_sum(left - 1, bi_tree)
    for i in range(26):
        r_sum[i] -= l_sum[i]
    return r_sum


from pprint import pprint

def solve(N, S, Q, queries):
    #arr.insert(0, 0)   # insert dummy node for 1-based indexing
    #bit = [0 for i in range(n+1)]
    bit = [[0] * 26 for i in range(N + 1)]
    s = []
    for i, c in enumerate(S):
        if 'a' <= c <= 'z':
            update(i, ord(c) - ord('a'), N + 1, bit)
        s.append(c)

    for q in queries:
        if q[0] == '1':
            i, c = int(q[1]) - 1, q[2]
            p = s[i]
            update(i, ord(p) - ord('a'), N + 1, bit, -1)
            update(i, ord(c) - ord('a'), N + 1, bit, 1)
            s[i] = c
        if q[0] == '2':
            l, r = int(q[1]), int(q[2])
            counts = get_range_sum(l, r, bit)
            ret = 0
            for x in counts:
                if x > 0:
                    ret += 1
            print(ret)
        #pprint(get_range_sum(1, 5, bit))
        #print(s)
        #print()

    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))
    S = str(next(tokens))
    Q = int(next(tokens))
    q = []
    for i in range(Q):
        q.append(list(map(str, input().split())))
    solve(N, S, Q, q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 236960
import itertools 
k = int(input())

#すでにクイーンがある位置
#[-1, -1, 2, -1, -1, 3, -1, -1]なら(2, 2)と(5, 3)にあることを示す
xy = [-1] * 8
for i in range(k):
  y, x = list(map(int, input().split()))
  xy[y] = x
#print(xy)

#どの列にあるか全て試す順列全探索
lis = [x for x in range(8)] # 0から7までのリスト 
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成
# 以下出力
asn = [-1] * 8
for one_case in permutations_lis: 
  wrong = 0
  #print(one_case)
  for i in range(8):
    if (xy[i] != -1) and (xy[i] != one_case[i]):
      #すでにあるクイーンの位置に反してないか
      wrong = 1
      break
    for j in range(i + 1, 8):#下の行と被りがあるか
      #縦と斜め2方向で合計3方向
      if one_case[i] == one_case[j]:
        wrong = 1
      elif abs(one_case[i] - one_case[j]) == abs(i - j):
        wrong = 1
  if wrong == 0:
    ans = one_case
    
#print(ans)    
for i in range(8):
  for j in range(8):
    if ans[i] == j:
      print("Q", end = "")
    else:
      print(".", end = "")
  print("")

    
    
    
  
  
    
    



Measured memory_bytes: 5668
def solve(N, As):
    k = 1 * 2
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2

    k = As[0] - (k // 2) + 1
    ans = [k]
    for i in range(1, N):
        k = As[i] - (k // 2)
        k *= 2
        ans.append(k)
    ans.insert(0, ans.pop())
    return " ".join([str(a) for a in ans])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 19092
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(long[]), n = rd1[0], ws = rd1[1];
  auto w = new long[](n), v = new long[](n);
  foreach (i; 0..n) {
    auto rd2 = readln.split.to!(long[]), wi = rd2[0], vi = rd2[1];
    w[i] = wi;
    v[i] = vi;
  }
  auto w0 = w[0];
  foreach (ref wi; w) wi -= w0;

  auto sumW = w.sum, dp = new long[][][](n+1, n+1, sumW+1);
  dp[0][0][0] = 1;
  foreach (i; 0..n)
    foreach (j; 0..n+1)
      foreach (k; 0..sumW+1) {
        if (j >= 1 && k >= w[i] && dp[i][j-1][k-w[i]])
          dp[i+1][j][k] = max(dp[i][j][k], dp[i][j-1][k-w[i]] + v[i]);
        else
          dp[i+1][j][k] = dp[i][j][k];
      }

  auto ans = 0L;
  foreach (j; 0..n+1)
    foreach (k; 0..sumW+1)
      if (k + w0 * j <= ws)
        ans = max(ans, dp[n][j][k]);

  writeln(ans-1);
}


Measured memory_bytes: 23420
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast


    int a,b;
    cin>>a>>b;


    for(int i = b-a+1; i <= b+a-1; i++)
    {
        cout<<i<<" ";
    }



    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A[4][3][10] = {};
	int n;
	cin >> n;
	int b, f, r, v;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		A[b - 1][f - 1][r - 1] += v;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << A[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)
			cout << "####################" << endl;
	}
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll h[100005];
ll dp[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 1; i < n; i++) {
		dp[i + 1] = min(abs(h[i + 1] - h[i]) + dp[i], abs(h[i + 1] - h[i - 1]) + dp[i - 1]);
		
	}

	cout << dp[n-1] << endl;
	return 0;

}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      char[] s = sc.next().toCharArray();
      int count = 0;
      int max = 0;
      boolean left = false;
      boolean right = false;
      for(int i = 0;i < n;i++){
        count = 0;
        left = false;
        right = false;
      	for(char x = 'a';x <= 'z';x++){
          left = false;
          right = false;
      		for(int j = 0;j < i;j++){
            	if(s[j]==x) left = true;
            }
            for(int j = i;j < n;j++){
            	if(s[j]==x) right = true;
            }
          if(left&&right)count++;
      	}
        max = Math.max(max,count);
      }
      System.out.println(max);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int i = 0;
		int a_tax = (int)(i * 0.08);
		int b_tax = (int)(i * 0.1);
		int ans = -1;
		while( i < 1000){
			i++;
			a_tax = (int)(i * 0.08);
			b_tax = (int)(i * 0.1);
			if (a_tax == A && b_tax == B){
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996