akhauriyash/Code-Regression huggingface dataset:
#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);
    string S, T;
    cin >> S >> T;
    rep(i, 1000) {
        if(S == T) {
            cout << "Yes" << endl;
            return 0;
        }
        S = S.back() + S;
        S.pop_back();
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
int n;cin>>n;
for(int i=0;i<n;i++){
    char a;cin>>a;
    if(a=='Y'){cout<<"Four";return 0;}
}
cout<<"Three";
}

Measured memory_bytes: 256
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; i++) {
  	cin >> p[i];
	}
  vector<vector<double>> dp(n, vector<double>(n + 1));
  dp[0][0] = 1 - p[0];
  dp[0][1] = p[0];
  for (int i = 1; i < n; i++) {
  	dp[i][0] = dp[i - 1][0] * 1.0 * (1 - p[i]);
  	for (int j = 1; j <= i + 1; j++) {
  		dp[i][j] = dp[i - 1][j] * 1.0 * (1 - p[i]) + dp[i - 1][j - 1] * 1.0 * p[i];
		}
	}
	double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++) {
		ans += dp[n - 1][i];
	}
	cout << fixed << setprecision(17);
	cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 70656
n  = int(input())
p  = list(map(int,input().split()))
q  = sorted(p)
a=[]
for i in range(n):
	if not p[i]==i+1:
		a.append(p[i])

n = len(a)
if n==0 or n ==2:
	print("YES")

else:
	print("NO")

Measured memory_bytes: 3060
n = int(input())
W = list()
ans = "Yes"
for i in range(n):
    w = input()
    W.append(w)
for j in range(1,n):
    if W[j][0] != W[j-1][-1] or (W[j] in W[:j]):
        ans = "No"
print(ans)

Measured memory_bytes: 3060
import math
a,b,h,m= map(int, input().split())
pi=math.pi
mi=60*h+m
hpi=2*pi*mi/(12*60)
mpi=2*pi*m/60
a1=a*math.sin(hpi)
a2=a*math.cos(hpi)
b1=b*math.sin(mpi)
b2=b*math.cos(mpi)
cc=math.sqrt((a1-b1)**2+(a2-b2)**2)
print(cc)

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

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


int main(void) {
    int N;
    cin >> N;
    double p[N];
    rep(i, N) cin >> p[i];



    double dp[N+1][N+1];
    rep(i,N){
        rep(j,N){
            dp[i][j] = 0.0;
        }
    }

    dp[0][0] = 1.0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= i; j++) {
            if(j >= 1){
                dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1.0 - p[i-1]);
            } else {
                dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]);
            }
        }
    }

    // rep(i,N){
    //     rep(j,N){
    //         cout << dp[i][j] << endl;
    //     }
    // }

    double ans = 0.0;
    for(int i = (N/2)+1; i <= N; i++) {
        ans += dp[N][i];
    }
    cout << setprecision(10) << scientific << ans << endl;

    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s == "Sunny")cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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 END(){cout << 1 << endl; exit(0);}

int fact(int n)
{
  if (n == 0) return 1;
  return n * fact(n-1);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<VB> G(n, VB(n, false));
  REP(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a][b] = true;
    G[b][a] = true;
  }
  int ans = 0;
  VI v(n-1);
  iota(ALL(v), 1);
  do
  {
    if (!G[0][v[0]]) continue;
    bool flg = true;
    REP(i, n-2)
    {
      if (!G[v[i]][v[i+1]])
      {
        flg = false;
        break;
      }
    }
    if (flg) ans++;
  } while(next_permutation(ALL(v)));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;

ifstream fin ("spioni.in");
ofstream fout ("spioni.out");

#define f first
#define s second

int dl[4] = {0, 0, -1, 1};
int dc[4] = {1, -1, 0, 0};

int n, m, t[23][23], mat[402][402],nr;
char v[23][23];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      cin >> v[i][j];
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    if (v[i][j] != '.') continue;
    nr++;
    t[i][j] = nr;
    for (int k = 0; k < 4; k++) {
      int ii = i + dl[k];
      int jj = j + dc[k];
      if (v[ii][jj] == '.' && t[ii][jj] && ii >= 1 && ii <= n && jj >= 1 && jj <= m) {
        mat[nr][t[ii][jj]] = 1;
        mat[t[ii][jj]][nr] = 1;
      }
    }
  }
  for (int i = 1; i <= nr; i++)
  for (int j = 1; j <= nr; j++)
    if (mat[i][j] == 0 && i != j)
      mat[i][j] = 1e9;
  for (int k = 1; k <= nr; k++)
    for (int i = 1; i <= nr; i++)
      for (int j = 1; j <= nr; j++) {
        if (mat[i][k] + mat[k][j] < mat[i][j])
          mat[i][j] = mat[i][k] + mat[k][j];
      }
  int mx =0;
  for (int i = 1; i <= nr; i++)
  for (int j = 1; j <= nr; j++)
    mx = max(mx, mat[i][j]);
  cout << mx;

  return 0;
}


Measured memory_bytes: 896
# coding: utf-8

while True:
    valueA, operation, valueB = input().split(" ")
    if operation == "?":
        break
    elif operation == "+":
        result = int(valueA) + int(valueB)
    elif operation == "-":
        result = int(valueA) - int(valueB)
    elif operation == "*":
        result = int(valueA) * int(valueB)
    elif operation == "/":
        result = int(valueA) / int(valueB)
    print("{0}".format(int(result)))

Measured memory_bytes: 7576
default = 120 * 60

while 1:
    t, h, s = map(int, input().split())
    if t == -1 and h == -1 and s == -1:
        break

    time = t * 3600 + h * 60 + s
    diff = default - time
    diff3 = diff * 3

    diff_t = str(diff // 3600).zfill(2)
    diff_h = str(diff % 3600 // 60).zfill(2)
    diff_s = str(diff % 60).zfill(2)

    diff_3t = str(diff3 // 3600).zfill(2)
    diff_3h = str(diff3 % 3600 // 60).zfill(2)
    diff_3s = str(diff3 % 60).zfill(2)

    print(diff_t + ":" + diff_h + ":" + diff_s)
    print(diff_3t + ":" + diff_3h + ":" + diff_3s)



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

int main() {
        int a, b;
        cin >> a >> b;
        cout << (1 ^ 2 ^ 3 ^ a ^ b) << endl;
        return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int solve(vector<int> a, vector<int> b, int k){
    int t = 1 << k;
    int m = 1 << (k+1) ;
    int n = a.size();
    rep(i, n){
        a[i] %= m;
        b[i] %= m;
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end());

    int ans = 0;
    int it1, it2, it3, it4;
    it1 = it2 = it3 = it4 = 0;

    rep(i, n){
        while(b[it1] < t - a[i]     && it1 < n) it1++;
        while(b[it2] < 2 * t - a[i] && it2 < n) it2++;
        while(b[it3] < 3 * t - a[i] && it3 < n) it3++;
        while(b[it4] < 4 * t - a[i] && it4 < n) it4++;
        ans += it4 - it3 + it2 - it1;

    }

    return ans;
}

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

    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];



    int ans = 0;

    rep(i, 30){
        int s = solve(a, b, i);
        if(s % 2 == 1){
            ans |= 1 << i;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;

  int All[100000] = {0};

  for (int i = 0; i < Q; i++) {
    int A;
    cin >> A;

    All[A-1]++;
  }
  
  for (int k = 0; k < N; k++) {
    if (K + All[k] - Q <= 0) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  
  return 0;
}

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

int main() {
  int N, K, sum;
  cin >> N >> K;
  sum = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    int a, b;
    a = x;
    b = K - x;
    if (a < b) {
      sum += 2 * x;
    }
    else {
      sum += 2 * (K - x);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <cctype>
using namespace std;
#define rg register

template <typename _Tp> inline _Tp read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}

inline void cmin(int&A,int B){A=A<B?A:B;}
const int N=201000,p=1e9+7;
int fac[N],inv[N],mi[N],t[N],c[N],w[N];
int n,X,Y,sz,m1=0x3f3f3f3f,m2=m1,i1,i2;

inline int qpow(int A,int B){
	int res(1);while(B){
		if(B&1)res=1ll*res*A%p;
		A=1ll*A*A%p,B>>=1;
	}return res;
}

void init();void work();
int main(){init();work();return 0;}

void work(){
	for(rg int i=1;i<=n;++i){
		if(m1+w[i]<=Y&&c[i]!=i1)++sz,++t[c[i]];
		else if(m2+w[i]<=Y&&c[i]!=i2)++sz,++t[c[i]];
	}sz=fac[sz];
	for(rg int i=1;i<=n;++i)
		if(t[i])sz=1ll*sz*inv[t[i]]%p;
	printf("%d\n",sz);
}

void init(){
	read(n),read(X),read(Y);
	memset(mi,0x3f,sizeof mi);
	for(rg int i=1;i<=n;++i){
		read(c[i]),read(w[i]);
		cmin(mi[c[i]],w[i]);
	}fac[0]=1;
	for(rg int i=1;i<=n;++i){
		fac[i]=1ll*fac[i-1]*i%p;
		if(mi[i]<=m1)m2=m1,i2=i1,m1=mi[i],i1=i;
		else if(mi[i]<m2)m2=mi[i],i2=i;
		if(w[i]+mi[c[i]]<=X)w[i]=mi[c[i]];
	}inv[n]=qpow(fac[n],p-2);
	for(rg int i=n-1;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%p;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	string s;
	while(cin>>s){
		if(s.size()%2){
			o("NA"); continue;
		}
		bool f=1;
		string ans="",t="z.?! ";
		rep(i,0,s.size()/2){
			if(1<=s[2*i]-'0' && s[2*i]-'0'<=6 && 1<=s[2*i+1]-'0' && s[2*i+1]-'0'<=5){
				if(s[2*i]!='6'){
					ans+='a'+5*(s[2*i]-'1')+s[2*i+1]-'1';
				}else if(s[i*2]=='6'){
					ans+=t[s[2*i+1]-'1'];
				}
			}else f=0;
		}
		if(f) o(ans);
		else o("NA");
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;cin >> x >> y;
	int ans = 0;
	if(x == 3) ans += 100000;
	if(x == 2) ans += 200000;
	if(x == 1) ans += 300000;
	if(y == 3) ans += 100000;
	if(y == 2) ans += 200000;
	if(y == 1) ans += 300000;
	if(x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
}


Measured memory_bytes: 256
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 1e5 + 10;
int passed[N], penalty[N], n, m;
int main() {
	cin >> n >> m;
	int score = 0;
	repn(i, m) {
		int pid; string verdict;
		cin >> pid >> verdict;
		if (verdict == "WA") {
			if (!passed[pid]) penalty[pid]++;
		}
		else {
			if (!passed[pid]) passed[pid] = true, score++;
		}
	}
	int ans = 0;
	repn(i, n) if (passed[i]) ans += penalty[i];
	cout << score << ' ' << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#define ri register int
#define rc register char
#define ll long long int
#define rl register long long int
#define in inline
#define gc getchar
in ll read()
{
    rl x=0,p=1;
    rc ch=gc();
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
        {
            p=-1;
        }
        ch=gc();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0',ch=gc();
    }
    return x*p;
}
ll a,b,c;
int main()
{
    a=read(),b=read(),c=read();
    if(a+b>=c)
    {
        puts("No");
    }
    else
    {
        ll d=(c-a-b)*(c-a-b);
        if(4*a*b<d)
        {
            puts("Yes");
        }
        else
        {
            puts("No");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxStore = 2e5 + 5;
int nbStore, sj, totNeg, totZer;
ll sum[maxStore];
struct STORE {
    ll slope, add;
    STORE operator = (const STORE &d) {
        slope = d.slope;
        add = d.add;
        return (*this);
    }
} store[maxStore], zero[maxStore];
ll dp[maxStore][35];
bool cmp1(STORE fir, STORE sec) {
    return (1ll * sec.slope * (fir.add + 1) < 1ll * fir.slope * (sec.add + 1));
}
bool cmp2(STORE fir, STORE sec) {
    return fir.add < sec.add;
}
int main() {
    scanf("%d%d", &nbStore, &sj);
    for (int i = 1; i <= nbStore; ++i) {
        STORE tmp;
        scanf("%lld%lld", &tmp.slope, &tmp.add);
        if (tmp.slope != 0)
            store[++totNeg] = tmp;
        else zero[++totZer] = tmp;
    }
    sort(store + 1, store + totNeg + 1, cmp1);
    sort(zero + 1, zero + totZer + 1, cmp2);
    for (int i = 1; i <= totZer; ++i)
        sum[i] = sum[i - 1] + zero[i].add + 1;
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int pre = 1; pre <= totNeg; ++pre) {
        dp[pre][0] = 0;
        //前几个取0个应该都是0 
        for (int chos = 1; chos <= 30; ++chos) {
            dp[pre][chos] = dp[pre - 1][chos];
            if (dp[pre - 1][chos - 1] > 1e9)
                continue ;
            ll tmp = (dp[pre - 1][chos - 1] + 1) * (store[pre].slope + 1) + store[pre].add; //这里把每条边+的1都带在前面，就是先+1再乘。
            if (tmp > 1e9) break ;
            else dp[pre][chos] = min(dp[pre][chos], tmp);
        }
    }
    int ans = 0;
    for (int chos = 0; chos <= 30; ++chos) {
        ll spare = sj - dp[totNeg][chos];
        if (spare < 0) break ;
        int pos = upper_bound(sum + 1, sum + totZer + 1, spare) - sum;
        ans = max(chos + pos - 1, ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 62720
#include <stdio.h>

int main(int argc, char *args[])
{
	int sec;
	int h,m,s=0;

	scanf("%d", &sec);

	h = sec / 3600;
	m = (sec % 3600) / 60;
	s = (sec % 3600) % 60;

	printf("%d:%d:%d\n", h,m,s);

	return 0;
}

Measured memory_bytes: 592
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i64,
    }
    for i in 0..n + 1 {
        if i * 108 / 100 == n {
            puts!("{}\n", i);
            return;
        }
    }
    puts!(":(\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#　三井住友B
import math
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n = ni()
ans = 0

ans = (n*100)/108

ans = math.ceil(ans)
# print(ans)
# print(math.floor(ans*1.08))
if n==math.floor(ans*1.08):
    print(ans)
else:
    print(':(')

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

using namespace std;

int main()
{
    long long n,flag=0;
    cin>>n;
    long long min1=9999999999999;
    /*for(long long i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout<<n-1<<endl;
    else*/
    {
        for(long long i=1; i*i<=n; i++)
        {

            if(n%i==0)
            {
                min1=min(min1,n/i+i-2);
                //cout<<"asd"<<endl;
            }
        }
        cout<<min1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        PriorityQueue<String> s=new PriorityQueue<String>();
        Queue<String> t=new ArrayDeque<String>();
        for(int i=0;i<n;i++){
            s.add(sc.next());
        }
        int max=0;
        while(s.peek()!=null){
            String str=s.peek();
            int i=0;
            for(;s.peek()!=null&&s.peek().equals(str);i++){
                s.remove();
            }
            if(max==i){
                t.add(str);
            }else if(max<i){
                max=i;
                t.clear();
                t.add(str);
            }
        }
        while(t.peek()!=null){
            System.out.println(t.remove());
        }
    }
}

Measured memory_bytes: 74968
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

int a[2][128];
int dp[2][128];

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
  int n;
  cin >> n;
  REP(i,2) REP(j,n) cin >> a[i][j];
  dp[0][0] = a[0][0];
  REP(i,n-1) dp[0][i+1] = dp[0][i] + a[0][i+1];
  dp[1][0] = a[0][0] + a[1][0];
  REP(i,n-1) dp[1][i+1] = max(dp[0][i+1], dp[1][i]) + a[1][i+1];
  cout << dp[1][n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
L,R = map(int, input().split())
if (R-L) > 2019:
    R = L+2019
ans = 2019**2
for i in range(L,R+1):
    for j in range(L,R+1):
        if i == j:
            continue
        elif ans > (i*j)%2019:
            ans = (i*j)%2019
            if ans == 0:
                print(ans)
                quit()
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp107 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var s = new int[N];
            for (int i = 0; i < N; i++) {
                s[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(s);

            int sum = s.Sum();

            if (sum % 10 != 0) {
                Console.WriteLine(sum);
                return;
            }

            var not10array = s.Where(x => x % 10 != 0).OrderBy(x => x).ToArray();
            
            if (not10array.Count() == 0) {
                Console.WriteLine(0);
            } else {
                Console.WriteLine(sum - not10array[0]);
            }

        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
黒を白にすることもある

*/

ll n,ru[200010]={},ru2[200010]={},ans=1e18;
string s;
bool black=false;
vector<pair<char,int> > v;

void RLE(string &s, vector<pair<char,int> > &v){
	v.push_back({s[0],0});
	for(int i=0;i<s.size();i++){
		if(s[i]==v[v.size()-1].first){
			v[v.size()-1].second++;
		}else{
			v.push_back({s[i],1});
		}
	}
}

void init(){
	cin>>n>>s;
	RLE(s,v);
	ru[0]=0;
	ru2[0]=0;
	reg(i,1,v.size()){
		ru[i]=ru[i-1]+(v[i-1].first=='#'?v[i-1].second:0);
		ru2[i]=ru2[i-1]+(v[i-1].first=='.'?v[i-1].second:0);
		// cerr<<ru[i]<<","<<ru2[i]<<endl;
	}
	// rep(i,v.size())cerr<<v[i].first<<","<<v[i].second<<endl;
	cerr<<"初期化終了"<<endl;
}

int main(void){
	init();
	reg(i,0,v.size()){
		ans=min(ans,ru[i] + ru2[v.size()]-ru2[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string t;
    cin >> s >> t;
    ll ans = mod;
    rep(i, s.length() - t.length() + 1) {
        string sub = s.substr(i, t.length());
        ll temp = 0;
        rep(j, t.length()) {
            if (t[j] != sub[j]) {
                temp++;
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3660
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	answers := make([]int, n + 1, n + 1)

	for i := 0; i < n - 1; i++ {
		sc.Scan()
		tmp, _ := strconv.Atoi(sc.Text())
		answers[tmp] += 1
	}

	for i := 1; i <= n; i++ {
		fmt.Println(answers[i])
	}
}

Measured memory_bytes: 6188
n,m=map(int, input().split())
alist=[list(map(int, input().split())) for l in range(n)]
alist.sort(key=lambda x:x[0])
ans=0
cnt=m
for i in range(n):
  if alist[i][1]<cnt:
    ans+=alist[i][0]*alist[i][1]
    cnt-=alist[i][1]
  else:
    ans+=cnt*alist[i][0]
    break
print(ans)

Measured memory_bytes: 28616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b; cin >> a >> b;
    int ans = (a+b >= 24) ? a+b-24: a+b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type base_size;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : base_size(0), c() {}
	explicit segment_tree(const size_type size)
		: base_size(getsize(size)),
		c(base_size + size, value_structure::identity()) {}

	bool empty() const { return size() == 0; }
	size_type size() const { return c.size() - base_size; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + base_size];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += base_size, last += base_size; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < base_size)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - base_size + 1;
	}

	void update(size_type index, const value_type &value) {
		assert(index < size());
		index += base_size;
		c[index] = value;
		while (index >>= 1)
			recalc(index);
	}
};

template <class T> class plus_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	segment_tree<plus_monoid<int>, vec_alias> seg(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;

		if (c)
			::std::cout << seg.fold(x - 1, y) << ::std::endl;
		else
			seg.update(x - 1, seg[x - 1] + y);
	}

	return 0;
}



Measured memory_bytes: 3616
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define lli long long
int main(){
  lli n,m,i,j,ans=0;
  cin>>n>>m;
  if(m==1){
    cout<<"0";
    return 0;
  }
  vector<int>a(m+1);
  for(i=1;i<=m;i++)
    cin>>a[i];
  sort(a.begin()+1,a.end());
  vector<int>v(m);
  for(j=2;j<=m;j++){
    v[j-2]=a[j]-a[j-1];
  }
  sort(v.rbegin(),v.rend());
  for(i=n-1;i<m;i++)
    ans+=v[i];
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	bool sosuu[100000] = {};
	
	for (int i = 2; i < 100000; i++) {
		sosuu[i] = true;
	}
	for (int i = 2; i < 100000; i++) {
		if (!sosuu[i]) continue;
		for (int k = i + i; k < 100000; k += i) {
			sosuu[k] = false;
		}
	}
	
	int anss[100001] = {};
	
	for (int i = 1; i < 100000; i+= 2) {
		if (sosuu[i] && sosuu[(i + 1) / 2]) anss[i] = 1;
	}
	for (int i = 0; i < 100000; i++) {
		anss[i + 1] += anss[i];
	}
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		cout << anss[r] - anss[l - 1] << endl;
	}
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define LINE_BUF_SIZE  1024

int main(void) {
  
  int R;

  scanf("%d",&R);
  
  printf("%f",2*R*(M_PI));

  return 0;
}

Measured memory_bytes: 1740
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

MOD = 10 ** 9 + 7

am = {}
for a in A:
	am[a] = True

dp = [1] + [0] * (N + 10)

for n in range(1, N + 1):
	if n in am:
		continue
	dp[n] = (dp[n - 1] + (dp[n - 2] if 2 <= n else 0)) % MOD

#print(dp)
print(dp[N])


Measured memory_bytes: 16284
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll a,b;
        cin>>a>>b;
        a%=b;
        cout<<Min(a,b-a);



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            if (inp == "SUN") Console.WriteLine("7");
            else if (inp == "MON") Console.WriteLine("6");
            else if (inp == "TUE") Console.WriteLine("5");
            else if (inp == "WED") Console.WriteLine("4");
            else if (inp == "THU") Console.WriteLine("3");
            else if (inp == "FRI") Console.WriteLine("2");
            else if (inp == "SAT") Console.WriteLine("1");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
//string s;
bool flag;

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

#define MAX 100

int main(void) {
  ll q, h, s, d;

  cin >> q >> h >> s >> d;
  cin >> n;

  temp = min(q * 4, h * 2);
  temp = min(temp, s);

  m = min(temp * 2, d);

  n % 2 == 0 ? ans = (n / 2) * m : ans = (n / 2) * m + temp;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
int dp[3030][3030];

int main() {
    cin >> s;
    cin >> t;
    int slen = s.length();
    int tlen = t.length();

    for(int i = 0; i <= slen+1; ++i) {
        for(int j = 0; j <= tlen+1; ++j) {
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < slen; ++i) {
        for(int j = 0; j < tlen; ++j) {
            if(s.at(i) == t.at(j)) {
                dp[i+1][j+1] = dp[i][j]+1;
            }else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    int len = dp[slen][tlen];
    vector<char> ans(len);
    int k = slen;
    int l = tlen;
    while(len > 0) {
        if(s.at(k-1) == t.at(l-1)) {
            ans.at(len-1) = s.at(k-1);
            k--;
            l--;
            len--;
        }else if(dp[k][l] == dp[k-1][l]) {
            k--;
        }else {
            l--;
        }
    }

    len = ans.size();
    for(int i = 0; i < len; ++i) {
        cout << ans.at(i);
    }
    cout << endl;
}

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

struct node{
	int i,ai;
	bool operator < (node t){
		return ai<t.ai;
	}
};

const int nmax=1e5+5;
int n;

node str[nmax];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		str[i].i=i;
		scanf("%d",&str[i].ai);
	}
	sort(str+1,str+n+1);
	for(int i=1;i<=n;i++){
		printf("%d ",str[i].i);
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(){
int A,B,C,D;
cin>>A >>B >>C >>D;
if (A*B==C*D){
	cout<<A*B<<endl;
	return 0;
}
if (A*B>C*D){
	cout<<A*B<<endl;
}
else{
	cout<<C*D<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) (a).begin(), (a).end()
#define pw(x) (1ll<<(x))
#define lb(x) ((x) & -(x))
#define endl "\n"
#define FI(x) freopen(#x".in","r",stdin)
#define FO(x) freopen(#x".out","w",stdout)
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
//typedef uniform_int_distribution<ll> RR;
const int P = 1e9 + 7;
//ll rnd(ll l, ll r) { mt19937 gen(rand()); RR dis(l, r); return dis(gen); }
int add(int a, int b) {if((a += b) >= P) a -= P; return a < 0 ? a + P : a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----

int n;
string s, t, ss;

int main() {
	//FI(a);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	cin >> n >> s >> t;
	rep(i, 0, sz(s)+1) {
		ss = s + t.substr(sz(t) - i, sz(t));
		if (ss.substr(0, n) == s && ss.substr(sz(ss) - n, sz(ss)) == t) {
			cout << sz(ss) << endl;
			return 0;
		}
	} 
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);

        while (true) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (x == 0 && y == 0) {
                return;
            }
            for (int i = 0; i < x; i++) {
                for (int p = 0; p < y; p++) {
                    if (i == 0 || p == 0 || (i == x - 1) || (p == y - 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 29624
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ll n; cin >> n;
	ll ans = 1000;
	while (n >= 100) {
		ll a = n % 1000;
		ans = min(abs(a - 753), ans);
		n /= 10;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])


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

#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>> //vvl data(10, vector<ll>(10);
#define fo(i,a,b) for(ll i=a; i<b; i++)

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

    vl num(N);
    ll limit = pow(10, 18);
    fo(i, 0, N){
        cin >> num[i];
        if(num[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        if(num[i] > limit){
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 1;
    fo(i, 0, N){
        if(limit/ans < num[i]){
            cout << -1 << endl;
            return 0;
        }else{
            ans *= num[i];
        }
    }
    
    cout << ans << endl;
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 4064
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	t_begin := -1

	for i := len(s) - 1; i >= 0; i-- {
		k := i
		for j := len(t) - 1; j >= 0; j-- {
			if !(t[j] == s[k]) && !(s[k] == '?') {
				break
			}
			k--
			if k < 0 {
				break
			}
		}
		if k == i-len(t) {
			t_begin = k + 1
			break
		}
	}

	if t_begin < 0 {
		fmt.Println("UNRESTORABLE")
		return
	}
	for i := 0; i < len(s); i++ {
		if t_begin <= i && i < t_begin+len(t) {
			fmt.Printf("%s", string(t[i-t_begin]))
		} else if s[i] == '?' {
			fmt.Printf("a")
		} else {
			fmt.Printf("%s", string(s[i]))
		}
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF=1000000000;

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;

	int ret=0,p,q,cnt;
	for(int i=0;i<b-ret;i++){
		p=0; q=i; cnt=0;
		while(1){
			
			if(s[p]==t[q]){
				if(p>=memo[q])break;
				memo[q]=p;
				cnt++;
				q++;
			}
			p++;
			if(p==a){
				ret=max(ret,cnt);
				break;
			}
		}
	}


	printf("%d\n",ret);
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back 
#define ff first 
#define ss second
#define all(c) c.begin(), c.end()
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
//Debugging tools 
#define debug(v) cout<<#v<<endl;for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) cout<<#v<<endl;for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<#sum<<" = "<<sum<<endl;
//Predefined values
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143


int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
        int n, x= 1000;
        cin>>n;
        if(n%x==0) cout<<0<<endl;
        else cout<<1000-n%x<<endl;
    }
  return 0;
} 

















Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	public static void main(String[] __){
		long a=getInt(),b=getInt(),c=getInt(),s=0,buf;
		for(int i=0;i<114514;i++) {
			if(s-(buf=s/60*60)<=c&&c<=s+a-buf) {
				System.out.println(buf+c);
				return;
			}
			s+=a+b;
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 26168
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
S = input()
L = [LIST() for i in range(Q)]
ruiseki = [0] * (N)

for i in range(N-1):
    if S[i+1] == "C" and S[i] == "A":
        #if S[i] == "A":
            ruiseki[i+1] += ruiseki[i] + 1
    else:
        ruiseki[i+1] = ruiseki[i]
for l, r in L:
    ans = ruiseki[r-1] - ruiseki[l-1]
    print(ans)

    



Measured memory_bytes: 32728
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<LL> pdivi(LL K){
    vector<LL> v;
    for(LL i=2;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        while(K%i==0){
            K/=i;
        }
    }
    if(K!=1) v.pb(K);
    return v;
}

LL gcd(LL a,LL b){
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    return gcd(a%b,b);
}

int main(){
    LL a,b;cin >> a >> b;
    auto p = pdivi(gcd(a,b));
    cout << p.size() + 1 << endl;
    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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,T;cin>>n>>T;
    int res=10000;
    rep(i,n){
        int c,t;cin>>c>>t;
        if(t>T)continue;
        chmin(res,c);
    }
    if(res==10000)cout<<"TLE"<<endl;
    else cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  vector<int> antennas(5);
  int N;
  cin >> N;
  vector<int> monster(N);
  for (int i = 0; i < N; i++) {
    cin >> monster[i];
  }
  for(int i = 1; i < N; i++){
    monster[0] = __gcd(monster[0], monster[i]);
  }
  cout << monster[0] <<endl;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 19541921608536647, base = 61;
    unsigned long N;
    cin >> N;
    vector<unsigned long> s(N);
    {
        string S;
        cin >> S;
        transform(S.begin(), S.end(), s.begin(), [](auto i){return i - 97;});
    }
    const auto f = [&MOD, &base, &N, &s](unsigned long x) -> bool{
        unsigned long h{0}, c{MOD - 1};
        for(unsigned long i = 0; i < x; ++i){
            ((h *= base) += s[i]) %= MOD;
            (c *= base) %= MOD;
        }
        unordered_set<unsigned long> st;
        deque<unsigned long> dq{h};
        for(unsigned long i = 0; i + x < N; ++i){
            dq.push_back(((h *= base) += c * s[i] + s[i + x]) %= MOD);
            if(dq.size() > x){
                st.insert(dq.front());
                dq.pop_front();
            }
            if(st.count(h))return true;
        }
        return false;
    };
    unsigned long L = 0, R = (N * 3 + 1) / 4;
    while(L + 1 < R){
        auto M = (L + R) / 2;
        (f(M) ? L : R) = M;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 604