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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int N; cin >> N;
  double p[4] = {-1*INF, INF, -1*INF, INF}; // U, D, R, L
  double ma[4] = {}, mi[4] = {}; // U, D, L, R
  fill_n(ma,4,-1*INF); fill_n(mi,4,INF);
  rep(i,N) {
    double x, y; cin >> x >> y;
    char d; cin >> d;
    if (d=='U') {
      p[2] = max(p[2],x); p[3] = min(p[3],x);
      ma[0] = max(ma[0],y); mi[0] = min(mi[0],y);
    }
    if (d=='D') {
      p[2] = max(p[2],x); p[3] = min(p[3],x);
      ma[1] = max(ma[1],y); mi[1] = min(mi[1],y);
    }
    if (d=='R') {
      ma[2] = max(ma[2],x); mi[2] = min(mi[2],x);
      p[0] = max(p[0],y); p[1] = min(p[1],y);
    }
    if (d=='L') {
      ma[3] = max(ma[3],x); mi[3] = min(mi[3],x);
      p[0] = max(p[0],y); p[1] = min(p[1],y);
    }
  }
  // debug(p,p+4); debug(ma,ma+4); debug(mi,mi+4);

  double pos[5][2] = {};
  pos[0][0] = (p[1]-mi[0]<=mi[1]-p[1]) ? p[1]-mi[0] : (mi[1]-mi[0])/2;
  pos[0][1] = (p[1]-mi[0]<=mi[1]-p[1]) ? mi[1]-p[1] : (mi[1]-mi[0])/2;
  pos[1][0] = (ma[1]-p[0]<=p[0]-ma[0]) ? ma[1]-p[0] : (ma[1]-ma[0])/2;
  pos[1][1] = (ma[1]-p[0]<=p[0]-ma[0]) ? p[0]-ma[0] : (ma[1]-ma[0])/2;

  pos[2][0] = (p[3]-mi[2]<=mi[3]-p[3]) ? p[3]-mi[2] : (mi[3]-mi[2])/2;
  pos[2][1] = (p[3]-mi[2]<=mi[3]-p[3]) ? mi[3]-p[3] : (mi[3]-mi[2])/2;
  pos[3][0] = (ma[3]-p[2]<=p[2]-ma[2]) ? ma[3]-p[2] : (ma[3]-ma[2])/2;
  pos[3][1] = (ma[3]-p[2]<=p[2]-ma[2]) ? p[2]-ma[2] : (ma[3]-ma[2])/2;

  // rep(i,4) debug(pos[i],pos[i]+2);

  double result = LLINF;
  rep(i,5) rep(j,2) {
    if (pos[i][j]<0) continue;
    double t = pos[i][j];
    double u = max(p[0],max(ma[0]+t,ma[1]-t));
    double d = min(p[1],min(mi[0]+t,mi[1]-t));
    double r = max(p[2],max(ma[2]+t,ma[3]-t));
    double l = min(p[3],min(mi[2]+t,mi[3]-t));
    result = min(result, (u-d)*(r-l));
    // cout << t << " " << u << " " << d << " " << r << " " << l << "->" << (u-d)*(r-l) << endl;
  }
  cout << fixed << result << endl;

  return 0;
}

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

int main(){
  int N, M, R; cin >> N >> M >> R;
  int town[8];
  for(int i=0; i<R; i++){
    cin >> town[i];
    town[i]--;
  }
  int path[200][200];
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i==j) path[i][j]=0;
      else path[i][j]=1000000000;
    }
  }
  for(int i=0; i<M; i++){
    int A, B, C; cin >> A >> B >> C;
    path[A-1][B-1]=C;
    path[B-1][A-1]=C;
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      for(int k=0; k<N; k++){
        path[j][k]=min(path[j][k],path[j][i]+path[i][k]);
      }
    }
  }
  vector<int> perm(R);
  for(int i=0; i<R; i++) perm[i]=i;
  int result=1000000000;
  do{
    int temp=0;
    for(int i=0; i<R-1; i++){
      temp+=path[town[perm[i]]][town[perm[i+1]]];
    }
    result=min(result,temp);
  }while(next_permutation(perm.begin(),perm.end()));
  cout << result << endl;
}

Measured memory_bytes: 384
gets
ary = [[], [], [], []]

(0..3).each do |i|
  3.times{|a| ary[i] << [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
end
ARGF.each_line do |line|
  b, f, r, v = line.chomp.split.map(&:to_i)
  ary[b-1][f-1][r-1] += v
end
4.times do |n|
  puts "#"*20 unless n == 0
  3.times{|i| puts "\s" + ary[n][i].join("\s")}
end

Measured memory_bytes: 6116
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
const int N=20,INF=1e9;
int a1[N],a2[N],n;
bool b[N];
struct node {
	int val,id;
	node(int v=0,int i=0):val(v),id(i){}
	bool operator<(const node &t) const{
		if(this->val==t.val)
			return this->id<t.id;
		return this->val<t.val;
	}
}c[N];
int solve() {
	for(int i=1;i<=n;i++)
		if(b[i])
			c[i]=node(a2[i],i);
		else
			c[i]=node(a1[i],i);
	sort(c+1,c+1+n);
	/*
	for(int i=1;i<=n;i++)
		printf("%d ",c[i].val);
	puts("");*/
	for(int i=1;i<=n;) {
		/*找下有多少个连续相等的*/
		int len=1;
		while(i+len<=n && c[i+len].val==c[i].val)
			len++;
		queue<node>q1,q2;
		for(int j=i;j<i+len;j++) {
			/*这个IF代表J的位置不对，需要修改*/
			int k=0;
			if(abs(j-c[j].id+b[c[j].id])%2) 
				k=1;
			k+=j;
			if(k&1)
				q1.push(c[j]);
			else
				q2.push(c[j]);
		}
	
		for(int j=i;j<i+len;j++)
			if(j&1) {
				if(!q1.empty())
					c[j]=q1.front(),q1.pop();
		
			} else {
				if(!q2.empty())
					c[j]=q2.front(),q2.pop();
			}
		if(q1.size() || q2.size())
			return -1;
		i+=len;
	}
	
	/*求逆序对*/
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) 
			if(c[i].id>c[j].id)
				ans++;
	return ans;
}
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("ou1.txt","w",stdout);
//	for(int up=1;up<=3000;up++) {
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a1[i];
		for(int i=1;i<=n;i++)
			cin>>a2[i];
		int s=(1<<n)-1;
		int ans=INF;
		for(int i=0;i<=s;i++) {	//1代表翻面 
			int fl=0;
			for(int j=0;j<n;j++)
				if(i&(1<<j))
					b[j+1]=1,fl++;
				else 
					b[j+1]=0;
			if(fl&1)continue;
			int al=solve();
	//		printf("al=%d\n",al);
			if(al!=-1)
				ans=min(ans,al);
		}
		if(ans!=INF)
			printf("%d\n",ans);
		else
			printf("%d\n",-1);
//	}
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long a, std::string s){
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
}

signed main(){
    long long a;
    scanf("%lld",&a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
from sys import stdin, exit

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

k, x = mi()
for i in range(max(-1000000, x-k+1), min(x+k, 1000000)):
    print(i, end=" ")


Measured memory_bytes: 3060
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7


x=I()
if x:
    print(0)
else:
    print(1)



Measured memory_bytes: 76648
#include <bits/stdc++.h>
using namespace std;
string s,t;
void solve()
{
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int i,len=t.size();
    for (i=0;i<len/2;i++) {char ch=t[i];t[i]=t[len-1-i];t[len-1-i]=ch;}
    if (s<t) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}
int main()
{
    while(cin>>s>>t)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    Rep(i,n) cin >> a[i];
    map<ll,ll> m;
    Rep(i,n){
        m[a[i]]++;
    }
    ll ans = 0ll;
    map<ll,ll> c;
    vector<ll> b(n,0ll);
    Rep(i,n){
        if(b[a[i]]>0) continue;
        c[a[i]] = m[a[i]]*(m[a[i]]-1);
        b[a[i]] = 1ll;
        ans += c[a[i]];
    }
    Rep(i,n){
        ll ansl = ans - c[a[i]];
        ansl += (m[a[i]]-1)*(m[a[i]]-2);
        cout << ansl/2 << endl;
    }
}

Measured memory_bytes: 20608
# coding: utf-8

def main():
    _, _, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ans = 200001

    for _ in range(M):
        x, y, c = map(int, input().split())
        tmp = a[x - 1] + b[y - 1] - c
        if ans > tmp:
            ans = tmp

    amin = min(a)
    bmin = min(b)

    if ans > amin + bmin:
        ans = amin + bmin

    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
	int n;
	cin >> n;
	int time=1;
	for(int i=0;i<8;i++){
		time = time * 2;
		if(time > n){
			cout << time/2 << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int H,W,A,B;
	cin >> H >> W >> A >> B;
	V<string> s(H,string(W,'.'));
	rep(i,H) rep(j,W){
		s[i][j] = (i<B ^ j<A) ? '1' : '0';
	}
	rep(i,H) cout << s[i] << endl;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
ll n,m;
ll a,b;
ll cou[SIZE];

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        if(a == 1 || b == 1){
            if(a == 1)  cou[b]++;
            else
            {
                cou[a]++;
            }
            
        }
        else{
            cou[a]++;
            cou[b]++;
        }
    }

    for(int i = 2; i <= n; i++){
        if(cou[i]%2 != 0){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    
}

Measured memory_bytes: 1024
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s = new Scanner(System.in);
        int a, b, c ;
        a = s.nextInt();
        b = s.nextInt();
        c = s.nextInt();
        System.out.println(minValue(a,b,c)
        		);
        }
	
	        	public static int minValue(int a, int b, int c) {
	        		int min = a + b;
	        		if (min > b + c) min = b + c;
	        		if (min > c + a) min = c + a;
	        		return min;
	        		
	        	}
	        	
}

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

ll ex(ll x,ll n){
  if(n==0)return 1;
  else if(n%2==1)return ex(x,n-1)*x%num;
  else return ex(x*x%num,n/2)%num;
};

int main(){
    ll n;
    cin >> n;
    ll a[n],bit1[60],bit0[60];
    for(ll i=0; i<60; i++){
        bit1[i]=0;
        bit0[i]=0;
    }
    for(ll i=0; i<n; i++){
        cin >> a[i];
    }
    for(ll i=0; i<n; i++){
        for(ll j=0; j<60; j++){
            if(a[i]&(1ll<<j)){
                bit1[j]++;
            }
            else bit0[j]++;
        }
    }
    ll ans=0;
    for(ll i=0; i<60; i++){
        ll tmp=bit0[i]*bit1[i]%num;
        ll pre=ex(2,i);
        ans+=tmp*pre%num;
        ans%=num;
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
int T[MAX_N];
int A[MAX_N];

ll hi[MAX_N];
ll lo[MAX_N];

void update(int i, ll from, ll to) {
  chmin(hi[i], to);
  chmax(lo[i], from);
}

int main2() {
  ll N = nextLong();
  REP(i, N) T[i] = nextInt();
  REP(i, N) A[i] = nextInt();

  const int INF = 1001001001;
  REP(i, N) hi[i] = INF;
  REP(i, N) lo[i] = 0;


  update(0, T[0], T[0]);
  for (int i = 1; i < N; i++) {
    if (T[i-1] < T[i]) {
      update(i, T[i], T[i]);
    } else {
      update(i, 1, T[i]);
    }
  }

  update(N-1, A[N-1], A[N-1]);
  for (int i = N-2; i >= 0; i--) {
    if (A[i] > A[i+1]) {
      update(i, A[i], A[i]);
    } else {
      update(i, 1, A[i]);
    }
  }
  const ll MOD = (ll)(1e9 + 7);
  ll ans = 1;
  REP(i, N) {
    if (lo[i] <= hi[i])
      ans *= hi[i] - lo[i] + 1;
    else
      ans = 0;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

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

  using M = Mint<int>;
  vector<M> dp(k+1,0);

  M ans{0};
  for(int i=k;i>0;i--){
    dp[i]=M(k/i).pow(n);
    for(int j=i+i;j<=k;j+=i)
      dp[i]-=dp[j];
    ans+=M(i)*dp[i];
  }

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h> 
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long 
#define LL long long 
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 22)], *p1 = buf, *p2 = buf;
using namespace std;
const int MAXN = 2e5 + 10, mod = 998244353, INF = 1e9 + 10;
const double eps = 1e-9;
template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline LL add(A x, B y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
template <typename A, typename B> inline void add2(A &x, B y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename A> inline void debug(A a){cout << a << '\n';}
template <typename A> inline LL sqr(A x){return 1ll * x * x;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
LL N, E, T, a[MAXN], f[MAXN];
int main() {
	N = read(); E = read(); T = read();
	memset(f, 0x3f, sizeof(f));
	for(int i = 1; i <= N; i++) a[i] = read();
	f[0] = 0; f[1] = T;
	LL mn = 1e18, j = 0;
	for(int i = 2; i <= N; i++) {
		while(T <= 2 * (a[i] - a[j + 1]) && j < i) chmin(mn, f[j] - 2 * a[j + 1]), j++;
		chmin(f[i], mn + 2 * a[i]);
		chmin(f[i], f[j] + T);
	}
	cout << f[N] + E;
    return 0;
}
/*
3 9 23333
1 3 8
*/

Measured memory_bytes: 4480
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Aug  6 00:46:16 2018
//
package main

import "fmt"

type problem struct {
	p, c int
}

var D, G int

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

func main() {
	fmt.Scan(&D, &G)
	ps := make([]problem, D)
	for i := range ps {
		fmt.Scan(&ps[i].p, &ps[i].c)
		ps[i].c += ps[i].p * (i + 1) * 100
	}

	ans := 1 << 30
	for i := 0; i < 1<<uint32(D); i++ {
		score := 0
		solved := 0
		for j := 0; j < D; j++ {
			if i&(1<<uint8(j)) != 0 {
				score += ps[j].c
				solved += ps[j].p
			}
		}

		if G <= score {
			ans = min(ans, solved)
		} else {
			for j := 0; j < D; j++ {
				if i&(1<<uint8(j)) == 0 {
					if G <= score+(ps[j].p-1)*(j+1)*100 {
						ans = min(ans, solved+(G-score+(j+1)*100-1)/((j+1)*100))
					}
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N, A, B = MI()

q, r = divmod(N, A + B)

if r > A:
    print(q * A + A)
else:
    print(q * A + r)


Measured memory_bytes: 9204
#include<iostream>//dp;
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int h[100010];
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    int cost[n+10];
    cost[1]=0;
    cost[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        int jamp=cost[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=k&&j<i;j++){
            jamp=min(jamp,cost[i-j]+abs(h[i]-h[i-j]));
        }
        cost[i]=jamp;
    }
    cout<<cost[n]<<"\n";
    return(0);
}

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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int mini= INT_MAX, maxi=INT_MIN;
    ll sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mini = min(mini,x);
        maxi = max(maxi, x);
        sum +=x;
    }
    cout<<mini<<" "<<maxi<<" "<<sum<<endl;
    return 0;
}




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

int main() {
	string s;cin>>s;
	int flag=1;
	for(int i=0;i<s.size();i++){
		if(i%2){
			if(s[i]=='R'){
				flag=0;
			}
		}else{
			if(s[i]=='L'){
				flag=0;
			}
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  int x, y;
  scanf("%d %d",&x,&y);
  if(x%y==0) printf("-1\n");
  else printf("%d\n",x); 

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


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

  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  double res=a[0];
  rep(i,n-1){
    res=(res+a[i+1])/2;
  }
  cout<<setprecision(12)<<res<<endl;
  return 0;

}


Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        while(a && (a & 1) == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3580
<?php
$n = int();
$A = ints();
$flag = true;
foreach($A as $a){
    if($a%2==0){
        if($a%3==0){
        }elseif($a%5==0){
        }else{
            $flag = false;
        }
    }
}
echo $flag ? "APPROVED" : "DENIED";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}

Measured memory_bytes: 4728
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  int r = 0;

  while (N) {
    r++;
    N /= K;
  }
  cout << r;
}
#endif


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc127/tasks/abc127_f

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

//------------------------------------------------------------------------------
#define LC(k)   (k * 2 + 1)
#define RC(k)   (k * 2 + 2)
#define M(l,r)  ((l + r) / 2)

template<typename T> class SegTree2 {
public:
  int n;
  int sz;
  T def;
  vector<T> dat;

  void init(int _n, T _def) {
    n = _n;
    sz = 1; while (sz < n) sz <<= 1;
    sz = sz * 2 - 1;
    def = _def;
    dat.resize(sz, def);
  }

  void update(int a, int b, T x, int k, int l, int r) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      dat[k] += x;
      return;
    }
    if (r - l > 1) {
      update(a, b, x, LC(k), l, M(l, r));
      update(a, b, x, RC(k), M(l, r), r);
    }
  }

  void update(int a, int b, T x) {
    update(a, b, x, 0, 0, n);
  }

  T query(int a, int b, int k, int l, int r) {
    T ret = def;
    if (r <= a || b <= l) return ret;
    ret += dat[k];
    if (r - l > 1) {
      ret += query(a, b, LC(k), l, M(l, r));
      ret += query(a, b, RC(k), M(l, r), r);
    }
    return ret;
  }

  T query(int a, int b) {
    return query(a, b, 0, 0, n);
  }

  void dump() {
    REP(i, sz) printf("%d%c", dat[i], i + 1 == sz ? '\n' : ' ');
  }
};

//------------------------------------------------------------------------------
const int Q_MAX = 2*1e5;
const int A_MAX = 1e9;
const int B_MAX = 1e9;
const int INF = 2e9;

int Q;
int Query[Q_MAX];
int a[Q_MAX];
int b[Q_MAX];

int N;
map<int, int> mp;
map<int, int> rmp;

SegTree2<int> st1;
SegTree2<ll> st2;

void compress() {
  mp[INF] = 1;
  mp[-INF] = 1;
  REP(i, Q) if (Query[i] == 1) mp[a[i]] = 1;
  int k = 0;
  ITR(mp, it) {
    it->second = k++;
    rmp[it->second] = it->first;
  }
}

bool C(int x) {
  return st1.query(x, x + 1) >= 0;
}

int bsearch() {
  int lo = 0;
  int hi = N;
  while (hi - lo > 1) {
    int mi = (lo + hi) / 2;
    if (C(mi)) hi = mi;
    else lo = mi;
  }
  return hi;
}

void solve() {
  compress();
  N = mp.size();

  st1.init(N, 0);
  st2.init(N, 0);
  REP(i, Q) {
    if (Query[i] == 1) {
      int ac = mp[a[i]];
      st1.update(0, ac, -1);
      st1.update(ac, N, 1);
      st2.update(0, ac, b[i] + a[i]);
      st2.update(ac, N, b[i] - a[i]);
    } else {
      int xc = bsearch();
      ll x = rmp[xc];
      ll v = st1.query(xc, xc + 1) * x + st2.query(xc, xc + 1);
      printf("%lld %lld\n", x, v);
    }
  }
}

void input() {
  scanf("%d", &Q);
  REP(i, Q) {
    scanf("%d", Query + i);
    if (Query[i] == 1) {
      scanf("%d %d", a + i, b + i);
    }
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 17408
N,M = map(int,input().split())
es = []
for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    c *= -1
    es.append((a,b,c))

INF = float('inf')
def solve():
    d = [INF for i in range(N)]
    d[0] = 0
    for i in range(N):
        for fr,to,cost in es:
            if d[fr] == INF: continue
            if d[to] > d[fr] + cost:
                d[to] = d[fr] + cost
                if i == N-1 and to == N-1: return 'inf'
    return -d[N-1]

print(solve())


Measured memory_bytes: 3316
a,b=input().split()
S=0
T=0
echo=[]
for x in range(int(a)):
    S+=1
    l=[int(x) for x in input().split()]
    for c in range(int(b)-1):
        if l[c]%2==1:
            echo.append(str(str(S)+" "+str(c+1)+" "+str(S)+" "+str(c+2)))
            l[c]=l[c]-1
            l[c+1]=l[c+1]+1
    #print(sum(l),T)
    #print(l)
    if (sum(l)+T)%2==1 and x+1 < int(a):
        echo.append(str(str(S)+" "+str(b)+" "+str(S+1)+" "+str(b)))
        T=1
    else:
        T=0
print(len(echo))
for y in echo:
    print(y)


Measured memory_bytes: 13988
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <ios>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>
#include <array>
#include <bitset>
#include <cstring>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <iterator>
using namespace std;
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Rof(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define int long long
#define db double
#define bit(x, i) (x >> i & 1ll)
#define onbit(x, i) (x | (1ll << i))
#define offbit(x, i) (x & (~(1ll << i)))

const int N = 1005, mo = 1e9 + 7;
int n, m, a[N][N], f[N][N];

main() {
    cin >> n >> m;
    For(i, 1, n) {
        For(j, 1, m) {
            char c;
            cin >> c;
            if(c == '#') a[i][j] = 1;
        }
    }
    f[1][1] = 1;
    For(i, 1, n) {
        For(j, 1, m) {
            if(!a[i][j]) {
                if(!a[i + 1][j]) f[i + 1][j] = (f[i + 1][j] + f[i][j]) % mo;
                if(!a[i][j + 1]) f[i][j + 1] = (f[i][j + 1] + f[i][j]) % mo;
                //cerr << f[i][j] << '\n';
            }
        }
    }
    cout << f[n][m];
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    vector<int> r;
    REP(i, N) {
        cin >> s[i];
        if(s[i] % 10 != 0) {
            r.push_back(s[i]);
        }
    }
    long long res = accumulate(s.begin(), s.end(), 0LL);
    if(res % 10 != 0) {
        cout << res << endl;
        return 0;
    } else {
        if(r.size() != 0) {
            cout << res - *min_element(r.begin(), r.end()) << endl;
        } else {
            cout << "0" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a[3000];
signed main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[j] < a[i]) {
				if (j > i) {
					ans += ((k + 1) * k / 2) % Mod;
				}
				else {
					ans += ((k - 1) * k / 2) % Mod;
				}
				ans %= Mod;
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    for (int i = 0; i <= 10000; i++)
    {
        int A_c = floor(i * 0.08);
        int B_c = floor(i * 0.1);

        if (A_c == A && B_c == B)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = K;
    rep(i, N - 1) {
        ans *= (K - 1);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;
const int MAX_V = 110;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int x; cin >> x;
	int tmp = x % 11;
	int ans = 0;
	if (tmp == 0)goto ex;
	if (7 <= tmp)ans += 2;
	else ans++;
ex:;
	cout << x / 11 *2+ ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

ans = [0] * N
for i in range(N):
    for j in reversed(range(len(B))):
        if j == B[j] - 1:
            ans[i] = B[j]
            if len(B) > 0:
                B.pop(j)
            break

if 0 in ans:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)

Measured memory_bytes: 3060
from math import sqrt
from itertools import combinations
N, D = map(int, input().split())
X = [[] for _ in range(N)]
for i in range(N):
    X[i] = list(map(int, input().split()))

def dist(p1, p2):
    ret = 0
    for a,b in zip(p1, p2):
        ret += abs(a-b)**2
    ret = sqrt(ret)
    return ret-int(ret)==0
ans = 0
for i,j in combinations(list(range(N)), 2):
    ans += dist(X[i], X[j])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<iomanip>
#include<string>
#include<algorithm>
#include<numeric>
#include<utility>
#define ll long long int
#define endl "\n"
#define ss string
using namespace std;
ll  mod(ll  a,ll  b)
{
  if(a>b)
    return (a-b);
  else
    return (b-a);
}
double distance(ll  x1, ll  y1, ll  x2, ll  y2)
{

    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}


int main()
{
 ll a, b, c, k;
 cin>>a>>b>>c>>k;
 if(k<=a)
 {
   cout<<k;
 }
 else if(k<=a+b)
 {
   cout<<a;
 }
 else
  cout<<a+(-1)*(k-a-b);

    return 0;

}


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

void input ();
void solve ();

const int MAXN = 10;

int n;
std::pair <int, std::pair <int, int> > towns [MAXN];

void input () {
  scanf ("%d", &n);
  for (int i = 0, a, b; i < n; i++) {
    scanf ("%d %d", &a, &b);
    towns [i] = std::make_pair (i, std::make_pair (a, b));
  }

  solve ();
}

void solve () {
  double ans = 0;
  long long count = 0;
  do {
    for (int i = 0; i < n - 1; i++)
      ans += std::hypot (towns [i].second.first - towns [i + 1].second.first, towns [i].second.second - towns [i + 1].second.second);

  } while (std::next_permutation (towns, towns + n));

  double fat = 1;
  for (int i = n; i > 0 ; i--)
    fat *= i;

  ans = ans / fat;

  printf ("%.10lf\n", ans);
}

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


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

int main() {
    int n, x, y;
    int s = 0;
    cin >> n;
    while(n--) {
        cin >> x >> y;
        if(x==y) {
            s++;
        } else {
            s = 0;
        }
        if(s==3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl; 
    return 0;
}

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

int main() {
     
     long long i,j,l,r,q,m,n,p,h,x;
     long long k,z,y,p1,h1;
     string st="",s1="",s2="";
     q=1;
     for(l=0;l<q;l++)
     {
          double f,d,t,s;
          std::cin >> d >> t >> s;
          f=d/s;
          if(f<=t)
               std::cout << "Yes" << std::endl;
          else
               std::cout << "No" << std::endl;
     }
     return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 11;
int S[N][N], C[N][N];
int n, mod;
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
inline int M(int x, int y){
    return 1LL * x * y % mod;
}
inline int ksm(int base, int x, int mod){
    int ans = 1;
    while(x){
        if(x & 1)ans = 1LL * ans * base % mod;
        base = 1LL * base * base % mod;
        x >>= 1;
    }
    return ans;
}
int main(){
    cin>>n>>mod;
    C[0][0] = S[0][0] = 1;
    for(int i = 1;i <= n + 1; i++){
        C[i][0] = 1;
        for(int j = 1;j <= i; j++){
            C[i][j] = A(C[i-1][j-1], C[i-1][j]);
            S[i][j] = A(S[i-1][j-1], M(S[i-1][j], j));
        }
    }
    int ans = ksm(2, ksm(2, n, mod - 1), mod);
    //printf("ans=%d\n", ans);
    for(int i = 1;i <= n; i++){
        int res = 0;
        for(int j = 0;j <= i; j++){
            res = A(res, M(S[i+1][j+1], ksm(2, 1LL * (n - i) * j % (mod - 1), mod)));
        }
        res = M(res, M(C[n][i], ksm(2, ksm(2, n - i, mod - 1), mod)));
        //printf("i=%d res=%d\n", i, res);
        if(i & 1)ans = A(ans, mod - res);
        else ans = A(ans, res);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

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

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

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

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

    vector<int> a(100010);
    int i=0;
    while(n != 1){
        if(n % (-2) == 0){
            a[i] = 0;
            n /= (-2);
        }
        else{
            a[i] = 1;
            n = (n-1) / (-2);
        }
        i++;
    }
    cout << 1;
    for(int j=i-1; j>=0; j--) cout << a[j];
    cout << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+50;
pair<long long,long long> m[N],b[N];
long long cnt;
int main()
{
	long long n,d,a;
	cin>>n>>d>>a;
	for (int i=0;i<n;i++)
		cin>>m[i].first>>m[i].second;
	sort(m,m+n);
	long long ans=0,cnt=0,l=1,sum=0;
	for (int i=0;i<n;i++)
	{
		while (l<=cnt)
		{
			if (b[l].first+d>=m[i].first)
				break;
			sum-=b[l].second;
			l++;
		}
		if (m[i].second<=sum)
			continue;
		m[i].second-=sum;
        long long num=(m[i].second+a-1)/a,v=num*a;
        b[++cnt]= make_pair(m[i].first+d,v);
        sum+=v;
        ans+=num;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
ll res = 0;
const int N = 1e5 + 10;
int h[N], n, Q;

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

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

    scanf("%d", &Q);
    while(Q--) {
        int a, b;
        scanf("%d%d", &a, &b);
        int cnt = h[a];
        h[a] = 0;
        res -= 1ll * cnt * a;
        res += 1ll * cnt * b;
        h[b] += cnt;
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 2124
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int n=Integer.parseInt(scan.next());
    		int a=Integer.parseInt(scan.next());
    		
    		System.out.print(n*n-a);

    		
    	
  
    				
 
     
    }
    }

Measured memory_bytes: 21716