akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(c - (a - b) >= 0)
        cout << c - (a - b);
    else
        cout << 0;
    return 0;
}

Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print('7')

elif S == 'MON':
    print('6')

elif S == 'TUE':
    print('5')

elif S == 'WED':
    print('4')

elif S == 'THU':
    print('3')

elif S == 'FRI':
    print('2')

elif S == 'SAT':
    print('1') 

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  string a, b, c; cin >> a >> b >> c;
  int ans = 0;
  REP (i, n) {
    if (a[i] == b[i] && b[i] == c[i]) {
    } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
      ans += 1;
    } else {
      ans += 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    int k;
    cin >> s >> k;
    set<string> a;
    int size = s.size();
    int mx = min(5, size);
    for(int i = 0; i< s.size(); i++){
        string tmp;
        for(int j = 0; j < mx; j++){
            if(i+j>=s.size()) break;
            tmp += s[i+j];
            a.insert(tmp);
        }
    }
    auto itr = a.begin();
    for(int i = 1; i< k; i++){
        //cout << *itr << endl;
        itr++;
    }
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 4708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for (int i = a; i <= b; i++) {
			if (i % K == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(bool f){
    cout << (f ? "first" : "second") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        if(a[i]&1){
            pr(1);
        }
    }
    pr(0);
    return 0;
}

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

int main() {
    ll h, p = 0;
    cin >> h;
    ll cnt = 0;
    for(ll i = 0; i < 100000000000; i++) {
        if(h == 0)
            break;
        else if(h % 2 == 0) {
            h = h / 2;
            ll o = pow(2, p);
            cnt = cnt + o;
            p++;

        } else {
            h = (h - 1) / 2;
            ll o = pow(2, p);
            cnt = cnt + o;
            p++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	double weight;
	while(scanf("%lf",&weight) != EOF){
		if(weight <= 48.00){
			printf("light fly\n");
		}
		else if(48.00 < weight && weight <= 51.00){
			printf("fly\n");
		}
		else if(51.00 < weight && weight <= 54.00){
			printf("bantam\n");
		}
		else if(54.00 < weight && weight <= 57.00){
			printf("feather\n");
		}
		else if(57.00 < weight && weight <= 60.00){
			printf("light\n");
		}
		else if(60.00 < weight && weight <= 64.00){
			printf("light welter\n");
		}
		else if(64.00 < weight && weight <= 69.00){
			printf("welter\n");
		}
		else if(69.00 < weight && weight <= 75.00){
			printf("light middle\n");
		}
		else if(75.00 < weight && weight <= 81.00){
			printf("middle\n");
		}
		else if(81.00 < weight && weight <= 91.00){
			printf("light heavy\n");
		}
		else{
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<string>
#include<stack>
#include<algorithm>

using namespace std;

void slove(){
    int k;
    int cnt = 1;
    
    cin>>k;
    if(k%2 == 0 || k%5 == 0){
        cout<<-1<<endl;
        return;
    }

    int res = 7%k;
    while(res){
        res = (res*10+7)%k;
        cnt++;
    }

    cout<<cnt<<endl;
}

int main(){
    slove();
}

Measured memory_bytes: 3636
import java.util.Scanner;
class Main
{
	public static void main(String[] args)throws Exception
	{
		Scanner scan=new Scanner(System.in);
		
		int num;
		int i=1;
		
		while(true)
		{
				num=scan.nextInt();;		
			if(num!=0)
			{
				System.out.println("Case"+" "+i+":"+" "+num);
				i++;
			}
			else
			{
				break;
			}
		}
	}

}

Measured memory_bytes: 42492
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int cost;

	while(cin >> cost)
	{
		if (cost == 0) break;

		int change, changenum;
		change = 1000 - cost;
		changenum = 0;

		if (change > 500)
		{
			change -= 500;
			changenum += 1;
		}

		for (int i = 0; change >= 100; i++)
		{
			change -= 100;
			changenum += 1;
		}

		for (int i = 0; change >= 50; i++)
		{
			change -= 50;
			changenum += 1;
		}

		for (int i = 0; change >= 10; i++)
		{
			change -= 10;
			changenum += 1;
		}
		
		for (int i = 0; change >= 5; i++)
		{
			change -= 5;
			changenum += 1;
		}

		changenum += change;

		cout << changenum << endl;
	}

	return 0;
}

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

int main() {
    string s;cin >> s;
    vector<int> a(4);
    bool flag = false;
    bool flags = false;
    for(int i=0;i<4;i++){
        a[i] = s[i] - '0';
    }
    int bef = a[0]*10+a[1];
    int aft = a[2]*10+a[3];

    if(bef > 12 || bef == 0){
        flag = true;
    }
    if(aft >12 || aft == 0){
        flags = true;
    }
    if(flag == true && flags == true){
        cout << "NA" << endl;
    }else if(flag == true && flags == false){
        cout << "YYMM" << endl;
    }else if(flag == false && flags == true){
        cout << "MMYY" << endl;
    }else{
        cout << "AMBIGUOUS" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
li = [ int(it) for it in input().split() ]
lil = [0]*N
lir = [0]*N

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
lil[0]=li[0]
lir[N-1]=li[N-1]
for i in range(N-1):
  lil[i+1]=gcd(li[i+1],lil[i])
for i in range(N-1,0,-1):
  lir[i-1]=gcd(li[i-1],lir[i])
s = -1
for i in range(N):
  if (i==0):
    gc = lir[1]
  elif (i==N-1):
    gc = lil[N-2]
  else:
    gc = gcd(lil[i-1],lir[i+1])
  s = max(s, gc )
print (s)


Measured memory_bytes: 14052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=1e9+7,N=5e5+10;
void Add(int &x,int y) { x+=y; if(x>=mod) x-=mod; }
int f[2][N],a[N],n;
vector<int> b[1<<20];
int buc[N];
int dp[N],s1[N],s2[N];
int solve(vector<int> &p) {
	int m=p.size()-1,ans=0;
	for(int i=0;i<=m;++i) dp[i]=s1[i]=s2[i]=0;
	for(int i=1;i<=m;++i) {
		dp[i]=((buc[p[i]]*(ll)s1[i-1]-s2[i-1]+1)%mod+mod)%mod;
		s1[i]=(s1[i-1]+dp[i])%mod;
		s2[i]=(s2[i-1]+dp[i]*(ll)buc[p[i]]%mod)%mod;
		Add(ans,dp[i]);
	}
	return ans;
}
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]),a[i]^=a[i-1];
	int ans=0;
	if(a[n]) {
		f[0][0]=1;
		for(int i=1;i<=n;++i) {
			f[0][i]=f[0][i-1];
			f[1][i]=f[1][i-1];
			if(a[i]==a[n]) Add(f[1][i],f[0][i-1]);
			if(a[i]==0) Add(f[0][i],f[1][i-1]);
		}
		ans=f[0][n-1];
	}
	else {
		for(int i=1;i<=n;++i) buc[i]=buc[i-1]+(a[i]==0);
		for(int i=0;i<(1<<20);++i) b[i].PB(0);
		for(int i=1;i<=n;++i)
			if(a[i]) b[a[i]].PB(i);
		for(int i=0;i<(1<<20);++i)
			if(b[i].size()>1) Add(ans,solve(b[i]));
		int t=1;
		for(int i=1;i<buc[n];++i) t=t*2ll%mod;
		Add(ans,t);
	}
	printf("%d",ans);
	return 0;
}


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

int	main(void)
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++) cin >> a[i][j];
	}
	int ans = 1e9;
	for (int i = 0; i < (1 << n); i++)
	{
		int payment = 0;
		vector<int> tmp(m, 0);
		for (int j = 0; j < n; j++)
		{
			if ((i >> j) & 1)
			{
				for (int k = 0; k < m; k++) tmp[k] += a[j][k];
				payment += c[j];
			}
		}
		bool flag = true;
		for (int j = 0; j < m; j++)
		{
			if (tmp[j] < x) flag = false;
		}
		if (flag) ans = min(ans, payment);
	}
	if (ans == 1e9) cout << "-1" << endl;
	else cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define CONTAINS(x, y) (x.find(y)!=x.end()) //x<T1,T2>, T1 y
#define getPair(x) MP(x->first,x->second)

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
string s;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    //cout<<setw(4)<<setfill('0')<<"hoge"<<endl;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i!=5 &&i!=13) {
            cout << s[i];
        }else{
            cout<<" ";
        }
    }
    cout<<endl;

}

Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
WSV = list(tuple(map(int, input().split())) for _ in range(N))
WSV.sort(key=lambda x: x[0] + x[1])
U = 2 * 10 ** 4 + 100
dp = np.zeros(U, dtype=np.int64)
for w, s, v in WSV:
    dp[w:w+s+1] = np.maximum(dp[w:w+s+1], dp[:s+1] + v)
print(dp.max())

Measured memory_bytes: 27628
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Library.LCS
{
    class AOJ_LCS
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int q = ReadInt();
            var xs = new string[q];
            var ys = new string[q];
            for(int i = 0; i < q; i++)
            {
                xs[i] = Read();
                ys[i] = Read();
            }
            for (int i = 0; i < q; i++)
            {
                var dp = new int[xs[i].Length + 1, ys[i].Length + 1];//xをi,yをjまで見たとき
                for(int j = 1; j <= xs[i].Length; j++)
                {
                    for(int k = 1; k <= ys[i].Length; k++)
                    {
                        if (xs[i][j-1] == ys[i][k-1])
                        {
                            dp[j, k] = dp[j - 1, k - 1] + 1;
                        }
                        else
                        {
                            dp[j,k]= Math.Max(dp[j - 1, k], dp[j, k - 1]);
                        }
                    }
                }
                Console.WriteLine(dp[xs[i].Length, ys[i].Length]);
            }

        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 38976
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  	string s;
  	cin>>s;
  	int ans = 0;
  	int i = 0,n=s.length();
  
  	while(i<n)
    {
      int c = 0;
    while(i<n&&(s[i]=='A'||s[i] == 'G' || s[i] == 'C' || s[i] =='T'))
    {
      i++;
      c++;
    }
      ans = max({ans,c});
      i++;
      
    }
  cout<<ans<<endl;
    return 0;

}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  if(a[x]==a[y])cout  << "Yes" << endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;


int main(){
    int w, h, n, x, y;
    int dp[20][20];
    while(cin >> w >> h, w||h){
        memset(dp,0,sizeof(dp));
        dp[0][0] = 1;
        cin >> n;
        rep(i, n){
            cin >> x >> y;
            dp[y - 1][x - 1] = -1;
        }
        rep(i, h){
            rep(j, w){
                if(dp[i][j] < 0)
                    continue;
                if(dp[i + 1][j] >= 0)
                    dp[i + 1][j] += dp[i][j];
                if(dp[i][j + 1] >= 0)
                    dp[i][j + 1] += dp[i][j];
            }
        }
        cout << dp[h - 1][w - 1] << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
        int n,k,q,i,j;
        cin >> n >> k >> q;
        int a[q];
        int b[n]={0};
        for (i=0;i<q;i++){
                cin >> a[i];
                b[a[i]-1] = b[a[i]-1] + 1;
        }
        for (i=0;i<n;i++){
                if (b[i]+k-q<=0){
                        cout << "No \n";
                }else{
                        cout << "Yes \n";
                }
        }
}


Measured memory_bytes: 1536
def gcd(a, b)
  a, b = b, a if a < b
  if a % b == 0
    return b
  else
    gcd(a % b, b)
  end
end

def lcm(a, b)
  (a / gcd(a, b) ) * b
end

n = gets.to_i
data = gets.split.map(&:to_i)

num = data[0]
1.upto(n - 1) do |i|
  num = lcm(num, data[i])
end
p data.map{|a| num/a}.inject(:+) % (7 + 10 ** 9)

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

using namespace std;

const int mod = 1e9 + 7; 

inline long long add(int a, int b) {
	return (a % mod + b % mod) % mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
   	int n, m;
   	cin >> n >> m;
   	vector<long long> dp(n + 1);
   	vector<bool> b(n + 1);
   	int a;
   	while(m--) {
   		cin >> a;
   		b[a] = true;
   	}
   	dp[0] = 1;
   	if(!b[1]) dp[1] = 1;
   	for(int i = 2; i <= n; i++) {
   		if(!b[i]) {
   			dp[i] = add(dp[i - 1], dp[i - 2]);
   		}
   	}
   	cout << dp[n];

    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
H, W, K = map(int,input().split())
S = [input() for k in range(H)]
ans = [[0 for k in range(W)] for l in range(H)]

b = []
for l in range(H):
    b.append(S[l].count("#"))

c = 1
for l in range(H):
    d = 0
    if b[l] != 0:
        for k in range(W):
            ans[l][k] = c+d
            if S[l][k] == "#":
                d += 1
                if d == b[l]:
                    d -= 1
    c += b[l]
f = 0
for k in range(H):
    if b[k] != 0:
        f = k
        break

for l in range(f-1,-1,-1):
    for k in range(W):
        ans[l][k] = ans[l+1][k]


for l in range(f,H):
    if b[l] == 0:
        for k in range(W):
            ans[l][k] = ans[l-1][k]

for e in ans:
    print(*e)


Measured memory_bytes: 45916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  bool ans = false;
  if(N % 10 == 7) ans = true;
  N = N - (N % 10);
  if (N % 100 == 70) ans = true;
  N = N - (N % 100);
  if (N % 1000 == 700) ans = true;
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
string s,ori;
vector<ll>pos;
int main()
{	
	SPEED;
	cin>>s;
	ori=s;
	ll ans=0;
	ll a=0,b=0;
	for(auto j:s)
		if(j=='p')
			a++;
	ans=s.length()/2-a;
	cout<<ans<<endl;
	return 0;
}

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

#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a)		cerr << #a << ": "; for (int& x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	string s;
	cin >> s;
	string list[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	int i ;
	for (i = 0; i < 7; i++) {
		if (list[i] == s)
			break;
	}
	if (i == 0) cout << 7 << endl;
	else cout << 7-i << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, V = map(int, readline().split())
B, W = map(int, readline().split())
T = int(readline())

A_L = A - (V * T)
A_R = A + (V * T)

B_L = B - (W * T)
B_R = B + (W * T)

if (A_L <= B_L) and (B_R <= A_R):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 27128
#include<stdio.h>
int main(){
	int n,k;
	char a;
	while(1){
		scanf("%d %c %d",&n,&a,&k);
		if(a=='+')n+=k;
		if(a=='-')n-=k;
		if(a=='*')n*=k;
		if(a=='/')n/=k;
		if(a=='?')break;
		printf("%d\n",n);
	}
	return 0;
}


Measured memory_bytes: 2024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xy =(y2-y1)/(x2-x1);
    int x3 = x2-(y2-y1);
    int y3 = y2+(x2-x1);
    cout << x3 << " " << y3 << " " << x3-(x2-x1) << " " << y3-(y2-y1) << endl;

}

Measured memory_bytes: 256
import Foundation
func readInts() -> [Int] {
    return readLine()!.components(separatedBy: " ").map { Int($0)! }
}

code_block: do {
    let x_n = readInts()
    if x_n[1] == 0 {
        print(x_n[0])
        break code_block
    }

    let p = readInts()
    let array = Array(0...101).filter { !p.contains($0) }
    var diff = [Int : Int]()

    for num in array {
        diff[num] = abs(num - x_n[0])
    }
    print(diff.min { left, right in
        return left.value != right.value
        ? left.value < right.value
        : left.key < right.key
        }!.key)
}


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

int arr[100010][3],dp[100010][3];

int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);*/
	
    int n;cin>>n;
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++){
    		cin>>arr[i][j];
    	}
    }
    for(int i=0;i<3;i++)dp[0][i]=arr[0][i];
    for(int i=1;i<n;i++){
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
    	dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
    	dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    int ans=0;
    for(int i=0;i<3;i++)ans=max(ans,dp[n-1][i]);
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2560
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    H,W,A,B = LI()
    ans = [[0] * W for _ in range(H)]

    for w in range(W):
        for h in range(H):
            if (w<A and h<B) or (A<=w and B<=h):
                ans[h][w] = 1

    for Line in ans:
        print("".join(map(str,Line)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 51548
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001];
int main()
{
    int n,s=0,i,j,k,w,l;
    string s1,s2;
    cin>>s1>>s2;
    for(i=0; i<s1.length(); i++)
    {
        for(j=0; j<s2.length(); j++)
        {
            if(s1[i]==s2[j])
                dp[i+1][j+1]=dp[i][j]+1;
            else
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }

    l=s1.length();
    k=s2.length();
    s=dp[l][k];
    char s3[s+1];
    s3[s--]='\0';
    while(k>0&&l>0)
    {
        if(dp[l][k]==dp[l][k-1])
            k=k-1;
        else if(dp[l][k]==dp[l-1][k])
            l=l-1;
        else if(dp[l][k]==(dp[l-1][k-1]+1))
        {
            s3[s--]=s1[l-1];
            l=l-1;
            k=k-1;
        }
    }
    cout<<s3<<endl;
}


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

typedef long long ll;
using namespace std;

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

	string num[] = {"0111111",
				  "0000110",
				  "1011011",
			      "1001111",
				  "1100110",
				  "1101101",
	              "1111101",
				  "0100111",
	              "1111111",
	              "1101111"};



	while(1){
		string s = "0000000";
		int n; cin >> n;
		if(n == -1) break;
		for (int i = 0;i < n;i++){
			int next;cin >> next;
			string ans = "0000000";
			for (int i = 0;i < 7;i++){
				if(s[i] == num[next][i])ans[i] = '0';
				else ans[i] = '1';
			}
			s = num[next];
			cout << ans << endl;
		}
	}

	return 0;

}



Measured memory_bytes: 3236
n=gets.to_i
xs= n.times.map{gets.strip.split}.map{|a,b|[a.to_f,b]}
sum = 0
xs.each do |x|
  if x[1] == 'BTC'
    sum += x[0] *380000.0
  else
    sum += x[0]
  end
end
puts sum

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

void solve(){
    ll k, n; 
    cin >> k >> n;
    vector<ll> A(n);
    REP(i, n){
        cin >> A[i];
    }
    ll tmpmax = -1;
    REP(i, n-1){
        ll diff = abs(A[i+1] - A[i]);
        tmpmax = max(tmpmax, diff);
    }
    //cout << tmpmax << endl;
    tmpmax = max(tmpmax, A[0] + k - A[n-1]);
    cout << k - tmpmax << endl;


}

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

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

int main(){
  string s, ans = "";
  int cnt = 0;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'B'){
      if(s[i-1] == 'B'){
        for(int j = i-1; j >= 0; j--){
          if(s[j] != 'B'){
            s[j] = 'B';
            break;
          }
        }
      }else{
        s[i-1] = 'B';
      }
    }
  }
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'B')
     cout << s[i];
  }
  cout << endl;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = a + b + c;
	if (d >= 22) {
		cout << "bust";
	}
	else {
		cout << "win";
	}
	return 0;
}

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

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

    auto B = N;
    for (auto A = 1LL; A*A <= N; A++)
        if (N % A == 0)
            B = N/A;

    auto digits = 0;
    while (B > 0)
    {
        B /= 10;
        digits++;
    }

    cout << digits << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


const int MAX_V = 2000; 

struct Edge{ ll to,cap,rev; };

vector<Edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,ll cap){
  G[from].push_back((Edge){to,cap,(ll)G[to].size()});
  G[to].push_back((Edge){from,0,(ll)G[from].size()-1});
}

ll dfs(int v,int t,ll f){
  if( v == t ) return f;
  used[v] = true;
  for(int i=0;i<(int)G[v].size();i++){
    Edge &e = G[v][i];
    if( !used[e.to] && e.cap > 0 ){
      ll d = dfs(e.to,t,min(f,e.cap));
      if( d > 0LL ){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

ll max_flow(int s,int t){
  ll flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    ll f = dfs(s,t,LLONG_MAX);
    if( f == 0LL ) return flow;
    flow += f;
  }
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  int source = n;
  int sink = source + 1;

  ll sum = 0;
  rep(i,n) sum += llabs(a[i]);

  rep(i,n) {
    add_edge(source, i, llabs(a[i]));
  }
  rep(i,n) {
    if( a[i] < 0 ) {
      add_edge(i, sink, llabs(a[i])*2LL);
    } else {
      add_edge(i, sink, 0);
    }
  }
  rep(i,n) {
    if( a[i] >= 0LL ) continue;
    int v = i + 1;
    int j = i + v;
    while( j < n ) {
      add_edge(j, i, LLONG_MAX);
      j += v;
    }
  }
  cout << sum - max_flow(source,sink) << endl;
  return 0;
}


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

#define INF 0x7fffffff
#define ll	long long

int main() {
	ll		c,i,j,k,n,m,x,y,ans = 0;

	cin >> k >> n;
	vector<ll> a(n),b(n);

	for(i=0;i<n;i++) {
		cin >> a[i];
	}
	for(i=0;i<n-1;i++) {
		b[i] = a[i+1] - a[i];
		ans += b[i];
	}
	b[n-1] = k - a[n-1] + a[0];
	ans += b[n-1];

	m = 0;
	for(i=0;i<n;i++) {
		m = max(m , b[i]);
	}

	cout << ans - m << endl;


}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
int main(){
    auto N = 0;
    std::string kari;
    std::cin >> N;
    std::vector<std::string> sv(N);
    for(int i=0;i<N;i++){
        std::cin >> sv[i];
    }
    int kari_sum = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<sv[i].size()-1;j++){
            if(sv[i].c_str()[j]=='A'&&sv[i].c_str()[j+1]=='B'){
                kari_sum++;
            }
        }
    }
    int BX = 0;
    for(int i=0;i<N;i++){
        if(*sv[i].begin()=='B'&&*sv[i].rbegin()!='A'){
            BX++;
        }
    }
    int XA = 0;
    for(int i=0;i<N;i++){
        if(*sv[i].begin()!='B'&&*sv[i].rbegin()=='A'){
            XA++;
        }
    }
    int BA = 0;
    for(int i=0;i<N;i++){
        if(*sv[i].begin()=='B'&&*sv[i].rbegin()=='A'){
            BA++;
        }
    }
    int ans = kari_sum;
    if(BA>0){
        if(XA>0){
            if(BX>0){
                ans +=  1+ BA + std::min(XA-1,BX-1);
            }else{
                ans += BA;
            }
        }else{
            if(BX>0){
                ans += BA;
            }else{
                ans += BA - 1;
            }
        }
    }else{
        ans += std::min(XA,BX);
    }
    std::cout << ans;
    
}



Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){

int AB,BC,CD;
cin >> AB>> BC>> CD;

cout <<AB*BC/2<<endl;

    

 return 0;
}

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

char field[50][50];
bool used[50][50];
int height, width;
int b_count, w_count;
bool b, w;

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

int move(int i, int j){
	int count = 1;
	used[i][j] = true;
	for(int k = 0; k < 4; k++){
		if(i+dy[k] >= 0 && i+dy[k] < height &&
		   j+dx[k] >= 0 && j+dx[k] < width)
		{
			int i2 = i+dy[k], j2 = j+dx[k];
			if(field[i2][j2] == '.'){
				if(!used[i2][j2]) count += move(i2, j2);
			}else if(field[i2][j2] == 'B'){
				b = true;
			}else{
				w = true;
			}
		}
	}
	return count;
}
	

int main(){
	while(cin >> width >> height && (width || height)){
		for(int i = 0; i < height; i++){
			for(int j = 0; j < width; j++){
				cin >> field[i][j];
				used[i][j] = false;
			}
		}
		b_count = 0;
		w_count = 0;
		for(int i = 0; i < height; i++){
			for(int j = 0; j < width; j++){
				if(field[i][j] == '.' && !used[i][j]){
					b = false;
					w = false;
					int count = move(i, j);
					if(b && !w){
						b_count += count;
					}else if(w && !b){
						w_count += count;
					}
				}
			}
		}
		cout << b_count << " " << w_count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	long long a = 1;
	rep(i,1000){
		if(a - 1 > n){
			cout << i - 1 << endl;
			break;
		}else{
			a *= 2;
		}
	}
}



Measured memory_bytes: 3100
n = int(input())
from collections import defaultdict


s_input_list = []

for i in range(n):
    tmp = input()
    s_input_list.append(tmp)


d = defaultdict(list)

s_sorted_list = []
for s in s_input_list:
    tmp = list(s)
    tmp.sort()
    
    s_sorted_list.append("".join(tmp))

#print(s_sorted_list)

ans = 0
for i in range(n):
    d[s_sorted_list[i]].append(i)

for key,value in d.items():
    v = len(value)
    ans = ans + int(v*(v-1)/2)

#print(d)
print(ans)

Measured memory_bytes: 39200
// Aizu Vol-2 0238: Time to Study
// 2017.8.7

#include <stdio.h>

int main()
{
	int t, n, s, f;
	int i, sm;

	while (1) {
		scanf("%d", &t);
		if (t == 0) break;
		scanf("%d", &n);
		for (sm = i = 0; i < n; i++) {
			scanf("%d%d", &s, &f);
			sm += f - s;
		}
		if (sm >= t) puts("OK");
		else printf("%d\n", t - sm);
	}
	return 0;
}

Measured memory_bytes: 612
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        long x = sc.nextInt();
        HashMap<Integer, Long> tars = new HashMap<>();
        tars.put(0, 0L);
        for (int i = 1; i <= 2000; i++) {
            tars.put(i, 1L * i * i * i * i * i);
            tars.put(-i, -1L * i * i * i * i * i);
        }

        ok(out, x, tars, tars);

        out.flush();
    }

    void ok(PrintWriter out, long x, HashMap<Integer, Long> m1, HashMap<Integer, Long> m2) {
        for (Map.Entry<Integer, Long> e1 : m1.entrySet()) {
            for (Map.Entry<Integer, Long> e2 : m2.entrySet()) {
                if (e2.getValue() - e1.getValue() == x) {
                    out.println(e2.getKey() + " " + e1.getKey());
                    return;
                }
            }
        }
    }



    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 40116
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>

using namespace std;

typedef unsigned long long ull;

ull n,m,a[100001],b[100001];
map<ull,ull> w;

int main(int argc,char** argv) {
	cin >> n >> m;
	w[0]++;
	for(ull i = 1;i <= n;i++) {
		cin >> a[i];
		b[i] = b[i-1] + a[i];
		w[b[i]%m]++;
	}
	ull result = 0;
	for(auto& e:w) {
		result += e.second * (e.second - 1) / 2;
	}
	cout << result << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstring>

using namespace std;

string work;
char s[25000000];
int len = 0;

int main()
{
	cin >> work;
	for (int i = 0; i < work.length(); i++)
	{
		if (work[i] == '0' || work[i] == '1') s[len] = work[i], len++;
		else len--;
		if (len < 0) len = 0;
	}
	for (int i = 0; i < len; i++)
		cout << s[i];
	cout << endl;
	return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  int64_t a, b;
  cin >> a >> b;
  
  int x1min = ((float)a) * 12.5f + 0.5f;
  int x1max = ((float)a) * 12.5f + 1.0f/0.08f - 1.0f;
  
  int x2min = b * 10;
  int x2max = b * 10 + 9;
  
  if ( x2min <= x1min && x1min <= x2max ) {
  	cout << x1min << endl;
  }
  else if ( x1min <= x2min && x2min <= x1max ) {
  	cout << x2min << endl;
  }
  else{
    cout << "-1" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(a, b);
		max = Math.max(max, c);
		System.out.println(a+b+c+9*max);
	}
}


Measured memory_bytes: 22740
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
if len(s) == 1:
    print(0)
    sys.exit(0)
if len(s) == 2 and s[0] == s[1]:
    print(0)
    sys.exit(0)

# [i][0]: index iが1文字分割
# [i][1]: index iが2文字分割
dp = [[0] * 2 for _ in range(len(s))]
# 3文字以上では1文字/2文字の仮想結果が使われる
# 1文字
dp[0][0] = dp[0][1] = 1
# 2文字
if s[0] == s[1]:
    # 実際には常に2文字分割になる
    dp[1][0] = dp[1][1] = 1
else:
    dp[1][0] = 2
    dp[1][1] = 1

# 3文字以上
for i in range(2, len(s)):

    # [i][0]: 末尾の分割を1文字にする場合

    # 末尾2文字が同じ場合
    # - 1つ前を2文字分割にしなくてはならない
    if s[i] == s[i-1]:
        dp[i][0] = dp[i-1][1] + 1
    # 末尾2文字が異なる場合
    # - 1つ前が1文字分割
    # - 1つ前が2文字分割
    else:
        dp[i][0] = max(dp[i-1][0] + 1, dp[i-1][1] + 1)


    # [i][1]: 末尾の分割を2文字にする場合
    # 末尾前の2文字が末尾の2文字と同じ場合
    # 末尾前を1文字分割にしなくてはならない
    if s[i-3:i-1] == s[i-1:i+1]:
        dp[i][1] = dp[i-2][0] + 1
    # 末尾前の2文字が末尾の2文字と異なる場合
    # - 末尾前が1文字分割
    # - 末尾前が2文字分割
    else:
        dp[i][1] = max(dp[i-2][0] + 1, dp[i-2][1] + 1)

print(max(dp[-1][0], dp[-1][1]))


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

int main()
{
  
  int n;
  cin>>n;
  int arr[n];
  for(int i=0; i<n; i++)
    cin>>arr[i];
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(arr[1]- arr[0]);
  for(int i=2; i<n; i++)
    dp[i] = min(  abs(arr[i] - arr[i-1]) + dp[i-1],  abs(arr[i] - arr[i-2] ) + dp[i-2] );
                
            cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4308
#include <stdio.h>


int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int N, K, i, j, max_i=0;
//	int A[200000];
	int p[200000];
	int temp, max=0;
	long long sum = 0;

	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++){
		scanf("%d", &p[i]);
	}

	temp = 0;
	for (j = 0; j < K; j++){
		temp += p[j];
	}
	for (i = 1; i < N - K + 1; i++){

			temp = temp - p[i-1] + p[i + K-1];
		
		if (temp > max){
			max = temp;
			max_i = i;
		}
	}
	for (j = 0; j < K; j++){
		sum += p[max_i+j] + 1;
	}

	printf("%f\n", (double) sum / 2.0);


	return 0;

}
    


Measured memory_bytes: 896
#include<stdio.h>
#define MAX 100000
int parent(int i){
  return (i - 1)/2;
}
int right(int i){
  return 2*(i + 1);
}
int left(int i){
  return 2 * i + 1;
}
int main(){
  int H,i,A[MAX + 1];
  scanf("%d",&H);
  for(i = 0;i < H;i++) scanf("%d",&A[i]);
  for(i = 0;i < H;i++){
    printf("node %d: key = %d, ",i+1,A[i]);
    if(i != 0){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i) < H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i) < H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
  return 0;
}



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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

const ll maxn=1e3+1,mod=1e9+7;

int memo[maxn][maxn][2];
string a;
int n;
vector<int> alpha(26);

bool f(vector<int> a,vector<int> b){
    ld sum = 0;
    forn(i,a.size()){
        ll temp = a[i]-b[i];
        temp*=temp;
        sum+=temp;
    }
    // cout<<sum<<endl;
    ld s = sqrt(sum);
    // cout<<fixed<<setprecision(10)<<s<<endl
    if(s-int(s)==0) return true;
    return false;
}

int main(){
    sync
    ll l,r;
    cin>>l>>r;
    ll ans = LONG_LONG_MAX;
    ll al,ar;
    if(r-l+1<2019){
        fore(i,l,r){
            fore(j,i+1,r){
                if((i*j)%2019<ans){
                    ans = (i*j)%2019;
                    // al = i;
                    // ar = j
                }
            }
        }
    }
    else{
        ans = 0;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  int brick[200000];
  
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    scanf("%d",&brick[i]);
  }
  printf("%d", break_brick(brick,n));
  return 0;
}

int break_brick(int *brick, int n) {
  int iterator = 1;
  for (int i = 0; i < n; i++) {
    if (brick[i] == iterator) {
      iterator++;
    }
  }
  if (iterator == 1) {
    return -1;
  } else {
    return n - (iterator - 1);
  }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define N 100
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159
#define cot cout.tie(0)
#define endl "\n"
using namespace std;
/**
        * @author :: Sawlani
        *
        */

 

int main()
{
        
        double r;
        cin >> r;
        cout << fixed <<  setprecision(10) ;
         double ans = 2.0*PI*r;

         cout << ans;
}

Measured memory_bytes: 3796
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [usize; n+1],
      bb: [usize; n],
    }

    let mut ans = 0;
    for i in 0..n {
        let mut b = bb[i];
        let v1 = min(aa[i], b);
        aa[i] -= v1;
        b -= v1;
        let v2 = min(aa[i+1], b);
        aa[i+1] -= v2;
        b -= v2;
        ans += v1 + v2;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
def isprime(n):
    if(n<2):
        return False
    for i in range(2,n):
        if(n%i==0):
            return False
    return True

def primelist(n):
    return [i for i in range(n) if isprime(i)]

def factor(n):
    f = {}
    while(n > 1):
        for p in primelist(n+1):
            if(n % p == 0):
                f[p] = f.get(p, 0) + 1
                n //= p
    return f

def factorfactorial(n):
    f = {}
    for i in range(1,n+1):
        fi = factor(i)
        for k, v in fi.items():
            f[k] = f.get(k,0) + v
    return f

# 75 = 3*5*5 = 3*25 = 5*15 
n = int(input())
f = factorfactorial(n)

# print(f)
cnt = 0

for i in f.keys():
    if(f[i]>=75-1):
        cnt += 1
    for j in primelist(n+1):
        if(i==j):
            continue
        if(f[i]>=25-1 and f[j]>=3-1):
            cnt += 1
        if(f[i]>=15-1 and f[j]>=5-1):
            cnt += 1
        if(i > j):
            for k in primelist(n+1):
                if k in [i,j]:
                    continue
                if(f[i]>=5-1 and f[j]>=5-1 and f[k]>=3-1):
                    cnt += 1



print(cnt)


Measured memory_bytes: 3064