akhauriyash/Code-Regression huggingface dataset:
"""素因数分解
Returns:
    list -- [[prime, index], ...]
"""

def factorization(n):
    res = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])
    if tmp != 1:
        res.append([tmp, 1])
    if res == []:
        res.append([n, 1])
    return res

N = int(input())

if N == 1:
    print(0)
    exit()

res = factorization(N)

ans = 0

for r in res:
    m = 1
    while (m*(m+1)//2 <= r[1]):
        m += 1
    ans += m-1

print(ans)



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

int main(){
  int N,W,w[100],v[100];
  cin>>N>>W;
  for (int i(0);i<N;i++) cin>>w[i]>>v[i];
  ll dp[101][100001]={0}; //i番目までを使って重さw以下になるように選んだ時の価値の最大値
  for (int i(0);i<N;i++){
    for (int j(0);j<=W;j++){
      if (w[i]>j) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, n, q, a, b, ans = -1, now;
  char s[100010], t[100010];
  vector<ll> vec[26];
  scanf("%s%s", s, t);
  for(i = 0; s[i]; ++i) vec[s[i] - 'a'].push_back(i);
  n = i;
  for(i = 0; t[i]; ++i) {
    t[i] -= 'a';
    if(!vec[t[i]].size()) {
      printf("-1");
      return 0;
    }
    now = upper_bound(vec[t[i]].begin(), vec[t[i]].end(), ans % n) - vec[t[i]].begin();
    if(now != vec[t[i]].size()) ans = ans / n * n + vec[t[i]][now];
    else ans = (ans / n + 1) * n + vec[t[i]][0];
  }
  printf("%lld", ans + 1);
  return 0;
}

Measured memory_bytes: 1568
N, K=map(int, input().split())
p=list(map(int, input().split()))
q=[(p[i]+1)/2 for i in range(N)]
r=[0]*(N-K+1)
r[0]=sum(q[:K])
for i in range(1, N-K+1):
  r[i]=r[i-1]-q[i-1]+q[i+K-1]
  
print(max(r))

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

const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  
  if(n == 1) cout << 0 << endl;
  if(n == 0) cout << 1 << endl;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int a[105][105], b[105][105];
llong c[105][105];
int main() {
   int n, m, l;
   cin >> n >> m >> l;
   rep(i, n) rep(j, m) cin >> a[i][j];
   rep(i, m) rep(j, l) cin >> b[i][j];
   rep(i, n) rep(j, l) rep(k, m) { c[i][j] += a[i][k] * b[k][j]; }
   rep(i, n) rep(j, l) { printf("%lld%c", c[i][j], j == l - 1 ? '\n' : ' '); }
   return 0;
}


Measured memory_bytes: 3276
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    N, D = map(int, input().split())
    ans = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        d = math.sqrt(X * X + Y * Y)
        if d <= D:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
S = list(map(int, list(input())))

result = 0
L = []

#S[1,2,5]とすると,i = 1でS[i] = 2で1 + 2の時,,
#1 + 25とするか1 + 2 + 5とするか,未確定
#確定したcurrent = 1とbuf = 2の2通りの値を持っておかないといけない

def recur(i, buf, current, S):
  global result
  if i == len(S) - 1:
    total = [current + buf * 10 + S[i],current,buf * 10,S[i]]
    L.append(total)
    result += current + buf * 10 + S[i]
    return
  
  # +を入れる
  ## ex:1 + 2 (= 3) → 3 + 5 = 8
  ## currentへ足し合わせ,bufを0とする
  ### i = 1,buf = 1の時,0 + 10 + 2 = 12をcurrentとして確定し再帰実行(i = 2で12 + 5)
  ### i = 1,current = 1の時(buf = 0),1 + 0 + 2をcurrentとして確定し再帰実行(i = 2で1 + 2 +5)
  #### i = 0の時,current,bufともに0,S[0] = 1をcurrentとして再帰実行(i = 1で1 + 25か 1 +2 +5の分岐に) 
  recur(i + 1, 0, current + buf * 10 + S[i], S)

  # +を入れない
  ## ex:1 * 10 + 2 (= 12) → (12) * 10 + 5 = 125
  ## iが進む毎に,bufとされた数が10倍になり,次の桁の数が足される
  ### i = 1,buf = 10の時,10 + 2 = 12をbuff(i = 2で120に)で再帰実行(120+5)
  ### i = 1,current = 1(buf = 0)の時,buf = 2(i = 2で20に),current = 1で再帰実行(1+20+5)
  ### i = 0の時,current,bufともに0,1をbufとする(i = 1で10に),current = 0で再帰実行(i = 1で125か12 + 5の分岐に)
  recur(i + 1, buf * 10 + S[i], current, S)

recur(0, 0, 0, S)
print(result)


Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
 
        int n = in.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            int a = in.nextInt();
            if(map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            }else {
                map.put(a, 1);
            }
        }
        int max = 0;
        for(Integer k:map.keySet()) {
            for(int i = k - 1; i <= k + 1; i++) {
                int a = map.containsKey(i - 1) ? map.get(i - 1) : 0;
                int b = map.containsKey(i) ? map.get(i) : 0;
                int c = map.containsKey(i + 1) ? map.get(i + 1) : 0;
                max = Math.max(max, a + b + c);
            }
            
        }
        in.close();
        System.out.println(max);
    }
}

Measured memory_bytes: 63908
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

#define MOD 1000000007
using namespace std;

int main() {
  int a, b, c, d, flag = 0;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    if (flag == 0) {
      c -= b;
      flag = 1;
    } else {
      a -= d;
      flag = 0;
    }
  }
  if (c <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
 
   long i,a,b,c,k;
   long tmpa,tmpb,tmpc;
    cin>>a>>b>>c>>k;
    if(a==b&&b==c){
        cout<<0<<endl;
    }else if(k%2==0){
        cout<<a-b<<endl;
    }else{
        cout<<b-a<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  
  int t = 0,x = 0,y = 0;
  
  bool can = true;
  REP(i,n){
    int ti,xi,yi;
    cin >> ti >> xi >> yi;
    if(abs(ti - t) < (abs(xi-x)+abs(yi-y))){
      can = false;
      break;
    }
    else{
      if((abs(ti - t)-abs(xi-x)-abs(yi-y)) % 2 == 0){
        x = xi;
        y = yi;
        t = ti;
      }
      else{
      can = false;
      break;
      }
    }
  }
  if(can == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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


int main(){
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        if(i%3&&i%5)
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;


}



Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int s[510][510];

int main(void){
    int n,m,q,l,r;
    cin>>n>>m>>q;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        s[l][r]++;
    }
    for(int i=0;i<=500;i++){
        for(int j=0;j<=500;j++){
            s[i+1][j+1]+=s[i][j+1]+s[i+1][j]-s[i][j];
        }
    }
    for(int i=0;i<q;i++){
        cin>>l>>r;
        cout<<s[r][r]-s[r][l-1]-s[l-1][r]+s[l-1][l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
array<array<array<Int, 2501>, 60>, 60> dp;
int main() {
    int N, K; cin >> N >> K;
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= K; k++) {
                if (j-1 >= 0 && k-2*j >= 0) dp[i][j][k] += dp[i-1][j-1][k-2*j];
                if (k-2*j >= 0) dp[i][j][k] += dp[i-1][j][k-2*j] * (2*j+1);
                if (k-2*j >= 0) dp[i][j][k] += dp[i-1][j+1][k-2*j] * (j+1) * (j+1);
                dp[i][j][k] %= MOD;
            }
        }
    }
    cout << dp[N][0][K] << '\n';
    return 0;
}

Measured memory_bytes: 60672
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
  string s;
  cin>>s;
  if(s[0]=='R')
  {
    if(s[1]=='R')
    {
      if(s[2]=='R')
        cout<<3;
      else
        cout<<2;
    }
    else
      cout<<1;

  }
  else if(s[1]=='R')
  {
    if(s[2]=='R')
      cout<<2;
    else
      cout<<1;
  }
  else if(s[2]=='R')
    cout<<1;
  else
    cout<<0;

    
}
return 0;
}

Measured memory_bytes: 3616
#include <cstdio>


int main (void)
{
    int N, stair[100005];
    scanf("%d", &N);
    if (N == 1) {
        printf("Yes\n");
        return 0;
    }
    for (int nn = 0; nn < N; nn++) 
        scanf("%d", &stair[nn]);
    int pivot = stair[0], flag = 0;
    bool can = true;
    for (int i = 1; i < N; i++) {
        if ((pivot - stair[i]) > 1) {
            can = false;
            break;
        }
        else if ((pivot - stair[i]) == 1) {
            if (flag == 0) {
                pivot = stair[i];
                flag = 1;
            }
            else {
                can = false;
                break;
            }
        }
        else {
            if (pivot != stair[i]) {
                pivot = stair[i];
                flag = 0;
            }
        }
    }
    if (can) 
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x, y, a, b, c, ans = 0;
    cin >> x >> y >> a >> b >> c;
    vi r(a), g(b), w(c);
    rep(i, a) cin >> r[i];
    rep(i, b) cin >> g[i];
    rep(i, c) cin >> w[i];
    sort(all(r), greater<ll>());
    sort(all(g), greater<ll>());
    rep(i, x) w.push_back(r[i]);
    rep(i, y) w.push_back(g[i]);
    sort(all(w), greater<ll>());
    rep(i, x+y) ans += w[i];
    cout << ans << endl;
}

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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
    ll n;
    cin >> n;
    deque<ll> b;
    for(ll i = 0; i < n; i++){
        ll a = 0;
        cin >> a;
        if(n % 2 == 0){
            if(i % 2 == 0){
                b.pb(a);
            }else{
                b.push_front(a);
            }
        }else{
            if(i % 2 == 0){
                b.push_front(a);
            }else{
                b.pb(a);
            }
        }
    }

    for(ll i = 0; i < n; i++){
        cout << b[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
  int n;
  long long c;
  cin>>n>>c;
  long long x[n];
  int v[n];
  for (int i=0; i<n; i++) cin>>x[i]>>v[i];

  long long cw[n], anti_cw[n];
  cw[0] = v[0] - x[0];
  for (int i=1; i<n; i++) {
    cw[i] = cw[i-1] + v[i] - (x[i] - x[i-1]);
  }

  anti_cw[n-1] = v[n-1] - (c - x[n-1]);
  for (int i=n-2; i>=0; i--) {
    anti_cw[i] = anti_cw[i+1] + v[i] - (x[i+1] - x[i]);
  }
  long long max_cw[n], max_anti_cw[n];
  max_cw[0] = cw[0];
  for (int i=1; i<n; i++) {
    max_cw[i] = max(cw[i], max_cw[i-1]);
  }
  max_anti_cw[n-1] = anti_cw[n-1];
  for (int i=n-2; i>=0; i--) {
    max_anti_cw[i] = max(anti_cw[i], max_anti_cw[i+1]);
  }
  long long ans = -1e15;
  for (int i=0; i<n-1; i++) {
    ans = max(cw[i] + max_anti_cw[i+1] - x[i], ans);
  }
  ans = max(max_cw[n-1], ans);
  for (int i=n-1; i>0; i--) {
    ans = max(anti_cw[i] + max_cw[i-1] - (c - x[i]), ans);
  }
  ans = max(max_anti_cw[0], ans);
  cout<<max(ans, 0ll)<<endl;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {

	ll A = 0, B = 0, C = 0;
	scanf("%lld%lld%lld", &A, &B, &C);
	printf("%s\n", B - A == C - B ? "YES" : "NO");

	return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int a,b,t;
  cn(a,b,t)
  t/=a;
  co(b*t)
}

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

using namespace std;

int main()
{
  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for (int i = 0; i < (int)s.size() - 2; i++)
    if (s.substr(i, 3) == "ABC") cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  int g = a[0];
  rep(i,n) g= __gcd(g,a[i]);
  vi y(n-1);
  rep(i,n-1){
    y[i] = a[i+1] - a[i];
  }
  sort(ALL(y));
  cout << g << endl;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

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; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

// 竹 l を使用して x の長さを作るのに必要なコスト
int calc(vector<int> l, int x) {
  sort(ALL(l));
  int ans = INF;
  for (int i = 0; i < (1<<l.size()); i++) {
    int mp = 0;
    int len = 0;
    for (int j = 0; j < l.size(); j++) {
      if ((i>>j) & 1) {
        if (len != 0) mp += 10;
        len += l[j];
      }
    }
    if (len == 0) continue;
    mp += abs(len - x);
    chmin(ans, mp);
  }
  return ans;
}

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

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

  int p = int(pow(3, n));

  int ans = INF;
  for (int i = 0; i < p; i++) {
    vector<vector<int>> v(3);
    for (int j = 0; j < n; j++) {
      int x = (i / int(pow(3, j))) % 3;
      v[x].push_back(l[j]);
    }
    if (v[0].empty() || v[1].empty() || v[2].empty()) continue;
    int tmp = calc(v[0], a) + calc(v[1], b) + calc(v[2], c);
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

vector<string> split(string str, char del){
    int first = 0;
    int last = str.find_first_of(del);

    vector<string> result;
    if(str.find_first_of(del) == string::npos){
        result.push_back(str);
        return result;
    }
    while(first < str.size()){
        string subStr(str, first, last - first);
        result.push_back(subStr);
        first = last + 1;
        last = str.find_first_of(del, first);
        if(last == string::npos){
            last = str.size();
        }
    }
    return result;
}

void solve(){

 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    string nums;
    cin >> nums;
    vector<int> ara;
    for(int i = 0; i < nums.size(); i++){
        int n = nums[i] - '0';
        ara.push_back(n);
    }
    int n = ara.size() - 1;
    ll sum = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        string num = nums;
        for(int i = 0; i < n; ++i){
            if(bit & (1 << i)){
                num.insert(i + 1 + (num.size() - nums.size()), "+");
            }
        }
        vector<string> n = split(num, '+');
        for(auto i : n){
            sum += atoll(i.c_str());
        }
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
struct shop
{
	long long int cost;
	long long int n;
};
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<shop>b;
	for(int i=0;i<n;i++)
	{
		int r, t;
		cin >> r >> t;
		b.push_back(shop{ r , t });
	}
	sort(b.begin(), b.end(), [](shop& l,shop&r)
	{
		return l.cost < r.cost;
	});
	long long int ans = 0;
	for(int i=0;i<n;i++)
	{
		if(m<b[i].n)
		{
			ans += m*b[i].cost;
			break;
		}else
		{
			ans += b[i].cost*b[i].n;
			m -= b[i].n;
		}
	}
	cout << ans;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
bool visprime[10000000];
vector<ll>prime;
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime.pb(i);}}


bool vis[100000+10];
int main()
{

  ll a,b,mul,ans;
  cin>>a>>b;
  mul=a*b;
  ll temp=__gcd(a,b);
  cout<<mul/temp<<endl;



}

















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

int main(void){
	int i,j,x,y,n,m,d,sum;
	int field[24][24];
	string s;

	while(cin>>n && n){
		sum = 0;
		memset(field,0,sizeof(field));
		for(i=0;i<n;i++){
			cin>>x>>y;
			field[y][x] = 1;
		}
		cin>>m;
		i=j=10;
		while(m--){
			cin>>s>>d;
			while(d--){
				if(s == "N") i++;
				if(s == "S") i--;
				if(s == "W") j--;
				if(s == "E") j++;
				if(field[i][j] == 1){
					sum++;
					field[i][j] = 0;
				}
			}
		}
		if(sum == n) cout<<"Yes\n";
		else cout<<"No\n";
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;

int main()
{
	string a;
	cin>>a;
	int sum=0;
	for (int i=0; i<a.length(); i++)
	{
		if(a[i]=='x') sum++; 
	} 
	
	if (sum>7) cout << "NO";
	else cout << "YES"; 
}

Measured memory_bytes: 256
from copy import deepcopy
N = int(input())
origin_dp = [list(map(int, input().split())) for _ in range(N)]
dp = deepcopy(origin_dp)

for i in range(N):
    for j in range(N):
        for k in range(N):
            dp[j][k] = min(dp[j][k], dp[j][i]+dp[i][k])
        

judge = origin_dp == dp

if judge:
    ans = 0
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if dp[j][k] == 0 or dp[j][i] == 0 or dp[i][k] == 0: continue

                if dp[j][k] == dp[j][i] + dp[i][k]:
                    dp[j][k] = 0
        
    for i in range(N):
        for j in range(i+1,N):
            ans += dp[i][j]

    print(ans)
else:
    print(-1)


Measured memory_bytes: 58588
N = int(input())
nl = [list() for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    nl[a].append((b, c))
    nl[b].append((a, c))
Q, K = map(int, input().split())

ans = [-1 for _ in range(N + 1)]
stack = [(K, -1, 0)]  # v, p, c
while len(stack) > 0:
    v, p, c = stack.pop()
    ans[v] = c
    for next_v, next_c in nl[v]:
        if next_v == p:
            continue
        stack.append((next_v, v, c + next_c))
for x, y in [tuple(map(int, input().split())) for _ in range(Q)]:
    print(ans[x] + ans[y])


Measured memory_bytes: 103072
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    f(m) {
        int x;
        cin >> x;
        n -= x;
    }
    if (n < 0) {
        cout << -1 << '\n';
    }
    else {
        cout << n << '\n';
    }
}


Measured memory_bytes: 3692
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val cs = IntArray(n - 1)
    val ss = IntArray(n - 1)
    val fs = IntArray(n - 1)
    for (i in 0..(n - 2)) {
        val (c, s, f) = readLine()!!.split(" ").map(String::toInt)
        cs[i] = c
        ss[i] = s
        fs[i] = f
    }
    for (i in 0..(n - 1)) {
        println(solve(n, cs, ss, fs, i, 0))
    }
}

fun solve(n: Int, cs: IntArray, ss: IntArray, fs: IntArray, x: Int, t: Int): Int {
    if (x == n - 1) {
        return t
    }
    val departure = if (t < ss[x]) {
        ss[x]
    } else {
        (t + fs[x] - 1) / fs[x] * fs[x]
    }
    return solve(n, cs, ss, fs, x + 1, departure + cs[x])
}

Measured memory_bytes: 37744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

int main(){
    int n,m;
    cin >>n >>m;
    vector<char> a(n);
    rep(i,n) cin >>a[i];
    rep(i,m){
        int u,v;
        cin >>u >>v;
        G[u].pb(v);
        G[v].pb(u);
    }

    rep(i,n){
        if(a[i]=='?'){
            vector<bool> used(26);
            for(int j:G[i]){
                if(a[j]!='?') used[a[j]-'a'] = true;
            }

            a[i] = 'a';
            while(used[a[i]-'a']) ++a[i];
        }
        cout << a[i];
    }
    cout << "\n";
    return 0;
}



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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (A * N == B) {
    cout << B << endl;
  }
  else if (A * N < B) {
    cout << A * N << endl;
  }
  else if (A * N > B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    if(N ==25)COUT("Christmas");
    if(N==24)COUT("Christmas Eve");
    if(N==23)COUT("Christmas Eve Eve");
    if(N==22)COUT("Christmas Eve Eve Eve");
    return 0;
}


Measured memory_bytes: 764
import numpy as np

H,W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(input()))
G = np.array(S)
G = np.where(G == ".", 1, 0)

## 事前計算
## マスごとに、「そのマスにライトを設置した場合に照らせるマスの数」を上下左右の4配列で求める
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
D = np.zeros((H,W),dtype=int)

for w in range(1,W):
  L[:,w] = (L[:,w-1]+1)*(G[:,w-1])
for w in range(W-1,0,-1):
  R[:,w-1] = (R[:,w]+1)*(G[:,w])
for h in range(1,H):
  U[h] = (U[h-1]+1)*(G[h-1])
for h in range(H-1,0,-1):
  D[h-1] = (D[h]+1)*(G[h])

ans = np.max((L+R+U+D)*G)+1
print(ans)

Measured memory_bytes: 266420
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<N-1;i++){
    cout<<a.at(N-i-1)<<" ";
  }
  cout<<a.at(0)<<endl;
  return 0;
}
  


Measured memory_bytes: 3104
#include <stdio.h>

int main() {
    
    int wh,wm,sh,sm,k;
    int w,s;
    
    scanf("%d %d %d %d %d",&wh,&wm,&sh,&sm,&k);
    
    w=wh*60+wm;
    s=sh*60+sm;
    
    int a =s-(w+k);
    
    printf("%d",a);

    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}

	int a, b;
	cin >> a >> b;
	cout << a + b << endl;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int64_t ans=0;
  for(int i=1;i<=n;i++)
    if(i%3!=0&&i%5!=0)
      ans+=i;
  cout << ans << endl;
  return 0;
}

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

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

def main():
    mod=10**9+7
    N,K=MI()
    #最大個数はスターグラフ，辺を追加すれば減らせる
    
    N2=((N-1)*(N-2))//2
    
    if K>N2:
        print(-1)
        exit()
    
    E=[]
    for i in range(1,N):
        E.append([0,i])#0が中心
        
    rem=N2-K
    
    for i in range(1,N):
        for j in range(i+1,N):
            if rem==0:
                break
            E.append([i,j])
            rem-=1
            
    M=len(E)
    print(M)
    
    for u,v in E:
        print(u+1,v+1)
            
    
    
            
    

main()


Measured memory_bytes: 75120
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef map<string,int>msi;
#define REP(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) REP(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(typeof(c)::iterator i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back

struct data{
    int pos,ac,sc,state;
    data(int a,int b,int c,int d):
        pos(a),ac(b),sc(c),state(d){}
    data(){}
};

struct edge{
    int to,num;
    edge(int a,int b):
        to(a),num(b){}
    edge(){}
};
int N,M,E,S,T,R;
vector<vector<edge> >G;
int d[100][1<<8];
map<int,int>event;
const int INF=1e9;
int solve(){
    fill_n(*d,100*(1<<8),INF);
    queue<data>Q;
    Q.push(data(S,0,0,0));
    while(Q.size()){
        data p=Q.front();Q.pop();
        if(p.pos==T)return p.ac;
        if(d[p.pos][p.state]<=p.sc){
            continue;
        }
        d[p.pos][p.state]=p.sc;
        if(event.find(p.pos)!=event.end()){
            p.state|=(1<<event[p.pos]);
        }
        if(p.sc<R){
            rep(i,G[p.pos].size()){
                edge &e=G[p.pos][i];
                if(e.num!=-1&&((p.state>>e.num)&1)==0)continue;

                Q.push(data(e.to,p.ac+1,p.sc+1,p.state));
            }
        }
        Q.push(data(S,p.ac+1,0,p.state));
        //bitset<4>bs(p.state);
        //cout<<p.pos<<" "<<p.ac<<" "<<p.sc<<" "<<bs.to_string()<<endl;
    }
    return -1;
}
int main(){
    cin>>N>>M>>E>>S>>T>>R;
    G.resize(N);
    rep(i,M){
        int a,b;cin>>a>>b;
        G[a].push_back(edge(b,-1));
        G[b].push_back(edge(a,-1));
    }
    rep(i,E){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].push_back(edge(b,i));
        G[b].push_back(edge(a,i));
        event[c]=i;
    }
    cout<<solve()<<endl;
    return 0;
}

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

int main() 
{
    string s;
    cin >> s;
    int x = count(s.begin(), s.end(), 'a');
    int y = count(s.begin(), s.end(), 'b');
    int z = count(s.begin(), s.end(), 'c');
    if (x==1 && y==1 && z==1)
        cout << "Yes";
    else 
        cout << "No";
    return 0;
}

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

int solve(vector<int> A, vector<int> B, int N)
{
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	long long ans = 0;
	for(auto x: A)
		ans += B.end() - lower_bound(B.begin(), B.end(), N-x);
	return ans%2;
}
int A[202020], B[202020];
int main() {
	int N;
	scanf("%d", &N);
	for(int i=0; i<N; ++i) scanf("%d", A+i);
	for(int i=0; i<N; ++i) scanf("%d", B+i);
	int ans = 0;
	for(int b=0; b<=29; ++b)
	{
		vector<int> X, Y, Z, W;
		int cnt1 = 0, cnt2 = 0;
		for(int i=0; i<N; ++i)
		{
			X.push_back(A[i]&((1<<b)-1));
			Y.push_back(B[i]&((1<<b)-1));
			if(A[i] & (1<<b)) ++cnt1;
			if(B[i] & (1<<b)) ++cnt2;
		}
		int c = solve(X, Y, (1<<b));
		if( (1LL*cnt1*(N-cnt2)+1LL*(N-cnt1)*(cnt2))%2 ) c = 1-c;
		ans += c<<b;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5576
/*	[]__________[][][][]____[][][][][]__{}__[][][][]____[][][][][]__[][][][]
    []__________[]______________[]__________[]__________[]__________[]____[]
    []__________[][][][]________[]__________[][][][]____[]__________[]____[]
    []__________[]______________[]________________[]____[]__[][][]__[]____[]
    []__________[]______________[]________________[]____[]______[]__[]____[]
    [][][][]____[][][][]________[]__________[][][][]____[][][][][]__[][][][]
*/
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define endl '\n'
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define decimal(x) cout<<fixed<<setprecision(x);
bool prime[100005]; 
void Sieve(int n) {
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
} 
void solve()
{
    string s, t;
    cin>>s>>t;
    char s1[s.length()+1],s2[t.length()+1];
    strcpy(s1,s.c_str());
    strcpy(s2,t.c_str());
    ll ans=INT_MAX;
    int n1=s.length();
    int n2=t.length();
    for(ll i=0;i<n1-n2+1;i++)
    {
        ll c=0;
        for(ll j=0;j<n2;j++)
        {
            if(s1[i+j]!=s2[j])
            c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}	
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
       //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3668
using System;

namespace _8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = new int[26];
            while(true)
            {
                var y = Console.ReadLine();
                if (y == null) break;
                var s = y.ToLower();
                for (var i = 0; i < s.Length; i++)
                {
                    if (IsAlphabet(s[i]))
                    {
                        array[s[i] - 'a']++;
                    }
                }
            }
            for (var i = 0; i < 26; i++)
            {
                var alpha = (char)('a' + i);
                Console.WriteLine("{0} : {1}", alpha, array[i]);
            }
        }
        public static bool IsAlphabet(char c)
        {
            return (c >= 'a' && c <= 'z') ? true : false;
        }
    }
}



Measured memory_bytes: 17888
import copy
def solve(N, S):
    single_ref = [False for _ in range(10)]
    double_ref = [{} for _ in range(N)]

    for i in range(N - 1, -1, -1):
        if i == N - 1:
            single_ref[int(S[i])] = True
            continue
        double_ref[i] = copy.deepcopy(double_ref[i + 1])
        for j in range(10):
            if not single_ref[j]:
                continue
            double_ref[i][S[i] + str(j)] = 1
        single_ref[int(S[i])] = True

    ret = {}
    for i in range(N - 1):
        for k in double_ref[i + 1].keys():
            ret[S[i] + k] = 1
    return len(ret.keys())

if __name__ == "__main__":
    N = int(input())
    S = input()
    print(solve(N, S))

Measured memory_bytes: 401416
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n, i, j;
	long long int sum = 0, max = -1000000000;
	scanf("%d", &n);
	int(*f)[10] = (int(*)[10])malloc(sizeof(int)*n * 10);
	int(*p)[11] = (int(*)[11])malloc(sizeof(int)*n * 11);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 10; j++)
		{
			scanf("%d", &f[i][j]);
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 11; j++)
		{
			scanf("%d", &p[i][j]);
		}
	}
	int c1, c2, c3, c4, c5, c6, c7, c8, c9, c10;
	int time;
	for (c1 = 0; c1 < 2; c1++)
	for (c2 = 0; c2 < 2; c2++)
	for (c3 = 0; c3 < 2; c3++)
	for (c4 = 0; c4 < 2; c4++)
	for (c5 = 0; c5 < 2; c5++)
	for (c6 = 0; c6 < 2; c6++)
	for (c7 = 0; c7 < 2; c7++)
	for (c8 = 0; c8 < 2; c8++)
	for (c9 = 0; c9 < 2; c9++)
	for (c10 = 0; c10 < 2; c10++)
	{
		sum = 0;
		time = c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10;
		if (time == 0) continue;
		else
		{
			for (i = 0; i < n; i++)
				{
					sum += p[i][c1*f[i][0] + c2 * f[i][1] + c3 * f[i][2] + c4 * f[i][3] + c5 * f[i][4] + c6 * f[i][5] + c7 * f[i][6] + c8 * f[i][7] + c9 * f[i][8] + c10 * f[i][9]];
				}
			if (sum > max) max = sum;
		}

	}
	printf("%lld", max);
}

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

int main()
{
    int n,m;

    cin>>n>>m;

    int mx=0,mn=1e8;


    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        mx=max(a,mx);
        mn=min(b,mn);
    }
    if(mn<mx)cout<<0<<endl;
    else cout<<mn-mx+1<<endl;
}


Measured memory_bytes: 384
from collections import Counter
mod = 10**9+7
def check(s):
    ban = ["AGC", "ACG", "GAC", "AGGC", "ATGC", "AGTC"]
    for b in ban:
        if b in s:
            return False
    return True

n = int(input())
dp = [Counter() for i in range(n+1)]
dp[0]["RAN"] = 1

for i in range(n):
    for key, value in dp[i].items():
        for c in "ACTG":
            if check(key+c):
                dp[i+1][key[1:]+c]+=value % mod

print (sum(dp[n].values())%mod)

Measured memory_bytes: 4192
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
int k[100005];
int main()
{
    int n;
    long long su=0,z;
    scanf("%d",&n);
    for(int i=0;i<n;++i){scanf("%d",&k[i]);su+=k[i];}
    z=((long long)n+1)*n/2;
    if(su%z==0)
    {
        long long f=su/z;
        long long co=f;
        for(int i=1;i<n;++i)
        {
            if(k[i]-k[i-1]>f)
            {
                printf("NO");
                return 0;
            }
            else
            {
                long long tm=f-k[i]+k[i-1];
                if(tm%n==0)
                {
                    co-=tm/n;
                }
            }
        }
        if(k[0]-k[n-1]>f)
        {
            printf("NO");
            return 0;
        }
        else
        {
            long long tm=f-k[0]+k[n-1];
                if(tm%n==0)
                {
                    co-=tm/n;
                }
        }
        if(co==0) printf("YES");
        else printf("NO");
    }
    else
    {
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 640
n = gets.to_i
arr = gets.split(" ").map.with_index{|x,i| x.to_i-(i+1)}.sort

if n % 2 == 0
  median = (arr[(n/2)-1] + arr[(n/2)]) / 2
else
  median = arr[(n/2)]
end

puts arr.inject(0){|sum,x| sum + (x-median).abs}

Measured memory_bytes: 19072
defmodule Main do
  def solve(s, t, 0), do: false
  def solve(s, t, c) do
  	[head | tail] = s
    if s == t do
      true
    else
      solve(tail ++ [head], t, c - 1)
      end
  end
  def main do
    s =
      IO.read(:line)
      |> String.trim |> String.to_charlist
    t =
      IO.read(:line)
      |> String.trim |> String.to_charlist
     if solve(s, t, length(s)) do
       IO.puts("Yes")
     else
       IO.puts("No")
       end
  end
end


Measured memory_bytes: 30804
import sys
from collections import deque
import copy


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def bfs(X, Ma, Mb):
    #node_list = deque([0, 1])
    drug_dict = {}
    drug_dict[(0, 0)] = 0
    drug_dict[(X[0][0], X[0][1])] = X[0][2]
##    drug_dict[0] = ((0, 0) ,0)
##    drug_dict[1] = ((X[0][0], X[0][1]), X[0][2])
##    depth = 1
    min_cost = sys.maxint
    new_drug_dict = copy.deepcopy(drug_dict)
    for i in range(1, len(X)):
        for drug in drug_dict:
            cost = drug_dict[drug]
            new_drug = (drug[0] + X[i][0], drug[1] + X[i][1])
            if new_drug not in drug_dict:
                new_drug_dict[new_drug] = cost + X[i][2]
            else:
                new_drug_dict[new_drug] = min(drug_dict[new_drug], cost + X[i][2])
            if new_drug[1] * Ma == new_drug[0] * Mb:
                if new_drug_dict[new_drug] < min_cost:
                    min_cost = new_drug_dict[new_drug]
        drug_dict = copy.deepcopy(new_drug_dict)
    return min_cost

def dp_search(X, Ma, Mb, AMax, BMax):
    dp = [[sys.maxint for i in range(AMax + 1)] for j in range(BMax + 1)]
    dp[0][0] = 0

    for i in range(len(X)):
        for a in range(AMax, -1, -1):
            for b in range(BMax, -1, -1):
                if dp[a][b] >= sys.maxint:
                    continue;
                if a + X[i][0] <= AMax and b + X[i][1] <= BMax:
                    dp[a + X[i][0]][b + X[i][1]] = min(dp[a + X[i][0]][b + X[i][1]], dp[a][b] + X[i][2])
    min_cost = sys.maxint
    for a in range(0 , AMax):
        for b in range(0, BMax):
            if a * Mb == b * Ma and a != 0 and b != 0:
                if dp[a][b] < min_cost:
                    min_cost = dp[a][b]
    return min_cost


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, Ma, Mb] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    X = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b, c] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        X.append((a, b, c))

    #cost = bfs(X, Ma, Mb)
    cost = dp_search(X, Ma, Mb, N * 10, N * 10)
    if cost < sys.maxint:
        print cost
    else:
        print -1


if __name__ == '__main__':
    main()

Measured memory_bytes: 4592
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
vector<int> adj[NN];


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        double r;
        cin >> r;
        cout << fixed << setprecision(10) << 2 * 2 * acos(0.0) * r << endl;

    }

}



Measured memory_bytes: 8476
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n;
  cin>>n;
  long long int a[n+1];
  for(long long int i=1;i<=n;i++)cin>>a[i];
    if(n%2){
      for(long long int j=n;j>=1;j=j-2)cout<<a[j]<<" ";
      for(long long int j=2;j<=n-1;j=j+2)cout<<a[j]<<" ";
    }
  else{
    for(long long int j=n;j>=2;j=j-2)cout<<a[j]<<" ";
    for(long long int j=1;j<=n-1;j=j+2)cout<<a[j]<<" ";
  }
  cout<<"\n";
}
      

Measured memory_bytes: 5180
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    if a>=b:
        X=a
        Y=b
    else:
        X=b
        Y=a
    C=0    
    while Y!=0:
        X=X%Y  
        X,Y=Y,X
        C+=1
    else:
        print(X,C)


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  bool ok = false;

  auto replacable = [&t](const string& a)->bool {
    for (uint i = 0; i < a.size(); ++i)
      if (a[i] != t[i] && a[i] != '?')
        return false;
    return true;
  };

  for (uint i = 0; i < s.size() - t.size() + 1; ++i) {
    if (replacable(s.substr(i, t.size()))) {
      ok = true;
      s.replace(i, t.size(), t);
      break;
    }
  }

  reverse(s.begin(), s.end());

  if (ok)
    replace(s.begin(), s.end(), '?', 'a');
  else
    s = "UNRESTORABLE";

  cout << s;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int N,k[1000];
int v[1000][1000];
int found[1000] = {0},ended[1000] = {0};
int keep;
int checking=0;

void dfs(int cur);

int main() {
	cin >> N;
	for(int i=1;i<N+1;i++) {
		cin >> keep >> k[i];
		for(int j=1;j<k[i]+1;j++) {
			cin >> v[i][j];

		}
	}
	dfs(1);
	while(true) {
		//cout << "processing..." << endl;
		bool flag = false;
		int key = 1;
		for(int i=1;i<N+1;i++) {
			if(found[i] == 0) {
				flag = true;
				key = i;
				break;
			}
		}
		if(flag) {
			dfs(key);
		} else {
			break;
		}
	}
	
	
	for(int i=1;i<N+1;i++) {
		cout << i << " " << found[i] << " " << ended[i] << endl;
	}
	

}

void dfs(int cur) {
	//cout << "process ended" << endl;
	if(!found[cur]) {
		checking++;
		//cerr << "visiting: " << cur << " " << "time: " << checking << endl;
		found[cur] = checking;

	}
	for(int dst=1;dst<N+1;dst++) {
		bool flag = false;
		for(int i=1;i<k[cur]+1;i++) {
			if(v[cur][i] == dst) flag = true;
		}
		if((flag) && (dst != cur) && (!found[dst])) dfs(dst);
	}
	if(!ended[cur]) {
		checking++;
		//cerr << "ended: " << cur << " " << "time: " << checking << endl;
		ended[cur] = checking;
	}
}

Measured memory_bytes: 3528