akhauriyash/Code-Regression huggingface dataset:
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

// floor(a / b)
Int divFloor(Int)(Int a, Int b) {
  return a / b - (((a ^ b) < 0 && a % b != 0) ? 1 : 0);
}

// ceil(a / b)
Int divCeil(Int)(Int a, Int b) {
  return a / b + (((a ^ b) > 0 && a % b != 0) ? 1 : 0);
}


void main() {
  try {
    for (; ; ) {
      long[2] T, A, B;
      foreach (i; 0 .. 2) T[i] = readLong();
      foreach (i; 0 .. 2) A[i] = readLong();
      foreach (i; 0 .. 2) B[i] = readLong();
      
      long[2] d;
      foreach (i; 0 .. 2) d[i] = T[i] * (A[i] - B[i]);
      if (d[0] + d[1] < 0) {
        swap(A, B);
        d[] *= -1;
      }
      if (d[0] + d[1] == 0) {
        writeln("infinity");
      } else {
        long ans;
        if (d[0] < 0) {
          ++ans;
        }
        // (d[0] + d[1]) k + d[0] < 0
        const res = divCeil(-d[0], d[0] + d[1]) - 1;
        if (res > 0) {
          ans += 2 * res;
        }
        // (d[0] + d[1]) k + d[0] == 0
        if ((-d[0]) % (d[0] + d[1]) == 0) {
          const k = (-d[0]) / (d[0] + d[1]);
          if (k > 0) {
            ++ans;
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 
    
    int main(){
        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;
        int n;
        cin>>n;
        ll ans=0;
        rep(i,1,n+1){
            if(i%3==0 || i%5==0 || i%15==0) continue;
            ans+=i;
        }
        cout<<ans;
        return 0;  
    }       
 
 
    //keep it simple stupid

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

int main()
{
        long long N, M, counter = 0;
        cin >> N >> M;

        vector<long long> H(N);
        vector<long long> H_2(N, 0);

        for(long long i = 0; i < N; i++)
        {
                cin >> H.at(i);
        }

        for(int i = 0; i < M; i++)
        {
                int A, B;
                cin >> A >> B;

                A--;
                B--;

                if(H.at(A) <= H.at(B))
                {
                        H_2.at(A) = -1;
                }

                if(H.at(B) <= H.at(A))
                {
                        H_2.at(B) = -1;
                }
        }

        for(int i = 0; i < N; i++)
        {
                if(H_2.at(i) != -1)
                {
                        counter++;
                }
        }

        cout << counter << endl;

        return 0;
}


Measured memory_bytes: 4804
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef long long int64;
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
const int INF = 1 << 30;

int main()
{
  int R, W[2], H[2], X, Y, L[500][500];
  int min_cost[500][500], limit[2][500 * 500 + 1];

  static const signed dy[] = { 0, 1, 0, -1}, dx[] = { 1, 0, -1, 0};

  while(cin >> R, R){
    map< int, int > level[2];
    for(int i = 0; i < 2; i++){
      cin >> W[i] >> H[i] >> X >> Y;
      --X, --Y;
      for(int j = 0; j < H[i]; j++){
        for(int k = 0; k < W[i]; k++){
          cin >> L[j][k];
        }
      }
      priority_queue< Pii, vector< Pii >, greater< Pii > > que;
      fill_n( *min_cost, 500 * 500, INF);
      que.push( Pii( L[Y][X], make_pair( X, Y)));
      min_cost[X][Y] = L[Y][X];
      level[i][min_cost[X][Y]]++;
      while(!que.empty()){
        Pii p = que.top(); que.pop();
        if(p.first > min_cost[p.second.first][p.second.second]) continue;
        for(int j = 0; j < 4; j++){
          int nx = p.second.first + dx[j], ny = p.second.second + dy[j];
          if(nx < 0 || nx >= W[i] || ny < 0 || ny >= H[i]) continue;
          if(max( L[ny][nx], p.first) >= min_cost[nx][ny]) continue;
          min_cost[nx][ny] = max( L[ny][nx], p.first);
          que.push( Pii( max( L[ny][nx], p.first), make_pair( nx, ny)));
          level[i][min_cost[nx][ny]]++;
        }
      }

      int sz = 0;
      fill_n( limit[i], H[i] * W[i], 0);
      ForEach(it, level[i]){
        sz += it -> second;
        limit[i][sz] = it -> first;
      }
      for(int j = H[i] * W[i] - 1; j > 0; j--){
        if(limit[i][j] == 0) limit[i][j] = limit[i][j + 1];
      }
    }

    int ret = INF;
    for(int i = 0; i < H[0] * W[0]; i++){
      int nokori = R - i;
      if(nokori < 0 || nokori > W[1] * H[1]) continue;
      ret = min( ret, limit[0][i] + limit[1][nokori]);
    }
    cout << ret << endl;
  }
}

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

typedef long long ll;

using namespace std;

const ll MAX_VALUE = 100007, INF = (1 << 30);

int main(){
	int N, W;
	cin >> N >> W;
	vector<vector<ll>> items(N, {0, 0});
	for(int i =0 ; i < N; i++){
		cin >> items[i][0] >> items[i][1];
	}

	vector<ll> dp(MAX_VALUE+1, INF);
	dp[0] = 0;
	ll maxSol = 0;
	for(int i =0; i<N; i++){
		ll weight = items[i][0];
		ll value = items[i][1];
		for(ll v = MAX_VALUE; v >= 0; v--){
			if (v - value >= 0) {
				dp[v] = min(dp[v], dp[v-value] + weight);
				if (dp[v] <= W) maxSol = max(maxSol, v);
			}
		}
	}

	cout << maxSol << endl;

	return 0;
}

Measured memory_bytes: 1024
k, n = map(int, input().split())
A = list(map(int, input().split()))

A_dif = [0]*n
A_dif[0] = A[0] + k - A[n-1]

for i in range(1,n):
  A_dif[i] = A[i]-A[i-1]

ans = k - max(A_dif)

 
print(ans)

Measured memory_bytes: 77452
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    int arr[t];
    for(int i=0; i<t; i++){
        cin>>arr[i];
    }
    int counter=0;
    for(int i=1; i<t-1; i++){
        if(arr[i]>min(arr[i-1], arr[i+1]) && arr[i]<max(arr[i-1], arr[i+1])) counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,k,a[1010]; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout); 
	cin>>n>>k;
	fo(i,0,n)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	fo(i,0,k)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<set>

using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    long long a[n+1];
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
    }
    long long cycle = 0, pre_cycle = 0;
    vector<long long> way = {};
    set<long long> reached;

    long long next = 1;
    way.push_back(next);
    reached.insert(next);
    while(cycle <= k){
        next = a[next];
        cycle++;
        if(reached.count(next) > 0) {
            long long cnt = 0;
            for(vector<long long>::iterator itr = way.begin(); itr != way.end(); itr++){
                if(*itr == next) break;
                cnt++;
            }
            pre_cycle = cnt;
            cycle -= pre_cycle;
            break;
        }
        way.push_back(next);
        reached.insert(next);
    }

    long long ans;
    if(k <= pre_cycle){
        ans = k;
    } else {
        ans = (k - pre_cycle) % cycle;
        ans += pre_cycle;
    }
    cout << way[ans] << endl;

    return 0;
}

Measured memory_bytes: 13620
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n - 1; ++i) os << v[i] << ' ';
    return os << v[n - 1];
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    std::string s; in(s);
    int n = sz(s);

    vi a(n);
    int i = 0;
    while (i < n) {
        int j = i;
        while (j < n and s[j] == 'R') ++j;
        int x = j - i;
        i = j;
        while (j < n and s[j] == 'L') ++j;
        int y = j - i;

        if ((x + y)&1) {
            int z = std::max(x - 1, y - 1);
            a[i - 1] = (x + y + 1)/2;
            a[i + 0] = (x + y - 1)/2;
            if ((~z&1) and x < y) std::swap(a[i - 1], a[i]);
            if ((z&1) and x > y) std::swap(a[i - 1], a[i]);
        } else {
            a[i - 1] = (x + y)/2;
            a[i - 0] = (x + y)/2;
        }
        i = j;
    }

    out(a);
    return 0;
}


Measured memory_bytes: 1488
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=1e6;
char str[N];
int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1),i,bug[26]={};
	LL ans=0;
	for (i=1;i<=n;i++) bug[str[i]-'a']++;
	for (i=0;i<26;i++)
		ans+=1LL*bug[i]*(n-bug[i]);
	printf("%lld\n",(ans>>1)+1);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll INF=1e16;
ll L;
ll A[200000];
ll dp[200000][5];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>L;
    rep(i,0,L) cin>>A[i];
    dp[0][0]=A[0];
    if(A[0]>1) dp[0][1]=A[0]%2;
    else dp[0][1]=2-A[0];
    if(A[0]>=1) dp[0][2]=(A[0]+1)%2;
    else dp[0][2]=1;
    dp[0][3]=INF;
    dp[0][4]=INF;
    rep(i,1,L){
        dp[i][0]=dp[i-1][0]+A[i];
        if(A[i]>1) dp[i][1]=min(dp[i-1][0]+A[i]%2, dp[i-1][1]+A[i]%2);
        else dp[i][1]=min(dp[i-1][0]+2-A[i], dp[i-1][1]+2-A[i]);
        if(A[i]>=1) dp[i][2]=min(dp[i-1][0],min(dp[i-1][1], dp[i-1][2]))+(A[i]+1)%2;
        else dp[i][2]=min(dp[i-1][0],min(dp[i-1][1], dp[i-1][2]))+1;
        if(A[i]>1) dp[i][3]=min(dp[i-1][0]+A[i]%2, min(dp[i-1][2]+A[i]%2, dp[i-1][3]+A[i]%2));
        else dp[i][3]=min(dp[i-1][0]+2-A[i], min(dp[i-1][2]+2-A[i], dp[i-1][3]+2-A[i]));
        dp[i][4]=min(dp[i-1][1],min(dp[i-1][2], min(dp[i-1][3],dp[i-1][4])))+A[i];
    }
    cout <<min(dp[L-1][0],min(dp[L-1][1], min(dp[L-1][2],min(dp[L-1][3], dp[L-1][4]))))<<"\n";
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  LL N;cin>>N;
  LL n[11]={1,1,1};
  LL ans=0;
  LL p[4]={0,3,5,7};
  while(1){
    n[0]++;
    for(int h=0;n[h]==4;n[h]=1,n[++h]++);
    LL e=0;int c[4]={};
    for(LL i=0,j=1;i<=10;i++){
      c[n[i]]=1;
      e+=j*p[n[i]];
      j*=10;
    }
    if(count(c+1,c+4,0)>0)continue;
    if(e>N)break;
    ans++;
  }
  cout<<ans<<endl;
}

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

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back

const double pi = 3.141592653589793238;
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double c = abs(30*h + 30 * (m / 60) - 6*m) / 180 * pi;

    
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(c));
    printf("%.16f", ans);
}


Measured memory_bytes: 4212
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll a(n);
  vvll x(n), y(n);
  rep(i, n)
  {
    cin >> a[i];
    rep(j, a[i])
    {
      ll X, Y; cin >> X >> Y;
      X--;
      x[i].pb(X);
      y[i].pb(Y);
    }
  }
  ll nisin = 0;
  ll ans = 0;
  rep(i, n)
  {
    nisin += pow(2, i);
  }
  while(nisin)
  {
    ll tmp = nisin;
    vb flag(n, false);
    ll now = 0;
    while(tmp)
    {
      if(tmp % 2 == 1)
      {
        flag[now] = true;
      }
      now++;
      tmp /= 2;
    }
    ll U = 0;
    rep(i, n)
    {
      if(flag[i])
      rep(j, a[i])
      {
        if(y[i][j] == 1 && !flag[x[i][j]] || y[i][j] == 0 && flag[x[i][j]]) U++;
      }
    }
    ll b = 0;
    rep(i, n)
    {
      if(flag[i]) b++;
    }
    if(U == 0) ans = max(b, ans);
    nisin--;
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(i%2!=0 && x%2!=0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3644
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    set<char> st;
    rep(i, s.size()){
        st.insert(s[i]);
    }
    bool f = false;
    if(st.size() == 2){
        f = false;
    } else {
        if(s.front() == s.back()){
            if(s.size() % 2 == 0){
                f = true;
            } else {
                f = false;
            }
        } else {
            if(s.size() % 2 == 0){
                f = false;
            } else {
                f = true;
            }
        }
    }
    if(f){
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll cnt = 0;
    rep(i, N)
    {
        cin >> A[i];
        if (A[i] % 2 == 0)
        {
            if (!(A[i] % 3 == 0 || A[i] % 5 == 0))
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

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

    int ans = -1e9;

    vector<int> vec(N);
    FOR(i,0,N) cin>>vec[i];

    FOR(i,0,N){
        FOR(j,0,N){
            ans = max(ans,abs(vec[i]-vec[j]));
        }
    }

    put(ans);
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b,k;
    cin >> a >> b >> k;
    if((a+b)>=k){
        if(a>=k){
            cout << (a-k) << " " << b ENDL;
        }else cout << 0 << " " << (a+b)-k ENDL;
    }else cout << 0 << " " << 0 ENDL;
    
    return 0;
}

Measured memory_bytes: 3612
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N,a,b;
    cin >> N;
    int i=0;
    int count = 0;
    REP(i,N){

        cin >> a >> b ;
        if(a == b){
            count++;
        }else{
            count = 0;
        }

        if(count==3){
            cout << "Yes" << endl;
            return 0;
        }

    }
    
    cout << "No" << endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;

struct UnionFind{
    vector <int> par;
    vector <int> height;
    vector <int> set_size;

    UnionFind(int N){
        par.assign(N, 0);
        height.assign(N, 0);
        set_size.assign(N, 1);
        for(int i = 0; i < N; i++){
            par[i] = i;
        }
    }

    int root(int x){
        if(x == par[x]){
            return x;
        }
        par[x] = root(par[x]);
        return par[x];
    }

    int same(int x, int y){
        return root(x) == root(y);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y){
            return;
        }
        if(height[x] >= height[y]){
            par[y] = x;
            if(height[x] == height[y]){
                height[x] ++;
            }
            set_size[x] += set_size[y];
        } else {
            par[x] = y;
            set_size[y] += set_size[x];
        }
    }
};

int p[100000];

int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    UnionFind un(N);
    for(int i = 0; i < M; i++){
        int x;
        int y;
        cin >> x >> y;
        un.unite(x - 1, y - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(un.same(i, p[i] - 1)){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);
        var m     = int.Parse(spl[2]);

        var aa = ToIntArray(input.ReadLine(), a);
        var bb = ToIntArray(input.ReadLine(), b);

        List<Chi> li = new List<Chi>();
        for(int i=0; i<m; i++) {
            var c = new Chi();
            spl   = input.ReadLine().Split(' ');
            c.x     = int.Parse(spl[0]) -1;
            c.y     = int.Parse(spl[1]) -1;
            c.c     = int.Parse(spl[2]);
            li.Add(c);
        }

        var min = int.MaxValue;

        foreach(var ch in li) {
            var v = aa[ch.x] + bb[ch.y] - ch.c;
            min = Math.Min(min, v);
        }

        min = Math.Min(min, aa.Min() + bb.Min());
        return min;
    }

    class Chi
    {
        public int x;
        public int y;
        public int c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return z>a.z;
    }

};

vector<int> v[1];

//bitset<4001000> b;
int a,i,b,n,d,c,m,k;

int o[2];
int l[1];
int j[1];
int e;


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

//int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=998244353,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
queue<int> q,q1;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<long long,int> p;
//list<int> l;

string r,r1;
//char r[1];
//deque<int> de;
//srand((int)time(NULL));
bool as(P a,P b)
{
    return a.z<b.z;
}

long long f(long long x,long long y)
{
    for(;y;)
    {
        long long h=x;
        x=y;
        y=h%y;
    }
    return x;
}

int main()
{
    scanf("%lld %lld",&x,&y);
    z=x/f(x,y)*y;
    cin>>r;
    cin>>r1;
    for(long long i=0;i<x;i++)
    p[i*z/x+1]=r[i];
    for(long long i=0;i<y;i++)
    {
        if(p[i*z/y+1]&&p[i*z/y+1]!=r1[i])
        {
            puts("-1");
            return 0;
        }
    }
    printf("%lld",z);
}


Measured memory_bytes: 10880
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l = make_divisors(n)
#print(l)

A = l[len(l)//2]
B = l[len(l)//2-1]

print( max( len(str(A)), len(str(B)) ) )


Measured memory_bytes: 3188
/* ITP1_5_A */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      //draw
      for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
          System.out.print("#");
        }
        System.out.println("");
      }
      System.out.println("");
    }

  }
}

Measured memory_bytes: 30896
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            bomb = 0
            dx = [0]
            dy = [0]
            if i != 0:
                dx.append(-1)
            if i != h - 1:
                dx.append(1)
            if j != 0:
                dy.append(-1)
            if j != w - 1:
                dy.append(1)

            for di in dx:
                for dj in dy:
                    if s[i + di][j + dj] == "#":
                        bomb += 1

            s[i][j] = str(bomb)

for i in range(h):
    print("".join(s[i]))


Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int maxn = 1e4+3;
int dp[maxn][102][2];
char s[maxn], d;
int main()
{
	scanf("%s %d", s+1, &d);
	int len = strlen(s+1);
	dp[0][0][1] = 1;
	for (int i = 0; i < len; ++i)
		for (int j = 0; j < d; ++j)
			for (int k = 0; k < 10; ++k)
			{
				int to = (j+k)%d;
				if (dp[i][j][1])
				{
					if (k<s[i+1]-'0')
						dp[i+1][to][0] = (dp[i+1][to][0] + dp[i][j][1])%mod;
					else if (k==s[i+1]-'0')
						dp[i+1][to][1] = (dp[i+1][to][1] + dp[i][j][1])%mod;
				}
				if (dp[i][j][0])
					dp[i+1][to][0] = (dp[i+1][to][0] + dp[i][j][0])%mod;
			}
	printf("%d\n", (dp[len][0][1] + dp[len][0][0]-1+mod)%mod);
	return 0;
}

Measured memory_bytes: 11712
# -*- coding: utf-8 -*-
 
def main(N, A):
    candies = 0
    for i in range(N):
        candies = max(candies, sum(A[0][:i+1]) + sum(A[1][i:]))
    print(candies)
    
if(__name__ == "__main__"):
    N = int(input())
    A = [[int(i) for i in input().split()] for i in range(2)]
    
    main(N, A)

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

int get_hours(int t) {
  return t / 3600;
}

int get_minutes(int t) {
  return (t % 3600) / 60;
}

int get_seconds(int t) {
  return t % 60;
}

int main(int argc, char const *argv[])
{
  int time;
  cin >> time;

  cout << get_hours(time) << ":" << get_minutes(time) << ":" << get_seconds(time) << "\n";
  return 0;
}



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

int main(){
  int n,a,b,x,y=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    x=b-a+1;
    y+=x;
  }
  cout << y <<endl;
  return 0;
}

Measured memory_bytes: 256
from numba import jit
n,k=map(int,input().split())
h=list(map(int,input().split()))
@jit
def jitcalc(n,k,h):
  cost=[0]
  for i in range(1,n):
    wk=[]
    for j in range(1,min(k,i)+1):
      wk.append(cost[i-j]+abs(h[i]-h[i-j]))
    cost.append(min(wk))
  print(cost[n-1])
jitcalc(n,k,h)

Measured memory_bytes: 119564
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut c=0;
    for a in read::<String>().as_bytes().iter().map(|c|*c).collect::<Vec<u8>>(){
    	if a as char=='+'{c+=1}else{c-=1}
    }
    println!("{}",c)
}


Measured memory_bytes: 4352
import sys
n, limit = map(int, sys.stdin.readline().split())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
#print(L)

dp = [{} for i in range(n+1)]
#print(dp)

for i in range(n):
    Lw, Lv = L[i][0], L[i][1]
    dp[i+1][Lv] = Lw #※初めてi+1行目に値が入る
    for v, w in dp[i].items():
        dp[i+1][v] = min(dp[i+1].get(v, w), w) #i+1行目に値がある場合があるので比較
        ww = min(dp[i+1].get(v+Lv, w+Lw), w+Lw)
        if ww <=limit:
            dp[i+1][v+Lv] =ww 

print(max(dp[-1].keys()))

Measured memory_bytes: 286600
#include<stdio.h>

int main(void){
    int N = 0;
    int i= 0;
    double A[1024];
    double Abar[1024];
    double sum = 0, sumbar = 0;

    scanf("%d", &N);

    for(i = 0; i < N; i++){
        scanf("%lf", &A[i]);
        Abar[i] = 1/A[i];
        sum += Abar[i];
    }

    sumbar = 1/sum;

    printf("%f", sumbar);

    return 0;
}

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

int main()
{
    int num = 10;
    int Mountain[num];

    for( int i = 0; i < num; i++ )
    {
        cin >> Mountain[i];
    }    

    for( int i = 0; i < num; i++ )
    {
        for( int j = 0; j < num - 1; j++)
        {
            if(Mountain[j] < Mountain[j+1] )
                {
                    int tmp = 0;
                    tmp = Mountain[j];
                    Mountain[j] = Mountain[j+1];
                    Mountain[j+1] = tmp;
                }
        }
        
    }

    for( int i = 0; i < 3; i++)
    {
        cout << Mountain[i] <<endl;
    }

    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> T;
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,k,c=0LL;cin>>n>>k;
  vector<ll> a(n),b(n);
  rep(i,n){cin>>a[i];c+=a[i];}
  if(c<=k){cout<<0;return 0;}
  rep(i,n)cin>>b[i];
  sort(all(a));sort(all(b),greater<ll>());
  vector<T> p(n);
  rep(i,n)p[i]=T(a[i]*b[i],P(a[i],b[i]));
  sort(all(p),greater<T>());
  ll ma=1LL<<60,mi=0LL,md;
  while(ma-mi>1LL){
    ll t=k;
    md=(ma+mi)/2;
    rep(i,n){
      if(md<p[i].first){
        ll m=md/p[i].second.second;
        t-=(p[i].second.first-m);
      }else break;
    }
    if(t>=0)ma=md;
    else mi=md;
  }
  cout<<ma;
}

Measured memory_bytes: 8064
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        IntStream intLine = Arrays.stream(line)
                .mapToInt(Integer::parseInt)
                .sorted();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i: intLine.toArray()) {
            a.add(i);
        }
        a.sort(Comparator.reverseOrder());
        String r = "";
        for (int j: a) {
            r += j + " ";
        }
        System.out.println(r.trim());
    }
}

Measured memory_bytes: 31976
mod1,mod2=10**9+7,998244353
mod=mod2
n,s=map(int,input().split())
dp=[0]*(s+1)
dp[0]=1
for a in map(int,input().split()):
    dp=[(2*dp[i]+(0 if i<a else dp[i-a]))%mod for i in range(s+1)]
print(dp[-1])

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
long long fac[600010], finv[600010], inv[600010]; 
long long MOD = 1000000007;
void COMinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < 600005; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	int N, M, K; cin >> N >> M >> K;
	COMinit(); 
	long long pow3[600010] = {}; 
	pow3[0] = 1; 
	for(int i = 1; i < 600005; i++) pow3[i] = pow3[i-1] * 3 % MOD; 
	long long A[600010] = {}; 
	long long B[600010] = {}; 
	A[0] = 1; 
	for(int i = 1; i <= M+K; i++){
		A[i] = ((A[i-1] * inv[i]) % MOD) * (N-1+i) % MOD; 
	}
	B[0] = 1; 
	for(int i = 1; i <= M+K; i++){
		B[i] = B[i-1] * 2 % MOD;
		long long mn = 0;  
		if(i > M){
			long long tmp = (fac[i-1] * finv[i-1-M]) % MOD; 
			tmp *= finv[M]; tmp %= MOD; mn += tmp;
		}
		if(i > K){
			long long tmp = (fac[i-1] * finv[i-1-K]) % MOD; 
			tmp *= finv[K]; tmp %= MOD; mn += tmp;
		}
		B[i] += MOD * 2 - mn; B[i] %= MOD; 
	}
	long long ans = 0; 
	for(int i = 0; i <= M+K; i++){
		ans += (B[i] * pow3[M+K-i] % MOD) * A[i] % MOD; 
		ans %= MOD;
	}
	cout << ans << "\n"; 
}

Measured memory_bytes: 31736
#include <bits/stdc++.h>
using namespace std;
int n,a[100009],sum=0,yes=true;
int pre(){
	for(int i=1;i<=n;i++)	if(a[i]%2==1){a[i]--;break;}
	int ngcd=a[1];sum=0;yes=true;
	for(int i=2;i<=n;i++)	ngcd=__gcd(a[i],ngcd);
	for(int i=1;i<=n;i++){
		a[i]/=ngcd;
		if(a[i]%2==0)	sum++;
		if(a[i]==1)	yes=false;
	}
	if(sum%2==1)	return 1;
	else if(n-sum==1&&yes)	return pre()^1;
	else return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==0)	sum++;
		if(a[i]==1)	yes=false;
	}
	if(sum%2==1)	printf("First");
	else if(n-sum==1&&yes)	printf(pre()^1?"First":"Second");
	else printf("Second");
	return 0;
}

Measured memory_bytes: 640
# include <cstdio> 
# include <cstring>
# include <iostream> 
# include <vector>
# include <map> 
# include <set> 
# include <string>
# include <cmath> 
using namespace std ; 

#define maxN 1000000 
#define VI vector<int> 
#define pb push_back 
#define UnsignedSize (sizeof(unsigned)*8)

unsigned pflag[maxN/UnsignedSize+1] ; 

VI primes ; 

void setBit(unsigned *pflag, int pos)
{
    int bytePos = pos / UnsignedSize ; 
    int bitPos = pos % UnsignedSize ; 
    pflag[bytePos] = pflag[bytePos] | (1<<bitPos) ; 
}


bool isBitSet(unsigned *pflag, int pos)
{
    int bytePos = pos / UnsignedSize ; 
    int bitPos = pos % UnsignedSize ; 
    return (pflag[bytePos] & (1<<bitPos)) ; 
}

void sieve(){
    //memset(pflag,0,sizeof(pflag)) ; 
    setBit(pflag, 0) ; 
    setBit(pflag, 1) ;
    primes.pb(2) ; 
    for(int i = 4 ; i < maxN; i+=2) 
        setBit(pflag, i) ; 
    for(int i = 3 ; i*i < maxN; i+=2)
    {
        if(isBitSet(pflag, i)) continue ; 
        //primes.pb(i) ; 
        for(int j=i*i; j  < maxN; j +=(2*i) )
            setBit(pflag, j) ; 
    } 
    for(int i = 3 ; i < maxN; i+=2){
        if(isBitSet(pflag, i)) continue; 
        primes.pb(i) ; 
    }
    /*int sz = primes.size();
    for(int i = 0 ; i < sz; ++i)
        cout << primes[i] << "\n" ; 
    */    
}





int cando(int f)
{
    double x = -1. + sqrt( 1. + (8.* f))  ; 
    return (int)floor(x)/2 ; 
}


int go(unsigned long long n )
{
    int sz = primes.size();
    int answer = 0 ; 

    unsigned long long tn = n; 

    //cout << "DEBUG(tn): " << tn << "\n" ; 

    for(int i = 0 ; i < sz  ; ++i){
        unsigned long long tmp = (unsigned long long) primes[i] ; 
        if(tmp*tmp>n) break ; 
        if(tn==1ULL)break ; 
        if(tn % tmp == 0ULL){
            //++answer ; 
            int f = 0 ; 
            while(tn % tmp == 0ULL){
                 ++f ; 
                tn = tn / tmp ; 
            }
            
            //cout << "DEBUG(f): " << f << "\n" ; 
            //cout << "DEBUG(tn): " << tn << "\n" ; 
            //cout << "DEBUG(prime): " << primes[i] << "\n" ; 
            int txt = cando(f) ;
            //cout << "DEBUG(txt): " << txt << "\n" ;  
            
            answer += txt ; 
        }
    } 
    if(tn > 1ULL)
    {
        ++answer ; 
    }
    return answer ; 

}

int main(){
    
    unsigned long long int n ; 
    cin >> n ; 
    if(n==1ULL){ 
        cout << "0\n" ;     
        return 0 ; 
    }
    sieve() ; 

    cout << go(n) << "\n" ; 

    return 0  ; 
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include "string"

using namespace std;

typedef long long ll;

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

    int N;
    int M;
    cin >> N >> M;

    int a = static_cast<int>(M / N);
    for (int i = a; i > 0; i--) {
        if (M % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
   int n;

   cin >> n;

   long long power = 1;
   for (int i = 1; i <= n; i++) {
       power *= i;
       power = power % (1000000000 + 7);
   }

   cout << power << endl;
   
   return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    int ans = 0, tmp, same_cnt = 1;
    for(int i = 0; i < n; i++){
        if(i > 0){
            if(A[i] == tmp){
                same_cnt++;
            }else{
                ans += same_cnt / 2;
                same_cnt = 1;
            }
        }
        tmp = A[i];
        if(i == n - 1){
            ans += same_cnt / 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll ok = 0, ng = n + 1;
  while (ok + 1 < ng) {
    ll m = (ok + ng) / 2;
    map<string, vector<ll>> mp;
    REP(i, n - m + 1) {
      string t = s.substr(i, m);
      mp[t].push_back(i);
    }
    bool pass = false;
    for (auto& x : mp) {
      vector<ll> v = x.second;
      ll l = v[0], r = v[SZ(v) - 1];
      if (l + m - 1 < r) {
        pass = true;
      }
    }
    (pass ? ok : ng) = m;
  }
  cout << ok << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int n, k;
    char m;
    cin >> n >> k;
    REP(i, n) {
        cin >> m;
        if(i==k-1) {
            if(m=='A') m = 'a';
            if(m=='B') m = 'b';
            if(m=='C') m = 'c';
        }
        cout << m;
    }
    cout << endl;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    boost;
    ll t;
    cin>>t;
    if(t >= 30)
    cout<<"Yes"<<"\n";
    else 
    cout<<"No"<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}

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

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<ll> s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n)cout<<"YES\n";
    else cout<<"NO\n";
}

Measured memory_bytes: 9600