akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

class segmenttree{
    private:
    int n;
    long long identity = 0;//単位元
    std::vector<long long> dat;
    public:
    
    void init(int N){
        n=1;
        while(n<N)n*=2;
        dat.clear();
        for(int i=0;i<2*n-1;++i){
            dat.push_back(identity);
        }
    }
    
    long long calc();
    
    void update(int k,long long a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=calc(dat[2*k+1],dat[2*k+2]);
        }
    }
    
    long long query(long long a,long long b){
        a+=n;
        b+=n;
        long long R=0;
        while(a < b){
            if(a % 2 == 1){
                R = calc(R, dat[a - 1]);
                a += 1;
            }
            a /= 2;
            if(b % 2 == 1){
                b -= 1;
                R = calc(R, dat[b - 1]);
            }
            b /= 2;
        }
        return R;
    }
    
    long long calc(long long a,long long b){
        //your monoid here
        return a|b;
    }
    
};


signed main(void){
    int N;
    string S;
    int Q;
    cin >> N;
    cin >> S;
    cin >> Q;
    
    segmenttree Seg;
    Seg.init(N);
    REP(i,N){
        int s = S[i]-'a';
        int t = (1<<s);
        Seg.update(i,t);
    }
    
    REP(_,Q){
        int com,l,r,i;
        char c;
        cin >> com;
        if(com==1){
            cin >> i >> c;
            i--;
            int s = c-'a';
            int t = (1<<s);
            Seg.update(i,t);
        }else{
            cin >> l >> r;
            l--;r--;
            int R=Seg.query(l,r+1);
            //cout << R << " ";
            int Ans=0;
            while(R>0){
                if(R%2==1)Ans++;
                R/=2;
            }
            cout << Ans << endl;
        }
    }
    
    return 0;
}



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

int main(){
long double a,b,c;
cin >>a >>b >>c;
if(c-a-b-2*sqrt(a*b)>0)cout <<"Yes"<<endl;
else cout <<"No" <<endl;


//if(a+b+2*sqrt(a*b)<c) cout <<"Yes"<<endl;
//else cout <<"No" <<endl;

return 0;
}

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

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n;
		long k,temp = 0,b = 0,ans,ans1,ans2;
		int[] a;
		String str;
		String[] s;
		str = bf.readLine();
		s = str.split(" ");
		n = Integer.parseInt(s[0]);
		k = Long.parseLong(s[1]);
		str = bf.readLine();
		s = str.split(" ");
		a = new int[n];
		for(int i = 0;i < n;++i) {
			a[i] = Integer.parseInt(s[i]);
			for(int j = 0;j < i;++j) {
				if(a[j] > a[i]) {
					b++;
				} else if(a[j] < a[i]) {
					temp++;
				}
			}
		}
		ans1 = temp;
		long num = k*(k-1)/2;
		num %= 1000000007;
		ans1 *= num;
		ans1 %= 1000000007;
		ans2 = b;
		num = k*(k+1)/2;
		num %= 1000000007;
		ans2 *= num;
		ans2 %= 1000000007;
		ans = ans1+ans2;
		ans %= 1000000007;
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
mod = 10**9+7

step = [0] * (N+1)
step[0] = 1
step[1] = 1

for i in range(N+1):
    if i==0 or i==1:
        if i in A:
            step[i] = 0
    else:
        step[i] = step[i-1]+step[i-2]
        if i in A:
            step[i] = 0
        step[i] %= mod

print(step[-1])

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

using namespace std;
typedef long long ll;

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

  int at[100001] = {0};
  for (int i = 0; i < n - 1; i++)
  {
    if (s[i] == 'A' && s[i + 1] == 'C')
    {
      at[i + 1] = 1;
    }
  }

  for (int i = 1; i < n; i++)
  {
    at[i] += at[i - 1];
  }

  int l, r;
  for (int i = 0; i < q; i++)
  {
    cin >> l >> r;
    l--;
    r--;
    cout << at[r] - at[l] << endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
typedef pair<ll,ll> P;
vector< pair<ll,ll> > Ga[114514], Gb[114514];
ll da[114514],db[114514];
signed main(){
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	vector<ll> u,v,a,b;
	for(ll i=0;i<m;i++){
		ll uu,vv,aa,bb;
		cin>>uu>>vv>>aa>>bb;
		u.pb(uu);v.pb(vv);a.pb(aa);b.pb(bb);
		Ga[uu].pb( mp( vv,aa) );
		Ga[vv].pb( mp( uu,aa) );
		Gb[uu].pb( mp(vv,bb));
		Gb[vv].pb( mp(uu,bb));
	}
	for(ll i=1;i<=n;i++){
		da[i] = LINF; db[i] = LINF;
	}
	da[s] = 0;
	priority_queue< P, vector<P>, greater<P> > que;
	que.push( mp( 0, s ) );
	while(! que.empty() ){
		P cur = que.top(); que.pop();
		ll co = cur.first;
		ll idx = cur.second;
		for(ll i=0;i<Ga[idx].size();i++){
			P nx = Ga[idx][i];
			if( da[ nx.first ] > da[ idx ] + nx.second){
				da[ nx.first ] = da[ idx ] + nx.second;
				que.push( mp( da[nx.first], nx.first ));
			}
		}
	}
	db[t] = 0;
	que.push( mp( 0, t ) );
	while(! que.empty() ){
		P cur = que.top(); que.pop();
		ll co = cur.first;
		ll idx = cur.second;
		for(ll i=0;i<Gb[idx].size();i++){
			P nx = Gb[idx][i];
			if( db[ nx.first ] > db[ idx ] + nx.second){
				db[ nx.first ] = db[ idx ] + nx.second;
				que.push( mp( db[nx.first], nx.first ));
			}
		}
	}
	priority_queue< ll, vector<ll>, greater<ll> > pue;
	vector<ll> ans;
	for(ll i=n;i>=1;i--){
		pue.push( da[i]+db[i] );
		ans.pb( pue.top() );
	}
	reverse( ans.begin(),ans.end() );
	for(ll i=0;i<n;i++){
		cout<<1000000000000000LL-ans[i]<<endl;
	}
	return 0;
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> h(n+1);
  for(int i = 1; i <= n; i++){
  	cin >> h.at(i);
  }
  int ans = 0;
  for(int i = 1; i <= 100; i++){
  for(int j = 0; j < n; j++){
  	if(h.at(j) < i && i <= h.at(j+1)){
    	ans++;
    }
  }
  }
  cout << ans << endl;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;


VI g[10005];


const int MAX_V = 10005;  // ツリーのサイズのありうる最大値

int N;  // ツリーのサイズ
vector<int> tree[MAX_V];  // ツリーを隣接リスト形式のグラフ構造で表したもの

int sizeSubtree[MAX_V];  // sizeSubtree[v] := v を根とする部分ツリーのサイズ
vector<int> centroids;  // 重心列挙の答えがここに入る

/* ツリーDP */
void SubFindCentroids(int v, int parent_of_v = -1) {
	sizeSubtree[v] = 1;
	bool isCentroid = true;
	for (auto ch : tree[v]) {
		if (ch == parent_of_v) continue;
		SubFindCentroids(ch, v);
		if (sizeSubtree[ch] > N / 2) isCentroid = false;
		sizeSubtree[v] += sizeSubtree[ch];
	}
	if (N - sizeSubtree[v] > N / 2) isCentroid = false;
	if (isCentroid) centroids.push_back(v);
}

void FindCentroids() {
	centroids.clear();
	SubFindCentroids(0, N); // これを呼び出すと centoroids に重心を列挙したものが入る
}


VI ans(10005,0);
VB used(10005, false);
void dfs(int i, int cnt) {
	ans[i] = cnt;
	used[i] = true;
	for (int j : tree[i]) {
		if (!used[j])dfs(j, cnt + 1);
	}
}


int main() {




	cin >> N;
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	SubFindCentroids(0, N);


	dfs(centroids[0], 0);
	vector<pair<int, int>> v;
	REP(i, N)v.push_back({ ans[i],i });
	sort(ALL(v));
	VI c(N);
	REP(i, N)cin >> c[i];
	sort(ALL(c));
	reverse(ALL(c));

	VI vv(N);
	REP(i, N) {
		vv[v[i].second] = c[i];
	}

	ll aa = 0;
	REP(i, N) {
		for (int j : tree[i]) {
			ll k = min(vv[i], vv[j]);
			aa += k;
		}
	}
	aa /= 2;

	cout << aa << endl;
	REP(i, N)cout << vv[i] << ' ';
	cout << endl;



	return 0;


}

Measured memory_bytes: 2172
#include <stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i)
{
  int l,r,tmp,largest;
  l = i*2;
  r = i*2+1;
  if (l<=H && A[l]>A[i]) largest = l;
  else largest = i;
  if (r<=H && A[r]>A[largest]) largest = r;
  if (largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int main(){
  int i;

  scanf("%d",&H);

  for(i=1;i<=H;i++)scanf("%d",&A[i]);

  for(i=H/2;i>=1;i--) maxHeapify(i);

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }

printf("\n");

  return 0;
}



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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e9;
const int mod = 1e9 + 7,
N = 2e5 + 11;

int n, a[N];
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    int res = INT_MAX;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= 100; i++) {
        int ans = 0;
        for (int j = 1; j <= n; j++)
            ans += (a[j] - i) * (a[j] - i);
        res = min(res, ans);
    }
    cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1105;
const ll INF=1LL<<60;
char ans[MAX][MAX];
int H,W;

void DFS(int u,int d,int l,int r){
    if(u>=d||l>=r) return;
    int h=(u+d)/2,w=(l+r)/2;
    ans[h][w]='1';
    
    DFS(u,h,l,w);
    DFS(h+1,d,l,w);
    DFS(u,h,w+1,r);
    DFS(h+1,d,w+1,r);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B;cin>>A>>B;
    H=pow(2,A)-1;
    W=pow(2,B)-1;
    
    DFS(0,H,0,W);
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<char('0'+(ans[i][j]=='1'));
        }
        cout<<endl;
    }
}




Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  double pai=3.141592653589793;
  double a,b,h,m;double ka;cin>>a>>b>>h>>m;
  h=(h*60+m)/2;m=m*6;
  ka=max(h,m)-min(h,m);
  if(ka>=180){ka=360-ka;}
    ka = ka*(pai/180);
  cout << fixed << setprecision(15)<<sqrt(a*a+b*b-2*a*b*cos(ka))<<endl;
}
  


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

using namespace std;

main(){
	char str[20];
	int len=0;
	int i;
	scanf("%s",str);

	len=0;
	while(str[len] != '\0') {
	len++;
	}

	for(i=len-1;i>=0;i--) {
	printf("%c",str[i]);
	}
	printf("\n");
}


Measured memory_bytes: 3144
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.next();
    Map<Character, Character> map = new HashMap(){{ put('A','T');put('T','A'); put('C','G');put('G','C');}};
    System.out.println(map.get(line.charAt(0)));
  }
}


Measured memory_bytes: 21460
#N = int(input())
l = [int(x) for x in input().split()]
while True:
    l[2] = l[2] - l[1]
    if l[2] <= 0:
        print("Yes")
        break
    l[0] = l[0] - l[3]
    if l[0] <= 0:
        print("No")
        break

Measured memory_bytes: 9184
#include <stdio.h>

long get_count(long A, long B, long target) {
    if (B < target)
        return 0;
    long mod_a = A % target;
    long mod_b = B % target;
    long initial = (mod_a == 0) ? A : A + (target - mod_a); // 最初に割り切れる値
    long last = B - mod_b;
    long initial_count = initial / target;
    long last_count = last / target;
    return last_count - initial_count + 1;
}

long gcd(long m, long n) {
    long tmp;
    while (m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }

    return n;
}

long lcm(long m, long n) {
    return m * n / gcd(m, n);
}

int main () {
    long A;
    long B;
    long C;
    long D;

    scanf("%ld", &A);
    scanf("%ld", &B);
    scanf("%ld", &C);
    scanf("%ld", &D);

    long divided_c = get_count(A, B, C);
    //printf("c: %ld\n", divided_c);
    long divided_d = get_count(A, B, D);
    //printf("d: %ld\n", divided_d);
    long divided_c_d = get_count(A, B, lcm(C, D));
    //printf("lcm: %ld\n", lcm(C, D));
    //printf("c_d: %ld\n", divided_c_d);

    long ans = (B - A + 1) - (divided_c - divided_c_d + divided_d);

    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 128
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
   // FI(); /// skip this line for compile
    int n,k;
    cin >> n >> k;
    if(n>=10) cout << k << endl;
    else cout << k+100*(10-n) << endl;
    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>b(n - 1);
	rep(i, n - 1)cin >> b[i];
	vector<int>c(n);
	c[0] = b[0];
	for (int i = 1; i < n - 1; i++) {
		c[i] = min(b[i], b[i - 1]);
	}
	c[n - 1] = b[n - 2];
	int ans = 0;
	rep(i, n) {
		ans += c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cfloat>
#include<cmath>
#include<algorithm>
 
 
using namespace std;
 
double EPS = 1e-10;
 
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
 
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
 
  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};
 
bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}
 

vector<point>N;

bool Binary_search(point x){
  int l=0,r=N.size(),mid=(l+r)/2;
 
  while(r-l>1){
    if(N[mid]==x)return true;
 
    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;
 
    mid=(l+r)/2;
  }
 
  if(N[mid]==x)return true;
  return false;
}
 
point solve(vector<point> M){
 
  for(int i=0; i< N.size(); i++){
    int j=1;
    for(; j< M.size(); j++){
      point t=N[i]+M[j]-M[0];
      if(!Binary_search(t))break;  
    }
    if(j==M.size())return N[i]-M[0];
  }
  return M[0];
}
 
int main(void){
  int n,m;
  point in;
  vector<point>M;
 
  while(cin >> m,m){
    M.clear();
    N.clear();   
 
    for(int i=0; i< m; i++){
      cin >> in.x >> in.y;
      M.push_back(in);
    }
     
    cin >> n;
 
    for(int i=0; i< n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }
 
    sort(N.begin(),N.end(),cmp_x);
 
    point res=solve(M);
 
    cout << res.x <<" "<< res.y << endl;
 
  }
 
  return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;

void solve(){
	cin >> n >> k;
	for(int i =0;i<n;i++){
		cin >> x;
		v.push_back(x);
	}
	sort(all(v));
	int sum=0;
	for(int i =0;i<k;i++){
		sum+=v[i];
	}
	cout << sum;
}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N,Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	int cnt[26] = { 0 };
	REP(i, S.size()) {
		cnt[S[i] - 'A']++;
	}
	int L = 0, R = N-1;

	char Ltmp='a', Rtmp='a';
	vector<char> a(Q), b(Q);
	REP(i, Q)cin >> a[i] >> b[i];

	for(int i=Q-1;i>=0;i--) {
		if (cnt[a[i] - 'A'] == 0)continue;

		if (b[i] == 'R' && a[i] == Ltmp) {
			L--;
			Ltmp = S[L - 1];
		}
		if (b[i] == 'L' && a[i] == Rtmp) {
			R++;
			Rtmp = S[R + 1];
		}
		if (b[i] == 'L' && S[L] == a[i]) {
			Ltmp = a[i];
			L++;
		}
		if (b[i] == 'R' && S[R] == a[i]) {
			Rtmp = a[i];
			R--;
		}
	}
	//cout << L << R << endl;
	cout << N - L - (N - R)+1 << endl;
	return 0;
}



Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9; 
int n,k;
std::vector<int> a(N); 
vector<ll> dp(N,1e18);
ll solve(int x){
    if(x>=n-1) return 0;
    if(dp[x]!=1e18) return dp[x]; 
    for(int i=1;i<=k&&x+i<n;i++)
    dp[x]=min(abs(a[x+i]-a[x])+solve(x+i),dp[x]);
    //cout<<ans<<endl;
    return dp[x];
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
    cout<<solve(0);
	return 0; 
	
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    
    cout<<n*n*n<<endl;
    
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, m; cin >> n >> m;

    vector<pair<int, int>> stores(n);
    for(int i = 0; i < n; ++i) {
        cin >> stores[i].first >> stores[i].second;
    }

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

    int ans = 0;
    int i = 0;
    while(m > 0) {
        int cans = min(m, stores[i].second);
        ans += cans*stores[i].first;
        m -= cans;
        ++i;
    }

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


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

template<class T>
struct SegTree {
    std::vector<T> tree;
    T INF;
    size_t N;
    std::function<bool(T,T)> pred;

    SegTree(size_t size, T inf, std::function<bool(T,T)> p) {
        INF = inf;
        pred = p;

        N = 1;
        while( N < size ) {
            N <<= 1;
        }
        tree.resize(2*N-1, INF);
    }

    void update(int i, int x) {
        i += N - 1;
        tree[i] = x;

        while(i > 0) {
            i = (i-1)/2;
            tree[i] = pred(tree[i*2+1],tree[i*2+2]) 
                        ? tree[i*2+1] 
                        : tree[i*2+2];
        }
    }

    T query(size_t a, size_t b) {
        return query(a, b, 0, 0, N);
    }
    T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
        if( r <= a || b <= l ) {
            return INF;
        }
        if( a <= l && r <= b ) {
            return tree[k];
        } else {
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return pred(vl, vr) ? vl : vr;
        }
    }
};

int main(){
    int n, q, c, x, y;
    std::cin >> n >> q;

    SegTree<long> st = SegTree<long>(n, (1LL << 31) - 1, [](long x, long y){return x < y;});
    REP(i, q) {
        std::cin >> c >> x >> y;
        if(c == 0) {
            st.update(x,y);
        } else {
            std::cout << st.query(x, y+1) << std::endl;
        }
    }
}

Measured memory_bytes: 4884
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, X, T;
  cin >> N >> X >> T;
  // const int64_t L = static_cast<int64_t>(T.length());
  cout << (N + (X - 1)) / X * T << endl;
  return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    cout << max(0,min(B,D)-max(A,C)) <<endl;
    return (0);
}

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

int main(){
    ll N, K; cin >> N >> K;
    ll ans=0;
    for(ll i=K+1; i<=N; i++){
        ans +=(N/i * (i-K) );
        ans += max(0LL, N%i-K+1LL );
        if(K==0) ans--;
//        cout << (N/i * (i-K) )  + max(0LL, N%i-K ) << endl;
    }
    cout << ans << endl;
}

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

// ----- SuffixArray -----

class SuffixArray
{
  int N, K;
  string S;
  vector<int> sa;

public:
  SuffixArray(string S) : N{static_cast<int>(S.size())}, K{1}, S{S}, sa(N + 1)
  {
    // initialize for 1 char
    for (auto i = 0; i <= N; i++)
    {
      sa[i] = i;
    }
    vector<int> rank(N + 1);
    for (auto i = 0; i < N; i++)
    {
      rank[i] = static_cast<int>(S[i]);
    }
    rank[N] = -1;
    // lambda for comparing
    auto compare_sa = [&](auto i, auto j) {
      if (rank[i] != rank[j])
      {
        return rank[i] < rank[j];
      }
      else
      {
        int ri{i + K <= N ? rank[i + K] : -1};
        int rj{j + K <= N ? rank[j + K] : -1};
        return ri < rj;
      }
    };
    // construct sa with rank
    vector<int> tmp(N + 1);
    for (; K <= N; K *= 2)
    {
      sort(sa.begin(), sa.end(), compare_sa);
      tmp[sa[0]] = 0;
      for (auto i = 1; i <= N; i++)
      {
        tmp[sa[i]] = tmp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0);
      }
      swap(rank, tmp);
    }
  }

  int operator[](int i) const
  {
    return sa[i];
  }

  int lower_bound(string const &T) const
  {
    int a{-1}, b{N + 1};
    auto cmp = [&](auto c) {
      return S.compare(sa[c], T.size(), T) < 0;
    };
    binary_search(a, b, cmp);
    return b;
  }

  int upper_bound(string const &T) const
  {
    int a{-1}, b{N + 1};
    auto cmp = [&](auto c) {
      return S.compare(sa[c], T.size(), T) <= 0;
    };
    binary_search(a, b, cmp);
    return a;
  }

  bool contain(string const &T) const
  {
    int b{lower_bound(T)};
    return b <= N && S.compare(sa[b], T.size(), T) == 0;
  }

  int count(string const &T) const
  {
    int lb{lower_bound(T)};
    int ub{upper_bound(T)};
    if (lb > ub)
    {
      return 0;
    }
    return ub - lb + 1;
  }

private:
  template <typename T>
  void binary_search(int &a, int &b, T cmp) const
  {
    while (abs(a - b) > 1)
    {
      int c{(a + b) / 2};
      if (cmp(c))
      {
        a = c;
      }
      else
      {
        b = c;
      }
    }
  }
};

// ----- main() -----

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_D&lang=ja

void solve()
{
  string S;
  int Q;
  cin >> S >> Q;
  vector<string> T(Q);
  for (auto i = 0; i < Q; i++)
  {
    cin >> T[i];
  }
  SuffixArray sa(S);
  for (auto i = 0; i < Q; i++)
  {
    cout << (sa.contain(T[i]) ? 1 : 0) << endl;
  }
}

int main()
{
  solve();
}



Measured memory_bytes: 26812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    char c;
    cin >> c;
    if(c >= 'a'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define nl "\n"
#define fr first
#define sc second
#define MP make_pair
#define pb push_back
#define VI vector<int>
#define VII vector<ll>
#define MAP map <int,int>
#define PI pair < int , int >
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define precise(n) fixed(cout);cout<<setprecision(n)

const int N = (int)4e7;
const int MOD = (int)1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    ///Let the showdown begin


    string s;
    cin >> s;

    if((s[2]==s[3]) && (s[4]==s[5]))
        cout << "Yes" << nl;
    else
        cout << "No" << nl;

    ///Happily DONE

    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);
	int ans = (n - 1 + (k - 1 - 1)) / (k - 1);
	write(ans);
}


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

int main() {
  string s,t,ans="Yes";
  cin >> s >> t;
  vector<long> a(26);
  vector<long> b(26);
  for(long i=0;i<s.size();i++) {
    if(a[t[i]-'a']!=0&&a[t[i]-'a']!=s[i]) ans="No";
    a[t[i]-'a']=s[i];
    if(b[s[i]-'a']!=0&&b[s[i]-'a']!=t[i]) ans="No";
    b[s[i]-'a']=t[i];
  }
  cout << ans << endl;
}

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

using namespace std;

template<typename T>
void maxHeapify(vector<T> &A, int32_t i) {
    int32_t l = 2*i+1, r = 2*i+2, largest = i;
    if (l < A.size() && A[l] > A[largest]) largest = l;
    if (r < A.size() && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[largest], A[i]);
        maxHeapify(A, largest);
    }

    return;
}

template<typename T>
void buildMaxHeap(vector<T> &A) {
    for (int32_t i = A.size() / 2; i >= 0; i--) {
        maxHeapify(A, i);
    }

    return;
}

int main() {
    int32_t H;
    cin >> H;

    vector<int32_t> heap(H);
    for (int32_t i = 0; i < H; i++) {
        cin >> heap[i];
    }

    buildMaxHeap(heap);

    for (int32_t i : heap) {
        cout << " " << i;
    }
    cout << endl;

    return 0;
}

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


const int INF = 1145141919;

int main() {
  int D, G; cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  for(int i=0; i<D; i++){
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }

  G /= 100;
  int score = 0;
  int ans = INF;
  int rest_max = 0;
  int num = 0;

  for(int i=0; i<(1<<D); i++){
    num = 0;
    score = 0;
    rest_max = 0;

    for(int j=0; j<D; j++){
      if((i>>j)&1){
        score += (j+1)*p[j]+c[j];
        num += p[j];
      } else {
        rest_max = max(rest_max, j);
      }
    }

    for(int j=0; j<p[rest_max]-1; j++){
      if(score >= G) break;
      score += rest_max+1;
      num++;
    }

    if(score < G) continue;
    ans = min(ans, num);
  }

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


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in();
  int ans = 0;
  while (a) {
    ans += a % 10;
    a /= 10;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

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

//変数

//解法
void solve() {
	ll A, B, C;
	cin >> A >> B >> C;

	ll ans = C - (A - B);

	if (ans < 0) {
		cout << 0;
	}
	else {
		cout << ans;
	}

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}

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

int main() {
  char r[4], a[4];
  int h, b;

  while(1) {
    cin >> r >> a;
    if(r[0] == '0' && a[0] == '0') break;

    h = 0;
    b = 0;

    for(int i = 0 ; i < 4; i++){
      if(r[i] == a[i])
        h++;
    }

    for(int i = 0 ; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
        if(r[i] == a[j])
          b++;
      }
    }

  cout << h << ' ' << (b-h) << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
n, k = map( int, input().split() )
r, s, p = map( int, input().split() )
t = str( input() )

t_list = [ c for c in t ]
for i in range( k, n ):
    if t_list[ i ] == t_list[ i - k ]:
        t_list[ i ] = "x"

score = 0
for hand in t_list:
    if hand == "r":
        score += p
    elif hand == "s":
        score += r
    elif hand == "p":
        score += s

print( score )

Measured memory_bytes: 9960
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int h = stdIn.nextInt(); //h行
		int w = stdIn.nextInt(); //w列
		int n = stdIn.nextInt(); //塗らなければいけない個数
		
		int l = Math.max(h, w);
		
		int ans = (n+l-1)/l;
		System.out.println(ans);
		
		
		
	}

}


Measured memory_bytes: 21588
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, s = 0;
    cin >> n >> m;
    vector<ll> a(m);
    for (ll &e : a)
        cin >> e, s += e;
    cout << (s > n ? -1 : n - s);
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
double P[505],Q[505],dp[505][505],S[505][505],a1,a2;
int n,i,j,k,m;
int main(){
	cin>>n;
	for(i=1;i<=n;i++)scanf("%lf",&P[i]);
	for(i=0;i<=n;i++)scanf("%lf",&Q[i]);
	for(i=1;i<=n;i++){
		dp[i][i]=P[i]+2*(Q[i-1]+Q[i]);
		S[i][i]=P[i]+Q[i-1]+Q[i];
	}
	for(k=1;k<n;k++)
		for(i=1;i<=n-k;i++){
			j=i+k;
			S[i][j]=S[i][j-1]+P[j]+Q[j];
			a1=S[i][j]+Q[i-1]+dp[i+1][j];
			a2=S[i][j]+Q[j]+dp[i][j-1];
			dp[i][j]=min(a1,a2);
			for(m=i+1;m<j;m++)dp[i][j]=min(dp[i][j],S[i][j]+dp[i][m-1]+dp[m+1][j]);
		}
	printf("%.8lf\n",dp[1][n]);
	return 0;
}



Measured memory_bytes: 7144
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,a = i_map()
    x = i_list()
    x.insert(0,0)

    dp = [[[0]*(n*a+1) for _ in range(n+1)] for _ in range(n+1)]
    for i in range(n+1):
        dp[i][0][0] = 1

    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n*a + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, n+1):
        ans += dp[n][j][a*j]
    print(ans)

  

if __name__=="__main__":
    main()

    

Measured memory_bytes: 117300
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int N,A,B;
int h[114514];
int Roundup(int a,int b){
    return (a+b-1)/b;
}

bool solve(int m){
    int co=0;
    REP(i,N){
        if(h[i]>=m*B){
            int e=Roundup(h[i]-m*B,A-B);
            co+=e;
        }
    }
    if(co>m){
        return false;
    }else{
        return true;
    }
}

signed main(){
    cin >> N >> A >> B;
    REP(i,N){
        cin >> h[i];
    }
    int ok=1e10,ng=-1,mid;
    while(abs(ok-ng)>1){
        mid=(ok+ng)/2;
        if(solve(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    for(int i=max(mid-10,0LL);i<=mid+10;i++){
        if(solve(i)==true){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}   


Measured memory_bytes: 1024
//For fast competitive programming

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

//DATA_TYPES
typedef long long ll; 
typedef vector<int> vi;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f; //Infinity

//INITIALISING
//memset(arr, 0, sizeof arr);
//vi v(N, 0);

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(NULL);
	
	//write your code here
	int t;
	cin>>t;
	int a,b;
	cin>>a>>b;
	for (int i=a;i<=b;i++)
	{
	    if((i% t)==0)
	    {cout<<"OK"<<endl;
	    return 0;
	    }
	    
	}
	
	cout<<"NG"<<endl;
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3652
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        a: usize, b: usize, x: usize,
    }
    println!("{}", b / x - a / x + if a % x == 0 { 1 } else { 0 });
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  int people[16][16];
  rep(i, n+1)rep(j, n+1){people[i][j]=-1;}

  rep(i, n){
    int a;cin>>a;
    rep(j, a){
      int x,y;cin>>x>>y;
      people[i+1][x]=y;
    }
  }

  int result=0;
  rep(bits, pow(2,n)){

    bool flag=true;
    rep(i, n){
      int mask = 1<<i;
      // 今見ているbitではi番目の人が正直者でないなら飛ばす。
      if(!(mask & bits))continue;
      // iの人がjの人について証言している(people[i+1][j+1]!=-1)
      // 現在のbitでのjの人の状態とiのjに対する証言にくい違いがないか
      rep(j,n){
        //cout<<bits<<' '<<(bits >> j & 1)<<' '<<people[i+1][j+1]<<' '<<i<<' '<<j<<endl;
        if(people[i+1][j+1]!=-1 && (bits >> j & 1) != people[i+1][j+1])flag=false;
      }
    }
    //if(flag)cout<<result<<' '<<__builtin_popcount(bits)<<' '<<bits<<endl<<endl;
    if(flag)result=max(result, __builtin_popcount(bits));

  }

  cout<<result;

  return 0;
}


Measured memory_bytes: 384
import sys
s = []
for line in sys.stdin:
    s.append (list(line.rstrip()))

alphabet = [chr(i) for i in range(ord('a'), ord('z')+1)]
for x in alphabet:
    t = 0
    for l in s:
        t += l.count(x)+l.count(str.upper(x))
    print (x,":",t)



Measured memory_bytes: 5588
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}

//main program
fn main() {
    let text = read_string();
    println!(
        "{}",
        switch(text[2] == text[3] && text[4] == text[5], "Yes", "No")
    )
}


Measured memory_bytes: 4352
while True:
    H, W = map(int, input().split())
    if not(H or W):
        break
    for j in range(W):
        print('#', end='')
    print()
    for i in range(H-2):
        print('#', end='')
        for j in range(W-2):
            print('.', end='')
        print('#')
    for j in range(W):
        print('#', end='')
    print('\n')

Measured memory_bytes: 9056
#include <stdio.h>

int main() {
  int a, b, i, j;
  while(1){
    scanf("%d%d", &a, &b);
    if(a == 0 || b == 0) break;
    for(i=1; i <= a; i++) {
      for(j=1; j <= b; j++) {
        if(i % 2 == 1 && j % 2 == 1) printf("#");
        else if(i % 2 == 0 && j % 2 == 0) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2136