akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  auto check = [&](ll m) {
    stack<P> cnt;
    ll prv = 0;
    each(x, a) {
      if (x <= prv) {
        ll rot = x;
        while (!cnt.empty() && cnt.top().first > x) {
          cnt.pop();
        }
        while (true) {
          if (rot == 0) return false;
          if (!cnt.empty() && cnt.top().first == rot) {
            if (++cnt.top().second == m) {
              cnt.pop();
              --rot;
            }
            else {
              break;
            }
          }
          else {
            if (m == 1) return false;
            cnt.push(P(rot, 1LL));
            break;
          }
        }
      }
      prv = x;
      // stack<P> tmp = cnt;
      // cout << ":" << endl;
      // while (!tmp.empty()) {
      //   P p = tmp.top(); tmp.pop();
      //   cout << "!" << p.first << " " << p.second << endl;
      // }
      // cout << endl;
    }
    return true;
  };
  // cout << check(2) << endl;
  // return;
  ll lb = 1, ub = n;
  rep(t, 30) {
    ll mid = (lb + ub) / 2;
    if (check(mid)) ub = mid;
    else lb = mid;
  }
  cout << ub << endl;
}


Measured memory_bytes: 1792
L = input()
N = len(L)

MOD = 10 ** 9 + 7

if L[0] == "1":
  e = [2]
  l = [1]
else:
  e = [1]
  l = [0]
  
for i in range(1, N):
  if L[i] == "1":
    de = (e[-1] * 2) % MOD
    dl = (e[-1] * 1 + l[-1] * 3) % MOD
  else:
    de = (e[-1] * 1) % MOD
    dl = (e[-1] * 0 + l[-1] * 3) % MOD
  e.append(de)
  l.append(dl)
#print("e:", e)
#print("l:", l)
print((e[-1] + l[-1]) % MOD)

Measured memory_bytes: 52336
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

// ABC103-A - Task Scheduling Problem
int main()
{
    int N[3];
    cin >> N[0] >> N[1] >> N[2];

    int c01 = abs(N[0]-N[1]);
    int c12 = abs(N[1]-N[2]);
    int c20 = abs(N[2]-N[0]);

    int c012 = c01 + c12;
    int c120 = c12 + c20;
    int c201 = c20 + c01;

    int output = min(c012, min(c120, c201));
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.Pattern;

 class Main {
    
    public static void main(String args[])
    {
     int a,b,i,small,sum=0;String s="";
     Scanner sc=new Scanner(System.in);
     a=sc.nextInt(); b=sc.nextInt();
     if(a<b)
     {
         small=a;
         for(i=b-1;i>=0;i--)
         {
             sum=sum+(int)Math.pow(10, i);
         }
         small=a*sum;
         s=""+small;
     }
     else
     {
         small=b;
         for(i=a-1;i>=0;i--)
         {
             sum=sum+(int)Math.pow(10, i);
         }
         small=b*sum;
         s=""+small;
     }
     System.out.println(s);
     }
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

template<typename T>
void print(T v) {
    cout << v << " ";
}

template<typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    map<ll, ll> m;
    map<ll, ll> cnt;
    for (auto &i : A) {
        cin >> i;
        m[i] = 1;
        cnt[i]++;
    }

    ll ans = 0;
    for (auto &i : m) {
        m[i.first] = nCr(cnt[i.first], 2);
        ans += m[i.first];
    }

    for (int i = 0; i < n; ++i) {
        cout << ans - m[A[i]] + nCr(cnt[A[i]]-1,2) << endl;
    }


}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 18944
A,B,K = map(int, input().split())

num = B-A+1
lis = []

#AからAよりK分大きい数までをLisに入れる
for i in range(A, A+K):
    #もし入れる数がB以下であればlisに追加
    if i <= B:
        lis.append(i)

#BよりK分小さい数からBまでをlisに入れる
for j in range(B-K+1, B+1):
    #もし入れる数がA以上であればlisに追加
    if j >= A:
        lis.append(j)

#集合にして重複をなくす
ans_set = set(lis)

ans_list = list(ans_set)
ans_list.sort()

for n in ans_list:
        print(n)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    vector<int> dp(k+1);
    dp.at(0) = 0;
    for (int i=0; i<k+1; i++) {
        for (int j=0; j<n && a.at(j)<=i; j++) {
            if (dp.at(i-a.at(j)) == 0) dp.at(i) = 1;
        }
    }

    if (dp.at(k) == 1) cout << "First" << '\n';
    else cout << "Second" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

int main(){
    // input
    int S, W;
    cin >> S >> W;

    // calc
    bool ans = (S <= W);

    // out
    printf( ans ? "unsafe" : "safe" );
} 

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
//const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;string ss;
    cin>>a>>ss;
    if(a>=3200)cout<<ss<<endl;
    else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<math.h>
#include<string>
#include<cstring>
#include<iomanip>
#include<iostream>
using namespace std;

int main()
{
	int r;
	cin>>r;
	if(r>=0&&r<=1199)
		cout<<"ABC"<<endl;
	else if(r>=1200&&r<=2799)
		cout<<"ARC"<<endl;
	else if(r>=2800&&r<=4208)
		cout<<"AGC"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  ll sum = 0;
  ll sum1=0;
  for(int i = 0; i < n; i++){
    cin>>a[i];
    sum+=a[i];
    if(i%2!=0)sum1+=a[i];
  }
  ll x[n];
  x[0] = sum-2*sum1;
  for(int i = 1; i < n; i++){
    x[i] = 2*a[i-1]-x[i-1];
  }
  for(int i = 0; i < n; i++){
    cout<<x[i]<<" ";
  }
  cout<<endl;
  return 0;
}




Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a,b,c,k,ans = 0;
  IN4(a,b,c,k);
  if(a >= k){
    a = k;
    k = 0;
  }
  else
  {
    k = k-a;
  }
  if(b >= k){
    b = k;
    k = 0;
  }
  else
  {
    k = k-b;
  }
  if(c >= k){
    c = k;
    k = 0;
  }
  else
  {
    k = k-c;
  }
  ans = a*1 + c*-1;
  OUT(ans);

}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    int x, p;
    cin >> x >> p;
    double ans;
    if(x%2 == 0){
        ans = ((double)(x/2))*((double)(100)/(double)(p));
    }else{
        ans = ((double)((x+1)/2))*((double)(100)/(double)(p));
    }
    cout << fixed;
    cout << setprecision(9) << ans << endl;
}

Measured memory_bytes: 256
// Partition
#include <stdio.h>
#include <stdlib.h>

int Partition(int*, int, int);

int main(){
  int i, n, *A, std;

  // 配列Aの入力
  scanf("%d", &n);

  A = malloc(sizeof(int) * n + 1);
  
  for(i=0; i < n; i++){
    scanf("%d", &A[i]);
  }

  std = Partition(A, 0, n-1); // パーティションを実施

  // 結果を出力
  for(i=0; i < n; i++){
    if(i != 0)printf(" ");
    if(i == std)printf("[%d]", A[i]);
    else printf("%d", A[i]);
  }
  printf("\n");
  
  return 0;
}

int Partition(int *A, int p, int r){
  int i, j, swap;

  // 配列の要素0からiまでは基準A[r]より小さい値、
  // 要素i+1からr-1までは基準A[r]より大きい値を格納していく
  i = p-1;
  for(j=p; j < r; j++){
    if(A[j] <= A[r]){
      i++;
      swap=A[i];  A[i]=A[j];  A[j]=swap; // A[i]とA[j]を交換
    }
  }
  swap=A[i+1];  A[i+1]=A[r];  A[r]=swap; // 最後にA[i+1]A[r]を交換
  return i+1; // パーティションの基準となる要素を返す
}



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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int h,w;
	cin>>h>>w;
	vector<vector<int>> a(h,vector<int>(w,0)),b(h,vector<int>(w,0));

	rep(i,h)rep(j,w)cin>>a[i][j];
	rep(i,h)rep(j,w)cin>>b[i][j];

	int num = 160*80;

	bool dp[82][82][161*81+10] = {};

	// if(a[0][0]-b[0][0]>=0)dp[0][0][a[0][0]-b[0][0]]=true;
	// if(b[0][0]-a[0][0]>=0)dp[0][0][b[0][0]-a[0][0]]=true;
	dp[0][0][abs(a[0][0]-b[0][0])] = true;
	repi(i,1,w){
		repr(k,num+1,0){
			if(dp[0][i-1][k]){
				int res = abs(a[0][i] - b[0][i]);
				dp[0][i][k+res]=true;
				dp[0][i][abs(k-res)]=true;
				// break;
			}
		}
	}
	repi(i,1,h){
		repr(k,num+1,0){
			if(dp[i-1][0][k]){
				int res = abs(a[i][0] - b[i][0]);
				dp[i][0][k+res]=true;
				dp[i][0][abs(k-res)]=true;
				// break;
			}
		}
	}

	repi(i,1,h)repi(j,1,w){
		repr(k,num+1,0){
			if(dp[i-1][j][k]){
				int res = abs(a[i][j] - b[i][j]);
				dp[i][j][k+res]=true;
				dp[i][j][abs(k-res)]=true;
			}
			if(dp[i][j-1][k]){
				int res = abs(a[i][j] - b[i][j]);
				dp[i][j][k+res]=true;
				dp[i][j][abs(k-res)]=true;
			}
		}
	}

	rep(i,num+1){
		// cout<<dp[h-1][w-1][i]<<" ";
		if(dp[h-1][w-1][i]){
			cout<<i<<endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 86016
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

typedef long long Int;
Int len[100010];

bool ok(int s) {
  int v[] = {0, 0, 0, 1, 1, 1};
  Int a[3];
  Int b[3];
  do {
      int A = 0, B = 0;
      REP(i, 6)
          if (v[i])
              a[A++] = len[s + i];
          else
              b[B++] = len[s + i];
      if (a[0] + a[1] > a[2] && b[0] + b[1] > b[2])
          return true;
  } while (next_permutation(v, v + 5));
  return false;
}

int main() {
  int N; scanf("%d", &N);
  REP(i, N) scanf("%lld", &len[i]);
  sort(len, len + N);
  Int ans = 0;
  for (int i = 0; i + 5 < N; i++) {
      if (ok(i)) {
          Int t = 0;
          REP(j, 6) t += len[i + j];
          ans = max(ans, t);
      }
  }

  Int t = 0;
  int c = 0;
  for (int i = N - 1; i - 2 >= 0; i--) {
      if (len[i - 2] + len[i - 1] > len[i]) {
          t += len[i - 2] + len[i - 1] + len[i];
          i = i - 2;
          c++;
          if (c == 2) break;
      }
  }
  if (c == 2) ans = max(ans, t);

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

Measured memory_bytes: 1624
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define REP(i, x, n) for(ull i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	ll a;
	ll b;
	ll c;
	ll k;
	
	cin >> a >> b >> c >> k;
	
	if ((a + b) > 1000000000000000000 ||
		(a - b) < -1000000000000000000) {
		cout << "Unfair" << endl;
	} else {
		if (k % 2 == 0) 
			cout << a - b << endl;
		else
			cout << -(a - b) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int sum =0;
  for(int i=0;i<s.length();i++)
  {
    sum = (sum%9+(s[i]-'0'))%9;
  }
  if(sum%9 == 0) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  string res = "";
  int i = s.size() - 1;
  while (i >= 0) {
    while (i >= 0 && s[i] != 'B') {
      res += s[i--];
    }
    int cnt = 0;
    while (i >= 0 && s[i] == 'B') {
      --i;
      ++cnt;
    }
    i -= cnt;
  }
  for (int i = res.size() - 1; i >= 0; --i) {
    printf("%c", res[i]);
  }
  printf("\n");
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector <string> vec(H);
  
  for (int i=0; i<H; i++){
    cin >> vec.at(i);
  }
  for(int i=0; i<W+2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0; i<H; i++){
    cout << "#" << vec.at(i) << "#" << endl;
  }
  for(int i=0; i<W+2; i++){
    cout << "#";
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    ans = list(s[:])
    k = int(input().strip())
    for i in range(len(s)):
        d = (ord('z') - ord(s[i]) + 1) % 26
        if k - d >= 0:
            ans[i] = 'a'
            k -= d
        if i == len(s) - 1:
            # print((ord(ans[i]) + k%26) % 26)
            ans[i] = chr(ord('a') + (ord(ans[i]) - ord('a') + k%26) % 26)
    print(''.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 49392
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
        cin >> a[i];
    REP(i, n)
        a[i]--;

    vector<int> idx(n);
    REP(i, n)
    idx[a[i]] = i;
    set<int> st;
    int ans = 0;
    for (int x = n - 1; x >= 0; x--)
    {
        int i = idx[x];
        vector<int> l(2, -1), r(2, n);
        ll c = 0;
        {
            //calc c
            st.insert(i);
           
            auto it = st.find(i);
            REP(j,2){
                if(it == st.begin())
                    break;
                --it;
                l[j] = *it;
            } 
        }

        {
                auto it = st.find(i);
            REP(j, 2)
            {
                ++it;
                if (it == st.end())
                    break;
               
                r[j] = *it;
            }
        }    
            vector<int> ls(2);
            ls[0] = i - l[0];
            ls[1] = l[0] - l[1];
            vector<int> rs(2);
            rs[0] = r[0] - i;
            rs[1] = r[1] - r[0];
            c = ls[0] * rs[1] + ls[1] * rs[0];
            //cerr << ls[0] << ls[1] <<i<< rs[0] << rs[1] << endl;
           // show(l);
           // show(r);
            //cerr << "c= " << c << "x= "<<x<<endl;
            //cerr << ans << endl;
            ans += c * (x + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
// D - Lunlun Number

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

ll ans;
int cnt = 0;

ll bfs(int K) {
	ll result;

	if (K <= 9) {
		return K;
	}

	queue<ll> lunlun_que;

	for (int k=1; k<=9; k++) {
		lunlun_que.push(k);
	}

	while(!lunlun_que.empty()) {
		ll n = lunlun_que.front();

		lunlun_que.pop();
		cnt++;
		if (cnt == K) {
			return n;
		}

		int right = n % 10;

		if (right - 1 >= 0) lunlun_que.push(n * 10 + right - 1);
		lunlun_que.push(n * 10 +  right);
		if (right + 1 <= 9) lunlun_que.push(n * 10 + right + 1);
	}

	return -1;
}

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

	ll ans = bfs(K);

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int n, k, d[10];
    string s;
    cin>>n>>k;
    for (int i=0; i<k; i++) cin>>d[i];
    for (int i=n; ; i++)
    {
        s=to_string(i);
        bool ok=true;
        for (int j=0; j<s.size(); j++)
        {
            for (int l=0; l<k; l++) if (s[j]-'0'==d[l]) ok=false;
        }
        if (ok)
        {
            cout<<i<<'\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    k = I()
    n = 8
    a = [-1]*n
    for i in range(k):
        y,x = LI()
        a[y] = x
    for p in permutations(range(n)):
        f = 0
        for i in range(n):
            if a[i] >= 0 and a[i] != p[i]:
                f = 1
                break
            for j in range(i):
                if abs(i-j) == abs(p[i]-p[j]):
                    f = 1
                    break
            if f:
                break
        if f:
            continue
        ans = [["Q" if p[i] == j else "." for j in range(n)] for i in range(n)]
        for i in ans:
            print(*i,sep="")
        return
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6080
class Dice:
    def __init__(self, dice: list):
        self.top = dice[0]
        self.bottom = dice[5]
        self.front = dice[1]
        self.behind = dice[4]
        self.right = dice[2]
        self.left = dice[3]

    def roll(self, direction: str):
        buffer = self.top
        if direction == 'E':
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = buffer
        elif direction == 'N':
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.behind
            self.behind = buffer
        elif direction == 'S':
            self.top = self.behind
            self.behind = self.bottom
            self.bottom = self.front
            self.front = buffer
        else:
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left = buffer

    def turn(self):
        buffer = self.front
        self.front = self.right
        self.right = self.behind
        self.behind = self.left
        self.left = buffer


def main():
    dice = Dice(list(map(int, input().split())))
    for _ in range(int(input())):
        top, front = map(int, input().split())
        while True:
            if dice.right != top and dice.left != top:
                break
            dice.turn()
        while dice.top != top:
            dice.roll('N')
        while dice.front != front:
            dice.turn()
        print(dice.right)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = (n-1); i >= (b); i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
int gcd(int a, int b){return b ? gcd(b, a % b): a;}
void yes(){cout<<"Yes"<<endl;return;}
void no(){cout<<"No"<<endl;return;}

int main()
{
    int x[3];
    int k;
    vll a[3];
    REP(i,0,3) cin >> x[i];
    cin >> k;
    REP(i,0,3) REP(j,0,x[i]) {
        ll ai;
        cin >> ai;
        a[i].push_back(ai);
    }
    REP(i,0,3) sort(a[i].begin(), a[i].end(), greater<ll>());
    vll sum, sum2;
    for(int i = 0; i < min(x[0],k); i++) for(int j = 0; j < min(x[1],k); j++) sum.push_back(a[0][i] + a[1][j]);
    sort(sum.begin(), sum.end(), greater<ll>());
    for(int i = 0; i < min((int)sum.size(), k); i++) for(int j = 0; j < min(x[2],k); j++) sum2.push_back(sum[i] + a[2][j]);
    sort(sum2.begin(), sum2.end(), greater<ll>());
    for(int i = 0; i < k; i++) cout << sum2[i] << endl;
    return 0;
}


Measured memory_bytes: 43384
import numpy as np
from numba import njit
 

@njit
def f(A):
    n = len(a)
    cnt = 0
    
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                cnt += (A[k] < A[i] + A[j])
    return cnt


n = int(input())
a = np.array(input().split(), dtype=np.int32)
a.sort()
print(f(a))


Measured memory_bytes: 110492
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

#define bigprime  1000000007
using ll = long long;
using namespace std;

void solve(vector<vector<char>> &v,int h,int w)
{
    vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
    dp[0][1] = 1;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            ll x = 0,y=0;
            if(v[i-1][j] == '.')
                x = dp[i-1][j];
            if(v[i][j-1] == '.')
                y = dp[i][j-1];
            dp[i][j] = (x % bigprime + y % bigprime) % bigprime;
        }
    }
    // for(int i=1;i<=h;++i)
    // {
    //     for(int j=1;j<=w;++j)
    //         cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    cout<<dp[h][w];
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h{},w{};
    cin>>h>>w;
    vector<vector<char>> v(h+1,vector<char>(w+1,'.'));
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
            cin>>v[i][j];
    }
    solve(v,h,w);
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string s, t;
	cin >> s >> t;

	bool f = false;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	
	if (s.size() < t.size()) {
		bool b = true;
		//cout << s << endl;
		//cout << t << endl;

		for (int i = 0; i < s.size(); i++) {
			//cout << s.at(i) << endl;
			//cout << count(t.begin(), t.end(), s.at(i)) << endl;
			
			if (count(t.begin(), t.end(), s.at(i)) == 0) {
				//cout << s.at(i) << endl;
				b = false;
				break;
			}
		}

		if (b) f = true;
	}
	//cout << f << endl;

	reverse(t.begin(), t.end());
	if (s < t) f = true;

	cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

typedef long long ll;

const ll INF = 1e9+7;

using namespace std;

int main(){
  int N;cin>>N;
  vector<pair<int,pair<int,int> > > txy(N);
  pair<int,pair<int,int> >  now = mp(0,mp(0,0));
  
  bool canTravel = true;
  
  rep(i,N){
    cin>>txy[i].fi>>txy[i].se.fi>>txy[i].se.se;
    int kyori = abs(now.se.fi - txy[i].se.fi + now.se.se - txy[i].se.se);
    int time = txy[i].fi - now.fi;
    if(kyori > time || (kyori % 2 != time % 2)){
        canTravel = false;
         break;
    }
    
    now.fi = txy[i].fi;
    now.se.fi = txy[i].se.fi;
    now.se.se = txy[i].se.se;
    
  }
  
  if(canTravel)print("Yes")else print("No")
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll> l(2*n);
    ll i,j;
    for(i=0;i<2*n;i++)cin>>l.at(i);
    sort(l.begin(),l.end());
    ll sum=0;
    for(i=0;i<n;i++)
        sum+=l.at(2*i);
    
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n, k;
    cin >> n >> k;
    vector<ll> h;
    REP(i, n) {
        ll input;
        cin >> input;
        h.push_back(input);
    }

    SORT(h);
    vector<ll> diff;
    REP(i, n-1) {
        diff.push_back(h[i+1] - h[i]);
    }

    ll min_diff = INF;
    REP(i, diff.size()-(k-2)) {
        ll sum = 0;
        REP(j, k-1) {
            sum += diff[i+j];
        }
        min_diff = min(min_diff, sum);
    }
    P(min_diff);

    return 0;
}


Measured memory_bytes: 2548
a,b =input().split()
A = int(a)
B = int(b)
N = []
for i in range(1300):
  if int(i * (8/100)) == A and int(i*(10/100)) == B:
    N.append(i)
if len(N)==0:
    print(-1)
else:
    print(min(N))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e10
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;

int k, s, dp[3][7501];

int solve(int i, int sum){
	if(i == 3){
		if(sum == s)return 1;
		return 0;
	}
	if(dp[i][sum] != -1) return dp[i][sum];
	int ret =0;
	for(int j=0;j<=k;j++){
		ret += solve(i+1, j+sum);
	}
	return dp[i][sum] = ret;
}

 main() {
	cin >> k >> s;
	memset(dp,-1,sizeof dp);
	cout << solve(0,0);
}

Measured memory_bytes: 384
## グリッドに関する処理
# ABC075B_Minesweeper

## 考え方：
# A NG:pandasに入れて、df.ilocによる行×列のスライスでうまくやる -> pandasはimport不可
# B:np.arrayに入れて、うまいことやる  # PyPy3ではnumpyもimport不可。python3は、numpyはimport可。

## for test
# # 1
# height, width = 3, 5
# _s_list = ['.....', '.#.#.', '.....']

# # 2
# height, width = 3, 5
# _s_list = ['#####', '#####', '#####']

# 3
# height, width = 6, 6
# _s_list = ['#####.', '#.#.##', '####.#', '.#..#.', '#.##..', '#.#...']


## for submit
import numpy as np
height, width = map(int, input().split())
_s_list = [input() for i in range(height)]
s_list = [list(ss) for ss in _s_list]  # 列×行に1文字ずつ区切ってリストへ追加 -> 2次元配列化
s_arr  = np.array(s_list)
# print(s_list)  # debug
# print(s_arr)  # debug

ans_list = []
for _h in range(height):
    for _w in range(width):
        # 周囲1マスずつを取得
        if _h <= 1:
            h_s = 0
        else:
            h_s = _h-1
        # h_e = _h + 2  # 一応、範囲外アクセスしないように修正
        if _h == height-1:
            h_e = _h+1
        else:
            h_e = _h+2
        
        if _w <= 1:
            w_s = 0
        else:
            w_s = _w - 1
        # w_e = _w + 2  # 一応、範囲外アクセスしないように修正
        if _w == width-1:
            w_e = _w+1
        else:
            w_e = _w+2

        # print(s_arr[h_s:h_e, w_s:w_e])  # debug
        # # np.count_nonzero()を使うとTrueの数、すなわち、条件を満たす要素の個数が得られる。
        # print(np.count_nonzero(s_arr[h_s:h_e, w_s:w_e] == '#'))

#         # 周囲1マスずつから、#の数を数えるための前処理
#         df_bool = (df.iloc[h_s:h_e, w_s:w_e] == '#')
#         # PythonでTrueは1、Falseは0とみなされるため、bool値のオブジェクトに対してsum()メソッドを呼べば条件を満たす要素の数が得られる。
#         # print(str(sum(df_bool.sum())))
        
        # チェック対象の中心が#なら#, それ以外はcount_nonzeroした結果の数値を文字列として保存
        if s_arr[_h, _w] == '#':
            ans_list.append('#')
        else:
            ans_list.append(str(np.count_nonzero(s_arr[h_s:h_e, w_s:w_e] == '#')))
        
# 結果を出力 width行を1区切りとして1行ずつ出力
ans_str = ''
for i in range(len(ans_list)):
    ans_str += ans_list[i]
    if (i+1) % width == 0:
        print(ans_str)
        ans_str = ''


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

ll op(ll a, ll b){
    return max(a, b);
}

ll e(){
    return -INF;
}

ll target;
bool f(ll x){
    return x < target;
}

int main(){

    ll N, Q;
    cin >> N >> Q;
    V<ll> a(N);
    REP(i, N) cin >> a[i];
    segtree<ll, op, e> seg(N);
    REP(i, N) seg.set(i, a[i]);

    while(Q--){
        ll t;
        cin >> t;
        if(t==1){
            ll X, V;
            cin >> X >> V;
            X--;
            seg.set(X, V);
        }else if(t==2){
            ll L, R;
            cin >> L >> R;
            L--, R--;
            cout << seg.prod(L, R+1) << "\n";
        }else{ 
            ll X, V;
            cin >> X >> V;
            X--;
            target = V;
            auto pos = seg.max_right<f>(X);
            cout << pos+1 << "\n";
        }
    }

    return 0;
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }
ll n;
vint a;
vvint edges;

vint ans;

void f(ll now, ll par, vint &L){

    auto it = lower_bound(ALL(L), a[now]);
    ll tmp = *it;
    *it = a[now];
    auto it2 = lower_bound(ALL(L), LLONG_MAX-1);
    ans[now] = it2 - L.begin();

    for(auto to : edges[now]){
        if(to == par) continue;
        f(to, now, L);
    }
    *it = tmp;
}



int main() {
    cout<<fixed<<setprecision(10);

    cin>>n;
    a.resize(n);
    ans.resize(n,-1);
    rep(i,n) cin>>a[i];

    edges.resize(n);
    rep(i,n-1){
        ll u,v; cin>>u>>v;
        u--; v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }


    vint L(n, LLONG_MAX);
    f(0, -1, L);

    for(auto e:ans)cout<<e<<endl;

    return 0;

}

Measured memory_bytes: 33104
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a;
    b=0;
    int d3,d5,d7;
    if(a>777777777)a=777777777;
    for(int i=355;i<=a;i+=2){
        c=i;
        d3=d5=d7=0;
        while(c>0){
            if(c%10!=3 && c%10!=5 && c%10!=7)break;
            if(c%10==3) d3=1;
            if(c%10==5) d5=1;
            if(c%10==7) d7=1;
            c/=10;
            if(c==0 && d3==1 && d5==1 && d7==1) {
              b++;
            }
        }
    }
    cout << b << endl;

}

Measured memory_bytes: 256
S=input()
N=len(S)
s=''.join(list(reversed(S)))

T=S[0:int((N-1)/2)]
NT=len(T)
t=''.join(list(reversed(T)))

U=S[int((N+1)/2):N]
NU=len(U)
u=''.join(list(reversed(U)))

if S[0:int((N-1)/2)] == s[0:int((N-1)/2)] and T == t and U == u:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class AAtCoderCrackers {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n, k;
      in >> n >> k;

      if (n % k == 0) {
        out << 0 << endl;
      } else {
        out << 1 << endl;
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AAtCoderCrackers solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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




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

    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n) cin >> a[i+1];
    vector<ll> ans(n+1); 
    ll sum = 0;
    
    for(ll i = n;i >= 1;--i){
        if(a[i] == 1) {
            ll an = 1;
            for(ll j = i+i;j <= n;j+=i){
                if(ans[j] == 1) an++;
            }
            if(an%2 == 1) {
                ans[i] = 1;
                sum++;
            }
        }else {
            ll an = 0;
            for(ll j = i+i;j <= n;j+=i){
                if(ans[j] == 1) an++;
            }
            if(an%2 == 1) {
                ans[i] = 1;
                sum++;
            } 
        }
    }

    cout << sum << endl;
    rep(i,n+1){
        if(ans[i] == 1) {
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}


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

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

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

    int N;
    cin >> N;
    vector<long long> x(N), y(N), h(N);
    int t;
    REP(i, N){
        cin >> x[i] >> y[i] >> h[i];

        /*
        ピラミッドの高さHは1以上の整数
        座標(X, Y)の高度は場合によって0になりうるが，
        最低一つのデータセットでH > abs(X - Cx) + abs(Y - Cy)を満たす
        h[i] > 0となるものならどれでもいいので出現位置を記録しておく
        */
        if(h[i] > 0){
            t = i;
        }
    }

    // CxとCyは0以上100以下
    REP(cx, 101){
        REP(cy, 101){
            /*
            h[t]は0より大きいので，
            h[t] = H - abs(X - Cx) - abs(Y - Cy)
            となる
            */
            long long H = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
            bool f = true;

            //すべてのデータセットに対し条件式が矛盾しないか確認
            REP(i, N){
                long long tmp;
                tmp = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
                if(h[i] != tmp){
                    f = false;
                    break;
                }
            }
            if(f){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
local function same(a, b)
    return math.abs(a-b) < 10^-9
end
local W, H, x, y = io.read("n", "n", "n", "n")
local cw, ch = W/2, H/2
local space = W*H/2
local mult = 0
if same(x, cw) and same(y, ch) then
    mult = 1
end
print(space, mult)

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll X=ii();
    ll K=ii();
    ll D=ii();

    if(X<0){
        X*=-1;
    }
    if(K<abs(X/D)){
        oie(X-D*K);
        return 0;
    }
    K-=(X/D);
    X-=D*(X/D);
    if(K%2==0){
        oie(X);
        return 0;
    }
    oie(-(X-D));
    return 0;
}


Measured memory_bytes: 3628
S = input()
T = input()
d0, d1 = {}, {}
for s, t in zip(S, T):
    if s in d0:
        if d0[s] != t:
            print('No')
            exit()
    elif t in d1:
        if d1[t] != s:
            print('No')
            exit()
    else:
        d0[s] = t; d1[t] = s
print('Yes')

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    string s, t;
    cin >>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    
    if(s<t) Yes;
    else No;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int main() {
	int x;
	cin>>x;
	if(x >= 30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3632