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

int main () {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		cin >> b[i];
	}
	for(int i=0; i<n-1; i++){
		a[i+1] += a[i];
	}
	for(int i=n-1; i>0; i--){
		b[i-1] += b[i];
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		ans = max(ans, a[i]+b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    //#define FILENAME "test" ← defined via command line
    assert(freopen(FILENAME ".in", "r", stdin));
    assert(freopen(FILENAME ".out", "w", stdout));
#endif

    ios_base::sync_with_stdio(0), cin.tie(0);
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        bool ok = 1;
        for (int j = 0; j < s.size(); j++) {

            if (s[j] != s[s.size() - 1 - j]) {
                ok = 0;
                break;
            }
        }
        cnt += ok;
    }
    cout << cnt;

    return 0;
}







































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

# V を昇順にソートする
V_asc = sorted(V)

# 係数 (2**N-1) * V[i] の和を求める
sum_coef_v = 0
for i in range(N):
  coef = 2 ** (i-1)
  if i == 0: coef = 1
  sum_coef_v += coef * V_asc[i]

ans = sum_coef_v / (2 ** (N-1))
print(ans)

Measured memory_bytes: 3060
# 2019/05/15
# AtCoder Beginner Contest 111 - C

from operator import itemgetter

# Input
n = int(input())
v = list(map(int, input().split()))

l_even = list()
l_odd = list()

# Separate Odd or Even
for i in range(n):
    if i % 2 == 0:
        l_even.append(v[i])
    else:
        l_odd.append(v[i])

l_even.sort()
l_odd.sort()
wk_cnt_e = 1
wk_cnt_o = 1

cnt_even = list()
cnt_odd = list()

# Count
for x in range(int(n/2)-1):
    if l_even[x] != l_even[x+1]:
        cnt_even.append([l_even[x], wk_cnt_e])
        wk_cnt_e = 1
    else:
        wk_cnt_e += 1

    if l_odd[x] != l_odd[x+1]:
        cnt_odd.append([l_odd[x], wk_cnt_o])
        wk_cnt_o = 1
    else:
        wk_cnt_o += 1

cnt_even.append([l_even[x+1], wk_cnt_e])
cnt_odd.append([l_odd[x+1], wk_cnt_o])

cnt_even.sort(key=itemgetter(1),reverse=True)
cnt_odd.sort(key=itemgetter(1),reverse=True)

# Max is same
if cnt_even[0][0] == cnt_odd[0][0]:
    if len(cnt_even) == 1 and len(cnt_odd) == 1:
        ans = n / 2
    elif len(cnt_even) == 1:
        ans = n / 2 - cnt_odd[1][1]
    elif len(cnt_odd) == 1:
        ans = n / 2 - cnt_even[1][1]
    else:
        ans = min((n / 2 - cnt_even[0][1]) + (n / 2 - cnt_odd[1][1]),
                (n / 2 - cnt_even[1][1]) + (n / 2 - cnt_odd[0][1]))
# Max is Not same
else:
    if len(cnt_even) == 1 and len(cnt_odd) == 1:
        ans = 0
    elif len(cnt_even) == 1:
        ans = n / 2 - cnt_odd[0][1]
    elif len(cnt_odd) == 1:
        ans = n / 2 - cnt_even[0][1]
    else:
        ans = (n / 2 - cnt_even[0][1]) + (n / 2 - cnt_odd[0][1])

# Output
print(int(ans))


Measured memory_bytes: 18660
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @b = map { $_ - 0 } split(/\s+/,<STDIN>);

my $t = $b[0] + $b[$n-1-1];
for(my $i=1;$i<$n-1;$i++){
  $t += ($b[$i-1] < $b[$i] ? $b[$i-1] : $b[$i]);
}
print "$t\n";



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	int R = 0, W = 0;
	for(auto c: s) {
		R += (c == 'R');
		W += (c == 'W');
	}

	int now = 0;
	for(int i = R; i < s.size(); i++) now += (s[i] == 'R');
	printf("%d\n", now);
	return 0;
}


Measured memory_bytes: 3880
abcd=list(input())
enzanshi=[['+','-'],['+','-'],['+','-']]
for i in range(2**3):
  l=[]
  for j in range(3):
    if (i>>j)&1:
      l.append(enzanshi[j][0])
    else:
      l.append(enzanshi[j][1])


  keisan=""
  for i,j in zip(abcd,l+['']):
    keisan+=i+j

  if eval(keisan)==7:
    print(keisan + '=7')
    break

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  char str[100];
  int n,i,j=0;
  
  scanf("%d%s",&n,str);
  
  if(n%2==0){
    for(i=0;i<n/2;i++){
     if(str[i]!=str[i+(n/2)]){
       j++;
     }
    }
    if(j==0){
      printf("Yes");
    }
    else
      printf("No");  
  }
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
def solve():
    S = int(input())
    MOD = 10**9+7

    dp = [0] * (S+1)
    dp[0] = 1

    for i in range(1,S+1):
        cnt = 0
        for j in range(i-2):
            cnt += dp[j]
        dp[i] = cnt % MOD
    
    print(dp[S])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 64392
#include<stdio.h>

int
output(char *str)
{
        if (*str != '\0')
                output(str + 1);
        else
                return 1;
        printf("%c", *str);
        return 1;
}

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

        scanf("%s", buf);
        output(buf);
        fputc('\n', stdout);
        return 0;
}

Measured memory_bytes: 520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

  int a,b;
  cin >> a >> b;

  for(int i=1; i<=998; i++)
  {
      int w = (i*(i+1))/2;
      int e = ((i+1)*(i+1+1))/2;
      if(a <= w && b <= e && (a+b)!= (w+e) && (w-a)==(e-b) )
      {
         // cout << i << " " << i+1 << endl;
          int sum = (w-a) ;
          cout << sum << endl;
          return 0;
      }

  }

    }


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

using namespace std;

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

struct Edge{
    ll from,to,cost;
    Edge(ll from,ll to,ll cost): from(from),to(to), cost(cost){}
};

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

    ll L; cin>>L;
    vector<int> v;
    while(L){
        v.push_back(L%2);
        L/=2;
    }
    ll len=v.size(),per=1;
    vector<Edge> es;
    //bool f = false;
    for(int i=1;i<=len-1;i++){
        es.push_back(Edge(i,i+1,0));
        es.push_back(Edge(i,i+1,per));
        per *= 2;
        //if(i==19) f=true;
    }
    if(len!=20) es.push_back(Edge(len,20,0));
    ll hd=per;
    for(int i=len-2;i>=0;i--){
        if(v[i]==0) continue;
        int idx=i+1;
        es.push_back(Edge(idx,20,hd));
        hd += (1<<i);
    }
    cout<<20<<" "<<es.size()<<endl;
    for(int i=0;i<(int)es.size();i++){
        cout<<es[i].from<<" "<<es[i].to<<" "<<es[i].cost<<endl;
    }
}


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

int main() {
	int n;
  	cin>>n;
  
  	int kotae =(n+1)/2;
  
  cout<<kotae<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int d[n]={};
  int a,b;
  while(cin>>a>>b){
    d[a-1]++;
    d[b-1]++;
  }
  for(int i=0;i<n;i++)cout<<d[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	bool even = true;
	for(int i = 0; i < N; i++) {
		int x;
		cin >> x;
		if(x&1) even = false;
	}
	if(even) cout << "second\n";
	else cout << "first\n";
	return 0;
}

// look at my code
// my code is amazing


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

using namespace std;
using ul = unsigned long;

ul gcd(ul a, ul b) {
  // assume a > b
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

void solve(ul A, ul B) {
  if (A < B)
    swap(A, B);
  ul x = gcd(A, B);

  set<ul> cds {1};
  for(ul i = 2; i <= sqrt(x); i++) {
    if (x % i)
      continue;
    while (x % i == 0)
      x /= i;
    cds.emplace(i);
  }
  cds.emplace(x);
  
  cout << cds.size() << endl;
}

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

  ul A, B;
  cin >> A >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

void print_leap_year(int start, int end);

int main(void)
{
    int start, end;
    while (1) {
        scanf("%d %d", &start, &end);
        if (start == 0 && end == 0) {
            break;
        } else {
            // 2回目の出力からは前回の出力とのあいだに空行をおく
            static bool first_output = 1;
            if (first_output == 0) {
                printf("\n");
            }
            first_output = 0;

            print_leap_year(start, end);
        }
    }

    return 0;
}

void print_leap_year(int start, int end)
{
    int year;
    int cnt = 0;
    for (year = start; year <= end; year++) {
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
            printf("%d\n", year);
            cnt++;
        }
    }
    if (cnt == 0) {
        printf("NA\n");
    }
}

Measured memory_bytes: 616
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=jp
#  Exhaustive Search : python3
#  2018.12.08 yonezawa


#from collections import deque
import sys
input = sys.stdin.readline
import cProfile

p = [pow(2,i) for i in range(30)]

def checkSum(l,d,ck=0):
    td = 0
    for i in range(len(l)):
        if  p[i] & ck == p[i]:
            continue
        td += l[i]
    if (td < d):
        return False
    elif ( td == d ):
        return True

    for i in range (len(l)):
        if  p[i] & ck == p[i]:
            continue
        ck += p[i]
        if  checkSum(l,d,ck):
            return True
        d -= l[i]
        #print ("debug:",i,d,ck)
        if d == 0:
            return True
        elif d < 0:
            return False
        if  checkSum(l,d,ck):
            return True
    return False

def main():
    n1 = int(input())
    l1 = list(map(int,input().split()))
    l1.sort()
    l1.reverse()
    n2 = int(input())
    l2 = list(map(int,input().split()))
    for i in range(n2):
        if checkSum(l1,l2[i]):
            print ("yes")
        else:
            print ("no")

if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

string a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0];
}




Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;
int a[maxn];
char s[maxn];

int main()
{
    while(~scanf("%s",s))
    {
        int len=strlen(s);
        int ans=0;
        for(int i=0;i<len;i++)
        {
            if(s[i]=='1')
                    ans++;
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  ll k;
  cin >> n >> k;
  vi a(n);
  vi f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  SORT(a);
  RSORT(f);
  ll l = -1, r = 1e12;
  while (l+1<r) {
    ll c = (l+r)/2;
    bool ok = [&]{
      ll s = 0;
      rep(i,n) {
        s += max(0ll, a[i]-c/f[i]);
      }
      return s <= k;
    }();
    if (ok) r = c; else l = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  ll n, k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  rep(i, n){
    cin >> a[i].first >> a[i].second;
  }
  sort(ALL(a));
  ll ind = 0;
  rep(i, n){
    ind += a[i].second;
    if (ind >= k) {
      cout << a[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

typedef pair<int,int> P;

int h,w,s,all,t[32][32];
int rec[32][32][32][32]; //[ly][lx][hy][hx]
P dp[32][32][32][32];

void mkRec(){
  memset(rec,0,sizeof(rec));

  rep(i,h){
    rep(j,w){
      rec[i][j][i][j] = t[i][j];

      for(int y=i-1;y>=0;y--)
        rec[y][j][i][j] = rec[y+1][j][i][j] + t[y][j];

      for(int y=i;y>=0;y--){
        int sum = 0;
        for(int x=j;x>=0;x--){
          sum += rec[y][x][i][x];
          rec[y][x][i][j] = sum;
        }
      }
    }
  }
}

P dfs(int lx,int ly,int hx,int hy){
  if(dp[ly][lx][hy][hx].first != 0) return dp[ly][lx][hy][hx];

  P res = P(1,s-(all-rec[ly][lx][hy][hx]));

  for(int i=ly;i<hy;i++){
    if(all - rec[ly][lx][i][hx] > s ||
       all - rec[i+1][lx][hy][hx] > s) continue;
    P a = dfs(lx,ly,hx,i);
    P b = dfs(lx,i+1,hx,hy);
    P cal = P(a.first+b.first,min(a.second,b.second));
    res = max(res,cal);
  }

  for(int j=lx;j<hx;j++){
    if(all - rec[ly][lx][hy][j] > s ||
       all - rec[ly][j+1][hy][hx] > s) continue;
    P a = dfs(lx,ly,j,hy);
    P b = dfs(j+1,ly,hx,hy);
    P cal = P(a.first+b.first,min(a.second,b.second));
    res = max(res,cal);
  }

  return dp[ly][lx][hy][hx] = res;
}

int main(void){
  while(scanf("%d%d%d",&h,&w,&s),h||w||s){
    all = 0;
    rep(i,h){
      rep(j,w){
        scanf("%d",&t[i][j]);
        all += t[i][j];
      }
    }

    mkRec();

    memset(dp,0,sizeof(dp));
    P p = dfs(0,0,w-1,h-1);
    printf("%d %d\n",p.first,p.second);
  }
}

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

using namespace std;

const int N = 123456;

int n;
int a[N], d1[N], d2[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[0] = a[n + 1] = 0;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    d1[i] = abs(a[i + 1] - a[i]);
    d2[i] = abs(a[i + 2] - a[i]);
    ans += d1[i];
  }
  for (int i = 1; i <= n; i++) {
    long long cur = ans;
    cur -= d1[i - 1] + d1[i];
    cur += d2[i - 1];
    printf("%lld\n", cur);
  }
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>

using namespace std;

int INF = 1'000'000;

int main() {
    int64_t N, X;
    cin >> N >> X;

    int64_t ans;
    vector<int64_t> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
        if( i==0 )  ans = abs(X-x[i]);
        else{
            ans = __gcd(ans, abs(X-x[i]));
        }
    }

    cout << ans << endl;
}

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

int main() {
  
  int n;
  cin >> n;
  vector<char> s(n);
  for(int i = 0; i < n; i++) {
    cin >> s.at(i);
    if(s.at(i) == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }
  int plus[N];
  for (int i = 0; i < N; i++) {
    plus[p[i]] = i;
  }
  ll a[N];
  ll b[N];
  a[0] = 0;
  b[0] = plus[0];
  for (int i = 1; i < N; i++) {
    a[i] = a[i-1] + 1;
    b[i] = plus[i] - a[i];
    if (a[i-1] < a[i] && b[i-1] > b[i]) {
      
    } else {
      b[i] = b[i-1] - 1;
      a[i] = plus[i] - b[i];
    }
  }
  ll big = 500000000;
  for (int i = 0; i < N; i++) {
    cout << a[i] + big << " ";
  }
  cout << endl;
  for (int i = 0; i < N; i++) {
    cout << b[i] + big << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4092
n_animal, n_foot = map(int, input().split())

checker = False
for i in range(n_animal + 1):
    n_kame = i
    n_tsuru = n_animal - n_kame
    n_foot_pred = n_kame * 4 + n_tsuru * 2
    
    if n_foot == n_foot_pred:
        checker = True
        break
    else:
        continue
if checker:
    print("Yes")
else:
    print("No")

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] line = bf.readLine().split("\\s");
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);
        int mod = (int) 1e9 + 7;

        int[][] dp = new int[n][m];
        String e;
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            e = bf.readLine();
            for (int j = 0; j < m; j++) {
                if (e.charAt(j) == '.') {
                    if (i + 1 < n) {
                        dp[i + 1][j] += dp[i][j];
                        if (dp[i + 1][j] > mod) {
                            dp[i + 1][j] -= mod;
                        }
                    }
                    if(j+1 < m) {
                        dp[i][j+1] += dp[i][j];
                        if(dp[i][j+1] > mod) {
                            dp[i][j+1] -= mod;
                        }
                    }
                }
            }
        }
        System.out.println(dp[n-1][m-1]);

    }
}


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

typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

unordered_map<string,ll> dp[101];

int main(){
    ll a,b;cin>>a>>b;
    ll ma,mb;
    ma=0;mb=0;
    ll c=1;
    ll ans=0;
    while(mb!=b){
        c=c*2;
        ma=a%c;
        mb=b%c;
        if(c==2){
            ll aa=a-a%2;
            ll bb=b+b%2;
            ll d=((bb-aa)/2)%2;
            if(d==0){
                
            }else{
                ans+=c/2;
            }
        }else{
            if(ma<c/2 && mb<c/2){
                
            }else if(ma<c/2 && mb>=c/2){
                if(mb%2==0){
                    ans+=c/2;
                }else{
                    
                }
            }else if(ma>=c/2 && mb<c/2){
                if(ma%2==0){
                    
                }else{
                    ans+=c/2;
                }
            }else{
                if((ma%2+mb%2)%2==0){
                    ans+=c/2;
                }else{
                    
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;

string base[7] = {"J","O","I","JO","JI","OI","JOI"};
int dp[1001][7] = {};

bool solve(char m,int p) {
	for (int i = 0; i < base[p].length(); i++) {
		if (base[p][i] == m) return 1;
	}
	return 0;
}

signed main()
{
	int N;
	string s;
	cin >> N >> s;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < 7; j++) {
			if (i == 0) continue;
			else if (i == 1) {
				if (solve('J', j) && solve(s[0], j)) dp[i][j]++;
			}
			else {
				if (solve(s[i - 1], j)) {
					for (int k = 0; k < 7; k++) {
						bool tmp = 0;
						for (int l = 0; l < base[j].length(); l++) {
							if (solve(base[j][l], k)) tmp = true;
						}
						if (tmp == true) dp[i][j] += dp[i - 1][k];
						dp[i][j] %= 10007;
					}
				}
				dp[i][j] %= 10007;
			}
			dp[i][j] %= 10007;
		}
	}
	/*
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < 7; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int ans = 0;
	for (int i = 0; i < 7; i++) {
		ans += dp[N][i];
		ans %= 10007;
	}
	cout << ans << endl;


}

Measured memory_bytes: 3204
N = int(input())
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
        
print('Yes' if all(travelable(p,q) for p,q in zip(P[:N],P[1:])) else 'No')

Measured memory_bytes: 23868
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, q;
  cin >> n >> q;
  vector< tuple< ll, bool, ll > > ev;
  for (int i=0; i<n; ++i) {
    ll s, t, x;
    cin >> s >> t >> x;
    ev.push_back(make_tuple(s-x, true, x));
    ev.push_back(make_tuple(t-x, false, x));
  }
  vector< tuple< ll, int > > d;
  for (int i=0; i<q; ++i) {
    ll dc;
    cin >> dc;
    d.push_back(make_tuple(dc, i));
  }
  sort(ev.begin(), ev.end());
  sort(d.begin(), d.end());
  vector< ll > ans(q, -1);
  ul ei = 0, di = 0;
  multiset< ll > ms;
  while (ei < ev.size() && di < d.size()) {
    auto dt = get<0>(d[di]);
    auto et = get<0>(ev[ei]);
    auto ef = get<1>(ev[ei]);
    auto ex = get<2>(ev[ei]);
    if (dt < et) {
      if (ms.size() > 0) ans[get<1>(d[di])] = *(ms.begin());
      di++;
      continue;
    }
    if (ef) ms.insert(ex);
    else ms.erase(ex);
    ei++;
  }
  for (int i=0; i<q; ++i) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 24680
#include <stdio.h>

int main (void)
{
int n, i,count = 0;
int p[n];
scanf("%d",&n);

for(i = 0;i < n;i++)
scanf("%d",&p[i]);

for(i = 1; i  < n-1; i++)
{
if(p[i-1]<p[i])
{
if(p[i]<p[i+1])
count ++;
}
else if(p[i-1]>p[i])
{
if(p[i]>p[i+1])
count ++;
}
}
printf("%d",count);

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 rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, l;
	cin >> n >> l;
	vi a(n);
	rep(i, n)cin >> a[i];

	int k = 0;
	rep1(i, n - 1)if (a[i - 1] + a[i] >= l)k = i;

	if (k == 0) {
		cout << "Impossible" << endl;
		return 0;
	}

	vi ans(0);

	while (k > 0) {
		ans.push_back(k);
		k--;
	}
	k = ans[0] + 1;
	while (k < n) {
		ans.push_back(k);
		k++;
	}

	cout << "Possible" << endl;
	rep(i, n - 1)cout << ans[n - 2 - i] << endl;

}

Measured memory_bytes: 1784
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = input()
    print("ABC"+n)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

vec Prime(1e7,0),W(1e7,0),isPrime(1e7+1,0);
void sosu(ll n){
  isPrime.at(0)=1;
  isPrime.at(1)=1;
  ll t=0;
  rep(i,n+1){
    if(isPrime.at(i)==0){
      Prime.at(t)=i;
      t++;
      for(ll j=2*i;j<=n;j+=i){
        isPrime.at(j)=1;
      }
    }
  }
}
void factor(ll M){
  rep(i,100000){
    if(Prime.at(i)==0){
      if(M==1) return;
      else{
        Prime.at(i)=M;
        W.at(i)++;
        M=1;
      }
    }else{
      while(M%Prime.at(i)==0){
        M/=Prime.at(i);
        W.at(i)++;
      }
    }
  }
}

int main(){
  ll N,a=0,b=0,c=0,d=0,e=0;
  cin >> N;
  sosu(N);
  rep(i,N){
    factor(i+1);
  }
  rep(i,N){
    if(Prime.at(i)!=0){
      if(W.at(i)>=2){
        a++;
      }
      if(W.at(i)>=4){
        b++;
      }
      if(W.at(i)>=14){
        c++;
      }
      if(W.at(i)>=24){
        d++;
      }
      if(W.at(i)>=74){
        e++;
      }
    }
  }
  ll ans=e+d*(a-1)+c*(b-1)+(b*(b-1)*(a-2))/2;
  cout << ans << endl;
}
          
          
        

Measured memory_bytes: 237528
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int l, r, ans, dp[62][2][2][2];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}


int calc (int b = 60, bool sp1 = 1, bool sp2 = 1, bool st = 0) {
   if (b < 0) return 1;
   int &res = dp[b][sp1][sp2][st];
   if (res != -1) return res;
   res = 0;
   for (int f1 = 0; f1 <= 1; f1 ++)
      for (int f2 = 0; f2 <= f1; f2 ++) {
         if (!st && f1 != f2) continue;
         bool is1 = ((r & (1ll << b)) > 0);
         bool is2 = ((l & (1ll << b)) > 0);
         if ((sp2 && f2 < is2) || (sp1 && f1 > is1)) continue;
         res = add (res, calc (b - 1, (sp1 & (is1 == f1)), (sp2 & (is2 == f2)), (st | f1)));     
      }                                  
   return res;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> l >> r;
   memset (dp, -1, sizeof dp);
   cout << calc ();
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 256
N = int(input())
tc_ls = []
for i in range(N):
    tc = input()
    tc_ls.append(tc)

AC = tc_ls.count("AC")
WA = tc_ls.count("WA")
TLE = tc_ls.count("TLE")
RE = tc_ls.count("RE")

print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

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

using namespace std;

struct WeightedUnionFind
{
  vector< int > data, weight;

  WeightedUnionFind(int sz) : data(sz, -1), weight(sz, 0) {}

  void unite(int x, int y, int w)
  {
    auto a = find(x), b = find(y);
    x = a.first, y = b.first;
    if(x == y) return;
    data[x] += data[y];
    data[y] = x;
    weight[y] = a.second - b.second - w;
  }

  pair< int, int > find(int k)
  {
    if(data[k] < 0) return (make_pair(k, 0));
    auto par = find(data[k]);
    data[k] = par.first;
    weight[k] = (par.second += weight[k]);
    return (par);
  }

  void diff(int a, int b)
  {
    if(find(a).first != find(b).first) cout << "UNKNOWN" << endl;
    else cout << weight[a] - weight[b] << endl;
  }
};

int main()
{
  int N, M;
  while(cin >> N >> M, N) {
    WeightedUnionFind tree(N);
    while(M--) {
      char A;
      int B, C, D;
      cin >> A >> B >> C;
      --B, --C;
      if(A == '!') {
        cin >> D;
        tree.unite(B, C, D);
      } else {
        tree.diff(B, C);
      }
    }
  }
}

Measured memory_bytes: 4500
n = gets.to_i

require 'prime'

divisors = n.prime_division.inject([1]) do |ary, (p, e)|
  (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
end.sort

def f(a,b)
  [a.to_s.size, b.to_s.size].max
end

min = 10**9

divisors.each do |d|
  break if d.to_s.size >= min
  min = [min, f(d, n / d)].min
end

puts min

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

void test(){

  vector<ll> mem(100,-1);
  mem[0]=mem[1]=mem[2]=1;
  auto f = [&](auto&& f,ll n){
    if(mem[n]!=-1)return mem[n];
    return mem[n]=n*f(f,n-2);
  };

  for(int i=0;i<20;++i){
    dump(i,f(f,i));
  }

}


std::vector<std::pair<ll,ll>> prime_factorization(ll n){
  std::vector<std::pair<ll,ll>> factor;
  for(ll p=2;p*p<=n;++p){
    if(n%p!=0)continue;
    ll num=0;
    while(n%p==0){
      num++;
      n/=p;
    }
    factor.emplace_back(p,num);
    if(n==1)return factor;
  }
  if(n!=1)factor.emplace_back(n,1);
  return factor;
}

int main(){

  ll n;
  cin>>n;

  if(n<10||(n&1)){
    cout<<(0)<<endl;
    return 0;
  }

  ll ans = 0;
  ll base = 2*5;
  while(base<=n){
    ans += n/base;
    base*=5;
  }
  cout<<(ans)<<endl;


}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    
    
    int n;
    int b=1;
    cin>>n;
    for(int i=n;3<i;i=i-7){
        if(i%4==0){
            cout<<"Yes"<<endl;
            b=0;
            break;
        }else if(i%7==0){
            cout<<"Yes"<<endl;
            b=0;
            break;
        }    }
    if(b==1){
        cout<<"No"<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
fn main() {
  let (n, m): (usize, usize) = read_tuple();
  let edges: Vec<(usize, usize)> = read_tuples(m);

  let mut graph: Vec<Vec<usize>> = vec![vec![]; n+1];
  for (v,w) in edges {
    graph[v].push(w);
    graph[w].push(v);
  }

  match is_bipartite(&graph) {
    (p, _) if !p     => {println!("{}", n * (n-1) / 2 - m)},
    (_, Some((b,w))) => {println!("{}", b*w - m)},
    _ => unreachable!()
  }
}

fn is_bipartite(g: &Vec<Vec<usize>>) -> (bool, Option<(usize, usize)>) {
  fn dfs(v: usize, p: bool, g: &Vec<Vec<usize>>, cv: &mut Vec<Option<bool>>) -> bool {
    match cv[v] {
      None => {
        let next = &g[v];
        cv[v] = Some(p);
        next.iter().all(|&w|dfs(w,!p,g,cv))
      },
      Some(q) if q == p => {true},
      Some(q) if q != p => {false},
      _ => unreachable!()
    }
  }

  let mut canvas: Vec<Option<bool>> = vec![None; g.len()];
  let ans = dfs(1, false, g, &mut canvas);
  let b = canvas.iter().filter(|&&v|v==Some(false)).count();
  let w = canvas.iter().filter(|&&v|v==Some(true)).count();
  (ans, if ans {Some((b,w))} else {None})
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn read_tuples<T1: std::str::FromStr, T2: std::str::FromStr>(n: usize) -> Vec<(T1, T2)> {
  let mut vec: Vec<(T1, T2)> = vec![];
  for _ in 0 .. n {
    vec.push(read_tuple());
  }
  vec
}


Measured memory_bytes: 12796
import java.util.Scanner;

class Main {
  public static final int INF = 999999999;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int time = sc.nextInt();
    int[] p = new int[time+1];
    p[0] = sc.nextInt();
    for (int i = 1; i < time; i++) {
      p[i] = sc.nextInt();
      sc.nextInt();
    }
    p[time] = sc.nextInt();
    System.out.println(matrixChainOrder(p));
  }

  public static int matrixChainOrder(int[] p) {
    int n = p.length - 1;
    int[][] m = new int[n+1][n+1];

    for (int i = 1; i <= n; i++) {
      m[i][i] = 0;
    }

    for (int l = 2; l <= n; l++) {
      for (int i = 1; i <= n - l + 1; i++) {
        int j = i + l - 1;
        m[i][j] = INF;

        for (int k = i; k <= j - 1; k++) {
          int q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
          if (q < m[i][j]) {
            m[i][j] = q;
          }
        }
      }
    }

    return m[1][n];
  }
}



Measured memory_bytes: 26492
fun main(args: Array<String>) {
    abc100b()
}

fun abc100b() {
    val (d, n) = readLine()!!.split(" ").map { it.toInt() }

    val pow = Math.pow(100.toDouble(), d.toDouble()).toInt()

    println(if (n == 100) pow * 101 else pow * n)
}


Measured memory_bytes: 37728
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K;
	cin >> K;
	if (K % 2 == 1) {
		int temp = (K + 1) / 2;
		cout << temp*(K -temp) << endl;
		return 0;
	}
	else {
		cout << (K / 2)*(K / 2) << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int T,n,m;
	scanf("%d",&T);
      if(0<=T<100){
    	m=T%10;
    	if(m==2||m==4||m==5||m==7||m==9) printf("hon");
		if(m==0||m==1||m==6||m==8) printf("pon");
		if(m==3) printf("bon");
	} 
	else{
		n=T%100;
    	m=n%10;
    	if(m==2||m==4||m==5||m==7||m==9) printf("hon");
		if(m==0||m==1||m==6||m==8) printf("pon");
		if(m==3) printf("bon");
	}
	return 0;
} 

Measured memory_bytes: 1732
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int X = scan.nextInt();

        int C[] = new int[N];
        int A[][] = new int[N][M];

        for (int i = 0; i < N; i++) {
            C[i] = scan.nextInt();
            for(int j = 0; j < M; j++) {
                A[i][j] = scan.nextInt();
            }
        }

        int ans = Integer.MAX_VALUE;

        for(int bit = 0; bit < (1 << N); bit++) {
            //初期化
            int sum[] = new int[M];
            int cost = 0;

            for (int i = 0; i < N; ++i) {
                if ((bit & (1<<i)) > 0) { // 列挙に i が含まれるか
                    cost += C[i];
                    for(int j = 0; j < M; j++) {
                        sum[j] += A[i][j];
                    }
                }
            }
            //判定
            boolean isSatisfy = true;
            for(int i = 0; i < M; i++) {
                if(sum[i] < X){
                    isSatisfy = false;
                    break;
                }
            }

            if(isSatisfy){
                ans = Math.min(ans, cost);
            }
        }

        if(ans == Integer.MAX_VALUE)
            os.println(-1);
        else
            os.println(ans);
    }


}

Measured memory_bytes: 28356
#include<bits/stdc++.h>
using namespace std;
string s,a="dream",b="dreamer",c="erase",d="eraser";
int check(int x)
{
	bool flag=1;
	for(int i=0;i<a.length();i++)
	{
		if(s[x+i]!=a[i])flag=0;
	}
	if(flag)return x+a.length();
	
	flag=1;
	for(int i=0;i<b.length();i++)
	{
		if(s[x+i]!=b[i])flag=0;
	}
	if(flag)return x+b.length();
	
	flag=1;
	for(int i=0;i<c.length();i++)
	{
		if(s[x+i]!=c[i])flag=0;
	}
	if(flag)return x+c.length();
	
	flag=1;
	for(int i=0;i<d.length();i++)
	{
		if(s[x+i]!=d[i])flag=0;
	}
	if(flag)return x+d.length();
	return -1;
}
int main()
{
	cin>>s;
	reverse(s.begin(),s.end());
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	reverse(c.begin(),c.end());
	reverse(d.begin(),d.end());
	for(int i=0;i<s.length();)
	{
		int nx=check(i);
		if(nx==-1){return puts("NO"),0;}
		else i=nx;
		if(i==s.length()-1)break;
	}
	puts("YES");
}

Measured memory_bytes: 512
import sys
import math
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N,K = na()
result=0
for b in range(1,N+1):
    p = N//b
    r = N%b
    result+=p*max(0,b-K)
    result+=max(0,r+1-K)
    if(K==0):
        result-=1

print(result)

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    string s;
    cin>>s;
    int m,y;
    m=(s[0]-'0')*10+(s[1]-'0');
    y=(s[2]-'0')*10+(s[3]-'0');
    if(m>=1&&m<=12&&y<=12&&y>=1)
    {
        cout<<"AMBIGUOUS";
        return 0;
    }
    else if(m>=1&&m<=12)
    {
        cout<<"MMYY";
        return 0;
    }
    else if(y>=1&&y<=12)
    {
        cout<<"YYMM";
        return 0;
    }
    else
        cout<<"NA";
    return 0;
}

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

int main()
{
     int x;
     cin>>x;
     int res;
     if(x>=400 && x<=599)
        res=8;
    else if(x<800)
        res=7;
    else if(x<1000)
        res=6;
    else if(x<1200)
        res=5;
    else if(x<1400)
        res=4;
    else if(x<1600)
        res=3;
    else if(x<1800)
        res=2;
    else if(x<2000)
        res=1;

    cout<<res;
    return 0;
}



 

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int ans;
int main(){
	int n1, n2; int a[10100],  q[501];
	int i; int j;
	cin >> n1;
	for(i=0;i<n1;i++){
		scanf("%d", &a[i]);
	}
	cin >> n2;
	for(i=0;i<n2;i++){
		scanf("%d", &q[i]);
	}
#ifdef DBG
	cout << i << endl; 
#endif
	for(j=0;j<n2;j++){
		for(i=0;i<n1;i++){
			if(q[j]==a[i]){
				ans++;
				break;
			}
#ifdef DBG
	cout << ans << j << i << endl; 
#endif
		}
	}
	cout << ans <<endl;
}



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

int main(){
    ll n;
    cin >> n;
    double a[n];
    for(ll i =0; i < n; i++){
        cin >> a[i];
    }
    double dp[n + 1][n + 1];
    for(ll i= 0; i < n + 1; i++){
        for(ll j = 0; j < n + 1; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1 - a[0];
    dp[0][1] = a[0];
    for(ll i = 1; i < n; i++){
        dp[i][0] = (1 - a[i]) * dp[i - 1][0];
    }
    for(ll i =1; i < n; i++){
        for(ll j = 1; j <= i + 1; j++){
            dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1 - a[i]);
        }
    }
    double ans = 0;
    for(ll i = (n + 2)/2; i <= n; i++){
        ans += dp[n - 1][i];
    }
    cout << setprecision(10) << ans << endl;
    // for(ll i = 0; i < n; i++){
    //     for(ll j = 0; j <= i + 1; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 70528
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    a1=0
    a2=0
    if n<=k:
        a1=n
    else:
        a1=k
        a2=n-k


    print(a1*x+a2*y)


Measured memory_bytes: 3828
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int P[N];
    for(int i=0;i<N;i++)
    cin>>P[i];
    int Q=0;
    for(int i=1;i<N-1;i++)
    {
        if(P[i-1]<P[i] && P[i]<P[i+1]){
            Q++;
        }
        if(P[i-1]>P[i] && P[i]>P[i+1]) 
        {
           Q++;
        }
    }
    cout<<Q;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,L;
vpint lis[40];

int dp[45][45];

signed main(){
    cin>>N>>M>>L;
    rep(i,M){
        int d,a,k,t;
        cin>>d>>a>>k>>t;
        a--;
        lis[d*N+a].pb(pint(k,t));
    }

    for(int i=0;i<5*N;i++){
        for(int j=0;j<=L;j++){
            chmax(dp[i+1][j],dp[i][j]);
            for(int k=0;k<lis[i].size();k++){
                int l,v;
                tie(l,v)=lis[i][k];
                if(j<L){
                    chmax(dp[i+l][j+1],dp[i][j]+v);
                }
            }
        }
    }
    cout<<dp[5*N][L]<<endl;
    return 0;
}

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

int main()
{
    ll n, ac=0, wa=0, tle=0, re=0;
    cin>>n;
    string s;
    for(int i=0; i<n; i++){
        cin>>s;
        if(s=="AC") ac++;
        if(s=="WA") wa++;
        if(s=="TLE") tle++;
        if(s=="RE") re++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re;
}


Measured memory_bytes: 3508