akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    class SegTree():
        def __init__(self, N):
            # N:  処理する区間の長さ
            self.N0 = 2 ** (N - 1).bit_length()
            self.INF = 2100000000
            self.seg_min = [-self.INF] * (2 * self.N0)

        def update(self, index, value):
            index += self.N0 - 1
            self.seg_min[index] = value
            while index > 0:
                index = (index - 1) >> 1
                L = self.seg_min[index * 2 + 1]
                R = self.seg_min[index * 2 + 2]
                if L > R:
                    self.seg_min[index] = L
                else:
                    self.seg_min[index] = R
                # self.seg_min[index] = min(self.seg_min[index * 2 + 1], self.seg_min[index * 2 + 2])

        def query(self, first, last):
            first += self.N0 - 1
            last += self.N0 - 1
            ret = -self.INF
            while first <= last:
                if not first & 1:
                    ret_new = self.seg_min[first]
                    if ret_new > ret:
                        ret = ret_new
                    # ret = min(ret, self.seg_min[first])
                if last & 1:
                    ret_new = self.seg_min[last]
                    if ret_new > ret:
                        ret = ret_new
                    # ret = min(ret, self.seg_min[last])
                first = first >> 1
                last = (last >> 1) - 1
            return ret

    mod = 998244353
    N = int(input())
    info = []
    X = []
    for _ in range(N):
        x, d = map(int, input().split())
        info.append((x, x+d))
        X.append(x)
    info.sort(key=lambda p: p[0])
    X.sort()
    segtree = SegTree(N+1)
    for i in range(N):
        segtree.update(i+1, info[i][1])

    dp = [0] * (N+1)
    dp[-1] = 1
    for i in range(N-1, -1, -1):
        l, r = info[i]
        j = bisect_left(X, r)
        rmax = segtree.query(i+1, j)
        #print(i+1, j, rmax)
        segtree.update(i+1, rmax)
        j2 = bisect_left(X, rmax)
        dp[i] = (dp[i+1] + dp[j2])%mod
    print(dp[0])
    #print(dp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 112896
# 1: O(N*digit(A))
if False:
    B=[int(i) for i in input().split()]
    N=int(input())
    rep={}
    for i,b in enumerate(B):
        rep[str(b)]=str(i)
    # print(rep)
    ans=[]
    for _ in range(N):
        a=input()
        num=''
        for d in a:
            num+=rep[d]
        ans.append((a,int(num)))
    ans.sort(key=lambda x: x[1])
    for i in range(N): print(ans[i][0])

# 2: 366**2
if False:
    N=int(input())
    S=[tuple(map(int,input().split('/'))) for _ in range(N)]
    if len(S)>=366: print(366)
    elif N==0: print(2)
    else:
        cal=[[] for m in range(12)]
        day=6 #0-6: 0-MON
        for m in range(12):
            if m+1==2: e=29
            elif m+1 in (4,6,9,11): e=30
            else: e=31
            for d in range(1,e+1):
                cal[m].append([d,day,day in (5,6)])
                day=(day+1)%7
        for m,d in S:
            m-=1
            d-=1
            while cal[m][d][2]:
                if d+1<len(cal[m]): d+=1
                else:
                    m+=1
                    m%=12
                    d=0
                if (m,d)==(11,30): break
            cal[m][d][2]=True
        ans=-1
        cnt=0
        for m in range(12):
            for d in range(len(cal[m])):
                if cal[m][d][2]:
                    cnt+=1
                else:
                    ans=max(ans,cnt)
                    cnt=0
        ans=max(ans,cnt)
        print(ans)
        # print(cal[11])

#ARC036-B
if False:
    N=int(input())
    H=[int(input()) for _ in range(N)]
    if N==1: print(1); exit()
    ans=0
    cnt=2
    prev=1 if H[0]<H[1] else 0 #1:<,0:>
    for i in range(1,N-1):
        tmp=1 if H[i]<H[i+1] else 0
        if prev<tmp:
            ans=max(ans,cnt)
            cnt=2
        else:
            cnt+=1
        prev=tmp
    ans=max(ans,cnt)
    print(ans)

#D2019PC-C
if True:
    N=int(input())
    S=[input() for _ in range(N)]
    ans=0
    cnt={'BA':0,'BX':0,'XA':0}
    for s in S: ans+=s.count('AB')
    for s in S:
        l=s[0]
        r=s[-1]
        if l=='B' and r=='A': cnt[l+r]+=1
        elif l=='B': cnt[l+'X']+=1
        elif r=='A': cnt['X'+r]+=1 
    if cnt['BA']:
        ans+=cnt['BA']-1
        if cnt['BX'] and cnt['XA']:
            ans+=min(cnt['BX']-1,cnt['XA']-1)+2
        else:
            ans+=int(bool(cnt['BX']))+int(bool(cnt['XA']))
    else:
        ans+=min(cnt['BX'],cnt['XA'])
    print(ans)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;
const int INF =1000000;


int main(){
ll n; cin>>n;
ll res=0;
ll count=n/10;
if(n%2==0){

bool flag=1;
 while(flag){
  res+=count;
  count/=5;
  if(count==0)flag=0;

}
cout<<res<<endl;
}else cout<<0<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int x,t;
   cin >> x >> t;

   int ans = x-t;
   if(ans < 0) cout << 0 << endl;
   else cout << ans << endl;


   return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++) cin >> s[i];
    int count=n;
    sort(s,s+n);
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            count--;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%ld", &x); return x;}


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

bool ask(ll x){
	printf("? %lld\n", x);
	fflush(stdout);
	char c;
	scanf(" %c", &c);
	return c == 'Y';
}

ll power[10] = {1LL, 10LL, 100LL, 1000LL, 10000LL, 100000LL, 1000000LL, 10000000LL, 100000000LL, 1000000000LL};

int main(void){
	if (ask(power[9])){
		// 10^n
		for(int i=8;i>=0;i--){
			if (!ask(power[i] + 1)){
				cout << "! " << power[i+1] << endl; return 0;
			}
		}
		cout << "! 1" << endl; return 0;
	}else{
		for(int i=8;i>=0;i--){
			if (ask(power[i])){
				// 10^i + 1 以上 10^{i+1} 未満
				ll ng = power[i], ok = power[i+1];
				while(llabs(ng - ok) > 1){
					ll mid = (ok + ng) / 2;
					if (ask(mid * 10)) ok = mid; else ng = mid;
				}
				cout << "! " << ok << endl; return 0;
			}
		}
	}
    return 0;
}




Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	
	final static int INF = 1001;
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] A = new int[INF];
		char[] x = new char[INF];
		char[] y = new char[INF];
		
		for(int i = 0; i < n; i++){
			String str = br.readLine();
			String str2 = br.readLine();
			x = str.toCharArray();
			y = str2.toCharArray();
			A[i] = LCS(x, y);
		}
		
		for(int i = 0; i < n; i++){
			System.out.println(A[i]);
		}
	}
	
	public static int LCS(char[] x, char[] y){
		int[][] a = new int[INF][INF];
		int m = x.length;
		int n = y.length;
		
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= n; j++){
				if(x[i - 1] == y[j - 1]){
					a[i][j] = a[i - 1][j - 1] + 1;
				}else if(a[i - 1][j] >= a[i][j - 1]){
					a[i][j] = a[i - 1][j];
				}else{
					a[i][j] = a[i][j - 1];
				}
			}
		}
		
		return a[m][n];
	}
}

Measured memory_bytes: 159280
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  int A, B, M, PA[100000], PB[100000];
  cin >> A >> B >> M;
  REP(i, A) {
    cin >> PA[i];
  }
  REP(i, B) {
    cin >> PB[i];
  }
  int ret = *min_element(PA, PA + A) + *min_element(PB, PB + B);
  REP(i, M) {
    int X, Y, C;
    cin >> X >> Y >> C;
    int c = PA[X-1] + PB[Y-1] - C;
    if(c < ret) {
      ret = c;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,Q,a[maxn],p[maxn],c[maxn],d[maxn],c2,q[maxn],c3,ans;

inline void wk(int x)
{
	rep(i,1,n) if(a[i]>=a[x]) p[i]=1; c2=0; c3=0;
	rep(i,1,n)
	{
		int cnt=0;
		while(p[i]==1) cnt++,d[++c2]=a[i],i++;
		sort(d+1,d+c2+1);
		rep(j,1,(c2-k+1)) q[++c3]=d[j]; c2=0;
	}
	sort(q+1,q+c3+1); if(q[Q]) ans=min(ans,q[Q]-a[x]);
	rep(i,1,c3) q[i]=0; rep(i,1,n) p[i]=0;
}

int main()
{
	n=read(); k=read(); Q=read(); rep(i,1,n) a[i]=read(); ans=inf;
	rep(i,1,n) wk(i); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXM 100000
#define MO 1000000007
using namespace std;
struct Matrix
{
	int M[4][4];
	Matrix operator * (const Matrix &b)
	{
		Matrix ret;
		for(int i=1;i<=3;i++)
			for(int j=1;j<=3;j++)
			{
				ret.M[i][j]=0;
				for(int k=1;k<=3;k++)
					ret.M[i][j]=(1LL*ret.M[i][j]+1LL*M[i][k]*b.M[k][j]%MO)%MO;
			}
		return ret;
	}
};
int x[MAXM+5],N,M;
int finans[4],d[4];
Matrix PowMod(Matrix a,int b)
{
	Matrix ret;
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
		{
			if(i==j)
				ret.M[i][j]=1;
			else
				ret.M[i][j]=0;
		}
	while(b)
	{
		if(b&1)
			ret=ret*a;
		a=a*a;
		b>>=1;
	}
	return ret;
}
void SPMul(Matrix ans)
{
	memset(finans,0,sizeof(finans));
	for(int j=1;j<=3;j++)
		for(int k=1;k<=3;k++)
			finans[j]=(1LL*finans[j]+1LL*ans.M[j][k]*d[k]%MO)%MO;
	d[1]=finans[1],d[2]=finans[2],d[3]=finans[3];
}
int main()
{
	scanf("%d %d",&N,&M);
	for(int i=1;i<=M;i++)
		scanf("%d",&x[i]),x[i]++;
	sort(x+1,x+1+M);
	Matrix ans,usu,ususpe;
	//===========================================
	usu.M[1][1]=1,usu.M[1][2]=0,usu.M[1][3]=0;
	usu.M[2][1]=1,usu.M[2][2]=1,usu.M[2][3]=0;
	usu.M[3][1]=1,usu.M[3][2]=2,usu.M[3][3]=1;
	//===========================================
	ususpe.M[1][1]=1,ususpe.M[1][2]=0,ususpe.M[1][3]=1;
	ususpe.M[2][1]=1,ususpe.M[2][2]=1,ususpe.M[2][3]=1;
	ususpe.M[3][1]=1,ususpe.M[3][2]=2,ususpe.M[3][3]=2;
	//===========================================
	d[1]=d[2]=d[3]=1;
	int pre=1;
	for(int i=1;i<=M;i++)
	{
		ans=PowMod(ususpe,x[i]-pre-1);
		SPMul(ans);
		ans=usu;
		SPMul(ans);
		pre=x[i];
	}
	ans=PowMod(ususpe,N-pre);
	SPMul(ans);
	printf("%d\n",d[3]);
	return 0;
}

Measured memory_bytes: 512
n, a, b = (int(i) for i in input().split())
#print(a,b,c)
ans=0
for i in range(1,n+1):
  j = str(i)
  l=[int(k) for k in j]   
  gokei=sum(l)
  if a<=gokei<=b:
    ans+=i
    
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace ALDS1_3_D
{
    class Program
    {
        interface IStack { }
        class Flat : IStack { }
        class SlopeDown : IStack
        {
        }
        class Pond : IStack
        {
            public int area;
            public int wide;
        }
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var stack = new Stack<IStack>();
            foreach (var c in line)
            {
                switch (c)
                {
                    case '\\': stack.Push(new SlopeDown()); break;
                    case '_': stack.Push(new Flat()); break;
                    case '/':
                        bool flag = false;
                        foreach (var item in stack) if (item is SlopeDown) { flag = true; break; }
                        if (flag)
                        {
                            int area = 1, wide = 2;
                            while (stack.Count > 0)
                            {
                                var top = stack.Pop();

                                if (top is SlopeDown)
                                {
                                    stack.Push(new Pond() { area = area, wide = wide });
                                    break;
                                }
                                else if (top is Flat)
                                {
                                    wide++;
                                    area++;
                                }
                                else if (top is Pond)
                                {
                                    area += (top as Pond).area + (top as Pond).wide;
                                    wide += (top as Pond).wide;
                                }
                            }
                        }
                        break;
                }
            }
            var s = new Stack<Pond>();
            int a = 0;
            while (stack.Count > 0)
            {
                var top = stack.Pop();
                if (top is Pond)
                {
                    s.Push(top as Pond);
                    a += (top as Pond).area;
                }
            }
            Console.WriteLine(a);
            Console.Write(s.Count);
            foreach (var p in s)
            {
                Console.Write(" " + p.area);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 10828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;


void solve1()
{
    ll n; cin >> n;

    cout << n*(n-1) / 2 << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3628
def divplis(N):
    lis = [i for i in range(N+1)]
    for i in range(int(N**0.5+1),1,-1):
        if lis[i] == i:
            lis[i::i] = [i]*(N//i)
    return lis

divp = divplis(10**6+1)
N = int(input())
d = [0]*(10**6+1)
A = [int(i) for i in input().split()]


def pfact(N):
    b = 0
    while N != 1:
        n = divp[N]
        if b != n:
            d[n] += 1
        b = n
        N = N // n
    return 0
    
for a in A:
    pfact(a)
m = max(d)
if m <= 1:
    print("pairwise coprime")
elif m == N:
    print("not coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 151316
N = int(input())
s = input()

possible = 0
finish_flag = 0
for animal0 in range(2):
    if finish_flag == 1:
        break
    for animal1 in range(2):
        if finish_flag == 1:
            break
        animal = [0] * N
        animal[0] = animal0
        animal[1] = animal1
        for i in range(1, N - 1):
            if animal[i] == 0:
                animal[i + 1] = animal[i - 1] if s[i] == 'o' else (animal[i - 1] + 1) % 2
            else:
                animal[i + 1] = (animal[i - 1] + 1) % 2 if s[i] == 'o' else animal[i - 1]
        if animal[N - 1] == 0:
            animal0_true = animal[N - 2] if s[N - 1] == 'o' else (animal[N - 2] + 1) % 2
        else:
            animal0_true = (animal[N - 2] + 1) % 2 if s[N - 1] == 'o' else animal[N - 2]
        if animal[0] == 0:
            animal1_true = animal[N - 1] if s[0] == 'o' else (animal[N - 1] + 1) % 2
        else:
            animal1_true = (animal[N - 1] + 1) % 2 if s[0] == 'o' else animal[N - 1]
        if animal0 == animal0_true and animal1 == animal1_true:
            possible = 1
            finish_flag = 1

if possible:
    ans = [0] * N
    for i in range(N):
        ans[i] = 'S' if animal[i] == 0 else 'W'
    print("".join(ans))
else:
    print(-1)


Measured memory_bytes: 50272
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Buffet | diff Buffet.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Buffet.cpp && ./a.out

/*
 
 9/7/2019
 
 5:01-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N],C[MAX_N];
int N;

void solve() {
  LL res=0;
  REP(i,N)res+=B[i];
  REP(i,N-1)if(A[i+1]-A[i]==1) res+=C[A[i]-1];
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  REP(i,N) cin>>B[i];
  REP(i,N-1) cin>>C[i];
  solve();
  
  return 0;
}


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

int main(){
    vector<char> S(4);
    for(int i = 0; i < 4; i++){
        cin >> S[i];
    }

    if((S[0] == '0' && S[1] >= '1') || (S[0] == '1' && S[1] <= '2')){
        if((S[2] == '0' && S[3] >= '1') || (S[2] == '1' && S[3] <= '2')){
            cout << "AMBIGUOUS" << endl;
            return 0;
        }else{
            cout << "MMYY" << endl;
            return 0;
        }
    }else if((S[2] == '0' && S[3] >= '1') || (S[2] == '1' && S[3] <= '2')){
        cout << "YYMM" << endl;
        return 0;
    }else{
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int const INF = 1e10;

int w,h; int fie[50][50];
void dfs(int y,int x){
    fie[y][x]=0;
    for (int i = -1; i <= 1; i++){
        for (int j = -1; j <= 1; j++){
            int ny=y+i,nx=x+j;
            if(ny>=0&&ny<h&&nx>=0&&nx<w&&fie[ny][nx]==1)dfs(ny,nx);
        }
    }
}

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

    while(true){
        cin>>w>>h; if(w+h==0)break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++) cin>>fie[i][j];
        }
        int ans=0;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if(fie[i][j]==1){
                    dfs(i,j);
                    ans++;
                }
            }
        }
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 3316
#include<iostream> 
#include<vector> 
#include<iomanip> 
using namespace std; 
#define lld long long int
#define X 1000000007
#define fast();  ios_base::sync_with_stdio(false); cin.tie(0);
# define rec(i,n) for(int i=0;i<n;i++) 
#define w(t) int t; cin>>t; while(t--)
int n; 
double a[3003]; 
double dp[3001][3001]; 
double coin(int i,int j) 
{ if(i<0) 
    return 0; 
  if(j==n) 
  { 
     if(i==0) 
     return 1; 
     return 0;
  }
  if(dp[i][j]!=-1)
   return dp[i][j];  
  dp[i][j]=(a[j])*coin(i-1,j+1) + (1-a[j])*coin(i,j+1); 
  
  return dp[i][j]; 
}
int main()
{
    fast(); 
    cin>>n; 
    rec(i,n) 
     cin>>a[i]; 
     rec(i,n+1) 
       rec(j,n+1)
         dp[i][j]=-1; 
     double ans=0; 
     int i=(n+1)/2; 
     for( ; i<=n;i++) 
      ans+= coin(i,0); 
      cout<<fixed<<setprecision(12)<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 70784
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    sc.Split(bufio.ScanWords)
    log.SetFlags(log.Lshortfile)
    s := nextString()
    var ans int = -1
    switch s{
    case "SUN":
        ans = 7
    case "MON":
        ans = 6
    case "TUE":
        ans = 5
    case "WED":
        ans = 4
    case "THU":
        ans = 3
    case "FRI":
        ans = 2
    case "SAT":
        ans = 1
    }
    fmt.Println(ans)
}

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

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
    return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}
func gcd(a, b int) int {
    if a < b {
        a, b = b, a
    }
    for b != 0 {
        a, b = b, a%b
    }
    return a
}
func max(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
func min(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
func sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
func abs(a int) int {
    if a < 0 {
        return -a
    }
    return a
}

type pair struct {
    a, b int
}

type pairs []pair

func (p pairs) Len() int {
    return len(p)
}
func (p pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
    if p[i].a == p[j].a {
        return p[i].b < p[j].b
    }
    return p[i].a < p[j].a
}


Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize,
        xyh: [(i64, i64, i64); n],
    };
    for c_y in 0..=100 {
        for c_x in 0..=100 {
            let mut c_h = 0;
            for &(x_i, y_i, h_i) in xyh.iter() {
                if h_i == 0 {
                    continue;
                }
                c_h = h_i + (x_i - c_x).abs() + (y_i - c_y).abs();
                break;
            }

            let mut ok = true;
            for &(x_i, y_i, h_i) in xyh.iter() {
                if h_i != std::cmp::max(c_h - ((x_i - c_x).abs() + (y_i - c_y).abs()), 0) {
                    ok = false;
                    break;
                }
            }
            if ok {
                println!("{} {} {}", c_x, c_y, c_h);
                return;
            }
        }
    }
}


Measured memory_bytes: 2172
#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,m=get_i
n-=1
m-=1
puts n*m

Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin>>N;
    long A[N];
    long T=0,S=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(T>A[i]){
            // cout<<A[i]<<" + "<<T-A[i]<<" = ";
            S+=(T-A[i]);
            A[i]=T;
            // cout<<T<<endl;
        }
        else{
            // cout<<A[i]<<" + "<<0<<" = ";
            T=A[i];
            // cout<<T<<endl;
        }
        
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 5132
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    string output;
    int num;
    
    cin >> s;
    
    num = s.size()-2;
    
    output = s[0] + to_string(num) + s[s.size()-1];
    
    cout << output;
    
    
   
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    char n[3],s;
    int a;
    scanf("%s",n);
    a=0;
    for(int i=0;i<3;i++){
        if(n[i] == '7'){
            a=1;
        }
    }
    if(a==1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


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

int n,ans=0;
string t;
stack<char>s;

void solve(char c){
    if(!s.empty() and s.top()!=c)
        ans++,s.pop();
    else s.push(c);    
}
int main(){
        cin>>t;
        n=t.size();

    up(i,0,n){
        solve(t[i]);
    }
    cout<<ans*2<<"\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int facctorialMethod(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int main() {
	long long N; std::cin >> N;
	double mean = 0;
	long long count = facctorialMethod(N);
	std::vector<std::pair<double, double>> XY(N);
	for (auto& r : XY)
		std::cin >> r.first >> r.second;
	std::sort(XY.begin(), XY.end());
	do {
		for (int i = 0; i < N - 1; ++i)
			mean += std::sqrt(std::pow(XY[i].first - XY[i + 1].first, 2) + std::pow(XY[i].second - XY[i + 1].second, 2));
	} while (std::next_permutation(XY.begin(), XY.end()));
	std::cout << std::setprecision(10) << mean / count << std::endl;

	return 0;
}


Measured memory_bytes: 3792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
  int a,b,c,q,x;
  a=0;
  scanf("%d",&x);
  for(b=1;b<33;b++)
  {
   for(q=2;q<11;q++)
    {
     c=pow(b,q);
     if(c<=x){
       a=fmax(a,c);
     }
   }
 }
  printf("%d",a);
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	double a;
	cin >>a;
	
	double z = a/3.0;
	printf("%.14f\n", z*z*z);
	return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  	ll k, n;
  	cin >> k >> n;
  	ll houses[n];
  	for (int i = 0; i < n; i++) {
  	    cin >> houses[i];
  	}
  	ll dis[n];
  	dis[0] = k - houses[n - 1] + houses[0];
  	for (int i = 1; i < n; i++) {
  	    dis[i] = houses[i] - houses[i - 1];
  	}
  	ll longest = *max_element(dis, dis + n);
  	ll total = accumulate(dis, dis + n, 0);
  	cout << (total - longest);
	return 0;
}

Measured memory_bytes: 3328
n=int(input())
p=list(map(int,input().split()))
ct=0
ct2=0
out=[]
for i in range(n-1):
    if p[i]>p[i+1]:
        ct+=1
        out.append(i)
if ct>2:print('NO')
elif ct==0:print('YES')
elif ct==1:
    p[out[0]],p[out[0]+1]=p[out[0]+1],p[out[0]]
    for i in range(n-1):
        if p[i]>p[i+1]:
            ct2+=1
    if ct2==0:print('YES')
    else:print('NO')
else:
    p[out[0]],p[out[1]+1]=p[out[1]+1],p[out[0]]
    for i in range(n-1):
        if p[i]>p[i+1]:
            ct2+=1
    if ct2==0:print('YES')
    else:print('NO')

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

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

    ll s;
    cin >> s;

    const ll v = 1e9;

    ll x = (v - s % v) % v;
    ll y = (s + x) / v;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>

#define rep(i,n) for(int i=0;i<(n);i++)


int main(){
        long long int K;
        scanf("%lld",&K);
        long long int N = 50;
        long long int a[N];
        
        long long int R = K % N;
        long long int Q = (K-R)/N;
        printf("50\n");
        rep(i,N){
                if (i < R){
                        printf("%lld",50 + Q);
                }
                else {
                        printf("%lld",49 + Q - R);
                }
                if (i < N-1){
                        printf(" ");
                }
        }
        puts("");
        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
const long double dinf=10000000000000.0;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
long double dp[1005];
struct edge{
    int to;long double cost;
};
int n;
vector<vector<edge>> graph;
ll xs,ys,xg,yg;
double dijkstra(){
    for(int i=0;i<n+2;i++)dp[i]=dinf;
    dp[0]=0.0;
    priority_queue<Pd,vector<Pd>,greater<Pd>> q;
    q.push(P(0.0,0));//始点を０で置く
    while(!q.empty()){
        Pd a=q.top();
        q.pop();
        if(dp[a.se]<a.fi)continue;
        for(edge e:graph[a.se]){
            if(dp[e.to]>dp[a.se]+e.cost){
                dp[e.to]=dp[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(Pd(dp[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
return dp[n+1];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>xs>>ys>>xg>>yg;
cin>>n;
graph.resize(n+2);
vector<Pi> a(n+2);
a[0]=Pi(P(xs,ys),0.0);
for(int i=1;i<=n;i++){
    ll b,c;long double d;
    cin>>b>>c>>d;
    a[i]=Pi(P(b,c),d);
}
a[n+1]=Pi(P(xg,yg),0.0);
for(int i=0;i<n+2;i++){
    for(int j=i+1;j<n+2;j++){
        int t=j;long double cost=max(0.0,sqrt((double)(abs(a[i].fi.fi-a[j].fi.fi)*abs(a[i].fi.fi-a[j].fi.fi))+(double)(abs(a[i].fi.se-a[j].fi.se)*abs(a[i].fi.se-a[j].fi.se)))-(double)(a[i].se+a[j].se));
        graph[i].push_back(edge{t,cost});
        graph[t].push_back(edge{i,cost});
        //printf("%.12f\n",cost);
    }
}
printf("%.12f\n",dijkstra());
}


Measured memory_bytes: 42988
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

A = [-x for x in A]
A.sort()

for i in range(M):
	a = heappop(A)
	heappush(A, -(-a//2))
	

print(-sum(A))



Measured memory_bytes: 16324
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            String ans = "";
            int D = in.nextInt();
            if (D == 25) {
                ans = "Christmas";
            } else if (D == 24) {
                ans = "Christmas Eve";
            } else if (D == 23) {
                ans = "Christmas Eve Eve";
            } else if (D == 22) {
                ans = "Christmas Eve Eve Eve";
            }
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

int main()  {
    int n,a,b;
    cin>>n>>a>>b;
    a-=b;
    a = abs(a);
    if(a%2 == 0){
        cout<<"Alice\n";
    }
    else{
        cout<<"Borys\n";
    }
    return 0;
}


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

int N;
vector<int> a(4, 0);
vector<vector<vector<double>>> dp;

double rec(int one, int two, int three)
{
	if (one == 0 && two == 0 && three == 0)
		return 0;
	if (one < 0 || two < 0 || three < 0)
		return 0;
	if (dp[one][two][three] != -1.0)
		return dp[one][two][three];
	dp[one][two][three] = 0;
	int rem = one + two + three;
	double val = N + one * rec(one - 1, two, three) + two * rec(one + 1, two - 1, three) + three * rec(one, two + 1, three - 1);
	val = val / rem;
	return dp[one][two][three] = val;
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		a[x]++;
	}
	dp.resize(N + 1);
	for (int i = 0; i <= N; i++)
	{
		dp[i].resize(N + 1, vector<double> (N + 1, -1.0));
	}
	double answer = rec(a[1], a[2], a[3]);
	cout << fixed << setprecision(12) << answer;

	return 0;
}

Measured memory_bytes: 219200
#include <stdio.h>
#define BLACK 2
#define GRAY 1
#define WHITE 0
#define MAX 2000
#define INF 1<<21
int n;
int M[MAX][MAX];
void dijkstra();
int main(){
  int i,j,u,k,c,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INF;
    }
  }
 
 for(i=0;i<n;i++){
   scanf("%d %d",&u,&k);
   for(j=0;j<k;j++){
     scanf("%d %d",&v,&c);
     M[u][v]=c;
   }
 }
  dijkstra();
  
  return 0;
}

void dijkstra(){
    int u,mincost;
  int i,v;
  int d[MAX],color[MAX];
  for(i = 0;i<n;i++){
    d[i] = INF;
    color[i] = WHITE;
  }

  
  d[0] = 0;
  
  while(1){
   
    mincost = INF;
    u = -1;
    for(i=0;i<n;i++){
 
      if(mincost>d[i] && color[i]!=BLACK){
	u = i;
	mincost = d[i];
      }
    }
    if(u == -1)break;


      
    color[u] = BLACK;
    
    for(v = 0;v<n;v++){
      if(color[v] != BLACK  && M[u][v]!=INF){
	if(d[v] > M[u][v]+d[u]){
	  d[v] = M[u][v]+d[u];
	  color[v] = GRAY;
	}
      }
    }
  }

  int sum = 0;
  for(i=0;i<n;i++){
    if(d[i] == INF )
      printf("%d -1\n",i);
    else  printf("%d %d\n",i,d[i]);
  }

}





Measured memory_bytes: 2304
def powl(x, n, l):#繰り返し2乗法 O(log n)
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = ans*x
        x = (x*x)%l
        n = n >> 1 #ビットシフト
    return ans

n,a,b=map(int,input().split())

out=powl(2,n,pow(10,9)+7)-1
X,Y=1,1
for i in range(a):
    X=(X*(i+1))%(pow(10,9)+7)
    Y=(Y*(n-i))%(pow(10,9)+7)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

for i in range(a,b):
    X=(X*(i+1))%(pow(10,9)+7)
    Y=(Y*(n-i))%(pow(10,9)+7)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

print(out%(pow(10,9)+7))

Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int main() {
    int n, x; cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long long sum = 0;
    for (int i = 1; i < n; i += 2) {
        if (a[i - 1] + a[i] > x) {
            int sa = a[i - 1] + a[i] - x;
            if (sa <= a[i]) {
                a[i] -= sa;
            } else {
                a[i - 1] = sa - a[i];
                a[i] = 0;
            }
            sum += sa;
        }
        if (i + 1 < n && a[i] + a[i + 1] > x) {
            int sa = a[i] + a[i + 1] - x;
            if (sa <= a[i + 1]) {
                a[i + 1] -= sa;
            } else {
                a[i] = sa - a[i + 1];
                a[i + 1] = 0;
            }
            sum += sa;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
// #include <vector>
// using namespace std;
int S[100000], n;
int binarySearch(int &T_i)
{
    int head = 0, tail = n, mid;
    while (head != tail)
    {
        mid = (head + tail) / 2;
        if (S[mid] == T_i)
        {
            return 1;
        }
        else if (S[mid] < T_i)
        {
            head = mid + 1;
        }
        else
        {
            tail = mid;
        }
    }
    if (S[head] == T_i)
        return 1;
    else
        return 0;
}
int main()
{
    int q, T_i, ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &T_i);
        ans += binarySearch(T_i);
        // if (binarySearch(T_i) == 1)
        //     ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, c;
	cin >> a >> b;
	if (a <= 5) c = 0;
	else if (a <= 12) c = b / 2;
	else c = b;
	cout << c << "\n";


	return 0;
}


Measured memory_bytes: 256
//  //
    //  Farid   //
//  //  //  //  //  //
    //  Imran   //
        //  //
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using kiwi = queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;
#define MOD 1000000007
const ll mx = 2e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)

int main()
{
    int no_of_stones, no_of_steps;
    cin >> no_of_stones >> no_of_steps;

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    const int oo = 1e9;
    vector <int> minimum_cost(no_of_stones + 1, oo);
    minimum_cost[1] = 0;

    for(int i = 2; i <= no_of_stones; i++)
    {
        for(int j = i - 1; j >= max(1, i - no_of_steps); j--)
        {
            minimum_cost[i] = min(minimum_cost[i], minimum_cost[j] + abs(height[i] - height[j]));
        }
    }

    cout << minimum_cost[no_of_stones];
    return 0;
}


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

int main(int argc, char const *argv[])
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << (float)W*(float)H/2.0 << " ";

    // W*Hの中心にx,yがあれば分割方法は無限通りある
    if (W%2==0 && H%2==0)
        if (W/2==x && H/2==y)
            cout << "1" << endl;
        else
            cout << "0" << endl;
    else
        cout << "0" << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  rep(i,s.size())if(s[i] != t[i])cnt++;
  cout << cnt << endl;
  



  return 0;
}

Measured memory_bytes: 3824
import sys

num = str(input())
nums = [int(i) for i in num]

for i in range(2**3):
    res = nums[0]
    # ビットが立っていたら、+ を与える
    for pos_i in range(0, 3):
        if (i >> pos_i) & 1:
            res += nums[pos_i + 1]
        else:
            res -= nums[pos_i + 1]
    
    # 条件を満たしていれば、出力してEND
    pos = ["-"]*3
    if i >> 0 & 1:
        pos[0] = "+"
    if i >> 1 & 1:
        pos[1] = "+"
    if i >> 2 & 1:
        pos[2] = "+"
            
    res_msg = "{}{}{}{}{}{}{}={}".format(nums[0], pos[0], nums[1], pos[1], nums[2], pos[2], nums[3], res)

#    print(res_msg)
    if res == 7:
        print(res_msg)
        sys.exit()

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	int i;
	int j;
	int v;
	int flag = 1;
	int count = 0;
	
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	int A[] = new int[n];

	//Initialize data
	for(i=0 ; i<A.length ; i++){
	    int num = scan.nextInt();
	    A[i] = num;
	}
	
	while( flag==1 ){
	    flag = 0;
	    for(j=n-1 ; j>0 ; j--){
		if(A[j] < A[j-1]){
		    v = A[j];
		    A[j] = A[j-1];
		    A[j-1] = v;
		    count++;
		    flag = 1;
		}
	    }
	}
	
	for(i=0 ; i<A.length-1 ; i++){
	    System.out.print(A[i]+" ");
	    }
	System.out.println(A[i]);
	System.out.println(count);
    }
    
}



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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  double ans;
  if(x / a > a * b / 2){
    ans = atan(2 * (a * a * b - x) / (a * a * a));
  }
  else{
    ans = atan((a * b * b) / (2 * x));
  }
  
  ans *= 180 / 3.141592653589;
  
  cout << fixed << setprecision(8) << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  int n; cin >> n;
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      if (i*4 + j*7 == n) {
        cout << "Yes\n";
        return 0;
      }
    }
  } 
  cout << "No\n";
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll N, M;
vector<int> v[100010];
int check[100010];

void dfs(int s, int s2, int x){
  for(int i = 0; i < v[s].size(); i++){
    if(v[s][i] == s2)  continue;
    if(check[v[s][i]] == -1){
      check[v[s][i]] = x;
      dfs(v[s][i], s, 1-x);
    }
    else if(check[v[s][i]] == 2){
      continue;
    }
    else if(check[v[s][i]] != x){
      check[v[s][i]] = 2;
      dfs(v[s][i], s, 1-x);
    }
    else{
      continue;
    }
  }
}

int main(){
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for(int i = 0; i <= N; i++) check[i] = -1;
  check[1] = 0;
  dfs(1, 0, 1);
  ll res0 = 0, res1 = 0, res2 = 0;
  for(int i = 1; i <= N; i++){
    if(check[i] == 0) res0++;
    else if(check[i] == 1) res1++;
    else if(check[i] == 2) res2++;
  }
  //cout << res0 << " " << res1 << endl;
  if(res2 > 0){
    cout << N*(N-1)/2 - M << endl;
  }
  else{
    cout << res0*res1 - M << endl;
  }

  return 0;
}


Measured memory_bytes: 9728
unittest
{
	assert( [ "2 60", "10 10", "100 100" ].solve == 110 );
	assert( [ "3 60", "10 10", "10 20", "10 30" ].solve == 60 );
	assert( [ "3 60", "30 10", "30 20", "30 30" ].solve == 50 );
	assert( [ "10 100", "15 23", "20 18", "13 17", "24 12", "18 29", "19 27", "23 21", "18 20", "27 15", "22 25" ].solve == 145 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto t = 0L;
	input.front.formattedRead!"%s %s"( n, t );
	auto abs = new long[ 2 ][ n ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	
	// dp[ 経過時間 ] = 美味しさの合計
	auto dp = new long[ 1 + t ];
	foreach( ab; abs.sort )		// 食べる時間が一番長いやつを最後に持ってくるべきなので必要時間が小さい順に試す
	{
		foreach_reverse( tt; 0L .. t )
		{
			auto k = min( t, tt + ab[ 0 ] );		// ラストオーダーに間に合えば食べる時間がオーバーしても良い
			dp[ k ] = max( dp[ k ], dp[ tt ] + ab[ 1 ] );
		}
	}
	return dp[ $ - 1 ];
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s , t; 
  cin >> s >> t;
  int ans = 0 ; 
  for(int i = 0 ; i < s.length() ; i++){
    if(s[i] != t[i])
      ans++ ; 
  }
  cout << ans ; 
  return 0 ; 
}

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    int X,N,tmp,dist=10000000,ans;
    map<int,bool> P;

    cin>>X>>N;

    for(int i=0;i<N;i++){
        cin>>tmp;
        P[tmp]=true;
    }

    for(int i=-100;i<200;i++){
        if(P[i] == true)continue;

        if(dist > abs(X-i)){
            dist=abs(X-i);
            ans=i;
        }
    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3640