akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    char s[11];
    scanf("%s", s);

    int mindata = 1000;

    int l = strlen(s);

    for (int i = 0; i < l - 3 + 1; i++) {
        char c1 = s[i];
        char c2 = s[i + 1];
        char c3 = s[i + 2];

        int num = (c1 - '0') * 100 + (c2 - '0')*10 + (c3 - '0')*1;

        mindata = (mindata > abs(num -753) ? abs(num - 753):mindata);
        

    }
    
    printf("%d",mindata);



    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a[26]={},b[26]={};
    string s,t;
    cin >> s >> t;
    SORT(s);
    SORT(t);
    reverse(all(t));
    if(s<t) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  string dna;
  cin >> dna;
  int C = 0;
  vector<int> dp(100000 + 5);
  for (int i = 0; i < N; i++){
    if (dna[i] == 'C' && i - 1 >= 0 && dna[i - 1] == 'A'){
      C++;
    }
    dp[i] = C;
  }
  while(Q--){
    int lo, hi;
    cin >> lo >> hi;
    lo--; hi--;
    cout << dp[hi] - dp[lo] << '\n';
  }
  return 0;
}

Measured memory_bytes: 1488
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            if(S.Count(s=>s==S[0])==S.Length)
            {
                WriteLine("Second");
                return;
            }
            var num = 0L;
            if (S.First() == S.Last())
                num = S.Length - 3;
            else
                num = S.Length - 2;
            if (num % 2 == 0)
                WriteLine("Second");
            else
                WriteLine("First");
        }
    }
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

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

  CIN(N, K);

  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  REP(i, MAX_N) {
    if ((K - 1) * i + 1 >= N) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 640
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and 2 * max(l[i], l[j], l[k]) < l[i] + l[j] + l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9200
L = int(input())
S = str(L)
N = len(str(L))
MOD = 10**9+7
dp0 = [0]*N
dp1 = [0]*N
dp0[0] = 1
dp1[0] = 2
for i in range(1,N):
  if S[i]=='1':
    dp0[i] = dp0[i-1]*3+dp1[i-1]
    dp1[i] = dp1[i-1]*2
  else:
    dp0[i] = dp0[i-1]*3
    dp1[i] = dp1[i-1]
  dp0[i] %= MOD
  dp1[i] %= MOD
print((dp0[-1]+dp1[-1])%MOD)


Measured memory_bytes: 11252
N, Y = map(int, input().split())
count = 0
Y = Y//1000

for i in range(N+1):# 10000円札
  for j in range(N+1):# 5000円札
    if count == 0:
      X = Y - 10*i - 5*j
      if (X == N-i-j) & (X>=0):
        print(i, j, X)
        count += 1
    else:
      break

if count == 0:
  print('-1 -1 -1')

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

int main(){
  string s;
  cin >> s;
  for (size_t i = 0; i < s.length() - 1; i++)
  {
    if (s[i] == s[i+1])
    {
      cout << "Bad" << endl;
      return 0;
    }
    
  }
  cout << "Good" << endl;
  
}

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

#define MAX_N 1000
#define MAX_M 2000

#define MOD 1000000007

#define pb push_back
#define xx first
#define yy second

using namespace std;

typedef long long lint;

struct elem
{
    int a, b, c;
};

elem v[MAX_M + 1];

struct cmp
{
    bool operator () (const elem &x, const elem &y)
    {
        return (x.c < y.c);
    }
};

vector <pair <int, int>> g[MAX_N + 1];

int n, m;

lint mst0;
lint x;
lint rez;

lint p2[MAX_M + 1];

int viz[MAX_N + 1];

int comp[MAX_M + 1];
bool luat[MAX_M + 1];
int h[MAX_M + 1];

int d[MAX_N + 1];
int t[MAX_N + 1];
int w[MAX_N + 1];

int diff[MAX_M + 1];

inline lint adun(lint a, lint b){lint rez = a + b; if(rez >= MOD)rez -= MOD; return rez;}
inline lint scad(lint a, lint b){lint rez = a - b; if(rez < 0)rez += MOD; return rez;}
inline lint mul(lint a, lint b){lint rez = a * b % MOD; return rez;}

int getComp(int a)
{
    if(comp[a] == a)
        return a;

    return (comp[a] = getComp(comp[a]));
}

void uneste(int a, int b)
{
    if(h[b] > h[a])
        swap(a, b);

    h[a] += (h[a] == h[b]);
    comp[b] = a;
}

void add(int a, int b, int z)
{
    g[a].pb({b, z});
    g[b].pb({a, z});
}

void getMst()
{
    sort(v + 1, v + m + 1, cmp());

    int i;
    for(i = 1; i <= n; i ++)
    {
        comp[i] = i;
        h[i] = 1;
    }

    for(i = 1; i <= m; i ++)
    {
        int ca = getComp(v[i].a);
        int cb = getComp(v[i].b);

        if(ca != cb)
        {
            add(v[i].a, v[i].b, v[i].c);
            uneste(ca, cb);
            mst0 += v[i].c;
            luat[i] = 1;
        }
    }
}

void dfs(int a)
{
    viz[a] = 1;
    for(auto u : g[a])
    {
        if(viz[u.xx] == 0)
        {
            d[u.xx] = d[a] + 1;
            t[u.xx] = a;
            w[u.xx] = u.yy;
            dfs(u.xx);
        }
    }
}

int mxPath(int a, int b)
{
    int rez = 0;
    while(a != b)
    {
        if(d[a] > d[b])
            swap(a, b);

        rez = max(rez, w[b]);

        b = t[b];
    }

    return rez;
}

void getRez()
{
    if(x < mst0 || n == 1)
    {
        rez = 0;

        return;
    }

    int i;
    int k = 0;
    for(i = 1; i <= m; i ++)
    {
        if(luat[i] == 0)
            diff[++ k] = v[i].c - mxPath(v[i].a, v[i].b);
    }

    sort(diff + 1, diff + k + 1);

    if(mst0 == x)
    {
        rez = adun(rez, scad(p2[n - 1], 2));
        rez = mul(rez, p2[m - (n - 1)]);
    }

    for(i = 1; i <= k; i ++)
    {
        if(mst0 + diff[i] == x)
            rez = adun(rez, p2[k - i + 1]);
    }
}

void getP2()
{
    int i;
    p2[0] = 1;
    for(i = 1; i <= MAX_M; i ++)
        p2[i] = (p2[i - 1] << 1LL) % MOD;
}

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

    cin >> n >> m;
    cin >> x;

    int i;
    for(i = 1; i <= m; i ++)
        cin >> v[i].a >> v[i].b >> v[i].c;

    getP2();

    getMst();

    dfs(1);

    getRez();

    cout << rez << "\n";

    return 0;
}


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

const int m=1e5+5;
int a[m],b[m];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		b[a[i]]=i;
	for(int i=1;i<=n;++i)
		cout<<b[i]<<" ";
	return 0;
} 

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	char c;
	cin >> c;
	if(c=='a' or c=='i' or c=='u' or c=='e' or c=='o')
		puts("vowel");
	else
		puts("consonant");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main(){
	int val1,val2,val3;
  	cin >> val1 >> val2 >> val3;
  	if((val1 == 7 && val2 == 5 && val3 == 5)
       || (val1 == 5 && val2 == 7 && val3 == 5) 
       || (val1 == 5 && val2 == 5 && val3 == 7)){
      cout << "YES";
    }
  	else{
      cout << "NO";
    }
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  long long a,b,c,d;
  cin >> a >> b >> c >>d;
  
  cout << max({1LL*a*c, 1LL*b*d, 1LL*a*d, 1LL*b*c});
 	 
}

Measured memory_bytes: 3632
n = int(input())
MX = 10 **18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > MX:
        print(-1)
        exit(0)
print(ans)


Measured memory_bytes: 21700
#include<bits/stdc++.h>
using namespace std;
struct PP{
  double r,l,p;
  int d;
  PP(){}
  PP(double r,double l,double p,int d):r(r),l(l),p(p),d(d){}
};
int main(){
  int k;
  double r,l,p,e,t,o=0;
  cin >> k >> r >> l >> p >> e >> t;
  PP pp(r,l,1,0);
  queue<PP> q;
  q.push(pp);
  while(!q.empty()){
    pp=q.front();q.pop();
    //cout << pp.d << "/" << pp.r <<":" << pp.l << ":" << pp.p << endl;
    if(t-e<=pp.r&&pp.l<=t+e){
      o+=pp.p;
      continue;
    }
    if(t+e<pp.r||pp.l<t-e){
      continue;
    }
    double mid = (pp.r+pp.l) /2;
    if(pp.d<k){
      if(mid<t){
	q.push(PP(pp.r,mid,pp.p*p,pp.d+1));
	q.push(PP(mid,pp.l,pp.p*(1-p),pp.d+1));
      }else{
	q.push(PP(pp.r,mid,pp.p*(1-p),pp.d+1));
	q.push(PP(mid,pp.l,pp.p*p,pp.d+1));
      }
    }else{
      if(fabs(t-mid)<=e) o+=pp.p;
    }
  }
  printf("%.6lf\n",o);
  return 0;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int len = s.size();

    vector<int> alfa1(26, 0), alfa2(26, 0);

    bool ans = true;
    for (int i = 0; i < len; i++)
    {
        int a1 = s[i] - 'a',a2 = t[i] - 'a';
        alfa1[a1]++; alfa2[a2]++;

        if(alfa1[a1] != alfa2[a2])
        {
            ans = false;
            break;
        }
    }

    if(!ans)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 776
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
x,a,b=gsmi
if (x-a).abs<(x-b).abs
  puts 'A'
else
  puts 'B'
end

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

int main(void) {
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << s[0] << s.length() - 2 << s[s.length() - 1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,i,j,k,s,t;
    scanf("%d",&N);
    int a[N];
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    t=0;
    for(i=0;i<N;i++){
        s=0;
        for(j=1;j<N;j++){
            if(j<=i){
                continue;
            }
            k=a[i]*a[j];
            s=s+k;
        }
        t=t+s;
    }
    printf("%d\n",t);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using P = pair<int,ll>;
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 binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}


int main()
{
    ll A,B;
    cin >> A >> B;

    ll C,D;
    bool a = false;
    bool b = false;
    if(A%2 == 1){//奇数
        a = true;
        C = A + 1;
    }
    if(B%2 == 0){//偶数
        b = true;
        D = B - 1;
    }

    ll ans;
    ll c;    
    if(a&&b){
        c = (B - A - 1)/2;
        if(c%2 == 0) ans = A^B;
        else ans = A^1^B;        
    }
    else if(a&&!b){
        c = (B - A)/2;
        if(c%2 == 0) ans = A + 0;
        else ans = A^1;        
    }
    else if(!a&&b){
        c = (B - A)/2;
        if(c%2 == 0) ans = B + 0;
        else ans = B^1;        
    }
    else{
        c = (B - A + 1)/2;
        if(c%2 == 0) ans = 0;
        else ans = 1;
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
h,w = map(int, input().split())
g = []
for _ in range(h):
  g.append(input())
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
u = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if g[i][j] == '#':
      l[i][j] = 0
      u[i][j] = 0
    else:
      if j == 0:
        l[i][j] = 1
      else:
        l[i][j] = l[i][j-1]+1
      if i == 0:
        u[i][j] = 1
      else:
        u[i][j] = u[i-1][j]+1
for i in reversed(range(h)):
  for j in reversed(range(w)):
    if g[i][j] == '#':
      r[i][j] = 0
      d[i][j] = 0
    else:
      if j == w-1:
        r[i][j] = 1
      else:
        r[i][j] = r[i][j+1]+1
      if i == h-1:
        d[i][j] = 1
      else:
        d[i][j] = d[i+1][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(l[i][j]+r[i][j]+u[i][j]+d[i][j]-3,ans)
print(ans)

Measured memory_bytes: 210852
open System
#nowarn "25"

let inline readLine typeOperator = stdin.ReadLine() |> typeOperator
let inline readArray typeOperator = stdin.ReadLine().Split ' ' |> Array.map typeOperator
let modval = 1000000007


/// エラトステネスの篩による素数リスト生成
let sievePrimes num =
    let sieve = Seq.init (num + 1) (fun i -> if i < 2 then 0 else i) |> Array.ofSeq
    let isPrimes = Array.zeroCreate<bool> (num + 1)
    eprintfn "%d %d" sieve.Length isPrimes.Length
    let maxIndex = num |> double |> sqrt |> ceil |> int
    for i in 2..maxIndex do
        if sieve.[i] = i then
            isPrimes.[i] <- true
            if double i <= sqrt (double num) then
                for j in (i * i)..i..num do
                    sieve.[j] <- min sieve.[j] i
    sieve, isPrimes

/// modの二分累乗法
/// a^n mod m を求める
let modpow a n m =
    let rec recModPow a n m res =
        if n <= 0 then res
        elif n &&& 1 = 1 then recModPow (a * a % m) (n >>> 1) m (res * a % m)
        else recModPow (a * a % m) (n >>> 1) m res
    recModPow a n m 1

/// modの世界での逆元を求める
/// num^(-1) mod m を求める
let modInverse num m =
    let rec recModInverse a b u v =
        let t = a / b
        let a' = a - t * b
        let a, b = b, a'
        let u' = u - t * v
        let u, v = v, u'
        b |> function
        | 0L -> u
        |_ -> recModInverse a b u v
    let a, b, u, v = num, m, 1L, 0L
    let u = recModInverse a b u v
    if u < 0L then (u + m) else u


// eprintfn "main"
let n = readLine int
// eprintfn "%d" n
let A = readArray int
// eprintfn "%A" A
let maxA = A |> Seq.max
// eprintfn "maxA: %d" maxA
let sieve, isPrimes = sievePrimes maxA
// eprintfn "sieve: %A" sieve
// eprintfn "isPrimes: %A" isPrimes
let maxCounts = Array.zeroCreate<int> (maxA + 1)
// eprintfn "count"
//TODO: 再帰関数でループさせる
for elem in A do
    let mutable num = elem
    while num > 1 do
        let p = sieve.[num]
        let mutable cnt = 0
        while num % p = 0 do
            num <- num / p
            cnt <- cnt + 1
        maxCounts.[p] <- max maxCounts.[p] cnt
// eprintfn "calced primeCounts: %A" maxCounts
// eprintfn "mod lcm"
let modlcm =
    Seq.init (maxA + 1) (fun i -> modpow i maxCounts.[i] modval)
    |> Seq.map int64
    |> Seq.fold (fun acc elem -> (int64 acc) * (int64 elem) % (int64 modval)) 1L
// eprintfn "mod lcm: %d" modlcm
// eprintfn "answer"
A |> Seq.map (fun ai -> modlcm * (modInverse (int64 ai) (int64 modval)) % (int64 modval))
|> Seq.fold (fun acc elem -> (acc + elem) % (int64 modval)) 0L
|> printfn "%d"


Measured memory_bytes: 35056
def main():
   n,k = map(int,input().split())
   a = list(map(int,input().split()))


   if k == 1:
      res = 0
      print(res)
   elif k == 2:
      res = 0
      for e in a:
         if e%k == 1:
            res += 1
      print(res)
   else:
      for i in range(n):
         a[i] = (a[i]-1)%k
      b = [0]
      d = {}
      d[0] = 1

      res = 0
      p = 0

      for i,e in enumerate(a):
         p = (p+e)%k
         if p in d:
            res += d[p]
            d[p] += 1
         else:
            d[p] = 1
         b.append(p)
         if i >= k-2:
            d[b[i-(k-2)]] -= 1
      print(res)

if __name__ == '__main__':
      main()




Measured memory_bytes: 118868
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

  int h, w;
  cin >> h >> w;
  string s[50];
  for(int i=0; i<h; i++){
    cin >> s[i];
  }

  for(int i=1; i<h-1; i++){
    for(int j=1; j<w-1; j++){
      if(s[i][j]=='#'){
        if(s[i][j+1]=='.' && s[i][j-1]=='.' && s[i-1][j]=='.' && s[i+1][j]=='.'){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    A = [[0]*3 for _ in range(3)]
    for i in range(3):
        A[i] = list(map(int, input().split()))
    N = int(input())
    hittable = [[False]*3 for _ in range(3)]
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if b==A[i][j]:
                    hittable[i][j]=True
    
    if hittable[0][0] and hittable[1][0] and hittable[2][0]:
        print("Yes")
    elif hittable[0][1] and hittable[1][1] and hittable[2][1]:
        print("Yes")
    elif hittable[0][2] and hittable[1][2] and hittable[2][2]:
        print("Yes")
    elif hittable[0][0] and hittable[0][1] and hittable[0][2]:
        print("Yes")
    elif hittable[1][0] and hittable[1][1] and hittable[1][2]:
        print("Yes")
    elif hittable[2][0] and hittable[2][1] and hittable[2][2]:
        print("Yes")
    elif hittable[0][0] and hittable[1][1] and hittable[2][2]:
        print("Yes")
    elif hittable[0][2] and hittable[1][1] and hittable[2][0]:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (int)(n);i++)
using namespace std;
bool cmp(pair<int,int64_t> a,pair<int,int64_t> b){
  return a.second < b.second;
}
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int64_t,vector<int64_t>,greater<int64_t>> aq;
  rep(i,n){
    int hoge;
    cin >> hoge;
    aq.push(hoge);
  }
  /*rep(i,n){
    cout << aq.top() << "," << endl;
    aq.pop();
  }*/
  vector<pair<int,int64_t>> bc(m);
  rep(i,m){
    cin >> bc.at(i).first >> bc.at(i).second;
  }
  sort(bc.begin(),bc.end(),cmp);
  reverse(bc.begin(),bc.end());
  rep(i,m){
    rep(j,bc.at(i).first){
      if(aq.top() < bc.at(i).second){
        aq.pop();
        aq.push(bc.at(i).second);
      }else{
        break;
      }
    }
  }
  int64_t sum = 0;
  while(!aq.empty()){
    sum += aq.top();
    aq.pop();
  }
  cout << sum << endl;
}
  

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

int main()
{
    int N;cin >>N;
    unsigned long long int vec[N];
    vector<unsigned long long int> as;
    for(int a = 0;a < N;a++){
        //cout <<a<<endl;
        cin >> vec[a];
    }
    //cout << "finish!"<<endl;
    map<unsigned long long int,int> s;
    for(int a = 0;a < N;a++){
        if(s.find(vec[a]) != s.end()){
            s[vec[a]]++;
        }else{
            s[vec[a]] = 1;
        }
    }
    as.push_back(0);
    as.push_back(0);
    for(auto mp:s){
        for(int a = 0;a < mp.second / 2;a++){
            as.push_back(mp.first);
        }
    }
    std::sort(as.begin(),as.end());
    /*
    for(int a :as){
        cout<<a<<" ";
    }
    */
    unsigned long long int a = as.at(as.size()-1) * as.at(as.size()-2);
    cout << a<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    int h[n];
    for(int i = 0;i<n;i++){
      cin >>h[i];
    }
    int sai = h[0];
    int k= 1;
    for(int i= 1;i<n;i++){
      if(h[i] >= sai){
        k+=1;
        sai = h[i];
      }
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
  if (tmp<0)tmp+=b;
  return ar+tmp*a;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}









int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner(val0,val1,1,0)-1;
        ll ans1=garner(val0,val1,0,1)-1;
        //if (ans0>1)
          ans=min(ans,ans0);
        //if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }
  


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

/*
30742895626683

695989518504 30742895626682 2 30742895626683
34542528895425 20495263751121 3 20495263751122
52994067520842 51238159377804 6 10247631875561
22669646754795 39784923752177 17 3616811250198
10472202270114 9042028125494 34 1808405625099
11352643890447 60280187503299 51 1205603750066
12660437818086 29537291876616 102 602801875033
*/

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  int ans = INF;
  for (int i = 0; i < N; ++i) {
    int cnt = 0;
    while (not (A[i] & 1)) {
      A[i] >>= 1;
      ++cnt;
    }
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int bubbleSort(int A[100],int N);

void show(int A[100],int N);

int bubbleSort(int A[100],int N){

  int i=0,j,c=0,temp,flag = 1;

    while(flag){
        flag = 0;
         for (j = N - 1; j >i; j-- ) {
            if (A[j - 1] > A[j]) {  
                c++;
                temp = A[j];       
                A[j] = A[j - 1];
                A[j - 1]= temp;
                flag = 1;
            
            }
         }
        i++;
    }

    return c;
}



void show(int A[100],int N){

 int i;

 for(i=0;i<N;i++){
     printf("%d",A[i]);
     if(i+1!=N){
         printf(" ");
     }
 }
 printf("\n");

}

int main(){

    int n,i;
    int a[100];

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

   int x;
   x = bubbleSort(a,n);

    show(a,n);

     printf("%d\n",x);
   
return 0;

}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef long long ll;
/*
  (px + q)(rx + s)
  p > 0
  r > 0
  (p > r) or (p = r and q >= s)

  prx^2 + (ps + qr)x + qs
  a = pr
  b = ps + qr
  c = qs
 */
int main(){
    ll a,b,c,p,q,r,s,i,j,k;

    while( cin >> a >> b >> c, a|b|c ){
        bool ok = false;

        for(i=1; i*i<=a; i++){
            if( a%i != 0 ) continue;
            p = a/i, r = i;

            for(int sign=-1; sign <=1; sign+=2){
                for(k=0; k*k<=abs(c); k++){
                    j = k * sign;
                    if( (j == 0 && c != 0) || (j != 0 && abs(c)%abs(j) != 0) ) continue;
                    if( j != 0 ){
                        q = c/j, s = j;
                        if( p*s + q*r != b ) q = j, s = c/j;
                        if( p*s + q*r != b ) continue;
                    }
                    else{
                        q = b/r, s = 0;
                        if( p*s + q*r != b ) q = 0, s = b/p;
                        if( p*s + q*r != b ) continue;
                    }

                    //printf(":: %lld %lld %lld %lld\n",p,q,r,s);
                    if( !( p*r == a && q*s == c && (p*s + q*r == b || p*r + q*s == b) ) ) continue;

                    ok = true;
                    if( p == r ){
                        printf("%lld %lld %lld %lld\n", p,max(q,s),r,min(q,s));
                    }
                    else{
                        if( p*s + q*r == b ){
                            printf("%lld %lld %lld %lld\n", p,q,r,s);
                        }
                        else{
                            printf("%lld %lld %lld %lld\n", p,s,r,q);
                        }
                    }
                    break;
                }
                if( ok ) break;
            }
            if( ok ) break;
        }
        if( !ok ) puts("Impossible");
    }
    return 0;
}

Measured memory_bytes: 0
//Name: Pankaj Mandrawal (pankaj_m05)
//Problem: FIzzBuzz Sequence 
//Submitted On : 12.04.2020 20:10:05
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define mod 10000000009
#define sz(c) int((c).size())
#define sortall(x) sort(all(x))         
#define PI 3.1415926535897932384626     
#define all(c) (c).begin(), (c).end()
#define clr(x) memset(x, 0, sizeof(x))  
#define MAX32 numeric_limits< int >::max() 
#define MIN32 numeric_limits< int >::min()
#define rall(c) (c).rbegin(), (c).rend()
#define deb(x) cerr << #x << " = " << x << endl
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = (int)(l); i < (int)(r); ++i)
#define tr(c, it) for(typeof(c).begin() it = c.begin(); it != c.end(); it++)
#define deb2(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl

using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vill;
typedef pair < int, int > pi;
typedef unsigned long long int ull;

ll mypow(ll x, ll y) { 
    if (y == 0) 
        return 1; 
    ll p = mypow(x, y / 2) % mod; 
    p = (p * p) % mod; 
    if (!(y & 1)) 
        return p;
    return (p * x) % mod; 
} 

void plssolve() {
	int n; cin >> n;
	ll sum = 0;
	for(int it = 1; it <= n; ++it) {
		if(it % 3 != 0 && it % 5 != 0)
			sum += it;
	}
	cout << sum << '\n';
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    cout << fixed;
    int t = 1;
    // cin >> t;
    while(t--) {
        plssolve();
    }
    return 0;
}

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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    bool f = false;
    rep(i, 0, N){
        cin >> A[i];
        if(A[i] == 0) f = true;
    }
    if(f){
        cout << 0 << endl;
        return 0;
    }
    ll p = A[0];
    rep(i, 1, N){
        if((double) p * (double) A[i] > 1e18 || p * A[i] > (ll)1e18){
            cout << -1 << endl;
            return 0;
        }
        p *= A[i];
    }
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 4048
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
 

int main(){
	int a,b;scanf("%d%d",&a,&b);
	printf("%d\n",max(max(a+b,a-b),a*b));
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdbool.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

bool S[14];
bool H[14];
bool D[14];
bool C[14];

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int num;
    scanf("%d", &num);
    getchar();
    char ch;
    int digit;
    for (size_t i = 0; i < num; i++)
    {
        scanf("%c %d", &ch, &digit);
        getchar();

        switch (ch)
        {
            case 'S':
                S[digit] = true;
                break;
            case 'H':
                H[digit] = true;
                break;
            case 'C':
                C[digit] = true;
                break;
            case 'D':
                D[digit] = true;
                break;
        }
    }

    for (size_t i = 1; i < 14; i++) {
        if(!S[i]) printf("S %d\n", i);
    }
    for (size_t i = 1; i < 14; i++) {
        if(!H[i]) printf("H %d\n", i);
    }
    for (size_t i = 1; i < 14; i++) {
        if(!C[i]) printf("C %d\n", i);
    }
    for (size_t i = 1; i < 14; i++) {
        if(!D[i]) printf("D %d\n", i);
    }
    
#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	string s;
	cin >> n >> s;
	
	int head=0;
	int l=0,r=0,ml=0;
	char prev='-';
	
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			if(prev != ')') l++; //((((((
			else{ //))))(
				if(ml+l < r) {
					head+=r-(ml+l);
					ml = 0;
				}else if(ml+l > r){
					ml += l - r;
				}else{
					ml = 0;
				}
				r=0;
				l=1; //自分の
				prev='(';
			}
		}else{//)
			if(prev!='(') r++; //)))))
			else{//(((()
				r++;
				prev=')';
			}
		}
		if(i==0) prev = s[0];
	}
//	cout << head << " " << ml << " " << l <<  " " << r << "\n";
	
	head += max(r-l-ml,0);
	for(int i=0;i<head;i++) cout << "(";
	cout << s;
	for(int i=0;i<ml+l-r;i++) cout << ")";
	cout << "\n";

	return 0;
}

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

const ll MOD = 1e9 + 7;
int N, mn[100009];
ll D[100009], S[222], F[222];

ll pw(ll x, ll y) {
    if(y == 0LL) return 1;
    ll t = pw(x, y>>1);
    if(y&1) return t*t%MOD*x%MOD;
    return t*t%MOD;
}

inline ll inv(ll x) {
    return pw(x, MOD-2);
}

inline ll pmt(ll n, ll r) {
    return F[n] * inv(F[n-r]) % MOD;
}

ll go(ll X) {
    int en = upper_bound(S, S+N, X) - S;
    if(en == 0) return X;
    if(D[X] != -1LL) return D[X];
    ll ret = 0;
    for(int i=0; i<en; i++) {
        int t = upper_bound(S, S+N, X % S[i]) - S;
        ret += pmt(en - 1, en - t - 1) * go(X % S[i]) % MOD, ret %= MOD;
    }
    return D[X] = ret;
}

int main() {
    memset(D, -1, sizeof(D));
    for(int i=1; i<=100000; i++) mn[i] = 1e9;
    ll X; scanf("%d%lld",&N,&X);
    F[0] = 1;
    for(int i=1; i<=N; i++) F[i] = F[i-1] * i % MOD;
    for(int i=0; i<N; i++) {
        scanf("%lld",&S[i]);
    }
    sort(S, S+N);
    int c = 0;
    for(int i=0; i<N; i++) if(S[i] > X) ++c;
    printf("%lld", pmt(N, c) * go(X) % MOD);
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    int D = scanner.nextInt();
    int train = Math.min(A, B);
    int bus = Math.min(C, D);
    System.out.println(train + bus);
  }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
    for(int i=0;i<n;i++)
        arr[i]-=1;
        arr[0]%=k;
    for(int i=1;i<n;i++)
    {
        arr[i]+=arr[i-1];
        arr[i]%=k;
    }

    map<int,vector<int> > mp;
     mp[0].pb(0);
    for(int i=0;i<n;i++)
        {
            mp[arr[i]].pb(i+1);
        }
    int ans=0;
    map<int,vector<int> > ::iterator it=mp.begin();
    for( ;it!=mp.end();it++)
    {
        vector<int> a=it->second;
        int i=0,j=1;
        int prev=a[0];
        while(j<a.size())
        {
            if(a[j]-prev<k)
            {   ans+=j-i;

                j++;
            }
            else
            {
                while(a[j]-a[i]>=k)
                {
                    i++;
                }
                prev=a[i];
            }
        }


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


Measured memory_bytes: 23680
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     200050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here

vector<ll> graph[MAX];

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n>>m;

    for(i=0;i<m;i++){
    	ll x,y;
    	cin>>x>>y;
    	graph[x].PB(y);
    	graph[y].PB(x);
    }

    ll start = 1;
    queue<ll> q;
    q.push(1);
    ll ans[n+1];
    clr(ans,-1);
    ans[1] = 0;
    ll nodes[n+1];
    clr(nodes,-1);
    nodes[1] = 1;

    while(!q.empty()){
    	ll cn = q.front();
    	q.pop();
    	for(auto nn: graph[cn]){
    		if(1+ans[cn]<ans[nn] || ans[nn]==-1){
    			nodes[nn] = cn;
    			ans[nn] = 1+ ans[cn];
    			q.push(nn);
    		}
    	}
    }
    ll check = 0;
    for(i=2;i<=n;i++){
    	if(nodes[i]==-1) check =1;
    }
    if(check) cout<<"No";
    else{
    	cout<<"Yes"<<NL;
    	for(i=2;i<=n;i++){
    		cout<<nodes[i]<<NL;
    	}
    }
    /// Don't forget to set array size....
    return 0;
}




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

int main() {
  int n;
  cin >> n;
  double a[n];
  for( int i = 0; i < n; ++i ) cin >> a[i];
  
  sort( a, a + n );
  double res = a[0];
  
  for( int i = 1; i < n; ++i ) {
    res = ( res + a[i] ) / 2;
    
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
      
      	int M1 = scanner.nextInt();
      	int D1 = scanner.nextInt();
      	int M2 = scanner.nextInt();
      	int D2 = scanner.nextInt();
      
      	if(M1 != 12) {
          	if(M2 == M1 + 1 && D2 == 1) {
              	System.out.println(1);
              	return;
            }
          	System.out.println(0);
          	return;
        }
      
      	if(M1 == 12 && M2 == 1 && D2 == 1) {
          	System.out.println(1);
          	return;
        }
     	System.out.println(0);
      	
	}
}
 

 



Measured memory_bytes: 23636
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
long long k,a[200001],i,n,s=0;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i],a[i]-=i;
	sort(a+1,a+1+n);
	k=a[(n+1)/2];
	for(i=1;i<=n;i++) s+=abs(k-a[i]);
	cout<<s;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool check = true;
  for(int i=0; i<s.size(); i++){
	if((i%2==1 && s[i]=='R') || (i%2==0 && s[i]=='L')){
      check = false;
      break;
    }
  }
   if(check)
     cout << "Yes" << endl;
   else
     cout << "No" << endl;
   return 0;
 }

Measured memory_bytes: 256
s = input()
q = int(input())

f = ''
r = ''

flag = True

for i in range(q):
    li = list(input().split())
    if li[0] == '1':
        flag = not flag
    else:
        if li[1] == '1':
            if flag:
                f = li[2] + f
            else:
                r += li[2]
        else:
            if flag:
                r += li[2]
            else:
                f = li[2] + f

if flag:
    print(f + s + r)
else:
    print((f + s + r)[::-1])


Measured memory_bytes: 4412
n, m = map(int, input().split())
g = [[0 for _ in range(n)] for _ in range(n)]
lis_a = []
lis_b = []
for _ in range(m):
    a, b = map(int, input().split())
    lis_a.append(a-1)
    lis_b.append(b-1)
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1

def dfs(v):
    seen[v] = 1
    ret = 1
    for v2 in range(n):
        if g[v][v2] == 1 and seen[v2] == 0:
            dfs(v2)
    if seen == [1] * n:
        ret = 0
        
    return ret
ans = 0
for i in range(m):
    seen = [0] * n
    g[lis_a[i]][lis_b[i]] = 0
    g[lis_b[i]][lis_a[i]] = 0
    ans += dfs(0)
    g[lis_a[i]][lis_b[i]] = 1
    g[lis_b[i]][lis_a[i]] = 1
print(ans)

Measured memory_bytes: 3064