akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int n,MOD,a,b,c,t;


template<class T>
class matrix{
public:
	vector<vector<T>> elm;
	int height,width;
	
	
	matrix():height(0),width(0){};
	matrix(int h,int w):height(h),width(w){
		elm.resize(h,vector<T>(w,0));	//0-padding
	}
	
	matrix<T> operator + (const matrix &m)const{
		matrix<T> ret = this;
		rep(i,height) rep(j,width) ret[i][j] += m.elm[i][j];
		return ret;
	}
	matrix<T> operator - (const matrix m)const{
		matrix<T> ret = this;
		rep(i,height) rep(j,width) ret[i][j] -= m.elm[i][j];
		return ret;
	}
	matrix<T> operator * (const matrix m)const{
		assert(width==m.height);
		matrix<T> ret(height,m.width);
		rep(i,height){
			rep(j,m.width){
				rep(k,width){
					(ret.elm[i][j] += elm[i][k]*m.elm[k][j])%=MOD;
				}
			}
		}
		return ret;
	}
	
	void output(){
		rep(i,height){
			rep(j,width){
				if(j)cout<<" ";
				cout<<elm[i][j];
			}
			cout<<endl;
		}
	}
	
	matrix<T> tern(){
		matrix<T> ret(width,height);
		rep(i,height) rep(j,width) ret.elm[j][i] = elm[i][j];
		return ret;
	}
};

vector<matrix<int>> T;


matrix<int> f(int t,matrix<int> v){
	matrix<int> ret = v;
	int c=0;
	while(t){
		if(t%2==1)ret = T[c]*ret;
		t/=2;
		c++;
	}
	return ret;
}


int main(){
	while(cin>>n>>MOD>>a>>b>>c>>t&&(n||MOD||a||b||c||t)){
		matrix<int> v(n,1);
		rep(i,n)cin>>v.elm[i][0];
		
		T.clear();
		T.resize(30,matrix<int>(n,n));
		rep(i,n)T[0].elm[i][i]=b;
		rep(i,n-1)T[0].elm[i][i+1]=c;
		rep(i,n-1)T[0].elm[i+1][i]=a;
		
		for(int i=1;i<30;i++){
			T[i] = T[i-1] * T[i-1];
//			rep(j,n)rep(k,n)T[i].elm[j][k]%=MOD;
		}
		
//		T[0].output();
//		v.output();
		
		matrix<int> res = f(t,v);

//		rep(i,res.height)rep(j,res.width)res.elm[i][j]%=MOD;
		
		res.tern().output();
	}
}

Measured memory_bytes: 3368
#include <stdio.h>
int n,s;
int sum,count,ans,data[11];

void rec(int);

void rec(int p){
  if(p>10){
    return;
  }
  if(count==n){
    if(s==sum) ans++;
    return;
  }
  data[p]=1;
  sum+=p;
  count++;
  rec(p+1);

  sum-=p;
  count--;

  data[p]=0;
  rec(p+1);
}
main(){

  while(1){
    scanf("%d %d", &n, &s);
    if(n==0 && s==0) break;

    ans=count=sum=0;

    rec(0);

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <memory.h>

using namespace std;

char map[105][105];

int h, w;
int ans;
bool used[105][105];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void dfs(int x, int y, char c)
{
    used[y][x] = true;
    for(int i = 0; i < 4; ++i)
    {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if(tx >= 0 and tx < w and ty >= 0 and ty < h and !used[ty][tx] and map[ty][tx] == c)
            dfs(tx, ty, c);
    }
}

int main()
{
    while(cin>>h>>w and h and w)
    {
        ans = 0;
        memset(used, 0, sizeof(used));
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
                cin>>map[i][j];

        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
            {
                if(!used[i][j])
                {
                    dfs(j, i, map[i][j]);
                    ans++;
                }
            }

        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3508
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

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

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int k, n;
    cin >> n >> k;

    vector<ll> h(n, 0);

    rep(i, n) {
        cin >> h[i];
    }

    sort(h.begin(), h.end(), greater<int>());

    rep(i, n) {
        if (k > 0) {
            h[i] = 0;
            k--;
        }
    }

    cout << std::accumulate(h.begin(), h.end(), 0LL);


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 1792
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if(abs(A-B) % 2 == 0) {
        print("Alice");
    } else {
        print("Borys");
    }
    return 0;
}

Measured memory_bytes: 384
program test
implicit none
integer(8) :: n,k,tmp,list1(100000)=0,list2(100000)=0,i,ii,j,answer=0,big=1000000007,kenzan=0
integer(8) :: aa,bb,now_power,ans
read(*,*) n,k



do i=1,k
  tmp = int(k/i)
  
  aa = tmp
  bb = n
  now_power = 0
  ans = 1
  
  do while(bb > 0)
    do while(mod(bb,2**(now_power+1)) > 0)
      bb = bb - 2**(now_power)
      ans = mod(ans * aa,big)
    enddo
    now_power = now_power + 1
    aa = mod(aa * aa,big)
  enddo
  
  list1(i) = ans
enddo

list2 = list1

do i=k,1,-1
 ii=2*i
 do while(ii<=k)
   list2(i) = list2(i) - list2(ii)
   ii = ii + i
 enddo
enddo

do i=1,k
 answer = mod(answer+i*list2(i),big)
enddo

write(*,*) answer

end program


Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x=min(x,y)
using namespace std;
string s[6][3];
bool r(int a,int b){
	rep(i,3) if(s[a][b][i]=='*') return 1;
	return 0;
}
bool c(int a,int b){
	rep(i,3) if(s[a][i][b]=='*') return 1;
	return 0;
}
int main(){
	while(true){
		int ans=10;
		cin>>s[0][0];
		if(s[0][0][0]=='#') break;
		rep(i,6) rep(j,3){
			if(i==0&&j==0) continue;
			cin>>s[i][j];
		}
		if(r(0,2)&&r(2,2)) chmin(ans,0);
		if(r(0,0)&&r(2,0)) chmin(ans,2);
		if(c(0,0)&&c(2,2)) chmin(ans,1);
		if(c(0,2)&&c(2,0)) chmin(ans,1);
		if(r(1,2)&&r(3,2)) chmin(ans,3);
		if(r(1,0)&&r(3,0)) chmin(ans,3);
		if(c(1,0)&&c(3,2)) chmin(ans,2);
		if(c(1,2)&&c(3,0)) chmin(ans,2);
		if(r(4,0)&&r(5,2)) chmin(ans,1);
		if(r(4,2)&&r(5,0)) chmin(ans,1);
		if(c(4,0)&&c(5,0)) chmin(ans,2);
		if(c(4,2)&&c(5,2)) chmin(ans,2);
		cout<<ans<<endl;
		}
}

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

int main(){
 string str, com, p;
 int q, a, b;
 cin >> str >> q;
 for(int t=0; t<q; t++){
  cin >> com >> a >> b;
  if( com == "print"){
   cout <<str.substr(a, b-a+1) << endl;
  }else if(com == "reverse"){
   string tmp= str.substr(a, b-a+1);
   int n=tmp.size();
   for( int i=0; i<n; i++) str[i+a]=tmp[n-i-1];
 }else if(com=="replace"){
  cin>>p;
  str=str.replace(a, b-a+1, p);
 }
}
return 0;
}


Measured memory_bytes: 3176
// C - Prison

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

int main() {
	int N, M;
	cin >> N >> M;

	int max_L = 1;
	int min_R = N;
	int L, R;
	for (int i=0; i<M; i++) {
		cin >> L >> R;
		max_L = max(max_L, L);
		min_R = min(min_R, R);
	}

	cout << max(min_R - max_L + 1, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    map<pair<char,char>,int> mp;
    REP(i,N+1) {
        string s = to_string(i);
        mp[{s.front(),s.back()}]++;
    }

    int ans = 0;
    FOR(i,'1','9'+1) FOR(j,'1','9'+1) ans += mp[{i,j}] * mp[{j,i}];
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    string s;
    cin >> s;
    rep(i,s.length()){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s << endl;
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3672
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<int> L;
vector<int> :: IT ite1[3000],ite2;
int main(){
	int n;
	cin>>n;
	rb(i,1,n) {
		int li;
		cin>>li;
		L.PB(li);
	}
	sort(ALL(L));
	ite1[0]=L.begin();
	rb(i,1,n-1){
		ite1[i]=ite1[i-1]+1;
	}
	LL res=0;
	rb(i,1,n){
		rb(j,i+1,n){
			int l,r;
			int a=L[i-1],b=L[j-1];
			r=a+b;
			ite2=lower_bound(ALL(L),r);
			ite2--;
			res+=ite2-ite1[j-1];
//			cout<<i<<" "<<
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b + c <= a) {
		cout << min(b, c) << " " << 0 << endl;
	}
	else {
		cout << min(b, c) << " " << abs(min(0, a - (b + c))) << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define FOR( i, l, r) for(int i = (l)    ; i <  (r); i++)
#define FOR1(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define REV( i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define REV1(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define INC( i, n) FOR( i, 0, n)
#define INC1(i, n) FOR1(i, 1, n)
#define DEC( i, n) REV( i, 0, n)
#define DEC1(i, n) REV1(i, 1, n)

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

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int MAX = 100000;

int n, t[MAX], a[MAX];
int max_t[MAX], min_t[MAX];
int max_a[MAX], min_a[MAX];

int main() {
	scanf("%d", &n);
	INC(i, n) { scanf("%d", &t[i]); }
	INC(i, n) { scanf("%d", &a[i]); }
	
	INC(i, n) {
		if(i == 0 || t[i - 1] < t[i]) {
			min_t[i] = max_t[i] = t[i];
		} else {
			min_t[i] = 1;
			max_t[i] = t[i];
		}
	}
	
	DEC(i, n) {
		if(i == n - 1 || a[i] > a[i + 1]) {
			min_a[i] = max_a[i] = a[i];
		} else {
			min_a[i] = 1;
			max_a[i] = a[i];
		}
		
		setmin(max_t[i], max_a[i]);
		setmax(min_t[i], min_a[i]);
	}
	
	LL ans = 1;	
	INC(i, n) {
		LL x = max_t[i] - min_t[i] + 1;
		(ans *= (x > 0 ? x : 0)) %= 1000000007;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int tong[N<<1],a[N],n,k;
ll check(int x){
	memset(tong,0,sizeof(tong));
	int dq=n,dd=1; ll ans=0;
	tong[n]=1; 
	for(int i=1;i<=n;i++){
		if(a[i]>=x){
			dq++; dd+=tong[dq];
		}else{
			dd-=tong[dq]; dq--;
		}
		ans+=dd; tong[dq]++; dd++;
	}
	return ans;
}
signed main(){
	n=read(); ll k=((ll)n*(n+1)/2+1)/2;
	for(int i=1;i<=n;i++)a[i]=read(); //cout<<check(30)<<endl; return 0;
	int l=0,r=1e9;
	while(l<r){
		int mid=(l+r)>>1; mid++;
		if(check(mid)>=k)l=mid; else r=mid-1;
	}
	cout<<l<<endl;
}

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

#define ll long long
#define pll pair<ll,ll> 


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin>>n;
	ll A[n];
	ll M[n]={};
	fill(M, M+n,INT_MAX);
	for(ll i=0;i<n;i++)
		cin>>A[i];
	M[0]=0;
	M[1]=abs(A[0]-A[1]);
	for(ll i=2;i<n;i++){
		M[i]=min(M[i], min(M[i-1]+abs(A[i-1]-A[i]), M[i-2]+abs(A[i-2]-A[i])));
	}
	cout<<M[n-1];

}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0,shu=0;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(i==0&&s[i]-48==1){
			++shu;
		}
		if(i!=0&&s[i]-48==0){
			++shu;
		}
		cnt+=(s[i]-48);
	}
	if(shu==s.size()){
		cout << 10;
	}else cout << cnt;
}

Measured memory_bytes: 256
# cook your dish here
n=int(input())
str_n=str(n)
list_n=list(str_n)
count=0
for i in range(0,len(list_n)):
    count+=int(list_n[i])
    
    
if(count%9 == 0 ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10764
#include<stdio.h>
int main(void){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x-r>=0){
		if(x+r<=w){
			if(y-r>=0){
				if(y+r<=h){
					printf("Yes\n");
				}
				else{
					printf("No\n");
				}
			}
			else{
				printf("No\n");
			}
		}
		
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

		

Measured memory_bytes: 584
//According to all known laws of aviation, there is no way that a bee should be able to fly.
 //Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
 //Because bees don't care what humans think is impossible.
 #include <bits/stdc++.h>
 #define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define mod 1000000007
 #define endl "\n"
 using namespace std ;
 using bigint = long long int ;
 using vi = vector<int> ;
 bigint arr[300011] ;
 int main(){
     int N ; cin >> N ;
     map<string , int> m ;
     m["AC"] = 0 , m["WA"] = 0 , m["TLE"] = 0 , m["RE"] = 0 ;
     for( int i = 0 ; i < N ; i++ ){
         string str ; cin >> str ;
         m[str]++ ;
     }
     cout << "AC" << " x " << m["AC"] << endl ;
     cout << "WA" << " x " << m["WA"] << endl ;
     cout << "TLE" << " x " << m["TLE"] << endl ;
     cout << "RE" << " x " << m["RE"] << endl ;
     return 0 ;
 }


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000+1
#define rep(a,b) for(ll i=a;i<b;i++)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()
{   io

    ll n=0,k=0;
    cin>>n>>k;
    ll h[n];
    ll dp[n];
    rep(0,n)
        cin>>h[i];

        rep(0,n)
        dp[i]=inf;
 dp[0]=0;
   /*
    dp[1]=abs(h[1]-h[0]);
    for(ll i=1;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }

   */
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<=min(i,k);j++)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }

    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

std::size_t F(const std::vector<std::size_t>& v, const std::vector<bool>& b)
{
    auto x = std::size_t(0);
    auto t = std::size_t(0);

    t = v[0];
    for (auto i = std::size_t(0); i < b.size(); ++i)
    {
        if (b[i])
        {
            x += t;
            t = v[i + 1];
        }
        else
        {
            t *= 10;
            t += v[i + 1];
        }
    }
    x += t;

    return x;
}

int main()
{
    auto s_in = std::string("");
    std::cin >> s_in;

    auto v = std::vector<std::size_t>();
    for (const auto& s : s_in) v.emplace_back(s - '0');

    auto result = std::size_t(0);

    for (auto i = std::size_t(0); i < static_cast<std::size_t>(std::pow(2, v.size() - 1)); ++i)
    {
        auto separator_flag = std::vector<bool>();
        for (auto n = std::size_t(v.size() - 1); n > 0; --n)
        {
            separator_flag.emplace_back(
                static_cast<bool>((i & static_cast<std::size_t>(std::pow(2, n - 1))) >> (n - 1)));
        }
        result += F(v, separator_flag);
    }

    std::cout << result << std::endl;

    return 0;
}

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

using namespace std;
int  n,sum,w[1000],val[1009];
long long k,dp[1000][100090];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            if(dp[i-1][j]!=-1)
            {
            if(dp[i][j]!=-1)
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j]);
            }
            else dp[i][j]=dp[i-1][j];
            dp[i][j+val[i]]=dp[i-1][j]+w[i];
            }
        }
    }
    long long ans=0;
    for(int i=sum;i>=0;i--)
    {
        if(dp[n][i]<=k&&dp[n][i]!=-1)
        {
            ans=i;
            break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 782208
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=0,n,j=1;
    cin>>a>>b;
    if(a<0 && b>0)cout<<"Zero"<<endl;
    if(a>0)cout<<"Positive"<<endl;
    else if(a<0 && b<0){
        if((b-a)%2==0)cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }

    return 0;
}


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

using namespace std;

int main(){
	long long a,b,c,d,x[4],maxv=0-2e18;
	cin>>a>>b>>c>>d;
	x[0]=a*c;
	x[1]=a*d;
	x[2]=b*c;
	x[3]=b*d;
	for(int i=0;i<=3;i++){
		if(x[i]>=maxv){
			maxv=x[i];
		}
	}
	cout<<maxv;
	return 0;
}


Measured memory_bytes: 3628
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
#from collections import Counter, defaultdict, deque
#from math import sqrt, log, floor, ceil, factorial, cos, sin, pi, gcd
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return str(input())
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def main():
    S = IS()

    ans = "Yes"
    if S[0] == S[1] and S[1] == S[2]:
        ans = "No"
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double pi = 2.0 * asin(1.0); 
  long double k=abs(360.0*h/12.0+30.0*m/60.0-360.0*m/60.0)/180.0*pi;
  long double c=sqrt(a*a+b*b-2.0*a*b*cos(k));
  cout << fixed << setprecision(15);
  cout<<c<<endl;
}


Measured memory_bytes: 4156
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <utility>
#include <iterator>
#include <sstream>
#include <fstream>
#include <functional>
#include <ctime>
#include <cassert>
#include <limits>

using namespace std;

#define SyncFalse ios::sync_with_stdio(0); cin.tie(0)
#define MEM(a, v) memset(a, v, sizeof(a))
#define CLRV(a, sz, v) a.clear(); a.resize(sz, v)
#define CLR(a, sz) a.clear(); a.resize(sz)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.end(), a.begin()
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define SZ(a) (int)a.size()
#define LNG(a) (int)a.length()
#define LPI 3.141592653589793238462643383279502884L
#define SI(n) scanf("%d", &n)
#define SL(n) scanf("%lld", &n)
#define SD(n) scanf("%lf", &n)
#define SLD(n) scanf("%llf", &n)
#define SC(n) scanf(" %c", &n)
#define SS(n) scanf("%s", n)
#define FR(i, n) for (int i = 0; i < n; i++)
#define RFR(i, n) for (int i = n - 1; i >= 0; i--)
#define FR1(i, n) for (int i = 1; i <= n; i++)
#define RFR1(i, n) for (int i = n; i >= 1; i--)
#define FOREACH(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<ld> VLD;
typedef vector<double> VD;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

const double PI = acos(-1.0);
const double EPS = numeric_limits<double>::epsilon();
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int MOD = (int) 1e9 + 7;

//------------------------------------------------------------------------

int main() {
	int n; SI(n);
	ll t; SL(t);
	ll ans = 0;
	ll c = 0;
	ll y = 0;
	while (n--) {
		ll x; SL(x);
		ans += min(x - y, t);
		y = x;
	}
	ans += t;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
//#include <fstream>

#include <iostream>
#include <algorithm>

using namespace std;

const int NMAX = 405;
int n, cost[NMAX];
long long s[NMAX];
long long dp[NMAX][NMAX];

int main()
{
	//ifstream cin("test.in");
	//ofstream cout("test.out");
	cin >> n;
	for (int i = 1;i <= n;++i)
	{
		cin >> cost[i];
		s[i] = s[i - 1] + cost[i];
	}
	for (int i = 1;i < n;++i)
		dp[i][i + 1] = cost[i] + cost[i + 1];
	for (int d = 2;d <= n - 1;++d)
		for (int i = 1;i <= n - d;++i)
		{
			int j = i + d;
			dp[i][j] = min(cost[i] + dp[i + 1][j] + s[j] - s[i], dp[i][j - 1] + cost[j] + s[j - 1] - s[i - 1]);
			for (int k = i + 1;k <= j - 2;++k)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + s[j] - s[i - 1]);
		}
	cout << dp[1][n] << "\n";
	return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void chkmax(int &x, int y){x<y?(x=y):0;}
const int N=100000+5;
struct node{int t, d;}a[N];
bool cmp(node a, node b){return a.d>b.d;}
stack<int> q; set<int> s;

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

signed main()
{
	int n=read(), k=read(), now=0, ans=0;
	for (int i=1; i<=n; i++) a[i].t=read(), a[i].d=read();
	sort(a+1, a+n+1, cmp);
	for (int i=1; i<=k; i++) 
	{
	    if (s.count(a[i].t)) q.push(a[i].d);
		s.insert(a[i].t); now+=a[i].d;
	}
	ans=now+(int)(s.size()*s.size()); 
	for (int i=k+1; i<=n; i++) 
	{
		if (q.empty()) break;
		if (s.count(a[i].t)) continue;
		s.insert(a[i].t); now=now-q.top()+a[i].d; q.pop();
		chkmax(ans, now+(int)(s.size()*s.size())); 
		
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4992
n, k, s = map(int, input().split())
if s == 10**9:
    a = 10**9-1
else:
    a = 10**9
l = [a for _ in range(n)]

if k == n:
    print(' '.join(map(str, [s for _ in range(n)])))
elif k == 0:
    print(' '.join(map(str, l)))
else:
    if s == 1:
        l[0:k] = [s for _ in range(k)]
    elif s % 2 == 0:
        l[0:k+1] = [s//2 for _ in range(k+1)]
    else:
        u, t = (s-1)//2, (s+1)//2
        for i in range(k+1):
            if i % 2 == 0:
                l[i] = u
            else:
                l[i] = t

    print(' '.join(map(str, l)))


Measured memory_bytes: 67232
# coding: utf-8

n = int(input().rstrip())

score_list = [int(i) for i in input().rstrip().split()]

under3200 = set([int(i/400) for i in score_list if i < 3200])
over3200 = [i for i in score_list if i >= 3200]

minColor = max(1, len(under3200))
maxColor = len(under3200) + len(over3200)

print("{} {}".format(minColor, maxColor))


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

using namespace std;

int main(void){
  
  int X,A,B;
  cin>>X>>A>>B;
  if(A+X<B)     cout<<"dangerous"<<endl;
  else if(A<B)  cout<<"safe"<<endl;
  else          cout<<"delicious"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string w;
  cin >> w;
  sort(w.begin(),w.end()); 
  for(int i=0;i<w.size();){
    if(count(w.begin(),w.end(),w[i])%2==0){
      i+=count(w.begin(),w.end(),w[i]);
      if(i==w.size())
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
      break;
    }
  }
}

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;
int main(){
    int k,t;
    cin>>k>>t;
    vector<int>a(t);
    int sum=0,mx=0;
    rep(i,t){
        cin>>a[i];
        sum+=a[i];
        mx=max(mx,a[i]);
    }
    sum-=mx;
    if(sum-1>=mx)cout<<0<<endl;
    else cout<<mx-sum-1<<endl;
}

Measured memory_bytes: 256
n = int(input())

p = list(map(int, input().split()))
ans = 0
for i in range(1, len(p)-1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int flag[200010];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(flag,0,sizeof(flag));
        int ans=0;
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)
        {
            if(a[i]==i)
            {
                if(flag[i])
                {
                    continue;
                }
                else
                {
                    if(a[i+1]==i+1)
                    {
                        if(flag[i+1]==0)
                        {
                            ans++;
                            flag[i+1]=1;
                            continue;
                        }
                        else continue;
                    }
                    else
                    {
                        ans++;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}


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

void ti(){
  #ifndef ONLINE_JUDGE
    freopen("in.txt", "r+", stdin);
    freopen("out.txt", "w", stdout);
  #endif
}

typedef long long ll;
int hg = 1000000000;

int main(){

  // ti();
  int n; cin>>n;

  vector<int> v(n+1, 0);
  for(int i = 1; i <= n; i++){
    cin>>v[i];
  }

  vector<int> mi(n+1);
  mi[2] = abs(v[2] - v[1]);
  for(int i = 3; i <= n; i++){
    mi[i] = min(mi[i - 1] + abs(v[i] - v[i-1]), mi[i - 2] + abs(v[i] - v[i-2]));
  }

  cout << mi[n] << endl;

  return 0;
}


Measured memory_bytes: 4028
import java.io.PrintWriter;
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) {
        while(true) {
            int a = Integer.parseInt(sc.next());
            String op = sc.next();
            int b = Integer.parseInt(sc.next());
            if(op.equals("+")) {
                out.println(a+b);
            } else if(op.equals("-")) {
                out.println(a-b);
            } else if(op.equals("*")) {
                out.println(a*b);
            } else if(op.equals("/")) {
                out.println(a/b);
            } else {
                break;
            }
        }
        out.flush();
    }
}

Measured memory_bytes: 26156
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef complex<double> P;
struct C{
    P p;
    double r;
};
bool operator < (const C& c, const C& d) {
    return c.p.real() < d.p.real();
}

int main(){
    int n;
    while(cin >> n && n > 0) {
        vector<C> cs(n);
        double max_r = 0;
        double th = M_PI / 6;
        REP(i, n) {
            double r, x, y;
            cin >> r >> x >> y;

            P p(x, y);
            p *= polar(1.0, th);

            cs[i] = {p, r};

            max_r = max(max_r, r);
        }

        sort(cs.begin(), cs.end());
        double ans = 1e63;

        REP(i, n) {
            for(int j = i + 1; j < n; j++) {
                assert(cs[j].p.real() >= cs[i].p.real());
                if(ans < cs[j].p.real() - cs[i].p.real() - cs[i].r - max_r) {
                    break;
                }
                ans = min(ans, abs(cs[i].p - cs[j].p) - cs[i].r - cs[j].r);
            }
        }
        printf("%.12f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 (b<a) { a=b; return 1; } return 0; }

int N,sum=0;

int main(){
    cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    rep(i,N)repi(j,i+1,N)sum+=A[i]*A[j];
    out(sum);
    
}


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


int main (){
    int A ,B;
    cin >> A >>B ;
    int n ,kuti = 0;
  int h = 1;
    rep(i,21){
      if (B == 1){
        cout << 0 << endl;
        break;
      }
        kuti = h*A - n;
      //cout << kuti << endl;
        if(kuti>= B ){
            cout << h << endl;
            break;
        }
      kuti = 0;
      h++;
      n++;
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = [int(x) for x in input().split()]

ans = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans[b-1] = 0
    if h[b-1] >= h[a-1]:
        ans[a-1] = 0

count = ans.count(1)
print(count)


Measured memory_bytes: 85264
#include <bits/stdc++.h>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define OO pow(10, 9)
using namespace std;

int main()
{
    int nb_days;
    cin >> nb_days;
    
    int maxi[3];maxi[0]=0;maxi[1]=0;maxi[2]=0;
    for (int iday = 0; iday < nb_days; ++ iday)
    {
        int a, b, c;
        cin >> a >> b >> c;
        int newmaxi[3];
        newmaxi[0] = max(maxi[1], maxi[2]) + a;
        newmaxi[2] = max(maxi[0], maxi[1]) + c;
        newmaxi[1] = max(maxi[0], maxi[2]) + b;
        
        maxi[0] = newmaxi[0];
        maxi[1] = newmaxi[1];
        maxi[2] = newmaxi[2];
    }
    cout << max(maxi[0], max(maxi[1], maxi[2])) << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int a[105];
using namespace std;
int main()
{
	int n,k,d,temp,ans=0;
	cin>>n>>k;
	for (int i=0;i<k;i++)
	{
		cin>>d;
		for (int i=0;i<d;i++)
		{
			cin>>temp;
			a[temp]++;
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (!a[i])   ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
H = list(map(int, input().split()))
border = H[N-1]

ans = True
for i in range(N-2, -1, -1):
    if H[i] <= border:
        border = H[i]
    else:
        if H[i] - 1 <= border:
            border = H[i] - 1
        else:
            ans = False

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20844
#include<iostream>
using namespace std;
int power(int a){
  int A;
  if(a>=2 && a<=13)A=a-1;
  else A=13;
  return A;
}
int main(void){
  int a,b;
  cin>>a>>b;
  int A=power(a);
  int B=power(b);
  if(A>B)cout<<"Alice"<<endl;
  else if(B>A)cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
  return 0;
}

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

using namespace std;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (auto &s : S) {
    cin >> s;
  }
  auto is_unreached_road = [&](vector<vector<int>> D, int i, int j) -> bool {
    if (i < 0 or i >= H) {
      return false;
    }
    if (j < 0 or j >= W) {
      return false;
    }
    return S[i][j] == '.' and D[i][j] == -1;
  };
  auto find_max_d = [&](int si, int sj) -> int {
    vector<vector<int>> D(H, vector<int>(W, -1));
    D[si][sj] = 0;
    queue<pair<int, int>> que;
    que.push({si, sj});
    while (!que.empty()) {
      auto k = que.front();
      que.pop();
      int i = k.first;
      int j = k.second;
      if (is_unreached_road(D, i - 1, j)) {
        D[i - 1][j] = D[i][j] + 1;
        que.push({i - 1, j});
      }
      if (is_unreached_road(D, i, j - 1)) {
        D[i][j - 1] = D[i][j] + 1;
        que.push({i, j - 1});
      }
      if (is_unreached_road(D, i + 1, j)) {
        D[i + 1][j] = D[i][j] + 1;
        que.push({i + 1, j});
      }
      if (is_unreached_road(D, i, j + 1)) {
        D[i][j + 1] = D[i][j] + 1;
        que.push({i, j + 1});
      }
    }
    int d = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        chmax(d, D[i][j]);
      }
    }
    return d;
  };
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') {
        continue;
      }
      chmax(ans, find_max_d(i, j));
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int H , N ; 
  cin >> H >> N ; 
  int A[N] ; 
  int B= 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> A[i] ;  
    B = B + A[i] ; 
  }
  
  if(B >= H){
    cout << "Yes" << endl ; 
    
  }
  else{
    cout << "No" << endl ;
  }
  
  
}

Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

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

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

    sort(L, L+N);

    if(accumulate(L, L+N-1, 0) > L[N-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(){
    long A, B, C;
    cin >> A >> B >> C;
    if(A%2==0 || B%2==0 || C%2==0){
      cout << "0" << endl;
      return 0;
    }
    if(A>B && A>C){
      cout << B*C << endl;
      return 0;
    }
    if(B>A && B>C){
      cout << A*C << endl;
      return 0;
    }
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while (true) {
    	int n = scanner.nextInt();
    	int x = scanner.nextInt();
    	if (n == 0 && x == 0) {
    		break;
    	} else {
    		int y = 0;
    		int count = 0;
    		//System.out.println (n);
    		for (int i = n; i >= 3; i--) {
    			//System.out.println (i);
    			for (int j = i - 1; j >= 2; j--) {
    				for (int k = j - 1; k >= 1; k--) {
    					y = i + j + k;
    					if (y == x) {
    						count = count + 1;
    					}
    				}
    			}
    		}
    		System.out.println (count);
    	}
    }
  }
}



Measured memory_bytes: 26572
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	char s[5];
	int bdama = 0;
	cin >> s;
	if (s[0] == '1') bdama++;
	if (s[1] == '1') bdama++;
	if (s[2] == '1') bdama++;
	cout << bdama;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long int n;
	scanf ("%lld", &n);
	long long int sum = 0;
	
	for (long long int i = 0; i <= n; i++){
		if (i % 3 == 0 || i % 5 == 0){
			continue;
		}
		else {
			sum = sum + i;
		}
	}
	printf ("%lld", sum);
	return 0;
}

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

int main(){
    long long a,b,x,n,cnt=1,ct;
    scanf("%lld%lld",&a,&b);
    x=__gcd(a,b);
    n=sqrt(x);
    for(long long i=2;i<=n;i++){
        ct=0;
        while(x%i==0){
            x/=i;
            ct=1;
        }
        cnt+=ct;
    }
    printf("%lld",cnt+(x==1?0:1));

}


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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  
  string ans = "Yes";
  
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (W.at(i) == W.at(j)) {
        ans = "No";
        break;
      }
    }
  }
  
  for (int i = 0; i < N - 1; i++) {
    if (W.at(i).at(W.at(i).size() - 1) != W.at(i + 1).at(0)) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    def I(): return int(input())
    
    readline = sys.stdin.readline
    readall = sys.stdin.read
    MI = lambda: map(int, readline().split())
    LI = lambda: list(map(int, readline().split()))
    
    class BIT:
        '''
        0-indexed
        '''
        def __init__(self, N):
            self.size = N
            self.tree = [0] * (N + 1)
            self.depth = N.bit_length()

        def _bitsum(self, i):
            ret = 0
            while i:
                ret += self.tree[i]
                i ^= i & -i
            return ret

        # [l,r)の和
        def bitsum(self, l, r=None):
            if r is None:
                return self._bitsum(l)
            else:
                return self._bitsum(r) - self._bitsum(l)

        # i番目にxを追加
        def add(self, i, x):
            i += 1
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return

        def lower_bound(self, x):
            sum_ = 0
            pos = 0
            v = 1 << self.depth
            for i in range(self.depth, -1, -1):
                k = pos + v
                if k <= self.size and sum_ + self.tree[k] < x:
                    sum_ += self.tree[k]
                    pos += v
                v >>= 1
            return pos + 1, sum_

    
    N,Q=MI()
    C=LI()
    
    Query =[]
    
    M=10**6
    M2=10**12
    for i in range(Q):
        l, r = MI()
        l-=1
        r-=1
        Query.append(r*M2 + l*M + i)
    Query.sort()
    
    """
    事前処理 + クエリの高速処理
    or 
    クエリ先読み
    
    とりあえずrの昇順にクエリをソートしておく．
    結局，各色ごとに1つ前のやつがどこにあるかが問題=>各色ごとに最新の物だけを保持すれば良い．
    最終的にクエリに答えたいので，i番目が使えるかどうかBITで管理
    """
    bit=BIT(N+3)
    dd=[N+3]*(N+1)#多くとっておく
    
    ans=[0]*Q
    pre=-1
    for q in Query:
        r = q // 10 ** 12
        l = (q % 10 ** 12) // 10 ** 6
        i = q % 10 ** 6
        for j in range(pre+1,r+1):
            c=C[j]
            old=dd[c]#その色の古いやつ
            bit.add(old,-1)#もしまだ出てきていないなら，範囲外の使わないところを-1する
            #最新を追加
            dd[c]=j
            bit.add(j,1)
        pre=r
        ans[i]=bit.bitsum(l,r+1)
        
    for a in ans:
        print(a)
main()


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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    ll d,t,s;
    cin>>d>>t>>s;
    
    cout<< ( s*t>=d ? "Yes" : "No") <<endl;
    
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        long result = Stream.of(a, b, c).distinct().count();
        System.out.println(result);
    }
}


Measured memory_bytes: 26580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuffer;

/*Question
/????????? strstr ?????????????????????????????????????????????????????????????????°???????????????????????????????????????????????\?????????????????????????????§???:
/print a b: strstr ??? a ??????????????? b ??????????????§??????????????????
/reverse a b: strstr ??? a ??????????????? b ??????????????§?????????????????????
/replace a b p: strstr ??? a ??????????????? b ??????????????§??? p ?????????????????????
/????????§??????????????? strstr ????????????????????? 0 ???????????¨????????????
*/
/*Input
/1 ?????????????????? strstr ????????????????????????strstr ?????±?°????????????????????????????
/2 ????????????????????° qq ????????????????????????
/?¶???? qq ??????????????????????¨??????¢?????§?????????????????????
*/

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		//????????¨
		StringBuffer sb = new StringBuffer();
		//??????????????????(strstr)
		String s = sc.readLine();
		//????????????????????????(qq)
		int n = Integer.parseInt(sc.readLine());
		//????????????????????????a,b??¨
		int a,b;
		//???????????°?????????
		for(int i = 0;i < n;i++){
			/*???????????\???
			/?????????????????£???" "(??????)??§???????????????s?????????
			/s[0]????????????s[1]?????????????????????????§???????(a)???s[2]???????????????(b)???replace????????°s[3]??????????????????????????????
			/a,b?????±?????§??????????????????????????????int?????????????????????????????£??\????????????
			/b???substring????????§????????´???+1???????????¨???????????????1???????????????????????¨??????????????????????????¨??????????????????
			/replace????????°????????????????????????????????§?????????????????§replace?????¨????????§???????????????????°???????????????§????????????
			*/
			String[] st = sc.readLine().split(" ");
			a = Integer.parseInt(st[1]);
			b = Integer.parseInt(st[2]);
			b++;
			//?????¢??¨
			StringBuffer rev = new StringBuffer();
			StringBuffer shobon = new StringBuffer();
			//????????????????¨?(?????´?????????)
			if(st[0].equals("print")){
				//print??????????????????????????????s??¨?????????????????¨sb?????????
				sb.append(s.substring(a,b)+"\n");
			}else if(st[0].equals("reverse")){
				/*?????¢
				/?????¨????????????s??????????????¢??????????????????StringBuffer rev???????´????????????¢
				/??????????????????????????????rev???????????????s???????´?
				/?????¢????????????????????????????????????a?????§??????????????\???StringBuffer shobon???????????????????????????????§??????????shobon????????????????????????s?????\??????
				*/
				if(a!=0)
					shobon.append(s.substring(0,a));
				rev.append(s.substring(a,b));
				s = shobon.append(rev.reverse()).append(s.substring(b)).toString();
			}else if(st[0].equals("replace")){
				//??????
				rev.append(s);
				s = rev.replace(a,b,st[3]).toString();
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 24552
#include<stdio.h>

int main(){
	int i,j,a[16],tmp;
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				tmp=a[i]; a[i]=a[j]; a[j]=tmp;
			}
		}
	}
	for(i=0;i<3;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 600
N, M, X, Y = map(int, input().split())
list_x = [int(i) for i in input().split()]
list_y = [int(j) for j in input().split()]
if max(list_x) >= min(list_y):
    print('War')
else:
    if X < max(list_x) + 1 <= Y:
        print('No War')
    else:
        print('War')


Measured memory_bytes: 2940