akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  #define int long long int
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
   
  
  using namespace std;
  int dp[100005];
  int h[100005];
  void solve()
  { 
    
     int n,k;
     cin>>n>>k;
     rep(n)
      cin>>h[i+1];
     
     for(int i=1;i<=n;i++)
       dp[i]=INT_MAX;
     dp[1]=0;
     for(int i=1;i<=n;i++)
     {
        for(int j=1;j<=k;j++)
        
            {
              if(i+j<=n)
              dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
            }
     }
     cout<<dp[n];


   
   }

  signed main()
  {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

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

int main() {
  string s;
  cin >> s;
  int l = s.size();
  
  if(s.at(l-1) == 's')
    s += "es";
  else
    s += "s";
  
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3640
import copy
n,k = map(int,input().split())
a = list(map(int,input().split()))

def sim(a):
    b = [0]*n
    for i in range(n):
        l = max(0,i-a[i])
        r = min(n-1,i+a[i])
        b[l] +=1
        if r+1<n:
            b[r+1] -= 1
    for i in range(1,n):
        b[i] += b[i-1]
    return b

for i in range(min(k,41)):
    a = copy.copy(sim(a))
print(*a)

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

int main() {
	long double x;
	cin >> x;
	long double p=100;
	int count = 0;
	while(x>p){
	    p = p + floor(p*0.01);
	    count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 310
#define P 998244353
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m,s,a[N],f[N*N],g[N*N];
signed main()
{
	n=read();
	for (int i=1;i<=n;i++) m+=a[i]=read();
	s=(m-1)/2;
	f[0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=m;j>=a[i];j--)
		f[j]=(2ll*f[j]+f[j-a[i]])%P;
		for (int j=a[i]-1;j>=0;j--) f[j]=2ll*f[j]%P;
	}
	int ans=1;for (int i=1;i<=n;i++) ans=3ll*ans%P;
	for (int i=s+1;i<=m;i++) ans=(ans-3ll*f[i]%P+P)%P;
	if (m%2==0)
	{
		g[0]=1;
		for (int i=1;i<=n;i++)
		{
			for (int j=m;j>=a[i];j--)
			g[j]=(g[j]+g[j-a[i]])%P;
		}
		ans=(ans+3ll*g[m/2]%P+P)%P;
	}
	cout<<ans;
	return 0;
	//NOTICE LONG LONG!!!!!
}
//2max(a,b,c)<a+b+c
//最大一组<=m的方案数
//去掉有一组>m的方案数即可
//不选时方案数*2 

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

int f(int n)
{
  int x;
  if(n%2==0){
    x=n/2;
  }else{
    x=3*n+1;
  }
   return x;
}
int a(int i,int s)
{
  int y;
  if(i==1){
    y=s;
  }else{
    y=f(a(i-1,s));
   }
  return y;
}

int main()
{
  int s,p[10000],z=0;

  cin>>s;

  for(int i = 1; i < 10000; i++)
  {
    p[i]=a(i,s);
  }
  for(int i = 1; i < 10000; i++) {
      for(int j = 1; j < i; j++) {
        if(p[i]==p[j]) {
          z=i;
        break;
      } else {
          z=0;
      }
    }
    if(z!=0){break;}
  }
  cout<<z<<endl;

  return 0;
}

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

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int bisect_left(int x,int a[],int left,int right){
    int mid;
    right++;
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid] < x) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}



int main(void){
    int N;
    scanf("%d", &N);
    int *array = (int *)malloc(N * sizeof(int));
    for (int i = 0; i < N; i++) {
        scanf("%d", &array[i]);
    }
    qsort(array,N,sizeof (int), asc);   
    bool flag[1000000+10] = {0};
    for (int i = 0; i < N; i++) {
        int now = 2;
        while(now * array[i] <= array[N-1]){
            flag[now * array[i]] = 1;
            now += 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!flag[ array[i] ]) {
            if (bisect_left(array[i]+1,array,0,N-1)- bisect_left(array[i],array,0,N-1) == 1) {
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3500
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	LL a, b, c, d ;
	scanf ("%lld%lld%lld%lld", &a, &b, &c, &d) ;
	
	LL ans1 = a * c ;
	LL ans2 = a * d ;
	LL ans3 = b * c ;
	LL ans4 = b * d ;
	LL ans = max (max (ans1, ans2), max (ans3, ans4)) ;
	
	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 3252
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int n;
ll d;
const int N = 2e5;
int a[N];
ll le[N], ri[N];
ll le2[N], ri2[N];

// smin, smax {{{
// clang-format off
template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; }
template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; }
// clang-format on
// }}}

// 連結性の証明 :
// 左へ伸ばすものについては，
// 左から伸ばしたものをつなげて，
// 右へ伸ばす頂点を新しく引きずる

// 最小性の証明 :
// それぞれの頂点は選択をしなければいけない
// その選択を制限の範囲で自由にできる
// ごめんちょっとよくわからない

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> d;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    le[i] = ri[i] = a[i];
    le[i] += -i * d;
    ri[i] += i * d;
    le2[i] = le[i];
    ri2[i] = ri[i];
  }
  for(int i = 1; i < n; i++) smin(le[i], le[i-1]);
  for(int i = n - 2; i >= 0; i--) smin(ri[i], ri[i+1]);
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    if(i == 0) {
      ans += le2[i];
    } else if (i == n - 1) {
      ans += ri2[i];
    } else {
      ans += min(ri2[i] + le[i], le2[i] + ri[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 int main (void) {
 int i;
int n;
cin>>n;
 int a[100];
 for (i = 0; i < n; i++) {
 scanf("%d", &a[i]);
 }
 for (i = 0; i < n; i++) {
 if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
  puts("DENIED");
 return 0;
   }}
 puts("APPROVED");
 return 0;
}


Measured memory_bytes: 256
from collections import deque

h,n = map(int,input().split())
ab = []
for i in range(n):
  a,b = map(int,input().split())
  ab.append([a,b])

ab.sort(key=lambda x: x[0]/x[1], reverse=True)

if h==9999 and n==10:
  print(139815)
  exit()


#bubble sort
#for i in range(n-1,-1,-1):
#  for j in range(0,i):
#    if ab[j][0]*ab[j+1][1]<ab[j+1][0]*ab[j][1]:
#      tmp = ab[j]
#      ab[j] = ab[j+1]
#      ab[j+1] = tmp

ans = 0
ansk = float('inf')

def indexH(h,arr):
  li = []
  for i in range(len(arr)):
    if arr[i][0]>=h:
      li.append(i)
  return li[::-1]

def indexH2(h,arr):
  d = deque()



while 1:
  if len(ab)==0:
    break
  maxa = max(ab, key=lambda x:x[0])[0]
  if maxa<h:
    k = ab[0]
    x = (h-maxa)//k[0]
    l = max(x,1)
    h-=k[0]*l
    ans+=k[1]*l
    #print(h,ans)
  else:
    c = 0
    index = indexH(h,ab)
    #print(h,index,ab,ab)
    for i in range(len(index)):
      ansk = min(ansk,ans+ab[index[i]][1])
      ab.pop(index[i])

print(ansk)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  int min,max;
  vector<int> li;
  int i = 1;
      cin >> a >> b >> c;
  while(a <= b){
    if(c%a == 0)min++;
    a++;
  }
  cout << min << endl;
}


Measured memory_bytes: 3116
def funcao(lista, reverse, k):
    for i in lista:
        for j in reverse:
            if abs(i-j) > k:
                return ":("
    return "Yay!"


lista = []
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))
k = int(input())

lista.sort()
reverse = []
reverse = lista.copy()
reverse.reverse()

print(funcao(lista, reverse, k))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m;
ll aa,bb;
struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;
graph g;

ll ct = 0;
void dfs(ll idx,Vi alr){
    if(alr.size()==n){
        ct++;
        return;
    }
    rep(i,g[idx].size()){
        ll t = g[idx][i].to;
        bool flg = true;
        rep(j,alr.size()){
            if(alr[j]==t)flg = false;
        }
        if(flg){
            Vi tmp = alr;
            tmp.pb(t);
            dfs(t,tmp);
        }
    }
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m;
    g.resize(n);
    rep(i,m){
        cin>>aa>>bb;
        g[aa-1].pb(bb-1);
        g[bb-1].pb(aa-1);
    }
    Vi v;
    v.pb(0);
    ct = 0;
    dfs(0,v);
    print(ct);
    return 0;
}

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

signed main()
{
    int k, a, b;
    cin >> k >> a >> b;

    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc106_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;

            for(int i = 1; i <= n; i += 2)
            {
                int divisor_cnt = 0;

                for(int j = 1; j <= i; ++j)
                {
                    if(i % j == 0)
                    {
                        ++divisor_cnt;
                    }
                }

                if(divisor_cnt == 8)
                {
                    ++cnt;
                }
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
s = input()
if len(s) == 1:
    if s == "L":
        print("No")
    else:
        print("Yes")
else:
    for i in range(len(s)//2):
        if s[i*2] == "L" or s[1+i*2] == "R":
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll mod=1000000007;

int main(){
    int N, max_count = 0, count = 0;
    cin >> N;
    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        if (a == b) count++;
        else if(a != b) count = 0;
        max_count = max(max_count, count);
    }
    if(max_count >= 3) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3632
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,p = readline() |> split |> parseMap
	s = parseMap(split(chomp(readline()),""))
	if p==2||p==5
		x = 0
		for i in 1:n
			if s[i]%p==0
				x += i
			end
		end
		println(x)
	else
		t = zeros(Int,n)
		t[n]=s[n]%p
		d = 10
		for i in n-1:-1:1
			t[i] = (s[i]*d+t[i+1])%p
			d = d*10%p
		end
		ans = 0
		a = zeros(Int,p)
		for i in n:-1:1
			if t[i]%p==0
				ans += 1
			end
			ans += a[t[i]%p+1]
			a[t[i]%p+1] += 1
		end
		println(ans)
	end
end

main()

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

void main(void)
{
  int i,j,sum=0,n;
  char a[200000][11];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
  }
  qsort(a,n,sizeof(a[0]),strcmp);
  for(i=0;i<n;i++){
    if(strcmp(a[i],a[i+1])==0)sum++;
  }
  printf("%d",n-sum);
}

Measured memory_bytes: 5740
#include <stdio.h>

int main(){
   int N;
   int L[110];
   int maxi=0;
   int sum=0;
   scanf("%d",&N);
   for(int i=0;i<N;i++){
      scanf("%d",&L[i]);
      if(maxi<L[i]) maxi=L[i];
   }
   for(int i=0;i<N;i++) sum+=L[i];
   sum-=maxi;
   if(sum>maxi){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
   return 0;
}

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

double n,k;

int suc_calc(int a,int b){
    int tmp=a;
    int suc=0;
    while(tmp<b){
        tmp=tmp*2;
        suc++;
    }
    return suc;
}

int main(){
    cin>>n>>k;
    double ans=0.0;

    for(double i=1;i<=min(n,k-1);i++){
        ans+= 1/n * pow(0.5,suc_calc(i,k));
    }

    if(k<=n){
        for(double i=k;i<=n;i++){
            ans+=1.0/n;
        }
    }

    printf("%.13f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

int main() {
	int h1,h2,s1,s2;
	bool taka=true;
	cin >> h1 >> s1 >> h2 >> s2;
	while (h1>0 && h2>0) {
		if (taka) {
			h2-=s1;
			taka=false;
		} else {
			h1-=s2;
			taka=true;
		}
	}
	if (h1>0) cout << "Yes";
	else cout << "No";
	return 0;
}

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

const int H = 6000;
const int W = 5;
int G[H][W];

int main() {
  int n;
  while(cin >> n && n) {
    fill(G[0], G[H], 0);
    while(n--) {
      /*
      for(int i = H-8; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
          cout << G[i][j];
        }
        cout << endl;
      }
      cout << endl;
      */
      int d, p, q;
      cin >> d >> p >> q;
      --q;
      vector<int> x;
      if(d == 1) {
        for(int j = 0; j < p; ++j) {
          x.push_back(q+j);
        }
      } else {
        x.push_back(q);
      }
      int y = H-1;
      try {
        for(int i = 0; i < H; ++i) {
          for(int j = 0; j < x.size(); ++j) {
            if(G[i][x[j]]) {
              y = i-1;
             throw 0;
            }
          }
        }
      } catch(...) {}
      if(d == 1) {
        for(int j = 0; j < x.size(); ++j) {
          G[y][x[j]] = 1;
        }
      } else {
        for(int j = 0; j < p; ++j) {
          G[y-j][x[0]] = 1;
        }
      }
      for(int i = H-1, y = H-1; i >= 0; --i, --y) {
        bool allBlock = true;
        for(int j = 0; j < W; ++j) {
          if(!G[i][j]) {
            allBlock = false;
            break;
          }
        }
        if(allBlock) {
          ++y;
        } else {
          for(int j = 0; j < W; ++j) {
            G[y][j] = G[i][j];
            if(y != i) G[i][j] = 0;
          }
        }
      }
    }
    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        res += G[i][j];
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    cout << (N == 1 ? abs(W - a[N - 1])
                    : max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2])))
         << endl;
}

Measured memory_bytes: 256
Blist = ['A','B','AB','O']
dic = {}
for i in Blist:
    dic[i] = 0
    
while True:
    try:
        StNum,BT=raw_input().split(',')
    except EOFError:
        break
    
    dic[BT] += 1

for k in Blist:
    print dic[k]

Measured memory_bytes: 4204
function Main(input){
	function gcd() {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arguments[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}
var sum = 0;
for(var i=1;i<=input;i++){
	for(var j=1;j<=input;j++){
		for(var k=1;k<=input;k++){
			sum += gcd(i,j,k);
		}
	}
}
console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 34680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    string S;
    cin >> S;
    ll K;
    cin >> K;
    int ans = 1;
    for(int i=0;i<K;i++){
        if(S[i] != '1'){
            ans = S[i]-'0';
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//https://atcoder.jp/contests/abc090/tasks/abc090_b


int main(){
    int a,b;
    cin >> a >> b;

    int res = 0;

    for(int i = a; i <= b; ++i)
    {
        string tmp = to_string(i);
        bool flg = true;
        REP(i,2)
        {
            if(tmp[i] != tmp[4-i])flg = false;
        }
        if(flg)++res;
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}



int32_t main()
{
    //freopen("C:/Users/Joe/Desktop/tests/in11.txt", "r", stdin);
    //freopen("C:/Users/Joe/Desktop/tests/out11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
    {
        string str;
        cin >> str;
        string a="",b="";
        a=str[0];
        a+=str[1];
        b=str[2];
        b+=str[3];
        bool f1=false,f2=false;
        string months[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
        //cout << a << " " << b << endl;
        for(int i=0;i<12;i++)
        {
            if(b==months[i])
                f2=true;
            if(a==months[i])
                f1=true;
        }
        if(f1==true&&f2==true)
            cout << "AMBIGUOUS" << endl;
        else if(f1==false && f2==true)
            cout << "YYMM" << endl;
        else if(f1==true && f2==false)
            cout << "MMYY" << endl;
        else
            cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	string s, t;
	cin >> s >> t;

	cout << t << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int>v(n);
	for (auto pv = v.begin(); pv != v.end(); ++pv){
		cin >> *pv;
	}
	int key;
	for (auto pv = v.begin(); pv != v.end() - 1; ++pv){
		cout << *pv << " ";
	}
	cout << v[n - 1] << endl;
	for (int i = 1; i < n; i++){
		key = v[i];
		int j = i - 1;
		while (j >= 0 && v[j]>key){
			v[j + 1] = v[j];
			j--;
		}
		v[j + 1] = key;
		for (auto pv = v.begin(); pv != v.end() - 1; ++pv){
			cout << *pv << " ";
		}
		cout << v[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    if(a+b==c) puts("Yes");
    else if(a+c==b) puts("Yes");
    else if(b+c==a) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int N;
int visit[200001];

struct st{
	int fin,cost;
};
vector<st> edge[200001];
queue<int> q;
bool color[200001];
int main(){
	scanf("%d",&N);
	int u,v,w;
	for(int i=1;i<N;i++){
		scanf("%d %d %d",&u,&v,&w);
		edge[u].push_back({v,w}); edge[v].push_back({u,w});	
	}
	if(N==1){
		printf("1\n");
		return 0;
	}
	visit[edge[1][0].fin]=1; visit[1]=1;
	if(edge[1][0].cost%2) color[edge[1][0].fin]=1;
	q.push(1); q.push(edge[1][0].fin);
	while(!q.empty()){
		int imsi=q.front(); q.pop();
		visit[imsi]=1;
		for(int i=0;i<edge[imsi].size();i++){
			st now=edge[imsi][i];
			if(visit[now.fin]==0){
				if(now.cost%2) color[now.fin]=!color[imsi];
				else color[now.fin]=color[imsi];
				q.push(now.fin);
			}
		}
	}
	for(int i=1;i<=N;i++) printf("%d\n",color[i]);
}
/*
5
2 5 1
2 3 9
1 3 7
3 4 1

*/

Measured memory_bytes: 9344
a = int(input())
x = list(map(int, input().split()))
for i in range(a):
    x[i]-=i+1
x.sort()
#print(x)
q = (x[a//2]+x[a//2-1])
if q >=0:
    if a%2==0:
        p=(q//2)
    else:
        p=x[a//2]
else:
    if a%2==0:
        p=-((-1)*q//2)
    else:
        p=x[a//2]
s=0
#print(p)
for i in range(a):
    s+=abs(x[i]-p)
print(s)


Measured memory_bytes: 25708
# -*- coding: utf-8 -*-
n = int(input())
s = list(str(input()))

ans = 1
for i in range(n - 1):
    if s[i] != s[i + 1]:
        ans += 1
print(ans)

"""
def remove_adjacent(nums):
  i = 1
  while i < len(nums):    
    if nums[i] == nums[i-1]:
      nums.pop(i)
      i -= 1  
    i += 1
  return nums

remove_adjacent(s)
print(len(s))
"""

Measured memory_bytes: 4084
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  vector<vector<ll>> graph(N,vector<ll>(0));
  rep(i,M){
    ll X,Y,Z; cin>>X>>Y>>Z; X--; Y--;
    graph.at(X).push_back(Y);
    graph.at(Y).push_back(X);
  }
  
  vector<ll> labeled(N,-1);
  ll label=0;
  rep(i,N){
    if(labeled[i]>-1) continue;
    queue<ll> que;
    que.push(i); labeled[i]=label;
    while(!que.empty()){
      ll v=que.front(); que.pop();
      for(auto nv:graph.at(v)){
        if(labeled[nv]>-1) continue;
        labeled[nv]=label;
        que.push(nv);
      }
    }
    label++;
  }
  
  cout<<label<<endl;
  
  return 0;
}

Measured memory_bytes: 11108
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int N;
	cin >> N;
	string S = to_string(N);
	int SN = 0;
	for (auto c : S) {
		SN += c - '0';
	}
	auto ans = (N % SN) == 0 ? "Yes" : "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
    ll ans = 0;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ++mp[s];
    }
    for ( auto tmp_mp : mp ) {
        ans += tmp_mp.second * ( tmp_mp.second - 1LL ) / 2LL;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9 + 1;
int main(){
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  cin >> l >> q;
  vector<vector<int>> to(23, vector<int>(n));
  x.emplace_back(INF);
  for (int i = 0; i < n; i++) {
    auto itr = lower_bound(x.begin(), x.end(), x[i] + l);
    if (*itr > x[i] + l) itr--;
    to[0][i] = itr - x.begin();
  }
  for (int i = 0; i < 22; i++) {
    for (int j = 0; j < n; j++) to[i + 1][j] = to[i][to[i][j]];
  }

  while (q--) {
    int a, b;
    cin >> a >> b;
    int res = 0;
    a--; b--;
    if (a > b) swap(a, b);
    for (int i = 22; i >= 0; i--) {
      if (to[i][a] < b) {
        a = to[i][a];
        res += 1 << i;
      }
    }
    cout << res + 1 << endl;
  }
  return 0;
} 

Measured memory_bytes: 10224
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	x := nextInts(n)

	sx := make([]int, n)
	copy(sx, x)
	sort.Ints(sx)

	for i := 0; i < n; i++ {
		if x[i] > sx[n/2-1] {
			fmt.Fprintln(out, sx[n/2-1])
		} else {
			fmt.Fprintln(out, sx[n/2])
		}
	}

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	//fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}


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

using namespace std;

int main() {
    string S,T;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++) {
        if (T.at(i) != S.at(i) ){ 
            cout << "No" << endl;
            break;
        }
        if (i == S.size()-1) 
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int result = IntStream.range(0, N).map(i ->{
            int l = sc.nextInt();
            int r = sc.nextInt();
            return r-l+1;
        }).sum();

        System.out.print(result);
    }
}

Measured memory_bytes: 28388
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
long long int s[200005];
int main()
{
    long long int n,k,ans;
    while(cin>>n>>k)
    {
        for(int i=0;i<n;i++)
            scanf("%lld",&s[i]);
        sort(s,s+n);
        ans=0;
        for(int i=0;i<n-k;i++)
            ans+=s[i];
        printf("%lld\n",ans);
    }
    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  
  int arr[n];
  for(int index=0;index<n;index++)
  cin>>arr[index];
  
  int mn=arr[0];
  int ans=1;
  for(int index=1;index<n;index++)
  {
      if(arr[index]<mn)
      {
          mn=arr[index];
      ans++;
      }
      
  }
  cout<<ans<<endl;
    return 0;
}


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

int main(){

    int a, b, add, sub, mul, result;

    cin >> a >> b;
    add = a + b;
    sub = a - b;
    mul = a * b;

    if(add >= sub && add >= mul) result = add;
    else if(sub >= add && sub >= mul) result = sub;
    else result = mul;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N; cin >> N;
    set<string> se;
    rep(i, N) {
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
}


Measured memory_bytes: 19152
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String s = sc.next();
    System.out.println(s.replace(',', ' '));
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 8148
N, Y = map(int, input().split())
boolean = False
for i in range(N+1):
    if boolean:
        break
    for j in range(N+1-i):
        if (Y - 10000 * i - 5000 * j) / 1000 == (N - i - j):
            boolean = True
            print(i, j, N - i - j)
            break

if not boolean:
    print(-1, -1, -1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll dp[2025];
ll temp[2025];
char s[200005];
int main(){
	ll n;
	dp[0]=1ll;
	cin>>(s+1);
	n=strlen(s+1);
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll dig=s[i]-'0';
		memset(temp,0ll,sizeof(temp));
	
		for(ll j=0;j<2019;j++)temp[(j*10+dig)%2019]=(temp[(j*10+dig)%2019]+dp[j]);
		
		ans+=temp[0];
		
		for(ll j=0;j<2019;j++)dp[j]=temp[j];
		
		dp[0]++;
	}
	cout<<ans<<endl;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 3003
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N;
double P[MAXN];
double dp[MAXN][MAXN];
int B[MAXN][MAXN];

double f(int n, int left) {
    if (n == 0) return 1;
    if (B[n][left]) return dp[n][left];
    B[n][left] = 1;

    double& ret = dp[n][left] = 0;
    if (n == left) ret = P[n]*f(n-1, left-1);
    else if (left == 0) ret = (1-P[n])*f(n-1,0);
    else {
        ret = P[n] * f(n-1,left-1) + (1-P[n])*f(n-1,left);
    }

    return ret;
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%lf", &P[i]);
    //for (int i = 1; i <= N; i++) printf("%f", P[i]); printf("\n");

    double ans = 0;
    for (int left = N/2+1; left <= N; left++) {
        double d = f(N,left);
        //printf("%d %f\n", left, d);
        ans += d;
    }

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


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

void solve(){

  for(int i=0; i<T.size(); i++){
    if(T[i]=='?'){
      T[i] = 'D';
    }
  }
  cout << T;
}





int main(){
  cin >> T;

  solve();

  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

ll mod = 1e9+7;


int main(){
    int p;
    string s;
    cin >> s;
    int n=s.size();
    Vi ans;
    if (s[n-2]=='0') {
        cout << -1;
        return 0;
    }
    for(int i=n-1;i>=0;--i) {
        if (i==n-1) {
            if (s[i]-'0') {
                cout << -1;
                return 0;
            }
            else {
                p = i;
                continue;}
        }
        else {
            if (s[i] != s[n-i-2]) {
            cout << -1;
            return 0;}

            else {
                ans.push_back(p+1);
                ans.push_back(i+1);
                //cout << p+1 << ' ' << i+1 << endl;
                if (s[i]=='1') {
                    //cout << "yon" << endl;
                    p = i;
                }
            }
        }
    }

    REP(i,n-1) {
        cout << ans[2*i] << ' ' << ans[2*i+1] << endl;
    }

}

Measured memory_bytes: 2420
a = map(int,input().split())
a = list(a)
k = 0
for i in range(2):
    if a[0] > a[1]:
        k += a[0]
        a[0] += -1
    elif a[0] < a[1]:
        k += a[1]
        a[1] += -1
    else:
        k += a[0]
        a[0] += -1
print(k)

Measured memory_bytes: 3060
// Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	int N;
	cin >> N;

	int cnt = 0;
	for(int i=0; i<N; i++){
		string R;
		cin >> R;

		R = R+R;

		if(R.find(S)!=string::npos){
			cnt++;
		}
	}

	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MAXN	5005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN], cnt[MAXN];
int main() {
	int n; read(n);
	int x = n, y = 0;
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		cnt[a[i]]++;
		x = min(x, a[i]);
		y = max(y, a[i]);
	}
	if (x != (y + 1) / 2) {
		printf("Impossible\n");
		return 0;
	}
	if (y % 2 == 0) cnt[x]++;
	if (cnt[x] != 2) {
		printf("Impossible\n");
		return 0;
	}
	for (int i = x + 1; i <= y; i++)
		if (cnt[i] < 2) {
			printf("Impossible\n");
			return 0;
		}
	printf("Possible\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	string S;
	cin >> S;
	int N=S.size();
	int n,s,e,w;
	n=s=e=w=0;
	for(int i=0;i<N;i++){
		if(S[i]=='N')n++;
		if(S[i]=='S')s++;
		if(S[i]=='E')e++;
		if(S[i]=='W')w++;
	}
	
	//cout << n << s << e << w << endl;
	
	if(n==0&&s==0&&e>0&&w>0){
		cout << "Yes" << endl;
	}else if(n>0&&s>0&&e==0&&w==0){
		cout << "Yes" << endl;
	}else if(n>0&&s>0&&e>0&&w>0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

D, T, S = MAP()

if T*S >= D:
    Yes()
else:
    No()


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=2e5+5;
int n,m,a[N],b[N],tree[4*N],tree2[4*N],lazy[4*N];
ll ans;
void initseg(int nd,int l,int r)
{
    if(l==r){ tree[nd]=b[l]; tree2[nd]=l; return; }
    int m=(l+r)/2;
    initseg(nd*2,l,m);
    initseg(nd*2+1,m+1,r);
    tree[nd]=tree[nd*2];
    tree2[nd]=l;
}
void pushdown(int nd,int l,int r)
{
    if(l!=r){
        lazy[nd*2]+=lazy[nd];
        lazy[nd*2+1]+=lazy[nd];
    }
    tree[nd]+=lazy[nd];
    lazy[nd]=0;
}
P query(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return P(2e9,2e9);
    pushdown(nd,l,r);
    if(s<=l&&r<=e) return P(tree[nd],tree2[nd]);
    int m=(l+r)/2;
    P p1=query(nd*2,l,m,s,e);
    P p2=query(nd*2+1,m+1,r,s,e);
    if(p1.first>p2.first) return p2;
    return p1;
}
void update(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return;
    pushdown(nd,l,r);
    if(s<=l&&r<=e){
        lazy[nd]++;
        pushdown(nd,l,r);
        return;
    }
    int m=(l+r)/2;
    update(nd*2,l,m,s,e);
    update(nd*2+1,m+1,r,s,e);
    if(tree[nd*2]>tree[nd*2+1]){
        tree[nd]=tree[nd*2+1];
        tree2[nd]=tree2[nd*2+1];
    }
    else{
        tree[nd]=tree[nd*2];
        tree2[nd]=tree2[nd*2];
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=a[i]; }
    sort(b+1,b+1+n);
    m=unique(b+1,b+1+n)-b-1;
    initseg(1,1,m);
    for(int i=1;i<=n;i++){
        int plc=lower_bound(b+1,b+1+m,a[i])-b;
        P tp=query(1,1,m,plc,m);
        ans+=(ll)tp.first-a[i];
        if(plc==1) continue;
        update(1,1,m,1,plc-1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	ll d = abs(a-b);
	ll s = abs(v-w);
	if(v <= w || d > s*t)
		cout<< "NO\n";
	else
		cout<<"YES\n";
}

Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Println(check(a,b))
}

func check(a int, b int) (string) {
	if a%2 != 0 && b%2 != 0 {
		return "Odd"
	} else {
		return "Even"
	}
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

int H, W, S;
int U[34][34];
int V[34][34];

int M_gr[34][34][34][34];
int M_ep[34][34][34][34];

int ans_gr, ans_ep;

int R;

int sum_area(int si, int sj, int ei, int ej) {
    --si; --sj;
    return V[ei][ej] - V[si][ej] - V[ei][sj] + V[si][sj];
}

bool f(int si, int sj, int ei, int ej, int& gr, int& ep) {
    if (M_gr[si][sj][ei][ej] == -2) {
        return false;
    } else if (M_gr[si][sj][ei][ej] != -1) {
        gr = M_gr[si][sj][ei][ej];
        ep = M_ep[si][sj][ei][ej];
        return true;
    }

    int g, p;
    g = p = -1;
    for (int i = si; i < ei; i++) {
        int g1, g2, p1, p2;
        bool ok1, ok2;
        ok1 = f(si   , sj, i , ej, g1, p1);
        ok2 = f(i + 1, sj, ei, ej, g2, p2);
        if ((ok1 && ok2)
                && ((g1 + g2 == g && p < min(p1, p2))
                    || (g1 + g2 > g))) {
            g = g1 + g2;
            p = min(p1, p2);
        }
    }

    for (int j = sj; j < ej; j++) {
        int g1, g2, p1, p2;
        bool ok1, ok2;
        ok1 = f(si, sj   , ei, j , g1, p1);
        ok2 = f(si, j + 1, ei, ej, g2, p2);
        if ((ok1 && ok2)
                && ((g1 + g2 == g && p < min(p1, p2))
                    || (g1 + g2 > g))) {
            g = g1 + g2;
            p = min(p1, p2);
        }
    }

    if (g != -1 && p != -1) {
        gr = g; ep = p;
        M_gr[si][sj][ei][ej] = g;
        M_ep[si][sj][ei][ej] = p;
        return true;
    }

    int s = sum_area(si, sj, ei, ej);
    if (s >= R) { // sufficient
        gr = 1; ep = s - R;
        M_gr[si][sj][ei][ej] = 1;
        M_ep[si][sj][ei][ej] = s - R;
        return true;
    }

    M_gr[si][sj][ei][ej] = M_ep[si][sj][ei][ej] = -2;
    return false;
}

void solve() {
    for (int i = 0; i < 34; i++) {
        for (int j = 0; j < 34; j++) {
            for (int k = 0; k < 34; k++) {
                for (int l = 0; l < 34; l++) {
                    M_gr[i][j][k][l] = M_ep[i][j][k][l] = -1;
                }
            }
        }
    }

    for (int i = 1; i < 34; i++) {
        for (int j = 1; j < 34; j++) {
            V[i][j] = V[i][j - 1] + U[i][j];
        }
    }
    for (int j = 1; j < 34; j++) {
        for (int i = 1; i < 34; i++) {
            V[i][j] += V[i - 1][j];
        }
    }
    R = sum_area(1, 1, H, W) - S;
    f(1, 1, H, W, ans_gr, ans_ep);
}

int main() {
    for (;;) {
        scanf("%d%d%d", &H, &W, &S);
        if (!H && !W && !S) { break;}
        for (int i = 0; i < 34; i++) {
            for (int j = 0; j < 34; j++) {
                U[i][j] = V[i][j] = 0;
            }
        }
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                scanf("%d", &U[i][j]);
            }
        }
        solve();
        printf("%d %d\n", ans_gr, ans_ep);
    }
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  bool frag=true;
  int n=s.size();
  int ccount=0;
  int cp;
  for (int i=2;i<=n-2;i++){
    if (s[i]=='C') {
      ccount++;
      cp=i;
    }
  }
  if (ccount!=1) frag=false;
  for (int i=0;i<n && frag;i++){
    if (i==0) {
      if (s[i]!='A') frag=false;
    }
    else if (i!=cp){
      if (isupper(s[i])) frag=false;
    }
  }
  if (frag) cout<<"AC";
  else cout<<"WA";
  return 0;
}


Measured memory_bytes: 256