akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Binary Indexed Tree(0-index) */

struct BIT{
  typedef int Type;
  int bit_size;
  vector<Type> data;
  
  BIT(int n){
    bit_size = n;
    data.assign(n+1,0);
  }
  
  //add x to kth value
  void add(int k,Type x){
    k += 1;
    
    while(k<=bit_size){
      data[k]+=x;
      k+= k&(-k); }
  }
  
  //sum of [1,k]
  Type query(int k){
    k += 1;
    
    Type rec=0;
    while(k>0){
      rec+=data[k];
      k-= k&(-k);
    }
    return rec;
  }
};

int main(){
  char s[SIZE],sL[SIZE] = {}, sR[SIZE] = {};
  int sLsize = 0, sRsize = 0;
  int n;
  int al[26] = {};
  ll ans = 0;
  
  scanf("%s",s);
  n = strlen(s);

  for(int i=0;i<n;i++){
    al[s[i]-'a']++;
  }

  int odd = 0;
  for(int i=0;i<26;i++){
    odd += al[i]%2;
  }

  if(odd >= 2){
    puts("-1");
    return 0;
  }

  int half = n/2;
  int rest = half;
  int center = n%2;
  int al2[26];
  for(int i=0;i<26;i++) al2[i] = al[i]/2;

  for(int i=0;i<n;i++){
    if(al2[s[i]-'a'] <= 0){
      if(al[s[i]-'a']%2 && center){
        ans += rest;
        center = 0;
      }else{
        ans += rest + center;
        sR[half - (++sRsize)] = s[i];
      }
    }else{
      rest--;
      al2[s[i]-'a']--;
      sL[sLsize++] = s[i];
    }
  }
  
  queue<int> que[26];
  BIT bit(half+1);

  for(int i=0;i<half;i++) bit.add(i,1);
  
  for(int i=0;i<half;i++){
    que[sR[i]-'a'].push(i);
  }

  for(int i=0;i<half;i++){
    int p = que[sL[i]-'a'].front();
    que[sL[i]-'a'].pop();
    
    bit.add(p,-1);
    ans += bit.query(p);
  }
  
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;
    
    long n = -1;
    long m = 0;
    
    cin >> s;
    for (long i = 0; i < s.length(); ++i)
    {
        if(n == -1 && 'A' == s[i]) n = i;
        if(n != -1 && 'Z' == s[i])
        {
            m = i;
        }
    }
    n = m - n + 1;
    cout << n << endl;
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<"Christmas"<<" ";
        for(int i=0;i<abs(25-n);i++){
            cout<<"Eve"<<" ";
        }
    }   
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
    A[i] -= i + 1;
  }
  sort(rng(A));
  int b;
  if(sz(A) % 2 == 1) {
    b = A[(N-1)/2];
  } else {
    b = (A[(N-1)/2] + A[N/2] )/ 2;
  }
  ll ans = 0ll;
  rep(i,N) {
    ans += (ll)abs(A[i]-b);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
int mod = (int) 1e9 + 7;
const int logN = 17;
const int inf = 1e9 + 9;
const int N = 2e5 + 5;

int n, m, x, y, z, t, k, q, dp[N], a[N];

int main() {

    scanf("%d", &n); n = n + n;
    FOR(i, 1, n)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    FOR(i, 1, n) {
        dp[i] = dp[i - 1];
        FOR(j, 1, i-1)
            dp[i] = max(dp[j - 1] + a[j], dp[i]);
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
import math
a_list = list(map(int,input().split()))
for i in range(n):
  a_list[i] = -1 * a_list[i]
import heapq
heapq.heapify(a_list)
for j in range(m):
  
  a = heapq.heappop(a_list)
  a = math.ceil(a/2)
  heapq.heappush(a_list,a)


print(-1 * sum(a_list))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <class F>
auto recursive(F f) {
    return [f](auto... a) { return f(f, a...); };
}
template <class I, class V = typename I::value_type>
V sum_up(const I &l, const I &r) {
    V v;
    for (I i = l; i != r; i++) v = i == l ? *i : v + *i;
    return v;
}
template <class I, class T = iterator_traits<I>>
I operator+(I it, int n) {
    for (int i = 0; i < n; i++) it++;
    return it;
}
template <class I, class T = iterator_traits<I>>
I operator-(I it, int n) {
    for (int i = 0; i < n; i++) it--;
    return it;
}
template <class T>
using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using vector2d = vector<vector<T>>;
struct fixprec {
    int x;
    fixprec(int d) : x(d) {}
};
ostream &operator<<(ostream &o, fixprec f) { return o << fixed << setprecision(f.x); }
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, auto judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

// O(NlogNlogK) = O(N(logN)^2)
int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N);
    for (i64 &a : A) cin >> a;
    sort(WHOLE(A));
    i64 ans = BinSearch<i64>(-1.1e18, 1.1e18, [&](i64 X) -> bool {
        // X |-> M:積ペアのうちX以下のものの数
        i64 M = 0;
        // O(NlogN)
        for (int i = 0; i < N; i++) {
            // k : A[i] と積を取ってX以下になる限界
            int k = BinSearch<int>(-1, N, [&A, i, X](int j) -> bool {
                return A[i] * A[j] <= X;
            }, A[i] < 0);
            if (A[i] < 0) {
                M += N - k;
            } else {
                M += k + 1;
            }
            // 自乗が含まれているなら削除
            if (A[i] * A[i] <= X) M--;
        }
        // ダブルカウンティングを解消
        return M >= 2 * K;
    });
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, char** argv) {
	int n;
	while(scanf("%d",&n)!=EOF)
	{int ans=0;
     for(int i=1;i<=n;i++)
      {
      	int a;int b;
      	scanf("%d%d",&a,&b);
      	ans+=abs(a-b)+1;
      }
      printf("%d\n",ans);
   }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[2]*10+a[1]+a[0];
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(A.begin(), A.end());
  vector<ll> S, L;
  copy(A.begin(), A.begin() + N / 2, back_inserter(S));
  copy(A.begin() + N / 2, A.end(), back_inserter(L));
  ll ans = 0;
  ll s = accumulate(S.begin(), S.end(), 0LL);
  ll l = accumulate(L.begin(), L.end(), 0LL);
  if (N % 2 == 0) {
    ans = (l - s) * 2 + S.back() - L.front();
  } else {
    ans = (l - s) * 2 - L[0] - L[1];
    s += L[0], l -= L[0];
    ll tmp = (l - s) * 2 + S.back() + L[0];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
# 辺の必要性
f = [[True] * n for _ in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            # ワーシャルフロイドの更新が適用されたらダメ
            # 迂回路も最短コストなら直結路は不要
            if a[i][k] + a[k][j] < a[i][j]:
                print(-1)
                exit()
            elif a[i][k] + a[k][j] == a[i][j] and i != k and k != j:
                f[i][j] = False

ans = 0
for i in range(n):
    for j in range(n):
        if f[i][j]:
            ans += a[i][j]
ans //= 2
print(ans)

Measured memory_bytes: 44764
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=300009;
vector<pair<ll ,ll > > v;
ll  dp[100001];
int main()
{
    ll  n,w;
    cin>>n>>w;
    for(ll  i=0;i<n;i++)
    {
        ll  a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }
    ll ans=0;
    for(auto x: v)
    {
        for(int used=w-x.first;used>=0;used--)
        {
            dp[used+x.first]=max(dp[used+x.first],dp[used]+x.second);
            ans=max(ans,dp[used+x.first]);
        }
    }
    cout<<ans<<endl;


}
/*
3 5
3 3
4 2
2 4
*/


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int n;
vector<int>pn;
void mpn() {
	pn.push_back(2);
	for (int i = 3; i <= n; i += 2) {
		for (int j = 0; j < pn.size(); j++)if (i%pn[j] == 0)goto heaven;
		pn.push_back(i);
	heaven:;
	}
	return;
}
int main() {
	cin >> n;
	if (n == 1)cout << "1\n";
	else {
		long long ans = 1;
		mpn();
		int a[1010]; for (int i = 1; i <= n; i++)a[i] = i;
		int cnt;
		for (int i = 0; i < pn.size(); i++) {
			cnt = 0;
			for (int j = 1; j <= n; j++)
				while (a[j] % pn[i] == 0) {
					a[j] /= pn[i];
					cnt++;
				}
			ans *= cnt+1;
			ans %= 1000000007;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//-------------------------
// 
//-------------------------

public class Main {
    public static void main(String[] args) {
        
        char[] s = new char[3];
        int output=0;

        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        scan.close();

        for(int i=0; i<3; i++)
        {
            s[i] = S.charAt(i);
            if(s[i]=='1') output++;
        }

        System.out.println(output);
    }
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;

namespace ABC101_B_Digit_Sums
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string n = Console.ReadLine();
			int npuls = 0;

			for (int i = 0; i < n.Length; i++)
			{
				npuls += int.Parse(n.Substring(i, 1));
			}
			//Console.WriteLine(npuls);

			if (int.Parse(n) % npuls == 0)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

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


int main() {
  int N, X, Y; cin >> N >> X >> Y; X--, Y--;
  int ans[2000] = {};
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      int d = j-i;
      d = min(d, abs(X-i)+1+abs(Y-j));
      ans[d]++;
    }
  }

  for(int d = 1; d < N; d++) {
    cout << ans[d] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a=1,b=1;
  int n; cin>>n;
  for(int i=0;i<n;i++){
    ll x,y; cin>>x>>y;
    ll mult=1;
    if(x*b==y*a) continue;
    if(a/x>b/y){
      if((a-1)/x!=a/x){
        mult=a/x;
      }else{
        mult=(a/x)+1;
      }
    }else if(a/x<b/y){
      if((b-1)/y!=b/y){
        mult=b/y;
      }else{
        mult=(b/y)+1;
      }
    }else{
      if((a-1)/x==a/x || (b-1)/y==b/y){
        mult=(b/y)+1;
      }else{
        mult=(a/x);
      }
    }
    x*=mult; y*=mult;
    a=x; b=y;
  }
  ll ans=a+b;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)
a = s[n-1:n]
if a == '2' or a == '4' or a == '5' or a == '7' or a == '9':
  print('hon')
elif a == '0' or a == '1' or a == '6' or a == '8':
  print('pon')
else:
  print('bon')


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

int main() {
    int N;
    std::cin >> N;
    std::vector<std::tuple<int, int, char, long long, std::string>> v(N);
    for (auto& e : v) {
        std::cin >>
            std::get<0>(e) >>
            std::get<1>(e) >>
            std::get<2>(e) >>
            std::get<3>(e) >>
            std::get<4>(e);
    }

    std::sort(v.begin(), v.end());
    for (auto& e : v) {
        std::cout
            << std::get<0>(e) << " "
            << std::get<1>(e) << " "
            << std::get<2>(e) << " "
            << std::get<3>(e) << " "
            << std::get<4>(e) << std::endl;
    }
}


Measured memory_bytes: 12100
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,y,a[300]={};
    a[1]=300000,a[2]=200000,a[3]=100000;
    cin>>x>>y;
    ll ans=a[x]+a[y];
    if(x==1&&y==1){
        cout<<1000000<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    int A,cnt = 0,tmp = 0;
    for(int i=0;i<N;i++){
        cin >> A;
        if(A%2 == 0){
            tmp++;
            if(A%3 == 0 || A%5 == 0) cnt++;
        }
    }
    
    if(cnt == tmp) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
    return 0;
}



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

typedef long long ll;

bool t[1111000];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //Älä käytä, jos tehtävä on interaktiivinen!
    ll k;
    cin >> k;
    ll mod=0;
    ll ans=0;
    bool b=1;
    while (b){
        ans++;
        mod*=10;
        mod+=7;
        mod%=k;
        if (mod==0) break;
        else{
            if (t[mod]) b=0;
            else t[mod]=1;
        }
    }
    if (b) cout << ans << "\n";
    else cout << "-1\n";
}






Measured memory_bytes: 4500
#include <set>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
const double eps = 1e-8;
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	sort(a.begin(), a.end());
	sort(b.begin(),b.end(),greater<int>() );
	if(a<b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}



}


Measured memory_bytes: 256
fun main(args:Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = (0 until n).map {
        readLine()?.toLong()!!
    }
    val result = aList.groupBy { it }
        .mapValues { it.value.size }
        .filter { it.value % 2 != 0 }
        .count()
    println(result)
}

Measured memory_bytes: 77004
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	int b=0;
	fo(i,6){
		if(a[i]=='1')
			b++;
	}
	cout<<b<<endl;
}

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

int count(int n,int x){
    int cnt=0;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            for(int k=j+1;k<=n;k++){
                if(i+j+k==x) cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int n,x;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0) break;
        cout << count(n,x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,ll)> P;
  ll n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(ll n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,ll b){return a;}):
    f(f),g(g),h(h),d1(d1),d0(d0),p(p){
    init(n_);
    if(n_==(ll)v.size()) build(n_,v);
  }
  void init(ll n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(ll n_, vector<T> v){
    for(ll i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(ll len,ll k){
    if(laz[k]==d0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=d0;
  }
  T update(ll a,ll b,E x,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(ll a,ll b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(ll a,ll b,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(ll a,ll b){
    return query(a,b,0,0,n);
  }
};
//区間加算区間和
int main() {
    cin >> n;
    cin>>q;
    vl A=vl(n,0);
    auto F = [](ll a, ll b){return a+b;};
    auto G = F;
    auto H = F;
    auto P = [](ll a, ll b){return a*b;};
    SegmentTree<ll,ll> seg(n, F, G, H, 0, 0,vl(n,0),multiplies<ll>());
    rep(i,q){
        cin>>x;
        if(x==0){
            cin>>a>>b>>c;
            a--;
            seg.update(a,b,c);
        }
        else{
            cin>>a>>b;
            a--;
            cout<<seg.query(a,b)<<endl;
        }
    }
}


Measured memory_bytes: 9164
#include "bits/stdc++.h"
using namespace std;

string s,temp="";
int counter=0,num,mx=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int j=0;j<=s.size()-3;j++){
		for(int i=j;i<j+3;i++){
			temp+=s[i];
		}
		stringstream strm(temp);
		strm>>num;
		if(abs(753-num) < abs(753-mx))
			mx=num;
		temp="";
	}
	cout<<abs(753-mx);
	return 0;
}

Measured memory_bytes: 256
n, a, b = map(int,input().split())
all_sum = 0
for i in range(1,n+1):
    i_li = list(str(i))
    #print(i_li)
    sum = 0
    for i_li_element in i_li:
        sum += int(i_li_element)
    if a<=sum<=b:
        all_sum += i
print(all_sum)

Measured memory_bytes: 3060
res = [0]*10001

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x

            if tmp <= 10000:
                res[tmp] += 1

N = int(input())

for i in range(1,N+1):
    print(res[i])

Measured memory_bytes: 9276
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
int n,m,q;
int resmax=0;
  vector<int> a,b,c,d;
template<typename T> bool chmax(T &m, const T q) {
  if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) {
  if (m > q) {m = q; return true;} else return false; }
void dfs(vector<int> A) {
    // 数列の長さが N に達したら打ち切り
    if (A.size() == n+1) {
      int res=0;
        REP(i,q){
          if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
        }
        resmax = max(res, resmax);
        // 処理
        return;
    }

    A.push_back(A.back());
    while(A.back()<=m){
      dfs(A);
      A.back()++;
    }
}
using namespace std;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> m >> q;
  a=b=c=d = vector<int>(q);
  REP(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>(1,1)); 
  cout << resmax << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n;
D dp[305][305][305];
D dfs(int x,int y,int z){
    if(dp[x][y][z]!=-1)return dp[x][y][z];
    D s=D(x)+D(y)+D(z);
    D res=0;
    if(x>0){
        res+=dfs(x-1,y,z)*(D(x)/D(n));
    }
    if(y>0){
        res+=dfs(x+1,y-1,z)*(D(y)/D(n));
    }
    if(z>0){
        res+=dfs(x,y+1,z-1)*(D(z)/D(n));
    }
    return dp[x][y][z]=(res+D(1))/(s/D(n));
}
int main(void){
    D x=0,y=0,z=0;
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        if(a==1)x++;
        else if(a==2)y++;
        else z++;
    }
    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;
    dp[0][0][0]=0;
    printf("%0.10lf\n",dfs(x,y,z));
}


Measured memory_bytes: 219392
#include <iostream>
using namespace std;
int main()
{
	int sx, sy, tx, ty, y_diff, x_diff;
    cin >> sx >> sy >> tx >> ty;
    y_diff = ty - sy;
    x_diff = tx - sx;
    for(int i = 0; i < y_diff; i++)
    	cout << "U";
    for(int i = 0; i < x_diff; i++)
    	cout << "R";
    for(int i = 0; i < y_diff; i++)
    	cout << "D";
    for(int i = 0; i < x_diff; i++)
    	cout << "L";
    cout << "L";
    for(int i = 0; i < y_diff+1; i++)
    	cout << "U";
    for(int i = 0; i < x_diff+1; i++)
    	cout << "R";
    cout << "DR";
    for(int i = 0; i < y_diff+1; i++)
    	cout << "D";
    for(int i = 0; i < x_diff+1; i++)
    	cout << "L";
    cout << "U";
}

Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	makei(M);
	say((N - 1)*(M - 1));
}

Measured memory_bytes: 256
N,M,P=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(M)]
c=[[] for i in range(N)]
v=[0]*N
for a,b,_ in ABC:
    c[a-1].append(b-1)
q=[0]
while q:
    p=q.pop()
    if v[p]==0:
        v[p]=1
        for n in c[p]:
            if n!=p:
                q.append(n)
inf=10**20
f=lambda i,j,w: [i-1,j-1,P-w]
edge=[f(i,j,w) for i,j,w in ABC if v[i-1]]
def bf(N,s):
    d=[inf]*N
    d[s]=0
    prev=[-1]*N
    for i in range(N-1):
        f=0
        for i,j,w in edge:
            if d[j]>d[i]+w:
                d[j]=d[i]+w
                prev[j]=i
                f=1
        if f==0:
            break
    while True:
        f=0
        for i,j,w in edge:
            if d[j]>d[i]+w and (d[j]!=-inf or d[i]!=-inf):
                d[i]=d[j]=-inf
                f=1
        if f==0:
            break
    return d
d=bf(N,0)
print(max(0,-d[-1]) if d[-1]>-inf else -1)

Measured memory_bytes: 53080
#include <stdio.h>

int main(void) {
	int h,w;
	while(scanf("%d%d", &h,&w)){
		if(h == 0 && w == 0)
			break;
		int i,c;
		for(i =0; h > i; i++){
			for(c = 0; w > c; c++){
				if(!(c%2-i%2))printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
using namespace std;

const int INT__MAX = 2147483647;
const int MOD = 1000000007;

int main() {

	int N;
	int h, o;

	cin >> N;

	h = (N - (N % 100)) / 100;
	o = N % 10;

	if (h == o)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int building[4][3][10];

int main(void)
{
    int n;
    int d, f, r, v;
    int i;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d%d%d%d", &d, &f, &r, &v);
        building[d - 1][f - 1][r - 1] += v;
    }
    
    for (d = 0; d < 4; d++){
        for (f = 0; f < 3; f++){
            for (r = 0; r < 10; r++){
                printf(" %d", building[d][f][r]);
            }
            printf("\n");
        }
        if (d != 3){
            printf("####################\n");
        }
    }
    
    return (0);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
string s; long long int ans;
int main(){
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if(i%2 == 0 && s[i] != '0' && s[0] == '0'){
      ans++;
    }
    if(i%2 == 1 && s[i] != '1' && s[0] == '0'){
      ans++;
    }
    if(i%2 == 0 && s[i] != '1' && s[0] == '1'){
      ans++;
    }
    if(i%2 == 1 && s[i] != '0' && s[0] == '1'){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int start = -1;
		for (int i = 0; i <= s.length - t.length; i++) {
			boolean flag = true;
			for (int j = 0; j < t.length; j++) {
				if (t[j] != s[i + j] && s[i + j] != '?') {
					flag = false;
					break;
				}
			}
			if (flag) {
				start = i;
			}
		}
		if (start == -1) {
			System.out.println("UNRESTORABLE");
			return;
		}
		System.arraycopy(t, 0, s, start, t.length);
		for (int i = 0; i < s.length; i++) {
			if (s[i] == '?') {
				s[i] = 'a';
			}
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 23764
from collections import defaultdict

N, A = map(int, input().split())
x = list(map(int, input().split()))

y = []
for xi in x:
    yi = xi - A
    y.append(yi)
X = max(x + [A])
NX = N * X

dp = defaultdict(int)
dp[(0, 0)] = 1
for i in range(N):
    for t in range(-NX, NX + 1):
        dp[(i + 1, t)] = dp[(i, t)] + dp[(i, t - y[i])]
print(dp[(N, 0)] - 1)


Measured memory_bytes: 40316
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
		double a1 = (xp-x1)*(y2-y1)-(yp-y1)*(x2-x1);
		bool parity = a1 > 0.0;

		double a2 = (xp-x2)*(y3-y2)-(yp-y2)*(x3-x2);
		if(parity ^ (a2 > 0.0)){
			puts("NO");
			continue;
		}

		double a3 = (xp-x3)*(y1-y3)-(yp-y3)*(x1-x3);
		puts(parity^(a3>0.0) ? "NO" : "YES");
	}
	return 0;
}

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


int main(){
	int n, k;
	cin >> n >> k;
	pair<long long, int> p[100010];
	for(int i = 0;i < n;i++){
		cin >> p[i].second >> p[i].first;
	}

	sort(p, p+n, greater<pair<long long, int> >());

	int t[100010];
	long long d[100010];
	for(int i = 0;i < n;i++){
		t[i] = p[i].second;
		d[i] = p[i].first;
	}

	priority_queue<long long, vector<long long>, greater<long long> > que1;
	priority_queue<long long> que2;
	int memo[100010] = {};
	long long ans = 0;
	long long num = 0;
	for(int i = 0;i < n;i++){
		if(i < k){
			if(memo[t[i]] == 0){ 
				memo[t[i]] = 1;
				ans += d[i];
				num++;
			}else{
				ans += d[i];
				que1.push(d[i]);
			}
		}else{
			if(memo[t[i]] == 0){
				memo[t[i]] = 1;
				que2.push(d[i]);
			}
		}
	}

	long long aa = ans + num * num;
	while(!que2.empty() && !que1.empty()){
		ans = ans + que2.top() - que1.top();
		num++;
		que2.pop(); que1.pop();
		aa = max(aa, ans + num*num);
	}

	cout << aa << endl;

	return 0;
}



Measured memory_bytes: 4160
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int R, G, B, N;

	std::cin >> R >> G >> B >> N;

	long result = 0;

	for (int r = 0; r <= N; r += R) {
		for (int g = 0; g <= N - r; g += G) {
			if ((N - r - g) % B == 0) {
				++result;
			}
		}
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 256
while True:
    n,x = [int(x) for x in input().split()]
    if(n == 0 and x == 0):
        break
        
    count = 0
    for j in range(1,n+1):
        for k in range(j+1,n+1):
            for l in range(k+1,n+1):
                if(j + k + l == x):
                    count += 1

    print(count)


Measured memory_bytes: 5600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream input = System.in;
      	OutputStream output = System.out;
      	Scanner sc = new Scanner(input);
      	PrintWriter out = new PrintWriter(output);
      	int X = sc.nextInt();
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	out.println((X - A) % B);
      	out.close();
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tolower(c) char(c+0x20)
#define toupper(c) char(c-0x20)
#define chartoll(c) ll(c) - ll('0')

const ll MAX_N = 1000000;

int main(void){
    ll k, x;
    cin >> k >> x;
    
    ll r, l;
    r = min(MAX_N, x+k-1);
    l = max(-MAX_N, x-k+1);

    For(i, l, r + 1) cout << i << " ";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine(3 * N * N);
        }
    }
}


Measured memory_bytes: 13140
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   string m;
 
   cin >> n >> m;
  
   if(n>=3200){
     cout << m << endl;
   }else{
     cout << "red" << endl;
   }
  
   
  return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b) = {
      let v: Vec<i64> = read_vec();
      (v[0], v[1])
    };

    if (a + b) % 2 == 0 {
      println!("{}", (a + b) / 2);
    } else {
      println!("IMPOSSIBLE");
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for(int i = 0; i < min(42, K); i++) {
        vector<int> B(N, 0);
        for(int j = 0; j < N; j++) {
            int l = max(0, j - A.at(j));
            int r = min(N - 1, j + A.at(j));
            B.at(l)++;
            if(r + 1 < N)
                B.at(r + 1)--;
        }
        for(int j = 1; j < N; j++) {
            B.at(j) += B.at(j - 1);
        }
        A = B;
    }

    for(int i = 0; i < N - 1; i++) {
        cout << A.at(i) << " ";
    }

    cout << A.at(N - 1) << endl;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;

    int main()
    {
        FAST
        int t;
        t = 1;;

        while(t--)
        {
           int h , w , f;
           cin >> h >> w >> f;

          
           char maze[h + 1][w + 1];

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

           int ans = 0;

           for(int i = 0 ; i < (1 << h) ; i++)
           {
              for(int j = 0 ; j < (1 << w) ; j++)
              {
                  int total = 0;
                  
                  for(int k = 0 ; k < h ; k++)
                  {
                      for(int l = 0 ; l < w ; l++)
                      {
                          if((i & (1 << k)) && (j & (1 << l)) && maze[k][l] == '#')
                          {
                              total++;
                          }
                      }
                  }
                  if(total == f)ans++;
              }    
           }

           cout << ans << endl;
        }
    }



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

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

using namespace std;

const string INF="NO";

struct Edge{ int u,v; string w; };

int n,m,s,g;
Edge E[400];

string BackwardBellmanFord(){
	string d[40];
	rep(u,n) d[u]=(u==g?"":INF);

	rep(k,6*n+1){
		bool changed=false;
		rep(i,m){
			int u=E[i].u,v=E[i].v;
			string nextd=E[i].w+d[v];
			if(d[v]!=INF && (d[u]==INF || nextd<d[u])){
				d[u]=nextd;
				changed=true;
				if(u==s && k>=n) return INF;
			}
		}
		if(!changed) break;
	}

	return d[s];
}

int main(){
	while(cin>>n>>m>>s>>g,n){
		rep(i,m) cin>>E[i].u>>E[i].v>>E[i].w;
		cout<<BackwardBellmanFord()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1432
#include <stdio.h>

int main(void) {
	int n,k,q,i,j;
	scanf("%d %d %d",&n,&k,&q);
	int a,p[n];
	for(j=0;j<n;j++){p[j]=k-q;}
	for(i=0;i<q;i++){
		scanf("%d",&a);
		p[a-1]++;
	}
	for(j=0;j<n;j++){
		if(p[j]>0){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	
	// your code goes here
	return 0;
}


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

int main() {
	int a, b, ans;
	cin >> a >> b;
	if (a + b > a - b) {
		ans = a + b;
	}
	else {
		ans = a - b;
	}
	if (ans > a * b) {
		cout << ans << endl;
	}
	else {
		cout << a * b << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,ans,n,x,m[100],min=1000,sum=0;
    scanf("%d %d",&n,&x);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m[i]);
        if(min>m[i])  min=m[i];
        sum+=m[i];
    }
    printf("%d\n",n+(x-sum)/min);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int K,X;

signed main(){
	cin>>K>>X;
	for(int i=X-(K-1);i<=X+(K-1);i++){
		cout<<i;
		if(i<X+(K-1)){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let d: usize = itr.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for i in 1..m + 1 {
        for j in 1..d + 1 {
            let d1 = j / 10;
            let d2 = j % 10;
            if d1 >= 2 && d2 >= 2 && i == d1 * d2 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


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

int main(void){
        int n;
        scanf("%d", &n);

        double a[n], b[n];
        for(int i=0; i<n; i++) scanf("%lf", &a[i]);
        for(int i=0; i<n; i++) scanf("%lf", &b[i]);

        double one, two, thr, inf;
        one = two = thr = inf = 0;
        for(int i=0; i<n; i++){
                double d = fabs(a[i]-b[i]);
                one += d;
                two += d*d;
                thr += d*d*d;
                inf = fmax(inf, d);
        }

        printf("%lf\n%lf\n%lf\n%lf\n", one, sqrt(two), pow(thr, 1.0/3.0), inf);
        return 0;
}


Measured memory_bytes: 2064
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    char ch; cin>>ch;
    char ans = ch  + 1;
    cout<<ans<<endl;
    return 0;
}

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

def next_alphabet(ch, n):
    c = ord(ch)
    return chr(c + n - ord('Z') + ord('A')-1) if c+n>90 else chr(c+n)
  
t = [0]*len(s)
for i in range(len(s)):
    t[i] = next_alphabet(s[i],n)
print(''.join(t))

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


int const D = 8;

int const T = 10;
int const INF = 1 << 30;
int const MOD = 1000000007;

int mul(int a, int b) {
	return (int) ((long long) a * b % MOD);
}

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int modpow(int a, int b) {
	int ret = 1;
	while (b > 0) {
		if (b & 1) ret = mul(ret, a);
		a = mul(a, a);
		b >>= 1;
	}
	return ret;
}
using namespace std;
int ten[T];
int getten(int len) {
	if (len >= T) return INF;
	return ten[len] - ten[len - 1];
}

void addit(int &ans, int a, int b) {
	add(ans, modpow(10, b));
	add(ans, MOD - modpow(10, b - 1));
	add(ans, MOD - a);
	add(ans, 1);
}

int main() {
	ten[0] = 1;
	for (int i = 1; i < T; i++) ten[i] = ten[i - 1] * 10;
	int s;
	cin >> s;
	int ans = 0;
	for (int len = 1; len <= D; len++) {
		long long got = 0;
		for (int j = len + 1; ; j++) {
			int left = (s - (int) got - len - j);
			if (left < 0) break;
			int a = len;
			int b = j;
			// cerr << a << ' ' << b << ' ' << left << endl;
			int g = __gcd(a, b);
			int ca = getten(a);
			int cb = getten(b);
			if (left % g == 0) {
				left /= g;
				a /= g;
				b /= g;
				int y = 0;
				while (left % a != y * b % a) ++y;
				int x = (left - y * b) / a;
				if (x > (ca - 1)) {
					int cn = (x - (ca - 1) + b - 1) / b;
					x -= cn * b;
					y += cn * a;
				}
				assert(x * a + y * b == left);
				if (x >= 0 && y <= cb - 1) {
					int can = min(((cb - 1) - y) / a, x / b);
					add(ans, can + 1);
					// cerr << "can = " << can << endl;
				}
			}
			got += (long long) getten(j) * j;
			if (got > s) break;
		}
	}
	for (int i = 1; i * i <= s; i++) {
		if (s % i != 0) continue;
		int a = i;
		int b = s / i;
		// cerr << a << ' ' << b << endl;
		// cerr << getten(a) << ' ' << getten(b) << endl;
		if (a <= getten(b)) {
			addit(ans, a, b);
		}
		if (a != b && b <= getten(a)) {
			addit(ans, b, a);
		}
	}
	for (int len = D + 1; len + (len + 1) <= s; len++) {
		int left = s - len - (len + 1);
		int a = len;
		int b = len + 1;
		int y = left % a;
		int x = left / a - y;
		if (x < 0) continue;
		add(ans, x / b + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384