akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t n, a, b, D, cnt;
  cin >> n >> D;
  cnt = 0;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    if(D*D>=(a*a+b*b)) cnt++;
  }
  cout << cnt;
      
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N; cin >> N;

  vector <string> S(N);

  for (int i = 0; i < N; i++){
    vector <char> s(10);
    for (int j = 0; j < 10; j++){
      cin >> s[j];
    }
    sort(s.begin(), s.end());
    for (int j = 0; j < 10; j++){
      S[i] = S[i] + s[j];
    }
  }
  sort(S.begin(), S.end());

  long long ans = 0, cnt = 1;
  for (int i = 0; i < N - 1; i++){
    if (S[i] == S[i + 1]){
      cnt ++;
    }else{
      long long sum = cnt * (cnt - 1);
      ans += (sum / 2);
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

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

typedef long long ll;

using namespace std;

int main() {
    
    int a,b;
    cin >> a >>b;
    
    int n = b-a-1;
    int ans = n * (n+1) / 2 - a;
    
    cout << ans <<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N), b(N), c(M), d(M);
  rep(i, N) cin >> a[i] >> b[i];
  rep(i, M) cin >> c[i] >> d[i];
  rep(i, N){
    ll ans = -1;
    ll m = INFL;
    rep(j, M){
      if(m > abs(c[j]-a[i]) + abs(d[j]-b[i])){
        m = abs(c[j]-a[i]) + abs(d[j]-b[i]);
        ans = j;
      }
    }
    cout << ans + 1 << endl;
  }



}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
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<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; }
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> pos(N);
  for(int i=1; i<=N; i++){
    int a;
    cin >> a;
    a--;
    pos[a] = i;
  }
  set<int> used;
  used.emplace(0);
  used.emplace(N+1);
  ll ans = 0;
  for(int i=0; i<N; i++){
    auto itr = used.lower_bound(pos[i]);
    int r = *itr;
    itr--;
    int l = *itr;
    ans += (ll)(i+1) * (pos[i]-l) * (r-pos[i]);
    used.emplace(pos[i]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 13548
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>
#include <climits>
#include <map>
#define rep(i, c) for (int i = 0; i < (int)c; i++) //atcoderの解説コードに利用されていたので，ある程度一般生があるかと思われる．

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

    std::map<std::string, int> S;
    rep(i, N)
    {
        std::string temp;
        std::cin >> temp;
        S[temp]++;
    }

if(S.size() == N){std::cout<<"YES"<<std::endl;}
else{std::cout<<"NO"<<std::endl;}

/*    int maxnum = 0;
    for (const auto &x : S)
    {
        int num = x.second;
        maxnum = std::max(maxnum, num);
    }
    for (auto it = S.begin(); it != S.end(); it++)
    {
        if (it->second == maxnum)
        {
            std::cout << it->first << std::endl;
        }
    }*/
    return 0;
}


Measured memory_bytes: 24832
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll a, b, dp[2100][2100], x[2100], y[2100];
int main() {
	cin >> a >> b;
	REP(i, a)cin >> x[i];
	REP(i, b)cin >> y[i];
	REP(i, a) {
		REP(j, b) {
			if (x[i] == y[j]) {
				dp[i + 1][j + 1] += 2 * dp[i][j] + 1;
				dp[i + 1][j + 1] += dp[i][j + 1] + dp[i + 1][j] - dp[i][j] * 2;
			}
			else {
				dp[i + 1][j + 1] += dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
			}
			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + MOD * 3) % MOD;
			//cout << dp[i + 1][j + 1] << endl;
		}
	}
	cout << dp[a][b] + 1 << endl;
}


Measured memory_bytes: 33152
int main(void) {
    int x, y;
    
    while (1) {
        scanf("%d %d", &x, &y);
    
        if (x == y && x == 0) break;
        
        if (x > y) {
            int a = x;
            x = y;
            y = a;
        }
        
        printf("%d %d\n", x, y);
    }
    
    return 0;
}


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

int main()
{
    vector<int> h(0),w(0);
    for (int i=0; ; i++)
    {
        h.push_back(0);
        w.push_back(0);
        cin>>h[i]>>w[i];
        if (h[i]==0 && w[i]==0) break;
    }
    for (int i=0; i<h.size()-1; i++)
    {
        for (int j=0; j<h[i]; j++)
        {
            if (j==0 || j==h[i]-1)
            {
                for (int k=0; k<w[i]; k++) cout<<"#";
            }
            else
            {
                cout<<"#";
                for (int k=0; k<w[i]-2; k++) cout<<".";
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<"\n";
    }
    return 0;
}



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

int main() {
  
  int A,B;
  cin >> A >> B;
  int Fa,Se,Th,Fo,Fi;
  int N=0;
  while (A<B+1){
  
  Fa=A%10;
  Se=A/10%10;
  Th=A/100%10;
  Fo=A/1000%10;
  Fi=A/10000;
  
   if(Fa==Fi && Se==Fo){
    N++;
   }
   else {}
    
  A++;
   
  }
  
  cout << N << endl;
  
  
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k[10000000];
int main(){
  string s;
  int n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>k[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++) ans+=k[i]*k[j];
  }
  cout<<ans<<"\n";
  return(0);
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    int ans;
    if ( s == "SUN") {
        ans = 7;
    } else if ( s == "MON") {
        ans = 6;
    } else if ( s == "TUE") {
        ans = 5;
    } else if ( s == "WED") {
        ans = 4;
    } else if ( s == "THU") {
        ans = 3;
    } else if ( s == "FRI") {
        ans = 2;
    } else if ( s == "SAT") {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = [0] + [int(i) for i in input().split()]

route = [1]
route_set = set()
start = 1
cnt = 0
while True:
  if cnt == K:
    print(route[-1])
    exit()
  elif A[start] in route_set:
    index = route.index(A[start])
    loop = len(route) - index
    break
  else:
    route.append(A[start])
    route_set.add(A[start])
    start = A[start]
    cnt += 1

K -= index
K = K % loop
print(route[index:][K])

Measured memory_bytes: 32280
function main(input) {
  const inp = input.split(' ')  
  
  if (inp[0] >= 10 || inp[1] >= 10) {
    console.log(-1)
  } else {
    console.log(inp[0] * inp[1])
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ll x;
    cin >> x;
    for (ll i=1;i<=9;i++){
        if (x%i==0 && x/i<10){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define size(x) ((int)(x).size())
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

bool cmp(pii a,pii b)
{
	return a.F<b.F;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,tot; cin>>n>>tot;
	vector<pii> v(n);
	For(i,0,n-1)
	{
		cin>>v[i].F>>v[i].S;
	}
	sort(all(v),cmp);
	int now=0,s=0,i=0;
	while(now<tot)
	{
		int t=min(v[i].S,tot-now);
		//cout<<i<<" "<<t<<"\n";;
		s+=t*v[i].F;
		now+=t;
		i++;
	}
	cout<<s<<"\n";
	return 0;
}














Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e5+5;

int a,b,c,n;
int solve(vector<int>& l,int i,int ca,int cb,int cc) {
    if(i==n) {
        if(ca==0 || cb==0 || cc==0) {
            return 1e7;
        }
        return abs(ca-a)+abs(cb-b)+abs(cc-c);
    }
    int ret = solve(l,i+1,ca,cb,cc);
    ret = min(ret,10+solve(l,i+1,ca+l[i],cb,cc));
    ret = min(ret,10+solve(l,i+1,ca,cb+l[i],cc));
    ret = min(ret,10+solve(l,i+1,ca,cb,cc+l[i]));
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>a>>b>>c;
    vector<int> l(n);
    for(int i=0;i<n;i++) {
        cin>>l[i];
    }
    cout<<(solve(l,0,0,0,0)-30);
}


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

const int N = 100000 + 10;

int main()
{
    int a, b;
    while(~ scanf("%d%d", &a, &b))
    {
        if(a + b >= 10) puts("error");
        else printf("%d\n", a + b);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;

    int ans = 0;
    REP(i,N) {
        int cnt[26] = {};
        cnt[A[i] - 'a']++;
        cnt[B[i] - 'a']++;
        cnt[C[i] - 'a']++;
        int max_cnt = -1;
        REP(j,26) {
            max_cnt = max(max_cnt, cnt[j]);
        }
        ans += 3 - max_cnt;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define f(a) memset(a, -1, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define c(m) cout<<"-1"<<endl
#define YY  cout<<"YES"<<endl
#define NY  cout<<"NO"<<endl
#define i(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
const int MOD=1000000007;
const int N=1000005;
typedef long long ll;
ll add(ll x, ll y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

ll inv(ll x)
{
    return binpow(x, MOD - 2);
}

ll divide(ll x, ll y)
{
    return mul(x, inv(y));
}

ll fact[N];

void precalc()//factorial
{
    fact[0] = 1;
    for(int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

ll C(ll n, ll k)//nCr
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}

int main()
{ ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc=1;
    while(tc--)
    {
      int l,r,d;
      cin>>l>>r>>d;
      int k=0;
      for(int i=1;i<=200;i++)
      {
      	if(d*i>=l&&d*i<=r)
      	k++;
      else	if(d*i>r)
      	break;
	  }
	  cout<<k;
    }
    
	return 0;
}


Measured memory_bytes: 3588
import math
import itertools
N= int(input())
zahyou=[list(map(int,input().split())) for i in range(N)]
lis = [i for i in range(N)]
permutations_lis=itertools.permutations(lis)
goukei=0
for i in permutations_lis:
    for j in range(N-1):
        goukei += math.sqrt(pow((zahyou[i[j+1]][0]-zahyou[i[j]][0]),2)+pow((zahyou[i[j+1]][1]-zahyou[i[j]][1]),2))
print(goukei/math.factorial(N))
        

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> c(3);
  repeat(i,3)cin>>c[i];
  cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char henkan(int a,int b){
	switch(a){
	case 1:
		switch(b % 5){
		case 0:
			return ' ';
		case 1:
			return '.';
		case 2:
			return ',';
		case 3:
			return '!';
		case 4:
			return '?';
		}
	case 2:
		switch(b % 3){
		case 0:
			return 'c';
		case 1:
			return 'a';
		case 2:
			return 'b';
		}
	case 3:
		switch(b % 3){
		case 0:
			return 'f';
		case 1:
			return 'd';
		case 2:
			return 'e';
		}
	case 4:
		switch(b % 3){
		case 0:
			return 'i';
		case 1:
			return 'g';
		case 2:
			return 'h';
		}
	case 5:
		switch(b % 3){
		case 0:
			return 'l';
		case 1:
			return 'j';
		case 2:
			return 'k';
		}
	case 6:
		switch(b % 3){
		case 0:
			return 'o';
		case 1:
			return 'm';
		case 2:
			return 'n';
		}
	case 7:
		switch(b % 4){
		case 0:
			return 's';
		case 1:
			return 'p';
		case 2:
			return 'q';
		case 3:
			return 'r';
		}
	case 8:
		switch(b % 3){
		case 0:
			return 'v';
		case 1:
			return 't';
		case 2:
			return 'u';
		}
	case 9:
		switch(b % 4){
		case 0:
			return 'z';
		case 1:
			return 'w';
		case 2:
			return 'x';
		case 3:
			return 'y';
		}
	default:
		return 'NUL';
	}
}

int main(void){
	int n,i,j;
	char c[1025] = {0};
	char r;
	
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		int a = 0,b = 0;
		scanf("%c",&r);
		scanf("%s",c);
		for(j = 0;j < strlen(c);j++){
			if(c[j] == '0'){
				if(c[j - 1] != '0' && j != 0) printf("%c",henkan(a,b));
				a = b = 0;
			}else{
				a = c[j] - '0';
				b++;
			}
		}
		printf("\n");
	}
	return 0;
}


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

int main() {
  int n,x;
  cin >> n;
  x = 0;
  vector<int> vec(n);
  for(int i = 0 ; i < n ; i++){
    cin >> vec.at(i);
    x += vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  x -= vec.at(0)/2;
  
  cout << x << endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def f(a, x):
    return a[x]


def binary_search(s, t, d, target):
    ok = s - 1
    ng = t

    while ng - ok > 1:
        mid = (ng + ok) // 2
        if f(d, mid) <= target:
            ok = mid
        else:
            ng = mid

    return ok


# 二分探索 ok ng
def main():
    N = I()
    A = LI()
    B = LI()
    C = LI()
    A = sorted(A)
    C = sorted(C)
    ans = 0
    # print(A)
    # print(C)

    for i in range(N):
        a_idx = bisect.bisect_left(A, B[i])
        c_idx = bisect.bisect_right(C, B[i])
        ans += a_idx * (N - c_idx)
        # print(B[i], a_idx * (N - c_idx))
        # print(B[i], a_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 93604
import sys
t=list(zip(*[[int(n[:-1] or 0),int(n[-1])] for n in (list(sys.stdin.read().split()))]))
print((sum(t[0])+len((u:=sorted(filter(lambda n:n>0,t[1])))[:0:-1]))*10+(u and u[0] or 0))

Measured memory_bytes: 9140
#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>;

vector<bool> eratos(ll n) {
  vector<bool> primes(n + 1, true);
  primes[0] = primes[1] = false;
  for (ll i = 2; i * i <= n; i++) {
    if (primes[i]) {
      ll j = i + i;
      while (j <= n) {
        primes[j] = false;
        j += i;
      }
    }
  }
  return primes;
}

// 素数か判定する
bool isPrime(ll n) {
  if (n <= 1) {
    return false;
  }
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int q;
  cin >> q;
  vector<P> lr(q);
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    lr.at(i) = make_pair(l, r);
  }
  const int MAX = 100'000;
  vector<bool> e = eratos(MAX);
  // 2017に似た数の累積和
  vector<int> s(MAX + 1, 0);
  for (int i = 1; i <= MAX; i++) {
    if (i % 2 == 0) {
      s.at(i) = s.at(i - 1);
      continue;
    }
    if (i == 1) {
      s.at(i) = 0;
      continue;
    }
    if (isPrime(i) && isPrime((i + 1) / 2)) {
      s.at(i) = s.at(i - 2) + 1;
    } else {
      s.at(i) = s.at(i - 2);
    }
  }
  rep(i, q) {
    P x = lr.at(i);
    int l = x.first;
    int r = x.second;
    cout << (s.at(r) - s.at(l - 1)) << endl;
  }
  return 0;
}


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

struct gg{
  ll a;
  ll b;
  bool operator<( const gg& right ) const {
        return a == right.a ? b < right.b : a < right.a;
    }
};

int main(){
  ll n,m;
  cin >> n >> m;
  vector<gg> c(n);
  
  FOR(i,n){
    cin >> c[i].a >> c[i].b;
  }
  sort(c.begin(),c.end());
  ll v=0,ans;
  FOR(i,n){
    if(v+c[i].b>m){
      FOR(j,m){
        if(v==m){
          break;
        }
        v++;
        ans+=c[i].a;
      }
    }else{
      ans+=(c[i].a)*(c[i].b);
      v+=c[i].b;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll n;
    cin>>n;
    ll i,j;
    i = 1;
    while(1000*i < n)
    {
        i++;
    }
    cout<<1000*i - n;
    
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		Node[] arr = new Node[n];
		for (int i = 0; i < n; i++) {
			Node o = new Node();
			o.i = i;
			arr[i] = o;
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			arr[a].nexts.add(b);
			arr[b].nexts.add(a);
		}
		br.close();

		Queue<Integer> que = new ArrayDeque<>();
		que.add(0);
		arr[0].x = 1;
		while (!que.isEmpty()) {
			int cur = que.poll();
			for (int next : arr[cur].nexts) {
				if (arr[next].x == 0) {
					que.add(next);
					arr[next].x = 3 - arr[cur].x;
				} else if (arr[next].x == arr[cur].x) {
					System.out.println((long) n * (n - 1) / 2 - m);
					return;
				}
			}
		}

		int[] cnt = new int[3];
		for (Node o : arr) {
			cnt[o.x]++;
		}
		System.out.println((long) cnt[1] * cnt[2] - m);
	}

	static class Node {
		int i, x;
		List<Integer> nexts = new ArrayList<>();
	}
}


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

using namespace std;

int main()
{
	string s,t;
	
	cin>>s>>t;
	
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	
	if(t.compare(s)>0) cout<<"Yes\n";
	else cout<<"No\n";
	
	//cout<<s<<endl<<t<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<bool> f(N);
	vector<int> p(N); rep(i, 0, N) {
		cin >> p[i];
		if (p[i] == i + 1)
			f[i] = true;
	}
	int c = 0;
	rep(i, 0, N) {
		if (i != N - 1 && f[i] && f[i + 1]) {
			c++;
			f[i] = f[i + 1] = false;
		}
		if (f[i]) {
			c++;
			f[i] = false;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
h = [int(_) for _ in input().split()]
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <string.h>

int main() {
	int N;
	scanf("%d",&N);
	char S[100001],c1[2],c2[2];
	scanf("%s",S);
	int ans = 1;
	strncpy(c1, S, 1);
	for (int i = 0; i < N-1; i++) {
		strncpy(c2, &S[i+1], 1);
		if (strcmp(c1, c2) != 0) ans += 1;
		strcpy(c1, c2);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<bool> VB;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int p, q, r;
  std::cin >> p >> q >> r;
  cout(std::min(p+q, std::min(q+r, r+p)));
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
		
		String s = in.readLine();
		
		int numA = 0;
		int numB = 0;
		int numC = 0;
		
		int length = s.length();
		
		for(int i = 0; i < length; i++){
			if(s.charAt(i) == 'a'){
				numA++;
			}else if(s.charAt(i) == 'b'){
				numB++;
			}
			else{
				numC++;
			}
		}
		
		//System.err.println(numA + " " + numB + " " + numC);
		
		//compare A and B
		if(Math.abs(numA - numB) > 1){
			//System.err.println("A - B");
			out.write("NO" + "\n");
		}
		else if(Math.abs(numA - numC) > 1){
			//System.err.println("A - C");
			out.write("NO" + "\n");
		}
		else if(Math.abs(numB - numC) > 1){
			//System.err.println("B - C");
			out.write("NO" + "\n");
		}
		else{
			out.write("YES" + "\n");
		}
		
		
		
		
		out.close();
		in.close();
	}
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define int long long
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int fun(string &str)
{
    int ind=-1;
    for(int i=0;i<str.size()-1;i++)
    {
        if(str[i]=='W' && str[i+1]=='R')
        {
            ind=i;
            break;
        }
    }
    return ind;
}
int32_t main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    int r=0,w=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]=='R')
            r++;
        else
            w++;
    }
    int ans=min(r,w);
    int cnt=0;
    for(int i=0;i<r;i++)
    {
        if(str[i]=='R')
        {
            cnt-=1;
        }
    }
    cout<<min(ans,r+cnt);
    return 0;
}


Measured memory_bytes: 3704
N , M = map(int, input().split())
field = []
for i in range(M):
    p,y = map(int, input().split())
    field.append((y, p, i))
field.sort()

sum = [0 for i in range(N)]
field2 = []

for i in range(M):
	sum[field[i][1]-1] += 1
	field2.append((field[i][2], field[i][1], sum[field[i][1]-1]))
field2.sort()
for i in range(M):
	print(str(field2[i][1]).zfill(6)+str(field2[i][2]).zfill(6))




Measured memory_bytes: 34044
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;
ll a[N] , sum;
int main(){
	timefaster;
	int n , k;
	cin >> n >> k;
	for(int i = 1;i <= n;i ++){
	 	cin >> a[i];
	}
	sort(a + 1 , a + n + 1);
	for(int i = 0;i <= n - k;i ++){
	 	sum += a[i];
	}
	cout << sum;
}// Aksay sila

Measured memory_bytes: 1792
#input
N = int(input())
S = []
T = []
for i in range(N):
    X_temp, L_temp = map(int, input().split())
    S.append(X_temp - L_temp)
    T.append(X_temp + L_temp)

#output
import numpy as np
S = np.array(S)
T = np.array(T)
idx = np.argsort(T)

S = S[idx]
T = T[idx]
answer = 0
length = -10**10
for i in range(N):
    if length <= S[i]:
        answer += 1
        length = T[i]

print(answer)

Measured memory_bytes: 21236
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val a = cin.nextInt()
  val b = cin.nextInt()

  if (a + b === 15) {
    println("+")
  } else if (a * b == 15) {
    println("*")
  } else {
    println("x")
  }

  cin.close()
}

Measured memory_bytes: 31268
N,M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
ab.sort(reverse=True)
cnt = 0
money = 0
while True:
    a,b = ab.pop()
    if cnt+b==M:
        money += b*a
        break
    elif cnt+b>M:
        money += (M-cnt)*a
        break
    else: #cnt+b<M
        money += b*a
        cnt += b
print(money)

Measured memory_bytes: 16976
#include <iostream>
#include <cstring>
#include <cstdio>
#include <utility>
#include <algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int INF = 1 << 29;
int n,k;
int solve(){
    int i=0;
while(n-pow(k,i)>=0){
    i++;
}
return i;
}
int main(){
cin>>n>>k;
cout<<solve()<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
const int SUBJECT = 5;		// 試験科目の数
using namespace std;

int main(void) {
  int n;

  while (cin >> n) {
    if (n == 0) break;

    vector<int> perf;
    for (int i = 0; i < n; i++) {
      int tmp, sum = 0;
      for (int j = 0; j < SUBJECT; j++) {
	cin >> tmp;
	sum += tmp;
      }
      perf.push_back(sum);
    }

    sort(perf.begin(), perf.end());

    cout << perf[n-1] << " " << perf[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    string str = to_string(i);
    ll sum = 0;
    for (int i = 0; i < str.size(); i++) {
      sum += (str[i] - '0');
    }
    if (A <= sum && sum <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double EPS=1e-10;
struct point{
	double x,y;
	point(const point&a):x(a.x),y(a.y){}
	point(const double&x=0,const double&y=0):x(x),y(y){}
	point operator+(const point&p)const{return point(x+p.x,y+p.y);}
	point operator-(const point&p)const{return point(x-p.x,y-p.y);}
	point operator*(const double&k)const{return point(x*k,y*k);}
	point operator/(const double&k)const{return point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}
	void operator=(const point&a){
		x=a.x,y=a.y;
	}
	bool operator<(const point&p)const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator==(const point&p)const{
		return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
	}
	friend double dot(const point&a,const point&b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const point&a,const point&b){
		return a.x*b.y-a.y*b.x;
	}
};
typedef point vector;
struct segment{
	point p1,p2;
	segment(const double&a,const double&b,const double&c,const double&d){
		p1.x=a,p1.y=b,p2.x=c,p2.y=d;
	}
	segment(const point&a, const point&b):p1(a),p2(b){}
	point get_vec()const{return point(p2.x-p1.x,p2.y-p1.y);}
};
point project(const segment&s,const point&p){
	vector base=s.get_vec();
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
point reflect(const segment&s,const point&p){
	return p+(project(s,p)-p)*2.0;
}
int ccw(const point&a,const point&b,const point&c){
	vector t1=b-a;
	vector t2=c-a;
	if(cross(t1,t2)>EPS) return 1;
	if(cross(t1,t2)<-EPS) return -1;
	if(dot(t1,t2)<-EPS) return -2;
	if(t1.norm()<t2.norm()) return 2;
	return 0;
}
int main(){
	double a,b,c,d;
	cin>>a>>b>>c>>d;
	point p1(a,b),p2(c,d);
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>a>>b;
		int t=ccw(p1,p2,(point(a,b)));
		if(t==1) cout<<"COUNTER_CLOCKWISE\n";
		else if(t==-1) cout<<"CLOCKWISE\n";
		else if(t==-2) cout<<"ONLINE_BACK\n";
		else if(t==2) cout<<"ONLINE_FRONT\n";
		else cout<<"ON_SEGMENT\n";
	}
	return 0;
}



Measured memory_bytes: 3220
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

i64 hoge(i64 H, i64 W) {
    if (H < 3) return LINF;
    const i64 P = H / 3;

    i64 res = LINF;
    reps(h, P-1, P+1) {
        if (h <= 0) continue;
        i64 rem = H - (2 * h);
        if (rem <= 0) continue;
        chmin(res, abs(rem * W - h * W));
    }

    return res;
}

i64 foo(i64 H, i64 W) {
    i64 res = LINF;
    reps(w, 1, W-1) {
        const i64 left = H * w;
        const i64 right_top = (H / 2) * (W - w);
        const i64 right_bot = H * W - left - right_top;
        chmin(res, max({left, right_top, right_bot}) - min({left, right_top, right_bot}));
    }
    return res;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 H, W;
    read(H, W);

    i64 ans = LINF;
    chmin(ans, hoge(H, W));
    chmin(ans, hoge(W, H));

    chmin(ans, foo(H, W));
    chmin(ans, foo(W, H));

    print(ans);

    return 0;
}


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

int main(void){
   long n;
   cin >> n;
   vector<long> h(n);;
   for(int i = 0;i < n;i++){
       cin >> h[i];
   }
   h.push_back(10e9 + 1);
   long ans = 0;
   long t = 0;
   for(int i = 1;i <= n;i++){
       if(h[i - 1] >= h[i]){
           t++;
       }else{
           ans = max(ans,t);
           t = 0;
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
input = lambda: sys.stdin.readline().rstrip()
from itertools import accumulate

N, Q = map(int, input().split())

S = input()

cum_sum = [0] * len(S)

for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        cum_sum[i+1] += 1


cum_sum = list(accumulate(cum_sum))

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

    print(cum_sum[r]-cum_sum[l])

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

int main() {
    int N; cin >> N;
    int d[60];
    for(int i = 0; i < N; ++i) cin >> d[i];
    
    int res = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) res += d[i] * d[j];
    }
    
    cout << res << endl;
}


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


int N;
vector<string> vs;
int v[10];


void dfs(int nrest, int idx, int maxn)
{
    if (nrest == 0) {
        string s(N, 'a');
        for (int i = 0; i < N; i++)
            s[i] = 'a' + v[i] - 1;
        vs.emplace_back(s);
        return;
    }
    for (int n = 1; n <= nrest; n++) {
        for (int c = 1; c <= maxn + 1; c++) {
            if (idx > 0 && v[idx - 1] == c)
                continue;
            for (int j = 0; j < n; j++)
                v[idx + j] = c;
            dfs(nrest - n, idx + n, max(maxn, c));
        }
    }
}


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

    cin >> N;
    dfs(N, 0, 0);
    sort(vs.begin(), vs.end());
    for (const auto &s : vs) cout << s << "\n";
    cout << flush;
    return 0;
}


Measured memory_bytes: 7796
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



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

	if (b > 0) {
		printf("%d", max(a + b, a * b));
	} else {
		printf("%d", max(a - b, a * b));
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int w,n,i;
	int a,b,tmp;
	int answer[30];
	
	
	scanf("%d",&w);
	scanf("%d",&n);
	
	for(i=0;i < w;i++){
		answer[i] = i+1;
	}
	
	for(i=0;i < n;i++){
		scanf("%d,%d",&a,&b);
		tmp = answer[a-1];
		answer[a-1] = answer[b-1];
		answer[b-1] = tmp;
	}
	
	for(i=0;i < w;i++){
		printf("%d\n",answer[i]);
	}
	
	return 0;
}

Measured memory_bytes: 596
import itertools

t_list = []
n, m, q = map(int, input().split())
for i in range(q):
    t_list.append(list(map(int, input().split())))

q = []

for i in range(1, m+1):
    q.append(i)

ret = 0

for item in itertools.combinations_with_replacement(q, n):
    score = 0
    for t_item in t_list:
        if item[t_item[1]-1] - item[t_item[0]-1] == t_item[2]:
            score += t_item[3]
    ret = max(ret, score)

print(ret)


Measured memory_bytes: 67984
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> ans(100100, 0);

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans.at(a+2)--;
        if(a != 0) a--;
        ans.at(a)++;
    }

    for(int i = 0; i < 100010; ++i) {
        ans.at(i+1) += ans.at(i);
    }

    int ansmax = 0;
    for(int i = 0; i < 100010; ++i) {
        ansmax = max(ansmax, ans.at(i));
    }

    cout << ansmax << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}


int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World\n";
	} else {
		int a, b;
		cin >> a >> b;
		cout << a + b << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 100010
#define LL long long
using namespace std;
int a[maxn];
LL sum[maxn];
int main(){
	int i,n;
	LL num=1,ans=0;
	scanf("%d",&n);
	for(i=0;i<=n;i++)scanf("%d",&a[i]);
	for(i=n;i>=0;i--)sum[i]=sum[i+1]+a[i];
	for(i=0;i<=n;i++){
		if(num<a[i]){printf("-1\n");return 0;}
		ans+=num;
		num-=a[i];
		num=min(num<<1,sum[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

    if(h>w){
        if(n%h==0){
            cout << n/h << endl;
        }
        else cout << n/h+1 << endl;
    } 
    else{
        if(n%w==0){
            cout << n/w << endl;
        }
        else cout << n/w+1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,n,c,d,y,temp,m,r,sum,count,k,l,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;
        for(i=0;;i++)
        {
            if(i*i<=n)continue;
            else break;
        }
        cout<<(i-1)*(i-1);
    }
}

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


int main() {
  string s;
  cin>>s;
  if(s=="0"||s=="1"){
    cout<<0<<endl;
  }
  else{
  if(s.size()%2==0){
    int sirokuro=0;
    int kurosiro=0;
    for(int i=0;i<s.size()-1;i+=2){
     if(s.at(i)=='0'){
       sirokuro++;
     }
      if(s.at(i+1)=='1'){
        sirokuro++;
      }
    }
    for(int i=0;i<s.size()-1;i+=2){
      if(s.at(i)=='1'){
       kurosiro++;
     }
      if(s.at(i+1)=='0'){
        kurosiro++;
      }
    }
    cout<<min(sirokuro,kurosiro)<<endl;
  }
  else{
    int sirosiro=0;
    int kurokuro=0;
    for(int i=0;i<s.size()-2;i+=2){
      if(s.at(i)=='0'){
       sirosiro++;
     }
      if(s.at(i+1)=='1'){
        sirosiro++;
      }
    }
    for(int i=0;i<s.size()-2;i+=2){
      if(s.at(i)=='1'){
       kurokuro++;
     }
      if(s.at(i+1)=='0'){
        kurokuro++;
      }
    }
    if(s.at(s.size()-1)=='0'){
      sirosiro++;
    }
    else{
      kurokuro++;
    }
    cout<<min(sirosiro,kurokuro)<<endl;
  }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define ADD(a, b) a = (a + b) % MOD

ll pow(ll x, ll n)
{
  if (n == 0)
    return 1;
  ll res = pow(x * x % MOD, n / 2);
  if (n & 1)
    res = res * x % MOD;
  return res;
}

ll inv(ll n)
{
  return pow(n, MOD - 2);
}

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N)
  cin >> A[i];
  vector<ll> fact(N + 1); // 1!, 2!, N!
  vector<ll> h(N + 1);    // 1/1 + 1/2 + ... + 1/N
  fact[0] = 1;
  h[0] = 0;
  REP(i, N)
  {
    fact[i + 1] = (i + 1) * fact[i] % MOD;
    ADD(h[i + 1], (inv(i + 1) + h[i]) % MOD);
  }
  ll ans = 0;
  REP(i, N)
  ADD(ans, A[i] * (((h[i + 1] + h[N - i]) % MOD - h[1]) % MOD) % MOD * fact[N] % MOD);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560