akhauriyash/Code-Regression huggingface dataset:
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = [0]
a = 0
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        a += 1
        list_c.append(a)
    else:
        list_c.append(a)

for i in range(q):
    g = list_score[i]
    print(list_c[g[1]-1]-list_c[g[0]-1])


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

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

    }
    int res = 0;
    for( int i = 1; i < n - 1; ++i ) {
        if( a[i - 1] < a[i] && a[i] < a[i + 1] || a[i - 1] > a[i] && a[i] > a[i + 1] ) ++res;

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int A[3];
	int K;

	cin >> A[0] >> A[1] >> A[2];
	cin >> K;

	sort(A, A+3);

	cout << (A[0] + A[1] + (A[2] << K)) << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

int n, W;
int w[101], v[101];
map<int, int> dp[101];

int saiki(int i, int o) {
  if(o < 0) return -1000000001;
  if(i == n) return 0;

  if(dp[i].count(o)) return dp[i][o];

  return dp[i][o] = max(saiki(i + 1, o), v[i] + saiki(i + 1, o - w[i]));
}

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

  rep(i, n) cin >> w[i] >> v[i];

  out(saiki(0, W));
}


Measured memory_bytes: 4736
/*
                                Shahriar Hasan
                          "University of Chittagong"
                                CSE 18 Batch
*/
#include <bits/stdc++.h>
using namespace std;

#define nln puts("")                    // newline
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))    //max/min from 3 input

#define even(x) x%2==0                  //even odd
#define odd(x) x%2!=0

#define PI acos(-1)                     // constant + math
#define lcm(a,b) (a*b/gcd(a,b))

#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)          // algorithm habijabi
#define srt(a,n) sort(a,a+n)
#define srtt sort(a.begin(),a.end())
#define cnt(x) count(a,a+n,x)
#define F first
#define S second
#define all(p) p.begin(),p.end()

#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(ull i=1;i<=n;i++)         //loop
#define forr(i,n) for(int i=n-1;i>=0;i--)
#define mem(a,b) memset(a, b, sizeof(a))
#define fill(a,b) fill(a.begin(),a.end(),b)
#define fill_n(a,n,b) fill_n(a.begin(),n,b)
                        //input
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print0(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define print1(a) for(int i=1;i<=a.size();i++)cout<<a[i]<<endl;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vl;
typedef pair<int,int> pii;           // datatype
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;



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

ull power(int a,int n)              // to the power
{ll multi=1;for(int i=1;i<=n;i++)multi=multi*a; return multi;}
bool isPrime(ull n)                 // prime number check
{if(n==2 | n==3)return true;else{ull m=power(2,n-1);if(m%n==1 && n%2==1)return true;else return false;}}
vi getdiv(ll n){vi div;int i;
    for(i=1;i*i<n;i++)
    {if(n%i==0){div.pb(i);div.pb(n/i);}}if(i*i==n)div.pb(i);            // divisor nirnoy kora
    //sort(div.begin(),div.end());
    return div;}
bool isPalindrome(int n){int num=n,sum=0,mod;
    while(n){mod=n%10;n=n/10;sum=sum*10+mod;}
    if(sum==num)return true;else return false;}


int main()
{
    int a,b;
    cin >> a >> b;
    if(a<=9 && b<=9)cout << a*b << endl;
    else cout << -1 << endl;

    return 0;
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    string sn = "";
    int m;
    string sm = "";
    string tmp;

    cin >> n;
    rep_i(i, n){
        cin >> tmp;
        sn += tmp;
    }

    cin >> m;
    rep_i(i, m){
        cin >> tmp;
        sm += tmp;
    }

    if(sm > sn){
        say(1);
        return 0;
    }
    say(0)
}


Measured memory_bytes: 3228
N, Ma, Mb = gets.split.map(&:to_i)
#N, Ma, Mb = 40, 1, 2
as, bs, cs = [], [], []
N.times do |i|
    as[i], bs[i], cs[i] = gets.split.map(&:to_i)
    #as[i], bs[i], cs[i] = 3.times.map{|_| rand(100)}
end

BIG = 10000

tri = N / 3
div1 = tri
div2 = N - tri
as1, as2, as3 = [as[0...div1], as[div1...div2], as[div2...N]].map{|i| i || []}
bs1, bs2, bs3 = [bs[0...div1], bs[div1...div2], bs[div2...N]].map{|i| i || []}
cs1, cs2, cs3 = [cs[0...div1], cs[div1...div2], cs[div2...N]].map{|i| i || []}

patterns1 = Hash.new(BIG)
(1...2**as1.length).each do |i|
    asum = 0
    bsum = 0
    index = 0
    cost = 0
    while i > 0 do
        if i % 2 == 1
            asum += as1[index]
            bsum += bs1[index]
            cost += cs1[index]
        end
        i >>= 1
        index += 1
    end
    diff = Ma * bsum - Mb * asum
    patterns1[diff] = cost if patterns1[diff] > cost
end

patterns2 = Hash.new(BIG)
(1...2**as2.length).each do |i|
    asum = 0
    bsum = 0
    index = 0
    cost = 0
    while i > 0 do
        if i % 2 == 1
            asum += as2[index]
            bsum += bs2[index]
            cost += cs2[index]
        end
        i >>= 1
        index += 1
    end
    diff = Ma * bsum - Mb * asum
    patterns2[diff] = cost if patterns2[diff] > cost
end

patterns3 = Hash.new(BIG)
(1...2**as3.length).each do |i|
    asum = 0
    bsum = 0
    index = 0
    cost = 0
    while i > 0 do
        if i % 2 == 1
            asum += as3[index]
            bsum += bs3[index]
            cost += cs3[index]
        end
        i >>= 1
        index += 1
    end
    diff = Ma * bsum - Mb * asum
    patterns3[diff] = cost if patterns3[diff] > cost
end

ans = [patterns1[0], patterns2[0], patterns3[0]].min
patterns1[0] = 0
patterns2[0] = 0
patterns3[0] = 0

patterns1.each do |diff1, cost1|
    patterns2.each do |diff2, cost2|
        diff3 = -(diff1 + diff2)
        next unless patterns3[diff3]
        cost = cost1 + cost2 + patterns3[diff3]
        next if cost == 0
        ans = cost if ans > cost
    end
end

if ans == BIG
    puts -1
else
    puts ans
end


Measured memory_bytes: 3964
S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
temp = 0

if S[0] == '<':
    temp = 0
else:
    for i in range(n):
        if S[i] == '>' and S[i + 1] == ('<'):
            temp = i+1
            break
        if i == n - 1:
            print((n + 1) * n // 2)
            exit()
ans += (temp) * (temp + 1) // 2
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) // 2 + r * (r + 1) // 2
print(ans)

Measured memory_bytes: 4232
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;
int min(int, int);
int main()
{
	int N, M, X;
	scanf("%d%d%d", &N, &M, &X);
	int TollGate[N];
	for (int i = 0; i < M; i++) scanf("%d", &TollGate[i]);
	int r_cost = 0, l_cost = 0;
	for (int i = 0; i < M; i++) {
		if(TollGate[i] < X) 
			l_cost++;
		else
			r_cost++;
	}

	printf("%d\n", min(r_cost, l_cost));
	return 0;
}

int min(int a, int b) {
	if (a > b)
		return b;
	else
		return a;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl
#define sz(a) (ll)(a.size())
#define endl "\n"

string s;
ll memo[105][10005][2],d,n,a[10005];

ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= mod)
		return res - mod;
	return res;
}

ll fn(ll sum, ll i,ll f){
  //cout<<i<<" "<<sum<<endl;
  if(i==n){
    if(sum%d==0) return 1;
    else return 0;
  }
  if(memo[sum][i][f]!=-1)
    return memo[sum][i][f];
  ll ans=0;
  if(f==0){
    for(ll digit=0;digit<=a[i]-1;digit++)
      ans=add(ans,fn((sum+digit)%d,i+1,1));
    ans=add(ans,fn((sum+a[i])%d,i+1,0));
  }else{
    for(ll digit=0;digit<=9;digit++)
      ans=add(ans,fn((sum+digit)%d,i+1,1));
  }
  memo[sum][i][f]=ans;
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>s>>d;
  n=sz(s);
  memset(memo,-1,sizeof(memo));
  forn(i,0,n) a[i]=(ll)(s[i]-'0');
  ll ans=fn(0LL,0LL,0LL);
  ans--;
  if(ans==-1) ans=mod-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 17536
import math
n=int(input())
#c=0
#ただのDPやんけ
#0~N
dp=[100000000000000]*(n+1)
dp[0]=0
for i in range(1,min(6,n+1)):
    dp[i]=i
#print(dp)
for i in range(n+1):
    for j in range(1,7):
        if i+6**j<=n:
            dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
    for j in range(1,6):
        if i+9**j<=n:
            dp[i+9**j]=min(dp[i+9**j],dp[i]+1)

print(dp[n])





Measured memory_bytes: 3828
//1_3_C
#include <stdio.h>
#define True 1

int main(void)
{
	int x, y;
	while(True){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0){
			break;
		}
		
		if(x <= y){
			printf("%d %d\n", x, y);
		}else{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
constexpr long long INF = LLONG_MAX;
struct edge { long long t, d; };
int main() {
	long long V,E,r;
	cin>>V>>E>>r;
	vector<vector<edge>> es(V);
	for (auto i = 0; i < E; i++) {
		long long s,t,d;
		cin>>s>>t>>d;
		es[s].push_back({t,d});
	}
	vector<long long> distance(V,INF);
	distance[r] = 0;
	typedef pair<long long,long long> pii;
	priority_queue<pii,vector<pii>,greater<pii>> que;
	que.emplace(0,r);
	while (!que.empty()) {
		pii now = que.top(); que.pop();
		long long v = now.second;
		if (distance[v] < now.first) continue;
		for (auto& i : es[v]) {
			if (distance[i.t] > distance[v]+i.d) {
				distance[i.t] = distance[v]+i.d;
				que.emplace(distance[i.t], i.t);
			}
		}
	}
	for (auto& i : distance)
		cout << (i == INF ? "INF" : to_string(i)) << endl;
	return 0;
}

Measured memory_bytes: 17652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define N 10005
using namespace std;
typedef long long ll;

ll n, k, sum, mx, a[N], ans[N];
vector<ll> gr[N];
queue<ll> qu;
int main() {
	ll i, t, u, v;
	cin>> n;
	for(i=0; i<n-1; i++) {
		scanf("%lld%lld", &u, &v);
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	for(i=0; i<n; i++) {
		scanf("%lld", &a[i]);
		sum += a[i];
		mx = max(mx, a[i]);
	}
	cout<< sum-mx<< endl;
	sort(a, a+n, greater<int>());
	qu.push(1);
	while(!qu.empty()) {
		t = qu.front(); qu.pop();
		ans[t] = a[k++];
		for(auto x: gr[t]) {
			if(!ans[x]) qu.push(x);
		}
	}
	for(i=1; i<=n; i++) printf("%lld ", ans[i]);
	return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
using ll=long long;

const ll INF=1LL<<60;

#include <vector>
#include <numeric>
#include <queue>
#include <functional>

template <typename T>
std::vector<T> dijkstra(const std::vector<std::vector<std::pair<int,T>>> &g,int s){
   //const T INF=std::numeric_limits<T>::max();
   using P=pair<T,int>;
   std::vector<T> dist(g.size(),INF);
   dist[s]=0;
   std::priority_queue<P,std::vector<P>,std::greater<P>> pq;
   pq.emplace(0,s);
   while(!pq.empty()){
      int idx;
      T cost;
      tie(cost,idx)=pq.top();
      pq.pop();
      if(cost>dist[idx]) continue;
      for(auto &e:g[idx]){
         T next_cost=cost+e.second;
         if(next_cost>=dist[e.first]) continue;
         dist[e.first]=next_cost;
         pq.emplace(next_cost,e.first);
      }
   }
   return dist;
}

int main(){
   int V,E,r;
   cin>>V>>E>>r;
   using P=pair<int,ll>;
   vector<vector<P>> g(V);
   for(int i=0;i<E;++i){
      int s,t;
      cin>>s>>t;
      ll d;
      cin>>d;
      g[s].emplace_back(t,d);
   }

   auto d=dijkstra(g,r);
   for(int i=0;i<V;++i){
      if(d[i]==INF) cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
   }
}


Measured memory_bytes: 19320
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353
 
const ll N=1e12;
 
int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}
 
ll solve(){
    
    return 0;
}
 
signed main(){
    IOS
// 	#ifndef ONLINE_JUDGE
//     	freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
    ll n;cin>>n;
  ll m,t;
  cin>>m>>t;
  if(m*t>=n)cout<<"Yes";
 else cout<<"No";
    return 0;
}
// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n;
    cin >> n;
    cout << ceil(((double)n/2)) << endl;
}




Measured memory_bytes: 256
lines = []

while line = gets
  lines << line.chomp.split(' ').map(&:to_i)
end

lines.each do |line|
  next if line[0] == 0 || line[1] == 0
  h_count = 1
  height = line[0].to_i
  line[0].times do
    w_count = 1
    width = line[1].to_i
    hash = []
    line[1].times do
      if h_count == 1 || h_count == height
        hash << "#"
      else
        if w_count == 1 || w_count == width
          hash << "#"
        else
          hash << "."
        end
        w_count += 1
      end
    end
    puts hash.join('')
    h_count += 1
  end
  puts "\n"
end


Measured memory_bytes: 6920
h,w = map(int,input().split())
k = []
h_remove = []
w_remove = []

for i in range(h):
    ls = input()
    if ls.count(".") == w:
        h_remove.append(i)
    k.append(ls)

for i in range(w):
    xx = ""
    for j in range(h):
        xx += k[j][i]
    if xx.count(".") == h:
        w_remove.append(i)

h_remove = set(h_remove)
w_remove = set(w_remove)
for i in range(h):
    ret = ""
    if i in  h_remove:
        continue
    else:
        for j in range(w):
            if j in w_remove:
                continue
            else:
                ret += k[i][j]
        print(ret)

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


int main()
{
    string S;
    cin >> S;
    
    bool flag = false;
    if (S != "AAA" && S != "BBB") {
        flag = true;
    }

    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
S = list(input())
ans = 0

if S.count('R')==0:
    ans = 0
elif S.count('R') == 1:
    ans = 1
elif S.count('R') == 3:
    ans = 3
elif S[0]=='S' or S[2]=='S':
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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



int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int xmax = 0;

    rep(i, N) {
        if (S[i] == 'I')x++;
        else x--;
        xmax = max(xmax, x);
    }
    cout << xmax << endl;
}


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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long div = (n/(a+b))*a;
    long long mod = 0;
    if(n%(a+b) >= a){
        mod = a;
    } else {
        mod = n%(a+b);
    }
    cout << div+mod;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    rep(i,n){
        for(int j=i+1; j<n; ++j){
            ans+=max(0,int(lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1-j));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  int now = 1;
  while(true){
    if(now*now <= n){
      now++;
    }else{
      now--;
      cout << now*now << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
// never give up //
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b=0,c=0,n,i,j,k,l;
	vector<long long > v,z;
	
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		
			v.push_back(a);
		b+=a;	
	}
	sort(v.begin(),v.end());
	if(b%10!=0)
	{
		cout<<b;
	return 0;
	}
	
	else
	if(b%10==0)
	for(i=0;i<v.size();i++)
	{
		if((b-v[i])%10!=0)
			z.push_back(b-v[i]);
		else
		c+=b;
		
		
	}
	if(z.size()==0)
	cout<<0;
	else
	for(i=0;i<z.size();i++)
	{
		cout<<z[0];
		return 0;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }

const int MAX_N = 110000;
int dp[MAX_N]; 

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

    for (int i = 0; i < MAX_N; ++i) dp[i] = N; 
    dp[0] = 0;
    priority_queue<pi, vector<pi>, greater<pi>> que;
    que.push(make_pair(0, 0));

    while (!que.empty()) {
        int cur = que.top().first; // 現在の距離
        int v = que.top().second; // 現在のノード
        que.pop();

        if (cur > dp[v]) continue;

        for (int pow6 = 1; v+pow6 <= N; pow6 *= 6) {
            int nv = v + pow6; 
            if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
        }
        for (int pow9 = 1; v + pow9 <= N; pow9 *= 9) {
            int nv = v + pow9; 
            if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

s  = input()
i  = 0
xs = []

def calc(i, ss, d):
  if i == len(s):
    return d
  for j in range(i + 1, len(s) + 1):
    cs = s[i:j]
    if cs != ss:
      td = calc(j, cs, d + 1)
      if td is not None:
        return td
  return None

print(calc(0, "", 0))

Measured memory_bytes: 184648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;
const  ll NUM=10e8+7;


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

  vector<ll> x(N,0),y(N,0);
  for(ll i=0;i<N;i++){
  cin>>x[i]>>y[i];
  }

  ll maxxy=0;
  ll minxy=INF;
  for(ll i=0;i<N;i++){
    maxxy=max(maxxy,x[i]+y[i]);
    minxy=min(minxy,x[i]+y[i]);
  }
 
  ll maxXY=-INF;
  ll minXY=INF;
  for(ll i=0;i<N;i++){
    maxXY=max(maxXY,x[i]-y[i]);
    minXY=min(minXY,x[i]-y[i]);
  }
  
  
  ll ans=max(maxxy-minxy,maxXY-minXY);
  cout<<ans<<endl;
 

}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
 
  int a, b, c, d, e, count=0;
  for (int i=A; i<=B; i++){
    a = i/10000;
    b = (i-a*10000)/1000;
    c = (i-a*10000-b*1000)/100;
    d = (i-a*10000-b*1000-c*100)/10;
    e = i-a*10000-b*1000-c*100-d*10;
    if (a == e && b == d){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////


int main(){
	bool x;
	cin >> x;
	cout << !x << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <stack>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <map>
#include <list>
using namespace std;

int main()
{
  float A,B,T; cin >> A >> B >> T;
  
  int ans = (int)((T+0.5)/A)*B;
  cout << ans << endl;
}

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

string s;
int ta[26] = {};

int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		ta[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (ta[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    ll K;
    cin >> K;
    ll N=50;
    vector<ll> a(N,0);
    ll tmp;
    REP(i,N){
        a[i]=i+K/N;
    }

    REP(i,K%N){
        a[N-1-i]+=1;
    }

    cout << N << endl;
    REP(i,N){
        cout << a[i];
        if(i!=N-1) cout <<" ";
    }
    cout <<endl;
    
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =40;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int mx = 0 , h , w;
int dist[maxn][maxn];
bool mark[maxn][maxn];
string s[maxn];
queue < pii > q;

void solve(int x ,int y){
    ms(mark , 0);
    dist[x][y] = 0;
    mark[x][y] = 1;
    q.push(pii (x , y));
    while(!q.empty()){
        pii cur = q.front();
        q.pop();
        if(s[cur.first][cur.second] == '#') continue;
        mx = max(mx , dist[cur.first][cur.second]);
        if(cur.first < h - 1 and !mark[cur.first + 1][cur.second]){
            mark[cur.first + 1][cur.second] = 1;
            dist[cur.first + 1][cur.second] = dist[cur.first ][cur.second] + 1;
            q.push(pii(cur.first + 1 , cur.second));
        }
        if(cur.first > 0 and !mark[cur.first - 1][cur.second]){
            mark[cur.first - 1][cur.second] = 1;
            dist[cur.first - 1][cur.second] = dist[cur.first ][cur.second] + 1;
            q.push(pii(cur.first - 1 , cur.second));
        }

        if(cur.second < w - 1 and !mark[cur.first ][cur.second+1]){
            mark[cur.first ][cur.second+1] = 1;
            dist[cur.first ][cur.second+1] = dist[cur.first ][cur.second] + 1;
            q.push(pii(cur.first  , cur.second+1));
        }

        if(cur.second >0  and !mark[cur.first ][cur.second-1]){
            mark[cur.first][cur.second-1] = 1;
            dist[cur.first][cur.second-1] = dist[cur.first ][cur.second] + 1;
            q.push(pii(cur.first , cur.second-1));
        }

    }
}

int main(){
    migmig
    cin >> h >> w;
    for (int i = 0 ; i < h ; i ++){
        cin >> s[i];
    }
    for (int i = 0 ; i < h ; i ++){
        for (int j = 0 ; j < w ; j ++){
            solve( i  , j);
        }
    }
    cout << mx;
    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL pref[N], suff[N], t[N],n;
int32_t main(void) {
    boost;
    cin>>n;
    f1(i,n) cin>>t[i];
    f1(i,n) {
        pref[i]=pref[i-1]+abs(t[i]-t[i-1]);
    }
    for(int i=n;i>=0;i--) {
        suff[i]=suff[i+1]+abs(t[i+1]-t[i]);
    }
    f1(i,n) {
        cout<<pref[i-1]+suff[i+1]+abs(t[i+1]-t[i-1])<<endl;
    }
}


Measured memory_bytes: 10240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

void print(){
	cout << "!" << endl;
}

int n, t;
int pa, pb, pc;
int a, b, c;
int f[1000];

struct abc{
	int a, b, c;
	abc(int a, int b, int c) : a(a), b(b), c(c){}
};

queue<abc> G;

int main(){
	while (cin >> pa >> pb >> pc&&pa + pb + pc){
		fill(f, f + 1000, 2);
		while (!G.empty())G.pop();
		cin >> n;
		REP(i, n){
			cin >> a >> b >> c >> t;
			if (t == 1){
				f[a] = 1;
				f[b] = 1;
				f[c] = 1;
			}
			else G.push(abc(a, b, c));
		}
		while (1){
			int size = G.size();
			abc e = G.front();
			REP(i, size){
				abc p = G.front();
				G.pop();
				if (i != 0 && e.a == p.a&&e.b == p.b&&e.c == p.c)break;
				if (f[p.a]==1 && f[p.b]==1){
					f[p.c] = 0;
				}
				else if (f[p.b]==1 && f[p.c]==1){
					f[p.a] = 0;
				}
				else if (f[p.c] == 1 && f[p.a] == 1){
					f[p.b] = 0;
				}
				else G.push(p);
			}
			if (size == G.size())break;
		}
		FOR(i, 1, pa + pb + pc + 1){
			cout << f[i] << endl;
		}
	}
}

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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;
int idx;
int N, M;
string alphas;
int curr;

void consume(char c) {
  if(idx >= N) throw exception();
  if(S[idx] != c) throw exception();
  idx ++;
}

bool try_consume(char c) {
  try {
    consume(c);
  } catch(...) {
    return false;
  }
  return true;
}

int E();

int convert(string const& b) {
  int n = b.size();
  int ret = 0;
  for(int i=0; i<n; i++) {
    ret *= 2;
    assert(isdigit(b[i]));
    ret += b[i] - '0';
  }
  return ret;
}

string B() {
  string ret;
  while(1) {
    if(S[idx] == '0') ret += '0';
    else if(S[idx] == '1') ret += '1';
    else break;
    idx++;
  }
  return ret;
}

int Nu() {
  if(try_consume('0')) return 0;
  consume('1');
  return convert("1" + B());
}

int F() {
  if(try_consume('-')) {
    return -F();
  }
  else if(try_consume('(')) {
    int r = E();
    consume(')');
    return r;
  }
  else {
    return Nu();
  }
}

int T() {
  int num1 = F();
  while(try_consume('*')) {
    int num2 = F();
    num1 *= num2;
  }
  return num1;
}

int E() {
  int term1 = T();
  while(1) {
    bool cont = 0;
    while(try_consume('+')) {
      cont = 1;
      int term2 = T();
      term1 += term2;
    }
    while(try_consume('-')) {
      cont = 1;
      int term2 = T();
      term1 -= term2;
    }
    if(!cont) break;
  }
  return term1;
}

bool Q() {
  int expr1 = E();
  consume('=');
  int expr2 = E();
  return expr1 == expr2 && idx == N;
}

int main() {

  string T = "01+-*()=";
  sort(T.begin(), T.end());
  string RS; cin >> RS;
  N = RS.size();
  for(auto c: RS) if(isalpha(c)) alphas.push_back(c);
  sort(alphas.begin(), alphas.end());
  alphas.erase(unique(alphas.begin(), alphas.end()), alphas.end());
  M = alphas.size();

  if(M > T.size()) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  set<string> st;
  do {
    S = RS;
    rep(i, N) {
      if(isalpha(S[i])) S[i] = T[alphas.find(S[i])];
    }
    if(!st.count(S)) {
      st.insert(S);
      idx = curr = 0;
      try { ans += Q(); } catch (...) {}
    }
  } while(next_permutation(T.begin(), T.end()));
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    int N,Y,dif,A=10000,B=5000,C=1000;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            dif=Y-(A*i+B*j);
            if(dif<0){
                break;
            }else if(dif/C==N-(i+j)){
                cout<<i<<endl<<j<<endl<<N-(i+j)<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl<<-1<<endl<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int N;
ll d[101];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>N;
	for(int i=0;i<N;i++) cin>>d[i];
	int ans=0;
	sort(d,d+N);
	for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) for(int k=j+1;k<N;k++) if(d[i]+d[j]>d[k]){
		if(d[i]==d[j]||d[j]==d[k]) continue;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
	int a, b, c, k, max = 0;
	scanf("%d %d %d %d", &a, &b, &c, &k);

	if(a < k){
		max += a;
		if(b < k - a){
			max = max - (k - a - b);
		}
	}else{
		max += k;
	}

	printf("%d", max);
}


Measured memory_bytes: 1736
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = 0
    t = sum(x) // n
    for i in range(n):
        ans += (x[i] - t) * (x[i] - t)
    a = ans
    ans = 0
    t += 1
    for i in range(n):
        ans += (x[i] - t) * (x[i] - t)
    print(min(ans, a))

        
   

main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 0;
  for (int i = 0; i < n - m + 1; ++i) {
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      if (s[i + j] == t[j]) {
        ++cnt;
      }
    }
    ans = max(ans, cnt);
  }
  cout << m - ans << '\n';
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define MAX 1000000007
#define ull unsigned long long int
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

int main(){
    // fast i/o
    ios_base::sync_with_stdio(false);
    // unties cout and cin streams....
    cin.tie(0); cout.tie(0);
//    int t;
//    cin>>t;
//    while(t--){
//
//    }
      string s;
      cin>>s;
      if(s=="ARC"){
          cout<<"ABC"<<endl;
      }
      else{
          cout<<"ARC"<<endl;
      }
    return 0;
}

Measured memory_bytes: 3652
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(u64);
    let X1 = 0u64;
    let Y1 = 0u64;
    let sqrtS = (S as f64).sqrt().ceil() as u64;
    let X2 = sqrtS;
    let Y3 = sqrtS;
    let gap = X2*Y3 - S;
    let X3 = gap;
    let Y2 = 1u64;
    println!("{} {} {} {} {} {}", X1, Y1, X2, Y2, X3, Y3);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
ll d;
int n;

void solve(){
	scanf("%d %lld",&n,&d);
	int res=0;
	for(int i=1;i<=n;i++){
		ll x,y;
		scanf("%lld %lld",&x,&y);
		if(x*x+y*y<=d*d)	res++;
	}
	printf("%d\n",res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#define ll long long
const int N=2e5+5,mo=1e9+7;
int n,m,a,b,i,ans,fact[N],inv[N],fv[N];
int C(int n,int m){return (ll)fact[n]*fv[m]%mo*fv[n-m]%mo;}
int cal(int n,int m){return C(n+m,m);}
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	fact[0]=fact[1]=inv[1]=fv[0]=fv[1]=1;
	for (i=2;i<=n+m-2;i++){
		fact[i]=(ll)fact[i-1]*i%mo;
		inv[i]=(ll)inv[mo%i]*(mo-mo/i)%mo;
		fv[i]=(ll)fv[i-1]*inv[i]%mo;
	}
	for (i=b+1;i<=m;i++)
		ans=(ans+(ll)cal(n-a-1,i-1)*cal(a-1,m-i))%mo;
	printf("%d",ans);
}

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


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  string s,t;
  cin>>s>>t;

  {
    set<char> sc(s.begin(),s.end());
    for(char c:t) if(!sc.count(c)) drop(-1);
  }

  Int n=s.size();
  string b=s+s;
  vector<Int> arr(26,n*2);
  vector< vector<Int> > nxt(n*2,arr);
  for(Int i=n*2-1;i>=0;i--){
    nxt[i]=arr;
    arr[b[i]-'a']=i;
  }

  Int pos=-1;
  for(char c:t){
    if(pos<0){
      pos=arr[c-'a'];
    }else{
      Int dst=nxt[pos%n][c-'a']-(pos%n);
      pos+=dst;
    }
  }
  cout<<pos+1<<endl;
  return 0;
}


Measured memory_bytes: 49152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  string s;
  cin >> s;
  if(s=="RRR") cout << 3 << endl;
  else if(s=="RRS"||s=="SRR") cout << 2 << endl;
  else if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR") cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {

  int a, b, c, count = 0, i;

  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++) {
    
    if(c % i == 0) {
    count = count + 1;
    }
 
 }
 
  printf("%d\n", count);

  return 0;
 
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[10100][10100];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    rep(i, s.size()){
      s[i] = 'x';
    }
    print(s);
}


Measured memory_bytes: 256
# 1. 3つとも違う数字
#  => 小さいふたつを + 1
# 2. 2つ同じ数字
#  => 1つだけの数字が小さい
#     小さい数字を + 2
#  => 1つだけの数字が大きい
#     小さいふたつを + 1
a, b, c = map(int, input().split())
result = 0
while True:
  if a == b and b == c:
    break
  elif a != b and b != c and a != c:
    if a < b:
      if b < c:
        a += 1
        b += 1
      else:
        a += 1
        c += 1
    else:
      if a < c:
        a += 1
        b += 1
      else:
        b += 1
        c += 1
  else:
    if a == b:
      if a > c:
        c += 2
      else:
        a += 1
        b += 1
    elif b == c:
      if a > b:
        b += 1
        c += 1
      else:
        a += 2
    else:
      # a == c
      if a > b:
        b += 2
      else:
        a += 1
        c += 1
  result += 1
print(result)


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

int main(){
	int n[10];
	int rank[3] = {0,0,0};
	
	for(int i=0 ; i<10 ; i++){
		cin >> n[i] ; 
	}
	
	for(int i=0 ; i<10 ; i++){
		if(rank[0] < n[i]){
			rank[2] = rank[1];
			rank[1] = rank[0];
			rank[0] = n[i];
		}
		else if(rank[1] < n[i]){
			rank[2] = rank[1];
			rank[1] = n[i];
		}
		else if(rank[2] < n[i]){
			rank[2] = n[i];
		}
	}

	for(int i=0 ; i<3 ; i++){
		cout << rank[i] << endl;
	}

	return 0;
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    int n;
    scanf("%d",&n);
    ll a[n],b[n],m,ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=n-1;i>=0;i--){
        m=(a[i]+ans)%b[i];
        if(m!=0){
            ans+=b[i]-m;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())

    x = 800 * N
    y = (N // 15) * 200

    print(x - y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10260
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    double r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 067_arc_b / Link: https://abc052.contest.atcoder.jp/tasks/arc067_b?lang=en  ----- */
/* ------問題------

東西方向にのびる直線上に、N 個の町があります。 町には、西から順に 1 から N までの番号がついています。 直線上には座標が設定されていて、東に行くほど座標が大きくなります。 町 i の座標は Xi です。
あなたは今、町 1 にいて、これからほかの全ての町を訪れたいです。 移動する手段は次の 2 種類あります。
直線上を歩いて移動する。 東西どちらに歩いても、1 移動する度に疲労度が A 上がります。
好きな場所へテレポートする。 テレポートをすると、移動した距離によらず疲労度が B 上がります。
この 2 種類の移動を繰り返して全ての町を最適に回った時、疲労度の上昇値の合計の最小値がいくつになるか求めてください。

-----問題ここまで----- */
/* -----解説等-----

サンプルに答えが書いてある問題
総移動距離は一緒なので隣に移動していくとして、
最適なほうを取っていけば良い。

----解説ここまで---- */

LL N,A,B;

LL ans = 0LL;

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

	cin >> N>>A>>B;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	FOR(i, 0, N - 1) {
		LL val = (a[i + 1] - a[i])*A;
		ans += min(val, B);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
import math
N,M = map(int, input().split())
S = list(map(int, input().split()))

L = math.ceil(sum(S) / (4 * M))
SS = 0
for s in S:
        if s // L >0:
        	SS+=1

if SS >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060