akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n;

std::vector<long> divisor(long n){
    std::vector<long> ret;
    for(long i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i != n / i){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

bool test(long vis){
    if(vis == 1){
        return false;
    }
    long a = n;
    while(a % vis == 0){
        //printf("%ld\n", a);
        a /= vis;
    }
    if(a % vis == 1){
        return true;
    }else{
        return false;
    }
}

int main(){
    scanf("%ld", &n);
    long ans = 0;
    ans += divisor(n-1).size() - 1;
    std::vector<long> div = divisor(n);
    for(long i = 0; i < div.size(); i++){
        long vis = div[i];
        if(test(vis)){
            ans++;
        }
    }
    printf("%ld\n", ans);
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	string s,t;
	cin >> s >> t;
	if(s == t.substr(0, s.size())){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int n;
    cin >> n;
    printf("ABC%03d\n", n);
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$H=explode(" ",trim(fgets(STDIN)));
$len = strlen($S);
$bs=0;
$ws=1;
$bcnt=0;
$wcnt=0;
for($i=0;$i<$len;$i++) {
  if ($bs == $S[$i]) {
    $bcnt++;
  }
  if ($ws == $S[$i]) {
    $wcnt++;
  }
  $bs = rev($bs);
  $ws = rev($ws);
}
printf("%d\n",min($wcnt,$bcnt));
function rev($i)
{
  if ($i==0) return 1;
  else return 0;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
const int MN = 620;
vector<pl> da[2];
int col[MN][MN];
int vs[MN][MN];
inline ll eud(pl a, pl b) {
	ll dx = a.first-b.first;
	ll dy = a.second-b.second;
	return dx*dx+dy*dy;
}
void bfs(int a, int b, int bs, int n) {
	queue<pl> q;
	q.push({a,b});
	while(!q.empty()) {
		pl co = q.front();q.pop();
		int i = co.first,j = co.second;
		int cv = (col[i][j]&(1<<bs))>>bs;
		for(int k=0;k<da[bs].size();k++) {
			int u = i+da[bs][k].first;
			int v = j+da[bs][k].second;
			if(u < 0 || u >= 2*n) {continue;}
			if(v < 0 || v >= 2*n) {continue;}
			if(vs[u][v]&(1<<bs)) {
				//if(col[u][v] == col[i][j]) {cout << "wtf detected\n";}
				continue;
			} else {
				vs[u][v] |= (1<<bs);
				col[u][v] |= (1-cv)<<bs;
				q.push({u,v});
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;
	for(int i=-2*n;i<=2*n;i++) {
		for(int j=-2*n;j<=2*n;j++) {
			if(i*i+j*j == a) {
				da[0].push_back({i,j});
			}
			if(i*i+j*j == b) {
				da[1].push_back({i,j});
			}
		}
	}
	memset(vs,0,sizeof(vs));
	memset(col,0,sizeof(col));
	for(int bs=0;bs<2;bs++) {
		for(int i=0;i<2*n;i++) {
			for(int j=0;j<2*n;j++) {
				if(!(vs[i][j]&(1<<bs))) {
					bfs(i,j,bs,n);
				}
			}
		}
	}
	int ctr[4] = {0,0,0,0};
	for(int i=0;i<2*n;i++) {
		for(int j=0;j<2*n;j++) {
			ctr[col[i][j]]++;
		}
	}
	int mi = 0;
	for(int i=0;i<4;i++) {if(ctr[i] > ctr[mi]) {mi = i;}}
	vector<pl> res;
	for(int i=0;i<2*n;i++) {
		for(int j=0;j<2*n;j++) {
			if(res.size() == n*n) {break;}
			if(col[i][j] == mi) {
				res.push_back({i,j});
			}
		}
	}
	for(int i=0;i<res.size();i++) {
		cout << res[i].first << " " << res[i].second << '\n';
	}
}


Measured memory_bytes: 9900
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_Virtual
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int hit = 0;
            for(int i = 0; i < 3; i++)
            {
                if (S[i] == T[i])
                {
                    hit++;
                }
            }
            Console.WriteLine(hit);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
#x1, y1, x2, y2 = map(int,input().split())

sq = int(pow(n , 0.5) + 0.0001)
for i in range(sq, 0, -1):
    if n % i == 0:
        j = n // i
        m = max(len(str(i)), len(str(j)))
        print(m)
        quit()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      DOUBLECHANGE(100);
      double T, X;
      cin >> T >> X;
      cout << T/X << endl;
}

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

int main(){

    int n,W;
    cin>>n>>W;
    int v[n+100],w[n+100];

    long long dp[n+100][W+100];
    for( int i=0; i<n ; i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0; i<W;i++){
        dp[0][i] = 0;
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<=W; j++){
            if(j >= w[i]){
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + v[i]);
        }else{
            dp[i+1][j] = dp[i][j];
        }
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 80512
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    map<int,int> A;
    rep(i,N){
        int a;cin >> a;
        A[a]++;
    }
    int even = 0;
    int odd = 0;
    for(auto b : A){
        int c = b.S;
        if(c % 2 == 0)even++;
        else odd++;
    }
    if(even == 0)cout << odd << endl;
    else if(even % 2 == 0)cout << even + odd << endl;
    else cout << even + odd - 1 << endl;
}


Measured memory_bytes: 4992
#include<iostream>

int main() {
    int a, b, c, d, e, k;
    int dist[5];
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;
    std::cin >> e;
    std::cin >> k;

    dist[0] = a; dist[1] = b; dist[2] = c;
    dist[3] = d; dist[4] = e;

    for(int i=0; i<5; i++)
      for(int j=i+1; j<5; j++)
        if(dist[j] - dist[i] > k) {
          std::cout << ":(";
          return 0;
        }

    std::cout << "Yay!";
    return 0;
}


Measured memory_bytes: 256
# ABC060 B - Choose Integers
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a,b,c = nm()
ans = 'NO'

for i in range(1,b+1):
    if (a*i)%b == c:
        ans = 'YES'
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 2000000001

int H=0,ary[MAX];

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxheap(int i){
  int l,r,largest,tmp;
  l=left(i);
  r=right(i);
  if(l<=H && ary[l]>ary[i]){largest=l;}
  else{largest=i;}
  if(r<=H && ary[r]>ary[largest]){largest=r;}
  if(largest!=i){
    tmp=ary[i];
    ary[i]=ary[largest];
    ary[largest]=tmp;
    maxheap(largest);
  }
}
int heapextractmax(){
  int max;
  if(H<1){
    fprintf(stderr,"ヒープアンダーフロー\n");
    exit(2);
  }
  max=ary[1];
  ary[1]=ary[H];
  H--;
  maxheap(1);
  return max;
}
void hik(int i,int key){
  int tmp;
  if(key<ary[i]){
    fprintf(stderr,"error\n");
    exit(1);
  }
  ary[i]=key;
  while(i>1 && ary[parent(i)]<ary[i]){
    tmp=ary[i];
    ary[i]=ary[parent(i)];
    ary[parent(i)]=tmp;
    i=parent(i);
  }
}
void insert(int key){
  H++;
  ary[H]=-100000000;
  hik(H,key);
}
int main(){
  int i,value,max;
  char com[10];
  
  while(1){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&value);
      insert(value);
    }
    if(strcmp(com,"end")==0)break;
    
    else if(strcmp(com,"extract")==0){
      printf("%d\n",heapextractmax());
    }
  }
  return 0;
}



Measured memory_bytes: 5628
w, h, n = gets.split.map(&:to_i)
m = [0, w, 0, h]
n.times do |i|
  x, y, a = gets.split.map(&:to_i)
  m[0] = [m[0], x].max if a == 1
  m[1] = [m[1], x].min if a == 2
  m[2] = [m[2], y].max if a == 3
  m[3] = [m[3], y].min if a == 4
end
puts (m[1] - m[0]) > 0 && (m[3] - m[2]) > 0 ? (m[1] - m[0]) * (m[3] - m[2]) : 0


Measured memory_bytes: 1916
H,W,N = map(int,input().split())
XY = []
for i in range(N):
    x,y = map(int,input().split())
    XY.append((x,y))

XY.sort()

ans,d = H,0
for xy in XY:
    x,y = xy[0],xy[1]
    if x == y+d:
        d += 1
    elif x > y+d:
        ans = min(ans, x-1)

print(ans)


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


    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Calc | diff Calc.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Calc.cpp && ./a.out

/*

 6/27/2020

 5:00-

 */

int A;

void solve() {
  cout<<A+A*A+A*A*A<<endl;
}

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

  cin>>A;
  solve();

  return 0;
}


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

int main(){
    int a,b;
    string s="";
    cin>>a>>b;
    if (a<=b) {
        for (int i=0;i<b;i++){
            s+=to_string(a);
        }
    }
    else {
        for (int i=0;i<a;i++) {
            s+=to_string(b);
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll n,k;
	cin >> n >> k;
	cout<<min(n%k,k-n%k)<<endl;
	return 0;
}


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

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  if(x >= a*a*b/2){
    double ans = atan(a*a*a/2/(a*a*b-x));
    double hennkann = 180/acos(-1);
    printf("%.10f", 90-ans*hennkann);
  }
  else{
    double ans = atan(a*b*b/2/x);
    double hennkann = 180/acos(-1);
    printf("%.10f", ans*hennkann);
  }
}


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

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans;
    int way = 0;

    ans = w * h / 2.0;
    if(x*2 == w && y*2 == h) way = 1;

    cout << setprecision(10) << ans << " " << way << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);//freopen("in.txt", "r", stdin);
#else 
#endif
}
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}

char st[200001];
int main()
{
	fast();
	while (cin >> st){
		string x = st;
		vector<vector<int>>v(50);
		int c = 0;
		for (int i = 0; i < x.size(); i++){
			v[x[i] - 'a'].push_back(i);
		}
		ll ans = 0;
		for (char ch = 'a'; ch <= 'z'; ch++){
			ll prev = 0;
			ll ans1 = 0;
			for (int j = 1; j < v[ch - 'a'].size(); j++){
				int idx1 = v[ch - 'a'][j];
				int idx2 = v[ch - 'a'][j - 1];
				int nw = 0;
				//if (idx1 - idx2>1)
				nw = 1;
				ans1 += prev + nw;
				prev = prev + nw;
			}
			ans += ans1;
		}
		ll sz = strlen(st);
		cout << (sz*(sz - 1)) / 2 - ans + 1 << endl;
	}
}

Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,M;
    cin>>N>>M;
    vpii payday(N);
    rep(i,0,N){
        cin>>payday[i].second>>payday[i].first;
    }
    sort(payday.rbegin(),payday.rend());
    set<int> canwork;
    rep(i,1,M+1)canwork.insert(i);
    ll res=0;
    rep(i,0,N){
        auto pos=canwork.lower_bound(payday[i].second);
        if(pos==canwork.end())continue;
        canwork.erase(*pos);
        res+=payday[i].first;
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 5760
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
int arr[256];
void Sequence() {
	int n;
	cin >> n;
	ll p = 1;
	for (ll m = 1; m <= n; m++)
	{
		p *= m;
		p %= INF;
	}
	cout << p << endl;
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int a[121212];
int main() {
	int n, i, j, k, ans = 0; scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	for (i = 0; i < n; ) {
		for (j = i + 1; j < n&&a[j - 1] <= a[j]; j++);
		for (k = i + 1; k < n&&a[k - 1] >= a[k]; k++);
		i = (j > k ? j : k);
		ans++;
	}
	printf("%d", ans);
	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int ans[2000], dist[2000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, X, Y;
	queue<int> Q;
	cin>>N>>X>>Y; --X; --Y;
	for(int i=0;i<N;i++) {
		memset(dist,0x7f,sizeof(dist));
		dist[i]=0;
		Q.push(i);
		while(!Q.empty()) {
			int c=Q.front();
			Q.pop();
			if(c && dist[c-1]>dist[c]+1) {
				dist[c-1]=dist[c]+1;
				Q.push(c-1);
			}
			if(c+1<N && dist[c+1]>dist[c]+1) {
				dist[c+1]=dist[c]+1;
				Q.push(c+1);
			}
			if((c==X || c==Y) && dist[c^X^Y]>dist[c]+1) {
				dist[c^X^Y]=dist[c]+1;
				Q.push(c^X^Y);
			}
		}
		for(int j=0;j<i;j++) ans[dist[j]]++;
	}
	for(int i=1;i<N;i++) cout<<ans[i]<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;
inline ll mul(ll a, ll b) {return (a*b)%M;}
const int MN = 3030;
ll dp[MN][MN];
ll pr[MN];
ll lf[MN],rt[MN];
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {ac = mul(ac,b);}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll cf[MN][MN];
ll ch(ll n, ll k) {
	if(k > n || k < 0) return 0;
	if(k == 0 || k == n) return 1;
	if(cf[n][k] != -1) return cf[n][k];
	return cf[n][k] = (ch(n-1,k-1)+ch(n-1,k))%M;
}
ll ct;
ll ds(ll id, ll x, ll rb) {
	rb = max(rb,lf[id]);
	x += pr[rt[id]]-pr[rb];
	if(id == ct-1) {
		return ch(rt[id]-lf[id],x);
	}
	if(dp[id][x] != -1) {
		return dp[id][x];
	}
	ll tot = 0;
	ll nt = max(rt[id]-lf[id+1],0LL);
	for(int i=0;i<=min(nt,x);i++) {
		tot += mul(ch(min(rt[id],lf[id+1])-lf[id],x-i),ds(id+1,i,rt[id]));
	}
	tot %= M;
	//cout << "dp " << id << " " << x << " = " << tot << '\n';
	return dp[id][x] = tot;
}
int main() {
	ios::sync_with_stdio(0);
	memset(cf,-1,sizeof(cf));
	memset(dp,-1,sizeof(dp));
	int n,m;
	string s;
	cin >> n >> m;
	cin >> s;
	ll ub = -1,id = 0;
	pr[0] = 0;
	for(int i=0;i<n;i++) {
		pr[i+1] = pr[i] + (s[i]-'0');
	}
	for(int i=0;i<m;i++) {
		ll a,b;
		cin >> a >> b;a--;b--;
		if(b <= ub) continue;
		ub = b;
		lf[id] = a;
		rt[id++] = b+1;
	}
	ct = id;
	cout << ds(0,0,0) << '\n';
}

Measured memory_bytes: 143872
// Lunlun Number

func main() {
    let k = Int(readLine()!)!
    var rest = k - 9

    var lunlun: [[Int]] = []

    var digits = 0
    lunlun.append([1,2,3,4,5,6,7,8,9])
    var count = 9

    while count < k {
        var currentLunlun: [Int] = []
        for i in lunlun[digits] {
            let lastNumber = i % 10
            switch lastNumber {
            case 0:
                currentLunlun.append(i * 10 + lastNumber)
                currentLunlun.append(i * 10 + lastNumber + 1)
            case 9:
                currentLunlun.append(i * 10 + lastNumber - 1)
                currentLunlun.append(i * 10 + lastNumber)
            default:
                currentLunlun.append(i * 10 + lastNumber - 1)
                currentLunlun.append(i * 10 + lastNumber)
                currentLunlun.append(i * 10 + lastNumber + 1)
            }
        }

        if rest <= currentLunlun.count {
            print(currentLunlun[rest-1])
            return
        }
        rest -= currentLunlun.count
        lunlun.append(currentLunlun)
        count += currentLunlun.count
        digits += 1
    }
    print(lunlun[0][k-1])
}

main()

Measured memory_bytes: 8912
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int H,W;
	cin>>H>>W;
	vector<vector<int>> p;
	p.resize(H);
	for(int i=0; i<H; i++)
	{
		p[i].resize(W);
		string S;
		cin>>S;
		for(int j=0; j<W; j++)
		{
			if(S[j] == '#')
			{
				p[i][j] = 1;
			}
		}
	}
	vector<vector<int>> collum(H);
	vector<vector<int>> row(H);
	for(int i=0; i<H; i++)
	{
		collum[i].resize(W);
		row[i].resize(W);
	}

	//横方向の走査
	for(int i=0; i<H; i++)
	{
		vector<int> list;
		list.push_back(-1);
		for(int j=0; j<W; j++)
		{
			if(p[i][j] == 1)
			{
				list.push_back(j);
			}
		}
		list.push_back(W);
		int list_size = list.size();
		//一件三重ループだが以下の二重for文内の計算量はNで収まる
		for(int j=0; j<list_size-1; j++)
		{
			int l = list[j];
			int r = list[j+1];
			for(int k=l+1; k<r; k++)
			{
				row[i][k] = r-l-1;
			}
		}
	}

	for(int i=0; i<W; i++)
	{
		vector<int> list;
		list.push_back(-1);
		for(int j=0; j<H; j++)
		{
			if(p[j][i] == 1)
			{
				list.push_back(j);
			}
		}
		list.push_back(H);
		int list_size = list.size();
		//一件三重ループだが以下の二重for文内の計算量はNで収まる
		for(int j=0; j<list_size-1; j++)
		{
			int l = list[j];
			int r = list[j+1];
			for(int k=l+1; k<r; k++)
			{
				collum[k][i] = r-l-1;
			}
		}
	}
	/*
	for(int i=0; i<H; i++)
	{
		
		for(int j=0; j<W; j++)
		{	
			cout<<row[i][j];
		}
		cout<<endl;
	}

	for(int i=0; i<H; i++)
	{
		
		for(int j=0; j<W; j++)
		{	
			cout<<collum[i][j];
		}
		cout<<endl;
	}

	*/
	int maximum = 0;
	for(int i=0; i<H; i++)
	{
		
		for(int j=0; j<W; j++)
		{	
			maximum = max(collum[i][j] + row[i][j],maximum);
		}
	}
	
	cout<<maximum-1<<endl;
	return 0;
}

Measured memory_bytes: 49280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,l=0,r=pow(10,9); cin>>n>>k;
  vector<double> a(n); for(int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  while(r-l>1){
    int m=(l+r)/2,c=0;
    for(int i=0;i<n;i++){
      double t=a[i]/m;
      c+=(t==(int)t?t-1:t);
      if(c>k) break;
    }
    c>k?l=m:r=m;
  }
  cout<<r;
}

Measured memory_bytes: 4844
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int  ,long long int> P;

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

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


int main(void)
{
	long long int n;
	long long int count = 0;
	long long int p = 1;

	cin >> n;

	while(1){
		count++;
		p *= 3;
		if(n<=p){
			break;
		}
	}

	cout << count << endl;
}



Measured memory_bytes: 3108
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
A = k()
B = k()
C = k()
D = k()
E = k()

if A >= N and B >=N and C>=N and D>=N and E >=N:
    print(5)
    sys.exit()

x = min(A,B,C,D,E)
a = math.ceil(N/x)
ans = a+4
print(ans)


Measured memory_bytes: 10012
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<iomanip>
#include<cctype>
#include<climits>
#include<queue>
#include<utility>
#include<functional>
#include<memory>
using namespace std;
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

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

  int N, L;
  cin >> N >> L;

  vector< string > vec;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    vec.emplace_back(s);  
  }

  sort(vec.begin(), vec.end());

  for (const string & str : vec) {
    cout << str;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = INF;
    for(int i = 0; i < s.size(); i++)
    {
        string t = s.substr(i, 3);
        ans = min(abs(753- stoi(t)), ans);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n,k,x,ans=0;
    cin >> n >> k;
    while(n--)
    {
        cin >> x;
        if(x >= k)++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int lenght(char* str){
  int i=0;
 while(str[i]){
     i++;
 }
 return i;
}

int main(){
  char S[101] ;
  int K, ans = 1, len = 0 ;
  cin >> K >> S  ;
  len = lenght(S) ;
  if(len <= K){
    cout << S << endl ;
  } 
  else{
    for(int i=0;i<K;i++){
      cout << S[i] ;
    }
    cout << "..." << endl ;
  }
  return 0 ;
}  

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i*i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

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

  auto v = divisor(n);
  ll ans = 1e18;
  each (i, v) {
    ll j = n / i;
    ans = min(ans, ll(max(to_string(i).size(), to_string(j).size())));
  }

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

Measured memory_bytes: 256
require "set"
n,m = gets.chomp.split(" ").map(&:to_i)

route = {}
room = Set.new
m.times do
  a,b = gets.chomp.split(" ").map(&:to_i)
  route[a] ||= Set.new
  route[a] << b
  route[b] ||= Set.new
  route[b] << a
  room << a
  room << b
end

result = {}
result[1] = 0

count = 1

next_set = Set.new
next_set << 1
while next_set.length > 0
  set = next_set
  next_set = Set.new
  set.each do |r|
    route[r].each do |next_r|
      next if result[next_r]
      result[next_r] = r
      next_set << next_r
    end
  end
  count += 1
end

if result.length == room.length
  puts "Yes"
  (2..n).each do |i|
    puts result[i]
  end
else
  puts "No"
end



Measured memory_bytes: 66924
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

long long dp[2009][2009], dp2[2009][2009], LP[2009], k, n, INF = 1200000000000000000LL; string S;

int main() {
	cin >> S >> k; n = S.size();
	for (int i = 1; i <= n; i++) LP[i] = S[i - 1] - 'a';
	for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) dp[i][j] = 10000; }
	for (int i = 1; i <= n; i++) { dp[i][i - 1] = 0; dp2[i][i - 1] = 1; dp[i][i] = 1; dp2[i][i] = 1; }
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n - i; j++) {
			int L = j, R = i + j;
			if (LP[L] == LP[R]) { dp[L][R] = dp[L + 1][R - 1] + 2; dp2[L][R] = dp2[L + 1][R - 1]; continue; }

			if (dp[L][R] > dp[L + 1][R] + 2) { dp[L][R] = dp[L + 1][R] + 2; dp2[L][R] = dp2[L + 1][R]; }
			else if (dp[L][R] == dp[L + 1][R] + 2) { dp2[L][R] += dp2[L + 1][R]; }

			if (dp[L][R] > dp[L][R - 1] + 2) { dp[L][R] = dp[L][R - 1] + 2; dp2[L][R] = dp2[L][R - 1]; }
			else if (dp[L][R] == dp[L][R - 1] + 2) { dp2[L][R] += dp2[L][R - 1]; }

			if (dp2[L][R] >= INF) dp2[L][R] = INF;
		}
	}
	if (dp2[1][n] < k) { cout << "NONE" << endl; return 0; }
	string V = ""; int LL = 1, RR = n;
	while (LL < RR) {
		vector<tuple<int, int, int>>vec;
		if (LP[LL] == LP[RR] && dp[LL + 1][RR - 1] + 2 == dp[LL][RR]) vec.push_back(make_tuple(LP[LL], 1, 1));
		else {
			if (dp[LL][RR - 1] + 2 == dp[LL][RR]) vec.push_back(make_tuple(LP[RR], 0, 1));
			if (dp[LL + 1][RR] + 2 == dp[LL][RR]) vec.push_back(make_tuple(LP[LL], 1, 0));
		}
		sort(vec.begin(), vec.end());

		for (int i = 0; i < vec.size(); i++) {
			int L1 = LL + get<1>(vec[i]), R1 = RR - get<2>(vec[i]);
			if (k <= dp2[L1][R1]) { V += ('a' + get<0>(vec[i])); LL = L1; RR = R1; break; }
			k -= dp2[L1][R1];
		}
	}
	string VV = V; reverse(VV.begin(), VV.end());
	if (dp[1][n] % 2 == 0) V += VV;
	else V = V + S[LL - 1] + VV;
	cout << V << endl;
	return 0;
}


Measured memory_bytes: 57284
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld a, b;
      lld c, i;
      cin >> a >> b >> c;
      if (a+b+c >= 22)
            cout << "bust";
      else
            cout <<  "win";
      return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    count = int(B / A)
    print(min(count, C))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

int n;

int f[205];
vector<int>dp,dp2;

void calc(){
  for(int i=1;i<=200;++i){
    f[i]=(i*(i+1)*(i+2))/6;
  }
}

void solve(){
  //個数制限なしナップサック1dver
  dp.resize(1e6+5,1e6),dp2.resize(1e6+5,1e6);
  dp[0]=0;dp2[0]=0;
  rep(i,200){
    rep(j,1e6+5){
      if(j-f[i]>=0)chmin(dp[j],dp[j-f[i]]+1);
    }
  }
  rep(i,200){
    rep(j,1e6+5){
      if(f[i]%2==1){
        if(j-f[i]>=0)chmin(dp2[j],dp2[j-f[i]]+1);
      }
    }
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  calc();
  solve();
  while(1){
    cin>>n;
    if(n==0)return 0;
    cout<<dp[n]<<" "<<dp2[n]<<"\n";
  }
	return 0;
}



Measured memory_bytes: 10632
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

from itertools import product

ans = 0
for a in product([0,1],repeat=n):
    for j,l in enumerate(li):
        t = 0
        for k in l[1:]:
            t += a[k-1]
        t %= 2
        if t != p[j]:break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 68072
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(S):
    S = S.copy()
    l_ind = np.where(S == -1)[0][:-1] + 1
    r_ind = np.where(S == -1)[0][1:]

    # 逆順にしておく
    N = len(l_ind)
    for i in range(N):
        S[l_ind[i]:r_ind[i]] = S[l_ind[i]:r_ind[i]][::-1]

    # Trie木の構築
    path = np.zeros_like(S)
    child = np.zeros((len(S), 26), np.int64)
    is_end = np.zeros(len(S), np.bool_)

    n_node = 1
    for i in range(N):
        node = 0
        for j in range(l_ind[i], r_ind[i]):
            path[j] = node
            if child[node][S[j]] == 0:
                child[node][S[j]] = n_node
                n_node += 1
            node = child[node][S[j]]
        is_end[node] = True
    child = child[:n_node]
    is_end = is_end[:n_node]
    ans = 0
    for i in range(N):
        se = 0
        for j in range(r_ind[i] - 1, l_ind[i] - 1, -1):
            se |= 1 << S[j]
            node = path[j]
            for k in range(26):
                if se & 1 << k:
                    if is_end[child[node][k]]:
                        ans += 1
    return ans - N

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba import njit, b1, i4, i8, f8
    import numba
    from numba.pycc import CC
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8[:],))
    cc.compile()

from my_module import main

N = int(readline())
S = np.array(list(read().rstrip()), np.int64)

S[S == ord('\n')] = -1
S[S > 0] -= ord('a')
S = np.insert(S, 0, -1)
S = np.append(S, -1)

print(main(S))


Measured memory_bytes: 301104
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
using Graph = vector<vector<int>>;
int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
  vector<ll> lead(N);
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            lead[nv] = v+1;
            que.push(nv);
        }
    }
  cout<<"Yes"<<endl;
  rep2(i,1,N)cout<<lead[i]<<endl;
}

Measured memory_bytes: 14200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    ll distance = abs(B - A);
    ll speed_d = V - W;
    if(speed_d < 0) {
        cout << "NO" << endl;
    } else if(T * speed_d >= distance) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x < 0 || y < 0) {
		cout << "No" << endl;
	}
	else
	{
		if (x + r <= w && x - r>=0 && y + r <= h && y - r>=0) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	

	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,p,ans;
	cin >> n;
	vector<int> d(n);
	for (int i = 0;i < n;i++)cin >> d[i];
	sort(d.begin(),d.end());
	p = d[(n-1) / 2];
	if (p == d[n / 2 ])ans = 0;
	else ans = d[n / 2 ] - p;
	cout << ans << endl;
}

Measured memory_bytes: 640
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=300005;
const int mod=1000000007;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int dp[N][3][3];
char s[N];
int main()
{
	int n=read_str(s);
	dp[0][0][0]=1;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<3;++j)
		{
			for(int k=0;k<3;++k)
			{
				if(s[i]=='0'||s[i]=='?')
				{
					if(k==2) add(dp[i+1][j][1],dp[i][j][k]);
					else if(k==1) add(dp[i+1][j][2],dp[i][j][k]);
					else add(dp[i+1][j][k+1],dp[i][j][k]);
				}
				if(s[i]=='1'||s[i]=='?')
				{
					if(k) add(dp[i+1][j][k-1],dp[i][j][k]);
					else add(dp[i+1][min(2,j+1)][k],dp[i][j][k]);
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<3;++i) for(int j=0;j<=i;++j) add(ans,dp[n][i][j]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14576
#入力を受け取る
s = list(input())
ans = [0] * len(s)

#左から見ていく.Rだけ位置を決定する.

undifined_childlen = 0

for i in range(len(s)):
    if s[i] == 'R':
        undifined_childlen += 1
    else:
        if undifined_childlen % 2 == 0:
            ans[i] += undifined_childlen // 2
            ans[i-1] += undifined_childlen // 2
        else:
            ans[i] += undifined_childlen // 2
            ans[i-1] += (undifined_childlen // 2) + 1
    
        undifined_childlen = 0
        

#右から見ていく.Lだけ位置を決定する.
undifined_childlen = 0

for i in list(reversed(range(len(s)))):
    if s[i] == 'L':
        undifined_childlen += 1
    else:
        if undifined_childlen % 2 == 0:
            ans[i+1] += undifined_childlen // 2
            ans[i] += undifined_childlen // 2
        else:
            ans[i+1] += (undifined_childlen // 2) + 1
            ans[i] += (undifined_childlen // 2)
    
        undifined_childlen = 0

print(*ans)

Measured memory_bytes: 8616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    vec d(4);
    rep(i,4){
        d[i]=n%10;
        n/=10;
    }
    if((d[0]==d[1]&&d[1]==d[2])||(d[1]==d[2]&&d[2]==d[3])) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc102 {

    class ProgramA {
        args: string[];

        // 3
        // 6
        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            let n: number = parseInt(this.args[0], 10);
            while (n % 2 !== 0) {
                n *= 2;
            }
            console.log(n);
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramA(args);
    prg.main();
}


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

int main(){
 int a,b,d,r;
 double f;

 cin >> a >> b;

 d = a / b;
 r = a % b;
 f = (double)a/ b;

 printf("%d %d %f\n",d,r,f);

 return 0;
}

Measured memory_bytes: 1184