akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int w, h;

	while(1){
		cin >> h >>w;
		if(h == 0 && w ==0) break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i == 0 || i == h-1 || j == 0 || j == w-1){
					cout << "#" ;
				}else{
					cout << "." ;
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3072
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,ans=1000;cin>>n;
	llint A,B;cin>>A;n--;
	while(n--){
		cin>>B;
		if(A<B){ans=ans%A+ans/A*B;}
		A=B;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

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

int main()
{
    string s,t;
    cin >> s >> t;
    t.erase(t.begin() + t.size()-1);
    cout << (s == t?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3628
def cmod(n, r, p):
    x,y  = 1, 1
    for i in range(r):
        x = x * (n - i) % p
        y = y * (r - i) % p
    return (x * pow(y, p - 2, p)) % p


n, a, b = map(int, (input().split()))
p = 10 ** 9 + 7
print((pow(2, n, p) - 1 - cmod(n, a, p) - cmod(n, b, p)) % p)


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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    int H,W;
    cin>>H>>W;
    vector<int> count(H+W-1);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char hoge;
            cin>>hoge;
            //cout<<hoge<<endl;
            if(hoge=='#'){
                count.at(i+j)++;
            }
        }
    }
    
    bool poss=true;
    for(int i=0;i<H+W-1;i++){
        if(count.at(i)!=1){
            poss=false;
        }
    }
    
    //出力
    if(poss){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)

Measured memory_bytes: 61836
#include<bits/stdc++.h>
using namespace std;
#ifdef FIO
const int S = 1 << 21;
char p0[S],*p1,*p2;
#ifndef ZXY
#define getchar() (p2 == p1 && (p2 = (p1 = p0) + fread(p0,1,S,stdin)) == p1 ? EOF : *p1++)
#endif
inline int read() {
	static int x,c;x = 0;
	do{c = getchar();}while(!isdigit(c));
	do{x = (x << 3) + (x << 1) + (c & 15);c = getchar();}while(isdigit(c));
	return x;
}
#endif
int x;
int main() {
	cin >> x;
	printf("%d\n",8-(x-400)/200);
	return 0;
}


Measured memory_bytes: 3760
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
template <typename T>
T uPow(T z,T n, T mod){
  T ans = 1;
  while(n != 0){
    if(n%2){
      ans*=z;
      if(mod)ans%=mod;
    }
    n >>= 1;
    z*=z;
    if(mod)z%=mod;
  }
  return ans;
}
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/


__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	queue<long long> A;
  for(int i = 1; 10 > i; i++){
    A.push(i);
  }
  int k;cin>>k;
  while(--k){
    long long z = A.front();A.pop();
    if(z%10!=0){
      A.push(z*10+(z%10)-1);
    }
    A.push(z*10+(z%10));
    if(z%10!=9){
      A.push(z*10+(z%10)+1);
    }
  }
  cout << A.front() << endl;
}

Measured memory_bytes: 1792
import numpy as np
nm = input()
[n, m] = [int(comp) for comp in nm.split()]
h_in = input()
h = [int(comp) for comp in h_in.split()]
dp = np.ones(n, dtype=int)  #展望台の情報を持っておく．
for i in range(m):
    abo_in = input()
    abo = [int(comp) for comp in abo_in.split()]
    if(h[abo[0]-1] >= h[abo[1]-1]):
        dp[abo[1]-1] = 0
    if(h[abo[0]-1] <= h[abo[1]-1]):
        dp[abo[0]-1] = 0

print(dp.sum())

Measured memory_bytes: 39472
#include <bits/stdc++.h>
using namespace std;
int f(int x) {
  return ((x - 1) / 10 + 1) * 10;
}
int main() {
  vector<int> T(5);
  int sum = 0;
  for(int i = 0; i < 5; i++) {
    cin >> T[i];
    sum += f(T[i]);
  }
  int min_time = sum;
  int ans = min_time;
  for(int i = 0; i < 5; i++) {
    if(T[i] % 10 != 0) {
      ans = sum + T[i] % 10 - 10;
    }
    if(ans < min_time) {
      min_time = ans;
    }
  }
  cout << min_time << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n;
    cin >> n;
    map<string, ll> msi;
    rep(i, n)
    {
        string s;
        cin >> s;
        sort(all(s));
        msi[s]++;
    }

    ll ans = 0;
    for (auto &i : msi)
    {
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

//ツ閉カツ篠堋療アsツづ景dxツ氾板姪堋つゥツづァ, ツ閉カツ篠堋療アtargetツつェツ出ツ個サツつキツづゥツつゥツづーツ板サツ津ィツつキツづゥ
bool check(string s, string target, int idx){
  for(int i = 0; i < target.size(); i++){
    if(s.length() <= idx + i){
      return false;
    }
    if(s[idx + i] != target[i]){
      return false;
    }
  }

  return true;
}

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

  getline(cin, s); //ツ催?渉可づ個青ョツ青板づーツ偲ヲツづ?つスツつ?づ?づ個嘉シツ行ツつェツ残ツづ?づ?つ「ツづゥツづ個づ? ツ偲ヲツづ?づ?つィツつュ

  for(int i = 0; i < n; i++){
    getline(cin, s);

    for(int i = 0; i < s.length(); i++){
      //iツ閉カツ篠堋姪堋つゥツづァ"Hoshino"ツづ可づ按づ?づ?つ「ツづゥツづ按づァ, "Hoshina"ツづ可置ツつォツ環キツつヲ
      if(check(s, "Hoshino", i)){
        s[i + 6] = 'a';
      }
    }

    cout << s << endl;
  }
}

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

const ll MOD = 1e9 + 7;
const char *AGCT = "AGCT";
int N;

// dp[N][i][j][k] := 長さNの文字列について、最後の文字が後ろから順にi,j,kとなっている文字列の数
ll dp[110][4][4][4];

ll rec(int n, int i, int j, int k){
    if(dp[n][i][j][k] != -1) return dp[n][i][j][k];
    if(n == 3){
        if(k == 0 && j == 1 && i == 2) return dp[n][i][j][k] = 0;
        if(k == 1 && j == 0 && i == 2) return dp[n][i][j][k] = 0;
        if(k == 0 && j == 2 && i == 1) return dp[n][i][j][k] = 0;
        return dp[n][i][j][k] = 1;
    }

    ll SUM = 0;
    rep(l, 0, 4){
        if(k == 0 && j == 1 && i == 2) continue;
        if(k == 1 && j == 0 && i == 2) continue;
        if(k == 0 && j == 2 && i == 1) continue;
        if(l == 0 && j == 1 && i == 2) continue;
        if(l == 0 && k == 1 && i == 2) continue;
        SUM += rec(n-1, j, k, l);
        SUM %= MOD;
    }
    //cerr << SUM << endl;

    return dp[n][i][j][k] = SUM;
}

int main(){
    cin >> N;
    memset(dp, -1, sizeof(dp));
    //dp[0][0][0][0] = 1;

    cout << rec(N+3, 3, 3, 3) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, A, B;
      cin >> N >> A >> B;
      
   if ((N*A) >= B){
     cout << B << endl;
   }
   if ((N*A) < B){
     cout << N*A << endl;
   }
  }
     

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)		(x)*(x)
#define abs(x)		(x)>0?(x):-(x)
#define Mul(x,y)    x=x*(y)%mod
#define Add(x,y)    x=(x+(y))%mod
#define Max(x,y)	x=x<(y)?(y):x
#define Min(x,y)	x=x>(y)?(y):x
#define E(x) 		return writeln(x),0
#define p(x)		printf("~%d~\n",x)
#define pp(x,y)		printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)	printf("~~~%d %d %d~~~\n",x,y,z)
#define f_in(x)		freopen(x".in","r",stdin)
#define f_out(x) 	freopen(x".out","w",stdout)
#define open(x)		f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#define NEG 0
    const int L=2333333;
    char SZB[L],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace SHENZHEBEI;
const ll N=120000;
ll mx,mn,n,a[N];
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	mx=2,mn=2;
	FOr(i,n,1){
		if (mn%a[i])	mn+=a[i]-mn%a[i];
		if (mx%a[i])	mx-=mx%a[i];
		if (mn>mx)	return puts("-1"),0;
		mx+=a[i]-1;
	}printf("%lld %lld\n",mn,mx);
}

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

int main(){
  int N,min_sumAB=100000000000000;
  cin >> N;
  for(int i=0;i<N-1;i++){
    int A=i+1,B=N-i-1;
    int sumA=0,sumB=0;
    while(A>0){
      sumA+=A%10;
      A/=10;
    }
    while(B>0){
      sumB+=B%10;
      B/=10;
    }
    int sumAB=sumA+sumB;
    min_sumAB=min(min_sumAB,sumAB);
  }
  cout << min_sumAB << endl;
}
    
      

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

signed main(){
  
  int N, M;
  cin>>N>>M;
  
  if( N == 1 && M == 1 ) cout<<1<<endl;
  else if( N == 1 ) cout<<max(0LL,M-2)<<endl;
  else if( M == 1 ) cout<<max(0LL,N-2)<<endl;
  else if( N == 2 || M == 2 ) cout<<0<<endl;
  else cout<<(N-2)*(M-2)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <regex>
using namespace std;

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

	stringstream ss;
	ss << "\\d{" << A << "}-\\d{" << B << "}";
	std::regex re(ss.str());

	string S;
	cin >> S;

	bool is_match = std::regex_match(S, re);

	string result;
	if (is_match) {
		result = "Yes";
	}
	else {
		result = "No";
	}
	cout << result << endl;
}

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = N;
    for(int i = 0; i < N-1; i++){
        if(S[i] == S[i+1]) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    cin>>N;
    vector<vector<ll>> a(2,vector<ll>(N));
    rep(i,N){
        cin>>a[0][i];
        a[1][i] = a[0][i];
    }
    if(N == 1){
        cout<<a[0][0]/2<<endl;
        return 0;
    }
    ll ans[2] = {0,0};
    reverse(all(a[1]));
    rep(i,2){
        rep(j,N-1){
            if((a[i][j] + a[i][j+1]) % 2 == 0){
                ans[i] += (a[i][j] + a[i][j+1]) / 2;
                a[i][j] = a[i][j+1] = 0;
            }
            else{
                ans[i] += (a[i][j] + a[i][j+1]) / 2;
                a[i][j] = 0;
                a[i][j+1] = min(1LL,a[i][j+1]);
            }
            //print(a[i]);
        }
        //cerr<<endl;
    }

    //cerr<<ans[0]<<" "<<ans[1]<<endl;
    cout<<max(ans[0],ans[1])<<endl;
}

Measured memory_bytes: 2560
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|
ans = 0
boder = s[i][0]-54*c[0]

  (0..25).each do |l|
    c[l] += C[l]
  end
  (1..25).each do |e|
    if s[i][e]-54*c[e] >= boder
      ans = e
      boder = s[i][e]-54*c[e]
    end
  end
c[ans] = 0
puts ans+1
last = boder
end


  



Measured memory_bytes: 14404
#include<bits/stdc++.h>
 using namespace std;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;

int main()
{
  FIO;
  
 
  int n;
  string s;
  cin>>n>>s;
  int a[n],b[n];
  fill(a,0);
  fill(b,0);

  forn(i,n)
  {
    if(i==0)
    {
      if(s[i]=='E')
        a[i]=1;
      else
        b[i]=1;
    }
    else
    {
      if(s[i]=='E')
        {
          a[i]=1+a[i-1];
          b[i]=b[i-1];
        }
      else
        {
          b[i]=1+b[i-1];
          a[i]=a[i-1];
        }

    }
  }

  int ans=n+5;
  forn(i,n)
  {
    if(i==0)
    {
       if(s[i]=='E')
        ans=min(ans,a[n-1]-1);
       else
        ans=min(ans,a[n-1]);
    }
    else if(i==n-1)
    {
      if(s[i]=='E')
        ans=min(ans,b[n-1]);
       else
        ans=min(ans,b[n-1]-1);
    }
    else
    {
      if(s[i]=='E')
       {
        ans=min(ans,b[i-1]+a[n-1]-a[i]);
       }
       else
       {
         ans=min(ans,b[i-1]+a[n-1]-a[i]);
       }
    }
  }
  cout<<ans;
  
 return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int dp[3005][3005];
int N,m;
pair<int,int> v[3005];
int func(int n, int times)
{
    if(times<=0) return 0;
    if(n < 0) return 0;
    if(dp[n][times]!=-1) return  dp[n][times];
    int ans1=0,ans2=0;
    ans1 += func(n-1,times-v[n].fr)+v[n].se;
    ans2 += func(n-1,times);

    return dp[n][times] = max(ans1,ans2);

}

int main()
{
   fast;
   memset(dp,-1,sizeof dp);
   cin >> N >> m;
   for(int i=0; i<N; i++) cin >> v[i].fr >> v[i].se;
   sort(v,v+N,greater< pair<int,int> >());
   cout << func(N-1,m) << "\n";

   return 0;
}


Measured memory_bytes: 35712
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    print(int(N * (N - 1) / 2 + M * (M - 1) / 2))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

using namespace std;

pair<pair<string, int>, int> p[101];

int main() {
    int N = 0, P;
    string S;
    
    cin >> N;
    cout << endl;

    for (int i = 0; i < N; i++) {
        cin >> S >> P;
        cout << endl;

       p[i] =  make_pair(make_pair(S, -P), i);
    }

    sort(p, p + N);
    for (int i = 0; i < N; i++) {
        cout << p[i].second + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,x;
	cin >> N >> x;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	
	sort(ALL(a));
	
	int ans = 0;
	for(int i=0;i<N;i++){
		if(x>=a[i]&&i!=N-1){
			x-=a[i];
			ans++;
		}else if(i==N-1){
			if(x==a[i])ans++;
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(100001);
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x<100001) a[x]++;
        else a[0]++;
    }
    int ans=0;
    for(int i = 0; i < 100001; i++) {
        if(a[i]>=i) ans += a[i]-i;
        else ans += a[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3708
n = int(input())
#h, w = list(map(int, input().split()))
# b = list(map(int, input().split()))
s = input()
countE = 0
countW = s.count("W")
ans = len(s)
min_idx = 0

for i in range(len(s)):
    if s[i] == "W":
        countW -= 1
    total = int(len(s))-1-i-countW + i-countE
    if total < ans:
        ans = total
    if s[i] == "E":
        countE += 1

print(ans)


Measured memory_bytes: 3676
// Problem : D - Wide Flip
// Contest : AtCoder - AtCoder Beginner Contest 083
// URL : https://atcoder.jp/contests/abc083/tasks/arc088_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int cnt0,cnt1;
	string s;cin>>s;
	cnt0=cnt1=size(s);
	for(int i=0;i<size(s);i++)
	{
		if(s[i]=='0')
		{
			cnt0=min(cnt0,max(i,size(s)-i-1));
		}
		else
		{
			cnt1=min(cnt1,max(i,size(s)-i-1));
		}
	}
	cout<<max(cnt1,cnt0);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

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

    vector<char> As(101, '0'), Bs(101, '0');
    REP(i, A.length()) {
        As[As.size() - A.length() + i] = A[i];
    }
    REP(i, B.length()) {
        Bs[Bs.size() - B.length() + i] = B[i];
    }

    REP(i, As.size()) {
        if(As[i] > Bs[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
        if(As[i] < Bs[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 3604
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = 0
    for a in range(1, N + 1):
        for b in range(1, N + 1):
            q = math.gcd(a, b)
            for c in range(1, N + 1):
                ret += math.gcd(q, c)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
n = int(input())
lis = list(map(int,input().split()))

lis.sort()

ans1 = lis[-1]

lis = lis[:-1]
half = ans1/2

ans2 = 0
length = 10**9+7

for i in lis:
    t = abs(half - i)
    if t < length:
        length = t
        ans2 = i
    

print(ans1, ans2)



Measured memory_bytes: 19804
n,k = map(int,input().split())
if(n == 1):
    print("1")
    exit()
s = input()
zero = []
one = []
sp = [-1]
for i in range(len(s)-1):
    if(s[i] != s[i+1]):
        sp.append(i)
sp.append(len(s)-1)
spp =[]
if(s[0] == "0"):spp.append(0)
for i in range(1,len(sp)):
    spp.append(sp[i]-sp[i-1])

if(s[-1] == "0"):spp.append(0)

if((len(spp)-1)//2 <= k): 
    print(n)
    exit()

sum = 0
for i in range(2*k+1):
    sum += spp[i]
ans = sum
for i in range(2*k,len(spp)-2,2):
    sum = sum+spp[i+1]+spp[i+2]-spp[i-2*k]-spp[i-2*k+1]
    ans = max(sum,ans)

print(ans)

Measured memory_bytes: 7880
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x, y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[3101][3333];
long long l[441][444];
long long j[441][444];

long long x,y,z,mod=1000000007;
//string r;
char r[3111],r1[3111];

P u[1];
priority_queue<int> q;
stack<int> s;
//set<P> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(int n,int m)
{
  if(n>a)
  {
    if(m) return 0;
    return 1;
  }
  if(j[n][m]>=0) return j[n][m];
  long long x=0;
  for(int i=0;i<=m;i++)
  {
    x+=f(n+1,m-i)*(l[o[n][1]][i]-l[o[n][0]-1][i]+mod)%mod;
    x%=mod;
  }
  return j[n][m]=x;
}

int main()
{
  memset(j,-1,sizeof(j));
  scanf("%d %d",&a,&b);
  for(int t=1;t<=400;t++)
  for(int h=0;h<=400;h++)
  {
    l[t][h]=1;
    for(int i=1;i<=h;i++)
      l[t][h]*=t,l[t][h]%=mod;
    l[t][h]+=l[t-1][h];
    l[t][h]%=mod;
  }
  for(int i=0;i<2;i++)
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t][i]);
  printf("%lld",f(1,b));
}
//0
//17



Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

int main() {
	LL A, B, V, W; cin >> A >> V >> B >> W;
	LL T; cin >> T;
	B -= A;
	B = abs(B);
	V -= W;
	if (V < 0) cout << "NO" << endl;
	else if (V * T >= B) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;
ll N, M;
vector<ll> X, Y, Z;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main() {
    cin >> N >> M;
    X.resize(M);
    Y.resize(M);
    Z.resize(M);

    UnionFind uf(N);

    rep(i, M) cin >> X[i] >> Y[i] >> Z[i];
    rep(i, M) {
        X[i]--;
        Y[i]--;
        uf.connect(X[i], Y[i]);
    }

    ll ans = 0;
    set<ll> visited;
    rep(i, N) {
        ll target = uf.root(i);
        if (visited.count(target)) continue;

        visited.insert(target);
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 7680
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t = min(a, b);
    int B = min(c, d);
    cout << t + B << endl;
    return 0;
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        struct tapi {
            string first;
            int second;
            int id;
        };

        vector<tapi> vp(N);
        rep(i, 0, N) {

            cin >> vp[i].first >> vp[i].second;
            vp[i].id = i + 1;
        }
        sort(all(vp), [](auto a, auto b) {
            if (a.first == b.first) {
                return a.second > b.second;
            }
            return a.first < b.first;
        });
        for (auto e : vp) {
            cout << e.id << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

using namespace std;

int a[100001];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int ans=0;
    for (int i = 0; i < N ; ++i) {
        int tmp;
        cin >> tmp;
        ans += tmp-1;
    }

    cout << ans << endl;

}

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

#define _u(i,a,b) for(int i=a;i<=b;++i)
#define _d(i,a,b) for(int i=a;i>=b;--i)
#define endl "\n"
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define FIO() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FI(task) freopen(task".inp","r",stdin)
#define FO(task) freopen(task".out","w",stdout)

using namespace std;

const int N = 1e5+7;
const int M = 1e9+7;

ll w[N], v[N];
ll f[107][N];
ll n, W;

#define task "test"

int main(){
    FIO();
   // FI(task);
    ///FO(task);

    cin >> n >> W;
    _u(i,1,n) cin >> w[i] >> v[i];
    _u(i,1,n){
        _u(j,0,W){
            f[i][j] = f[i-1][j];
            if(j-w[i]<0) continue;
            f[i][j] = max(f[i][j], f[i-1][j-w[i]] + v[i]);
        }

    }
    cout << f[n][W];
    return 0;
}


Measured memory_bytes: 81408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath> 

using namespace std;

int main(void) {
    string S, a;
    
    a = "abcdefghijklmnopqrstuvwxyz";
    
    int N = (int)a.size();
    
    cin >> S;
    
    for(int i=0; i<N; i++) {
        //cout << (int)S.find(a[i]) << endl;
        if( (int)S.find(a[i]) < 0 ) {
            cout << a[i] << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    /*
    if( a % b == 0 ){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    */
    
    cout << ( a - 1 ) * ( b - 1 ) << endl;

    return 0; 
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>

using namespace std;

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

int main() {
	int t[4];
	REP(i,4) cin >> t[i];

	int sum = 0;
	REP(i,4) sum += t[i];

	printf("%d\n%d\n", sum/60, sum%60);

	return 0;
}

Measured memory_bytes: 1144
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  long long A, B, C;

  std::cin >> A >> B >> C;

  for (int i = 1; i < 111111; i ++) {
    long long s = A * i;

    if (s < C)
      continue;

    if ((s - C) % B == 0) {
      std::cout << "YES" << std::endl;

      return 0;
    }
  }

  std::cout << "NO" << std::endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<char> stones(N);
    vector<int> w_pos(N, 1<<30);
    int num_w = 0;
    for (int i = 0; i < N; i++) {
        cin >> stones[i];
        if (stones[i] == 'W') {
            num_w++;
            w_pos[num_w] = i;
        }
    }
    int num_r = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if (stones[i] == 'R') {
            if (i <= w_pos[num_r+1]) break;
            num_r++;
            stones[w_pos[num_r]] = 'R';
        }
    }
    cout << num_r << endl;
    return 0;
}

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

int main() {    
    string s,t;
    cin >> s;
    t = s;
    reverse(s.begin(), s.end());
    if(t == s) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Xs = [list(map(str, input().split())) for _ in range(N)]
one_BTC = 380000.0
otoshidama = 0
for x in Xs:
  if x[1] == "JPY":
    otoshidama += int(x[0])
  else:
    otoshidama += (float(x[0])*one_BTC)
print(otoshidama)

Measured memory_bytes: 3060
import itertools
n = int(input())
march = [0]*5
for _ in range(n):
    s = input()[0]
    if s=='M':
        march[0] += 1
    if s=='A':
        march[1] += 1
    if s=='R':
        march[2] += 1
    if s=='C':
        march[3] += 1
    if s=='H':
        march[4] += 1
res = 0
for l in list(itertools.combinations(range(5),3)):
    res += march[l[0]] * march[l[1]] * march[l[2]]
print(res)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        System.out.println((n - 1) * (m - 1));
    }
}


Measured memory_bytes: 35620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
	//作るときはParentの値を全て-1にする
	//こうするとすべてバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}
	//AとBをくっつける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついているからくっつけない
			return false;
		}
		//大きい方(A)に小さいほう(B)をくっつけたい
		//大小が逆だったらひっくり返しちゃう
		if (size(A) < size(B)) swap(A, B);
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
	//AとBが同じグループにいるか
	bool same(int A, int B) { return root(A) == root(B); }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> res(100005);
	vector<vector<int>> g(n);
	UnionFind Uni(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		Uni.connect(a, b);
		res[a]++; res[b]++;
	}
	rep(i, k) {
		int c, d;
		cin >> c >> d;
		c--; d--;
		g[c].push_back(d);
		g[d].push_back(c);
	}
	rep(i, n) {
		int ans = Uni.size(i) - 1 - res[i];
		for (int c : g[i]) if (Uni.same(i, c)) ans--;
		cout << ans << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 9240
#include <iostream>

int main()
{
    int N, Q;
    scanf("%d %d", &N, &Q);
    char S[N+1];
    scanf(" %s", S);
    int l[Q], r[Q];
    for(int i=0; i<Q; i++){
        scanf(" %d %d", &l[i], &r[i]);
    }

    int sum[N];
    int j = 0, count = 0;
    while(j < N){
        if(j != N-1 && S[j] == 'A' && S[j+1] == 'C'){
            sum[j] = count;
            count++;
            sum[j+1] = count;
            j += 2;
        }
        else{
            sum[j] = count;
            j++;
        }
    }
    for(int i=0; i<Q; i++)
        std::cout << sum[r[i]-1] - sum[l[i]-1] << std::endl;
}

Measured memory_bytes: 2048
#include<cstdio>

int main(){
	int n,x;
	scanf("%d", &n);
	int dice[n][6];
	int tmp[6];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 6; j++){
			scanf("%d", &dice[i][j]);
		}
	}

	int pt[5][6] = {	{5,1,3,4,6,2}, 
				 	{0,0,0,0,0,0},
					{4,2,1,6,5,3},
					{2,6,3,4,1,5},
					{3,2,6,1,5,4}};
	int t[24] = {0,0,0,2,0,0,0,2,0,0,0,4,0,0,0,4,0,0,0,2,0,0,0,0};

	for(int a = 0; a < n; a++){
		for(int b = a + 1; b < n; b++){
			for(int i = 0; i < 24 ; i++){
				int c = 0;
				while(!(dice[a][c] - dice[b][c])){
					c++;
					if(c == 6){
						printf("No\n");
						return 0;
					}
				}

				for(int j = 0; j < 6; j++){
					tmp[j] = dice[a][j];
				}
				for(int j = 0; j < 6; j++){
					x = pt[t[i]][j];
					dice[a][j] = tmp[x - 1];
				}
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1012
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string n;
   cin >> n;

   if(n.size()==1) cout << "ABC00" << n << endl;
   else if(n.size()==2) cout << "ABC0" << n << endl;
   else if(n.size()==3) cout << "ABC" << n << endl;



   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;
  
  int ans = -1;
  
  for(int i = 1; i <= 1250; i++){
    if(A == int(i*0.08) && B == int(i*0.1)){
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

int main() {
    double a,b,x;
    cin>>a>>b>>x;
    double t=0.0;
    if(a*a*b<2*x) {
        t = atan(2.0 * (a * a * b - x) / pow(a, 3.0)) * 180 / M_PI;
    }else{
        t = atan(a*b*b/2.0/x)*180/M_PI;
    }
    printf("%.10f",t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e6;
const int INF = 1e18 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];

int32_t main() {
    IOS;
    cin>>n>>m;
    int Min=INF,Max=-INF;
    fu(i,1,m)
    {
        int x,y;
        cin>>x>>y;
        Min=min(Min,y);
        Max=max(Max,x);
    }
    cout<<max(Min-Max+1,(long long) 0);
    return 0;
}


Measured memory_bytes: 256
A, B, N = map(int, input().split())
# for x in range(N+1+20):
#     a = int(A * x / B) - A * int(x / B)
#     print(a)
if N < B-1:
    x = N
else:
    x = B - 1
print(int(A * x / B) - A * int(x / B))

Measured memory_bytes: 9172
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
char a[100000];

int main(){
  scanf("%s",a);
  int len=strlen(a);
  bool flag=false;
  bool res=false;
  for(int i=0;i<len;i++){
    if(a[i]=='C') flag = true;
    else if(a[i]=='F' && flag) res=true;
  }
  if(res==true) printf("Yes\n");
  else printf("No\n");


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int MAX_N = 2e5+7;

ll N;
vvl G(MAX_N);
vl cs(MAX_N), tree_size(MAX_N), color_cnts(MAX_N,0);
vl ans(MAX_N);

ll nc2(ll x) { return x*(x-1)/2; }

void calc_size(int v, int par = -1) {
    tree_size[v] = 1;
    for (auto to : G[v]) {
        if (to == par) continue;
        calc_size(to, v);
        tree_size[v] += tree_size[to];
    }
}
void dfs(int v, int par = -1) {
    ll prev_cnt = color_cnts[cs[v]];
    for (auto to : G[v]) {
        if (to == par) continue;
        ll prev = color_cnts[cs[v]];
        dfs(to, v);
        ll diff = color_cnts[cs[v]] - prev;
        ll cnt = tree_size[to] - diff;
        // cerr << v << "->" << to << ": " << cnt << endl;
        ans[cs[v]] -= nc2(cnt);
    }
    color_cnts[cs[v]] = prev_cnt + tree_size[v];
}

int main() {
    cin >> N;
    ans.assign(MAX_N, nc2(N));
    rep(i,N) cin >> cs[i+1], ans[cs[i+1]]++;
    rep(i,N-1) {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    calc_size(1);
    dfs(1);
    rep(c,N) ans[c+1] -= nc2(N-color_cnts[c+1]);
    rep(i,N) cout << ans[i+1] << endl;
    return 0;
}


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

#define NAME "B"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;

int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int k;
    cin>>k;

    string s;
    cin>>s;
    cout<<s.substr(0,min( k , (int)s.len ) );
    if (k<s.len) cout<<"...";
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>

#define INF 100000001
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	string s;
	cin >> s >> k;
	vector<string> x;
	for (int i = 0; i<s.size(); i++) {
		for (int j = 1; j < k + 1; j++) {
			if (i + j == 1 + s.size()) {
				break;
			}
	//		cout << s.substr(i, j) << endl;
			x.push_back(s.substr(i, j));
		}
	}
	sort(x.begin(), x.end());
	auto itr = x.begin();
	int a = 1;
	while (a != k) {
		if (*itr != *(itr+1)) {
			a++;
		}
		itr++;
	}
	cout <<*itr;
	return 0;
}

Measured memory_bytes: 1660
// Problem : D - Sum of Large Numbers
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

const int mod = 1e9+7;
#define int long long

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, k;
	cin >> n >> k;
	long long tot = 0;
	for(int i = k; i <= n+1; i++) {
		long long x = (1LL*(i-1)*i/2);
		x %= mod;
		long long y = (i*n)%mod;
		tot += (y - 2*x + 1 + 2*mod)%mod;
		tot %= mod;			
	}
	cout << tot << '\n';			
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long mod = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n); rep(i, n)cin >> a[i];
	int sum = 0;
	rep(i, n) {
		sum ^= a[i];
	}
	if ((sum^sum) == sum)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024