akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest143.Questions;
using AtCoderBeginnerContest143.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest143.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var d = inputStream.ReadIntArray();

            var sum = 0;

            for (int i = 0; i < d.Length; i++)
            {
                for (int j = i + 1; j < d.Length; j++)
                {
                    sum += d[i] * d[j];
                }
            }

            yield return sum;
        }
    }
}


namespace AtCoderBeginnerContest143
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest143.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest143.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	
long long A,B,X,W;
scanf("%lld%lld%lld",&A,&B,&X,&W);
if(A==0)
W=(B/X)+1;
else{
	W=(B/X)-(A-1)/X;
}
cout<<W;
}

Measured memory_bytes: 256
def keta1 x, y
    answer = ((y - x + 1) / 2).odd? ? 1 : 0
    answer = 1 - answer if (y - x).even? && x.odd? 
    return answer
end

def getresidual x, y
    arr = [[], []]
    [x, y].each_with_index{|z, i|
        d = 4
        while true
            arr[i] << z % d
            d *= 2
            break if d > z * 2
        end
    }
    return arr
end

x, y = gets.chomp.split.map(&:to_i)
if x == y
    puts x
else
    answers = [keta1(x, y)]
    residuals = getresidual(x, y)

    d = 1
    residuals[1].length.times{|i|
        d *= 2
        if residuals[0][i].nil? || residuals[0][i] < d
            if residuals[1][i] < d
                answers << 0
            else
                answers << (residuals[1][i].even? ? 1 : 0)
            end
        else
            if residuals[1][i] < d
                answers << (residuals[0][i].even? ? 0 : 1)
            else
                answers << ((residuals[0][i] % 2 == residuals[1][i] % 2) ? 1 : 0)
            end
        end
    }
    puts answers.reverse.join.to_i(2)
end

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

int main() {
  ll k, n; cin >> k >> n;
  vector<ll> a(n);
  vector<ll> dif(n-1);
  rep(i,n) cin >> a[i];
  
  ll sum = 0;
  ll mx = -1;
  ll mx_num = -1;
  
  rep(i,n-1) {
    sum += a[i+1] - a[i];
    if ((a[i+1] - a[i]) > mx) {
      mx = a[i+1] - a[i];
      mx_num = i;
    }
  }
  
  ll rev_dif = k - a[n-1] + a[0];
 
  if (rev_dif < mx) {
    sum -= mx;
    sum += rev_dif;
  }
  
  cout << sum << endl;
    
  return 0;

}

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

int main()
{
 int x,y;
  cin >> x >> y;
  
  int sum = 0;
  if (x == 1  && y == 1)
    sum += 400000;
  if (x==1)
    sum += 300000;
  if (x==2)
    sum += 200000;
  if (x==3)
    sum += 100000;
   if (y==1)
    sum += 300000;
  if (y==2)
    sum += 200000;
  if (y==3)
    sum += 100000;
  cout << sum << endl;
}

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

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

    int acc = 0;
    int judge = -2;
    for (int i=0;i<n-1;i++){
        if (i == judge + 1){
            judge = -2;
            continue;
        }
        if (slimes[i] == slimes[i+1]){
            acc++;
            judge = i;
        }
    }
    cout << acc << endl;
    return 0;

}

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

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int main(){
while(1){//start

	int h;
	cin >> h;
	if(h == 0) break;

	vector<vector<int> > v (5, vector<int>(h));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < 5; j++){
			int tmp;
			cin >> tmp;
			v[j][i] = tmp;
		}
	}

	for(int i = 0; i < 5; i++){
		reverse(v[i].begin(), v[i].end());
	}

	//cout << v << endl;


	int ans = 0;
for(int k = 0; k <= 11; k++){

	for(int i = 0; i < h; i++){
		if(v[0][i] == v[1][i] and v[0][i] == v[2][i] and v[0][i] == v[3][i] and v[0][i] == v[4][i]){
			ans += v[0][i] * 5;
			v[0][i] = 0;
			v[1][i] = 0;
			v[2][i] = 0;
			v[3][i] = 0;
			v[4][i] = 0;
		}
		else if(v[0][i] == v[1][i] and v[0][i] == v[2][i] and v[0][i] == v[3][i]){
			ans += v[0][i] * 4;
			v[0][i] = 0;
			v[1][i] = 0;
			v[2][i] = 0;
			v[3][i] = 0;
		}
		else if(v[1][i] == v[2][i] and v[1][i] == v[3][i] and v[1][i] == v[4][i]){
			ans += v[1][i] * 4;
			v[1][i] = 0;
			v[2][i] = 0;
			v[3][i] = 0;
			v[4][i] = 0;
		}
		else if(v[1][i] == v[2][i] and v[2][i] == v[3][i]){
			ans += v[1][i] * 3;
			v[1][i] = 0;
			v[2][i] = 0;
			v[3][i] = 0;
		}
		else if(v[0][i] == v[1][i] and v[1][i] == v[2][i]){
			ans += v[0][i] * 3;
			v[0][i] = 0;
			v[1][i] = 0;
			v[2][i] = 0;
		}
		else if(v[2][i] == v[3][i] and v[3][i] == v[4][i]){
			ans += v[2][i] * 3;
			v[2][i] = 0;
			v[3][i] = 0;
			v[4][i] = 0;
		}
	}

	for(int i = 0; i < 5; i++){
		v[i].erase(remove(v[i].begin(), v[i].end(), 0), v[i].end());
		v[i].resize(h);
	}
}
	cout << ans << endl;
	//init
	v.clear();

}//end

	return 0;
}



Measured memory_bytes: 3108
/*input
5 3 4
12 14 14 14 14
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=55;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll v[maxn];
map<ll,int> mp;
ll C[maxn][maxn];

int main()
{
	IOS;
	REP(i,maxn) REP(j,i+1){
		if(j==0||j==i) C[i][j]=1;
		else C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	int n,a,b;
	cin>>n>>a>>b;
	REP(i,n) cin>>v[i];
	REP(i,n) mp[v[i]]++;
	sort(v,v+n,greater<ll>());

	pll tmp=MP(0,1);
	for(int i=a;i<=b;i++){
		ll sum=0;
		REP(j,i) sum+=v[j];
		if(sum*tmp.S>tmp.F*i){
			tmp=MP(sum,i);
		}
	}
	cout<<fixed<<setprecision(12)<<(double)tmp.F/tmp.S<<'\n';

	ll ans=0;

	for(int i=a;i<=b;i++){
		int cnt=0;
		ll sum=0;
		REP(j,i){
			if(v[i-1]==v[j]) cnt++;
			sum+=v[j];
		}
		if(sum*tmp.S!=i*tmp.F) continue;

		ans+=C[mp[v[i-1]]][cnt];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <utility>
#include <vector>

template <class F> class make_rec {
  F f;

public:
  make_rec(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};

using i64 = long long;

i64 f(i64 n) {return n * (n + 1) / 2;}

int main() {

  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  std::cin >> n;
  std::vector<int> c(n);
  for (int &e : c) {
    std::cin >> e;
    e -= 1;
  }
  std::vector<std::vector<int>> g(n);
  for (int i = 0; i != n - 1; i += 1) {
    int a, b;
    std::cin >> a >> b;
    a -= 1;
    b -= 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  std::vector<i64> size(n, 1);

  make_rec([&](auto &&dfs, int v, int p) -> void {
    for (int e : g[v]) {
      if (e == p)
        continue;
      dfs(e, v);
      size[v] += size[e];
    }
  })(0, n);

  std::vector<i64> count(n, n), ans(n, f(n));

  make_rec([&](auto &&dfs, int v, int p) -> void {
    i64 prev = count[c[v]];
    for (int e : g[v]) {
      if (e == p)
        continue;
      count[c[v]] = size[e];
      dfs(e, v);
      ans[c[v]] -= f(count[c[v]]);
    }
    count[c[v]] = prev - size[v];
  })(0, n);

  for (int i = 0; i != n; i += 1) {
    ans[i] -= f(count[i]);
    std::cout << ans[i] << "\n";
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(20);
    vector<int> b(20);
    vector<int> c(20);
    int point = 0;

    for(int i = 0; i<N; i++){
        cin >> a.at(i);
    }
    for(int i = 0; i<N; i++){
        cin >> b.at(i);
    }
    for(int i = 0; i<N-1; i++){
        cin >> c.at(i);
    }
    for(int i = 0; i < N; i++){
        point += b.at(i);
    }
    for(int i = 0; i < N-1; i++){
        if(a.at(i+1)-a.at(i)==1){
            point += c.at(a.at(i) - 1);
        }
    }
    
    cout << point << endl;
    return 0;
}


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


int main(void)
{
    long long n;
    int p[10000];
    cin >> n;

    int i =0;
    while(n > 0){
           n = n-1;
        p[i] = n % 26;
        n /= 26;
        if(n==0) break;
        i++;  
    }



    string s="";
    for(int j=i; j >= 0; j--){
        string tmp;
        tmp = 'a' + p[j];
        s += tmp;
    }

    cout << s << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >>N;
   vector<int> A(N);
   for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  double S=0;
for (int i = 0; i < N; i++) {
 S +=(1.0/A[i]);
}
 double T=0;
T= 1.0/S;
  cout <<T<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;
  


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     
      int n,m,x;
      cin>>n>>m>>x;
      int a[n][m];
      int c[n];
      for (int i = 0;i<n;i++){
        cin>>c[i];
        for (int j = 0;j<m;j++){
          cin>>a[i][j];
        }
      }
      ll ans = INF;
      for (int mask = 0;mask<(1<<n);mask++){
        vector<int> skill(m);
        ll cost = 0;
        for (int p = 0;p<n;p++){
          if ((1<<p)&mask){
            cost+=c[p];
            for (int i = 0;i<m;i++){
              skill[i]+= a[p][i];
            }
          }
        }
        bool ok = true;
        for (int i = 0;i<m;i++) if (skill[i]<x) ok = false;
        if (ok) ans = min(ans, cost);
      }
      if (ans==INF){
        cout<<"-1\n";
      }else{
        cout<<ans<<"\n";
      }
   
}
  

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

int main() {
	int all, b1, b2, b3, b4, b5, b6, b7, b8, b9;
	while (cin >> all >> b1 >> b2 >> b3 >> b4 >> b5 >> b6 >> b7 >> b8 >> b9) {
		if (all == 0) {
			break;
		}
		cout << all - b1 - b2 - b3 - b4 - b5 - b6 - b7 - b8 - b9 << endl;
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;


int main() {
    LL N, M;
    cin >> N >> M;
    priority_queue<LL, vector<LL>, greater<LL>> A;
    REP(i, N) {
        LL a;
        cin >> a;
        A.push(a);
    }

    // merge the operations
    VP X(M);
    REP(i, M) {
        LL B, C;
        cin >> B >> C;
        X[i] = MP(C, B);
    }
    RSORT(X);
    
    REP(i, M) {
        LL B, C;
        //cin >> B >> C;
        C = X[i].first;
        B = X[i].second;
        //dump(B);
        //dump(C);
        while (B > 0) {
            LL x = A.top();
            if (x < C) {
                A.pop();
                A.push(C);
                B--;
            } else {
                break;
            }
        }
    }
    LL ans = 0;
    while (!A.empty()) {
        LL x = A.top();
        A.pop();
        ans += x;
    }
    cout << ans << endl;
	
    return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
  ll N;
  cin >> N;
  
  if(N==1)
  {
cout << "Hello World" << endl;
  }
  
  else
  {
    ll A, B;
    cin >> A >> B;
    
    cout << A+B << endl;
  }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int a, b;
	while(cin >> a >> b)
	{
		int sum = a + b;
		int count = 0;
		while(sum)
		{
			sum /= 10;
			++count;
		}
		cout << count << endl;
	}
}

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

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

#define ar array
#define ll long long int

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       ll x, k, d;
       cin >> x >> k >> d;
       ll y = abs(x);
       ll q = y / d, r = y % d;
       if (q <= k) {
           k -= q;
           if (k & 1) {
               cout << (x < 0 ? abs(-r + d) : abs(r - d));
           }
           else {
               cout << abs(r);
           }
       }
       else {
           cout << abs(y - k * d);

       }
    }

    return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= MOD;
	if(k%2 == 1){
		ret *= x;
		ret %= MOD;
	}
	return ret;
}

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	
	sort(a,a+n);
	static int b[100010];
	for(int i = 0 ; i < n ; i ++){
		b[i] = abs(i-(n-1-i));
	}
	sort(b,b+n);
	
	for(int i = 0 ; i < n ; i ++){
		if(a[i] != b[i]){
			puts("0");
			return 0;
		}
	}
	cout << modpow(2,n/2) << endl;
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int a,b,c,d;
  int ans;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a*b >= c*d){
    ans = a*b;
  }else{
    ans = c*d;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
N, T = map(int, input().split())
ct = []
for _ in range(N):
    ct.append(list(map(int,input().split())))

ans = 1001
for i in ct:
    if T >= i[1]:
        ans = min(ans, i[0])

if ans == 1001:
    print('TLE')
else:
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void matrixprod(vector<vector<int> > vv, vector<int> w) {
    vector<int> ans;
    int n = vv.size();
    int m = w.size();
    REP(i,n) {
        int k = 0;
        REP(j,m) {
            k += vv[i][j] * w[j];
        }
        ans.push_back(k);
    }
    REP(i,n) {
        cout << ans[i] << endl;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > vv;
    REP(i,n) {
        vector<int> v;
        REP(j,m) {
            int k;
            cin >> k;
            v.push_back(k);
        }
        vv.push_back(v);
    }
    vector<int> w;
    REP(i,m) {
        int j;
        cin >> j;
        w.push_back(j);
    }
    
    matrixprod(vv, w);
    return 0;
}

Measured memory_bytes: 1308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

int dp[2001][2001];

int main(int argc, char *argv[])
{
    int n, y;
    scanf("%d %d", &n, &y);
    y /= 1000;
    int min10 = y / 10;
    y -= min10 * 10;
    int min5 = y / 5;
    y -= min5 * 5;
    int min1 = y;
    if (min10 + min5 + min1 > n)
    {
        puts("-1 -1 -1");
        return 0;
    }
    if (min10 + min5 + min1 == n)
    {
        printf("%d %d %d\n", min10, min5, min1);
        return 0;
    }

    dp[min10][min5] = min10 + min5 + min1;
    for (int i10 = min10; i10 >=1; --i10)
    {
        int i5 = min5 + 2 * (min10 - i10 + 1);
        dp[i10 - 1][i5] = dp[i10][i5 - 2] + 1;
        if (dp[i10 - 1][i5] == n)
        {
            printf("%d %d %d\n", i10 - 1, i5, dp[i10 - 1][i5] - i10 - i5 + 1);
            return 0;
        }
    }
    for (int i10 = min10; i10 >=0; --i10)
    {
        for (int i5 = min5 + 2 * (min10 - i10); i5 >=0; --i5)
        {
            if (i5 >= 1)
            {
                dp[i10][i5 - 1] = dp[i10][i5] + 4;
                if (dp[i10][i5 - 1] == n)
                {
                    printf("%d %d %d\n", i10, i5 - 1, dp[i10][i5 - 1] - i10 - i5 + 1);
                    return 0;
                }
            }
            if (i10 >= 1)
            {
                dp[i10 - 1][i5] = dp[i10][i5] + 9;
                if (dp[i10 - 1][i5] == n)
                {
                    printf("%d %d %d\n", i10 - 1, i5, dp[i10 - 1][i5] - i10 - i5 + 1);
                    return 0;
                }
            }
        }
    }
    puts("-1 -1 -1");
}


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

#define ll long long int
#define mp make_pair 
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define ff first
#define ss second
#define ll_MAX 922337203685477999
#define endl "\n"
inline ll absdiff(ll a,ll b) {return (a>b)?a-b:b-a;}
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt", "w", stdout);

    ll t_c;t_c = 1;
    // cin >> t_c;
    for (ll ti = 0; ti < t_c; ++ti)
    {  
        ll n,r; cin >> n >> r;
        ll ans;
        if(n>=10) ans = r;
        else{
            ans = r+(100)*(10-n);
        }
        cout << ans;
    }
    return 0;       
}       

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void){
    ll N ;
    cin >> N ;
    int a[N] ;
    rep(i , N){
        cin >> a[i] ;
    }
    int now ;
    int ans = 400000000000 ;
    int tmp = 0;
    rep(j , 201){
        now = j - 100 ;
        rep(i , N){
            tmp += (a[i] - now)*( a[i] - now) ;
        }
        if(ans > tmp){
             ans = tmp ;
        }
        tmp = 0 ;
    }
    cout << ans << endl;
    return 0 ;
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long a,b; cin>>a>>b;
    long long ans=((b+1)/2-a/2)%2;
    a--;
    for(long long i=4;;i<<=1ll){
        long long bb=max((b%i+1)-i/2,0ll);
        long long aa=max((a%i+1)-i/2,0ll);
        // cout<<bb<<" "<<aa<<endl;
        ans+=((bb+aa)%2)*(i/2);
        // cout<<ans<<endl;
        if(b<=i/2) break;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  string N;
  cin >> N;

  if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Program.cpp

#include <bits/stdc++.h>
using namespace std;

typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;

#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n)           for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

void solve(int TEST_CASE){
    int n=0;
    int N,M;
    cin >> N >> M;
    char grid[N][M];
    fr(i,N){
    	fr(j,M){
    		cin >> grid[i][j];
    	}
    }
    int dp[N+1][M+1];
    //dp[i][j] -> no. of ways to reach block {i,j}
    fr(i,N+1){
        fr(j,M+1)
            dp[i][j] = 0;
    }

    dp[1][1] = 1;
    frA(i,1,N){
        frA(j,1,M){
            if(grid[i-1][j-1] == '#')
                dp[i][j] = 0;
            else{
                dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1])%(1000000007);
            }
        }
    }
    cout << dp[N][M] << endl;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
vector <int> graph[100005];
int visited[100005];
int path[100005];
int dfs(int u){
	if(visited[u]==1){
		return path[u];
	}
	visited[u]=1;
	int i,l=graph[u].size(),p=1;
	for(i=0;i<l;i++){
		p=max(p,dfs(graph[u][i])+1);
	}
	return path[u]=p;
}
int main(){
	int i,n,m,u,v,ans=0;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>u>>v;
		graph[u].push_back(v);
	}
	for(i=1;i<=n;i++){
		if(visited[i]==0){
			ans=max(ans,dfs(i)-1);
		}
	}
	cout<<ans<<endl;
}

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

int main(void){
   int N;
   cin>>N;
   vector<char> S(N);
   for(int i=0;i<N;i++){
      cin>>S[i];
   }
   int K;
   cin>>K;
   char temp=S[K-1];
   for(int i=0;i<N;i++){
      if(S[i]!=temp){
         S[i]='*';
      }
   }
   for(int i=0;i<N;i++){
      cout<<S[i];
   }
   cout<<endl;
   return 0;
}


Measured memory_bytes: 3628
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

s = readChar()
q = readInt()
qa = []
booh = 0
for i in range(q):
	x = input()
	if x=="1":
		qa.append([1,0,0])
	else:
		x = x.split()
		qa.append([int(x[0]),int(x[1]),x[2]])

def t1(s):
	return s[::-1]

def t2(f,c,s):
	if f==1:
		return c+s
	else:
		return s+c

fi=""
la=""
q = queue.deque()
for a in qa:
	if a[0]==1:
		booh = (booh+1)%2
	else:
		if (a[1]+booh)%2==1:
			fi=a[2]+fi
			q.appendleft(a[2])
		else:
			la+=a[2]

s = "".join(list(q))+s+la
if booh==1:
	s = t1(s)

print(s)

Measured memory_bytes: 27744
#include <iostream>
#include <set>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	set<int> color;
	int rating, free = 0;
	for (int i = 0; i < N; ++i) {
		cin >> rating;
		
		if (rating < 3200) {
			color.insert(rating / 400);
		} else {
			free += 1;
		}
	}
	
	cout << (color.size() == 0 ? 1 : color.size()) << " " << free + int(color.size());
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int sum =0;

		for(int i=1; i<=k; i++){
			for(int j=1; j<=k; j++){
				for(int l=1; l<=k; l++){
					sum += gcd(l , gcd(i,j));
				}
			}
		}
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 35772
N, M, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = [0].concat gets.split.map(&:to_i)
a = 0
b = B.sum
j = M
ans = 0
for i in 0..N
  while a + b > K && j >= 0
    b -= B[j]
    j -= 1
  end
  if j>=0
    ans = [ans, i+j].max
  else
    break
  end
  a += i < N ? A[i] : 0
end
p ans

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// n×mの行列Aのnとmの数、m×1の列ベクトルbのmの数を取得
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		// aの2次元配列とbの1次元配列、答えを入れるcの一次元配列をつくる
		int[][] a = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];

		// 配列に入力値を入れる
		for (int cnt = 0; cnt < n; cnt++) {
			for (int i = 0; i < m; i++) {
				a[cnt][i] = sc.nextInt();
			}
		}

		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}

		// ansを計算してcの一次元配列に入れる
		int ans = 0;
		for (int cnt = 0; cnt < n; cnt++) {
			for (int i = 0; i < m; i++) {
				ans = ans + a[cnt][i] * b[i];
			}
			c[cnt] = ans;
			ans = 0;
		}

		// 答えcを表示
		for (int cnt = 0; cnt < n; cnt++) {
			System.out.println(c[cnt]);
		}
	}
}



Measured memory_bytes: 40652
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n+1,0), b(m+1,0), sa(n+1,0), sb(m+1,0);
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		sa[i] =sa[i-1]+a[i];
	}
	for(int i=1; i<=m; ++i){
		cin >> b[i];
		sb[i] =sb[i-1]+b[i];
	}
	
	int ans=0, j=m;
	for(int i=0; sa[i]<=k && i<=n; ++i){
		while(sa[i]+sb[j]>k) --j;
		ans = max(ans, i+j);
	}

	cout << ans << endl;
}


Measured memory_bytes: 9512
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;
typedef long long ll;

int N, M;
int cnt[100000];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (cnt[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int s;
    cin >> s;
    map<int, int> dic;
    int ans = 0;
    ++dic[s];
    for (int i = 2;;++i)
    {
        if (s & 1)
        {
            s = 3 * s + 1;
        }
        else
        {
            s = s / 2;
        }
        ++dic[s];
        if (dic[s] > 1)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

for _ in range(M-1):
    l, r = map(int, input().split())
    if L < l:
        L = l

    if R > r:
        R = r

print(R-L+1 if R-L >= 0 else 0)


Measured memory_bytes: 3188
#include <cstdio>

int main(){
    char str[1500];

    for (int i = 0; i < 1500; i++){
        str[i] = '\0';
    }

    fgets(str, sizeof(str), stdin);

    for (int i = 0; str[i] != '\0'; i++){
        if (str[i] >= 'A' && str[i] <= 'Z'){
            str[i] += 'a' - 'A';
        }
        else if (str[i] >= 'a' && str[i] <= 'z'){
            str[i] -= 'a' - 'A';
        }
    }
    printf("%s", str);

    return 0;
}

Measured memory_bytes: 944
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

def conv(l):
    #l.reverse()
    ret = 0
    for e in l:
        ret = ret*60+e
    return ret

while True:
    N = int(sys.stdin.readline())
    if N == 0:
        exit()
    a = tuple(tuple(sys.stdin.readline().split()) for _ in range(N)) # multi line with single param
    a = [[conv(list(map(int,s.split(":")))), conv(list(map(int,e.split(":"))))] for s,e in a]

    N = 24*60*60
    imos = [0]*(N+1)

    for s,e in a:
        imos[s] += 1
        if e < N+1 : imos[e] -= 1

    cur = 0
    ret = 0
    for i in range(N):
        cur = cur + imos[i]
        ret = max(ret,cur)
    print(ret)



Measured memory_bytes: 10048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;

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

  int N, A, B;
  cin >> N >> A >> B;

  int a = A * N;
  int b = B;
  if (a < b) cout << a << endl;
  else cout << b << endl;

  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x;
    cin>>x;
    long long int a[x.size()+1];
    a[x.size()]=0;
    for(int i=x.size()-1;i>=0;i--)
    {
      if(x[i]=='W')
        a[i]=a[i+1]+1LL;
      else
        a[i]=a[i+1];
    }
    long long c=0;
    for(int i=0;i<x.size();i++)
    {
      if(x[i]=='B')
        c+= a[i+1];
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int N;
   cin >> N;
   
   int count = 0;
   vector<int> P(N);
   long int min = 10000000;
   for (int i=0; i<N; i++) {
       cin >> P.at(i);
       if (P.at(i) < min) {
           min = P.at(i);
           count++;
       }
       
   }
   
   cout << count << endl;
   
   cout << endl;
   
   
 }


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <iterator>

using namespace std;

int main()
{
  int n,q,c,s,t,x;
  vector<list<int> > a;

  scanf("%d", &n);
  scanf("%d", &q);

  for (int i = 0; i < n; i++) {
    a.emplace_back();
  }

  c = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", &c);
    if (c == 0){
      scanf("%d", &t);
      scanf("%d", &x);
      a[t].push_back(x);
    }else if (c == 1){
      scanf("%d", &t);
      //printf("%dt %dc\n",t,c);
      if (a[t].empty()==false){
        auto itr = a[t].begin();
        for (itr = a[t].begin(); itr!=a[t].end(); ++itr) {
          if (itr!=--a[t].end()){
            printf("%d ",*itr);
          }else{
            printf("%d",*itr);
          }
        }
      }else if(a[t].empty()==true){
        //printf("");
      }
      printf("\n");
    }else if (c == 2){
      scanf("%d", &s);
      scanf("%d", &t);
      a[t].splice(a[t].end(), a[s]);
      a[s].clear();
    }

  }
  return 0;
}



Measured memory_bytes: 18840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,A;
   
 
  cin>>N>>M;
  int answer=N;
  for(int i=0;i<M;i++){
    cin>>A;
    answer-=A;
    
  }
if(answer>=0){
  cout<<answer<<endl;
}else{
  cout<<-1<<endl;  
 }
 
 return 0; 
}

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

/* #include<cstdio>*/
int main(){
	int a, b, c, tmp;
	cin >> a >> b >> c;
	tmp = 0;
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}if (b > c) {
		tmp = b;
		b = c;
		c = tmp;
	}if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	
	cout << a <<" "<<  b << " " << c << endl;


	return 0; 
}


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

using namespace std;

const int mod=1e9+7, maxn=1e5+5;

int n, k;
vector < int > ms[maxn];
bool bio[maxn];

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

int rek(int x, int pos, int pre){
	int res=k-pos-pre;
	bio[x]=1;
	if(res==0){
		return 0;
	}
	for(int i=0; i<ms[x].size(); i++){
		if(!bio[ms[x][i]]){
			res=mul(res, rek(ms[x][i], 1, pos));
			pos++;
		}
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	int a, b;
	for(int i=0; i<n-1; i++){
		cin >> a >> b;
		a--;
		b--;
		ms[a].push_back(b);
		ms[b].push_back(a);
	}
	cout << rek(0, 0, 0) << '\n';
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){



}


void solve(){

    ll a,b;
    cin >> a >> b;
    ll ans = a*b;
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

#define A 100000

int main() {
	static int scores[A + 1];
	int n, k, q, i, a;

	scanf("%d%d%d", &n, &k, &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &a), a--;
		scores[a]++;
	}
	for (a = 0; a < n; a++)
		printf(scores[a] + (k - q) > 0 ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

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



int a, b;

signed main() {
	cin >> a >> b;
	cout << (b%a==0 ? a+b : b-a) << endl;
}

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

vector<int> ps;

void solve(int n, int p){
	auto ite = upper_bound(ps.begin(), ps.end(), n);
	vector<int> w;
	for(int i=0; i<p; ++i)
		for(int j=i; j<p; ++j)
			w.push_back(*(ite+i) + *(ite+j));
	sort(w.begin(), w.end());
//	for(int i=0; i<10; ++i)
//		cout << w[i] << "\n";
	cout << w[p-1] << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	int cnt = 0;
	for(int i=2; cnt<101; ++i){
		bool f = true;
		for(int j=0; j<ps.size()&&ps[j]*ps[j]<=i; ++j)
			if(i % ps[j] == 0){
				f = false;
				break;
			}
		if(f){
			ps.push_back(i);
			if(i > 100000) ++cnt;
		}
	}
	while(1){
		int n, p;
		cin >> n >> p;
		if(n + p == -2) return 0;
		solve(n, p);
	}
}


Measured memory_bytes: 3156
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Measured memory_bytes: 3444
def f
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  selection_sort(a, n)
end

def selection_sort(a,n)
  exchange_counts = 0
  for i in 0..n-1
    minj = i
    for j in i..n-1
      if a[j] < a[minj]
        minj = j
      end
    end
    if i != minj
      a[i], a[minj] = a[minj], a[i]
      exchange_counts += 1
    end
  end
  puts a.join(" ")
  puts exchange_counts
end

f


Measured memory_bytes: 6872
imports System

Module Module1
  public Sub Main()

    Dim Multi as integer = convert.toint32(Console.ReadLine())
    Dim Betw as String() = Console.ReadLine().split(" ")

    Dim FromNum as integer = convert.toint32(Betw(0).tostring)
    Dim ToNum as integer  = convert.toint32(Betw(1).tostring)

    Dim Result as integer

    for i as integer = 0 to 1000

        Result =  i * Multi

	if i * Result < FromNum then 
		
	elseif FromNum <= Result and Result <= ToNum then

		console.writeLine("OK".tostring)

	     exit for

	elseif Result  > ToNum then
	
		console.writeLine("NG".tostring)

	     exit for
	
	end if

    next

  End Sub
End Module


Measured memory_bytes: 27724
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n,k,r,s,p;
	cin>>n>>k>>r>>s>>p;
	string t;
	cin>>t;
	ll ans=0;
	vector<bool>used(n);
	for(int i=0;i<n;i++){
		if(i<k){
			if(t[i]=='r'){
				ans+=p;
			}
			else if(t[i]=='p'){
				ans+=s;
			}
			else{
				ans+=r;
			}
			used[i]=true;
		}
		else{
			if((t[i]=='r'&&t[i-k]!='r')||(t[i]=='r'&&used[i-k]==false)){
				used[i]=true;
				ans+=p;
			}
			if((t[i]=='p'&&t[i-k]!='p')||(t[i]=='p'&&used[i-k]==false)){
				used[i]=true;
				ans+=s;
			}
			else if((t[i]=='s'&&t[i-k]!='s')||(t[i]=='s'&&used[i-k]==false)){
				used[i]=true;
				ans+=r;
			}
		}
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 512
N = [int(i) for i in list(input())][::-1]

if len(N) == 1:
    print(N[0])
    exit()

p = N[-1]
q = sum(N)

ans = 0
for i in range(len(N)-1):
    if N[i] != 9:
        for j in range(i,len(N)):
            if N[j] != 0:
                N[j] -= 1
                N[i] = 9
            else:
                N[j] = 9

N[-1] = p-1
print(max(sum(N),q))


Measured memory_bytes: 9176
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 1e6+5;
string n;
ll k, dp[105][5][3];

ll f(ll i, ll j, bool maxi) {
    if (dp[i][j][maxi]) return dp[i][j][maxi];
    if (!j) return 1;
    if (i == n.size()) return 0;
    if (!maxi) return dp[i][j][maxi] = 9*f(i+1, j-1, 0) + f(i+1, j, 0);
    int digit = n[i] - '0';
    if (!digit) return dp[i][j][maxi] = f(i+1, j, 1);
    return dp[i][j][maxi] = (digit-1) * f(i+1, j-1, 0) + f(i+1, j-1, 1) + f(i+1, j, 0);
}

pls give {
    AC;
    cin >> n >> k;
    cout << f(0, k, 1) << nl;
}


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

int main()
{
	cin.sync_with_stdio(false);
	map<int, int> ut;
	string com;
	int k;
	while (cin >> com, com != "end") {
		if (com == "insert") {
			cin >> k;
			ut[k]++;
		}
		else {
			int res = ut.rbegin()->first;
			printf("%d\n", res);
			auto ite = ut.find(res);
			if (ite->second == 1) ut.erase(ite);
			else ut[res]--;
		}
	}
	return 0;
}

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

int main() {

     int K;
     cin >> K;



    for (int i = 0; i < K; i++) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636