akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    int mx = 0;
    rep(i, t) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    cout << max(0, mx - 1 - k + mx) << endl;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    
    str_n = str(n)

    for i in range(3):
        if str_n[i] == '1':
            print(9,end='')
        else:
            print(1,end='')
        
    print()

if __name__ == '__main__':
    main()


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }

  ll total = accumulate(all(a), 0LL);
  ll x = a[0], y = total - a[0];
  ll ans = abs(x - y);
  rep(i, 1, N - 1) {
    x += a[i], y -= a[i];
    chmin(ans, abs(x - y));
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() 
{ 
    fastio
    ll cur = 1;
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(auto& it : vec) cin>>it;
    for(int i = 0; i<n; ++i) {
        if(vec[i]==0) {
            cout<<0<<endl;
            return 0;
        }
    }
    ll last = 0;
    for(int i = 0; i<n; ++i) {
        cur *= vec[i];
        if(cur<0 || cur<last) {
            cout<<-1<<endl;
            return 0;
        }
        last = cur;
    }
    if(cur>(ll)(powl(10, 18))) {
        cout<<-1<<endl;
        return 0;
    }
    cout<<cur<<endl;
} 

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

int main(){
	set<int> s;
	int n;
	int num;
	cin>>n;
	while(n--)
	{
		scanf("%d",&num);
		if(s.find(num)!=s.end())
		s.erase(num);
		else 
		s.insert(num);
	}
	cout<<s.size()<<endl;

    return 0;
}


Measured memory_bytes: 4864
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, p, ctr = 0;
   cin >> n;
   for (int i = 1; i <= n; i++)
   {
      cin >> p;
      if (p != i)
         ctr++;
   }
   cout << (ctr <= 2 ? "YES" : "NO") << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    int k = stoi(a + b);
    int v = sqrt(k);
    cout << (k == v*v ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#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>
#include <fstream>

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 MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

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;
typedef pair<int, string> PSI;

string s;

int stringtoi(string s){
	int res;
	stringstream ss;
	ss << s;
	ss >> res;
	return res;
}

template <typename List> 
void split(const string s, const string delim, List& result){
	result.clear();

	string::size_type pos = 0;
	while (pos != string::npos){
		string::size_type p = s.find(delim, pos);

		if (p == -1){
			result.push_back(stringtoi(s.substr(pos)));
			break;
		}
		else{
			result.push_back(stringtoi(s.substr(pos, p - pos)));
		}

		pos = p + delim.size();
	}
}

int main(){
	while (getline(cin, s) && s != "0"){
		vector<int> vi;
		int cnt = 0, sum = 0;
		split(s, " ", vi);
		REP(i, vi.size()){
			if (vi[i] == 1)cnt++;
			if (vi[i] >= 10)sum += 10;
			else sum += vi[i];
		}
		while (sum <= 11 && cnt > 0){
			cnt--;
			sum += 10;
		}
		if (sum <= 21)cout << sum << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 1252
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
	  TimeSpan t = new TimeSpan(0, 0, 0);
	  for (int i = 0; i < 4; i++)
	  {
	    t += new TimeSpan(0, 0, cin.nextInt());
	  }
    Console.WriteLine(t.Minutes);
    Console.WriteLine(t.Seconds);
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 5628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    ll n;
    cin>>n;
    vl a(n);
    vb iro(8,false);
    ll legend = 0;
    rep(i,n){
        cin>>a[i];
        if(a[i] <= 399) iro[0] = true;
        else if(a[i] <= 799) iro[1] = true;
        else if(a[i] <= 1199) iro[2] = true;
        else if(a[i] <= 1599) iro[3] = true;
        else if(a[i] <= 1999) iro[4] = true;
        else if(a[i] <= 2399) iro[5] = true;
        else if(a[i] <= 2799) iro[6] = true;
        else if(a[i] <= 3199) iro[7] = true;
        else legend++;
    }
    ll kosu = count(all(iro),true);
    if(kosu == 0){
        cout<<1<<" "<<n<<endl;
    }
    else{
        cout<<kosu<<" "<<kosu+legend<<endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    M = 10**9+7
    a = pow(10,N,M)
    b = pow(9,N,M)
    c = pow(8,N,M)
    return str((a-2*b+c)%M)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int x,a,b;
  cin>>x>>a>>b;
  a=abs(x-a);
  b=abs(x-b);
  if(a<=b){
    cout<<"A"<<"\n";
  }
  else{
    cout<<"B"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int n,a,b,ans;
cin>>a>>b;
a=500*a;
if(a>=b)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   // ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int t;
    cin>>t;
    ll m = 1000000000000000000;
    ll ans = 1;
    ll arr[t];
    memset(arr,0,sizeof(arr));
    int x=0;
    int check =0;
    for(int i=0;i<t;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
            check=1;
    }
    sort(arr,arr+t);
    for(int i=0;i<t;i++)
    {
        ans*=arr[i];
        if(ans==0)
            break;
        if((i+1)<t)
        {
            if((m/ans) < arr[i+1])
            {
                x=1;
                break;
            }


        }
    }
    if(x==1)
        cout<<-1;
    else
        cout<<ans;


}


Measured memory_bytes: 4376
import sys
def input(): return sys.stdin.readline().rstrip()

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

    ans = 0
    for i in range(N):
        s1 = S[:i]
        s2 = S[i:]

        tmp = set()
        for s in s1:
            if s in s2:
                tmp.add(s)
        tmp_len = len(tmp)
        if tmp_len > ans:
            ans = tmp_len
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

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


int main(void) {
    int N, K;
    scanf("%d %d", &N, &K);
    int *h, *dp, *c;
    h = (int*)malloc(N * sizeof(int));
    dp = (int*)malloc(N * sizeof(int));
    c = (int*)malloc((N-1) * sizeof(int));

    int i, j;
    for(i=0; i<N; i++) {
        scanf("%d", &h[i]);
        dp[i] = INT_MAX;
    }
    dp[0] = 0;

    for(i=0; i<N; i++) {
        for(j=1; j<=K; j++) {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
    printf("%d\n", dp[N-1]);
    return 0;
}


Measured memory_bytes: 896
n, m = list(map(int, input().split()))
s = [0] * m
c = [0] * m
for i in range(m):
  s[i], c[i] = list(map(int, input().split()))
if n == 1:
  L = range(10)
if n == 2:
  L = range(10, 100)
if n == 3:
  L = range(100, 1000)
for i in L:
  I = str(i)
  flag = True
  for j in range(m):
    if int(I[s[j]-1]) != c[j]:
      flag= False
  if flag:
    print(i)
    exit()  
print(-1)

Measured memory_bytes: 3064
def main():
    n=int(input())
    ab=[list(map(int,input().split())) for _ in [0]*(n-1)]
    g=[[] for _ in [0]*n]
    [g[a-1].append(b-1) for a,b in ab]
    [g[b-1].append(a-1) for a,b in ab]
    color=[-1]*n
    color[0]=0
    q=[[0,0]]
    while q:
        qq=[]
        while q:
            i,root=q.pop()
            cnt=1
            for j in g[i]:
                if j==root:
                    continue
                if cnt==color[i]:
                    cnt+=1
                color[j]=cnt
                cnt+=1
                qq.append([j,i])
        q=qq
    print(max(color[1:]))
    for i,j in ab:
        print(color[j-1])
main()

Measured memory_bytes: 87256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

ll x;
map< ll ,ll  > ok;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    for(ll i=0; i<=1000; i++){
        x = i*i*i*i*i;
        ok[ x ] = i;
        ok[ -x ] = -i;
    }

    cin >> x;
    for(auto val:ok){
        if( ok.count( val.fi-x ) ){
            cout << val.se << " " << ok[ val.fi-x ];
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3784
/*input
1 629 384378949109878497

*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long int arr[112345],dp[1123456]={0};
long long int pow(long long int a, long long int b, long long int mod){
	if(b==1)return a;
	if(b==0)return 1;
	long long int ret = pow(a, b/2 ,mod);
	ret = ret * ret;
	ret %= mod;
	if(b&1){
		ret=ret*a;
		ret %= mod; 
	}
	return ret;
}

int main() {
	int n,m,ans;
	cin>>n;
	cout<<n/3<<endl;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<=b;i++) if(i-a<k || b-i<k) cout<<i<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define ll long long
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll(i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, std::vector<std::string> s, long long M, std::vector<std::string> t){
    map<string,ll> ma;
    rep(i,N){
        ma[s[i]]++;
    }
    rep(i, M) {
        ma[t[i]]--;
    }   
    ll ans=0;
    for (auto it:ma)    
    {
        if(it.SE>0)ans=max(it.SE,ans);
    }
    op(ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> t(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> t[i];
    }
    solve(N, std::move(s), M, std::move(t));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  int res;
  
  res = 0;
  
  if (str =="SUN"){
    res = 7;
  }
  else if (str =="MON"){
    res = 6;
  }
  else if (str =="TUE"){
    res = 5;
  }
  else if (str =="WED"){
    res = 4;
  }
  else if (str =="THU"){
    res = 3;
  }
  else if (str =="FRI"){
    res = 2;
  }
  else if (str =="SAT"){
    res = 1;
  }
              
   cout << res << endl;
  
  
  
}

Measured memory_bytes: 256
n, y = list(map(int, input().split()))

ans = [-1, -1, -1]
for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if 10000*i + 5000*j + 1000*k == y:
            ans = [i, j, k]
            break
        
print(' '.join(list(map(str, ans))))


Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  pair<int,int> p;
  vector<pair<int,int> > vp;
  int a,b,k=0,r[100],rh;
  char s;
  vp.clear();
  while(1){
    k++;
    cin>>a>>s>>b;
    if(a==0)break;
    p.first=b*-1;
    p.second=a;
    vp.push_back(p);
  }
  sort(vp.begin(),vp.end());
  r[vp[0].second]=1;
  rh=1;
  for(int i=1;i<k-1;i++){
    if(vp[i].first!=vp[i-1].first){
      r[vp[i].second]=++rh;
    }else r[vp[i].second]=rh;
  }
  while(cin>>a){
    cout<<r[a]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2984
#include<iostream>
using namespace std;
int main(){
long long int n;
cin>>n;
long long sum=0;
for(int i=1;i<=n;i++){
    sum+=i;
}
for(int i=1;i<=n;i++){
   if((i%3==0 && i%5==0)|| i%3==0 || i%5==0){
    sum=sum-i;
   }

}
cout<<sum;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  vector<int> a(n,0);
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='C') a[i+1]=a[i]+1;
    else a[i+1]=a[i];
  }
  
  for(int w=0;w<q;w++){
    int l,r;
    cin>>l>>r;
    --l;
    --r;
    cout<<a[r]-a[l]<<endl;
  }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

int r, s, p;

int main() {
  while (cin >> r >> s >> p) {
    map<int, int> cnt;
    for (int i = 0; i < p; ++i) {
      int x, y;
      cin >> y >> x;
      int xx;
      if (x > s) {
        xx = x - s;
      } else {
        xx = s - x + 1;
      }
      int d = (r - (y-1)) + xx;
      ++cnt[d];
    }
    int now = 0;
    for (auto iter : cnt) {
      if (now < iter.first) {
        now = iter.first + iter.second - 1;
      } else {
        now = now + iter.second;
      }
    }
    cout << now << endl;
  }
}



Measured memory_bytes: 3116
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    ABC = sorted(list(map(int, input().split())))

    res = 0
    ABC[0] += ABC[2] - ABC[1]
    res += ABC[2] - ABC[1]
    res += (ABC[2] - ABC[0]) // 2 if (ABC[2] - ABC[0]) % 2 == 0 else (ABC[2] - ABC[0]) // 2 + 2
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a).most_common()
# print(cnt)
ans = 0
for i in cnt:
    if i[0] < i[1]:
        ans += i[1] - i[0]
    elif i[0] == i[1]:
        continue
    else:
        ans += i[1]
print(ans)


Measured memory_bytes: 22576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		int hankei=sc.nextInt();

		double result=(hankei+hankei)*Math.PI;

		System.out.println(result);

	}

}


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

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
L, R = [None] * M, [None] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

l = max(L)
r = min(R)

ans = max(r - l + 1, 0)

print(ans)


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

const int INF = 1e9;

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

  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  vector<char> ans;
  while(n!=0){
    if (abs(n%2)==1){
      ans.push_back('1');
      n=n-1;
    }else{
      ans.push_back('0');
    }
    n=n/(-2);
  }
  reverse(ans.begin(),ans.end());
  for(char c: ans){
    cout<<c;
  }
  cout<<endl;

}

Measured memory_bytes: 256
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main()
        {
            var r = double.Parse(Console.ReadLine());
            
            //円の面積=半径×半径×円周率
            //円周の長さ=直径×円周率
            double f = 3.141592653589;
            
            double s = r * r * f;
            double p = 2 * r * f;
            
            Console.WriteLine("{0} {1}", s, p);
        }
    }
}


Measured memory_bytes: 17920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		char[] s = in.next().toCharArray();
		char[] t = in.next().toCharArray();
		int cnt = 0;
		for(int i = 0; i<3; i++) {
			
			if(s[i] == t[i]) {
				cnt++;
			}
		}

		System.out.println(cnt);
		in.close();


	}

}

Measured memory_bytes: 21844
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static class Pair {
        int u;
        int v;

        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return u == pair.u &&
                    v == pair.v;
        }

        @Override
        public int hashCode() {
            return Objects.hash(u, v);
        }
    }

    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<Integer, Set<Integer>> nodes = new HashMap<>();
        Map<Pair, Long> weights = new HashMap<>();

        for (int i = 0; i < n - 1; ++i) {
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            long w = scanner.nextLong();

                Set<Integer> uEnds = nodes.getOrDefault(u, new HashSet<>());
                uEnds.add(v);
                nodes.put(u, uEnds);
                Set<Integer> vEnds = nodes.getOrDefault(v, new HashSet<>());
                vEnds.add(u);
                nodes.put(v, vEnds);
                weights.put(new Pair(u, v), w);
                weights.put(new Pair(v, u), w);
        }

        int [] colors = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            colors[i] = -1;
        }
        PriorityQueue<Integer> uncolors = new PriorityQueue<>();
        uncolors.add(1);
        colors[1] = 0;
        while (!uncolors.isEmpty()) {
            int current = uncolors.poll();
            int currentColor = colors[current];
            for (Integer end : nodes.getOrDefault(current, new HashSet<>())) {
                if (colors[end] == -1) {
                    long weight = weights.get(new Pair(current, end));
                    if (weight % 2 == 0) {
                        colors[end] = currentColor;
                    } else {
                        colors[end] = 1 - currentColor;
                    }
                    uncolors.add(end);
                }
            }
        }
        for (int i = 1; i <= n; ++i) {
            System.out.println(colors[i]);
        }



    }

}


Measured memory_bytes: 173576
from itertools import combinations
from collections import Counter

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

if N == 1:
    print(1)
    quit()

X.sort()
diff = []
for i, j in combinations(range(N), 2):
    diff.append((X[i][0] - X[j][0], X[i][1] - X[j][1]))
print(N - Counter(diff).most_common()[0][1])




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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#define endl '\n'
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m = ceil((double)n/1.08);
    //cout<<m<<endl;
    //cout<<floor(m*1.08)<<endl;
    if(floor(m*1.08) == n)cout<<m<<endl;
    else cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll n,i,j=0,m=0,a=0,r=0,c=0,h=0;
       std::cin >> n;
       string s[n];
       fr(i,0,n)
       {
           std::cin >> s[i];
           if(s[i][0]=='M')
           m++;
           if(s[i][0]=='A')
           a++;
           if(s[i][0]=='R')
           r++;
           if(s[i][0]=='C')
           c++;
           if(s[i][0]=='H')
           h++;
       }
       ll x[5],sum=0;
       x[0]=m,x[1]=a,x[2]=r,x[3]=c,x[4]=h;
       fr(i,0,5)
       {
           fr(j,i+1,5)
           {
               fr(l,j+1,5)
               {
                   sum+=(x[i]*x[j]*x[l]);
               }
           }
       }
       cout<<sum<<"\n";
   }
}

Measured memory_bytes: 6788
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    int x=n-m,y=n;
    int cnt=0;
    while(x<y){
        cnt ++;
        cout<<x<<" "<<y<<endl;
        x ++;
        y --;
        if(cnt==m) return 0;
    }
    y=n-m-1;
    x=y-(m-1);
    while(x<y){
        cnt ++;
        cout<<x<<" "<<y<<endl;
        x ++,y --;
        if(cnt==m) return 0;
    }
}/*
./problem.exe
*/

Measured memory_bytes: 3656
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t)
    {
        ll n;
        cin>>n;
        if(n>=30)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        t--;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s, t;
    cin >> s >> t;
    map<char, vint> m;
    rep(i, s.size())
    {
        m[s[i]].emplace_back(i + 1);
    }
    if (m[t[0]].size() == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0;
    int pre = -1;
    rep(i, t.size())
    {
        if (!m[t[i]].size())
        {
            cout << -1 << endl;
            return 0;
        }
        int idx = upper_bound(m[t[i]].begin(), m[t[i]].end(), pre) - m[t[i]].begin();
        if (idx == m[t[i]].size())
            idx--;

        if (pre >= m[t[i]][idx])
        {
            // printf("%d %d %c\n", pre, m[t[i]][idx], t[i]);
            // view(m[t[i]]);
            ans += s.size();
            pre = m[t[i]][0];
        }
        else
        {
            pre = m[t[i]][idx];
        }
    }
    ans += pre;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4220
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);++(i))
#define REP1(i,n) for((i)=1;(i)<=(int)(n);++(i))

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int w, a, b; cin >> w >> a >> b;
    int res = 200000;
    if (a < b) {
    	if (a+w >= b) res = 0;
    	else res = b-a-w; 
    } else if (a > b) {
    	if (a <= b+w) res = 0;
    	else res = a-b-w;
    } else {
    	res = 0;
    }
    cout << res << endl;
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];

vector<vector<int> > es;
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].pb(t), es[t].pb(s);
  }
  return 1;
}

bool fail;

long long sum[maxn];

void dfs(int v, int p) {
  if (1 == sz(es[v])) {
    sum[v] = a[v];
    return;
  }

  long long ssum = 0;
  long long mxsum = 0;

  for (int u : es[v]) {
    if (u == p) {
      continue;
    }
    dfs(u, v);
    ssum += sum[u];
    mxsum = max(mxsum, sum[u]);
  }

  long long now = ssum - a[v];

  if (now < 0) {
    fail = 1;
  } else {
    if (now > ssum - mxsum) {
      fail = 1;
    }
    sum[v] = a[v] - now;
    if (sum[v] < 0) {
      fail = 1;
    }
  }
}

void solve() {
  if (n == 2) {
    printf(a[0] == a[1] ? "YES\n" : "NO\n");
    return;
  }
  int root = 0;
  while (root < n && sz(es[root]) == 1) {
    ++root;
  }
  assert(root < n);

  fail = 0;
  dfs(root, -1);
  if (sum[root]) {
    fail = 1;
  }
  printf(!fail ? "YES\n" : "NO\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>
int main ( )
{
int a , b ;
scanf("%d%d",&a,&b) ;
int r = 0 ;
for(int i = a ; i <= b ; i++)
{
int s = i % 10 , t = i / 10000 % 10;
int u = i / 10 % 10 , v = i / 1000 % 10;
if ( s == t&&u == v ) r++;
}
printf("%d\n",r);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

void dfs(int s, const vector<vector<int>>& g, vector<int>& d){
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for (int i = 0; i < g[now].size(); ++i){
            int next = g[now][i];
            if(d[next] == 1000000){
                d[next] = d[now] + 1;
                q.push(next);
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> graph(n + 1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<int> dis1(n + 1, 1000000);
    vector<int> dis2(n + 1, 1000000);
    dis1[1] = 0;
    dis2[n] = 0;
    dfs(1, graph, dis1);
    dfs(n, graph, dis2);
    int fcnt = 0, scnt = 0;
    for (int i = 1; i < n + 1; ++i)
    {
        if(dis1[i] <= dis2[i])
            ++fcnt;
        else
            ++scnt;
    }
    if(fcnt > scnt)
        cout << "Fennec"
             << "\n";
    else
        cout << "Snuke"
             << "\n";
    return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int kind = sc.nextInt();
		int[] number = new int[kind + 1];
		int[] good = new int[kind + 1];
		int[] goodPlus = new int[kind];

		int mansum = 0;

		for (int i = 1; i <= kind; i++) {
			number[i] = sc.nextInt();
		}

		for (int i = 1; i <= kind; i++) {
			good[i] = sc.nextInt();
		}

		for (int i = 1; i < kind; i++) {
			goodPlus[i] = sc.nextInt();
		}

		for (int i = 1; i <= kind; i++) {
			mansum += good[i];
		}

		for (int i = 1; i < kind; i++) {
			if ((number[i] + 1) == number[i + 1]) {
				mansum += goodPlus[number[i]];
			}
		}

		System.out.println(mansum);

	}

}


Measured memory_bytes: 21844
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/5 18:39:28
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 100 + 5;

int vis[N];

void run() {
    int n, k; cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        int d; cin >> d;
        for (int j = 1; j <= d; j++) {
            int x; cin >> x;
            vis[x] = 1;
        }   
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            ++ans;
        }   
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x,y,z,n,m;
	cin >> a >> b;
	x = a+b;
	y = a-b;
	z = a*b;
	n = max(x,y);
	m = max(n,z);
	cout << m;
	return 0;
} 


Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A == 0).sum()

left = -10 ** 18
right = 10 ** 18

while left + 1 < right:
    num = (left + right) // 2

    less_count = 0

    if num >= 0:
        less_count += zeros * n

    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(-num // negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A ** 2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2

    if less_count >= k:
        right = num
    else:
        left = num

print(right)


Measured memory_bytes: 34580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    long n,m;
    cin >> n >> m;

    vector <long> price(n);
    map <long, int> a;// a[値段]=本数
    rep(i,n){
        long c;
        int d;
        cin >> c >> d;

        if(a.count(c)) a.at(c) += d;
        else a[c] = d;
        price[i] = c;
    }

    sort(all(price));
    price.erase( unique (  price.begin() , price.end() ) , price.end() );

    long count=0;
    long sum=0;

    for(long x:price){
        if((count + a.at(x)) >= m){
            sum += x * (m-count);
            break;
        }

        else{
            count += a.at(x);
            sum += x * a.at(x);
        }
    }

    cout << sum << endl;
}


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

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	if (a + k > b - k) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
	}
	else {
		for (int i = a; i < a + k; i++) {
			cout << i << endl;
		}
		for (int i = b - k + 1; i <= b; i++) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y ;
    int ab = 2*c;
    int ans = INF;
    for(int i = 0; i<=max(x,y); i++){
        int cost = ab*i + a*max(0,x-i) + b*max(0,y-i);
        if(ans>cost) ans = cost;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
vector<int> v[MN+5];int n,d[MN+5];
bool cmp(int x,int y){return d[x]>d[y];}
void dfs(int x)
{
	for(int i=0;i<v[x].size();++i)
		dfs(v[x][i]);
	sort(v[x].begin(),v[x].end(),cmp);
	for(int i=0;i<v[x].size();++i)
		d[x]=max(d[x],d[v[x][i]]+i+1);
}
int main()
{
	n=read();
	for(int i=2;i<=n;++i) v[read()].push_back(i);
	dfs(1);
	printf("%d\n",d[1]);
	return 0;
}



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

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

    int N, M;
    cin >> N >> M;

    pair<bool, int> count[N + 1];
    for (int i = 0; i <= N; ++i) {
        count[i] = make_pair(false, 1);
    }
    count[1].first = true;
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        count[x].second--;
        count[y].second++;
        count[y].first |= count[x].first;
        if (count[x].second == 0) {
            count[x].first = false;
        }
    }

    int res = 0;
    for (int i = 1; i <= N; ++i) {
        res += count[i].first;
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define N 200005

vector <int> v[N];

const int inf = 0x3f3f3f3f;
int d[N], p[N];

int BFS(int rt, int n) {
	static queue <int> Q;
	while (!Q.empty()) Q.pop();
	for (int i = 1; i <= n; i ++) d[i] = inf;
	d[rt] = p[rt] = 0;
	Q.push(rt);
	int res;
	while (!Q.empty()) {
		int x = Q.front(); Q.pop();
		res = x;
		for (int i = 0; i < v[x].size(); i ++) {
			int y = v[x][i];
			if (d[y] < inf) continue;
			d[y] = d[x] + 1; p[y] = x;
			Q.push(y);
		}
	}
	return res;
}

int main() {
	int n, x, y;
    scanf("%d", &n);
    for (int i = 1; i < n; i ++) {
		scanf("%d %d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int k = BFS(1, n);
    k = BFS(k, n);
    puts(d[k]%3==1?"Second":"First");
	return 0;
}


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

    
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int64_t count (int64_t x){
    int64_t y = 0;
    int64_t ans = 0;
    for ( int64_t i = 1; i < 1e+15; ++i){
        y = y + i;
        if ( x == y ){
            ans = i;
            break;
        } else if ( y > x ){
            ans = i - 1;
            break;
        }
    }
    return ans;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    
    map<int64_t,int64_t> m;
    for (auto p : res) {
        //for (int i = 0; i < p.second; ++i) cout << " " << p.first;
        for (int i = 0; i < p.second; ++i) {
            m[p.first] = m[p.first] + 1;
        }
    }
    
    
    int64_t ans = 0;
    for ( auto p : m){
        int64_t val = p.first;
        int64_t num = p.second;
        //cout << val << " " << num << endl;
        ans = ans + count(num);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632