akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
template <int mod>
struct ModInt {
    int val;
    ModInt() : val(0) {}
    ModInt(long long x) : val(x >= 0 ? x % mod : (mod - (-x) % mod) % mod) {}
    int getmod() { return mod; }
    ModInt &operator+=(const ModInt &p) {
        if ((val += p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((val += mod - p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        val = (int)(1LL * val * p.val % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-val); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return val == p.val; }
    bool operator!=(const ModInt &p) const { return val != p.val; }
    ModInt inverse() const {
        int a = val, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(long long n) const {
        ModInt ret(1), mul(val);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.val; }
    friend istream &operator>>(istream &is, ModInt &a) {
        long long t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
const int MOD = 1000000007;  // if inv is needed, this shold be prime.
using modint = ModInt<MOD>;

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string L;
    cin >> L;
    int n = (int)L.size();
    vector<vector<modint>> dp(n + 1, vector<modint>(2));
    dp[0][0] = 1;
    dp[0][1] = 2;
    for (int i = 1; i < n; i++) {
        dp[i][0] += dp[i - 1][0] * 3;
        if (L[i] == '1') {
            dp[i][0] += dp[i - 1][1];
            dp[i][1] += dp[i - 1][1] * 2;
        } else {
            dp[i][1] += dp[i - 1][1];
        }
    }
    cout << dp[n - 1][0] + dp[n - 1][1] << endl;
}


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

    public class Main {

        public static void main(String[] args) throws IOException {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int r = Integer.parseInt(br.readLine());
            System.out.println((Math.PI*2*r));
        }
    }




Measured memory_bytes: 33024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <vector>
#include <cctype>
#include <set>
#include "iostream"
using namespace std;
const int INF = 2147483640;
typedef unsigned long long ll;
const int MAXN = 600500;
const int MOD = 998244353;
struct edge
{
	int t,w;
};
std::vector<edge> e[MAXN];
int in[MAXN];
bool vis[MAXN];
void init()
{
	memset(in,0,sizeof in);
	memset(vis,0,sizeof vis);
	for (int i = 0; i < MAXN; ++i)
	{
		e[i].clear();
	}
}
int n,s;
ll top()
{
	ll ans=1;
	queue<int> que;
	for(int i=n+1;i<=2*n;++i) if(in[i]==1) que.push(i),vis[i]=1;
	while(!que.empty())
	{
		int cur=que.front(); que.pop();
		int si=e[cur].size();
		for(int i=0;i<si;++i)
		{
			int v=e[cur][i].t,w=e[cur][i].w;
			if(vis[v]) continue;
			in[v]--;
			if(in[v]==1)
				que.push(v),vis[v]=1;
			if(cur>n) ans=(ans*1LL*w)%MOD;
		}
	}
	return ans;
}
ll ans[2];
void dfs(int u,int ty,int fa)
{
	vis[u]=1;
	int si=e[u].size();
	for(int i=0;i<si;++i)
	{
		int v=e[u][i].t,w=e[u][i].w;
		if(v==s && v!=fa) ans[ty]=(ans[ty]*1LL*w)%MOD;
		if(vis[v]) continue;
		ans[ty]=(ans[ty]*1LL*w)%MOD;
		dfs(v,ty^1,u);
	}
}
int main()
{

	int a,b,c,d;
	while(cin>>a>>b>>c>>d)
	{
		if(min(b,d) - max(a,c)>0)
			printf("%d\n",min(b,d) - max(a,c) );
		else printf("0\n");
	}
    return 0;
}


Measured memory_bytes: 15360
from collections import Counter
n,m=map(int,input().split())
d=Counter(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d:
        d[c]+=b
    else:
        d[c]=b
d=sorted(Counter(d).items(),reverse=True)
check=n
ans=0
for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break

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

int main() {
  string S;
  cin >> S;
  int R = 700;
  
  if(S.at(0)=='o') R=R+100;
  if(S.at(1)=='o') R=R+100;
  if(S.at(2)=='o') R=R+100;
  
  cout<< R <<endl;
  
}

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

int main() {
  int K = 0, S = 0;
  cin >> K;
    for (int a = 1; a <= K; a++) {
      for (int b = 1; b <= K; b++) {
        for (int c = 1; c <= K; c++) {
            S += gcd(gcd(a,b), c);
          }
        }
      }
  cout << S << endl;
}
    


Measured memory_bytes: 3644
#include<stdio.h>
#define N 1001
static const int INFTY = (1<<21);

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0 ; i < n ; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0 ; v < n ; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

int main(){
  int  u, t, v, i, j;

  scanf("%d",&n);

  for ( i = 0 ; i <n ; i++ ){
    for ( j = 0 ; j <n ; j++ )
      M[i][j] = 0;
  }

  for ( i = 0 ; i < n ; i++ ){
    scanf("%d %d",&u,&t);
    u--;
    for ( j = 0 ; j < t ; j++ ){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}


Measured memory_bytes: 2096
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
string S[100010];

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

	cin >> N;
	rep(i, 0, N)
	{
		cin >> S[i];
		sort(all(S[i]));
	}

	sort(S, S + N);

	int ans = 0;
	int t = 0;
	string ps;
	rep(i, 0, N)
	{
		if (i == N - 1 || i != 0 && ps != S[i])
		{
			if (i == N - 1 && ps == S[i])t++;
			if (t > 1)
			{
				ans += t * (t - 1) / 2;
			}
			t = 0;
		}
		t++;
		ps = S[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

 ll N,W;
 cin >> N >> W;
 
 ll w[N+1];
 ll V[N+1];
 
 rep(i,1,N+1) cin >> w[i] >> V[i];
 
 ll dp[W+1];
 memset(dp,0,sizeof(dp));
 
 for(ll i=1;i<=N;i++){
	for(ll j = W;j>=w[i];j--){ 
	    dp[j] = max(dp[j],dp[j-w[i]] + V[i]);
 }
 }
 
 cout << dp[W]<<endl;  
	   
} 





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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000
int main()
{
    ios;
    string s,t;
    cin>>s>>t;
    int l=s.length();
    int m=t.length();
    if(m==l+1)
    {
        string s1=t.substr(0,l);
        if(s1.compare(s)==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long c = Long.parseLong(sc.next());
				
		long d = c - a  - b;
		long e = 4L* a * b;
		
		long f = (long)d*d;
		if(f > e && d > 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21972
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Connect Cities
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void init(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

UFT uft;
int gs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  uft.init(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    uft.merge(a, b);
  }

  memset(gs, -1, sizeof(gs));
  int k = 0;

  for (int i = 0; i < n; i++) {
    int ri = uft.root(i);
    if (gs[ri] < 0) gs[ri] = k++;
  }

  printf("%d\n", k - 1);
  return 0;
}


Measured memory_bytes: 5388
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<double> p(n);
	for(int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	
	vector< vector<double> > dp(n + 10, vector<double>(n + 10, 0.0));
	dp[0][0] = 1.0;
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < i + 1; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}
	
	double ans = 0.0;
	for(int i = n / 2 + 1; i <= n; ++i) {
		ans += dp[n][i];
	}

	printf("%.12f\n", ans);
	
	return 0;
}


Measured memory_bytes: 74304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
//题意:两堆石子 X,Y<=1e8 操作 从某一堆拿2*i个 扔掉i个 添加i个到另外一堆 轮流操作 无法操作为输,问先手必败还是必胜?
//必败态后继都为必胜态,必胜态后继存在必败态,打表找规律 
bool check(int x,int y)
{
	if(x==1&&y==0||(x==0&&y==1))
		return false;//lose态 
	bool flag=false;
	for(int i=2;i<=x;i+=2)
		if(!check(x-i,y+i/2))
			flag=true;
	for(int i=2;i<=y;i+=2)
		if(!check(x+i/2,y-i))
			flag=true;
	return flag;
}
void pattern()
{
	for(int i=1;i<=5;i++)
	{
		for(int j=1;j<=10;j++)
		{
			cout<<i<<' '<<j<<' ';
			if(check(i,j))
				cout<<"win"<<endl;
			else
				cout<<"lose"<<endl;
		}
	}	
}
int main()
{
	ll x,y;
	//pattern();
	while(cin>>x>>y)
	{
		if(abs(x-y)>1)
			puts("Alice");
		else
			puts("Brown");
	}
	return 0;
}
 

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

int main() {
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	bool memo[26];
	for (int i = 1; i <= N - 1; i++) {
		int buf = 0;
		string X = S.substr(0, i);
		string Y = S.substr(i, N - i);
		fill(memo, memo + 26, false);
		for (int j = 0; j < X.length(); j++) {
			for (int k = 0; k < Y.length(); k++) {
				if (X[j] == Y[k] && !memo[X[j] - 'a']) {
					buf++;
					memo[X[j] - 'a'] = true;
				}
			}
		}
		ans = max(ans, buf);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

ll dp[200002][5];

int main(){
    ll l;
    cin >> l;
    VE a(l+1);
    rep(i, 1, l+1)cin >> a[i];
    vector<vector<ll>> dp(l+1, vector<ll>(5, 0));
    rep(i, 1, l+1){
        ll ai = a[i];
        dp[i][0] = dp[i-1][0] + ai;
        dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + a[i] % 2 + (a[i]==0) * 2;
        dp[i][2] = (a[i] + 1) % 2 + min({dp[i-1][2], dp[i-1][0], dp[i-1][1]});
        dp[i][3] = a[i] % 2 + (a[i]==0) * 2 + min({dp[i-1][3], dp[i-1][2], dp[i-1][0], dp[i-1][1]});
        dp[i][4] = a[i] + min({dp[i-1][4], dp[i-1][3], dp[i-1][2], dp[i-1][0], dp[i-1][1]});
    }
    ll ans = min({dp[l][4], dp[l][3], dp[l][2], dp[l][0], dp[l][1]});
    print(ans);
}


Measured memory_bytes: 15872
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

n = getN()
lista = []
digit = 26
i = 0

while n != 0:
    opt = n % digit
    lista.insert(0, opt)
    if n % digit == 0:
        n = n // digit - 1
    else:
        n = n // digit
    i += 1

str_list = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
for i in range(len(lista)):
    ans += str_list[lista[i] - 1]
print(ans)

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

int main(){
  int X;
  cin >> X;
  int K = 1, count = X;
  for(int i = 2; i <= 361; i++){
    if(count % 360 == 0){
      cout << K << endl;
      return 0;
    }
    K++;
    count = X * i;
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
ll dp[1010][1010];
string S[1010];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	dp[0][0]=1;
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) if(S[y][x]=='.') {
			if(y) dp[y][x]+=dp[y-1][x];
			if(x) dp[y][x]+=dp[y][x-1];
			dp[y][x]%=mo;
		}
	}
	cout<<dp[H-1][W-1]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
    int n, q, l, r;
    string str;
    int ctr[N] = {};
    cin >> n >> q >> str;

    FOR(i, 1, n)
    {
        ctr[i] = ctr[i - 1];
        if (str[i - 1] == 'A' && str[i] == 'C')
            ctr[i]++;
    }

    FOR(i, 0, q)
    {
        cin >> l >> r;
        cout << ctr[r-1] - ctr[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

//Global Variable
int n; // the size of target array
int q; // the number of querys
int* D;// the minimum value array.
int* lazy;
int x;
int i; // the variable for for loop. just lazy.
//End of Global Variable



// Function prototype Area
void __get_init_value(void);
int __min(int a, int b);
void initRMQ( int n_);
void update(int a, int b);
void __update(int a, int b, int k, int l, int r);
int find(int a);
void __find(int k);
int query(int a , int b, int k, int l, int r);

void lazy_evaluate(int k);
// End of Funtion prototype Area


int main(int argc, char* argv[]){

	__get_init_value();
	//printf("init n = %d\n",n);
	initRMQ(n);
	//printf("after initRMQ n = %d\n",n);


	int com;
	int s;
	int t;
	//int x;
	int y;// i in question
	int ans;
	while(q>0){
		scanf("%d",&com);
		if(com){
			scanf("%d",&y);
			ans = find(y);
			printf("%d\n",ans);
		}else{
			scanf("%d %d %d",&s, &t, &x);
			update(s,t);
		}	
		q--;
	}

	return 0;
}

int __min(int a, int b){
	if(a > b){
	return b;
	}else{
	return a;
	}
}

void __get_init_value(void){

	scanf("%d %d", &n, &q);
	return;
}//end of get init value;

void initRMQ(int n_){
	// n_ is used to preserved original n;
	// after this function, n is not the total item number anymore.

	n = 1;
	while(n < n_){
		n *= 2;
	}
	
	D = malloc(sizeof(int)* (2*n-1));
	lazy = malloc(sizeof(int)* (2*n-1));
	if(D == NULL){
		printf("Init Array Failed, no memory or size is wrong\n");
		return;
	}

	for(i = 0; i< 2*n-1 ; i++){
		D[i] = INT_MAX;
		lazy[i] = INT_MAX;
	}
	return;
}// end of initRMQ;


void update(int a , int b){
	__update(a, b+1, 0, 0, n);
}// end of update;

void __update(int a, int b, int k , int l, int r){
	//printf("qurey a=%d b=%d k=%d l=%d r=%d\n",a,b,k,l,r);
	//
	if(k >= 2*n-1){return;}

	lazy_evaluate(k);

	if(r <= a || b <= l){
		return;
	}
	if(a <= l && r <= b){
		D[k] = x;
		if (l == r){
			return;
		}else{	
			if(k < n-1){
				lazy[k*2+1] = x;
				lazy[k*2+2] = x;
			}
			return;
		}
	}
	//printf("(L+R)/2 = %d\n",(l+r)/2);
	//printf("vl, l=%d\n",l);
	__update(a, b, k*2+1, l , (l+r)/2);
	//printf("vr, r=%d\n",r);
	__update(a, b, k*2+2, (l+r)/2, r);
	D[k] =  __min(D[k*2+1],D[k*2+2] );

}


int find(int a){
	//printf("findMin n = %d\n",n);
	a += n - 1;
	__find(a);
	return D[a];
	//return query( a, b+1, 0, 0, n);
}// end of findMin;

void __find(int k){
	if(k > 0){
		__find((k-1)/2);
	}
	lazy_evaluate(k);

}

int query(int a, int b, int k , int l , int r){
	//printf("qurey a=%d b=%d k=%d l=%d r=%d\n",a,b,k,l,r);
	if(r <= a || b <= l){
		return INT_MAX;
	}
	if(a <= l && r <= b){
		return D[k];
	}
	//printf("(L+R)/2 = %d\n",(l+r)/2);
	//printf("vl, l=%d\n",l);
	int vl = query(a, b, k*2+1, l , (l+r)/2);
	//printf("vr, r=%d\n",r);
	int vr = query(a, b, k*2+2, (l+r)/2, r);
	return __min(vl, vr);
}//end of query

void lazy_evaluate(int k){
	if( lazy[k] == INT_MAX){
		return;
	}
	D[k] = lazy[k];
	if(k < n-1){
		lazy[2*k +1] = lazy[k];
		lazy[2*k +2] = lazy[k];
	}
	lazy[k] = INT_MAX;
}



Measured memory_bytes: 3820
#include<stdio.h>

int main (void){
    int a,b;



    while(scanf("%d%d",&a,&b)){
        if(a==0)break;
        int dp[32][32]={{0}};
        dp[1][1]=1;
        int n;
        int keep_out[32][32]={{0}};
        int i,j;
        int fake_x,fake_y;
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d%d",&fake_x,&fake_y);
            keep_out[fake_y][fake_x]=1;
        }

        for(i=1;i<=b;i++){
            for(j=1;j<=a;j++){
                if(keep_out[i][j+1]==0)dp[i][j+1]+=dp[i][j];
                else dp[i][j+1]=0;
                if(keep_out[i+1][j]==0)dp[i+1][j]+=dp[i][j];
                else dp[i+1][j]=0;
            }
        }
        printf("%d\n",dp[b][a]);
    }

    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long;
using ld=long double;
 
 
int main(){
   vector<int> a(5);
   for(int i=0;i<5;i++)
   cin>>a[i];
   int ans=1000000000;
   do{
       int c=0;
       for(int i=0;i<5;i++){
           c+=a[i];
           if(i==4)
           {ans=min(c,ans);
           break;}
           else if(c%10!=0)
           c+=(10-c%10);
       }
   }while(next_permutation(a.begin(),a.end()));
   cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register int
using namespace std;
bitset<4000010>s;
int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main(){
	int n=read(),sum=0; s[0]=1;
	for (ri i=1,x;i<=n;i++){
		x=read();
		sum+=x;
		s|=(s<<x);
	}
	for (ri i=(sum+1)/2;i<=sum;i++)if(s[i])return printf("%d\n",i),0;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    if(n <= 9){
        cout << n;
    }else if(9 < n && n<= 99){
        cout << 9;
    }else if(99 < n && n <=999){
        cout << 9 + (n - 100 + 1);
    }else if(999 < n&& n <= 9999){
        cout << 999 - 100 + 1 + 9;
    }else if(9999 < n && n <= 99999){
        cout << 9 + 999 - 100 + 1 + (n - 10000 + 1);
    }else{
        cout << 9 + 999 - 100 + 1 + 99999 - 10000 + 1;
    }
}


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

#define int long long
typedef pair<int, int> P;
const int INF = 1e9;

int N, M;
vector<int> p;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;

  int bit = 0;
  for ( int i = 0; i < N; i++ ) {
    int b;
    cin >> b;
    bit |= (b<<i);    
  }

  p = vector<int>(M);
  for ( int i = 0; i < M; i++ ) {
    cin >> p[i];    
  }

  vector<bool> used(1<<N, false);
  priority_queue<P, vector<P>, greater<P> > Q;
  Q.push({0, bit});

  while ( !Q.empty() ) {
    P e = Q.top(); Q.pop();
    int c = e.first, b = e.second;    

    vector<int> q;
    int cnt = 1;
    bool pre = b&1;  
    for ( int i = 1; i < N; i++ ) {
      if ( pre != (bool)(b&(1<<i)) ) {
	q.emplace_back(cnt);
	pre = !pre;
	cnt = 1;      
      } else {
	cnt++;      
      }
    }
    q.emplace_back(cnt);

    if ( q == p ) {
      cout << c << endl;
      return 0;
    }

    if ( used[b] ) continue;
    used[b] = true;

    for ( int i = 0; i < N-1; i++ ) {
      int nxt = b;
      nxt &= ~(1<<i);
      nxt &= ~(1<<(i+1));
      if ( b & (1<<i) ) nxt |= (1<<(i+1));
      if ( b & (1<<(i+1)) ) nxt |= (1<<i);
      Q.push(P(c+1, nxt));      
    }
  }
  
  return 0;
}



Measured memory_bytes: 3340
using System;

namespace abc059A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            Console.WriteLine(str[0].Substring(0, 1).ToUpper() + str[1].Substring(0, 1).ToUpper() + str[2].Substring(0, 1).ToUpper());
        }
    }
}


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

int n;
ll dp[10][10];
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        dp[s[0] - '0'][s[s.size() - 1] - '0']++;
    }
    
    ll ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = i; j <= 9; j++) {
            if (i != j) ans += 2 * (dp[i][j] * dp[j][i]);
            else ans += (dp[i][j] * dp[j][i]);
        }
    }
    cout << ans;
}   



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll dp[110000][13];

int main(){
  ll A[110000],sum=0,M[110000];
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>A[i];
    sum+=A[i];
  } 
  
  for(int i=2;i<N;i+=2){
    sum-=A[i]*2;
  }
  M[1]=sum;
  for(int i=2;i<=N;i++){
    M[i]=2*A[i-1]-M[i-1];
  }
  cout<<M[1];
  for(int i=2;i<=N;i++){
    cout<<" "<<M[i];
  }
  cout<<endl;
}


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

class UF{
public:
	vector<int>go;
	UF(int in){go.res(in);for(int i=0;i<in;i++){go[i]=i;}}
	int find_uf(int a){
		if(go[a]==a){return a;}
		return go[a]=find_uf(go[a]);
	}
	void uni_uf(int a,int b){go[find_uf(a)]=find_uf(b);}
};
int main(void){
	//I like this problem
	int n,H,W,i,j;cin>>n>>H>>W;
	llint ans=0;
	UF aa(H+W+1);
	vector<tuple<int,int,int>>card(n);
	for(i=0;i<n;i++){
		int r,c,a;cin>>r>>c>>a;
		c+=H;
		card[i]=mt(a,r,c);
	}
	SO(card);REV(card);
	for(auto it:card){
		int a,r,c;tie(a,r,c)=it;
		int rf=aa.find_uf(r),cf=aa.find_uf(c),zf=aa.find_uf(0);
		if(rf==zf&&cf==zf){continue;}
		ans+=a;
		if(rf!=cf){aa.uni_uf(r,c);}
		else{aa.uni_uf(r,0);}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
S = list(input())
A = int(''.join(S[0:2]))
B = int(''.join(S[2:4]))
if  B > 0 and B <= 12 and (A == 0 or A > 12):
    print('YYMM')
elif A > 0 and A <= 12 and (B == 0 or B > 12):
    print('MMYY')
elif A > 0 and A <= 12 and B > 0 and B <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];
int main(){
	ll k,n;
	cin>>k>>n;

	forn(i,n) cin>>a[i];
	if(n==2){
		cout<<min(abs(a[0]-a[1]),k-abs(a[0]-a[1]));
		return 0;
	}
	ll mi=1e6;
	for(ll i=1;i<n;i++){
		mi=min(mi,k-a[i]+a[i-1]);
		//cout<<mi<<" ";
	}
	mi=min(mi,a[n-1]-a[0]);
	cout<<mi;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;
int64_t dp[55][5005];
int main() {
  int N,A;
  cin>>N>>A;
  vector<int>x(N);
  for(int i=0;i<N;i++){
    cin>>x[i];
    x[i]-=A;
  }
  for(int i=0;i<55;i++){
    for(int j=0;j<5000;j++){
        dp[i][j]=0;
    }
  }


  //
  dp[0][2505]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<5005;j++){
        if(dp[i][j]==0){continue;}
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j+x[i]]+=dp[i][j];
    }
  }
  
  cout<<dp[N][2505]-1<<endl;
  return 0;  
}

Measured memory_bytes: 5768
unittest
{
	assert( [ "3 7", "1 6 3" ].solve == 14 );
	assert( [ "4 9", "7 4 0 3" ].solve == 46 );
	assert( [ "1 0", "1000000000000" ].solve == 1000000000000 );
	
	assert( [ "3 6", "1 2 4" ].solve == 13 );		// 追加ケース
	assert( [ "3 5", "1 2 4" ].solve == 12 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	// asの各bitが立っている数を集計
	auto ds = new long[ 40 ];
	foreach( i, a; as )
	{
		foreach( j, ref d; ds )
		{
			if( a & ( 1L << j ) ) d++;
		}
	}
	
	// dp[ 右からi桁目 ][ k未満フラグ ] = f(x)
	auto dp = new long[][]( 1 + ds.length, 2 );
	foreach_reverse( i, d; ds )
	{
		auto b = 1L << i;
		auto kb = k & b;
		auto va = b * ( as.length.signed - d );		// この桁を1にしたときのf(x)増加量
		auto vb = b * d;							// この桁を0にしたときのf(x)増加量
		
		// k同値 -> k同値
		if( kb ) dp[ i ][ 0 ] = max( dp[ i ][ 0 ], dp[ i + 1 ][ 0 ] + va );
		else     dp[ i ][ 0 ] = max( dp[ i ][ 0 ], dp[ i + 1 ][ 0 ] + vb );
		
		// k同値 -> k未満
		if( kb ) dp[ i ][ 1 ] = max( dp[ i ][ 1 ], dp[ i + 1 ][ 0 ] + vb );
		
		// k未満 -> k未満
		if( 0 < dp[ i + 1 ][ 1 ] ) dp[ i ][ 1 ] = max( dp[ i ][ 1 ], dp[ i + 1 ][ 1 ] + max( va, vb ) );
	}
	return dp[ 0 ].reduce!max;
}


Measured memory_bytes: 9492
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int X;cin >> X;
    switch(X){
        case 7:
        case 5:
        case 3:
            cout << "YES" << endl;
            break;
        default:
            cout << "NO" << endl;
            break;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        int s = sc.nextInt();

        int count = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int l = s - (i + j);
                if (l >= 0 && l <= k) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}

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

int main(){
    ll n,m;cin>>n>>m;//cin>>n,mにしない
    vl x(m);rep(i,m)cin>>x.at(i);

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

    vl d(m-1);rep(i,m-1)d.at(i)=x.at(i+1)-x.at(i);

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

    ll sum=0;

    rep(i,m-n)sum+=d.at(i);
 
    cout<<sum<<endl;
}
   

Measured memory_bytes: 1792
let rec floor_sqrt acc acc_x_2_x_r sq_acc_minus_z r sq_r =
  if r = 0 then acc
  else
    let sq_acc_minus_z' = sq_acc_minus_z + acc_x_2_x_r + sq_r in
    ( if sq_acc_minus_z' <= 0 then
        floor_sqrt (acc + r) ((acc_x_2_x_r lsr 1) + sq_r) sq_acc_minus_z'
      else
        floor_sqrt acc (acc_x_2_x_r lsr 1) sq_acc_minus_z) (r lsr 1) (sq_r lsr 2)
let floor_sqrt z = floor_sqrt 0 0 (~-z) (1 lsl 30) (1 lsl 60)

let () = Scanf.scanf "%d %d\n" @@ fun n d ->
  let xss =
    Array.init n @@ fun _ ->
      Array.init d @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  Printf.printf "%d\n" @@ 
  Array.fold_left (Array.fold_left ( + )) 0 @@
  Array.init n @@ fun i ->
    Array.init i @@ fun j ->
      let sqd = 
        Array.fold_left ( + ) 0 @@ 
        Array.init d @@ fun k ->
          (xss.(i).(k) - xss.(j).(k)) * (xss.(i).(k) - xss.(j).(k)) in
      let d = floor_sqrt sqd in
      if d * d = sqd then 1 else 0



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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> T(N - K + 1);
    rep(i, N) {
        cin >> A[i];
        if (i > K - 1) {
            if (A[i - K] < A[i]) {
                puts("Yes");
            } else {
                puts("No");
            }
        }
    }

    return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int mod = 1000000007;
const int FacN = 200200;//使わないなら0

constexpr int power(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)res *= a;
        a *= a;
        res %= mod;
        a %= mod;
        b /= 2;
    }
    return res;
}

constexpr int inv(int x) {
    return power(x, mod - 2);
}

const struct Fac {
    int val[FacN];

    constexpr Fac() : val() {
        if (FacN == 0)return;
        val[0] = 1;
        for (int i = 1; i < FacN; ++i) val[i] = val[i - 1] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac;

const struct FacInv {
    int val[FacN];

    constexpr FacInv() : val() {
        if (FacN == 0)return;
        val[FacN - 1] = 1;
        for (int i = 1; i < FacN; ++i)val[FacN - 1] = val[FacN - 1] * i % mod;
        val[FacN - 1] = inv(val[FacN - 1]);
        for (int i = FacN - 1; i >= 1; --i)val[i - 1] = val[i] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac_inv;

int Perm(int n, int r) {
    if (n < r) return 0;
    return fac[n] * fac_inv[n - r] % mod;
}

int Comb(int n, int r) {
    return Perm(n, r) * fac_inv[r] % mod;
}
//mod,Factorial書き換え
//要検証

int N, M, K;


signed main() {
    cin >> N >> M >> K;
    int ans = 0;
    //X
    for (int d = 1; d <= M - 1; ++d) {
        ans += d * (M - d) * N * N % mod * Comb(N * M - 2, K - 2);
        ans %= mod;
    }
    //Y
    for (int d = 1; d <= N - 1; ++d) {
        ans += d * (N - d) * M * M % mod * Comb(N * M - 2, K - 2);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
f = int(S[:2])
l = int(S[2:4])
if (1 <= f and f <= 12 and (l > 12 or l == 0)):
    print('MMYY')
elif ((f > 12 or f == 0) and 1 <= l and l <= 12):
    print('YYMM')
elif ((f > 12 or f == 0) and (l == 0 or l > 12)):
    print('NA')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(cin>>s){
    s+="*";
    string ans;
    char c[9][10]=
      {{'\'',',','.','!','?'},
       {'a','b','c','A','B','C',},
       {'d','e','f','D','E','F',},
       {'g','h','i','G','H','I',},
       {'j','k','l','J','K','L',},
       {'m','n','o','M','N','O',},
       {'p','q','r','s','P','Q','R','S',},
       {'t','u','v','T','U','V',},
       {'w','x','y','z','W','X','Y','Z',}};
    int si[]={5,6,6,6,6,6,8,6,8,};
    char a;
    int i,j,k;
    for(i=0;i<s.size();i++){
      a=s[i];k=0;
      if(s[i]=='*') break;
      while(s[i]==s[i+1]) {
	i++;k++;
      }
      if(a=='0'){
	for(j=0;j<k;j++) ans+=' ';
	continue;
      }
      ans+=c[a-'1'][k%s[a-'1']];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cmath>
#define mod 1000000007
using namespace std;
typedef long long int LLI;
LLI solve(LLI & a, LLI & b)
{
	LLI ans = 1, smaller = a > b ? b : a, bigger = a > b ? a : b;
	for(LLI i = 1; i <= smaller; i++)
	{
		ans *= (i*i)%mod;
		ans %= mod;
	}
	if( a == b )
		return ( 2 * ans ) % mod;
	return ( bigger * ans ) % mod;
}

int main()
{
	LLI a, b;
	cin >> a >> b;
    if( abs( a - b ) > 1 )
    	cout << 0;
    else
		cout << solve(a,b);
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  rep(i,m){
    cin >> p[i].first >> p[i].second;
  }
  sort(all(p));
  vector<pair<int,int>> r(n);
  rep(i,n){
    r[i]={i,i};
  }
  rep(i,m){
    int k = p[i].second-1;
    r[k]=r[k+1]={r[k].first,r[k+1].second};
  }
  rep(i,n){
    cout << r[i].second-r[i].first+1;
    if(i<n-1) cout << " ";
    else cout << endl;
  }
  return 0;
}



Measured memory_bytes: 5204
#include<bits/stdc++.h>
#define N (1<<19)
#define Q 924844033
using namespace std;
inline int qp(int a,int p){
	int r=1;
	while(p){
		if(p&1) r=1LL*a*r%Q;
		a=1LL*a*a%Q;
		p>>=1;
	}
	return r;
}
inline int inv(int x){
	return qp(x,Q-2);
}
int ans[N],cnt[N],sz[N],n,fac[N],ifac[N],fa[N],fb[N],fc[N];
int rt[30],irt[30];
vector<int> g[N];
int build_sz(int u,int p){
	sz[u]=1;
	int tmp=n-1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(v==p) continue;
		sz[u]+=build_sz(v,u);
		cnt[sz[v]]--;
		if(cnt[sz[v]]<0) cnt[sz[v]]+=Q;
		tmp-=sz[v];
	}
	cnt[tmp]--;
	if(cnt[tmp]<0) cnt[tmp]+=Q;
	return sz[u];
}
void FFT(int x[], bool pos){
    for (int i=1, j=0; i<N; ++i){
        for (int k=N>>1; !((j^=k)&k); k>>=1) ;
        if (i>j) swap(x[i], x[j]);
    }
    for (int k=2; k<=N; k<<=1){
        long long om = pos?rt[__lg(k)]:irt[__lg(k)];
        for (int j=0; j<N; j+=k){
            long long mul = 1;
            for (int i=j; i<j+k/2; i++){
				int a = x[i], b = 1LL*x[i+k/2]*mul%Q;
                x[i]     = (a + b)%Q;
                x[i+k/2] = (a + Q - b)%Q;
                mul = mul*om%Q;
            }
        }
    }
}
void mul(int a[],int b[],int c[]){
	FFT(a,true);
	FFT(b,true);
	for(int i=0;i<N;i++){
		c[i]=1LL*a[i]*b[i]%Q;
	}
	FFT(c,false);
	int iN=inv(N);
	for(int i=0;i<N;i++){
		c[i]=1LL*iN*c[i]%Q;
	}
}
int main(){
	int a,b;
	scanf("%d",&n);
	fac[0]=ifac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%Q;
		ifac[i]=1LL*ifac[i-1]*inv(i)%Q;
	}
	bool flag=true;
	for(int gn=2;flag;gn++){
		int tmp=qp(gn,441);
		flag=false;
		for(int j=0;j<21;j++){
			rt[21-j]=tmp;
			if(tmp==1){
				flag=true;
				break;
			}
			tmp=1LL*tmp*tmp%Q;
		}
	}
	for(int j=1;j<=21;j++) irt[j]=inv(rt[j]);
	cnt[n]=n;
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	build_sz(1,0);
	for(int i=0;i<=n;i++){
		fa[n-i]=1LL*cnt[i]*fac[i]%Q;
	}
	for(int i=0;i<=n;i++){
		fb[i]=ifac[i];
	}
	mul(fa,fb,fc);
	for(int i=1;i<=n;i++){
		printf("%d\n",1LL*fc[n-i]*ifac[i]%Q);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define sz(x) (ll)(x).size()
#define mpa make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define nl "\n"

const int mod=1e7;
const int mxN=1e5;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	if(x==1) {
		cout << 0;
	}else {
		cout << 1;
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <bitset>

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

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

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

template<class T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<class T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<class T> T min(std::vector<T> a) { return *std::min_element(all(a)); }
template<class T> T max(std::vector<T> a) { return *std::max_element(all(a)); }
template<class T> T sum(std::vector<T> a) {
    return std::accumulate(all(a), (T)0);
}

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

constexpr ld PI = 3.141592653589793L;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e12;

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

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
ll ctz(ll n) { ll ans = 0; for (; ~n & 1; n >>= 1) ans++; return ans; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}
str zfill(str s, ll n) { return str(n - s.length(), '0') + s; }
ll to_ll(char c) { return (ll)c - '0'; }
ll to_ll(str s) {
    ll ans = 0;
    for (ll i = 0; i < s.length(); i++)
        ans = 10 * ans + to_ll(s[i]);
    return ans;
}

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

void Solve();

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

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

    Solve();
}

void Solve() {
    ll n; std::cin >> n;
    vll a(n);
    for (ll i = 0; i < n; i++)
        std::cin >> a[i];

    ll q; std::cin >> q;
    for (ll i = 0; i < q; i++) {
        ll m; std::cin >> m;
        vvb dp(n + 1, vb(m + 1, false));
        dp[0][0] = true;
        for (ll j = 0; j < n; j++) for (ll k = 0; k < m + 1; k++) {
            if (!dp[j][k]) continue;
            dp[j + 1][k] = true;
            if (k + a[j] <= m)
                dp[j + 1][k + a[j]] = true;
        }
        std::cout << (dp[n][m] ? "yes" : "no") << '\n';
    }
}



Measured memory_bytes: 3216
h,w = map(int, input().split())

S = []

dxy_list = [(-1, 0), (0, 1), (1, 0), (0, -1)]

for i in range(h):
    S.append(list(input()))


for i in range(h):
    for j in range(w):

        if (S[i][j] == '.'): continue
            
        has_sharp = False

        for dxy in dxy_list:
            ni = i + dxy[0]
            nj = j + dxy[1]

            if (ni < 0 or h <= ni): continue
            if (nj < 0 or w <= nj): continue

            if (S[ni][nj] == '#'):
                has_sharp = True
                break

        if (not has_sharp):
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main(){

  ll Lucas[100];

  Lucas[0] = 2;
  Lucas[1] = 1;
  for(int i=2;i<100;i++){
    Lucas[i] = Lucas[i-1] + Lucas[i-2];
  }

  int n;
  cin >> n;
  cout << Lucas[n] <<endl;
  
  return 0;
}













Measured memory_bytes: 256