akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){

	int N,i,count=0;
	scanf("%d",&N);
	char s[N];
	scanf("%s",s);

	for(i=0;i<=N;i++){
		if(s[i]=='A'){
			if(s[i+1]=='B'){
				if(s[i+2]=='C'){
					count=count+1;
				}
			}
		}
	}
	printf("%d",count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 100003, M = N << 1;

int n, k;
int a[N], b[N];
int tot, head[N], ver[M], nxt[M];
char s[N];

inline void add(int u, int v)
{
    ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

LL fac5[N];

int main()
{
    n = gi();
    LL now = 1;
    for (int i = 1; i <= 20000; i+=1) 
    {
        now = 1;
        for (int j = 1; j <= 5; j+=1) now *= (i - 7778);
        fac5[i] = now;
    }
    for (int i = -7777; i <= 7777; i+=1)
        for (int j = -7777; j <= 7777; j+=1)
            if (fac5[i + 7778] - fac5[j + 7778] == n)
            {
                printf("%d %d\n", i, j);
                return 0;
            }
    return 0;
}

Measured memory_bytes: 3912
# frozen_string_literal: true

N = gets.to_i
H = gets.split.map(&:to_i)

count = 0
max = 0

(N - 1).times do |i|
  if H[i] < H[i + 1]
    max = count if max < count
    count = 0
  else
    count += 1
  end
end

puts max < count ? count : max

Measured memory_bytes: 8580
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int H, W;
    scanf("%d%d", &H, &W);
    vector<int> a(H), b(H);

    map<int, int> z;
    int i;
    for (i = 0; i < W; i++) {
        z[i] = 0;
    }
    map<int, int> cnt;
    cnt[0] = W;

    vector<int> ans;
    for (i = 0; i < H; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        auto it0 = z.lower_bound(a);
        auto it1 = z.lower_bound(b+1);
        set<int> dd;
        int tmp = INF;
        while (it0 != it1) {
            dd.insert(it0->first);
            int tmp0 = b + 1 - (it0->first) + it0->second;
            tmp = MIN(tmp, tmp0);
            it0++;
        }
        if (it1!=z.end() && it1->first == b + 1) {
            tmp = MIN(tmp, it1->second);
        }
        if (b + 1 < W && tmp<INF) {
            auto it5 = z.find(b + 1);
            if (it5 != z.end()) {
                cnt[it5->second]--;
                if (cnt[it5->second] == 0) {
                    cnt.erase(it5->second);
                }
            }
            z[b + 1] = tmp;
            cnt[tmp]++;
        }
        auto it2 = dd.begin();
        for (; it2 != dd.end(); ++it2) {
            int tmp = *it2;
            auto it8 = z.find(tmp);
            assert(it8 != z.end());
            int tmp2=it8->second;
            cnt[tmp2]--;
            if (cnt[tmp2] == 0) {
                cnt.erase(tmp2);
            }
            z.erase(tmp);
        }

        if(0){
            auto it = z.begin();
            for (; it != z.end(); ++it) {
                printf("(%d %d)", it->first, it->second);
            }
            printf("\n");
        }
        if (cnt.empty()) {
            ans.push_back(-1);
        }
        else {
            auto it7 = cnt.begin();
            ans.push_back(it7->first);
        }
    }
    for (i = 0; i < H; i++) {
        if (ans[i] >= W || ans[i]<0) {
            printf("-1\n");
        }
        else {
            printf("%d\n", 1+ i + ans[i]);
        }
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



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

int main()
{
  int n;
  cin >> n;
  int64_t a[n];
  for (auto &i : a)
  {
    cin >> i;
  }
  map<int64_t, int64_t> m;
  int64_t dp[n + 1]{};
  for (int i = 0; i < n; i++)
  {
    dp[i + 1] = dp[i] + a[i];
  }
  int64_t ans = 0;
  for (int i = 0; i <= n; i++)
  {
    ans += m[dp[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,dp[2000004],a[2000004],k;
int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    dp[1] = 0;
    for(int i=2; i<=n; i++){
        dp[i] = 10000000000000000;
        for(int j=i-1; j>=max(i - k,1LL); j--)
            dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
    }
    
    cout << dp[n];
    
    
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int p[n]; rep(i,n) cin >> p[i];
	int q[n]; rep(i,n) cin >> q[i];
	vector<int> s(n); rep(i,n) s[i] = i + 1;
	int a, b, cnt = 0;
	do {
		cnt++;
		bool flga = true, flgb = true;
		for(int i = 0; i < n; ++i) {
			if(s[i] != p[i]) flga = false;
			if(s[i] != q[i]) flgb = false;
		}
		if(flga) a = cnt;
		if(flgb) b = cnt;
	} while(next_permutation(all(s)));
	cout << abs(a - b) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int a, b;
	int x;

	while (1) {
		scanf("%d %c %d", &a, &x, &b);
		if(x == '?') break;
		else if(x == '+') {
			printf("%d\n", a+b);
		}
		else if(x == '-') {
			printf("%d\n", a-b);
		}
		else if(x == '*') {
			printf("%d\n", a*b);
		}
		else if(x == '/') {
			printf("%d\n", a/b);
		}
	} 

	return 0;
}


Measured memory_bytes: 2064
import statistics

N = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
AB = [list(map(int, input().split())) for i in range(N)]
AB = list(zip(*AB))

low = statistics.median(AB[0])
high = statistics.median(AB[1])

if len(AB[0])%2 ==0:
    print(int(2*(high-low)+1))
else:
    print(high-low+1)


Measured memory_bytes: 62916
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
$ans=0
def dfs(now,res)
    if now==N
        $ans+=1 if res.even?
        return
    end
    -1.upto(1) do|i|
      dfs(now+1,res*(A[now]+i))
    end
end
dfs(0,1)
puts $ans

Measured memory_bytes: 14332
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b;

	cin>>a>>b;

	cout<<(a-1)*(b-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 1000000007;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    ll N;
    cin >> N;

    ll P = 1;

    for (ll i = 1; i <= N; ++i) {
        P = P * i % wazu;
    }

    cout << P << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

int n, res;
int a[] = {3, 5, 7};

void dfs(int num, vector<int> tfs){
    if(num > n) return;
    if(num <= n && tfs[0] && tfs[1] && tfs[2]) ++res;
    rep(i,3){
        ++tfs[i];
        dfs(num * 10 + a[i], tfs);
        --tfs[i];
    }
}

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    cin >> n;
    dfs(0, vector<int>({0,0,0}));

    cout << res << '\n';
    
    return 0;
}

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




int main(){
	int N,M;
	cin>>N>>M;
	
	
	vector<pair<pair<int,int>,int>> v;
	for(int i=0;i<M;i++){
		int P,Y;
		cin>>P>>Y;
		v.push_back(make_pair(make_pair(P,Y),i));
	}
	sort(v.begin(),v.end());
	
	vector<pair<int,string>> v2;
	int cnt = 1;
	for(int i=0;i<v.size();i++){
		if(i!=0){
			if(v[i].first.first!=v[i-1].first.first)cnt=1;
		}
		string s1 = to_string(v[i].first.first);
		string s2 = to_string(cnt);
		string S = "";
		for(int i=0;i<6-s1.size();i++)S+='0';
		S+=s1;
		for(int i=0;i<6-s2.size();i++)S+='0';
		S+=s2;
		cnt++;
		
		
		v2.push_back(make_pair(v[i].second,S));
	}
	
	sort(v2.begin(),v2.end());
	
	for(int i=0;i<v2.size();i++){
		cout<<v2[i].second<<endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 10480
#include <iostream>
#define INFTY 1000000000
typedef long long ll;

ll merge(int A[], int left, int mid, int right){
    ll cnt = 0;
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1];
    int R[n2 + 1];
    for(i=0; i<n1; i++){
        L[i] = A[left + i];
    }
    for(i=0; i<n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    i = 0;
    j = 0;
    for(k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i += 1;
        }
        else{
            A[k] = R[j];
            j += 1;
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergeSort(int A[], int left, int right){
    int mid = (left + right) / 2;
    ll cnt = 0;
    if((left+1) < right){
        cnt += mergeSort(A, left, mid);
        cnt += mergeSort(A, mid, right);
        cnt += merge(A, left, mid, right);
    }
    return cnt;
}

int main(){
    int n;
    std::cin >> n;
    int S[n];
    for(int i=0; i<n; i++){
        std::cin >> S[i];
    }

    int left = 0;
    int right = n;
    ll cnt = mergeSort(S, left, right);

    std::cout << cnt << '\n';
    return 0;
}


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

using namespace std;

int main()
{
    double a, b, c, d;

    cin >> a >> b >> c >> d;

    int turn_t, turn_a;

    turn_t = ceil(c/b);
    turn_a = ceil(a/d);

    if (turn_t <= turn_a)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

#define M 7
#define N 1000

static int d[ M ];
static int r[ M ];
static int m;

static int k_operafan[ M ][ N + 1 ];

static int
dpFSA (
  int p,
  int c
  )
{
  int i;

  if ( c == 0 )           return ( 1 );
  if ( p >= m || c <  0 ) return ( 0 );

  if ( ~k_operafan[ p ][ c ] ) ;
  else
  {
    k_operafan[ p ][ c ] = 0;

    for ( i = 0; i <= r[ p ]; ++i )
    {
      k_operafan[ p ][ c ] += dpFSA ( p + 1, c - d[ p ] * i );
    }
  }

  return ( k_operafan[ p ][ c ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int g;

    scanf ( "%d", &m );
    if ( !( m ) ) break ;
    for ( i = 0; i < m; ++i )
    {
      scanf ( "%d%d", d + i, r + i );
    }
    scanf ( "%d", &g );

    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    for ( i = 0; i < g; ++i )
    {
      int n;

      scanf ( "%d\n", &n );
      printf ( "%d\n", dpFSA ( 0, n ) );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func divisor(n int) []int {
	ret := []int{}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			// if i*i != n {
			ret = append(ret, n/i)
			// }
		}
	}
	return ret
}

// Pfs :　素因数分解し、スライスを作成
func Pfs(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()

	a := make([]int, 0)
	for i := 1; i <= N; i++ {
		x := Pfs(i)
		// out(x, i)
		a = append(a, x...)
	}
	sort.Ints(a)
	m := make(map[int]int)
	for _, v := range a {
		m[v]++
	}
	cnt74 := 0
	cnt24 := 0
	cnt14 := 0
	cnt4 := 0
	cnt2 := 0
	for _, v := range m {
		if v >= 74 {
			cnt74++
		}
		if v >= 24 {
			cnt24++
		}
		if v >= 14 {
			cnt14++
		}
		if v >= 4 {
			cnt4++
		}
		if v >= 2 {
			cnt2++
		}
	}

	// out(cnt74, ":", cnt24, cnt2, ":", cnt14, cnt4, ":", cnt4, cnt2, ":", len(m)-cnt2)

	ans := cnt74 + cnt24*(cnt2-1) + cnt14*(cnt4-1) + cnt4*(cnt4-1)*(cnt2-2)/2
	out(ans)
}


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


ll nck(ll n, ll k){
    
    ll p=1000000007;
    ll p2;
    p2=p-2;
    vector <int> r(35);
    vector <ll> r2(36);

    rep(j,35){
        r[j]=(p2>>j)&1;
    }

    ll ans;
    ans=1;

    if (k!=0){
    rep(i,k-1){   
        r2[0]=i+2;
        rep(j,35){
           
            r2[j+1]=(r2[j]*r2[j])%p;
            if(r[j]==1){
            ans*=r2[j];
            ans=ans%p;
            }
        }
    }
    rep(i,k){
        ans*=n-i;
        ans=ans%p;
    }
    }
    return ans;
}


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

    ll ans2,k2;
    vector <ll> si(35,0),amari(35,0);
    k2=2;

    rep(i,35){
        si[i]=((n>>i)&1);
        amari[i]=k2;
        k2=(k2*k2)%1000000007;
    }

    ans2=1;
    rep(i,35){
        if(si[i]==1){
        ans2*=si[i]*amari[i];
        ans2=ans2%(1000000007);
        }
    }

    ans2-=nck(n,a)+nck(n,b)+1;
    while(ans2<0){
        ans2+=1000000007;
    }


    if(n<=2){
        ans2=0;
    }
    cout << ans2 << endl;



    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	string str; cin >> str;
	for (auto ch : str)
		if (ch == '7')
			RT("Yes" << endl);
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int  s[100000];
bool p(int X, int N, int M){
  bool clear = false;
  int i = 0;
  int L = 1;
  int cnt = 1;
  // 初手で最初の敵が倒せなきゃクリアできない
  // 逆に，初手で最初の敵が倒せさえすれば地道にレベルアップして倒せる
  if(s[0] >= L + X){
    return false;
  }else{
    while(!clear && cnt < M){
      // まず，ラスボスが倒せるんだったらつべこべ言わず倒してしまえ
      if(s[N-1] < L+X){
	clear=true;
	cnt++;
      }else{
	// まだラスボスが倒せない状態なのでレベル上げ．
	// abs(L-s[i]) が最小となるiをimaxとし，このimaxを求める．要するにs[i]が最もLに近く位置を求める．
	//   abs(L-s[0]) > abs(L-s[1]) > ... > abs(L-s[imax]) < abs(L-s[imax+1]) < ... < abs(L-s[n-1])
	// となるので，減少してかつ倒せる間 i を増やし続けていけば良い．
	int imax = -1;
	while(s[i] < L+X && i < M-1 && imax < 0){
	  if(abs(L-s[i]) < abs(L-s[i+1])){
	    //増加に転ずる地点があればそのiが最大
	    imax = i;
	  }else{
	    i++;
	  }
	}
	//倒せる敵がいるのでレベル上げ
	// cout << "| L : " << L << ", imax : " << imax << endl;
	L += max(1, X - abs(L - s[imax]));
	cnt++;
      }
    }
  }
  // M 回目の時点でクリアしてないなら Xmax 更新
  // cout << "X : " << X << ", cnt : " << cnt << endl;
  if(!clear){
    return true;
  }else{
    return false;
  }
}

int main(void){
  for(;;){
    int N, M;
    cin >> N >> M;
    if(N == 0 && M == 0){return 0;}
    for(int i = 0 ; i < N ; i++){
      cin >> s[i];
    }
    // 実際に敵を倒してみる
    // 今倒せる敵の中で最もレベルの上がるもの(一番Lに近いもの)を倒していくのが最短である
    // cout << "p(3): " << p(3,N,M) << endl
    // X は探索範囲が広いので二分探索する
    int left  = s[0]-1;
    int right = s[N-1];
    while(left < right){
      int mid = (left + right)/2;
      if(p(mid, N, M) == true){
        left  = mid + 1;
      }else{
	right = mid;
      }
    }
    left--;
    cout << ((left <= s[0]-1)?(-1):(left)) << endl;
  }
}



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

int main(){
  int n;
  cin >> n;
  
  int a=0,b=0,c=0;
  long long  x=0,y=0,z=0;
  
  while(n--){
    cin >> a >> b >> c;
    int p=a+max(y,z);
    int q=b+max(x,z)  ;
    int r=c+max(x,y);
    x=p;
    y=q;
    z=r;
  }
  
  cout << max(max(x,y),z);
  
  return 0;
}


Measured memory_bytes: 3632
import Control.Monad
import Control.Applicative
import Data.List
f2::Int->Int->[Int]->[[Int]]
f2 _ _ (_:[])=[]
f2 y x (0:0:zs)=f2 y (x+1) (0:zs)
f2 y x (0:1:zs)=f2 y (x+1) (1:zs)
f2 y x (1:0:zs)=[y,x,y,(x+1)]:f2 y (x+1) (1:zs)
f2 y x (1:1:zs)=[y,x,y,(x+1)]:f2 y (x+1) (0:zs)

f2_1::Int->[[Int]]->[[[Int]]]
f2_1 _ []=[]
f2_1 y (z:zs)=(f2 y 1 z):f2_1 (y+1) zs

f3::[Int]->[Int]
f3 (x:[])=[x]
f3 (0:0:zs)=0:f3 (0:zs)
f3 (0:1:zs)=0:f3 (1:zs)
f3 (1:0:zs)=0:f3 (1:zs)
f3 (1:1:zs)=0:f3 (0:zs)

f3_1::[[Int]]->[[Int]]
f3_1 []=[]
f3_1 (z:zs)=(f3 z ): (f3_1 zs)

f1::[Int]->[Int]
f1 []=[]
f1 (x:xs)=x `mod` 2 : f1 xs

f4 :: [Int]->[Int]
f4 (a:b:c:d:[])=(b:a:d:c:[])



main = do
       [h,w]<- map read . words <$> getLine
       ms <- replicateM h getLine
       let ms2=map (map read. words) ms::[[Int]]
           ms3=map f1 ms2
           ans1=concat $ f2_1 1 ms3
           ms4 =transpose $ f3_1 ms3
           ans2=map f4 $ concat $ f2_1 1 ms4
           n=length ans1 + length ans2
           ans3=map unwords $ map (map show) $  (ans1++ans2)
       putStrLn $ show $ n
       mapM_ putStrLn $ ans3
      
       

Measured memory_bytes: 63740
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt();
		int b=sc.nextInt();
    
 	if(a*n>=b){
    		System.out.println(b);
    	}else{
     		System.out.println(a*n);
   	 }

    	System.out.println();
    }
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

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

	int cnt=0;
	for (int i = 0; i < s.size(); i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			cnt++;
			i+=2;
		}
	}

	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<queue>
#define ll long long
using namespace std;
const int maxn=1e5;
int n,a,b,tot;
ll ans,d;
bool vis[maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

struct Vertex
{
    ll x,y;
    int id;
}V[maxn+8],f1[maxn+8],f2[maxn+8];
bool cmp1(Vertex a,Vertex b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool cmp2(Vertex a,Vertex b){return a.y!=b.y?a.y<b.y:a.x<b.x;}
struct My_Cmp1
{
    bool operator()(const Vertex &a,const Vertex &b)
    {return a.x!=b.x?a.x<b.x:a.y<b.y;}
};
struct My_Cmp2
{
    bool operator()(const Vertex &a,const Vertex &b)
    {return a.y!=b.y?a.y<b.y:a.x<b.x;}
};
set<Vertex,My_Cmp1>st1;
set<Vertex,My_Cmp2>st2;
queue<Vertex>stack;

void work_1(ll x,ll l,ll r)
{
    set<Vertex,My_Cmp1>::iterator it=st1.lower_bound((Vertex){x,l});
    while(it!=st1.end())
	{
	    Vertex p=*it;
	    if (p.x>x||p.y>r) break;
	    vis[p.id]=1;
	    it++;
	    st1.erase(p),st2.erase(p);
	    stack.push(p);
        }
}

void work_2(ll y,ll l,ll r)
{
    set<Vertex,My_Cmp2>::iterator it=st2.lower_bound((Vertex){l,y});
    while(it!=st2.end())
	{
	    Vertex p=*it;
	    if (p.x>r||p.y>y) break;
	    vis[p.id]=1;
	    it++;
	    st1.erase(p),st2.erase(p);
	    stack.push(p);
	}
}

int find_1(ll x,ll y)
{
    int l=1,r=tot,tmp=tot+1;
    while(l<=r)
	{
	    int mid=(l+r)>>1;
	    if (f1[mid].x>x||(f1[mid].x==x&&f1[mid].y>=y)) tmp=mid,r=mid-1;
	    else l=mid+1;
	}
    return tmp;
}

int find_2(ll x,ll y)
{
    int l=1,r=tot,tmp=tot+1;
    while(l<=r)
	{
	    int mid=(l+r)>>1;
	    if (f2[mid].y>y||(f2[mid].y==y&&f2[mid].x>=x)) r=mid-1,tmp=mid;
	    else l=mid+1;
	}
    return tmp;
}

void solve_1(ll x,ll l,ll r)
{
    int s1=find_1(x,l),s2=find_1(x,r);
    if (f1[s2].x!=x||f1[s2].y!=r) s2--;
    ans+=s2-s1+1;
    if (f1[s1].x==x&&f1[s1].y==l) ans--;
    if (f1[s2].x==x&&f1[s2].y==r) ans--;
}

void solve_2(ll y,ll l,ll r)
{
    int s1=find_2(l,y),s2=find_2(r,y);
    if (f2[s2].x!=r||f2[s2].y!=y) s2--;
    ans+=s2-s1+1;
}
int main()
{
    n=read(),a=read(),b=read();
    for (int i=1;i<=n;i++)
	{
	    ll x=read(),y=read();
	    V[i].x=x+y,V[i].y=x-y,V[i].id=i;
	    if (i!=a&&i!=b) st1.insert(V[i]),st2.insert(V[i]);
	}
    vis[a]=vis[b]=1;
    d=max(abs(V[a].x-V[b].x),abs(V[a].y-V[b].y));
    stack.push(V[a]),stack.push(V[b]);
    while(!stack.empty())
	{
	    Vertex p=stack.front();stack.pop();
	    work_1(p.x+d,p.y-d,p.y+d);
	    work_1(p.x-d,p.y-d,p.y+d);
	    work_2(p.y+d,p.x-d,p.x+d);
	    work_2(p.y-d,p.x-d,p.x+d);
	}
    for (int i=1;i<=n;i++) if (vis[i]) f1[++tot]=V[i],f2[tot]=V[i];
    sort(f1+1,f1+tot+1,cmp1);
    sort(f2+1,f2+tot+1,cmp2);
    for (int i=1;i<=n;i++)
	if (vis[i])
	    {
		Vertex p=V[i];
		solve_1(p.x+d,p.y-d,p.y+d);
		solve_1(p.x-d,p.y-d,p.y+d);
		solve_2(p.y+d,p.x-d,p.x+d);
		solve_2(p.y-d,p.x-d,p.x+d);
	    }
    printf("%lld\n",ans/2);
    return 0;
}


Measured memory_bytes: 22272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A+B>=C-1) cout << C+B << endl;
    else cout << A+B+1+B << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(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 FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(string, s);
	OUT(count(ALL(s), '7') ? "Yes" : "No");
}


Measured memory_bytes: 3620
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

int main()
{
#ifdef _MSC_VER
	//freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	string s;
	cin>>s;
	for (char c='a';c<='z';c++) if (s.find(c)==-1)
	{
		printf("%s%c\n",s.c_str(),c);
		return 0;
	}
	for (int i=LENGTH(s)-1;i>=0;i--) for (char c=s[i]+1;c<='z';c++)
	{
		int p=s.find(c);
		if (p!=-1 && p<i) continue;
		printf("%s%c\n",s.substr(0,i).c_str(),c);
		return 0;
	}
	printf("-1\n");
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int ans = 0;
	double n,d;
	scanf("%lf %lf",&n,&d);
	double x,y;
	for (double i=0;i<n;i++){
		scanf("%lf %lf",&x,&y);
		if (x*x+y*y<=d*d){
			ans++;
		}
	}
	
	printf("%d",ans);
}

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

int main() {
    int K,S,X,Y,Z;
    cin >> K >> S;
    int total ;
    int count_ =  0;
    for(X=0;X<=K;X++){
        for(Y=0;Y<=K;Y++){
            Z = S -(X + Y);
            if(0<= Z && Z <= K){
                count_ = count_ + 1;
            }
        }
    }
    cout << count_ << endl;
}  


Measured memory_bytes: 3596
import sys
S = list(map(int,input()))

if len(S) != 4: sys.exit()

if 1 <= int(str(S[0])+str(S[1])) <= 12 and 1 <= int(str(S[2])+str(S[3])) <= 12: print('AMBIGUOUS');sys.exit()
if int(str(S[0])+str(S[1])) >= 13 and 1 <= int(str(S[2])+str(S[3])) <= 12: print('YYMM');sys.exit()
if 0 == int(str(S[0])+str(S[1])) and 1 <= int(str(S[2])+str(S[3])) <= 12: print('YYMM');sys.exit()
if 1 <= int(str(S[0])+str(S[1])) <= 12 and 13 <= int(str(S[2])+str(S[3])): print('MMYY');sys.exit()
if 1 <= int(str(S[0])+str(S[1])) <= 12 and 0 == int(str(S[2])+str(S[3])): print('MMYY');sys.exit()
print('NA')

Measured memory_bytes: 9216
n=int(input())
l=list(map(int,input().split()))
num=[0]*(10**5+1)
for i in l:
    num[i]+=1
q=int(input())
count=sum(l)
for _ in range(q):
    b,c=map(int,input().split())
    count+=num[b]*(c-b)
    num[c]+=num[b]
    num[b]=0
    print(count)

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

string s;
int d[14], n;
//ll dp[2][9*14+1][14*3+1][14*2+1][15][15][3];
unordered_map<ll, ll> dp[2][14*9+1][3];

int main(){
	cin >> s;
	n = s.size();
	rep(i, n) d[i] = s[i] - '0';
	
	int cur = 0, next = 1;
	dp[cur][0][1][1] = 1;
	rep(i, n){
		//rep(j, 14*9+1) rep(k, 3) dp[next][j][k].clear();
		rep(sum, 9*i+1) rep(sml, 3) for(auto p : dp[cur][sum][sml]){
			rep(x, 10){
				ll prod = p.first * (x + 1);
				int nsml = sml;
				if(sml == 1 && d[i] != x) nsml = d[i] > x ? 0 : 2;
				dp[next][sum + x][nsml][prod] += p.second;
			}
		}
		rep(sum, 9*i+1) rep(sml, 3) dp[cur][sum][sml].clear();
		swap(cur, next);
	}
	int dsum = 0;
	ll dprod = 1;
	ll ans = 0;
	rep(i, n) dsum += d[i], dprod *= d[i] + 1;
	rep(sum, dsum + 1) rep(sml, 3) for(auto p : dp[cur][sum][sml])
	if(sum < dsum || sum == dsum && p.first < dprod || sum == dsum && p.first == dprod && sml == 0){
		/*
		dbg(sum); dbg(dsum);
		dbg(p.first); dbg(dprod);
		dbg(sml); dbg(p.second);
		*/
		ans += p.second;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30872
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        mut a: [i64; n],
        mut b: [i64; m],
    };
    a.push(1 << 40);

    let mut acc = b.iter().sum::<i64>();
    let mut j = m;
    let mut ans = 0;

    for i in 0..a.len() {
        while acc > k && j > 0 {
            j -= 1;
            acc -= b[j];
        }

        if acc > k {
            break;
        }

        ans = max(ans, j + i);
        acc += a[i];

        if a[i] > k {
            break;
        }
    }

    println!("{}", ans);
}


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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == s[i+1]){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 25
#define ll long long
using namespace std;
int n;
int s[N];
ll find(int li,int ri,int x,int y){
	if(li>=ri-1) return 0;
	ll mi=1e17;
	for(int i=li+1;i<ri;i++) mi=min(mi,find(li,i,x,x+y)+find(i,ri,x+y,y)+(ll)s[i]*(x+y));
	return mi;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	printf("%lld\n",find(1,n,1,1)+s[1]+s[n]);
	return 0;
} 

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

int main() {
  
  string S;
  cin >> S;
  
  int hantei = 1;
  
  for ( int i = 0; i < S.size(); i ++){
    if ( ( ( i + 1 ) % 2 == 1 ) && ( S.at(i) == 'L' ) ){
      hantei = 0;
    }else if ( ( ( i + 1 ) % 2 == 0 ) && ( S.at(i) == 'R' ) ){
      hantei = 0;
    }
  }
  
  if ( hantei ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


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

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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
const int INF = 1001001001;
const ll mod = 1e9+7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int h,w,k;
  cin>>h>>w>>k;
  mint dp[105][9];
  rep(i,105)rep(j,9)dp[i][j]=0;
  dp[0][0]=1;
  rep(i,h+1)rep(j,w){
    rep(k,1<<(w-1)){
    bool check=true;
    rep(l,w-2){
      if (((k>>l) & 1) && ((k>>(l+1)) & 1)) check=false;
    }
    if (check==false)continue;
    if(j>=1 and ((k>>j-1) & 1)){
      dp[i+1][j-1]+=dp[i][j];
    }
    else if(j<=w-2 and ((k>>j) & 1)){

      dp[i+1][j+1]+=dp[i][j];
      //cout<<i<<'i'<<j<<'j'<<dp[i][j]<<' '<<dp[i+1][j+1]<<endl;

    }
    else{
      dp[i+1][j]+=dp[i][j];
    }
    }
  }
  cout<<dp[h][k-1];


}


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

using namespace std;

int main()
{
    int n; // the number of temperatures to analyse
  	vector<int> h;
  	int cost[100000];
  	
    cin >> n; cin.ignore();
    for (int i = 0; i < n; i++) {
        int t; // a temperature expressed as an integer ranging from -273 to 5526
        cin >> t; cin.ignore();
        h.push_back(t);
    }
  	cost[0]=0;
  	cost[1]=abs(h[1]-h[0]);

  	for (int i = 2; i < n; i++) {
    	cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]), cost[i-2] +abs(h[i]-h[i-2]));
    }
  	cout<< cost[n-1]<<endl;
}



Measured memory_bytes: 1144
mod = 10**9 + 7
n, m = map(int, input().split())
a = []
for _ in range(m):
    x = int(input())
    if len(a) > 0 and x == a[-1] + 1:
        print(0)
        exit()
    a.append(x)
j = 0
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if j < m and i >= a[j]:
        j += 1
    if j < m and i+1 == a[j]:
        pass
    else:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    if j < m and i+2 == a[j]:
        pass
    elif i+2 <= n:
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[-1])

Measured memory_bytes: 77636
#include <iostream>
#include <vector>
#include <set>
using namespace std;

void input()
{
}

set<int> A;
int a, b, c, d, e;
int main()
{
    cin >> a >> b >> c >> d;
    A.insert(a);
    A.insert(b);
    A.insert(c);
    A.insert(d);

    if (A.count(1) > 0 && A.count(9) > 0 && A.count(7) > 0 && A.count(4) > 0    )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int odd = (n + 1) / 2;
        double ans = (double)odd / n;
        System.out.println(ans);
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException
	{
		
		int tmp;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}if(b > c) {
			tmp = b;
			b = c;
			c = tmp;
		}if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		System.out.println(a +" "+ b +" "+ c);
	}		
}

Measured memory_bytes: 16976
use v6;

my ($i, $o, $t, $j, $l, $s, $z) = +<<get.words;
my $tri = [min]($i, $l, $j);
my $ans = 0;
say [max] do for (0, 1) {
  my $x = $tri - $_;
  $x >= 0 ?? $o + $x * 3 + ($i, $l, $j).map({2 * (($_ - $x) div 2)}).sum !! 0;
};


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

string s;
    int k;
    cin>>s>>k;
   
    // vector<int> num;
    // while(n>0)
    // {
    //     num.pb(n%10);
    //     n/=10;
    // }
    // reverse(num.begin(),num.end());
    int m=s.length();
     vector<vector<int> > dp(k+1,vector<int>(2));
     dp[0][0]=1;
    for(int i=1;i<=m;i++)
    {
         vector<vector<int> > new_dp(k+1,vector<int>(2));
        for(int j=0;j<=k;j++)
        {
            if(s[i-1]!='0')
            {
                if(j<k){
            new_dp[j+1][0]+=dp[j][0];
            new_dp[j+1][1]+=((s[i-1]-'0')-1)*dp[j][0];
           
                }
                 new_dp[j][1]+=dp[j][0];
            
            }
            else new_dp[j][0]+=dp[j][0];

           // 
            if(j<k)
            new_dp[j+1][1]+=9*dp[j][1];
            new_dp[j][1]+=dp[j][1];
        }

        //dp[j][0]=
        dp=new_dp;
       

    }
    // for(auto it: dp)
    // {
    //     cout<<it[0]<<" "<<it[1]<<endl;
    // }
    cout<<dp[k][0]+dp[k][1]<<endl;

}

Measured memory_bytes: 256
from sys import stdin,stdout
n=input()
l=[]
for i in range(n):
    l1=list(map(int,stdin.readline().split()))
    l.append(l1)
a,b,c=l[0][0],l[0][1],l[0][2]
for i in range(1,n):
    x,y,z=a,b,c
    a=l[i][0]+max(y,z)
    b=l[i][1]+max(x,z)
    c=l[i][2]+max(x,y)
stdout.write(str(max(a,b,c))+'\n')
            
        
            
            
    
        


Measured memory_bytes: 48156
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont,from,to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans=0;
    for(int r=0;r*R<=N;++r) {
        for(int g=0;g*G<=N-r*R;++g) {
            if ((N-r*R-g*G)%B==0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
N=int(input())
X=float(N)/1.08
if X%1==0.0:
    print(int(X))
else:
    Y=math.floor(X)
    if math.floor(Y*1.08)==N:
        print(Y)
    elif math.floor((Y+1)*1.08)==N:
        print(Y+1)
    elif math.floor((Y-1)*1.08)==N:
        print(Y-1)
    else:
        print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//関数
const long MOD=1000000007;

int main(void){
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> a(M);
    for(int i=0;i<M;i++){
        cin>>a.at(i);
    }
    
    //計算
    vector<bool> safe(N+1,true);
    for(int i=0;i<M;i++){
        safe.at(a.at(i))=false;
    }
    vector<long> dp(N+1,0);
    
    dp.at(0)=1;
    for(int i=0;i<N+1;i++){
        if(! safe.at(i)){
            dp.at(i)=0;
            continue;
        }
        
        dp.at(i)=(i==0);
        if(0<=i-1) dp.at(i)+=dp.at(i-1);
        if(0<=i-2) dp.at(i)+=dp.at(i-2);
        //cout<<i<<" "<<dp.at(i)<<endl;
        dp.at(i)%=MOD;
    }
    
    //出力
    cout<<dp.at(N)<<endl;
}

Measured memory_bytes: 1792