akhauriyash/Code-Regression huggingface dataset:
N=input()
L=[ 0 for _ in range(N+1) ]
for x in range(1,int(N**0.5)+1):
    for y in range(1,int(N**0.5)+1):
        for z in range(1,int(N**0.5)+1):
            a=x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=a<=N:
                L[a]+=1
for i in range(1,N+1):
    print L[i]

Measured memory_bytes: 94308
n = int(input())
n_step = 1
nm2_step = 1
for i in range(1,n+1):
    n_step *= i
for i in range(1,n-1):
    nm2_step *= i
point = []
dist_array = []
for i in range(n):
    point.append(list(map(int,input().split())))
for i in range(0,n-1):
    for j in range(i+1,n):
        dist = ((point[i][0] - point[j][0])**2 +
                (point[i][1] - point[j][1])**2) ** 0.5
        dist_array.append(dist)
print(sum(dist_array) * 2 * (n-1) * nm2_step / n_step)


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)
typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int dist[2 * pow10(5)];
int nextOf[2 * pow10(5)];

void solve()
{
    int N;
    LL K;
    cin >> N >> K;

    REP0 (i, N)
    {
        dist[i] = INTINF;
        cin >> nextOf[i];
        nextOf[i]--;
    }

    if (nextOf[0] == 0)
    {
        std::cout << 1 << endl;
        return;
    }

    int cur = 0;
    dist[0] = 0;
    LL cost_till_loop = 0, l_size = 0, loop_start = 0, nxt = 0;

    int count = 0;

    while (true)
    {
        nxt = nextOf[cur];
        // std::cout << "->" << nxt << endl;
        count++;
        if (K == count)
        {
            std::cout << nxt + 1 << endl;
            return;
        }
        if (nxt == cur)
        {
            std::cout << nxt + 1 << endl;
            return;
        }
        if (dist[nxt] < dist[cur] + 1)
        {
            loop_start = nxt;
            cost_till_loop = dist[nxt];
            l_size = dist[cur] - dist[nxt] + 1;
            break;
        }
        else
        {
            dist[nxt] = dist[cur] + 1;
            cur = nxt;
        }
    }

    K -= cost_till_loop;
    LL inner = K % l_size;
    // if (inner == 0)
    // {
    //     std::cout << loop_start + 1 << endl;
    //     return;
    // }

    cur = loop_start;
    int cnt = 0;
    while (true)
    {
        cur = nextOf[cur];
        cnt++;
        if (cnt % l_size == inner)
        {
            std::cout << cur + 1 << endl;
            return;
        }
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,a[100007],dp[1000007];
int32_t main()
{
 cin>>n>>k;
 for(int i=0;i<n;i++)
   cin>>a[i],dp[i]=INT_MAX;
 dp[0]=0;
 dp[1]=abs(a[1]-a[0]);
 for(int i=2;i<n;i++){
  for(int j=i-1;j>=0&&i-j<=k;j--)
    dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
 }
 cout<<dp[n-1]<<endl;
 return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
#define RI register int
inline double clac(double a, double b) {
	double re = 0;
	while (a < b) ++re, a *= 2;
	return re;
}
int main() {
	int n, k; scanf("%d %d", &n, &k);
	double d = n, ans = 0;
	for (double i = 1; i <= n; ++i)
		ans += 1 / d * pow(0.5, clac(i, k));
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
include Math
require 'prime'

n = gets.to_i
root_prime = Prime.each(10000).to_a
c = 0

n.times {
  catch(:next) do
    x = gets.to_i
    if (x <= 10000)
      c += 1 if (x == root_prime.bsearch{|i| x <= i})
      throw :next
    end
    xs = sqrt(x).floor
    root_prime.each{ |rp|
      break if (rp > xs)
      throw :next if (x % rp == 0)
    }
    c += 1
  end
}
puts c

Measured memory_bytes: 9032
/*
Created on Thu Aug 27 21:32:39 2020

@author: roastedcoder

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
const int mod = 1e9+7;
const int INF = INT_MAX;
#define endl "\n"
#define append push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________


int main() {
	roastedcoder
	string a, b; cin>>a>>b;
	int n = a.length(), m = b.length();
	int res = INT_MAX;
	for(int i = 0; i<n-m+1; i++) {
		int tmp = 0;
		for(int j = i; j<i+m; j++) {
			if(a[j] != b[j-i]) tmp += 1;
		}
		res = min(res, tmp);
	}
	cout<<res<<endl;
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;

signed main(void){
    
    long long S;
    cin >> S;
    
    //dp[i]:=i桁の数列で条件を満たすものの数
    vector<long long> dp(S+1,0);
    
    for(long long i=3;i<=S;i++){
        //dp[i]=sum(dp[0],..,dp[i-3])+1
        for(long long j=0;j<=i-3;j++){
            dp[i]=(dp[i]+dp[j])%MOD;
        }
        dp[i] = (dp[i]+1)%MOD;
    }
    
    cout << dp[S] << endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];
	vi v; rep(i, n) v.pb(x[i]), v.pb(y[i]);
	sort(all(v));
	ll ans = 1e18;
	
	{
		ll l = -1e18, r = 1e18;
		rep(i, n){
			ll a = min(x[i], y[i]);
			ll b = max(x[i], y[i]);
			l = max(l, a);
			r = min(r, b);
		}
		ans = min(ans, (l - v[0]) * (v.back() - r));
	}
	//dbg(ans);
	{
		ll mx= -1e18;
		priority_queue<pi, vector<pi>, greater<pi>> q;
		rep(i, n){
			ll a = min(x[i], y[i]), b = max(x[i], y[i]);
			q.emplace(a, b);
			mx = max(mx, a);
		}
		while(1){
			pi p = q.top(); q.pop();
			ans = min(ans, (mx - p.first) * (v.back() - v[0]));
			if(p.second <= p.first) break;
			mx = max(mx, (ll)p.second);
			q.emplace(p.second, p.first);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node* NIL;

int m;
Node* root;

void init() {
  NIL = new Node;
  NIL->parent = NIL;
  NIL->left = NIL;
  NIL->right = NIL;
  root = NIL;
}

void insert(int k) {
  Node* z = new Node {k, NIL, NIL, NIL};
  Node* y = NIL;
  Node* x = root;
  while (x != NIL) {
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if (y == NIL) root = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void preParse(Node* u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preParse(u->left);
  preParse(u->right);
}

void inParse(Node* u) {
  if (u == NIL) return;
  inParse(u->left);
  cout << " " << u->key;
  inParse(u->right);
}

bool find(int k) {
  Node* c = root;
  while (c != NIL) {
    if (c->key == k) return true;
    else if (k < c->key) c = c->left;
    else c = c->right;
  }
  return false;
}

int main() {
  cin >> m;
  rep(i, m) {
    string com;
    cin >> com;
    int key;
    if (com == "insert") {
      cin >> key;
      insert(key);
    } else if (com == "print") {
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    } else if (com == "find") {
      cin >> key;
      if (find(key)) cout << "yes" << endl;
      else cout << "no" << endl;
    } else {
      cout << "error" << endl;
    }
  }
}



Measured memory_bytes: 21812
#include <bits/stdc++.h>
using namespace std;
 
#define FORI(n) for(int i=0;i<n;i++)
 
int main()
{
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  FORI(s.size())
  {
    if(i!=k-1) cout<<s[i];
    else putchar(tolower(s[i]));
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_2_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] n = ReadIntAr();
            List<Queue<int>> li = new List<Queue<int>>();
            for (int i = 0 ; i < n[0] ; i++) li.Add(new Queue<int>());

            for (int i = 0 ; i < n[1] ; i++)
            {
                int[] line = ReadIntAr();
                switch (line[0])
                {
                    case 0: li[line[1]].Enqueue(line[2]); break;
                    case 1: if (li[line[1]].Count > 0) Console.WriteLine(li[line[1]].Peek().ToString()); break;
                    case 2: if (li[line[1]].Count > 0) li[line[1]].Dequeue(); break;
                }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 25880
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    //val sqrtN = math.sqrt(datN).toInt
    val datA = for(i <- 1 to datN) yield {
      (datN - 1) / i
    }
    val ans = datA.sum
    println(ans)
  }
}


Measured memory_bytes: 61964
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n;
    cout << "ABC" << n << endl; return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
char a[1000][2];
char b[100000];
int c, d;
int main() {
while(1){
    cin >> c;
if(c==0)return 0;
    for (int i = 0; i < c; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    cin >> d;
    for (int i = 0; i < d; i++) {
        cin >> b[i];
    }
    for(int i=0;i<d;i++){
        for (int j = 0; j < c; j++) {
            if (b[i] == a[j][0]) {
                //cout << "max" << endl;
                b[i] =a[j][1];
                break;
            }
        }
    }
    for (int i = 0; i < d; i++) {
        cout << b[i];
    }
    cout << endl;
}
}

Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int K;
  cin >> K;
  if(K % 2)
    cout << (K / 2) * (K / 2 + 1) << endl;
  else
    cout << (K / 2) * (K / 2) << endl;
}

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

using namespace std;

const int N = 1e5 + 5, MOD = 1e9 + 7;
int n, dp1[N], dp2[N];
vector<int> g[N];

// dp1[i] -> i is red
// dp2[i] -> i is black

inline void add(int &a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
}

inline void sub(int &a, int b){
	a-= b;
	if(a < 0)a += MOD;
}

inline int mul(int a, int b){
	return (int)((long long) a * b %MOD);
}

void dfs(int v, int prnt){
	dp1[v] = dp2[v] = 1;
	for(int u : g[v])if(u != prnt){
		dfs(u, v);
		dp1[v] = mul(dp1[v], (dp1[u] + dp2[u])%MOD);
		dp2[v] = mul(dp2[v], dp1[u]);
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin>>n;
	for(int i=0;i<n-1;++i){
		int u, v; cin>>u>>v;
		g[u].push_back(v); g[v].push_back(u);
	}

	dfs(1, 0);
	int ans = dp1[1] + dp2[1];
	ans %= MOD;

	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[605];
vector<double> cnt;
vector<double> pr;

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

  int n, m; cin >> n >> m;
  cnt.resize(n);
  pr.resize(n);
  rep(i, m) {
    int s, t; cin >> s >> t;
    s--; t--;
    graph[s].push_back(t);
  }

  for(int i=n-2; i>=0; i--) {
    double sum = 0;
    int c = graph[i].size();
    for(auto& e: graph[i]) {
      sum += cnt[e];
    }
    cnt[i] = sum/c + 1;
  }

  double ans = cnt[0];

  vector<P> vec;
  rep(i, n) {
    debug(i, cnt[i]);
    double mi = -1;
    int p = -1;
    for(auto& e: graph[i]) {
      debug(i, e, cnt[e]);
      if (cnt[e] > mi) {
        mi = cnt[e];
        p = e;
      }
    }
    debug(i, p);
    if (graph[i].size() > 1) {
      vec.emplace_back(i, p);
    }
  }

  for(auto& pair: vec) {
    int p = pair.first;
    int q = pair.second;
    rep(i, n) {
      cnt[i] = 0;
    }
    for(int i=n-2; i>=0; i--) {
      double sum = 0;
      int c = graph[i].size();
      for(auto& e: graph[i]) {
        if (i==p && e==q) continue;
        sum += cnt[e];
      }
      if (i==p) c--;
      assert(c>0);
      cnt[i] = sum/c + 1;
    }
    debug(p, q, cnt[0]);
    chmin(ans, cnt[0]);
  }

  cout << setprecision(10) << fixed << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

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

    int n;
    ll cur = 0;
    cin >> n;
    vi c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++)
        cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i <= n - 1; i++)
    {
        int st = i;
        cur = 0;
        while (st < n - 1)
        {
            if (cur >= s[st] && cur % f[st] == 0)
                cur += c[st];
            else if (cur >= s[st])
            {
                while (cur % f[st])
                    cur++;
                cur += c[st];
            }
            else
                cur = s[st] + c[st];

            st++;
        }

        cout << cur << endl;
    }

    //cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, r = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    s, t, d = map(int, input().split())
    edge[s].append((t, d))

inf = 10 ** 18
dist = [inf] * N
dist[r] = 0
que = [(0, r)]
while que:
    c, s = heapq.heappop(que)
    if dist[s] < c:
        continue
    d = dist[s]
    for t, cost in edge[s]:
        if dist[t] > d + cost:
            dist[t] = d + cost
            heapq.heappush(que, (d + cost, t))

for i in range(N):
    if dist[i] >= inf:
        print("INF")
    else:
        print(dist[i])


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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for(int i = A; i <= B; i++) {
        int C = i;
        int a = C % 10;
        C /= 10;
        int b = C % 10;
        C /= 100;
        int c = C % 10;
        C /= 10;
        int d = C % 10;
        // cout << a <<" "<<b<<" "<<c<<" "<<d<<endl;
        if(a == d && b == c) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
    string S;
    cin>>S;
    int N=S.size();
    int count_1_o=0,count_0_o=0,count_1_e=0,count_0_e=0;
    for(int i=0;i<N;i+=2){
        if(S.at(i)=='1') count_1_o++;//奇数番の1の個数
        if(S.at(i)=='0') count_0_o++;//奇数番の0の個数
    }
    for(int i=1;i<N;i+=2){
        if(S.at(i)=='1') count_1_e++;//偶数番の1の個数
        if(S.at(i)=='0') count_0_e++;//偶数番の0の個数
    }
    int ans=N-max(count_1_o+count_0_e,count_0_o+count_1_e);
    cout<<ans<<endl;
}


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

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

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

int main(){
    string s; cin >> s;
    int ans=0;
    int i=0;
    int j=s.size()-1;
    while(true){
        if(i>=j) break;
        if(s[i]==s[j]){
            i++; j--;
        }else{
            if(s[i]=='x'&&s[j]!='x'){
                i++;
                ans++;
            }else if(s[i]!='x'&&s[j]=='x'){
                j--;
                ans++;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int diff=0;
  REP(i,N){
    int p;
    cin>>p;
    if(p-1!=i)diff++;
  }
  cout<<(diff<=2?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)
    val result = mutableListOf<Char>()

    while(true){
	    val m = cin.nextInt()
	    val f = cin.nextInt()
	    val r = cin.nextInt()
    
	    if(m + f + r == -3) break

	    result.add(evaluate(m,f,r))
    }

    for(i in result.indices) println(result[i])
}

fun evaluate(m:Int, f:Int, r:Int):Char{

    var grade:Char
    val mf = m + f
 
    grade = when{
	    mf < 30 -> 'F'
	    mf < 50 -> 'D'
	    mf < 65 -> 'C'
	    mf < 80 -> 'B'
	    else -> 'A'
    }

    if(grade == 'D' && r >=50) grade = 'C'
    if(m == -1 || f == -1) grade = 'F'

    return grade
}
	




Measured memory_bytes: 24872
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S;
	cin >> S;

	if (S[0] == S[1] && S[0] == S[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
from sys import stdin

n = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
s = str(data[0])
count_red, count_blue = 0,0
for i in range(len(s)):
    if s[i] == "R":
        count_red += 1
    else:
        count_blue += 1

if count_red > count_blue:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import math
A,B = map(int,input().split())
r_a = []
r_a_l = math.ceil((A * 100) / 8)
r_a_r = ((A + 1) * 100) // 8
r_b_l = math.ceil((B * 100) // 10)
r_b_r = ((B + 1) * 100) // 10

ans = -1
for i in range(r_a_l,r_a_r,1):
    for j in range(r_b_l,r_b_r,1):
        if i == j and ans == -1:
            ans = i
        else:
            pass
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] == '+') {
            ans++;
        }
        else {
            ans--;
        }
    }
    out(ans);
    re0;
}

Measured memory_bytes: 256
def bite_eating(n, l)
  first = l
  last = l + n - 1
  taste = (first + last) * n / 2

  if 0 < first
    taste -= first
  elsif last < 0
    taste -= last
  end

  taste
end

n, l = gets.split.map(&:to_i)
puts bite_eating(n, l)

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int cnt = 0;
vector<int> g;

void insertionSort(vector<int> &a, int g)
{
	for (int i = g; i < a.size(); i++)
	{
		int v = a[i];
		int j = i - g;
		for (; j >= 0 && a[j] > v;)
		{
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = v;
	}
}

void shellSort(vector<int> &a)
{
	for (int i = 1; i <= a.size(); i = 3 * i + 1)
	{
		g.push_back(i);
	}

	for (int i = g.size() - 1; i >= 0; i--)
	{
		insertionSort(a, g.at(i));
	}
}

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a.at(i));
	}

	shellSort(a);

	cout << g.size() << endl;
	for (int i = g.size() - 1; i >= 0; i--)
	{
		cout << g.at(i) << (i == 0 ? "" : " ");
	}

	cout << endl;
	cout << cnt << endl;

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


Measured memory_bytes: 6800
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

string solve(vector<int> &v,int n,int k)
{
    // initailly pile mei k stone hai...
    // hum hr eik stage ko define karenge,....
    // agar hum kisi particualr stage se aisi stage pr ja sakte hain..jahan se stones ko remove krna possible 
    // nhi hai tu in that case vo eik winning position hai...
    bool dp[k+1];
    // dp[i] will define whether it is possible for taru to win the game or not...
    for(int i=0;i<=k;i++)
    {
        if(i<v[0])
           dp[i]=false;
        int flag=0;
        for(int j=0;j<n;j++)
        {
            if(i-v[j]>=0)
            {
            if(dp[i-v[j]]==false)
            {
                flag=1;
                break;
            }
            }
            else // elements given are in the sorted form....
            {
                break;
            }
        }
        if(flag)
        {
            // it is possible to reach a particular stage from where we cant remove a stone...
            // so this is a winning stage...
            dp[i]=true;
        }
        else
        {
            dp[i]=false;
        }
    }
    return dp[k]==true?"First":"Second";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(v,n,k);
    return 0;
}







Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int mypow(int a,int b){
	if(b==0) return 1;
	if(b%2) return mypow(a,b-1)*a%mod;
	int z=mypow(a,b/2);
	return z*z%mod;
}
signed main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	cout<<4+(a-1)/min({b,c,d,e,f})+1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define loop(num)	for(int a = 0; a < num; a++)

int main(){
	int num;
	do{
		long long A = 0, B = 0;
		int a_card, b_card;
		scanf("%d", &num);
		loop(num){
			scanf("%d%d", &a_card, &b_card);
			if (a_card < b_card) B += (a_card + b_card);
			if (b_card < a_card) A += (a_card + b_card);
			if (a_card == b_card){
				A += a_card;
				B += b_card;
			}
		}
		if (num != 0)
		printf("%lld %lld\n", A, B);
	} while (num != 0);
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> a(3);
    for(auto& x : a)
        cin >> x;
    sort(a.begin(), a.end());
    bool f = (a[0] + a[1] == a[2]);
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

char c[100005];
ll cnt[3];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>c;
ll ns=0;
for(ll i=0; c[i]!='\0'; ++i) ns++;
rep(i,ns){
    if(c[i]=='0') cnt[0]++;
    else cnt[1]++;
}
cout<<2*min(cnt[0],cnt[1])<<endl;

}
	


Measured memory_bytes: 3724
package main

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(ReadString(), 10, 64)
	return n
}

func readInt() int {
	return int(readInt64())
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func min64(integers ...int64) int64 {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	x, k, d := readInt64(), readInt64(), readInt64()
	fmt.Println(solve(x, k, d))
}

func solve(x, k, d int64) int64 {
	np := (k - x/d) / 2
	nm := (k + x/d) / 2
	if np < 0 {
		return int64(math.Abs(float64(x - k*d)))
	} else if nm < 0 {
		return int64(math.Abs(float64(x + k*d)))
	}
	var res []int64
	for i := -5; i <= 5; i++ {
		xp := np + int64(i)
		if xp < 0 {
			continue
		}
		xm := k - xp

		if xm < 0 {
			continue
		}
		res = append(res, int64(math.Abs(float64(x+(xp-xm)*d))))
	}
	for i := -5; i <= 5; i++ {
		xm := nm + int64(i)
		if xm < 0 {
			continue
		}
		xp := k - xm
		if xp < 0 {
			continue
		}
		res = append(res, int64(math.Abs(float64(x+(xp-xm)*d))))
	}
	return min64(res...)
}


Measured memory_bytes: 1784
let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () =
  let str = Array.to_list @@ array_of_string @@ read_line () in
  if List.exists (( = ) 'N') str = List.exists (( = ) 'S') str
  && List.exists (( = ) 'E') str = List.exists (( = ) 'W') str
  then print_endline "Yes"
  else print_endline "No"

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

ll ff(ll a,ll x){
    if (a>=0) return a/x+1;
    else return 0;
}

int main(void){
    ll a,b,x;
    cin>>a>>b>>x;
    ll ans=ff(b,x)-ff(a-1,x);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=SI()
n=len(s)
count=0
for i in range(n):
    if s[i]=="p":
        count+=1
if n%2==0:
    pos=n//2
else:
    pos=(n-1)//2
ans=pos-count
print(ans)
    

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

using namespace std;

const int INF = 1e9 + 5;

int main(){
    int n, k;

    scanf("%d", &n);
    scanf("%d", &k);

    vector<int> h(n);

    for(int& x: h){
        scanf("%d", &x);
    }

    vector<int> dp(n, INF);

    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<=i + k; j++){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    printf("%d\n", dp[n-1]);
}

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

int main() {
  string S,T;
  int A,B;
  string U;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if(S == U) {
    cout << A-1 << " " << B << endl;
  } else {
    cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, map) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll X; cin >> X;
    X = abs(X);
    ll ret = 0, sum = 0, idx = 0;
    bool flag = true;
    while(flag){
        idx++; sum += idx;
        if(X <= sum) flag = false;
    }
    cout << idx << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = a / c;
    if(a % c == 0) x--;
    ll y = b / c;
    ll u = a / d;
    if(a % d == 0) u--;
    ll v = b / d;
    ll lcm = (c * d) / __gcd(c, d);
    ll g = a / lcm;
    if(a % lcm == 0) g--;
    ll h = b / lcm;
    cout << b - a + 1 - y + x - v + u + h - g;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    Int n, p;
    cin >> n >> p;
    if (n == 1) {
        dump(p);
        return 0;
    }
    Int c = 0;
    Int res = 1;
    while (p%2 == 0) {
        p /= 2;
        c++;
        if (c%n == 0) res *= 2;
    }
    for (Int i = 3; i*i <= p; i+=2) {
        c = 0;
        while (p%i == 0) {
            p /= i;
            c++;
            if (c%n == 0) res *= i;
        }
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 256
N = input()

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

#各要素を2乗する関数
def calc_sq(n):
	return n ** 2

a2 = list(map(calc_sq, a))
"""
map関数の戻り値はリストではなく、シーケンスのmapオブジェクト
なので、インデックスでアクセスしたり、ループで回したりできるが、
appendなどのlistメソッドは使用できない。
また、print関数で出力しても、カンマ区切りの要素では表示されず、
オブジェクトの型名が表示されるだけ。

だが、map関数の戻り値はシーケンスなので、
list関数を使ってlist型に変換することができる！！
"""

sum_a = sum(a)

sum_a2 = sum(a2)

cost = []
for x in range(-101, 101):
	cost.append(int(N) * x**2 - 2 * x * int(sum_a) + int(sum_a2))

print(min(cost))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e9;

int main()
{
    char c[3][3];
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> c[i][j];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define N 200010
#define pr pair <ll,ll>
#define a first
#define b second
using namespace std;
int n,t,c1=0,c2=0,ans=0;
pr m[N];ll c[N],dp[40];
bool cmp(pr x,pr y){return x.a*(y.b+1)>y.a*(x.b+1);}
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1; i<=n; i++)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(!x) c[++c1]=y+1;
		else m[++c2]={x,y};
	}
	sort(m+1,m+c2+1,cmp);
	sort(c+1,c+c1+1);
	for(int i=1; i<=30; i++) dp[i]=t+1;
	dp[0]=0;
	for(int i=1; i<=c2; i++)
		for(int j=30; j>=1; j--)
			dp[j]=min(dp[j],(dp[j-1]+1)*(m[i].a+1)+m[i].b);
	for(int i=1; i<=c1; i++ )c[i]+=c[i-1];
	for(int i=0; i<=30; i++)
	{
		if(dp[i]>t) continue;
		int j=0;
		if(c1) j=upper_bound(c+1,c+c1+1,t-dp[i])-c-1;
		ans=max(ans,i+j);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    int na = a.size(), nb = b.size(), nc = c.size();
    vector<bool> ab(20000, true);
    vector<bool> bc(20000, true);
    vector<bool> ac(20000, true);
    for (int i = 0; i < na; ++i) {
        for (int j = 0; j < nb; ++j) {
            if (a[i] != '?' && b[j] != '?' && a[i] != b[j])
                ab[i - j + 10000] = false;
        }
    }
    for (int i = 0; i < nb; ++i) {
        for (int j = 0; j < nc; ++j) {
            if (b[i] != '?' && c[j] != '?' && b[i] != c[j])
                bc[i - j + 10000] = false;
        }
    }
    for (int i = 0; i < na; ++i) {
        for (int j = 0; j < nc; ++j) {
            if (a[i] != '?' && c[j] != '?' && a[i] != c[j])
                ac[i - j + 10000] = false;
        }
    }
    int ret = na + nb + nc;
    for (int i = -4000; i <= 4000; ++i) {
        for (int j = -4000; j <= 4000; ++j) {
            if (ab[i + 10000] && ac[j + 10000] && bc[j - i + 10000]) {
                int left  = min({0, i, j});
                int right = max({na, i + nb, j + nc});
                chmin(ret, right - left);
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
// E - Double Factorial
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = 0;
	if(N%2) ans = 0;
	else{
		ll n = N/2, m = log(n)/log(5);
		for(ll w=5, i=0; i<m; ++i, w*=5) ans += n/w;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,a;
    cin>>n>>d>>a;
    d*=2;
    int x[n],h[n];
    vector<pair<int,int>>p(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>h[i];
        p[i]={x[i],h[i]};
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        x[i]=p[i].first;
        h[i]=p[i].second;
    }
    int dam[n+1]={},wa[n+1]={};
    long long X=0;
    for(int i=0;i<n;i++){
        h[i]=max(h[i]-wa[i],0);
        int att;
        if(h[i]>0)att=(h[i]-1)/a+1;
        else att=0;
        X+=att;
        dam[i]+=att*a;
        if(x[i]+d<x[n-1])dam[upper_bound(x,x+n,x[i]+d)-x]-=att*a;
        if(i)wa[i]=wa[i-1]+dam[i];
        else wa[i]=dam[i];
        wa[i+1]+=dam[i+1]+wa[i];
    }
    cout<<X<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    vector<vector<ll>> dp(sz(S)+1,vector<ll>(13));
    int multi=1;
    dp.at(0).at(0)=1;
    rep(i,sz(S)){
        int x;
        if(S.at(i)=='?'){x=-1;}
        else{x=S.at(i)-'0';}

        if(x==-1){
            vector<int> nex(10);
            rep(j,10){
                nex.at(j)=j*multi%13;
            }
            rep(j,13){
                rep(k,10){
                    dp.at(i+1).at((j+nex.at(k))%13)+=dp.at(i).at(j);
                    dp.at(i+1).at((j+nex.at(k))%13)%=MOD;
                }
            }
        }
        else{
            x*=multi;
            x%=13;
            rep(j,13){
                dp.at(i+1).at((j+x)%13)+=dp.at(i).at(j);
                dp.at(i+1).at((j+x)%13)%=MOD;
            }
        }

        multi*=10;
        multi%=13;
    }

    cout<<dp.at(sz(S)).at(5)<<endl;
    
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<ll>;
using vc   = vector<char>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vvc  = vector<vc>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
using posteriority_queue = priority_queue<int, vi, greater<int>>;


int main() {
    ll N; cin >> N;
    int a_kind = 'a'-1;
    vll A(15,0), exp_26(15,1);
    char tmp_char;
    vll tmp_div(15), tmp_mod(15);
    for (int i = 0; i  < 15; i++) {
        if(N <= 26) {
            tmp_mod.at(i)=N;
            for (int j = i; j >=0; j--) {
                tmp_char = a_kind + tmp_mod.at(j);
                cout << tmp_char;
            }
            break;
        }
        tmp_div.at(i)=N/26;
        tmp_mod.at(i)=N%26;
        if(tmp_mod.at(i)==0) {
            tmp_mod.at(i)=26;
            N = tmp_div.at(i)-1;
        } else {
            N = tmp_div.at(i);
        }
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A[100005];
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  sort(A, A+N);
  if (A[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ret = 1;
  ll INF = 1000000000000000000LL;
  for (int i=0; i<N; i++) {
    if (INF / ret < A[i]) {
      cout << -1 << endl;
      return 0;
    }
    ret = ret * A[i];
  }
  if (ret > INF) {
    cout << -1 << endl;
  } else {
    cout << ret << endl;
  }
}

Measured memory_bytes: 4400
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
	//cout << INT_MAX << endl;
	int n, m;
	cin >> n >> m;
	VI x(m);
	rep(i, m)cin >> x[i];
	SORT(x);
	VI y(m);
	rep(i, m - 1)y[i] = abs(x[i] - x[i + 1]);
	SORT(y); REVE(y);
	//for (auto a : y)cout << a << " ";
	int sum = 0;
	rep(i, min(n - 1, m))sum += y[i];
	cout << x[m - 1] - x[0] - sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
auto modmul = [](auto... modx) {
  ll res = 1;
  for (auto modx_ : {modx...})
  {
    res *= modx_;
    res %= mo;
    res += mo;
    res %= mo;
  }
  return res;
};
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
int main()
{
ll n , k ;
cin >> n >> k ;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
COMinit();
vector<ll> fac = factorial(100000);

ll s=0;
rep(i,k+1)s=mod(s+mypow(-1,k-i)*COM(k,i)*mypow(i,n));

vector<ll> b={1};
rep(i,k)b.push_back(mod(b.back()+(i%2?1:-1)*mypow(fac[i+1],mo-2)));
ll bb=0;
rep(i,k+1)bb=mod(bb+modmul(mypow(i,n),mypow(fac[i],mo-2),b[k-i]));

vector<vector<ll>> p(5000, vector<ll>(5000,0) );
rep(i,5000)p[i][1]=1;
rep(i,5000)rep(j,4998)p[i][j+2]=mod(p[i][j+1]+(i-j-2>=0?p[i-j-2][j+2]:0));
/* 
https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
//1
//cout << mypow(k,n) << endl;
//2
//cout << (COM(k,n)*fac[n])%mo << endl;
//3
//cout << t << endl;
//4
//cout << COM(n+k-1,n) << endl;
//5
//cout << COM(k,n) << endl;
//6
//cout << COM(n-1,k-1) << endl;
//7
//cout << bb << endl;
//8,11
//cout << (n>k?0:1) << endl;
//9 漸化式でもできる
//cout << mod(s*mypow(fac[k],mo-2)) << endl;
//10
//cout << p[n][k] << endl;
//12
cout << (n-k<0?0:p[n-k][k]) << endl;

return 0;
}


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

int main()
{
    int n; cin>>n;
    map<int, int> a;
    for(int t; cin>>t; ++a[t]);
    int res=0;
    auto b=a;
    for(auto& e: b) {
        int x=e.first;
        res=max(res, a[x]+a[x-1]+a[x+1]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 7680