akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
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 (a>b) { a=b; return 1; } return 0; }
map<int,int> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
}
int sum=0,eat=0;
bool ok=true;
for(auto p:mp){
    if(p.se==1)sum++;
    else{
        if(p.se>2){
                  if((p.se-3)%2==0)sum++;
                  else eat+=2;
            }
        else eat+=2;
        if(eat>=3){
            sum+=2;
            eat=0;
        }
    }
}
//２枚ダブりが合って終わった場合、sumから１つとって操作を行う必要があるが、制約でsumが必ず１つは存在することが確約されていて\
sumから１枚取ったあと1枚プラスされるためそのような処理をしなくても良い
cout<<sum<<endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 long long INF = 1LL<<60;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}//gcd

int main(){
    int k;cin >> k;
    int Ans = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int t=1;t<=k;t++){
                int tmp = gcd(i,j);
                int ans = gcd(tmp,t);
                Ans+=ans;
            }
        }
    }
    cout << Ans << endl;
}

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

int main(){
    string n;
    cin >> n;
    string ret = "";
    for(size_t i = 0; i < 3; i++)
    {
        if (n[i]=='1')
            ret += '9';
        else
            ret += '1';
    }
    cout << ret << endl;    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 5*1e5 + 10;

int n, a[N], b[N], c[N];

// 0,1,2
int dp[N][4];
std::vector<int> v;

int solve(int idx, int prev){
   if(idx >= n){
      return 0;
   }
   int &ans = dp[idx][prev];//[prev_prev];
   if(ans != -1)
      return ans;
   ans = -inf;
   // if(prev == ){
      for (int i = 0; i < 3; ++i)
      {
         if(i == prev)continue;
         if(i == 0){
            ans = max(ans, solve(idx+1, 0 /*,prev*/)+a[idx]);
         }
         else if(i == 1){
            ans = max(ans, solve(idx+1, 1 /*,prev*/)+b[idx]);
         }
         else if(i == 2){
            ans = max(ans, solve(idx+1, 2 /*,prev*/)+c[idx]);
         }
      }
   // }
   // else{
      // ans = max(ans, solve(idx+1, 0 ,prev)+a[idx]);
      // ans = max(ans, solve(idx+1, 1 ,prev)+b[idx]);
      // ans = max(ans, solve(idx+1, 2 ,prev)+c[idx]);
   // }
   return ans;
}  

int32_t main(){_

   cin>>n;

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

   memset(dp, -1, sizeof dp);
   
   cout<<(solve(0,3));

   return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int n;
    cin >> n;

    if(n<105)
      ppp(0);
    else if(n<135)
      ppp(1);
    else if(n<165)
      ppp(2);
    else if(n<189)
      ppp(3);
    else if(n<195)
      ppp(4);
    else if(n<=200)
      ppp(5);









    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll powl(ll a, ll b) {
	ll c = 1;
	rep(b)
		c = c * a;
	return c;
}


int main() {
	cout.precision(20);
	string S;
	ll N, M, K;
	ll c = 0;
	cin >> N >> K;
	ll i = 1;
	if (N < K) {
		cout << 1;
		return 0;
	}
	while (1) {
		if (N < powl(K, i)) {
			break;
		}
		else if (n == pow(K, i)) {
			i++;
			break;
		}
		i++;
		c++;
	}
	cout << i;
}




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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i,n) cin >> p.at(i);
  sort(p.begin(),p.end());
  ll ans = 0;
  rep(i,k){
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  vector<int> cnt(S.size(), 0);
  string ab = "";
  for (char c = 'a'; c <= 'z'; ++c) {
    ab += c;
  }
  for (int i = 0; i < S.size(); ++i) {
    char s = S[i];
    for (int j = 0; j < 26; ++j) {
      char c = ab[j];
      if (s == c) {
        ++cnt[j];
        break;
      }
    }
  }
  string result = "";
  for (int i = 0; i < 26; ++i) {
    int each = cnt[i];
    if (each == 0) {
      result += ab[i];
    }
  }
  if (result.size() != 0) {
    sort(result.begin(), result.end());
    cout << result[0] << endl;
  } else {
    cout << "None" << endl;
  }
}

Measured memory_bytes: 896
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)

Measured memory_bytes: 47416
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num[30];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s;
	cin>>s;
	REP(i, s.size()){
		++num[s[i]-'A'];
	}
	bool ok=true;
	REP(i, 30){
		if(num[i]>0){
			if(num[i]!=2){
				ok=false;
				break;
			}
		}
	}
	cout<<(ok ? "Yes" : "No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, F[50];
	
	F[0] = F[1] = 1;
	cin >> n;
	for (int i=2; i<=n; i++) F[i] = F[i - 1] + F[i - 2];
	
	cout << F[n] << endl;
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

public class P
{
    public int win { get; set; }
    public int loss { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = "Fire,Scissors,Snake,Human,Tree,Wolf,Sponge,Paper,Air,Water,Dragon,Devil,Lightning,Gun,Rock".Split(',');
        var d = new Dictionary<string, int>();
        var d2 = new Dictionary<int, string>();
        for (int i = 0; i < 15; i++)
        {
            d[line[i]] =14 - i;
            d2[14 -i] = line[i];
        }
        var win = new List<int>[15];
        for (int i = 0; i < 15; i++) win[i] = new List<int>();
        for (int i = 0; i < 15; i++)
            for (int j = 1; j <= 7; j++)
            {
                var p = i - j;
                if (p < 0) p += 15;
                win[i].Add(p);
            }
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var hs = new HashSet<int>();
            for (int i = 0; i < n; i++)
                hs.Add(d[Console.ReadLine().Trim()]);
            getAns(hs, d2, win);
        }
    }
    static void getAns (HashSet<int> hs, Dictionary<int,string> d2, List<int>[] win)
    {
        var a = new P[15];
        for (int i = 0; i < 15; i++) a[i] = new P();
        foreach (var x in hs)
        {
            foreach (var y in win[x])
            {
                if (hs.Contains(y))
                {
                    a[x].win++;
                    a[y].loss++;
                }
            }
        }
        var ok = false;
        for (int i = 0; i < 15; i++)
        {
            if (a[i].win > 0 && a[i].loss == 0)
            {
                ok = true;
                Console.WriteLine(d2[i]);
                break;
            }
        }
        if (!ok) Console.WriteLine("Draw");
    }
}


Measured memory_bytes: 18740
s = input()
moji = ["dream", "dreamer", 'erase', 'eraser']
while s != "":
    if s[-5:] == moji[0]:
        s = s[:-5]
    elif s[-7:] == moji[1]:
        s = s[:-7]
    elif s[-5:] == moji[2]:
        s = s[:-5]
    elif s[-6:] == moji[3]:
        s = s[:-6]
    else:
        break
if s == "":
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    string S;
    cin >> S;
    int Q;
    cin >> Q;
    
    string prefix, suffix;
    bool reversed = false;

    int T, F;
    char C;
    rep(i,Q) {
        cin >> T;
        if (T == 1) {
            reversed = !reversed;
            swap(prefix, suffix);
        } else {
            cin >> F >> C;
            if (F == 1) prefix += C;
            else suffix += C;
        }
    }

    rep(i,prefix.length()) cout << prefix[prefix.length() - (i + 1)];
    if (reversed) rep(i,S.length()) cout << S[S.length() - (i + 1)];
    else cout << S;
    cout << suffix << endl;
    
    return 0;
}

Measured memory_bytes: 1088
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var a = o.l().sort((a,b)=>a-b);
  var f = o.l().sort((a,b)=>b-a);
  var ok = 1e12, ng = -1;
  while(ok-ng > 1){
    var m = Math.floor((ok+ng)/2);
    var cnt = 0;
    for(var i = 0; i < n && cnt <= k; i++){
      if(a[i]*f[i] <= m)continue;
      var b = Math.floor(m/f[i]);
      cnt += a[i]-b;
    }
    if(cnt <= k)ok = m;
    else ng = m;
  }
  return ok;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> L;
    for (int i = 0; i < N; ++i) {
        int l;
        cin >> l;
        L.push_back(l);
    }
    sort(L.begin(), L.end());
    /*
    for (int i = 0; i < N; ++i) {
        cout << L[i] << "\n";
    }
    */
    int ans = 0;
    for (int i = 0; i < N - 2; ++i) {
        int a = L[i];
        for (int j = i + 1; j < N - 1; ++j) {
            int b = L[j];
            for (int k = j + 1; k < N; ++k) {
                int c = L[k];
                if (c < a + b) {
                    ans++;
                } else {
                    break;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

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

  vector<int> cnt(256);

  long long ans = 1;
  for (int i = s.size() - 1; i >= 0; i--) {
    ans += (s.size() - 1 - i) - cnt[s[i]];
    cnt[s[i]]++;
  }

  cout << ans << endl;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0; i < N; i++){
    cin >> p.at(i);
  }
  vector<int> p2 = p;
  sort(p2.begin(), p2.end());
  if(p == p2){
    cout << "YES" << endl;
    return 0;
  }
  vector<int> dif;
  for(int i=0; i < N; i++){
    if (p.at(i) != p2.at(i)){
      dif.push_back(i);
    }
  }
  if(dif.size() > 2){
    cout << "NO" << endl;
    return 0;
  }
  else{
    int a = dif.at(0);
    int b = dif.at(1);
    int pa = p.at(a);
    int pb = p.at(b);
    p.at(a) = pb;
    p.at(b) = pa;
  }
  if(p == p2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  } 

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			String names[] = new String[n];
			int[] ns = new int[30];
			boolean[][] act = new boolean[n][30];
			for (int i = 0; i < n; i++) {
				String name = sc.next();
				names[i] = name;
				int m = sc.nextInt();
				for (int j = 0; j < m; j++) {
					int d = sc.nextInt();
					act[i][d] = true;
					ns[d]++;
				}
			}
			int index = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				int p = 0;
				for (int j = 0; j < 30; j++) {
					if (act[i][j]) {
						p += n - ns[j] + 1;
					}
				}
				if (min > p) {
					min = p;
					index = i;
				} else if (min == p) {
					if (names[i].compareTo(names[index]) < 0) {
						index = i;
					}
				}
			}
			System.out.println(min + " " + names[index]);
		}
	}
}

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

int main(){
  int n,i,cnt,Max;
  cin>>n;
  int h[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  for(i=0;i<n-1;i++){
    if(h[i+1]<=h[i])cnt++;
    else cnt=0;
    Max=max(Max,cnt);
  }
  cout<<Max;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		D, G int
		ans = math.MaxInt32
	)
	fmt.Scan(&D, &G)
	p := make([]int, D+10)
	c := make([]int, D+10)

	for i := 0; i < D; i++ {
		fmt.Scan(&p[i], &c[i])
	}

	for bit := 0; bit < (1 << D); bit++ {
		s, num, max := 0, 0, 0
		for i := 0; i < D; i++ {
			if (bit >> i) & 1 == 1 {
				s += 100 * (i+1) * p[i]  + c[i]
				num += p[i]
			} else {
				max = i
			}
		}
		if s < G {
			s1 := 100 * (max + 1)
			need := (G - s + s1 - 1) / s1
			if need >= p[max] {
				continue
			}
			num += need
		}
		ans = int(math.Min(float64(ans), float64(num)))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int count = 0;
    rep(i,1,N+1){
        int n = i;
        int tt = 0;
        rep(j,1,i+1){
            if(i % j == 0){
                tt++;
            }
        }
        if(tt == 8 && i % 2 == 1){
            count++;
        }

    }
    print(count);

}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(n);
  int list_input(a, n);
  set<int> s(a, a + n);
  out(s.size());
}


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

int dfs(int num, int n, bitset<8> seen, vector<vector<bool>> list) {
  seen.set(num,0);
  int ans=0;
  if(seen.count()==0) {
    ans=1;
  }
  else {
    for(int i=1;i<n;i++) {
      if(list.at(num).at(i)&&seen.test(i)) {
        ans+=dfs(i,n,seen,list);
      }
    }
  }
  return ans;
}
  

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<bool>> list(n,vector<bool>(n,false));
  for(int i=0;i<m;i++) {
    int temp1,temp2;
    cin >> temp1 >> temp2;
    temp1--;
    temp2--;
    list.at(temp1).at(temp2)=true;
    list.at(temp2).at(temp1)=true;
  }
  bitset<8> seen((1<<n)-1);
  cout << dfs(0, n, seen, list) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer count = Integer.parseInt(br.readLine());
		HashMap<Integer, String> spadeMap = new HashMap<Integer, String>();
		HashMap<Integer, String> heartMap = new HashMap<Integer, String>();
		HashMap<Integer, String> clubMap = new HashMap<Integer, String>();
		HashMap<Integer, String> daiyaMap = new HashMap<Integer, String>();
		ArrayList<Integer> spadeList = new ArrayList<Integer>();
		ArrayList<Integer> heartList = new ArrayList<Integer>();
		ArrayList<Integer> clubList = new ArrayList<Integer>();
		ArrayList<Integer> daiyaList = new ArrayList<Integer>();
		for (int i = 1; i < 14; i++) {
			spadeMap.put(i, "×");
			heartMap.put(i, "×");
			clubMap.put(i, "×");
			daiyaMap.put(i, "×");
		}
		for (int i = 0; i < count; i++) {
			String[] numArrays = br.readLine().split(" ");
			if ("S".equals(numArrays[0])) {
				spadeMap.put(Integer.parseInt(numArrays[1]), "◯");
			} else if ("H".equals(numArrays[0])) {
				heartMap.put(Integer.parseInt(numArrays[1]), "◯");
			} else if ("C".equals(numArrays[0])) {
				clubMap.put(Integer.parseInt(numArrays[1]), "◯");
			} else if ("D".equals(numArrays[0])) {
				daiyaMap.put(Integer.parseInt(numArrays[1]), "◯");
			}
		}
		for (Integer key: spadeMap.keySet()) {
			if ("×".equals(spadeMap.get(key))) {
				spadeList.add(key);
			}
		}
		Collections.sort(spadeList);
		for (Integer key: heartMap.keySet()) {
			if ("×".equals(heartMap.get(key))) {
				heartList.add(key);
			}
		}
		Collections.sort(heartList);
		for (Integer key: clubMap.keySet()) {
			if ("×".equals(clubMap.get(key))) {
				clubList.add(key);
			}
		}
		Collections.sort(clubList);
		for (Integer key: daiyaMap.keySet()) {
			if ("×".equals(daiyaMap.get(key))) {
				daiyaList.add(key);
			}
		}
		Collections.sort(daiyaList);
		for (int i = 0; i < spadeList.size(); i++) {
			System.out.println("S " + spadeList.get(i));
		}
		for (int i = 0; i < heartList.size(); i++) {
			System.out.println("H " + heartList.get(i));
		}
		for (int i = 0; i < clubList.size(); i++) {
			System.out.println("C " + clubList.get(i));
		}
		for (int i = 0; i < daiyaList.size(); i++) {
			System.out.println("D " + daiyaList.get(i));
		}
	}
}

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

#define maxn 200005
#define mod 998244353

typedef pair<int, int> P;

ll a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (c <= a + b)
        cout << "No\n";
    else if ((c - a - b) * (c - a - b) > 4 * a * b)
        cout << "Yes" << endl;
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 384
N = int(input())

if N % 2 != 0:
    print('0')
else:
    count = 0
    i = 1

    while True:
        dif = (N // 2) // (5 ** i)
        count += dif
        if dif == 0:
            break

        i += 1

    print(count)


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

int main(){
  int N,x,a[100],i,j,temp,ans=0;
  bool lack=0;
  cin>>N>>x;
  for(i=0;i<N;i++){
  	cin>>a[i];
  }
  for(j=0;j<N-1;j++){
    for(i=0;i<N-1;i++){
      if(a[i]>a[i+1]){
          temp=a[i];
          a[i]=a[i+1];
          a[i+1]=temp;
      }
    }
  }
  temp=x;
  for(i=0;i<N-1;i++){
  	if(temp-a[i]>=0){
    	temp=temp-a[i];
      	ans++;
    }else{
      	lack=1;
    	break;
    }
  }
  if(a[N-1]==temp && lack==0)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
program regist;
var 
    s, t : string;
    i : longint;
    align : boolean;
begin
    readln(s);
    readln(t);
    align := true;
    for i := 1 to length(s) do
        if t[i] <> s[i] then
            align := false;
    if align then
        writeln('Yes')
    else
        writeln('No');
end.

Measured memory_bytes: 1356
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
int n,k,h[100005],ans;
int main(){
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)	scanf("%d",&h[i]);
	for(register int i=1;i<=n;i++)	if(h[i]>=k)	ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    while True:
        x, y = get_li()
        if x == y == 0:
            break
        print(min(x, y), max(x, y))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin>>A>>B>>K;
    for(int i=A;i<=min(A+K-1,B-K);i++){
        cout<<i<<endl;
    }
    for(int i=max(B-K+1,A);i<=B;i++){
        cout<<i<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

int main() {
    int n; cin >> n;
    vector<int> a(n+1); repp(i,1,n+1) cin >> a[i];
    map<int, int> m; repp(i,1,n+1) m[a[i]] += 1;
    repp(i,1,n+1) cout << m[i] << endl;
}


Measured memory_bytes: 13556
#include<iostream>
#include<algorithm>
#include<set>
using lint=int64_t;
using namespace std;

int main()
{
	int N;

	cin >> N;
	set<int> s;
	for(int i=0;i<N;i++)
	{
		int A;
		cin >> A;
		s.insert(A);
	}

	if(s.size()%2==0)
		cout << s.size()-1;
	else
		cout << s.size();
	cout << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <queue>
#define fi first
#define se second
using namespace std;

const int M = 1005, N = 1005, DX[4] = {1, 0, -1, 0}, DY[4] = {0, 1, 0, -1};

int m, n, ans = 0, dis[M][N];
char s[N];
queue<pair<int, int>> q;

bool valid(int u, int v)
{
    if (u <= 0 || u > m || v <= 0 || v > n)
        return false;
    else
        return dis[u][v] == -1;
}

void BFS()
{
    for (; !q.empty(); q.pop())
    {
        pair<int, int> u = q.front();
        for (int i = 0; i < 4; i++)
            if (valid(u.fi + DX[i], u.se + DY[i]))
            {
                ans = max(ans, dis[u.fi + DX[i]][u.se + DY[i]] = dis[u.fi][u.se] + 1);
                q.push({u.fi + DX[i], u.se + DY[i]});
            }
    }
    printf("%d", ans);
}

int main()
{
    scanf("%d %d", &m, &n);
    for (int i = 1; i <= m; i++)
    {
        scanf("%s", s + 1);
        for (int j = 1; j <= n; j++)
            if (s[j] == '#')
            {
                dis[i][j] = 0;
                q.push({i, j});
            }
            else
                dis[i][j] = -1;
    }
    BFS();
}


Measured memory_bytes: 12304
#include <iostream>
#include <stack>
using namespace std;
typedef long long ll;
signed main(){
    string s; cin>>s;
    stack<char> st;
    ll N = s.size();
    ll res = 0;
    for(long long i=0; i<N; i++){
        if(st.empty()){
            st.push(s[i]);
            continue;
        }
        if(s[i]!=st.top()){
            st.pop();
            res+=2;
        } 
        else st.push(s[i]); 
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
// I am Nothing, You Are Nothing!
// Krishna is Everything ...
// Jai Shree Krishna

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, knapsack_capacity;
	cin >> n >> knapsack_capacity;

	vector<int> weight(n + 1), value(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> weight[i] >> value[i];
	}
	int N = n * 1000 + 1;
	vector<vector<int>> dp(n + 1, vector<int>(N + 1, INT_MAX));

	dp[1][value[1]] = weight[1];
	dp[1][0] = 0;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= value[i]) {
				dp[i][j] = min(dp[i][j], weight[i] + dp[i - 1][j - value[i]]);
			}
		}
	}

	int ans;
	for (int i = 0; i < N; i++) {
		if (dp[n][i] <= knapsack_capacity)
			ans = i;
	}

	cout << ans << endl;
	return 0;
}


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

int main() {

  string a,b;
  cin >> a >> b;
  a += b;
  int ans = stoi(a);
  double f = sqrt(ans);
  // cout << ans << endl;
  if (fmod(f,1) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import cmath
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7


def main():
    N=int(input())
    a=list(map(int, input().split()))

    ans=0
    for b in range(60):
        c0=0
        c1=0
        for ai in a:
            if ai & (1<<b):
                c1+=1
            else:
                c0+=1

        ans+=(1<<b)*c0*c1
        ans%=MOD

    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 122936
d=[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]
def f(x,y,a):
    a[y][x]='0'
    for dx,dy in d:
        if 0<=x+dx<8 and 0<=y+dy<8 and a[y+dy][x+dx]=='1':f(x+dx,y+dy,a)
    return a

for i in range(int(input())):
    print('Data %d:'%(i+1))
    input()
    a=[list(input()) for _ in [0]*8]
    for x in f(int(input())-1,int(input())-1,a):print(''.join(x))

Measured memory_bytes: 7608
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    
    vector<int> a_vec(1, 0);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        a_vec.push_back(a);
    }

    vector<int> visited_vec(n + 1, 0);
    visited_vec[1] = 1;
    int cur = 1;
    bool able = true, escape = false;
    
    int ans = 0;
    while (!escape){
        /* code */
        int next = a_vec[cur];
        ans++;
        if(next != 2){
            if(visited_vec[next] == 1){
                escape = true;
                able = false;
            }else{
                cur = next;
                visited_vec[cur] = 1;
            }
        }else{
            escape = true;
        }
    }
    
    if(able) cout << ans << endl;
    else cout << "-1\n";
    return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  int X[N][D];

  for (int k = 0; k < N; k++) {
    for (int l = 0; l < D; l++) {
      cin >> X[k][l];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int diff = 0;
      for (int k = 0; k < D; k++) {
        int d = abs(X[i][k] - X[j][k]);
        diff += d * d;
      }

      bool f = false;
      for (int k = 0; k <= diff; k++) {
        if (k * k == diff) {
          f = true;
        }
      }
      if (f) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

def F(A, B):
    a = len(str(A))
    b = len(str(B))
    return max(a, b)

fmin = 1000000000
for a in range(1, int(N ** 0.5) + 1):
    b = N // a
    if a * b == N:
        fmin = min(fmin, F(a, b))
print(fmin)

Measured memory_bytes: 38896
import java.util.Scanner;

public class Main{

	public static void main(String[] args)  {

		Scanner scan = new Scanner(System.in);
		int numN = scan.nextInt();
		int numM = scan.nextInt();
		int numL = scan.nextInt();
		long[][] arrA = new long[numN][numM];
		long[][] arrB = new long[numM][numL];
		long[][] arrTot = new long[numN][numL];

		for (int i = 0; i < numN; i++) {
			for (int j = 0; j < numM; j++) {
				arrA[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < numM; i++) {
			for (int j = 0; j < numL; j++) {
				arrB[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < numN; i++) {
			for (int j = 0; j < numL; j++) {
				for (int k = 0; k < numM; k++) {
					arrTot[i][j] += arrA[i][k] * arrB[k][j];
				}
			}
		}
		for (int i = 0; i < numN; i++) {
			System.out.print(arrTot[i][0]);
			for (int j = 1; j < numL; j++) {
				System.out.print(" " + arrTot[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 53492
import copy
s = list(input())
t = list(input())
ans_list = []

if len(t)>len(s):
    print('UNRESTORABLE')
    exit()
else:

    for i in range(len(s)-len(t)+1): #sのi番目から部分列を取り出す
        sublist = copy.copy(s)
        for j in range(len(t)):
            if sublist[i+j] == '?':
                sublist[i+j] = t[j]
            elif sublist[i+j] != t[j]:
                break
        else:
            str_ans = ''.join(sublist)
            str_ans = str_ans.replace('?','a')
            ans_list.append(str_ans)

if ans_list:
    ans_list.sort()
    print(ans_list[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3444
#include <iostream>
#include <bitset>
#include <vector>
#include <cstdio>

using namespace std;

const int SZ = 300;

struct Graph {
    int n, m;
    vector<int> g[SZ];
    bool px[SZ];
    int py[SZ];
    int used[SZ];
    int cc;
    int mSize;

    bool dfs(int v) {
        used[v] = cc;
        for (auto to : g[v]) {
            if (py[to] == -1) {
                py[to] = v;
                px[v] = true;
                return true;
            }
        }
        for (auto to : g[v]) {
            if (used[py[to]] != cc && dfs(py[to])) {
                py[to] = v;
                px[v] = true;
                return true;
            }
        }
        return false;
    }

    inline void khun() {
        cc = 1;
        for (int run = 1; run;) {
            run = 0;
            cc++;
            for (int i = 0; i < n; ++i) {
                if (!px[i] && dfs(i)) {
                    run = 1;
                }
            }
        }
    }

    inline int pars() {
        khun();
        mSize = 0;
        for (int i = 0; i < n; ++i) {
            mSize += px[i];
        }
        return mSize;
    }

    inline void add(int v, int u) {
        g[v].push_back(u);
    }

    Graph(int n) : n(n), m(n) {
        fill_n(px, n, false);
        fill_n(py, m, -1);
        fill_n(used, n, 0);
    }
};

int main() {
    int n;
    cin >> n;
    Graph g(n);
    vector<pair<int, int>> pts(n);
    for (auto &p : pts) {
        cin >> p.first >> p.second;
    }
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        for (int j = 0; j < n; ++j) {
            if (x > pts[j].first && y > pts[j].second) {
                g.add(i, j);
            }
        }
    }
    cout << g.pars() << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 838627288460106
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
  fast_io
    ll n,j,ans=0;
    cin>>n;
    for(j=1; j<=n; j++)
    {
        ans+=j*(n/j)*(n/j+1)/2;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}





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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    int n;
    cin >> n;
    struct UnionFind uf(n);
    int m;
    cin >> m;
    int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        uf.unionSet(a-1,b-1);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(uf.findSet(i,p[i]-1)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n, Q;
int a[100005];

int main(void)
{
	string s;
	cin >> n >> Q;
	cin >> s;
	s = "#" + s;
	
	for(int i = 1; i < n; i++){
		a[i] = a[i-1];
		if(s[i] == 'A' && s[i+1] == 'C') a[i]++; 
	}
	
	int l, r;
	for(int q = 0; q < Q; q++){
		cin >> l >> r;
		cout << a[r-1] - a[l-1] << endl;
	}	
	return 0;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
void ff() {
	cout << "FastestFinger" << endl;
}
 
void aa() {
	cout << "Ashishgup" << endl;
}
 
void solve()
{
	char a;
	cin>>a;
	if(a>='A' && a<='Z')
		cout<<"A";
	else
		cout<<"a";
}
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main(){
int n;
cin >> n;
int a[n];
for(int i = 0; i<n; i++){
     cin >> a[i];
}
for(int i = n-1; i>=0; i--){
     if(i == 0){
          cout << a[i];
     }else{
          cout << a[i] << " ";
     }
}
cout << endl;
return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    string str;
    cin >> str;

    LL k;
    cin >> k;

    for(int i = 0; i < str.size(); i++){
        if(str[i] == 'a'){
            continue;
        }

        LL t = (LL)('z' - str[i]) + 1;
        if(t <= k){
            k -= t;
            str[i] = 'a';
        }
    }

    if(k > 0){
        LL x = k%26;
        char tmp = str[str.size()-1];
        for(int i = 0; i < k; i++){
            tmp++;
            if(tmp > 'z'){
                tmp = 'a';
            }
        }
        str[str.size()-1] = tmp;
    }

    cout << str << endl;

    return 0;
}

Measured memory_bytes: 592
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    A = read_ints()
    min_moves = 10**18
    for positive in [False, True]:
        prefix = 0
        base = 0
        moves = 0
        for a in A:
            prefix += a
            if positive:
                if prefix+base <= 0:
                    moves += 1-(prefix+base)
                    base = 1-prefix
            else:
                if prefix+base >= 0:
                    moves += prefix+base+1
                    base = -1-prefix
            positive = not positive
        min_moves = min(min_moves, moves)
    return min_moves



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


Measured memory_bytes: 86876
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int p1 = x2 - x1;
        int p2 = y2 - y1;
        int q1 = -p2;
        int q2 = p1;
        System.out.print(x2 + q1);
        System.out.print(" ");
        System.out.print(y2 + q2);
        System.out.print(" ");
        System.out.print(x2 + q1 - p1);
        System.out.print(" ");
        System.out.print(y2 + q2 - p2);
    }
}

Measured memory_bytes: 21844
R, C, T = map(int, input().split())
RC = []
for _ in range(T):
    RC.append(list(map(int, input().split())))
TR = [0] * (R + 1)
TC = [0] * (C + 1)
for r, c in RC:
    TR[r] += 1
    TC[c] += 1
mxr = max(TR)
mxc = max(TC)
ct = TR.count(mxr) * TC.count(mxc) - len([0 for r, c in RC if TR[r] == mxr and TC[c] == mxc])
print(mxc + mxr - (ct == 0))

Measured memory_bytes: 70904