akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string A, B;
	cin >> A >> B;
	A += B;
	int X = stoi(A);
	int sqrtX = sqrt(X);
	YesNo(sqrtX*sqrtX == X);
	return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim dic As New Dictionary(Of Integer, Boolean)
        Dim N As Integer = NextInt()

        For i As Integer = 0 To N - 1
            Dim d As Integer = NextInt()
            dic(d) = True
        Next

        WriteLine(dic.Count)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22224
def main():
    N, T = map(int, input().split())
    time = [int(t) for t in input().split()]
    start = 0
    cur = 0
    ans = 0
    for t in time[1:]:
        if t - cur > T:
            ans += cur + T - start
            start = t
        cur = t
    ans += cur + T - start
    return ans


if __name__ == '__main__':
    print(main())


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A.at(i);
  
  int divide = 0;

  for (int i = 0; i < N; ++i) {
    while   (i + 1 < N && A.at(i) == A.at(i + 1)) ++i;
    
    if      (i + 1 < N && A.at(i) < A.at(i + 1)) {
      while     (i + 1 < N && A.at(i) <= A.at(i + 1)) ++i;
    }
    else if (i + 1 < N && A.at(i) > A.at(i + 1)) {
	  while     (i + 1 < N && A.at(i) >= A.at(i + 1)) ++i;
    }
      
    ++divide;
  }
  cout << divide << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	vector<string> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) {
		cout << v.at(i);
		if (i == N - 1) {
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N, K);
    vector<i64> h(N);
    read(h);

    sort(all(h));
    i64 ans = LINF;
    rep(i, 0, N - K + 1) {
        dump(i, i+K-1);
        chmin(ans, h[i+K-1] - h[i]);
    }

    print(ans);

    return 0;
}


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

#define N 3000
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

long long dp[N][N]; // dp[l][r] = [l,r]のX-Yの最適値

int main(void){
  int n, a[N];
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
    dp[i][i] = n%2? a[i]: -a[i];
  }
    
  for (int ln=2; ln<=n; ln++){
    for (int i=0; i<=n-ln; i++){
      if (ln%2 == n%2){ // taro (pl.1)
        dp[i][i+ln-1] = MAX(dp[i+1][i+ln-1]+a[i], dp[i][i+ln-2]+a[i+ln-1]);
      } else { // jiro (pl.2)
        dp[i][i+ln-1] = MIN(dp[i+1][i+ln-1]-a[i], dp[i][i+ln-2]-a[i+ln-1]);
      }
//    cout << "[" << i << "," << i+ln-1 << "]";
//    cout << " -> " << dp[i][i+ln-1];
//    cout << " (" << (ln%2==n%2?"T)":"J)") << endl;
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 70016
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

score = t.count('r') * p + t.count('s') * r + t.count('p') * s

for i in range(k):
    li = []
    idx = i
    while idx < n:
        li.append(t[idx])
        idx += k

    pre = "x"
    cnt = 1
    for c in li:
        if c == pre:
            cnt += 1
        if c != pre and cnt > 1:
            cnt //= 2
            if pre == "r":
                score -= p * cnt
            elif pre == "s":
                score -= r * cnt
            else:
                score -= s * cnt
            cnt = 1
        pre = c
    else:
        if cnt > 1:
            cnt //= 2
            if pre == "r":
                score -= p * cnt
            elif pre == "s":
                score -= r * cnt
            else:
                score -= s * cnt
print(score)
        

Measured memory_bytes: 4212
#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 SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  int N, M, K;
  cin >> N >> M >> K;
  combination C(2*N);
  auto H = [&](int n, int r) {
    return C(n+r-1, r);
  };
  mint ans = 0;
  for(int k = 0; k <= K; ++k) {
    mint add = M;
    add *= H(N-k, k) * modpow(M-1, N-k-1);
    ans += add;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 9508
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#define maxn 200005
using namespace std;
struct nod
{
	int now,dis;
	nod(int x,int y)
	{
		now=x;
		dis=y;
	}
	nod(){}
};
bool operator<(nod a,nod b)
{
	return a.dis>b.dis;
}
int n,ss,t,tot[2];
int pre[maxn];
char s[maxn];
int head[2][maxn],nex[2][maxn*30],to[2][maxn*30],vis[maxn];
void add(int f,int x,int y)
{
	to[f][++tot[f]]=y; nex[f][tot[f]]=head[f][x]; head[f][x]=tot[f];
}
int pre2[maxn][30],id[maxn];
int dis1[maxn],dis2[maxn];
priority_queue<nod> q;
vector<nod>edge[maxn];
void spfa(int start,int f,int *dis)
{
	memset(dis,0x3f,sizeof(int)*maxn);
	memset(vis,0,sizeof(vis));

	dis[start]=0;
	q.push(nod(start,0));
	while(!q.empty())
	{
	//	cerr<<"+1"<<endl;
		int now=q.top().now; q.pop();
		if(vis[now]) continue;
		vis[now]=1;
	//	cout<<now<<" "<<dis[now]<<endl;
		for(int i=head[f][now];i;i=nex[f][i])
		{
			if(dis[to[f][i]]>dis[now]+1)
			{
				dis[to[f][i]]=dis[now]+1;
				q.push(nod(to[f][i],dis[to[f][i]]));
			}
		}
	}
}
int cmp(int i,int j)
{
	return dis1[i]<dis1[j];
}
int can[30];
int vis1[maxn];
int main()
{
	scanf("%s",s+1); n=strlen(s+1);

	int ss=n+1,t=n+2;

	for(int i=0;i<=25;i++)
		pre[i]=ss;

	for(int i=1;i<=n;i++)
	{
		id[i]=i;
		for(int j=0;j<=25;j++)
		if(!vis[pre[j]])
		{
			add(0,pre[j],i);
			add(1,i,pre[j]);
			vis[pre[j]]=1;
			edge[pre[j]].push_back(nod(i,j));
		}

		for(int j=0;j<=25;j++)
			vis[pre[j]]=0,pre2[i][j]=pre[j];

		pre[s[i]-'a']=i;
	}

	for(int i=0;i<=25;i++)
		if(!vis[pre[i]])
			add(0,pre[i],t),add(1,t,pre[i]),vis[pre[i]]=1,edge[pre[i]].push_back(nod(t,i));
	for(int i=0;i<=25;i++)
		vis[pre[i]]=0,pre2[t][i]=pre[i];

	spfa(ss,0,dis1);
	spfa(t,1,dis2);

	int res=dis1[t];

	int now=1;


	sort(id+1,id+1+n,cmp);

	int preans=0;

	vis1[ss]=1;
	for(int i=1;i<=n;i++)
	{
		if(now==res) 
			break;

		int temp=i;

		int p=id[i];
		while(dis1[p]==now)
		{
			for(int j=0;j<=25;j++)
			{
				if(dis1[p]+dis2[p]==res && dis1[p]==dis1[pre2[p][j]]+1 && vis1[pre2[p][j]])
					can[j]=1;
			}
			i++;
			p=id[i];
		}
	

		for(int j=0;j<=25;j++)
		if(can[j])
		{
			printf("%c",'a'+j);
			preans=j;
			break;
		}

		for(int j=temp;j<=i-1;j++)
		{
			p=id[j];
//			cerr<<dis1[p]<<" ";
			if(dis1[p]+dis2[p]==res && dis1[p]==dis1[pre2[p][preans]]+1 && vis1[pre2[p][preans]])
				vis1[p]=1;
		}

		memset(can,0,sizeof(can));
		i--;

		now++;
	}

	for(int i=0;i<=25;i++)
	{
		if(dis1[t]==dis1[pre2[t][i]]+1 && vis1[pre2[t][i]])
			return printf("%c\n",'a'+i),0;
	}
}


Measured memory_bytes: 185344
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      char c;
      cin >> c;
      
      // ここにプログラムを追記
      if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
        cout << "vowel" <<endl;
      }else{
        cout << "consonant" <<endl;
      }
        
    }

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define Ln 20
#define mp make_pair
#define INF (ll)1e9+5
#define dif 0.0000000001
#define pp pair<ll,ll> 
#define sp set<pp>
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define SZ 100005
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

//vi adj[100005];

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

int main() {
    fastio;
    int l;
    string s;
    cin>>s;
    
    l=s.length();
    
    cout<<s[0]<<l-2<<s[l-1];
  
    
    
   
    // your code goes here
	return 0;
}

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

X_max = X[0]
X_min = X[0]

for i in range(N):
    if X_max < X[i]:
        X_max = X[i]
    if X_min > X[i]:
        X_min = X[i]

min = 0
count = 0
for p in range(X_min, X_max+1, 1):
    total = 0
    for i in range(N):
        total += (X[i]-p)**2
    count += 1
    if count == 1:
        min = total
    elif  min > total:
        min = total

print(min)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
   int n,k,s,r,p;
   cin >> n >> k;
   cin >> r >> s >> p;
   string t;
   cin >> t;
   string my="";
   long long sum = 0;
   for(int i=0;i<n;i++){
      if(i < k){ //全ての手を出せる
         switch(t[i]){
            case 'r':
               sum += p;
               my += "p";
               break;
            case 's':
               sum += r;
               my += "r";
               break;
            case 'p':
               sum += s;
               my += "s";
               break;
         }
      }else{   //Ｋ回前の手は出せない 
         switch(t[i]){
            case 'r':
               if(my[i-k] != 'p'){
                  sum += p;
                  my += "p";
               }else{
                  my +="o";
               }
               break;
            case 's':
               if(my[i-k] != 'r'){
                  sum += r;
                  my += "r";
               }else{
                  my +="o";
               }
               break;
            case 'p':
               if(my[i-k] != 's'){
                  sum += s;
                  my += "s";
               }else{
                  my +="o";
               }
               break;
         }
      }
   }

   cout << sum << endl;
   return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n, k;
	cin >> n >> k;

	vector<long long> heights(n);
	for (int i = 0; i < n; i++) {
		cin >> heights[i];
	}

	vector<long long> dp(n, numeric_limits<long long>::max());
	dp[0] = 0;
	for (long long i = 1; i < n; i++) {
		for (long long j = 1; j <= k; j++) {
			if (i - j < 0) continue;
			dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]));
		}
	}

	cout << dp.back() << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint(), C = getint(), K = getint();
	if (C == 1) {
		printf("%d\n", N);
		Would you please return 0;
	}
	int T[100000];
	rep(i, N) T[i] = getint();
	pakuri_sort(N, T);

	int ima = 0;
	int hito = 0;
	int kotae = 0;
	rep(i, N) {
		if (ima < T[i]) {
			ima = T[i] + K;
			hito = 1;
			kotae++;
		}
		else if (++hito >= C) {
			ima = 0;
		}
	}
	printf("%d\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = Int[]
	t = 1
	while t <= sqrt(n)
		if n%t == 0
			push!(a,t)
		end
		t += 1
	end
	k = 0
	l = length(a)
	for i in 1:l
		if div(n,a[i])-1 > a[i]
			k += div(n,a[i])-1
		end
	end
	if n == 2
		println(0)
	else
		println(k)
	end
end
main()


Measured memory_bytes: 164456
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int n,k,q; cin >> n >> k >> q;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int ans = 1 << 30;
  for(int i = 0; i < n; i++){
    vector<int> v;
    for(int j = 0; j < n; j++){
      vector<int> t;
      while(j < n && a[i] <= a[j]){
        t.push_back(a[j]);
        j++;
      }
      sort(t.begin(),t.end());
      for(int l = 0; l < max(0LL,(int)t.size()-k+1); l++){
        v.push_back(t[l]);
      }
    }
    if(v.size() < q) continue;
    sort(v.begin(),v.end());
    ans = min(ans,v[q-1] - v[0]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
n=int(input())
x={}

count=0
for i in range(n):
  s=input()
  if s in x:
    x[s]+=1
  else:
    x[s]=1

a=max(x.values())
keys=[k for k,v in x.items() if v==a]
answer=sorted(keys)
  
for a in answer:
  print(a)



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

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a < b && b < c && a < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
   

    return 0;
}


Measured memory_bytes: 3084
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);
  writeln(a.map!(ai => calc(ai)).reduce!min);
}

auto calc(int n)
{
  auto r = 0;
  for (; n%2 == 0; n /= 2) ++r;
  return r;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))

c = defaultdict(int)
for ai in a:
    c[ai] += 1

ans = 0
for k, v in c.items():
    if v > k:
        ans += v - k
    elif v < k:
        ans += v
print(ans)


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int W, H, N;

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    cin >> N >> W >> H;

    cout << (N-H+1)*(N-W+1) << endl;    
}

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

int main(){

int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)
    cin>>a[i];
int maxt=a[0];
ll ans=0;
for(int i=1;i<n;i++){
    ans+=max(maxt-a[i],0);
    maxt=max(maxt,a[i]);
}
cout<<ans<<endl;

}


Measured memory_bytes: 3992
import java.util.Arrays;
import java.util.Scanner;
   
   
public class Main {
    static int INF = 2 << 27;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
         
        long[][] dp = new long[n+1][t+1];
        for(int i = 0; i < n+1; i++) {
            //Arrays.fill(dp[i], -1);
            dp[i][0] = 0;
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= t; j++) {
                //if(dp[i][j] == -1) continue;
                dp[i+1][j] = Math.max(dp[i][j], dp[i+1][j]);
                int tmp = j + b[i];
                if(tmp > t) continue;
                if(tmp > s && j < s) {
                    dp[i+1][s] = Math.max(dp[i+1][s], dp[i][j]);
                }
                else {
                    dp[i+1][tmp] = Math.max(dp[i+1][tmp], dp[i][j] + a[i]);
                }
            }
        }
        /*
        for(int i = 0; i < n+1; i++) {
            for(int j = 0; j < t+1; j++) {
            	if(dp[i][j] == -1) continue;
                System.out.print(dp[i][j] + " ");
            }
            System.out.println();
        }
        */
        
         
        long ans = 0;
        for(int i = 0; i <= t; i++) {
            ans = Math.max(ans, dp[n][i]);
        }
        System.out.println(ans);
         
         
         
         
         
    }
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a <= c && c <= b) || (a >= c && c >= b)) cout << "Yes\n";
  else cout <<"No\n";
  return 0;
}


Measured memory_bytes: 256
K, S = gets.split.map(&:to_i)
ans = 0
min = (S/3.0).ceil
(min..K).each do |a|
  rest = S - a
  next if rest > K*2

  minb = (rest/2.0).ceil
  maxb = [rest, K, a].min
  (minb..maxb).each do |b|
    c = rest - b
    if a == b
      if b == c
        #p [1,a,b,c]
        ans += 1
      else
        #p [3,a,b,c]
        ans += 3
      end
    elsif b == c
      #p [3,a,b,c]
      ans += 3
    else
      #p [6,a,b,c]
      ans += 6
    end
  end
end
p ans


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

int main()
{
  int n;
  cin >> n;
  int x = 0;
  int y = n;
  while(y > 0){
    x = x + (y % 10);
    y /= 10;
  }
  
  cout << (n % x == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#define N 100000
int S[N];
int T[N];

int binary_search(int [N],int,int,int);
int main(){
  int n,q,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  int count=0;
  for(i=0;i<q;i++){
    if(binary_search(S,T[i],0,n)==1){
      //printf("%d\n",T[i]);
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}


int binary_search(int ary[N], int key, int imin, int imax) {
    if (imax < imin) {
        return 0;
    }
    else {
        int imid = (imin + imax) / 2;
        if (S[imid] > key) {
            return binary_search(S, key, imin, imid-1);
        }
        else if (S[imid] < key) {
            return binary_search(S, key, imid + 1, imax);
        }
        else {
            return 1;
        }
    }
}



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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {

	
	ll n;
	cin >> n;
	vector<ll> a(n), b(n - 1);
	REP(i, n)cin >> a[i];
	REP(i, n - 1) {
		b[i] = a[i + 1] - a[i];
	}

	n--;

	ll ans = 0;

	ll nk = 1;
	FOR(i,1, n+1) {
		nk *= i;
		nk %= mod;
	}

	ll bunsi = 1;
	ll bunbo = 2;
	


	ll bun = 0;
	REP(i, n) {

		ans += b[i] * nk;
		ans %= mod;

		if (i != 0) {
			ll c = bunsi * modinv(bunbo, mod);
			bun += c;
			bun %= mod;
			ll tmp = nk * bun;
			tmp %= mod;
			tmp *= b[i];
			tmp %= mod;
			ans += tmp;
			ans %= mod;
			bunbo++;
		}
	}
	cout << ans << endl;


}



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

int main()
{
  int64_t x;
  cin >> x;
  int64_t ans = 1;
  for (int b = 1; b <= 1000; b++)
  {
    for (int p = 2; p <= 10; p++)
    {
      int64_t i = pow(b, p);
      if (i > x)
        break;
      ans = max(ans, i);
    }
  }
  cout << ans << endl;
}

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

const int mo=998244353,g=3;
int len,n,m,N,fac[10010],ifac[10010],A[1<<15],X[1<<15],W[1<<15],iW[1<<15],ans;
char a[10010],b[10010];

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

void NTT(int *a,int n,int op)
{
	for (int i=0; i<n; i++)
		{
			int t=i,p=0;
			for (int j=1; j<n; j<<=1)  p<<=1,p|=(t&1),t>>=1;
			if (p<i)  swap(a[i],a[p]);
		}
	int *w=op>0?W:iW,u,v;
	for (int len=2; len<=n; len<<=1)
		for (int i=0; i<n; i+=len)
			for (int j=0; j<(len>>1); j++)
				{
					u=a[i+j],v=1LL*a[i+j+(len>>1)]*w[n/len*j]%mo;
					a[i+j]=(u+v)%mo,a[i+j+(len>>1)]=(u-v+mo)%mo;
				}
	if (op==-1)
		{
			int inv=qpow(n,mo-2);
			for (int i=0; i<n; i++)  a[i]=1LL*a[i]*inv%mo;
		}
}

void qpow(int b)
{
	A[0]=1;
	while (b)
		{
			NTT(X,N,1);
			if (b&1)
				{
					NTT(A,N,1);
					for (int i=0; i<N; i++)  A[i]=1LL*A[i]*X[i]%mo;
					NTT(A,N,-1);
					for (int i=n+1; i<N; i++)  A[i]=0;
				}
			for (int i=0; i<N; i++)  X[i]=1LL*X[i]*X[i]%mo;
			NTT(X,N,-1);
			for (int i=n+1; i<N; i++)  X[i]=0;
			b>>=1;
		}
}

void work()
{
	scanf("%s\n%s",a+1,b+1),len=strlen(a+1);
	for (int i=1; i<=len; i++)
		if ((a[i]=='1')&&(b[i]=='1'))  n++;
		else  if ((a[i]=='1')&&(b[i]=='0'))  m++;
	fac[0]=1;
	for (int i=1; i<=n+m+1; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n+m+1]=qpow(fac[n+m+1],mo-2);
	for (int i=n+m+1; i; i--)  ifac[i-1]=1LL*ifac[i]*i%mo;
	for (N=1; N<=2*n; N<<=1);
	for (int i=0; i<=n; i++)  X[i]=ifac[i+1];
	W[0]=iW[0]=1,W[1]=qpow(g,(mo-1)/N);
	for (int i=2; i<N; i++)  W[i]=1LL*W[i-1]*W[1]%mo;
	for (int i=1; i<N; i++)  iW[i]=W[N-i];
	qpow(m);
	for (int i=0; i<=n; i++)  ans=(ans+A[i])%mo;
	ans=1LL*ans*fac[n+m]%mo*fac[m]%mo*fac[n]%mo;
	printf("%d",ans);
}

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


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

int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i ++){
        cin >> S.at(i);
    }
    sort (S.begin(), S.end());
    string ans;
    for (int i = 0; i < N; i ++){
        ans += S.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <stdio.h>

using namespace std;

vector<int> ball(10);

int dfs(int cnt, int l, int r){ 
    ++cnt;
    if(cnt == 10) return 1;
    if(ball[cnt] > r){ 
        if(dfs(cnt,l,ball[cnt])) return 1;
    }   
    else if(ball[cnt] > l){ 
        if(dfs(cnt,ball[cnt],r)) return 1;
    }   
    return 0;
}
int main(int argc, void *argv[]){
    int n;
    int tmp;
    
    scanf("%d", &n);
    while(n--){
        for(int i=0;i<10;i++){
            scanf("%d",&tmp);
            ball[i] = tmp;
        }   
        if(dfs(-1,0,0)) printf("YES\n"); else printf("NO\n");
    }   
}

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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL n, cnt;
vector<LL> factor;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    n--;
    for (LL i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt += (i * i == n) ? 1 : 2;
        }
    }
    cnt--, n++;
    for (LL i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            if ((n - 1) % i == 0 || (n - 1) % (n / i) == 0) continue;
            if (i * i != n) {
                factor.emplace_back(i);
                factor.emplace_back(n / i);
            } else factor.emplace_back(i);
        }
    }
    //cout << cnt << endl;
    // cout << factor.size() << endl;
    for (auto &i : factor) {
        LL tmp = n;
        while (tmp % i == 0) {
            tmp /= i;
        }
        if (tmp % i == 1) cnt++;
    }
    cout << ++cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int t[1000001];
int s[100001];

int bin_pret(int a[], int donja, int gornja, int x)
{
    int sred ;
    if (donja > gornja)
        return 0;

    else
    {
    sred = (donja + gornja) / 2;

    if (x == a[sred]) return sred;
    else
        if (x < a[sred]) return bin_pret(a, donja,sred-1, x);

        else return bin_pret(a,sred+1,gornja, x);
    }
}
int main()
{
    int n, q, br = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    for (int i = 1; i <= q; i++)
    {
        scanf("%d", &t[i]);
    }
    sort(s + 1, s + n + 1);
    sort(t + 1, t + q + 1);
    if (n <= q)
    {
        for (int i = 1; i <= n; i++)
        {
            if (bin_pret(t, 1, q, s[i]) != 0)
            {
                br++;
            }
        }
    }
    else
    {
        for (int i = 1; i <= q; i++)
        {
            if (bin_pret(s, 1, n, t[i]) != 0)
            {
                br++;
            }
        }
    }
    cout << br << '\n';
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <string>

using namespace std;

int func(long long a)
{
	int ret = 0;
	for (int i = 0; i < 22; i++) {
		if ((a >> i & 1) == 1) {
			ret += 1;
		}
	}
	return ret;
}

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

	long long num = 0;
	for (int i = 0; i < n; i++) {
		num += (s[i] - '0');
	}

	long long a[2][200010] = {};
	a[0][n - 1] = a[1][n - 1] = 1;
	long long now[2];
	now[0] = now[1] = (s[n - 1] == '1' ? 1 : 0);

	if (num == 1) {
		for (int i = n - 2; i >= 0; i--) {
			a[1][i] = a[1][i + 1] * 2;
			a[1][i] %= num + 1;

			if (s[i] == '1') {
				now[1] += a[1][i];
				now[1] %= num + 1;
			}
		}
	} else {
		for (int i = n - 2; i >= 0; i--) {
			a[0][i] = a[0][i + 1] * 2;
			a[1][i] = a[1][i + 1] * 2;
			a[0][i] %= num - 1;
			a[1][i] %= num + 1;

			if (s[i] == '1') {
				now[0] += a[0][i];
				now[1] += a[1][i];
				now[0] %= num - 1;
				now[1] %= num + 1;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		int mod;
		long long c;
		if (s[i] == '0') {
			c = now[1] + a[1][i];
			mod = num + 1;
		} else {
			c = now[0] - a[0][i];
			mod = num - 1;
		}
		
		if (mod == 0) {
			cout << 0 << endl;
			continue;
		}
		c %= mod;
		c = (c + mod) % mod;

		int ans = 1;
		while (c != 0) {
			mod = func(c);

			c %= mod;
			ans++;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 6840
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


ll dp[100001][3];


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

    ll n, aa, bb, cc;
    vector<ll> abc[3];
    cin >> n;
    rep(i, n){
        cin >> aa >> bb >> cc;
        abc[0].push_back(aa);
        abc[1].push_back(bb);
        abc[2].push_back(cc);
    }

    rep(i, n){
        rep(j, 3){
            dp[i][j] = 0;
        }
    }

    rep(i, n){
        rep(j, 3){
            dp[i+1][j] = max(dp[i][(j+1)%3] + abc[(j+1)%3][i], dp[i][(j+2)%3] + abc[(j+2)%3][i]);
        }
    }

    ll res = 0;
    rep(i, 3){
        res = max(dp[n][i], res);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5216
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a)

def solution():
    N,X = input_ints()
    Xs = input_ints()

    diffs = [abs(X-int(x)) for x in Xs]
    ans = gcd(diffs)
    print(ans)

if __name__ == '__main__':
    solution()

Measured memory_bytes: 88300
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

const int mod=10007;

int n;
vi a(7);

int main(){
	cin>>n;
	char c;
	cin>>c;
	if(c=='J') a[0]=a[3]=a[5]=1;
	else if(c=='O') a[3]=1;
	else a[5]=1;
	a[6]=1;
	for(int i=1;i<n;i++){
		cin>>c;
		if(c=='J'){
			a[0]=(a[0]+a[3]+a[5]+a[6])%mod;
			a[3]=(a[0]+a[1]+a[4])%mod;
			a[5]=(a[0]+a[2]+a[4])%mod;
			a[6]=(a[5]+a[1])%mod;
			a[1]=a[2]=a[4]=0;
		}
		else if(c=='O'){
			a[1]=(a[1]+a[3]+a[4]+a[6])%mod;
			a[3]=(a[1]+a[0]+a[5])%mod;
			a[4]=(a[1]+a[2]+a[5])%mod;
			a[6]=(a[4]+a[0])%mod;
			a[0]=a[2]=a[5]=0;
		}
		else{
			a[2]=(a[2]+a[4]+a[5]+a[6])%mod;
			a[4]=(a[2]+a[1]+a[3])%mod;
			a[5]=(a[2]+a[0]+a[3])%mod;
			a[6]=(a[5]+a[1])%mod;
			a[0]=a[1]=a[3]=0;
		}
	}
	int sum=0;
	for(int i=0;i<7;i++) sum=(sum+a[i])%mod;
	cout<<sum<<endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <functional>

const int INF = 1 << 30;
using namespace std;
int solve();

int main(void) {
		
	solve();

	return 0;
}

int solve() {

	int N;
	cin >> N;

	vector<int> p(N+1,0);
	vector<int> ng(N+1,0);
	vector<int> ok(N+1,0);
	vector<int> cost(N+1,INF);
	vector<int> visited(N+1,0);
	vector<int> contain(N+1,0);

	for( int i = 0; i < N; i++ )
		cin >> p[i+1];

	//?????????????????????
	for( int i = 1; i < N; i++ ) {

		int pos = i;
		if( p[i] == 0 ) { continue; }
		if( ng[i] != 0 ) { continue; }
		if( ok[i] != 0 ) { continue; }

		visited.clear();
		visited.resize(N+1,0);

		while(true) {

			if( p[pos] == 0 ) {
				for( int j = 1; j < N; j++ ) {
					if( visited[j] ) 
						ok[j] = 1;
				}
				break;
			}

			if( visited[pos] != 0 || ng[pos] != 0 ) {

				for( int j = 1; j < N; j++ ) {
					if( visited[j] ) {
						ng[j] = 1;
						visited[j] = 0;
					}
				}

				break;
			}

			visited[pos] = 1;
			pos += p[pos];

		}

	}

	priority_queue<int,vector<int>,greater<int>> q;
	q.push(1);
	cost[1] = 0;

	while( !q.empty() ) {

		int cnode = q.top();
		contain[cnode] = 0;

		q.pop();

		if( p[cnode] == 0 ) {

			for( int i = 1; i <= 6; i++ ) {

				int j = min(i+cnode,N);
				if( ng[j] ) { continue; }
				
				if( cost[j] == INF || cost[cnode] + 1 < cost[j] ) {
					cost[j] = cost[cnode] + 1;
					if( !contain[j] ) {
						contain[j] = 1;
						q.push(j);
					}
				}

			}

		} else {

			if( ng[cnode] == 0 ) {

				int j = min(cnode+p[cnode],N);

				if( cost[j] == INF || cost[cnode] < cost[j] ) {
					cost[j] = cost[cnode];
					if( !contain[j] ) {
						contain[j] = 1;
						q.push(j);
					}
				}



			}

		}

	}
	
	cout << cost[N] << endl;
	return 0;

}

Measured memory_bytes: 5184
//team04 lyt

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
//#include <io.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

long long a[100005];
map<long long,int> m;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        m.clear();
        long long mx1=0ll,mx0=0ll;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            m[a[i]]++;
            if(m[a[i]]==2&&a[i]>mx0)
            {
                mx0=a[i];
                if(mx1<mx0)
                    swap(mx1,mx0);
                m[a[i]]=0;
            }
        }
        printf("%lld\n",mx1*mx0);
        
        
    }

    return 0;
}

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

#define MAX 1000 + 1
#define ASCII 123

char text[MAX];
char pat[MAX];
int skip[ASCII];

int main() {
	int i, textLen, patLen, pLast, pText, pPat;
	cin >> text;
	cin >> pat;

	textLen = strlen(text);
	patLen = strlen(pat);

	for (i = 0; i < ASCII; i++) skip[i] = patLen;

	for (i = 0; i < patLen - 1; i++) skip[int(pat[i])] = patLen - i - 1;

	pLast = patLen - 1;
	while (pLast < textLen) {
		pText = pLast;
		pPat = patLen - 1;
		while (text[pText] == pat[pPat]) {
			if (pPat == 0) {
				cout << pText << endl;
				break;
			}
			pText--;
			pPat--;
		}
		pLast = pLast + skip[int(text[pLast])];
	}
	
	return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
	while(true){
		string s;
		getline(cin, s);
		if(s.length()==1&&s[0]=='0'){
			break;
		}
		int sum = 0;
		for(int i = 0; i < s.length(); i++){
			sum += (int)(s[i]-48);
		}
		cout << sum << "\n";
	}
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


ll t(ll x, ll y){
    ll k=0;
    while(x>=y){
        k+=x/y;
        x/=y;
    }
    return k;
}


ll ans(ll x){
    if(x%2)return 0;
    ll y=x/2;
    return min(t(y,2)+y,t(y,5));
}



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

    cout<<ans(N)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n,a,b,k = (int(i) for i in input().split())
mod,ans = 998244353,0
fn,fk = [1]*n,[1]*n
for i in range(n-1): fn[i+1] = (fn[i]*(i+2))%mod
def power(n,k):
	if k==1: return n
	elif k%2==0: return power((n**2)%mod,k//2)
	else: return (n*power(n,k-1))%mod
def comb(n,k):
	if n==0 or k==0 or n==k: return 1
	else: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod
fk[-1] = power(fn[-1],mod-2)
for i in range(2,n+1): fk[-i] = (fk[-i+1]*(n+2-i))%mod
for i in range(n+1):
	if (k-a*i)%b==0 and k-a*i>=0 and (k-a*i)//b<=n:
		j = (k-a*i)//b
		ans = (ans+(comb(n,i)*comb(n,j))%mod)%mod
print(ans)

Measured memory_bytes: 26740
#include <iostream>

int main() {
  using namespace std;

  int x, n;
  cin >> x >> n;

  bool flag[102] = { };
  for (int i = 0; i < n; i++) {
    int p;

    cin >> p;
    flag[p] = true;
  }

  int ans = 0;
  for (int i = 0; i < 102; i++) {
    if (flag[i]) {
      continue;
    } else if (abs(x - ans) > abs(x - i)) {
      ans = i;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())

    ans = 0
    for i in range(1, N+1):
        num = list(str(i))
        tmp = 0
        for n in num:
            tmp += int(n)
        # print(i, tmp)
        if A <= tmp and tmp <= B:
            # print(i)
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int i,j,n,l,k;
    string s[110],t;
    cin >> n >> l;
    for(i=0;i<n;i++){
		cin >> s[i];
    }
    
    for(i=0;i<n-1;i++){
    	for(j=i+1;j<n;j++){
    		if(s[i]>s[j]){
	    		t=s[i];
	    		s[i]=s[j];
	    		s[j]=t;
			}
    	}
    }
    for(i=0;i<n;i++)
    	cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b == c:
    print(-1)
    exit()

ans = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a_tmp = b // 2 + c // 2
    b_tmp = a // 2 + c // 2
    c_tmp = a // 2 + b // 2
    a, b, c = a_tmp, b_tmp, c_tmp
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
 
void solve()
{
  int n;
    cin>>n;
  double dp[n+1][n+1];
  double prob[n];
    for(int i=0;i<n;i++)
        cin>>prob[i];
  
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
  {
    dp[i][0]=(1-prob[i-1])*dp[i-1][0];
    dp[0][i]=0;
  }
  
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
       dp[i][j]=prob[i-1]*(dp[i-1][j-1]);
       dp[i][j]+=(1-prob[i-1])*(dp[i-1][j]);
       
    }
  double ans=0;
  for(int i=n/2+1;i<=n;i++)
    ans+=dp[n][i];
    
    //ans=ceil(ans*1000000000.0)/1000000000.0;
    cout<<setprecision(9);
    cout<<ans<<endl;
    
// printf("%.9f\n", ans);
 
 
 
}
 
int32_t main()
{
    
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 74012
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;


lli calc_formula(queue<lli> index, string s){
  lli n = s.size() - 1, sum = 0;
  sum += s[0] - '0';
  for(lli i = 0; i < n; i++){
    if(index.size() != 0 && index.front() == i){
      sum += s[i+1] - '0';
      index.pop();
    }
    else
      sum -= s[i+1] - '0';
  }
  return sum;

}

int main(){
  string s;
  lli n;
  cin >> s;
  n = s.size() - 1;
  for(lli bit = 0; bit < (1<<n); bit++){
    queue<lli> index;
    for(lli i = 0; i < n; i++){
      if(bit & (1 << i))
        index.push(i);
    }

    if(calc_formula(index, s) == 7){
      for(lli i = 0; i < n; i++){
        cout << s[i];
        if(index.size() != 0 && index.front() == i){
          cout << '+';
          index.pop();
        }
        else
          cout << '-';
      }
      cout << s[n] << "=7" << endl;
      break;
    }
  }


}





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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
vector<vector<int> > g;
int ans = 0;
int n,k;
vector<int> a;
int dfs(int id){
    int mx = 1;
    for(int x:g[id]){
        if(x!=0)mx = max(mx,dfs(x)+1);
    }
    if(id==0)return 0;
    if((mx==k&&a[id]!=0)||mx>k){
        //cerr << id << " " << mx << endl;
        ans++;
        mx =0;
    }
    return mx;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    g.resize(n);
    rep(i,n){
        cin >> a[i];
        if(i==0&&a[i]!=1){
            a[i] = 1;
            ans++;
        }
        a[i]--;
        g[a[i]].push_back(i);
    }
    
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10752
a,b,c,x,y=map(int,input().split())

if x>y:
  print(min(2*x*c,2*y*c+(x-y)*a,a*x+b*y))
else:
  print(min(2*y*c,2*x*c+(y-x)*b,a*x+b*y))

Measured memory_bytes: 61636