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

map<int, int> pf; // prime factors

int f(int n)
{
    int ret = 0;
    for (auto& x : pf) ret += x.second >= n - 1;
    return ret;
}
int main()
{
    int N;
    cin >> N;

    for (int i = 2; i <= N; i++) {
        int t = i;
        for (int j = 2; j <= N; j++) {
            for (; t % j == 0;) {
                t /= j;
                pf[j]++;
            }
        }
    }

    int ans = 0;

    ans += f(75);
    ans += f(15) * (f(5) - 1);
    ans += f(25) * (f(3) - 1);
    ans += f(5) * (f(5) - 1) * (f(3) - 2) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
 

BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
    
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
     
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
  
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
n,d=map(int,input().split())
c=0
for i in range (n):
    x,y=map(int,input().split())
    r=math.sqrt((x*x)+(y*y))
    if r<=d:
        c+=1
print(c)

Measured memory_bytes: 84188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int S; cin >> S;
    int up = S / 100; //上二桁
    int lo = S % 100; //下二桁
    if (up == 0 or (13 <= up and up <= 99) ){
        if (lo == 0 or (13 <= lo and lo <= 99) ) cout << "NA" << endl;
        else cout << "YYMM" << endl;
    }
    else {
        if (lo == 0 or (13 <= lo and lo <= 99) ) cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int getDegit(long long n){
	long long ret = 0;
	while(true){
		n = n / 10;
		ret++;
		if(n == 0) break;
	}
	return ret;
}

int main(int argc, char* argv[]){
	long long N, M;
	cin >> N;

	M = sqrt(N) + 2;

	int d = getDegit(N);
	int ans = d;
	for(int i=1; i<M; i++){
		if((N % i) != 0){
			continue;
		}
		long long n = N / i;
		ans = min(ans, max(getDegit(i), getDegit(n)));
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
      c -= b;
      if (c <= 0) {
        cout << "Yes";
        return 0;
      }
      a -= d;
      if (a <= 0) {
        cout << "No";
        return 0;
      }
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int ans;
    double bestT = 1e9, tem, tmp;
    for (int i = 0; i < n; i++) {
        tem = t - h[i] * 0.006;
        tmp = bestT;
        bestT = min(bestT, abs(a - tem));
        if (tmp != bestT) {
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

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


int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if(a > k) {
    ans = k;
  }
  else if( a + b > k ){
    ans = a;
  }
  else{
    ans = 2*a + b - k;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
	long long a, b, c, d, e;
	scanf("%lld %lld", &a,&b);
	a = a - 1;
	if (a % 4 == 0) d = a;
	if (a % 4 == 1) d = 1;
	if (a % 4 == 2) d = a + 1;
	if (a % 4 == 3) d = 0;

	if (b % 4 == 0) c = b;
	if(b % 4 == 1) c = 1;
	if (b % 4 == 2) c = b + 1;
	if (b % 4 == 3) c = 0;
	if (a == -1) {
		printf("%lld", c);
		return 0;
	}
	e = c ^ d;
	printf("%lld", e);
}

Measured memory_bytes: 3184
import math

while 1:
    d, w, h = map(int, input().split())
    if d == 0:
        break

    datas = []
    n = int(input())
    for _ in range(n):
        r = int(input())
        datas.append(r)

    cheese = [d, w, h]
    cheese.sort()
    a = cheese[0]
    b = cheese[1]
    r = math.sqrt(a**2 + b**2) / 2

    for data in datas:
        if r >= data:
            print("NA")
        else:
            print("OK")



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

int n_node, pos;
vector<int> pre, in, post;

#if LOCAL
// Split Function
vector<int> split_int(string input,char del){
    vector<int> output;
    string substr;
    for(const char c : input){
        if(c == del){
          output.push_back(atoi(substr.c_str()));
          substr.clear();
        } else {
          substr += c;
        }
    }
    output.push_back(atoi(substr.c_str()));
    return output;
}

vector<string> split_str(string input,char del){
    vector<string> output;
    string substr;
    for(const char c : input){
        if(c == del){
          output.push_back(substr);
          substr.clear();
        } else {
          substr += c;
        }
    }
    output.push_back(substr);
    return output;
}
#endif // for local test


void rec(int l, int r) {
	if (l >= r) {
		return;
	}
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve() {
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n_node; i++) {
		if (i) {
			cout << ' ';
		}
		cout << post[i];
	}
	cout << endl;
}

int main() {
	int id_node, right, left;
	scanf("%d", &n_node);

#if LOCAL // for local test
	vector<string> input = {"1 2 3 4 5",
	 						"3 2 4 1 5"};
	// input for local test
	vector<int> vec_tmp;
	pre = split_int(input[0], ' ');
	in = split_int(input[1], ' ');
#endif // for local test

#ifndef LOCAL // for online test
	for (int i = 0; i < 2; i++) {
		int input;
    	for (int j = 0; j < n_node; j++) {
			scanf("%d", &input);
			if (i == 0) {
				pre.push_back(input);
			} else {
				in.push_back(input);
			}
		}
    }
#endif // for online test
	solve();
    return 0;
}



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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;

void work()
{
    char c;
    cin >>c;
    cout <<(char) (c + 1) <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

s=input().rstrip()
mx=0
for i in range(len(s)):
    l=0
    for j in range(i,len(s)):
        if s[j]=="A" or s[j]=="T" or s[j]=="G" or s[j]=="C":
            l+=1
        else:
            break
    if l>mx:
        mx=l
print(mx)

Measured memory_bytes: 3444
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if((a>0 && a<10) &&( b<10 && b>0)){
            System.out.println(a*b);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
//#define Se second
#define Fi first

ll A[200050];
ll B[200050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &A[i], &B[i]);

	for (i = 1; i <= N; i++) if (A[i] != B[i]) break;
	if (i > N) return !printf("0\n");

	ll ans = 0, mn = LL_INF;
	for (i = 1; i <= N; i++) {
		if (A[i] > B[i]) mn = min(mn, B[i]);
		ans += A[i];
	}
	ans -= mn;
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int digSum(int x) {
    int ret = 0;
    while(x > 0) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    if(N % digSum(N) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX 256
int main(){
    float a[1000],b[1000],c[1000],d[1000],e[1000],f[1000],x[1000],y[1000];
    int i,j,num;
    char str[MAX], *tp;

    i = 0;
    /* input */
    while (fgets(str,MAX,stdin) != NULL)
    {
        tp = strtok(str, " ");
        a[i] = atoi(tp);
        tp = strtok(NULL, " ");
        b[i] = atoi(tp);
        tp = strtok(NULL, " ");
        c[i] = atoi(tp);
        tp = strtok(NULL, " ");
        d[i] = atoi(tp);
        tp = strtok(NULL, " ");
        e[i] = atoi(tp);
        tp = strtok(NULL, "\n");
        f[i] = atoi(tp);
        i++;
    }

    for (j = 0; j < i; j++)
    {
        if (a[j] >= d[j])
        {
            e[j] = e[j] - (b[j] * (d[j] / a[j]));
            f[j] = f[j] - (c[j] * (d[j] / a[j]));
            y[j] = f[j] / e[j];

            b[j] = b[j] * y[j];
            x[j] = (c[j] - b[j]) / a[j];

            x[j] = (roundf(x[j] * 1000)) / 1000;
            y[j] = (roundf(y[j] * 1000)) / 1000;
        }
        else
        {
            b[j] = b[j] - (e[j] * (a[j] / d[j]));
            c[j] = c[j] - (f[j] * (a[j] / d[j]));
            y[j] = c[j] / b[j];

            e[j] = e[j] * y[j];
            x[j] = (f[j] - e[j]) / d[j];

            x[j] = (roundf(x[j] * 1000)) / 1000;
            y[j] = (roundf(y[j] * 1000)) / 1000;
        }
    }

    /* output */
    for(j = 0; j < i; j++)
    {
        printf("%.3f %.3f\n",x[j],y[j]);
    }

    return 0;
}

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

using namespace std;

long long binom[60][60];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, p, i, j;
	int x, e = 0, o = 0;
	long long sol = 0;
	
	for (i = 0; i <= 50; ++i)
		binom[i][0] = 1;
	for (i = 1; i <= 50; ++i) for (j = 1; j <= i; ++j)
		binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
	
	cin>>n>>p;
	
	while (n--)
	{
		cin>>x;
		
		if (x % 2)
			++o;
		else ++e;
	}
	
	for (i = 0; i <= o; ++i)
		if (i % 2 == p)
			sol += binom[o][i];
	
	cout<<(sol<<e)<<'\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  private static final String STR_YES = "Yes";
  private static final String STR_NO = "No";
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    System.out.println(isValidFormula(a, b, c));
  }

  private static String isValidFormula(int a, int b, int c) {
    if (a < b && b < c) {
      return STR_YES;
    }
    return STR_NO;
  }
}

Measured memory_bytes: 26204
#include<cstdio>
int min(int a,int b) {return a<b?a:b;}
int getsum(int x)
{
	int sum=0;
	while(x)
	{
		sum+=x%10;
		x/=10;
	}
	return sum;
}
int main()
{
	int n,ans=0x7f7f7f7f;
	scanf("%d",&n);
	for (int i=1;i<n;++i)
		ans=min(ans,getsum(i)+getsum(n-i));
	printf("%d",ans);
	return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int A,B,C,D,E,F;

int gcd(int x,int y)
{
	return y ? gcd(y,x % y) : x;
}

int lcm(int x,int y)
{
	return x / gcd(x,y) * y;
}

int main()
{
	cin >> A >> B >> C >> D >> E >> F;

	int P = lcm(A,B),Q = lcm(C,D);
	int ansW = A * 100,ansS = 0;
	FOR(i,0,P / A + 1) FOR(j,0,P / B + 1) FOR(k,0,Q / C + 1) FOR(l,0,Q / D + 1){
		int w = A * 100 * i + B * 100 * j,s = C * k + D * l;
		if(w + s > F) continue;
		if(w / 100 * E < s) continue;
		s = s + min((F - (w + s)) / Q,(w / 100 * E - s) / Q) * Q;
		if(ansS * (w + s) < s * (ansW + ansS)){
			ansW = w;
			ansS = s;
		}
	}
	cout << ansW + ansS << " " << ansS << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

cnt = 0
max_cnt = 0
for i in range(N-1):
	if H[i] >= H[i+1]:
		cnt += 1
	else:
		cnt = 0
	
	if cnt >= max_cnt:
		max_cnt = cnt

print(max_cnt)

Measured memory_bytes: 14252
#D問題
N,K = map(int,(input().split()))
A = list(map(int,input().split()))

def f(X):
    return sum([X ^ a for a in A])

if K==0:
    print(f(0))
else:
    l = len(bin(K)[2:])
    a_bit = [N - 2*sum([(a>>i) & 1 for a in A]) for i in range(l)]
    k_bit = [a > 0 for a in a_bit]
    k = 0
    for i,b in enumerate(k_bit[::-1],1):
        if b and (k + (1<<(l-i)) <= K):
            k += (1<<(l-i))
    print(f(k))

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

int main() {
  vector<int> t(365);
  int d;
  vector<int> c(26);
  vector<vector<int>> s(365, vector<int>(26));
  cin >> d;
  vector<int> dectrend(26);
  int cHighCnt = 0;
  rep(i,26) {
    int inc;
    cin >> inc;
    if (inc > 80) {
      dectrend[i] = 1;
      cHighCnt++;
    }
    c[i] = inc;
  }
  rep(i,365) {
    int mx = 0;
    rep(j,26) {
      int ins;
      cin >> ins;
      if (ins > mx) {
        t[i] = j + 1;
        mx = ins;
      }
      s[i][j] = ins;
    }
  }

  vector<int> c2(c.size());
  sort(c.begin(), c.end(), greater<int>());
  rep(i,cHighCnt) {
    rep(j,26) {
      if (c[i] == c2[j]) {
        t[365 - i] = j;
      }
    }
  }

  rep(i,365) {
    cout << t[i] << endl;
  }
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

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



int main()
{
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;

    priority_queue<ll, vector<ll>, greater<ll> > p;
    priority_queue<ll, vector<ll>, greater<ll> > q;
    priority_queue<ll> r;

    vector<ll> tmp_p(A);
    vector<ll> tmp_q(B);
    
    rep(i,A) cin >> tmp_p[i];
        
    rep(i,B) cin >> tmp_q[i];
   
    rep(i,C)
    {
        ll tmp;
        cin >> tmp;
        r.push(tmp);
    }
    
    sort(all(tmp_p),greater<ll>());
    rep(i,X) p.push(tmp_p[i]);

    sort(all(tmp_q),greater<ll>());
    rep(i,Y) q.push(tmp_q[i]);

    rep(i,C)
    {
        if( r.top() < p.top() && r.top() < q.top() ) break;

        if( p.top() > q.top() )
        {
            q.pop();
            q.push(r.top());
            r.pop();
        }
        else
        {
            p.pop();
            p.push(r.top());
            r.pop();
        }
    }

    ll ans = 0;
    rep(i,X)
    {
        ans += p.top();
        p.pop();
    }
    
    rep(i,Y)
    {
        ans += q.top();
        q.pop();
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 4852
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    M=10**5
    n=int(input())
    C=[0]*M
    for a in map(int,input().split()):
        C[a]+=1
    print(max(*(C[i-1]+C[i]+C[i+1] for i in range(1,M-1))))
resolve()

Measured memory_bytes: 57284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int n, m;
vector<int> g[N];
bool used[N];
int q[N];
int topQ;
int deg[N][2];
char s[N];
int a[N];

void addEdge(int v, int u) {
	g[v].push_back(u);
	deg[v][a[u]]++;
}

void eraseVertex(int v) {
	for (int u : g[v]) {
		if (used[u]) continue;
		deg[u][a[v]]--;
		if (deg[u][a[v]] == 0) {
			used[u] = 1;
			q[topQ++] = u;
		}
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	scanf("%s", s);
	for (int i = 0; i < n; i++)
		a[i] = (int)(s[i] - 'A');
	while(m--) {
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		addEdge(v, u);
		addEdge(u, v);
	}
	for (int v = 0; v < n; v++) {
		if (deg[v][0] == 0 || deg[v][1] == 0) {
			used[v] = 1;
			q[topQ++] = v;
		}
	}
	for (int i = 0; i < topQ; i++)
		eraseVertex(q[i]);
	if (topQ == n)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#define DEBUG
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    ll n;
    //read
    scanf("%lld", &n);

    //solve
    ll sum = 0;
    rep(i, n)
    {
        sum += i;
    }

    //write
    printf("%lld", sum);

    return 0;
}

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

using namespace std;

int main()
{
  string S, T; cin >> S >> T;

  vector<int> a(26, -1), b(26, -1);
  for (int i = 0; i < S.size(); ++i) {
    int s = S[i]-'a', t = T[i]-'a';
    if ((a[s] != -1 || b[t] != -1) and (a[s] != t || b[t] != s)) {
      cout << "No" << endl;
      return 0;
    }

    a[s] = t;
    b[t] = s;
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, T, min = 0, a, b;
	vector<int> c, t;

	cin >> N;
	cin >> T;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		c.push_back(a);
		cin >> b;
		t.push_back(b);
	}


	for (int i = 0; i < N; i++)
	{
		if (t[i] <= T && (c[i] < min || min == 0))
			min = c[i];
	}

	if (min == 0)
		cout << "TLE" << endl;
	else
		cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;cin>>s;int len=s.length();int ok=1;
	for(int i=1;i<=len;i++)
	{
		if(i%2==1)
		{
			if(!(s[i-1]=='R'||s[i-1]=='U'||s[i-1]=='D'))
			{
				ok=0;break;
			}
		}
		else
		{
			if(!(s[i-1]=='L'||s[i-1]=='U'||s[i-1]=='D'))
			{
				ok=0;break;
			}
		}
	}
	if(ok==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int r;
    cin >> r;
    string ans = "AGC";

    if (r < 1200) ans="ABC";
    else if (r < 2800) ans = "ARC";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;


int main(){
    int N;
    cin >> N;
    double A[100];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    double sum = 0;
    for(int j=0; j<N; j++){
        sum += 1/A[j];
    }

    double answer = 1/sum;
    cout << fixed << setprecision(10) << answer;

    return 0;
}

Measured memory_bytes: 256
h, _w = gets.strip.split(' ').map{|x| x.to_i}

$cost = []
10.times do |i|
  $cost[i] = gets.strip.split(' ').map{|x| x.to_i}
end

$cache = {}
def calc(n, parents=[])
  parents.push n
  return $cache[parents] if $cache.key?(parents)

  min_c = $cost[n][1]
  10.times do |i|
    next if i == 1 || parents.include?(i)
    if $cost[n][i] < min_c
      cost = $cost[n][i] + calc(i, parents)
      if cost < min_c
        min_c = cost
      end
    end
  end
  $cache[parents.dup] = min_c
  parents.pop

  min_c
end

a = []
h.times do |i|
  a.concat(gets.strip.split(' ').map{|x| x.to_i}.select{|x| x != -1})
end

puts a.map{|x| calc(x)}.inject(:+)


Measured memory_bytes: 9724
ss = input()
t = input()
e = len(ss)
f = len(t)
d = []
try:
    for i in range(e-f+1):
        b = 1
        for j in range(f):
            if ss[i+j] != t[j] and ss[i+j] != '?':
                b = 0
        if b:
            s = ss[:i]+t+ss[i+f:]
            d.append(s.replace('?', 'a'))
    d.sort()
    print(d[0])

except:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int A[3][3],N,b;
bool a[3][3];
int main(){
    for(int i=0;i<9;i++){cin>>A[i/3][i%3];a[i/3][i%3]=false;}
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>b;
        for(int j=0;j<9;j++)if(A[j/3][j%3]==b)a[j/3][j%3]=true;
    }
    if((a[0][0]&&a[0][1]&&a[0][2])||(a[1][0]&&a[1][1]&&a[1][2])||(a[2][0]&&a[2][1]&&a[2][2])
    ||(a[0][0]&&a[1][0]&&a[2][0])||(a[0][1]&&a[1][1]&&a[2][1])||(a[0][2]&&a[1][2]&&a[2][2])
    ||(a[0][0]&&a[1][1]&&a[2][2])||(a[0][2]&&a[1][1]&&a[2][0]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   string S;
   cin>>S;
   int len=S.size();
   int num;
   int ans=1000;
   rep(i,len-2){
       num=(S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0';
       ans=min(ans,abs(753-num));
   }
   cout<<ans<<endl;
   
   
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string>a(h),b(h),c(h);
  for(i=0;i<h;i++)cin>>a[i];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(i==0||i==h-1||j==0||j==w-1){
        b[i]+='#';c[i]+='.';
      }
      else if(j==1){
        b[i]+=a[i][j];
        c[i]+='#';
      }
      else if(i%2==1){
        b[i]+=a[i][j];
        c[i]+='#';
      }
      else{
        b[i]+='#';
        c[i]+=a[i][j];
      }
    }
  }
  debug(b,h,w);
  cout<<endl;
  debug(c,h,w);

  return 0;
}

Measured memory_bytes: 1796
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1 && B != 1) {
		cout << "Alice" << endl;
	}
	else if (A != 1 && B == 1) {
		cout << "Bob" << endl;
	}
	else if (A == B) {
		cout << "Draw" << endl;
	}
	else if (A < B) {
		cout << "Bob" << endl;
	}
	else if (A > B) {
		cout << "Alice" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long K;
        K = sc.nextLong();
        long[] P = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                P[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, K, P);
    }
}

class Solver {
    public void solve(long N, long K, long[] P) {
        long ans = 1;
        final TreeSet<Long> ts = new TreeSet<>();
        for (int i = 0; i < N; i++) {
            ts.add(P[i]);

            if (i >= K) {
                if (ts.first() != P[(int) (i - K)] || ts.last() != P[i]) ans++;
                ts.remove(P[(int) (i - K)]);
            }
        }

        int sorted = 0;
        int count = 1;
        for (int i = 1; i < N; i++) {
            if (P[i - 1] < P[i]) {
               count++;
               if (count == K) {
                   sorted++;
               }
            }
            else {
                count = 1;
            }
        }

        if (sorted >= 2) {
            System.out.println(ans - (sorted - 1));
            return;
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 104256
n,m=gets.chomp.split(" ").map(&:to_i)
ttl = []
n.times do |i|
  _, *ary = gets.chomp.split(" ").map(&:to_i)
  ttl << ary
end

sa = ttl[0]
ttl.each do |t|
  sa = sa & t
end

puts sa.size

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define bgn begin()
#define sz size()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second

signed main(){
  int n, m;
  cin >> n >> m;
  V<int> hakai(n+1 , 1);
  fo(i,m){
    int a;
    cin >> a;
    hakai[a] = 0;
  }
  int dp[100010];
  fo(i,100010){
    dp[i] = 0;
  }
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    if(!hakai[i])
      continue;
    for(int j = max<int>(0 , i-2); j < i; j++){
      dp[i] += dp[j];
      dp[i] %= 1000000007;
    }
  }
  cout << dp[n] << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> a(n);
    rep(i,n) {
        int A, B;
        cin >> A >> B;
        a[i].first = A;
        a[i].second = B;
    }
    sort(all(a));
    ll ans = 0;
    int d = 0;
    rep(i,n) {
        if(m>=(d + a[i].second)){
            d+=a[i].second;
            ans+=(ll)a[i].first*(ll)a[i].second;
        }
        else if(d==m) break;
        else{
            ans += (m-d)*a[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    map<ll, ll> a;
    rep(i, 0, n) {
        ll p; cin >> p;
        a[p]++;
    }
    ll use = 0, ans = 0;
    for (auto itr = a.begin(); itr != a.end(); ++itr) {
        if (itr->second / 2 > 0) {
            if (itr->second / 4 > 0) 
                ans = max(ans, itr->first * itr->first);
            else 
                ans = max(ans, use * itr->first);
            use = itr->first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
  char s[100001];
  scanf("%s",s);
  int t=0;
  int i;
  while(1){
    if(s[t]=='\0')break;
    t++;
  }
  int array[t];
  for(i=0;i<t;i++){
    array[i]=s[i]-48;
  }
  int zero=0;
  int one=0;
  for(i=0;i<t;i++){
    if(array[i]==0)zero++;
    if(array[i]==1)one++;
  }
  if(zero<one){
    printf("%d\n",zero*2);
  }else{
    printf("%d\n",one*2);
  }
  return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		arr[x] = i + 1;
	}
	for(int i = 0; i < n; i++) {
		cout << arr[i] << " ";
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n);
  rep(t, 2){
    int cn = 0;
    rep(i, n){
      if(s[i] == 'R')cn++;
      else{
        ans[i] += cn / 2;
        ans[i - 1] += (cn + 1) / 2;
        cn = 0;
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i, n){
      if(s[i] == 'R') s[i] ='L';
      else s[i] = 'R';
    }
  }
  rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    int total = 0;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr) {
        cin >> val;
        total ^= val;
    }
    for(int i = 0; i < n; i++) {
        int tmp = total ^ arr[i];
        cout << tmp << " ";
    }
    return 0;
}


Measured memory_bytes: 3980
from itertools import combinations

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

border = (n - 1) * (n - 2) // 2

if k > border:
  print(-1)
else:
  print(n - 1 + border - k)
  for i in range(2, n + 1):
    print(1, i)
  comb = list(combinations([i for i in range(2, n + 1)], 2))
  for i, j in comb[:border - k]:
    print(i, j)

Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, m ;
  cin >> a >> b >> m ;
  vector<int> r(a) ;
  vector<int> d(b) ;
  REP(i,a){
    cin >> r[i] ;
  }
  REP(i,b){
    cin >> d[i] ;
  }
  int ans = INF ;
  REP(i,m){
    int x, y , c ;
    cin >> x >> y >> c ;
    int sum = 0 ;
    x-- ;
    y-- ;
    sum = r[x] + d[y] -c ;
    ans = min(sum,ans) ;
  }
  sort(ALL(r)) ;
  sort(ALL(d)) ;
  ans = min(ans,r[0]+d[0]) ;
  cout << ans <<endl ;
  
  
  
  return 0 ;
}




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

const ULL M = 1000000007;
ULL N,K;
ULL F[1000001];
ULL I[1000001];
ULL iF[1000001];

ULL P(ULL n,ULL r){ return F[n]*iF[n-r]%M; }
ULL C(ULL n,ULL r){ return F[n]*iF[r]%M*iF[n-r]%M; }

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

 F[0]=I[1]=iF[0]=1;
 for(int i=1; i<=1000000; i++) F[i]=F[i-1]*i%M;
 for(int i=2; i<=1000000; i++) I[i]=M-M/i*I[M%i]%M;
 for(int i=1; i<=1000000; i++) iF[i]=iF[i-1]*I[i]%M;

 ULL ans = 0;
 for(int i=0; i<=N; i++){
  ULL tmp=0;
  tmp += P(K-i,N-i);
  tmp = tmp * C(N,i) % M;
  if(i&1) ans += M-tmp; else ans += tmp;
 }

 ans %= M;
 ans = ans * P(K,N) % M;
 cout<<ans<<endl;

 return 0;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int K; cin >> K;
    string S; cin >> S;
    if (S.size() <= K) {
        cout << S;
    }
    else {
        for (int i = 0; i < S.size(); i++) {
            if (i < K) {
                cout << S.at(i);
            }
            else {
                cout << "...";
                break;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  cout<<((n>=30)?"Yes":"No")<<endl;
  
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


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


    if ((n >= 'a') && (n <= 'z')) {
        cout << "a" << endl;
    }
    if ((n >= 'A') && (n <= 'Z')){
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
N, Q = map(int, input().split())
S = input()
L = [list(map(int, input().split())) for _ in range(Q)]
C = [0]*N
for i in range(1,N):
	if S[i-1] == 'A' and S[i] == 'C':
		C[i] = C[i-1] + 1
	else:
		C[i] = C[i-1]
for i in range(Q):
	print(C[L[i][1] - 1]- C[L[i][0] - 1])


Measured memory_bytes: 30652
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;
queue<long>que;

int main(){
    long a,b,c,k;
    cin >> a>>b>>c>>k;
    long  ans;
    if(k<=a)
        ans =k;
    else if(k<=a+b)
        ans = a;
    else
        ans = a - (k-(a+b));
    
    cout<< ans <<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

void DFS(vector<vector<int>>& graph, int v, int& time, vector<int>& d, vector<int>& f){
    time++;
    d[v] = time;
    for( int i = 0 ; i < graph[v].size(); i++){
        if(d[graph[v][i]] == -1){
            DFS(graph, graph[v][i], time, d, f);
        }
    }

    time++;
    f[v] = time;

    return;
}

int main(){

    int n;
    cin >> n;

    vector<vector<int>> graph(n);

    for(int i = 0; i < n; i++ ){
        int v, k;
        cin >> v >> k;
        for(int j = 0; j < k ; j++){
            int v2;
            cin >> v2;
            graph[v-1].push_back(v2-1);
        }
    }

    vector<int> d(n, -1);
    vector<int> f(n, -1);
    int time = 0;

    for(int i = 0 ; i < n ; i++){
        if( d[i] == -1 ){
            DFS(graph, i, time, d, f);
        }
    }

    for(int i = 0; i < n; i++ ){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, w; cin >> n >> w;
    vvi dp(n+1, vi(w+1, 0));
    vector<pair<ll, ll>> wv(n+1);
    repf(i, n) cin >> wv[i].first >> wv[i].second;

    for(ll i=1; i<=n; i++){
        for(ll sum_weight=0; sum_weight<=w; sum_weight++){
            if(sum_weight-wv[i].first >= 0){
                // i番目の商品を品物を持ち帰れる場合、ギリギリの容量が空いている場合の最大価値+i番目の品物の価値
                chmax(dp[i][sum_weight], dp[i-1][sum_weight-wv[i].first]+wv[i].second);
            }
            // 選ばない場合はdpテーブルにおける上の行をそのまま引き継ぐ
            chmax(dp[i][sum_weight], dp[i-1][sum_weight]);
        }
    }
    cout << dp[n][w] << endl;
}

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

 int main() {
   int N;
   cin >> N;
   long int A[210000];
   for (int i = 0; i < N; i++) {
     cin >> A[i];
   }
   string res = "YES";
  sort(A, A + N, greater<int>());
   for (int i = 0; i < N - 1; i++) {
     if (A[i] == A[i + 1]) {
       res =  "NO";
       break;
     }
   }
   cout << res << '\n';
 }


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

int main(){
  	int A, B, C, D ;
	cin >>A >>B >>C >>D;
  		if(A + B > C + D){
        	cout << "Left" << endl;
        }
    	if(A + B == C + D){
        	cout << "Balanced" << endl;
        }
  		if(A + B < C + D){
        	cout << "Right" << endl;
        }
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int dp[][];
    static int w;
    static int h;
    static int max = 0;
    static ArrayList<Integer> mhs;

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
         h = sc.nextInt();
         w = sc.nextInt();
        int[][] board = new int[w][h];
        dp = new int[w][h];
        for (int y = 0;y < h;++y){
            for (int x = 0;x < w;++x){
                board[x][y] = sc.nextInt();
                dp[x][y] = Integer.MIN_VALUE;
            }
        }
        //search(0,0,board,0,new ArrayList<>());

        mhs = search(board);
        System.out.println(mhs.size() / 2);
        for (int i = 0;i < mhs.size() / 2;++i){
            int n1 = mhs.get(i * 2);
            int n2 = mhs.get(i * 2 + 1);
            int y1 = n1 / w;
            int x1 = (n1 - y1 * w);
            int y2 = n2 / w;
            int x2 = (n2 - y2 * w);
            StringBuilder sb = new StringBuilder();
            sb.append(y1 + 1);
            sb.append(' ');
            sb.append(x1 + 1);
            sb.append(' ');
            sb.append(y2 + 1);
            sb.append(' ');
            sb.append(x2 + 1);
            System.out.println(sb.toString());
        }

      /*  int c = 0;
        for (int y = 0;y < h;++y){
            for (int x = 0;x < w;++x){
                if((board[x][y] & 1) == 0){
                    ++c;
                }
            }
        }
        System.out.println(c);*/
    }

    public static ArrayList<Integer> search(int board[][]){
        ArrayList<Integer> hi = new ArrayList<>();
        for (int y = 1;y < h;++y){
            for (int x = 0;x < w;++x){
                if((board[x][y - 1] & 1) == 1){
                    --board[x][y - 1];
                    ++board[x][y];
                    hi.add(x + (y - 1) * w);
                    hi.add(x + y * w);
                }
            }
        }
        for (int x = 0;x < w - 1;++x){
            if((board[x][h - 1] & 1) == 1){
                --board[x][h - 1];
                ++board[x + 1][h - 1];
                hi.add(x + (h - 1) * w);
                hi.add(x + 1 + (h - 1) * w);
            }
        }
        return hi;
    }


}




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

#define MOD 1000007
#define MAX 100007

int main(){
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << "-1\n";
    }else{
        cout << a*b << "\n";
    }
    return 0;
}


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

#define int long long

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

int N;
int C[500], S[500], F[500];

signed main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }
    for (int i = 0; i < N; i++) {
        int ans = 0;
        for (int j = i; j < N - 1; j++) {
            ans = ans <= S[j] ? S[j] : ceil((double)(ans - S[j]) / F[j]) * F[j] + S[j];
            ans += C[j];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<int> index[26];

int main(){
	string s;
	cin >> s;
	/*
	for(int i=0; i<s.size(); i++)
		index[s[i]-'a'].push_back(i);

	int pos[26];
	for(int i=0; i<26; i++) pos[i] = 1;
	for(int i=0; i<s.size(); i++){
		int c = s[i]-'a';
		for(int j=pos[c]; j<index[c].size(); j++){
			cout << i << " " << j << " " << index[c][j]+1-i << " " << (j-pos[c]+2) << endl;
			if(index[c][j]+1-i < 2*(j-pos[c]+2)){
				cout << i+1 << " " << index[c][j]+1 << endl;
				return 0;
			}
		}
		pos[c]++;
	}
	*/

	for(int i=0; i<s.size(); i++){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512