akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}

func Solve() {
  HW := NextIntVec()
  H, W := HW[0], HW[1]
  B := make([][]int, H)
  for i := range B {
    B[i] = make([]int, W)
    C := NextLine()
    for j, c := range C {
      B[i][j] = int(c) - int('a')
    }
  }
  cnt := 0
  DP := make([][]int, H + 1)
  for i := range DP {
    DP[i] = make([]int, H + 1)
  }
  Cost := make([][]int, H + 1)
  for i := range Cost {
    Cost[i] = make([]int, H + 1)
  }
  for w := 1; w < W; w++ {
    for i := range DP {
      for j := range DP[i] {
        DP[i][j] = 0
      }
    }
    for i := range Cost {
      for j := range Cost[i] {
        Cost[i][j] = 0
      }
    }
    for i := 0; i < H; i++ {
      for j := 0; j < H; j++ {
        if B[H - i - 1][w - 1] == B[H - j - 1][w] {
          Cost[i][j]++
        }
      }
    }
    for i := H; 0 < i; i-- {
      for j := H; 0 < j; j-- {
        Cost[i - 1][j - 1] += Cost[i][j]
      }
    }
    for i := 0; i < H; i++ {
      DP[i + 1][0] += DP[i][0] + Cost[i][0]
      DP[0][i + 1] += DP[0][i] + Cost[0][i]
    }
    for l := 0; l < H; l++ {
      for r := 0; r < H; r++ {
        DP[l + 1][r + 1] = MinInt(DP[l][r + 1] + Cost[l][r + 1], DP[l + 1][r] + Cost[l + 1][r])
      }
    }
    cnt += DP[H][H]
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
    
    int n,k,i,j;
    cin >> n >> k;
    int arr[n];bool dp[k+1] = {false};
    for(i=0;i<n;i++){
    cin >> arr[i];
    dp[arr[i]]=true;
    }
    sort(arr,arr+n);
    //dp[0]=true;
    
    for(i=arr[0]+1;i<=k;i++){
        bool dev = false;
        if(dp[i])
        continue;
        for(j=0;j<n;j++){
            if(i-arr[j] <= 0)
             break;
             else if(! dp[i-arr[j]]){
                 dev = true;
                 break;
                 
             }
        }
        dp[i] = dev;
    }
    /*for(i=0;i<=k;i++)
    cout << i << " :: " << dp[i] << "\n";*/
    if(dp[k])
    cout << "First";
    else
    cout << "Second";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
int main()
{
    ll i,j,k,l,m,n,ans=INT_MAX;
    cin>>n>>m;
 if(abs(n-m)>=2019)return cout<<0<<endl,0;
 for(i=n;i<=m-1;i++)
 {
     for(j=i+1;j<=m;j++)
     {
         ll p = i%2019;
         ll q = j%2019;
         ans = min(ans,(p*q)%2019);
     }
 }
 cout<<ans<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];
    sort(ALL(L));

    ll ans = 0;
    for (int i = 0;i < N - 1; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            ll a = L[i], b = L[j];
            auto pos = lower_bound(ALL(L), a + b);
            int index = distance(L.begin(), pos);
            ans += index - j - 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
typedef long long ll;
const int maxn=1e5+233;

int n,m,k;
int main()
{
	string s;
	cin>>n>>k;
	cin>>s;
	if(s[k-1]>='A')s[k-1]-=('A'-'a');
	cout<<s<<endl;
    return 0;
}




Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    put!(
        ((sc.chars()[0] as u8) + 1) as char
    );
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int N=1000;

int LCS(string x,string y){
	int c[N+1][N+1],LCSlen=0;
	int m=x.size();
	int n=y.size();
	x=' '+x;
	y=' '+y;
	for(int i=1;i<=m;i++) c[i][0]=0;
	for(int j=1;j<=n;j++) c[0][j]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i]==y[j])
			c[i][j]=c[i-1][j-1]+1;
			else
			c[i][j]=max(c[i][j-1],c[i-1][j]);
			LCSlen=max(LCSlen,c[i][j]);
		}
	}
	return LCSlen;
}

int main(){
	string x,y;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>x;
		cin>>y;
		printf("%d\n",LCS(x,y));
	}
}

Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int Q;
  cin >> Q;

  ll bsum = 0;
  multiset<ll> l, r;
  ll lsum = 0, rsum = 0;
  rep(i,Q){
    int x;
    cin >> x;
    if(x == 1){
      ll a, b;
      cin >> a >> b;

      bsum += b;
      l.insert(a);
      lsum += a;
      if(l.size()-r.size()>1){
        auto itr = --l.end();
        ll x = *itr;
        l.erase(itr);
        lsum -= x;
        r.insert(x);
        rsum += x;
      }
      while(true){
        if(r.size() == 0) break;
        auto itrl = --l.end();
        auto itrr = r.begin();
        ll x = *itrl;
        ll y = *itrr;
        if(x <= y) break;
        l.erase(itrl);
        lsum -= x;
        r.erase(itrr);
        rsum -= y;
        l.insert(y);
        lsum += y;
        r.insert(x);
        rsum += x;
      }
    }else{
      if(l.size() == 0){
        cout << 0 << endl;
      }else{
        auto itr = --l.end();
        ll x = *itr;

        ll N = l.size();
        ll M = r.size();
        //cout << N << " " << M << " " << x << endl;
        
        cout << x << " " << bsum + N * x - lsum + rsum - M * x << endl;
      }
    }
  }
    
  return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e15;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m, k; cin >> n >> m >> k;
    V<> a(n), b(m);
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];
    V<> as(n+1), bs(m);
  	as[0] = 0;
    bool af = false, bf = false;
    REP(i,n){
        if(af){
            as[i+1] = k + 1;
            continue;
        }
        if(!i)as[i+1] = a[i];
        else as[i+1] = as[i] + a[i];
        if(as[i+1] > k){
            as[i+1] = k + 1;
            af = true;
        }
    }
    REP(i,m){
        if(bf){
            bs[i] = k + 1;
            continue;
        }
        if(!i)bs[i] = b[i];
        else bs[i] = min(bs[i-1] +b[i],INF);
        if(bs[i] > k){
            bs[i] = k + 1;
            bf = true;
        }
    }
    ll res = 0;
    REP(i,n+1){
        ll pres = i;
        ll ts = as[i];
        if(ts > k) break;
        pres += upper_bound(all(bs), k-as[i]) - bs.begin();
        chmax(res,pres);
    }
    cout << res << endl;
}

Measured memory_bytes: 9512
#include<bits/stdc++.h>
#define li long long
#define mod 998244353
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
int n,k;
li c[5000][5000],er[100000];
void init(int N){
	for(int i=0;i<=N;++i) c[i][0]=1;
	for(int i=1;i<=N;++i){
		for(int j=1;j<=i;++j){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	}
	er[0]=1;
	for(int i=1;i<=N;++i) er[i]=1ll*er[i-1]*2%mod;
}
li calc(int x,int y,int z){
	li res=0;if(y<0) return 0;//
	for(int i=0;i<=z&&i<=x;++i)
		if(i+y-1>=0)
			(res+=1ll*c[x][i]*er[i]%mod*c[z+y-1][i+y-1]%mod)%=mod;
	return res;
}
int main(){
	k=read(),n=read();
	init(4000);
	for(int i=2;i<=2*k;++i){
		int x0=0;
		for(int j=1;j<=k;++j)
			if(1<=i-j&&i-j<=k) ++x0;
		if(i%2==1) printf("%lld\n",calc(x0/2,k-x0,n));
		else printf("%lld\n",(calc((x0-1)/2,k-x0,n)+calc((x0-1)/2,k-x0,n-1))%mod);
	}
	return 0;
}

Measured memory_bytes: 156032
char s[4005],t[4005];u[4005],m,i,j,c,d;main(n){for(;~scanf("%s%s",d=s,t+1);i=m=!printf("%d\n",m)){for(n=strlen(s);d;d=t[++i])for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<iii> viii;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll c = 0, i = 0, j, k, bca = 0, r = 0, t = 0, as, bcs, ans;
	bool is = false;
	string s;
	viii seg;
	cin >> s;
	while (i + 2 < s.size()) {
		if (s[i] == 'A' and s[i + 1] == 'B' and  s[i + 2] == 'C') {
			if (!t)
				r = i;
			t++;
			i += 3;
		} else if (s[i] == 'B' and s[i + 1] == 'C' and  s[i + 2] == 'A') {
			bca++;
			if (!t)
				r = i;
			t++;
			i += 3;
		} else {
			if (t)
				seg.push_back(iii(t, ii(r, i - 1)));
			t = 0;
			i++;
		}
	}
	if (t)
		seg.push_back(iii(t, ii(r, i - 1)));
	k = 0; ans = 0;
	for (i = 0; i < seg.size(); i++) {
		as = 0, bcs = 0;
		j = seg[i].second.first - 1;
		while ((i == 0 and j >= 0) or (i > 0 and j > seg[i - 1].second.second)) {
			if (s[j] == 'A')
				as++;
			else
				break;
			j--;
		}
		if (i > 0 and j < k)
			as += ans;

		j = seg[i].second.second + 1;
		while ((i == seg.size() - 1 and j - 1 < s.size()) or (i < seg.size() - 1 and j < seg[i + 1].second.first)) {
			if (s[j] == 'B' and s[j + 1] == 'C') 
				bcs++;
			else
				break;
			j += 2;
		}
		k = j;
		ans = seg[i].first + as;
		t = seg[i].first + as + bcs;
		t = (t * (t + 1)) / 2;
		as = (as * (as + 1)) / 2;
		bcs = (bcs * (bcs + 1)) / 2;
		c += (t - as - bcs);
	}
	c -= bca;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
char s[MAXN];
int sum[MAXN];
void Solve() {
    read(N);
    scanf("%s",s + 1);
    for(int i = 1 ; i <= N ; ++i) {
	sum[i] = sum[i - 1];
	if(s[i] == '#') sum[i]++;
    }
    int ans = N;
    for(int i = 0 ; i <= N ; ++i) {
	ans = min(ans,sum[i] + N - i - (sum[N] - sum[i]));
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const ll mod=1e9+7;
const int maxn=2e5;
int n,m,q;
int a[maxn+5],b[maxn+5];
int main()
{

    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m>>q;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=1;i<=m;++i) cin>>b[i];
    int ans=0;
    int mi=a[1];
    for(int i=2;i<=n;++i) mi=min(mi,a[i]);
    ans=mi;
    mi=b[1];
    for(int i=2;i<=m;++i) mi=min(mi,b[i]);
    ans+=mi;
    while(q--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans=min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
ll n;
ll s;

ll f(ll b,ll n){
	if(n<b) return n;
	return f(b,n/b)+n%b;
}

void solve(){
	if(s==n) {cout<<n+1<<endl;return;}
	if(s>n) {cout<<-1<<endl;return;}
	//if(s==1) {cout<<n<<endl;return;}
	ll sp=sqrt(n)+1;
	repv(i,2,sp){
		if(f(i,n)==s){
			cout<<i<<endl;return;
		}
	}
	ll ans=1e18+1;
	for(ll i=1;i<sp;i++){
		ll b=(n-s)/i+1;
		if((n-s)%i==0&&f(b,n)==s){
			ans=min(b,ans);
		}
	}
	if(ans==1e18+1)
		cout<<-1<<endl;
	else cout<<ans<<endl;
}

int main(){
	cin>>n>>s;
	solve();
	return 0;
}


Measured memory_bytes: 384
s = str(input())

n = len(s)

if len(set(list(s))) == 1:
    print(n)
    exit()

def is_ok(x):
    for i in range(n-x, x-1):
        if s[i] != s[i+1]:
            return False
    else:
        return True

l = 1
r = n
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        l = c
    else:
        r = c
print(l)


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string AM = "AMBIGUOUS";

int main() {
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));

    bool am = false, bm = false;
    if (1 <= a and a <= 12) am = true;
    if (1 <= b and b <= 12) bm = true;

    if (am and bm) {
        cout << AM << endl;
    }
    else if (am and !bm) {
        cout << "MMYY" << endl;
    }
    else if (!am and bm) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
a = [0] * n
for i in range(1, n):
    a[i] = a[i - 1]
    if (s[i - 1:i+1] == "AC"):
        a[i] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(a[r-1]-a[l-1])


Measured memory_bytes: 50904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll l,r,ans=1000000000;
    cin >> l >> r;
    if(r-l>=2020){
        cout << 0 << "\n";
        return 0;
    }else{
        for(ll i=l;i<r;++i){
            for(ll j=l+1;j<=r;++j){
                ll x=(i*j)%2019;
                ans=min(ans,x);
            }
        }
        cout << ans << "\n";
        return 0;
    }
}   

Measured memory_bytes: 3644
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e3+4;
const int H = 1e4+4;

int n;
int h;
int A[N];
int B[N];
int mem[N][H];

int go(int idx , int curH){
    if(curH <= 0)
        return 0;
    if(idx == n+1)
        return 1e9;
    if(~mem[idx][curH])
        return mem[idx][curH];
    int c1 = go(idx + 1 , curH);
    int c2 = go(idx , curH - A[idx]) + B[idx];
    return mem[idx][curH] = min(c1 , c2);
}

int main(){
    scanf("%d%d" , &h , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d%d" , &A[i] , &B[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(1 , h));
}


Measured memory_bytes: 39936
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    h_taka, a_taka, h_ao, a_ao = MI()

    def attack(h, a):
        return h - a

    turn_taka = 1
    while h_taka > 0 and h_ao > 0:
        if turn_taka:
            h_ao = attack(h_ao, a_taka)
        else:
            h_taka = attack(h_taka, a_ao)

        turn_taka = 1 - turn_taka
        # print(h_taka, h_ao, turn_taka)

    if turn_taka:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int mod = int(1e9) + 7;
const int DIM = 52;

struct Matrix {
  int a[DIM][DIM];
  int *operator [] (int r) { return a[r]; };

  Matrix(int x = 0) {
    memset(a, 0, sizeof a);
    if (x)
    {
		for(int i = 0; i < DIM; i++) a[i][i] = x;
	}
  }
} const I(1);

Matrix operator * (Matrix A, Matrix B) {
  const ll mod2 = ll(mod) * mod;
  Matrix C;
 for(int i = 0; i < DIM; i++)
 {
	 for(int j = 0; j < DIM; j++)
	 {
		ll w = 0;
		for(int k = 0; k < DIM; k++)
		{
			w += ll(A[i][k]) * B[k][j];
			if (w >= mod2) w -= mod2;
		}
    C[i][j] = w % mod;
	}
  }
  return C;
}

Matrix operator ^ (Matrix A, ll b) {
  Matrix R = I;
  for (; b > 0; b /= 2) {
    if (b % 2) R = R*A;
    A = A*A;
  }
  return R;
}

Matrix M;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; ll k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>M[i][j];
		}
	}
	M = M^k;
	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans+=M[i][j]; ans%=mod;
		}
	}
	ans%=mod; if(ans<0) ans+=mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt() 
    val a = (0 until n).map { readLong() }.sorted()
    val sheet = mutableMapOf<Long, Int>()
    a.forEach { k ->
        sheet[k] = if(sheet.contains(k)) sheet[k]!!+1 else 1
    }
    val count = sheet.values.toList().count { it % 2 == 1 }
    println(count)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
void solve(){
	cin >> n;
	int gcd = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(gcd == 0) gcd = a[i];
		else gcd = __gcd(gcd,a[i]);
	}
	cout << gcd << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int sosu(long X){
    for(int i=2;i*i<=X;i++){
        if(X%i==0)
        return 1;
    }
    return 0;
}
int main(void){
    // Your code here!
    long X;
    cin >> X;
    while(sosu(X)!=0)
    X++;
    
    cout << X << endl;
}


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

string S;

int main() {
    cin >> S;

    int left_A = 1.0e9;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A') {
            left_A = i;
            break;
        }
    }

    int right_Z = -1;
    for (int i = S.length() - 1; i >= 0; i--) {
        if (S[i] == 'Z') {
            right_Z = i;
            break;
        }
    }

    cout << right_Z - left_A + 1 << endl; 

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n,k;cin>>n>>k;
    int res=0;
    while(n>0){
        n/=k;
        res++;
    }
    cout<<res<<endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        ans += i;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


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

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

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

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

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

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

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

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")


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

	LL A,B,K;
	cin >> A >> B >> K;

	if(K <= A) {
		cout << (A-K) << ' ' << B << endl;
	}
	else if(K <= (A+B)){
		cout << "0 " << (B - (K-A)) << endl;
	}
	else {
		cout << "0 0\n";
	}

	return 0;
}


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++)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> a(n+1),b(n+1,0);
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=n;i>0;--i){
      int tot=0;
      for(int j=2*i;j<=n;j+=i){
          if(j%i==0)tot+=b[j];
      }
      if(tot%2!=a[i]%2)b[i]=1;
  }
  int k=0;
  rep(i,n+1)k+=b[i];
  cout<<k<<endl;
  for(int i=1;i<=n;i++)if(b[i]==1)cout<<i<<' ';
  cout<<endl;
  return 0;
  }


Measured memory_bytes: 2560
n = int(input())
a = []
b = []
c = []
for i in range(0, n):
	a.append(int(input()))

# print(n)
# print(a)

a.sort()
#print(a)
for j in range(0, 4):
	for k in range(0, 4):
		if (j != k):
			b.append(str(a[j]) + str(a[k]))

for k in b:
	c.append(int(k))

c.sort()
print(c[2])



Measured memory_bytes: 5928
/****************************************

			LostMartian

****************************************/
//#pragma GCC optimize("Ofast")  
//#pragma GCC target("avx,avx2,fma") 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t) {
		pn("Yes");
	}
	else {
		pn("No");
	}















	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}


Measured memory_bytes: 3808
import math

integrationEnemy = int(input())
sqrtCount = 0
harf = 10

while True:
    if harf == 1:
        sqrtCount += 1
        break
    elif harf == 0:
        break
    else:
        sqrtCount += 1

    if sqrtCount == 1:
        harf = math.floor(integrationEnemy / 2)
    else:
        harf = math.floor(harf / 2)

print(2**(sqrtCount)- 1)

Measured memory_bytes: 3060
def is_prime(n):
    if n==1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

s=[0]*100007
s[2]=1
t=[0]*100007
for i in range(1,100001,2):
    s[i]+=is_prime(i)
for i in range(1,100001,2):
    t[i]=(s[i]+s[(i+1)//2])//2
for i in range(1,100007):
    t[i]+=t[i-1]
for i in range(int(input())):
    l,r=map(int,input().split())
    print(t[r]-t[l-1])

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

using namespace std;

int x, y;
string s;

int main(void)
{
	cin >> x >> y;
	
	s = "0020101001010";
	if(s[x] == s[y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int get_ans(int n){
    int ans=1;
    if(n%2==0||n==1)ans=0;
    else{
        int co=0,t=3;
        vector<int> v;
        while(n>1){
            if(n%t==0){
                n/=t;
                co++;
            }  
            if(n%t!=0){
                t++;
                v.push_back(co);
                co=0;
            }
        }
        rep(i,v.size()){
            ans*=v[i]+1;
        }
    }
    return ans;
}
int main(){
    int n;cin>>n;
    int ans=0;
    FOR(i,1,n){
        if(get_ans(i)==8)ans++;
//        cout<<get_ans(i)<<endl;
    }
    cout<<ans<<endl;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n); for(int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end()); 
  reverse(a.begin(), a.end());
  
  int A = 0;
  int B = 0;
  
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) A += a.at(i);
    else B += a.at(i);
  }
  cout << A - B << endl;
}

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int m,d;cin>>m>>d;
	int cnt=0;
	for(int i=1;i<=m;i++){
		for(int j=11;j<=d;j++){
			int nn=j;
			if(to_string(nn).size()==2){
				int x=nn%10;
				nn/=10;
				int y=nn%10;
				if(x>=2&&y>=2&&x*y==i){
					cnt++;//cout<<i<<" "<<j<<endl;
				}
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,ans=0,pos=0;
	cin>>n;
	vector<lint>a(n);
	rep(i,n)cin>>a.at(i);
	while(a.size()!=pos){
		if(a.at(pos)!=pos+1-ans)ans++;
		pos++;
	}
	cout<<(ans!=pos?ans:-1)<<endl;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  long long N;
  cin >> N;
  vector<long long> B(N - 1);
  for (int i = 0; i < N - 1; i++)
    cin >> B[i];
  vector<long long> A(N);
  A[0] = B[0];
  A[N - 1] = B[N - 2];
  for (int i = 1; i < N - 1; i++)
  {
    A[i] = min(B[i], B[i - 1]);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans += A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# coding : utf-8
num = gets.to_i ; line = [0,0,0,0,0,0]
list = Array.new(num)
num.times do |i|
	list[i] = gets.to_i
end
num.times do |i|
	if list[i]<165.0
		line[0]+=1
	elsif list[i]<170.0
		line[1] += 1
	elsif list [i]<175.0
		line[2] += 1
	elsif list [i]<180.0
		line[3] += 1
	elsif list [i]<185.0
		line[4] += 1
	else 
		line[5] +=1
	end
end
6.times do |i|
	print i+1 , ":"
	line[i].times do 
		print "*"
	end
	print "\n"
end

Measured memory_bytes: 6124
# -*- coding: utf-8 -*-

import sys
from collections import Counter

N=input()
D=map(int, sys.stdin.readline().split())
max_D=max(D)

C=Counter(D)
if C[0]!=1:
    print 0
    quit()

mod=998244353
if D[0]!=0:
    print 0
    quit()
else:
    ans=1
    for i in range(2,max_D+1):
        ans*=pow(C[i-1],C[i],mod)
        ans%=mod

print ans%mod

Measured memory_bytes: 53808
#include <iostream>
using namespace std;
int main(void){
    int x, i=1, a[10000];
    while(cin>>x){
        if(x == 0){
            break;
        }
        a[i] = x;
        cout<<"Case "<<i<<": "<<a[i]<<"\n";
        i++;
    }
}


Measured memory_bytes: 3052
n,m,i,j,r[10000],v[10000],vn,d[5000];
main(){
	for(;scanf("%d",&n),n;){
		memset(r,0,sizeof(r));
		for(i=1;i<n;i++)
			r[i*i%n]=1;
		vn=0;
		for(i=0;i<n;i++)
			if(r[i])
				v[vn++]=i;
		memset(d,0,sizeof(d));
		for(i=0;i<vn;i++)
			for(j=0;j<vn;j++)
				if(i!=j){
					m=v[i]-v[j];
					if(m<0)
						m+=n;
					if(m>(n-1)/2)
						m=n-m;
					d[m]++;
				}
		for(i=1;i<=(n-1)/2;i++)
			printf("%d\n",d[i]);
	}
	exit(0);
}

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

int main() {
    int N,A,B,C;
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    for(int i=0; i<N; ++i) cin >> l[i];

    int res = 1001001001;
    for(int s = 0; s < (1 << 2*N); ++s) {
        int a = 0, b = 0, c = 0;
        int acnt = 0, bcnt = 0, ccnt = 0;
        for(int i=0; i<N; ++i) {
            if(((s >> 2*i) & 3) == 1) { a += l[i]; ++acnt; }
            if(((s >> 2*i) & 3) == 2) { b += l[i]; ++bcnt; }
            if(((s >> 2*i) & 3) == 3) { c += l[i]; ++ccnt; }
        }
        if(a > 0 && b > 0 && c > 0) {
            int tmp = abs(a - A) + abs(b - B) + abs(c - C);
            tmp += 10*(acnt + bcnt + ccnt - 3);
            res = min(res, tmp);
        }
    }
    cout << res << endl;
}

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

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a < 6) cout << 0 << endl;
  else if (a < 13) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,m;
    vector<vector<int> > c;
    int now=0;
    int temp;

    cin >> n >> m;

    c.resize(2);

    c[0].push_back(-1);
    c[1].push_back(-1);

    for(int i=1; i<=2*n; ++i) {
        c[0].push_back(i);
        c[1].push_back(i);
    }

    for(int i=0; i<m; ++i) {
        cin >> temp;
        if(temp==0) {
            for(int j=1; j<=n; ++j) {
                c[(now+1)%2][2*j-1]=c[now][j];
                c[(now+1)%2][2*j]=c[now][n+j];
            }
        } else {
            for(int j=1; j<=2*n-temp; ++j) {
                c[(now+1)%2][j]=c[now][temp+j];
            }
            for(int j=1; j<=temp; ++j) {
                c[(now+1)%2][2*n-temp+j]=c[now][j];
            }
        }
        now=(now+1)%2;
    }
    for(int i=1; i<=2*n; ++i) {
        cout << c[now][i] << endl;
    }
    return 0;
}

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

int main() {
    int k;
    cin >> k;
    int zero = 0, ichi = 0;
    for (int i = 1; i <= k; i += 2) ichi ++;
    for (int i = 2; i <= k; i += 2) zero ++;
    cout << zero * ichi << endl;
    return 0;
}


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

int main() {
    while(true) {
        stack<char> cc;
        char c;
        bool success = true;
        string line;
        getline(cin, line);
        if(line == ".") break;
        for(int i = 0; i < line.size(); ++i) {
            c = line[i];
            if(c == '(') cc.push(')');
            if(c == '[') cc.push(']');
            if(c == ')') {
                if(!cc.empty() && cc.top() == ')') cc.pop();
                else success = false;
            }
            if(c == ']') {
                if(!cc.empty() && cc.top() == ']') cc.pop();
                else success = false;
            }
        }
        cout << ((success && cc.empty()) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int M = sc.nextInt();
        PriorityQueue<Job> jobs = new PriorityQueue<>();
        for (int i = 0; i < N; i++) {
            int delay = sc.nextInt();
            int val = sc.nextInt();
            jobs.add(new Job(val, delay));
        }
        TreeSet<Integer> spots = new TreeSet<>();
        for (int i = 0; i < M; i++) {
            spots.add(i);
        }
        int day = 0;
        long total = 0;
        while (day < M && jobs.size() > 0) {
            // We want to use either M - DELAY, or something earlier if taken!
            if (spots.lower(M - jobs.peek().delay + 1) != null) {
                int latestDay = spots.lower(M - jobs.peek().delay + 1);
//                System.out.println(latestDay);
                spots.remove(latestDay);
                // maintain invariant of best value on top
                total += jobs.poll().val;
                day++;
            }
            else {
                // That job couldn't go anywhere. We had greedily found better
                // values for all time slots this one could fit. So baby it's worthless
                jobs.poll();
            }
        }
        out.println(total);
        out.close();
    }

    static class Job implements Comparable<Job>{
        int val, delay;

        public Job(int v, int d) {
            val = v; delay = d;
        }

        public int compareTo(Job j2) {
            return j2.val - val; // big val first!
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 52244
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 305;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, k;
ll dp[N][N][N];
ll arr[N];

ll recur(ll pos, ll rem, ll prev1) {

  if (rem < 0)
    return inf;
  if (pos == n + 1)
    return 0;

  ll &ans = dp[pos][rem][prev1];

  if (ans != -1)
    return ans;

  ans = inf;
  ll val = arr[prev1];

  ans = min(ans, recur(pos + 1, rem - 1, prev1));
  ans = min(ans, max(0ll, arr[pos] - val) + recur(pos + 1, rem, pos));
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> k;

  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  arr[0] = 0;
  memset(dp, -1, sizeof(dp));

  cout << recur(1, k, 0) << en;

  return 0;
}

/*
5
1 2 3 1 2
1
1 5
 */

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;


int main(void){
    string S;
    cin >> S;
    int l = S.size();
    int tmp;
    int ans = 10000;
    for(int i = 0; i < l - 2; i++){
        tmp = (int)(S.at(i) - '0') * 100 + (int)(S.at(i+1) - '0') * 10 + (int)(S.at(i+2) - '0');
        ans = min(ans, abs(tmp-753));
    }
    
    printf("%d\n", ans);
}


Measured memory_bytes: 384
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060