akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
//        out.flush();
        System.out.println(main.solve());
    }
    long solve() throws IOException{
        int H = sc.nextInt(), W = sc.nextInt();
        char[][] grid = new char[H][];
        for(int i=0;i<H;i++){
            grid[i] = sc.next().toCharArray();
        }
        int[][] dp = new int[H][W];
        for(int i=0;i<H;i++) Arrays.fill(dp[i],1000000);
        dp[0][0] = grid[0][0]=='.'?0:1;
        for(int r=0;r<H;r++){
            for(int c=0;c<W;c++){
                if(r>0){
                    //check from above
                    int temp = dp[r-1][c];
                    if(grid[r][c]=='#'&&grid[r-1][c]=='.') temp++;
                    dp[r][c] = Math.min(dp[r][c],temp);
                }
                if(c>0){
                    // check from left
                    int temp = dp[r][c-1];
                    if(grid[r][c]=='#'&&grid[r][c-1]=='.') temp++;
                    dp[r][c] = Math.min(dp[r][c],temp);
                }
            }
        }
        return dp[H-1][W-1];
    }
}



Measured memory_bytes: 23172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int a, b;
  cin >> a >> b;
  if(a - 2*b > 0)
    cout << a - 2*b;
  else 
    cout << 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var hs = new HashSet<int>();
        var up3200 = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] >= 3200) up3200++;
            else hs.Add(a[i] / 400);
        }
        var count = hs.Count();
        var maxcolor = up3200 + count;
        int mincolor;
        if (count == 0) mincolor = 1;
        else mincolor = count;
        Console.WriteLine("{0} {1}", mincolor, maxcolor);
    }
}

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e3 + 3;

vector < pp > V[N],U[N];
vector < int > Y[N]; 
int D[N],low[N],zaman,H[N],Scc[N],scc,T[N],ans[N*200],n,m,x,y,i,X;
stack < int > S;

void f(int x){
    D[x] = low[x] = ++zaman;
    S.push(x); H[x] = 1;
    for(auto t : V[x]){
        int y = t.st;
        if(y == X) continue;
        if(!D[y]){ f(y); low[x] = min(low[x] , low[y]); }
        else if(H[y]) low[x] = min(low[x] , D[y]); 
    }
    
    if(low[x] == D[x]){
        scc++;
        for(int y = 0; y != x;){
            y = S.top();
            S.pop();
            H[y] = 0;
            Scc[y] = scc;
            Y[scc].pb(y);
        }        
    }
}

void g(int x){
    X = x;
    int i;
    memset(D , zaman=0 , sizeof D);
    memset(Scc , scc=0 , sizeof Scc);
    for(i=1;i<=n;i++) { Y[i].clear(); U[i].clear(); }
    for(i=1;i<=n;i++) if(i != X && !D[i]) f(i);
    if(x == 0){
        for(i=1;i<=n;i++) T[i] = Scc[i];
        return;
    }

    memset(D , 0 , sizeof D);
    for(auto t : V[X]){
        U[ Scc[t.st] ].pb(t);
    }
    for(i=scc; i ;i--){
        if(!D[i] && U[i].size() == 0) continue;
        if(D[i] || U[i].size() > 1){
            for(auto t : U[i]){
                ans[t.nd] = T[X] == T[t.st];
            }
        }
        else { for(auto t : U[i]) ans[t.nd] = T[X] != T[t.st]; }
        
        for(auto x : Y[i]){
            for(auto y : V[x])
                D[ Scc[y.st] ] = 1;    
        }
    }
}

signed main(){
    cin >> n >> m;
    for(i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        V[x].pb(mp(y,i));
    }
    
    for(i=0;i<=n;i++) g(i);
    for(i=1;i<=m;i++) puts(ans[i] ? "same" : "diff");
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll k,n,a[200005];
int32_t main(){
CODE_START;
cin>>k>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    a[i]++;
}
ll ans=1e18;
for(ll i=0;i<n;i++)
{
ans=min(ans,a[i]+k-a[i+1]);
}
ll s1=0;
for(ll i=0;i<n;i++)
{
    a[i]--;
}
for(ll i=1;i<n;i++)
    s1=s1+a[i]-a[i-1];
ans=min(ans,s1);
if(a[0]==0){
    s1=0;
    for(ll i=2;i<n;i++)
        s1=s1+a[i]-a[i-1];
    s1=s1+k-a[n-1];
    ans=min(ans,s1);
}
cout<<ans<<endl;
}


Measured memory_bytes: 1792
def c(S, a):
    return S.count(a)


S = input()
n, w, s, e = c(S, 'N'), c(S, 'W'), c(S, 'S'), c(S, 'E')
if ((n > 0 and s == 0) or (s > 0 and n == 0)):
    print('No')
elif ((w > 0 and e == 0) or (e > 0 and w == 0)):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>

namespace n91 {
bool solve() {
  usize h, w, n;
  std::cin >> h >> w >> n;
  usize x, y;
  std::cin >> x >> y;
  --x;
  --y;
  std::string s, t;
  std::cin >> s >> t;

  usize u = 0, d = h;
  for (const auto i : revrep(0, n)) {
    if (t[i] == 'U') {
      if (d != h) {
        ++d;
      }
    }
    if (t[i] == 'D') {
      if (u != 0) {
        --u;
      }
    }
    if (s[i] == 'U') {
      if (u != h) {
        ++u;
      }
    }
    if (s[i] == 'D') {
      if (d != 0) {
        --d;
      }
    }
    if (d <= u) {
      return false;
    }
  }
  if (x < u || d <= x) {
    return false;
  }

  usize l = 0, r = w;
  for (const auto i : revrep(0, n)) {
    if (t[i] == 'L') {
      if (r != w) {
        ++r;
      }
    }
    if (t[i] == 'R') {
      if (l != 0) {
        --l;
      }
    }
    if (s[i] == 'L') {
      if (l != w) {
        ++l;
      }
    }
    if (s[i] == 'R') {
      if (r != 0) {
        --r;
      }
    }
    if (r <= l) {
      return false;
    }
  }
  if (y < l || r <= y) {
    return false;
  }

  return true;
}

void main_() { std::cout << (solve() ? "YES" : "NO") << std::endl; }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define sz(a) int(a.size())
#define pb(x) push_back(x);
#define ll long long
#define ii pair<ll,ll>
#define Long long long
#define MAX_N 3
#define MOD 1000000007

int main() {
    /*
    int n;cin>>n;
    vector<ii>a(n);
    for(auto x:a)cin>>x.first>>x.second;

    sort(a.begin(),a.end());
    long double total = 0;
    ll c = 0;
    do{
        for(int i = 0;i <n-1;i++,c++){
            ll dx = a[i].first-a[i+1].first;
            ll dy = a[i].second-a[i+1].second;
            total += sqrt(dx*dx+dy*dy);
        }
    }while(next_permutation(a.begin(),a.end()));
    cout<<total/c;*/
    int r;cin>>r;
    cout<<r*r;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,q = LI()
    sa = [-inf,-inf] + [I() for _ in range(a)] + [inf, inf]
    ta = [-inf,-inf] + [I() for _ in range(b)] + [inf, inf]
    xa = [I() for _ in range(q)]
    r = []
    for x in xa:
        si = bisect.bisect_left(sa, x)
        ti = bisect.bisect_left(ta, x)
        l = sa[si-1]
        k = x - l
        ti2 = bisect.bisect_left(ta, l)
        t = inf
        if ti2 > 0 and t > k + l - ta[ti2-1]:
            t = k + l - ta[ti2-1]
        if t > k + ta[ti2] - l:
            t = k + ta[ti2] - l
        l = sa[si]
        k = l - x
        ti2 = bisect.bisect_left(ta, l)
        if ti2 > 0 and t > k + l - ta[ti2-1]:
            t = k + l - ta[ti2-1]
        if t > k + ta[ti2] - l:
            t = k + ta[ti2] - l

        l = ta[ti-1]
        k = x - l
        si2 = bisect.bisect_left(sa, l)
        if si2 > 0 and t > k + l - sa[si2-1]:
            t = k + l - sa[si2-1]
        if t > k + sa[si2] - l:
            t = k + sa[si2] - l
        l = ta[ti]
        k = l - x
        si2 = bisect.bisect_left(sa, l)
        if si2 > 0 and t > k + l - sa[si2-1]:
            t = k + l - sa[si2-1]
        if t > k + sa[si2] - l:
            t = k + sa[si2] - l


        r.append(t)

    return JA(r, "\n")

print(main())





Measured memory_bytes: 126936
#include<stdio.h>
#include<math.h>
int main(){

  int x,h;
  double dx,dh;;
  while(scanf("%d\n%d",&x,&h)!=EOF){
    if(x==0&&h==0) break;
    dx=(double)x;
    dh=(double)h;
    printf("%.6lf\n",
	   dx*dx+4.0*(sqrt(dx*dx/4.0+dh*dh)*dx/2.0));
  }
 return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

int main() {

    int N;
    cin >> N;
    ll ans = 1;

    auto spf = smallest_prime_factors(N);

    for (int i = 2; i <= N; i++){
    	int temp = i;
    	int before = spf[temp];
    	int coun = 1;
    	ll yaku = 1;
    	while (temp != 1){
    		temp /= spf[temp];
    		if (before == spf[temp]){
    			coun++;
    		}else{
    			yaku *= (coun+1);
    			before = spf[temp];
    			coun = 1;
    		}
    	}
    	ans += i*yaku;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42308
#include<iostream>

using namespace std;

string check(string seq){
    for(int i =0; i<seq.size() ; i++)
    {

        if((i+1) % 2 != 0 )
        {
            if(seq[i] != 'R' && seq[i] != 'U' && seq[i] != 'D')
                return "No";

        }
        else{
            if(seq[i] != 'L' && seq[i] != 'U' && seq[i] != 'D')
                return "No";


        }
    }
    return "Yes";
}


int main(){
string seq;
cin>>seq;
cout<<check(seq);

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
#include<numeric>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind tree(n);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		tree.unite(x, y);
	}
	int an = 0;
	for (int i = 0; i < n; i++) {
		if (tree.root(i) == i)an++;
	}
	cout << an << endl;
}



Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const ll mod = 1000000007;

ll ka[2000010];

ll c(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod*mod_pow(ka[y], mod - 2, mod) % mod;
}

ll n;
ll cum[20];
string ans;

signed main() {
	cin >> n;
	int cnt = 0;
	for (ll i = 1; i <= 1000000000000000001; i *= 26) {
		cnt++;
		cum[cnt] = cum[cnt - 1] + i;
	}
	for (ll i = 12; i >= 0; i--) {
		if (n < (ll)pow(26, i) + cum[i])continue;
		int p = (n - cum[i]) / (ll)pow(26, i);
		ans += 'a' + p - 1;
		n -= p * (ll)pow(26, i);
	}
	cout << ans << endl;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string s[3];

main() {
    rep(i,3) cin >> s[i];
    printf("A%cC",s[1][0]);
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
	
	int i,j;
	char Masu[4][4];
	
	for( i=0; i<3; i++ ){
		for( j=0; j<3; j++ ){
			if( i != 0 && j == 0 ){
				scanf("%*c%c", &Masu[i][j]);
			} else {
				scanf("%c", &Masu[i][j]);
			}
		}
	}
	printf( "%c%c%c\n", Masu[0][0],Masu[1][1],Masu[2][2] );
	return 0;
}
 

Measured memory_bytes: 2064
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int r = fr.nextInt(), D = fr.nextInt(), x = fr.nextInt();
        for (int i = 0; i < 10; i++) {
            x = r * x - D;
            System.out.println(x);
        }
    }
}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException  e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 32728
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

ll f(ll x){
    if(x==1) return 1;
    else{
        ll a = f(x/2);
        return 2*a+1;
    }
}

int main(){
    ll h; cin >> h;
    cout << f(h) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;

int main() {
	cin >> S;
	S[5] = S[13] = ' ';
	cout << S << endl;
}

Measured memory_bytes: 764
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){

	string s;
	cin >> s;

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

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 256
x,y = map(int,input().split())
"""
1zi houteisiki
2a+2b = 2x
2a+4b = y
2b = y-2x
2a = 4x-y
"""
if (y-2*x) % 2 == 0 and (4*x-y) % 2 == 0 and y-2*x >= 0 and 4*x-y >= 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9172
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	char c;
	cin >> c;
	cout << (char)(c + 1);
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int f(int x) {
	int s = 0;
	while(x) { s += x % 10; x /= 10; }
	return s;
}

int main() {
	cin >> n;
	
	int ans = f(1) + f(n - 1);
	incII(a, 1, n - 1) {
		int b = n - a;
		setmin(ans, f(a) + f(b));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    string s; cin >> s;
    int i = 0;
    vector<string> use;
    while (i < s.size()) {
        string tmp = s.substr(i, 6);
        if(tmp == "eraser") {
            i += 6;
            use.push_back(tmp);
            continue;
        }
        tmp = s.substr(i, 7);
        if(tmp == "dreamer") {
            i += 7;
            use.push_back(tmp);
            continue;
        }
        tmp = s.substr(i, 5);
        if(tmp == "dream" || tmp == "erase") {
            i += 5;
            use.push_back(tmp);
            continue;
        }
        if(use.size() > 0 && use[use.size()-1].size() > 5) {
            i -= use[use.size()-1].size();
            tmp = s.substr(i, 5);
            use[use.size()-1] = tmp;
            i += 5;
        } else {
            cout <<  "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 1408
N = int(input())
Inp = list()
for i in range(N):
    x , l = list(map(int,input().split()))
    Inp.append([x-l,x+l])
# 右腕を基準にソートする
robots = sorted(Inp, key=lambda x: x[1])
# print(robots)

ans = 0
now = -float('inf')
for left,right in robots:
    if left >= now:
        ans += 1
        now = right

print(ans)

Measured memory_bytes: 22568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  while (cin >> S) {
    bool res = S[2] == S[3] && S[4] == S[5];
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>


int count_divisors(int a, int b, int c) {
  // output the number of divisors of `c' between `a' and `b'.
  int count = 0;

  for (int i = a; i <= b; i ++) {
    if (c % i == 0) {
      count += 1;
    }
  }

  return count;
}

int main() {

  int a, b, c;

  std::cin >> a >> b >> c;

  std::cout << count_divisors(a, b, c) << std::endl;

  return 0;
}


Measured memory_bytes: 3112
/*
g++ -std=c++11 -o2 -Wall ABC105B.cpp -o ./out/ABC105B.out
./out/ABC105B.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      if (n == 4 * i + 7 * j) flag = true;
    }
  }
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%s\n",(a<=8 && b<=8)?"Yay!":":(");
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  
  int np = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'p') {
      np++;
    }
  }
  
  cout << s.size() / 2 - np << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
void solve()
{   
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int n;
    cin>>n;
    ll a[n];
    ll t = 0;
    unordered_map<ll,ll> m;
    fi(i,0,n)
        {cin>>a[i];
         t+=a[i];
         m[a[i]]++;}
    int q;
    cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        t-=x*m[x];
        t+=y*m[x];
        m[y]+=m[x];
        m[x] = 0;
        cout<<t<<"\n";
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    return 0;
}


Measured memory_bytes: 7852
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main() 
{
	int x,a,b,c;
	int ans=0;
	cin>>a>>b>>c>>x;
	for (int i=0;i<=a&&500*i<=x;i++)
    {
        for (int j=0;j<=b&&100*j+500*i<=x;j++)
        {
            for (int k=0;k<=c&&50*k+100*j+500*i<=x;k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
t=0
x=0
y=0
ans = "Yes"
(N=gets.to_i).times do
	dt,dx,dy=gets.split.map(&:to_i)
	diff = (dx-x).abs + (dy-y).abs
	if (diff+dt-t).odd? || diff>(dt-t)
		ans = "No"
		break
	end
	t = dt
	x = dx
	y = dy
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y,z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

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

bool isTriangle(int a, int b, int c) {
  if (a >= b + c || b >= c + a || c >= a + b) {
    return false;
  } else {
    return true;
  }
}

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

  vector<int> l(n);
  rep (i, n) cin >> l[i];

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

  int ans = 0;
  for (int a = 0; a < n - 1; a++) {
    for (int b = a + 1; b < n - 1; b++) {
      for (int c = b + 1; c < n; c++) {
        if (isTriangle(l[a], l[b], l[c])) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[5]={};
	FOR(i,0,5)cin>>a[i];
	int ans=mod;
	FOR(i,0,5){
		int t=0;
		t+=a[i];
		FOR(j,0,5){
			if(i==j)continue;
			t+=(a[j]+9)/10*10;
		}
		ans=min(ans,t);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
lp=list(map(int,input().split()))
maxsum=sum(lp[:K])
befsum=maxsum
for i in range(1,N-K+1):
    tmpsum=befsum-lp[i-1]+lp[i+K-1]
    if tmpsum>maxsum:
        maxsum=tmpsum
    befsum=tmpsum
print((maxsum+K)/2)


Measured memory_bytes: 24804
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define nmax 410

int n;
int a[nmax];
ll pSum[nmax], dp[nmax][nmax];

ll sum(int l, int r)
{
    return pSum[r] - pSum[l - 1];
}

ll compute(int l, int r)
{
    if (l > r) return 0;
    if (l == r) return 0;

    if (dp[l][r] != LL_INF) return dp[l][r];

    for (int i = l; i < r; i++) 
        dp[l][r] = min(dp[l][r], compute(l, i) + compute(i + 1, r) + sum(l, r));

    return dp[l][r];
}

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

    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    for (int i = 1; i <= n; i++) pSum[i] = pSum[i - 1] + a[i];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dp[i][j] = LL_INF;

    printf("%lld\n", compute(1, n));

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<numeric>
#include<string>
#define REP(i,n) for(int (i)=0;(i) < (n);(i)++)
using namespace std;

int main(){
  double x,y;
  double s;
  cin >> x >> y;
  if(y-x>180){
    s = (360 - (y-x))/2;
    if (y+s>360) printf("%f\n",y+s-360);
    else printf("%f\n",y+s);
  }
  else if(y-x>=0){
    s = (y-x)/2;
    if (x+s>360) printf("%f\n",x+s-360);
    else printf("%f\n",x+s);
  }
  else if(x-y>=180){
    s = (360 - (x-y))/2;
    if (x+s>360) printf("%f\n",x+s-360);
    else printf("%f\n",x+s);
  }
  else{
    s = (x-y)/2;
    if (y+s>360) printf("%f\n",y+s-360);
    else printf("%f\n",y+s);
  }



  return 0;
}


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

int main() {
  int N, M, sum;
  cin >> N >> M;
  sum = 0;
  for(int i = 0; i<M;i++){
    int a = 0;
    cin >> a;
    sum = sum + a;
  }
  if((N-sum)>=0){
    cout << N - sum;
  }
  else{
    cout << -1;
  }
}
 
  




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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_bacn
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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 main()
{
	fast;
	int h, n;
	cin >> h >> n;
	// min magic point
	vll dp(h + 1, 1e8 + 1);
	dp[0] = 0;
	FOR(n)
	{
		int health, magic;
		cin >> health >> magic;
		for (int j = 0; j <= h; j++)
			chmin(dp[j], dp[max(0, j - health)] + magic);
	}
	cout << dp[h];
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int N, M;
long long A[100010]; 
bool seen[100010]; 
vector<int> E[100010]; 
vector<int> C[100010]; 
void dfs(int now, int parent, int &id){
	seen[now] = true; 
	C[id].push_back(A[now]); 
	for(int i = 0; i < E[now].size(); i++){
		if(E[now][i] == parent) continue; 
		dfs(E[now][i], now, id); 
	}
}
int main(){
	cin >> N >> M; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	for(int i = 0; i < M; i++){
		int x, y; cin >> x >> y; 
		E[x].push_back(y); E[y].push_back(x); 
	}
	int id = 0; 
	for(int i = 0; i < N; i++){
		if(seen[i]) continue;
		id ++; 
		dfs(i, -1, id);  
	}
	long long ans = 0; 
	priority_queue<long long, vector<long long>, greater<long long>> que;  
	for(int i = 1; i <= id; i++){
		sort(C[i].begin(), C[i].end()); 
		ans += C[i][0]; 
		for(int j = 1; j < C[i].size(); j++) que.push(C[i][j]); 		
	}
	if(N > 2 * M + 2){
		cout << "Impossible" << endl; return 0; 
	}
	if(N == M + 1){
		cout << 0 << endl; return 0; 
	}
	for(int i = 0; i < 2 * (N-M-1) - id; i++){
		long long a = que.top(); 
		ans += a; que.pop(); 
	}
	cout << ans << endl; 
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main(void)
{
    const int H_MAX = 100;
    const int W_MAX = 8;
    int H, W, K;
    cin >> H >> W >> K;
    --K;
    ll dp[H_MAX + 1][W_MAX];
    REP(w, 8) dp[0][w] = (w == 0);
    ll f[W_MAX + 1];
    f[0] = 0;
    f[1] = 1;
    FOR(i, 2, W_MAX + 1) f[i] = f[i - 1] + f[i - 2];
    int dl[] = {-1, 0, 0};
    int dr[] = {0, 0, -1};
    FOR(h, 1, H + 1) {
        REP(k, W) {
            ll temp = 0;
            REP(i, 3) {
                int left = k + dl[i];
                int right = W - k - 1 + dr[i];
                if (left < 0 || right < 0) {
                    continue;
                }
                temp += dp[h - 1][k + i - 1] * f[left + 1] % MOD * f[right + 1] % MOD;
            }
            dp[h][k] = temp % MOD;
        }
    }
    cout << dp[H][K] << endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const ll MOD = 1e9 + 7;

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

const int N = 5100;

int n, a, b;

ll dp[N][2];
ll dp2[N][2];

void add(ll& a, ll b) {
	a = (a + b) % MOD;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n >> a >> b;
	if (a < b) {
		swap(a, b);
	}

	dp2[0][0] = 1;
	
	for (int i = 0; i < n; ++i) {
		add(dp2[i + 1][0], dp2[i][0]);
		add(dp2[i + 1][0], dp2[i][1]);
		add(dp2[i + 1][1], dp2[i][1]);
		if (i + b <= n) {
			add(dp2[i + b][1], dp2[i][0]);
		}
	}

	dp[0][0] = 1;
	dp[0][1] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= b - 1 && i + j <= n; ++j) {
			add(dp[i + j][1], dp[i][0]);
		}

		for (int j = 1; j < a && i + j <= n; ++j) {
			int len = j;
			if (i != 0) {
				len -= 1;
			}
			if (i + j != n) {
				len -= 1;
			}
			len = max(len, 0);

			add(dp[i + j][0], dp[i][1] * (dp2[len][0] + dp2[len][1]));
		}
	}

	ll sm = (dp[n][0] + dp[n][1]) % MOD;
	ll ans = pw(2, n) - sm;
	ans %= MOD;
	if (ans < 0) {
		ans += MOD;
	}
	cout << ans << "\n";

	return 0;
}




Measured memory_bytes: 3812
N = int(input())
S = [int(input()) for _ in range(N)]
sum_s = sum(S)
if sum_s % 10 != 0:
    print(sum_s)
else:
    ans = [sum_s - S[i] for i in range(N) if (sum_s - S[i]) % 10 != 0]
    print(max(ans,default=0))



Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll H, W, d;
char mp[2010][2010];
char ans[510][510];
void solve(){
  cin >> H >> W >> d;
  rep(i, 2010)rep(j, 2010)if(!((i+j)%2)){
    if(i/d%2 && j/d%2) mp[i][j] = 'R';
    if(i/d%2 && !(j/d%2)) mp[i][j] = 'Y';
    if(!(i/d%2) && j/d%2) mp[i][j] = 'G';
    if(!(i/d%2) && !(j/d%2)) mp[i][j] = 'B';
  }

  rep(i, H)rep(j, W){
    ans[i][j] = mp[i+j+500][i-j+500];
  }
  rep(i, H){
    rep(j, W){
      cout << ans[i][j];
    }
    cout << endl;
  }
}


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


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

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

	return 0;
}



Measured memory_bytes: 6664
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

  if(b == 0)
    return a;
  else return gcd(b,a%b);
}


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}

int main(){

 long long n,k,x,y;
 cin>>n;
 cin>>k;
 cin>>x;
 cin>>y;

 if(n<=k)
    cout<<n*x<<endl;
 else if(n>k)
    cout<<k*x+(n-k)*y<<endl;


return 0;
}


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

struct ST {
  int x, y;
  double angle;
};
bool operator<(const ST& a, const ST& b){
  return a.angle < b.angle;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0){
      ;
    }else{
      double angle = atan2(y,x);
      v.push_back((ST){x,y,angle});
    }
  }
  sort(ALLOF(v));

  double ret = 0;
  int M = v.size();
  rep(i,M){
    ll X = 0, Y = 0;
    rep(j,M){
      X += v[(i+j)%M].x;
      Y += v[(i+j)%M].y;
      double dist = sqrt(X*X+Y*Y);
      ret = max(ret, dist);
    }
  }

  printf("%.12lf\n", ret);
  
  return 0;
}


Measured memory_bytes: 256