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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    cout << (a-b>=0? "delicious":(a+x-b>=0? "safe":"dangerous"));
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//


#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (unsigned long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VLL vector<long long>
#define VULL vector<unsigned long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second

using namespace std;

signed main()
{
	LL N;
	LL M;
	LL ret = 0;
	const LL MAX = 1000000007;

	cin >> N >> M;

	ULL n = N < M ? N : M;
	ULL m = N > M ? N : M;


	if (m - n > 1) {
		cout << 0;
		return 0;
	}

	ret = 1;
	for (size_t i = 1; i <= n; i++) {
		ret *= i;
		ret %= MAX;
	}

	if (n == m) {
		ret = ret * ret;
		ret %= MAX;
		ret *= 2;
	}
	else {
		ret = ret * ret;
		ret %= MAX;
		ret *= m;
	}

	ret %= MAX;
	cout << ret;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define int long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair
#define f first
#define s second
#define mod 998244353
int32_t main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);


////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                int php[4000] , cdc[8000], cdm[8000];
//                for(int j=0;j<5;j++){
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//for(int i=0;i<2000;i++)php[i/10]=1;
//                }
//
// vector<int> ab;
// vector<int> ab1(1000);
// vector<int> ab2;
// vector<int> ab3;
// vector<int> ab4;
// vector<int> ab5;
// string abcd="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn";
// string abcd1="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn cbcksknlsnv";
// string abcd2="bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn kjeaebbaekcmaekes";
//
//
// char abcde[1000];
// int mfch=0;
// int abcdefg[1000];
// int abcg[1000];
// int abcfg[1000];

////////////////////////////////////////////////////////////////////////////////////////////////////////



//    ll t;
//    cin>>t;
//    while(t--)
        {
      int n , s;
      cin>>n>>s;
      int w[n+1] , v[n+1];
      for(int i = 1 ; i <= n ; i++){
           cin>>w[i]>>v[i];
      }
     int ps=1;
   vector<vector<int>>dp(n+1 , vector<int>(s+1 , 0LL));

    for(int i=0;i<=n;i++)dp[i][0]=0;
    for(int i=0;i<=s;i++)dp[0][i]=0;


    for(int i=1;i<=n;i++){
        for(int j=1;j<=s;j++){
            if(j<w[i]){
                dp[i][j]= dp[i-1][j];
                continue;
            }
            else dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout<<dp[n][s]<<endl;


    }

}




Measured memory_bytes: 83080
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int N;
  cin>>N;
  vector<i64>vec(N,0);
  i64 sum = 0;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
    sum += vec[i];
  }
  cout<<*min_element(vec.begin(),vec.end())<<" "<<*max_element(vec.begin(),vec.end())<<" "<< sum<<endl;
  
  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3168
N, M, X = map(int, input().split())

INF = 30
ans = 1 << INF

data = []
for i in range(N):
    c = list(map(int, input().split()))
    data.append(c)

for i in range(1, 2**N):
    tmp = 0
    skill = [0] * M
    for j in range(N):
        if i >> j & 1:
            tmp += data[j][0]
            for k in range(M):
                skill[k] += data[j][k + 1]
    if min(skill) >= X and tmp < ans:
        ans = tmp

if ans == 1 << INF:
    print('-1')
else:
    print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ONLINE_JUDGE
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

const ll mod = 1e9+7;

int X[] = {0,1,0,-1,-1,-1,1,1};
int Y[] = {1,0,-1,0,-1,1,-1,1};

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

const int maxn = 10;

int main() {
#ifndef ONLINE_JUDGE
    freopen("qns.txt","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    ll a,b,ab,u,v;
    cin >> a >> b >> ab >> u >> v;
    ll mi = 1e18;
    for(ll i=0;i<=100000;i++) mi = umin(mi,i*2*ab + umax(0,u-i)*a + umax(0,v-i)*b);
    cout << mi << endl;
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

char s[51];

// aaaaaaaaaaaaaaaa
void solve() {
  int N, K;
  scanf("%d%d", &N, &K);
  scanf("%s", s);
  s[K - 1] = (s[K - 1] - 'A' + 'a');
  rep(i, 0, N) printf("%c", s[i]);
  puts("");
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	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);

        while(true){
            int n = sc.nextInt();
            if(n==0)    break;
            double a;
            double[] s = new double[n];
            int sum=0;
            for(int i=0;i<n;i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            double m = (double)sum / n;
            double V=0;
            for(int i=0;i<n;i++){
                V += Math.pow((s[i] - m),2) / n;
            }

            System.out.println(Math.sqrt(V));
        }
    }
}


Measured memory_bytes: 31500
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int a = 0, b = 0, c = 0;

int main(void) {
	Rapid;//固定高速

	int t, x;
	cin >> t >> x;
	cout << (double)t / x << rt;

	please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll used[114514];	vector<ll> pat[114514];
int main(){
	ll n,m;
	cin>>n>>m;
	deque<ll> ham;
	for(int i=0;i<m;i++){
		ll ta,tb;
		cin>>ta>>tb;
		if(i==0){
			ham.pb(ta);used[ta]++;
			ham.pb(tb);used[tb]++;
		}
		pat[ta].pb(tb);
		pat[tb].pb(ta);
	}
	ll f = 0;
	while(f==0){
		f=1;
		ll cur = ham[0];
		for(ll j=0;j<pat[cur].size();j++){
			if( used[ pat[cur][j]  ] == 0 && f==1){
				ham.push_front( pat[cur][j] );
				used[ pat[cur][j] ] = 1;
				f = 0;
			}
		}
		cur = ham[ham.size()-1];
		for(ll j=0;j<pat[cur].size();j++){
			if( used[ pat[cur][j]  ] == 0 && f==1){
				ham.push_back( pat[cur][j] );
				used[ pat[cur][j] ] = 1;
				f = 0;
			}
		}
		if(f==1){
			cout<<ham.size()<<endl;
			for(int i=0;i<ham.size();i++){
				cout<<ham[i]<<" ";
			}
			cout<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 8192
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define MAX 21000000000
const int Mod = 100000007;

using namespace std;

int main(void)
{
	int n, ma, mb;
	vector <int> a, b, c;
	long long int dp[41][401][401];

	cin >> n >> ma >> mb;

	for (int i = 0; i < n; i++)
	{
		int t1, t2, t3;
		cin >> t1 >> t2 >> t3;
		a.push_back(t1);
		b.push_back(t2);
		c.push_back(t3);
	}

	for (int i = 0; i < 41; i++)
	{
		for (int j = 0; j < 401; j++)
		{
			for (int k = 0; k < 401; k++)
			{
				dp[i][j][k] = MAX;
			}
		}
	}

	dp[0][0][0] = 0;

	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i <= 400; i++)
		{
			for (int j = 0; j <= 400; j++)
			{
				if (dp[k][i][j] == MAX)
				{
					continue;
				}
				dp[k + 1][i][j] = min(dp[k + 1][i][j], dp[k][i][j]);
				dp[k + 1][i + a[k]][j + b[k]] = min(dp[k + 1][i + a[k]][j + b[k]], dp[k][i][j] + c[k]);
			}
		}
	}

	long long int res = MAX;
	for (int i = 1; i <= 400; i++)
	{
		for (int j = 1; j <= 400; j++)
		{
			if (i*mb == j*ma)
			{
				res = min(res, dp[n][i][j]);
			}
		}
	}

	if (res == MAX)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 51712
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
    int w, h, n;
    cin >> w >> h >> n;
    int nowx, nowy;
    cin >> nowx >> nowy;

    int ans = 0;
    for(int i=0; i<n-1; i++) {
        int x, y;
        cin >> x >> y;
        if((nowx > x and nowy < y) or (nowx < x and nowy > y))
            ans += abs(x - nowx) + abs(y - nowy);
        else
            ans += max(abs(x - nowx), abs(y - nowy));
        nowx = x;
        nowy = y;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int ans =0;
		int div;
		div = H >= W ? H : W;
		ans += N / div;
		if (N % div > 0) {
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    int n,m,ans=0;
    cin>>n>>m;
    vector<int> red(n,0),ball(n,1);
    red[0]++;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        ball[--y]++;
        if(red[--x])red[y]=1;
        ball[x]--;
        if(!ball[x])red[x]=0;
    }
    rep(i,0,n) if(red[i])ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = INF; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N;
	ll A, B;
	cin >> A >> B;
	ll a = 0, b = 0, c = 0;
	for (i = 0; i < N; i++) {
		ll p;
		cin >> p;
		if (p <= A) a++;
		else if (B + 1 <= p) c++;
		else b++;
	}
	cout << min(a, min(b, c));
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan  3 17:27:56 2019
//
package main

import "fmt"

func pow2(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow2(n-1)
}

func main() {
	var X, Y int
	fmt.Scan(&X, &Y)

	i := 0
	for ; pow2(i)*X <= Y; i++ {
	}
	fmt.Println(i)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

const int MOD = 1000000007;
const int NMAX = 53;

ll a[NMAX][NMAX], sol[NMAX][NMAX], aux[NMAX][NMAX];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            cin >> a[i][j];

    for(int i = 1; i <= n; i ++)
        sol[i][i] = 1;

    while(k) {
        if(k % 2) {
            memset(aux, 0, sizeof(aux));

            for(int i = 1; i <= n; i ++)
                for(int j = 1; j <= n; j ++)
                    for(int l = 1; l <= n; l ++)
                        aux[i][j] = (aux[i][j] + sol[i][l] * a[l][j]) % MOD;
            memcpy(sol, aux, sizeof(aux));
        }

        memset(aux, 0, sizeof(aux));
        for(int i = 1; i <= n; i ++)
            for(int j = 1; j <= n; j ++)
                for(int l = 1; l <= n; l ++)
                    aux[i][j] = (aux[i][j] + a[i][l] * a[l][j]) % MOD;
        memcpy(a, aux, sizeof(aux));

        k /= 2;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            ans = (ans + sol[i][j]) % MOD;
    cout << ans;

    return 0;
}


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

int main(){
    int count=0;
    int A[100],n;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
    
    for (int i=0;i<n;i++){
        int minj = i;
        for (int j=i;j<n;j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        if (i!=minj){
                swap(A[i],A[minj]);
                count++;
        }
    }
    for (int i=0;i<n;i++){
        if (i!=0){cout << " ";};
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 18500000
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int x;
    cin >> x;
    if (x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long H, long long W, std::vector<std::string> s){
  ll cur=0;
  ll prev=0;
  vector<vector<ll>> ans(H,vector<ll>(W,INF));
  if(s[0][0]=='#'){
    ans[0][0]=1;
  }else{
    ans[0][0]=0;
  }
  REP(H){
    For(j,W){
      if(i==0&&j==0)continue;
      if(i!=0){
        if(s[i-1][j]=='#'||s[i-1][j]==s[i][j]){
          chmin(ans[i][j],ans[i-1][j]);
        }else{
          chmin(ans[i][j],ans[i-1][j]+1);
        }
      }
      if(j!=0){
        if(s[i][j-1]=='#'||s[i][j-1]==s[i][j]){
          chmin(ans[i][j],ans[i][j-1]);
        }else{
          chmin(ans[i][j],ans[i][j-1]+1);
        }
      }
    }
  }
  cout<<ans[H-1][W-1]<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> s(W);
    for(int i = 0 ; i < W ; i++){
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


Measured memory_bytes: 384
import math

MOD = 10**9+7


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a):
    g, x, y = xgcd(a, MOD)
    return x % MOD


fact = [1] * 200100
for i in range(1, 200100):
    fact[i] = fact[i-1] * i % MOD


def calc(h, w):
    h -= 1
    w -= 1
    return (fact[h+w]*modinv(fact[h]) % MOD)*modinv(fact[w]) % MOD


h, w, a, b = map(int, input().split())
if a >= h // 2:
    ans = 0
    for i in range(1, h - a + 1):
        ans += calc(i, b) * calc(h + 1 - i, w - b) % MOD
        if ans >= MOD:
            ans -= MOD
    print(ans)

else:
    ans = calc(h, w)
    for i in range(h-a+1, h + 1):
        ans -= calc(i, b) * calc(h + 1 - i, w - b) % MOD
        if ans < 0:
            ans += MOD
    print(ans)


Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  LL a, b;
  cin >> a >> b;
  if(abs(a - b) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
int N,X;
cin>>N>>X;
int num[N];
for(int i=0;i<N;i++){cin>>num[i];}
int sum=0;
for(int j=0;j<N;j++){sum=sum+num[j];}
X=X-sum;
int min=10000;
for(int k=0;k<N;k++){
if(num[k]<min) min=num[k];}
int ans=N+X/min;
cout<<ans;
    return 0;
}



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

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

    int a = 0;
    int l = 0;
    rep(i, n) {
        if (s.at(i) == '(') a++;
        if (s.at(i) == ')') a--;
        if (a < 0) {
            a++;
            l++;
        }
    }
    rep(i, l) s.insert(0, "(");
    rep(i, a) s.push_back(')');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	
	int n,a;
	vector<int>v;
	
	for(n=0;n<10;n++){
	cin>>a;
	v.push_back(a);
	}

	sort(v.begin(),v.end());
	cout << v[9] << endl << v[8] << endl << v[7] << endl;
	
}

Measured memory_bytes: 1216
#include <stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define INF 100000000
#define min(a,b) (a<b?a:b)
int main(){
	int i,j,k,n,m,bit,next,cur,r,newCost,ret;
	int land[200][200] , ship[200][200] , R[1000] ,dp[1000][200];
	while(scanf("%d%d",&n,&m) && n){
		rep(i,200)rep(j,200)land[i][j] = ship[i][j] = INF;
		rep(i,200)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			char t;
			int a,b,c;
			scanf("%d %d %d %c\n",&a,&b,&c,&t);
			a--,b--;
			if(t=='L')land[a][b] = land[b][a] = min(c,land[a][b]);
			else  ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		scanf("%d",&r);	
		rep(i,r)scanf("%d",&R[i]) , R[i]--;
		
		rep(j,1000)rep(k,200)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					newCost = dp[bit][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[bit+1][next] = min( dp[bit+1][next],newCost);
				}
				dp[bit+1][cur] = min(dp[bit+1][cur],dp[bit][cur]+land[R[bit]][R[bit+1]]);
			}
		}
		ret = INF;
		rep(i,n)ret = min(dp[r-1][i],ret);
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 1508
//Arayi
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1, 0 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1, 0 };


const int N = 2e5 + 30;
const lli mod = 36000;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-13;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
struct pt
{
    lli x, y;
    int ind;
    int bl;
    bool operator==(const pt& a)
    {
        return ind == a.ind;
    }
    bool operator<(const pt& b)
    {
        if (x == b.x) return y < b.y;
        return x < b.x;
    }
};




int n, x, pat;
int main()
{
    fastio;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if (i % 2 == 0 && x % 2 == 1) pat++;
    }
    cout << pat << endl;
    return 0;
}

/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/

Measured memory_bytes: 3636
N,K = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(2*K)]
D = []
ans = 0
for i in range(K):
    k = d[2*i +1]
    for j in k:
        if j not in D:
            D.append(j)

ans = N-len(D)
print(ans)

Measured memory_bytes: 9276
#include <stdio.h>
int main(){
  int i,h,H[251],n;

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&H[i]);
  }

  /* output */
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(i!=1) printf("parent key = %d, ",H[i/2]);
     if(2*i<=h) printf("left key = %d, ",H[2*i]);
     if(2*i+1<=h) printf("right key = %d, ",H[2*i+1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
// #pragma GCC optimize "trapv"

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define MAP map<ll ,ll>
#define UMAP unordered_map<ll , ll>
#define endl "\n"
#define SET set<ll> 
#define SETC set<char>
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
#define time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define ll long long int
const ll INF = 1e13+7;
const ll mod = 1e9+7;

void solv(){
    ll n ;
    cin >> n ;
    vll a(n) , b(n);

    FOR(i , 0 , n-1)
        cin >>a[i];
    FOR(i, 0 ,n-1)
        cin >> b[i];

    vll dp(n+1);

    dp[1] = b[0];
    map<ll , ll> mp;
    mp[a[0]]  = dp[1];
    //  3 1 4 2
    ll ans = dp[1];
    FOR(i , 2 , n){
        dp[i] = b[i-1];

        auto it = mp.lower_bound(a[i-1]+1);

        if(it != mp.begin()){
            it--;
            dp[i] += it->second;
        }

        mp[a[i-1]] = dp[i];

        auto it2 = mp.upper_bound(a[i-1]);

        while(it2 != mp.end() and it2->second <= dp[i]){
            auto temp = it2;
            ++temp;
            mp.erase(it2);
            it2 = temp;
        }
        ans = max(ans , dp[i]);
    }
    // return ans;
    cout << ans << endl;
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




Measured memory_bytes: 20256
#include <cstdio>

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

    while (n != 0) {
        if (n % 10 == 9) {
            printf("Yes\n");
            return 0;
        }
        n /= 10;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		double r = in.nextDouble();
		double s = r*r*Math.PI;
		double l = r*2*Math.PI;
		DecimalFormat fm = new DecimalFormat("#.######");
		System.out.println(fm.format(s)+" "+fm.format(l));
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#define cmax 10000

int main(){
  int i,n,j;
  int C[cmax];
    scanf("%d",&n);
  unsigned short A[n],B[n];
  
  
  for( i = 1 ; i <= n ; i++ )
    scanf("%hu",&A[i]);
    
  for( i = 0 ; i <= cmax ; i++ )
    C[i] = 0;

  for( j = 1 ; j <= n ; j++ )
    C[A[j]]++;

  for( i = 1 ; i <= cmax ; i++ )
    C[i] = C[i] + C[i-1];

  for( j = n ; j > 0 ; j-- )
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }


  for( i = 1 ; i < n ; i++ )
    printf("%d ",B[i]);
  printf("%d\n",B[i]);
  return 0;
}

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

int main(){
	int n; cin >> n;
    string s; cin >> s;
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }
	cout << (s.substr(0,n/2)==s.substr(n/2,n/2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def outputList(l):
  r = len(l)
  c = len(l[0])
  
  if r==1 and c==1:
    print(l[0][0])
  else:
    for i in range(r):
      for j in range(c-1):
        print(f'{l[i][j]} ',end='')
      print(l[i][j+1])


n, m, l = map(int, input().split())

a = []
b = []
c = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
  a.append(list(map(int, input().split())))

for i in range(m):
  b.append(list(map(int, input().split())))

for i in range(n):
  for j in range(l):
    for k in range(m):
      c[i][j] += a[i][k] * b[k][j]

outputList(c)





Measured memory_bytes: 7080
from collections import Counter
div = 10**9 + 7

def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

m = int(input())
a = Counter()

for i in range(2,m+1):
    a += Counter(pf(i))

ans = 1
for i in range(1,1001):
    if a[i] == 0:
        continue
    else:
        ans = ans * (a[i] + 1) % div
        
print(ans)

Measured memory_bytes: 41840
#include <iostream>
#include <algorithm>
#include <deque>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int in = 0;
	string s;
	cin>>s;
	deque <char> mq;
	for(int i=0;i<s.length();i++)mq.push_back(s[i]);
	int q;
	cin>>q;
	int t,f;
	char c;
	while(q--){
		cin>>t;
		t--;
		if(t){
			cin>>f>>c;
			f--;
			if(in!=f)mq.push_back(c);
			else mq.push_front(c);
		}
		else in^=1;
	}
	if(in){
		while(!mq.empty()){
			cout<<mq.back();
			mq.pop_back();
		}
		cout<<endl;
	}
	else{
		while(!mq.empty()){
			cout<<mq.front();
			mq.pop_front();
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 960
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool flag=false;
  while(n>0){
    if(!(n%4) || !(n%7)) flag=true;
    n-=7;
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ll x, y, ans = 1e18, tmp;
  cin >> x >> y; 

  tmp = y - x;
  if (tmp >= 0) {
    ans = min(ans, tmp);
  }

  x = -x; tmp = 1;
  tmp += y - x;
  if (tmp >= 0) {
    ans = min(ans, tmp);
  }
  y = -y; tmp = 2;
  tmp += y - x;
  if (tmp >= 0) {
    ans = min(ans, tmp);
  }
  x = -x; tmp = 1;
  tmp += y - x;
  if (tmp >= 0) {
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int i,n;
  string foot[1000];
  while(1){
    int count=0;
    cin >> n;
    if(n==0)break;
    for(i = 0; i < n; i++){
      cin >> foot[i];
    }
    
    for(i = 0; i < n-1; i++){
      if((foot[i]=="lu" && foot[i+1]=="ru")||(foot[i]=="ru" &&foot[i+1]=="lu" )||(foot[i]=="ld" &&foot[i+1]=="rd") ||(foot[i]=="rd" &&foot[i+1]=="ld"))count++;
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   if (A + B < C + D) cout << "Right" << endl;
   else if (A + B > C + D) cout << "Left" << endl;
   else cout << "Balanced" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N,M;
double x[30],y[30],z[30],ans=0;
double calc(int a,int b){
  return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])+(z[a]-z[b])*(z[a]-z[b]);
}
int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>z[i];
  for(int i=0;i<(1<<N);i++){
    if(__builtin_popcount(i)!=M)continue;
    double sum=0;
    for(int j=0;j<N;j++){
      if((i>>j&1)==0)continue;
      for(int k=j+1;k<N;k++){
	if((i>>k&1)==0)continue;
	sum+=calc(j,k);
      }
    }
    ans=max(ans,sum);
  }
  printf("%.8f\n",ans);
  return 0;
}

Measured memory_bytes: 1252
n, a, b = map(int, input().split())

if a == b:
  print(1)
  exit()

if a > b:
  print(0)
  exit()

mid_num = n - 2

if mid_num < 0:
  print(0)
  exit()

print(b * mid_num - a * mid_num + 1)


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define POS(i,j) ((i)*n+(j))

void sieve(char *p,int n){
  int i,j;
  for(i=2;i<=n;i++) p[i]=1;
  p[0]=p[1]=0;
  for(i=2;i*i<=n;i++){
    if(!p[i]) continue;
    for(j=i*i;j<=n;j+=i) p[j]=0;
  }
  return;
}

void run(void){
  const int n=500;
  char *p=(char *)malloc(sizeof(char)*8001);
  sieve(p,8000);
  int *l=(int *)malloc(sizeof(int)*2*n);
  int *r=(int *)malloc(sizeof(int)*2*n);
  int lp=0;
  int rp=0;
  int i=2;
  while(lp<2*n){
    l[lp++]=i++;
  }
  while(rp<2*n){
    if(p[i]) r[rp++]=i;
    i++;
  }
  int64 *board=(int64 *)malloc(sizeof(int64)*n*n);
  int j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if((i+j)%2==0){
	board[POS(i,j)]=l[(i+j)/2]*r[((n-i)+j)/2];
      } else {
	int64 local=(int64)l[(i+j)/2]*l[(i+j)/2+1]*r[((n-i)+j)/2]*r[((n-i)+j)/2+1];
	board[POS(i,j)]=local+1;
      }
    }
  }
  int m;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    printf("%lld",board[POS(i,0)]);
    for(j=1;j<m;j++){
      printf(" %lld",board[POS(i,j)]);
    }
    printf("\n");
  }
}

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


Measured memory_bytes: 4608
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

K, N = rdi()

if K == 1:
        print " ".join(["1"] * ((N+1)/2))
        sys.exit(0)

if K % 2 == 0:
        print K/2,
        for i in range(N-1):
                print K,
        print
        sys.exit(0)

t = [ K/2+1 ] * N
j = N-1
for i in range(N/2):
        if t[j] == 1:
                j -= 1
        else:
                t[j] -= 1
                for k in range(j+1, N):
                        t[k] = K
                j = N-1
        #print t
print " ".join([ str(x) for x in t[:j+1]])

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    V x(5);  VECCIN(x);
    for(int i = 0 ; i < 5 ; i++)
      if(x[i] == 0)  cout << i+1 << endl;
    
	return 0;
}

Measured memory_bytes: 3540
n = gets.chomp.to_i
words = Hash.new(0)
prev = ""
n.times do |i|
  w = gets.chomp
  if i == 0
    prev = w
  else
    if words.has_key?(w)
      puts "No"
      exit
    elsif prev[-1] != w[0]
      puts "No"
      exit
    else
      prev = w
    end
  end
  words[w] += 1
end
puts "Yes"

Measured memory_bytes: 1788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> low(M);
    vector<ll> big(M);
    rep(i, M)cin >> low[i] >> big[i];
    sort(all(low));
    sort(all(big));
    ll a = low[M - 1];
    ll b = big[0];
    if (b < a)cout << "0" << endl;
    else cout << b - a + 1 << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin>>N;
  int64_t A[N];
  int64_t n=1;
  long double m=1.0;

  for(int i=0; i<N; i++){
    cin>>A[i];
    m*=A[i];
    n*=A[i];
  }
  if(m>1.0e+18){
    cout<<"-1"<<endl;
  }else{
    cout<<n<<endl;
  }

  return 0;
}


Measured memory_bytes: 4372
N=int(input())
p=[]
count=0
for i in range (N):
  a=int(input())
  p.append(a)
list.sort(p)
flag=1
for j in range (N-1):
  if p[j]==p[j+1]:
    flag*=-1
  else:
    if flag>0:
      count+=1
    flag=1
if flag>0:
  count+=1
print(count)

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

bool cup[3] = {1,0,0};
void swap(int a,int b){
	bool tmp;
	tmp = cup[a];
	cup[a] = cup[b];
	cup[b] = tmp;
}

int main()
{
	char a,dot,b;
	while(cin >> a && cin >> dot && cin >> b){
		swap(static_cast<int>(a-'A'),static_cast<int>(b-'A'));
	}
	for(int i=0;i<3;i++){
		if(cup[i] == 1)
			cout << static_cast<char>(i+'A') << endl;
	}	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x,n;
	cin>>x>>n;
	int s[100+2]={0};
	int f;
	for(int i=1;i<=n;i++) {
		cin>>f;
		s[f]=1;
	}
	for(int i=0;;i++) {
		if(s[x-i]==0) {
			cout<<x-i<<endl;
			return 0;
		}
		if(s[x+i]==0) {
			cout<<x+i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3580
import math
# from decimal import Decimal

a, b, h, m = map(int, input().split())

minutes = h * 60 + m
# print(minutes)
min_needle_angle = minutes * 6
hour_needle_angle = minutes * 0.5

# print(min_needle_angle)
if min_needle_angle > 360:
    min_needle_angle %= 360 # /じゃなく% n周して余ったところを渡せばいい

angle = max(min_needle_angle, hour_needle_angle) - min(min_needle_angle, hour_needle_angle)
# angle = abs(min_needle_angle - hour_needle_angle)
# print(angle)


# if angle > 180:
#     # angle -= 180 # angleから180を引かない
#     angle = 360 - angle # 360からangleを引く
angle = min(angle, 360 - angle) #こっちの方がわかりやすいかも


# print(angle)
# print(a**2, b ** 2, 2 * a * b)
# angle = float(angle)
# cosc = Decimal(math.cos(f'{angle:.10f}'))
# cosc = round(math.cos(angle), 9)

# これを1/2乗する
# c_nijou =  a ** 2 + b ** 2 - 2 * a * b * math.cos(angle)
# print(math.radians(angle))
# print(math.cos(math.radians(angle)))
c_nijou =  a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))

print((c_nijou)**0.5)

Measured memory_bytes: 9428
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
#define dd double
#define vi vector<int> 
#define li list<int> 
#define pb push_back
int a[200009];
 	// int b[200009];
 	// int c[200009];
 int main()
 {
 	int n, k;
 	cin >> k >> n;

 	for(int i = 0; i < k; i++) cin >> a[i];

 	sort(a, a+k);

 	int sum = 0;
 	for(int i = 0; i < n; i++) sum = sum + a[i];

 	cout << sum << endl;

 	return 0;
 }

Measured memory_bytes: 3636
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]

N = int(input())
P = list(map(float,input().split()))

dp = np.zeros(N+1, dtype=float)
dp[0] = 1

for c in P:
#    prev = dp.copy()
    dp = np.append(dp[:-1] * (1-c), 0) + np.append(0, dp[:-1] * c)
#    print(dp)

ans = np.sum(dp[N//2+1:])
print(ans)


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

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

long long lcm(long long a, long long b){
  return a / gcd(a, b) * b;
}

int main(){
  ll n;
  cin >> n;
  ll a[n];
  r(i,n)cin >> a[i];
  r(i,n-1){
    a[0]=lcm(a[0],a[i+1]);
  }
  cout << a[0]<<endl;
}


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

using namespace std;


int main() {

	int n,q;
	cin >> n >> q;

	int a, b,c;
	vector<vector<int>> aa(n,vector<int>());
	for (int i = 0; i <q; i++) {
		cin >> a >> b  ;
		if (a == 0) {
			cin >> c;
			aa[b].push_back(c);
		}
		if (a == 1) {
			if (!aa[b].empty()) {
				for (int j = 0; j < aa[b].size() - 1; j++) {
					cout << aa[b][j] << " ";
				}
				cout << aa[b][aa[b].size() - 1] << endl;
			}
			else {
				cout << endl;
			}
		}
		if (a == 2) {
			aa[b].erase(aa[b].begin(),aa[b].end());
		}
	}

}


Measured memory_bytes: 5808
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end(), greater<int>());

    int suma=0, sumb=0;
    for(int i=0; i<n; i++){
        if(i%2==0) suma+=a[i];
        else sumb+=a[i];
    }

    cout << suma-sumb << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void EducationalDP_B()
{
	int N, K;
	cin >> N >> K;
	vector<int> h(N + 1);
	for (int i = 0; i < N; ++i)
	{
		cin >> h[i + 1];
	}

	vector<int> dp(N + 1, 2000000000);
	dp[1] = 0;
	for (int i = 2; i <= N; ++i)
	{
		for (int k = 1; k <= K; ++k)
		{
			if (i - k <= 0)
				continue;
			dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]));
		}
	}
	cout << dp[N] << endl;
}

int main()
{
	EducationalDP_B();
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int a,b,c,x,y,n=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		y=c%x;
		if(y==0) n=n+1;
	}
	printf("%d\n",n);

return 0;
}

Measured memory_bytes: 596