akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  string S;
  cin>>S;
  if(S == "SUN")
  {
    cout<<7<<endl;
  }
  else if(S == "MON")
  {
    cout<<6<<endl;
  }
  else if(S == "TUE")
  {
    cout<<5<<endl;
  }  
  else if(S == "WED")
  {
    cout<<4<<endl;
  }
  else if(S == "THU")
  {
    cout<<3<<endl;
  }
  else if(S == "FRI")
  {
    cout<<2<<endl;
  }
  else if(S == "SAT")
  {
    cout<<1<<endl;
  }
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}

Measured memory_bytes: 256
h,n=map(int,input().split())
p=[float("INF")]*(h+1)
p[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h+1):
        if p[min(h,j+a)]>p[j]+b:
            p[min(j+a,h)]=p[j]+b
print(p[-1])

Measured memory_bytes: 46556
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	A = getlist()
	s = sum(A)
	if N >= s:
		print(N - s)
	else:
		print(-1)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 68248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N, K; cin >> N >> K;
  vector<int> ans(N,0);
  for(int i=0;i<K;i++){
    int d; cin >> d;
    for(int j=0;j<d;j++){
      int a; cin >> a;
      ans[a-1]++;
    }
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(ans[i]==0){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(MAX_V);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
  //bellman_ford
  bool bellman_ford(int s) { // nは頂点数、sは開始頂点
    init();
    d[s]=0;
    for (int i=0;i<MAX_V;i++) {
      for (int v=0;v<MAX_V;v++) {
	for (int k =0;k<E[v].size();k++) {
	  Edge e=E[v][k];
	  if (d[v]!=Inf&&d[e.to]>d[v]+e.cost) {
	    d[e.to]=d[v]+e.cost;
	    if(i==MAX_V-1)return true; // n回目にも更新があるなら負の閉路が存在
	  }
	}
      }
    }
    return false;
  }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  Graph g(n+10);
  Graph g2(n+10);
  for(int i=0;i<m;i++){
    ll a,b,c;cin>>a>>b>>c;
    g.add_edge(--a,--b,-c);
    g2.add_edge(b,a,-c);
  }
  if(g.bellman_ford(0)){
    if(g2.bellman_ford(n-1))
      cout<<"inf"<<endl;
    else
      cout<<-g.d[n-1]<<endl;
  }else{
    cout<<-g.d[n-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
int main(){
	int n,a,b,i;
	scanf("%d",&n);
	if(n<=3){
		printf("No");
		return 0;
	}
	a=n/4;
	b=n/7;
	for(i=a;i>=b;i--){
		if((n-(4*i))%3==0&&(n-(4*i))/3<=i){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
  if(A/D+(A%D>0?1:0)<C/B+(C%B>0?1:0)){
    cout<<NO<<endl;
  }else{
    cout<<YES<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

long long MOD = 1000000007;
long long fac[200000];
long long finv[200000];
long long inv[100000];

int BIT_SIZE = 64;
long long power(long long m, long long n){
    long long ans = 1;
    long long tmp = m;
    for(int i = 0; i < BIT_SIZE; i++){
        //cout << ans << endl;
        if(((n >> i) & 1) == 1){
            ans = ans * tmp % MOD;
        }
        tmp = (tmp * tmp) % MOD;
    }
    return ans;
}

/*
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 200000; 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 comb(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;
}

long long combination(long long M, long long N){
    long long ans = 1;
    for(long long i = 0; i < N; i++){
        cout << ans << endl;
        ans = (ans * (M - i)) % MOD;
    }
    for(long long i = 0; i < N; i++){
        cout << ans << endl;
        ans = (ans / (N - i)) % MOD;
    }
    //cout << ans << endl;
    return ans;
}

*/

int main(){
    /*
    comb_init();
    int N;
    int M;
    long long K;
    cin >> N >> M >> K;
    
    
    long long ans = 0;
    for(int dist = 1; dist < N; dist++){
        long long tmp = N - dist;
        tmp = (((tmp * M)  % MOD) * M) % MOD;
        ans = (ans + (tmp * comb(N * M - 2, K - 2)) % MOD) % MOD;        
    }
    for(int dist = 1; dist < M; dist++){
        long long tmp = M - dist;
        tmp = (((tmp * N)  % MOD) * N) % MOD;
        ans = (ans + (tmp * comb(N * M - 2, K - 2)) % MOD) % MOD;        
    }
    cout << ans << endl;
    */
    /*
    cout << combination(N * M - 2, K - 2) << endl;;
    cout << N * M - 2 << " " << K - 2 << endl;
    */
   
   int m;
   long long n;
   cin >> m >> n;
   //cout << "hell" << endl;
   cout << power(m, n) << endl;
   return 0;
}




Measured memory_bytes: 3092
from fractions import gcd

N, A, B, K = map(int, input().split())
if K == 0:
    print(1)
    exit()
c = gcd(A, B)
if K % c != 0:
    print(0)
    exit()
A //= c; B //= c; K //= c
mod = 998244353

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

ans = 0
for x in range(N+1):
    y, r = divmod(K - A * x, B)
    if r != 0:
        continue
    if 0 <= y <= N:
        ans = (ans + comb(N, x) * comb(N, y)) % mod
print(ans)

Measured memory_bytes: 71784
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
ll max_lim(ll n)
{
	int beg=1,end=100;
	while(beg<=end)
	{
		int mid=beg+((end-beg)>>1);
		if(mid*(mid+1)<=2*n)
		{
			beg=mid+1;
		}
		else
			end=mid-1;
	}
	return end;
}
void solve()
{
fastio
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=2;i*i<=n;i++)
	{
		ll pow=0;
		if(n%i==0)
		{
			while(n%i==0)
			{
				n/=i;
                pow++;
			}
          ans+=max_lim(pow);
		}
	}
	if(n!=1)
	{
		ans++;
	}
	cout<<ans;
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;
    ll a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>

int main(){
    int n, t;
    std::cin >> n >> t;

    for(int i = t - (n - 1); i <= t + (n - 1); ++i){
        std::cout << i;
        if(t + (n - 1) != i){
            std::cout << " ";
        }
    }

    std::cout << std::endl;

    return 0;

}

Measured memory_bytes: 256
n,y=map(int,input().split())
import sys
for i in range(n+1):
    if y>=10000*i:
        y1=y-10000*i
        n1=n-i
        for j in range(n1+1):
            if y1>=5000*j:
                y2=y1-5000*j
                n2=n1-j
                if y2==1000*n2:
                    print(i,j,n2)
                    sys.exit()
print(-1,-1,-1)


Measured memory_bytes: 40300
$n = <>;
chomp($n);
$p = <>;
chomp($p);
@p=split/ /,$p;
$count=0;
for($i=0;$i<$n-2;$i++){
	@ary = ($p[$i],$p[$i+1],$p[$i+2]);
    @ary =sort{$a <=> $b}@ary;
    if($ary[1] == $p[$i+1]){
   		$count++; 
   }
}
print $count;

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	string s; cin >> s;
	int c=0;

	rep(i,s.size())
	{
		if(i%2)
		{
			if(s[i]=='g')c++;
		}
		else
		{
			if(s[i]=='p')c--;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

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

    string output;
    for (int i = 0; i < A.length(); i++)
    {
        if(i != A.length()-1){
            output += A[i];
            output += B[i];
        }else{
            if(A.length()>B.length()){
                output += A[i];
            }else{
                output += A[i];
                output += B[i];
            }
        }
    }
    
    cout << output << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N, i, S=0,ans;
	cin >> N;
	vector<int> vec(100002);
	vec[0] = vec[N+1] = 0;
	FOR(i, 1, N+1)
		cin >> vec[i];
	REP(i, N + 1) {
		S += abs(vec[i] - vec[i + 1]);
	}
	FOR(i, 1, N + 1) {
		ans = S + abs(vec[i - 1] - vec[i + 1]) - (abs(vec[i - 1] - vec[i]) + abs(vec[i] - vec[i + 1]));
		cout << ans << endl;;
	}
}

Measured memory_bytes: 1664
S = list(input())
m = 0
count = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 0
        #switch = False
        for s in list(S[i:j+1]):
            #print(s, list(S[i:j+1]), count)
            if s in ['A', 'G', 'T', 'C']:
                count += 1
            else:
                if m <= count:
                    m = count
                count = 0
                switch = True
            if m <= count:
                m = count


print(m)


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    cout << 24 - n + 24 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;

using ll = long long;
const int N = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    priority_queue<pair<int,int>> pq;
    pq.push({a[0],a[0]});

    ll sum = 0;
    for(int i = 1; i < n; ++i) {
        pair<ll,ll> pi = pq.top();
        pq.pop();
        sum += pi.first;
        pq.push({a[i],pi.first});
        pq.push({a[i],pi.second});
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 6872
w,h,n=map(int,input().split())
ux=w
lx=0
uy=h
ly=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        lx=max(lx,x)
    if a==2:
        ux=min(ux,x)
    if a==3:
        ly=max(ly,y)
    if a==4:
        uy=min(uy,y)
print(max(ux-lx,0)*max(uy-ly,0))

Measured memory_bytes: 3064
n = int(input())
cnt = 0

def sft(s):
	global cnt
	if int(s) > n:
		return
	if "3" in s and "5" in s and "7" in s:
		cnt += 1
	sft(s+"3")
	sft(s+"5")
	sft(s+"7")

sft("0")
print(cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S,T;
    cin >> S >> T;
    int dp[S.size()+1][T.size()+1];
    rep(i,0,S.size()+1){
        rep(j,0,T.size()+1){
            if(i == 0 || j == 0)dp[i][j] = 0;
            else if(S[i-1] == T[j-1])dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    string ans;
    for(int i = S.size(), j = T.size();i > 0 && j > 0;){
        if(S[i-1] == T[j-1]){
            ans = T[j-1] + ans;
            i--,j--;
        }else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    //cout << dp[S.size()][T.size()] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1030,M=1000000007;
string s[N];
int i,j,n,m,dp[N][N];
bool vis[N][N];
int play(int x,int y){
	if(x==n||y==m) return 0;
	if(s[x][y]=='#') return 0;
	if(vis[x][y]) return dp[x][y];
	vis[x][y]=true;
	if(x==n-1&&y==m-1) return dp[x][y]=1;
	return dp[x][y]=(play(x+1,y)+play(x,y+1))%M;
}
int main(){
	ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(NULL);
	cin>>n>>m;
	for(i=0;i<n;++i) for(j=0;j<m;++j) vis[i][j]=false;
	for(i=0;i<n;++i) cin>>s[i];
	cout<<play(0,0);
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
using namespace std;
int main(){
    int a = 0;
    int A[100] = {};
    
    while(true){
        int n, x, c;
        c = 0;
        cin >> n >> x;
        
        if(n == 0 && x == 0){
            break;
        } else {
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                    for(int k = 1; k <= n; k++){
                        if(i != j && i != k && j != k && i + j + k == x){
                            c += 1;
                        }
                    }
                }
            }
            A[a] = c/6;
            a += 1;
        }
    }
    
    for(int b = 0; b < a; b++){
        cout << A[b] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h> 
#define PII pair<int,int>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
int n,m;
const int N=2e5+10; 
int head[N],ne[N<<1],e[N<<1];
int cnt;
bool st[N];
int pre[N];
int dis[N];
priority_queue<PII,vector<PII>,greater<PII> > heap;
void add(int u,int v)
{
	e[cnt]=v,
	ne[cnt]=head[u],
	head[u]=cnt++;
}
void dijkstra()
{
	heap.push({0,1}); 
	dis[1]=0;
	while(heap.size())
	{
		pair<int,int> t=heap.top();
		heap.pop();
		int ver=t.second,distance=t.first;
		if(st[ver]) continue;
		st[ver]=1;
		for(int i=head[ver];i!=-1;i=ne[i])
		{
			int v=e[i];
			if(dis[v]>distance+1)
			{
				pre[v]=ver;
				dis[v]=distance+1;
				heap.push({dis[v],v});
			}
		}
	}
}
int main()
{
	memset(dis,INF,sizeof(dis));
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	int u,v;
	while(m--){
		cin>>u>>v;
		add(u,v);
		add(v,u);
	}
	dijkstra();
	for(int i=1;i<=n;i++)
	{
		if(dis[i]==INF)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<pre[i]<<endl;
	return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b, c; cin >> a >> b >> c;
    int sum = a + b + c, max_num = max(a, max(b, c));

    cout << (max_num == sum - max_num ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();

		if (a.charAt(0) == a.charAt(1) && a.charAt(1) == a.charAt(2) || a.charAt(1) == a.charAt(2) && a.charAt(2) == a.charAt(3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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


int main()
{
    string str;
    cin>>str;
    int n=str.length();
    if(str[n-1]=='s')
    {
        str+="es";
    }
    else
    {
        str+="s";
    }
    cout<<str<<endl;
    

    return 0;
}

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

typedef long long ll;

int gcd(
  ll A
  , ll B
)
{
  ll b = A;
  ll r = B;
  while (0 != b%r)
  {
    auto _r = b%r;
    b = r;
    r = _r;
  }
  return r;
}

int main()
{
  ll A, B;
  cin >> A >> B;
  auto min = ((A < B) ? A : B);
  auto max = ((A < B) ? B : A);
  cout << A*B/gcd(max, min);
  return 0;
}


Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 0usize;
  let mut cmax = 0usize;
  let mut h: HashMap<&usize, usize> = HashMap::new();
  for i in 0..N {
    *h.entry(&A[i]).or_insert(0usize) += 1usize;
    nmax = max(nmax, A[i]);
    cmax = max(cmax, *h.get(&A[i]).unwrap());
  }
  debug!(h, nmax, cmax);
  let mut mx = 0;
  let mut isprime = vec![true; nmax + 1];
  isprime[0] = false;
  isprime[1] = false;
  let mut i = 2;
  while i * i <= nmax {
    if isprime[i] {
      let mut j = 2;
      while i * j <= nmax {
        isprime[i * j] = false;
        j += 1;
      }
    }
    i += 1;
  }
  let mut pflag = true;
  for p in 2..=nmax {
    debug!(p);
    if isprime[p] {
      let mut f = 0usize;
      for q in 1..=nmax / p {
        let a = p * q;
        f += *h.get(&a).unwrap_or(&0);
      }
      mx = max(mx, f);
    }
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}
fn gcd(a: usize, b: usize) -> usize {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}
fn issetwise(A: Vec<usize>) -> bool {
  let mut a = A[0];
  for i in 1..A.len() {
    a = gcd(a, A[i]);
    if a == 1 {
      return true;
    }
  }
  return false;
}


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



int main() {
    int X; cin >> X;
    int N = 10000000;
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            if (i == X) {
                printf("%d\n", X);
                break;
            }
            else if (i > X) {
                printf("%d\n", i);
                break;
            }
        }
    }
}


Measured memory_bytes: 1408
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

#define debug(x,i,j) cout << #x << " " << #i << " " << #j << " " << x << " "<< i << " " << j<< endl

const double PI = 3.141592653589793;

void solve()
{
	int l,r;
	cin >> l >> r;
	if(r-l>=2019)
	{
		cout << "0";
		return ;
	}
	int ans = 2020 ;
	for(int i=l;i<r;i++)
	{
		for(int j=i+1;j<=r;j++)
		{
			ans = min(ans, (i*j)%2019);
		}
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3580
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
A = [int(i)-1 for i in input().split()]

mp={}
mp[0] = 1
hT = [0]
T = 0
ans = 0
for i,a in enumerate(A):
	T += a
	T %= M
	if i>=M-1:
		mp[hT[i-M+1]]-=1
	if T in mp.keys():
		ans += mp[T]
		mp[T] += 1
	else:
		mp[T] = 1
	hT.append(T)

print(ans)


Measured memory_bytes: 39456
import math
pi = math.pi

th = pi * 60.0 / 180.0
cos = math.cos(th)
sin = math.sin(th)

class Point():
    def __init__(self):
        self.x = 0.0
        self.y = 0.0
        
def koch(n, p1, p2):
    if n == 0:
        return None
    
    s = Point()
    t = Point()
    u = Point()
    
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0
    u.x = (t.x - s.x) * cos - (t.y - s.y) * sin + s.x
    u.y = (t.x - s.x) * sin + (t.y - s.y) * cos + s.y
    
    koch(n-1, p1, s)
    print(s.x, s.y)
    koch(n-1, s, u)
    print(u.x, u.y)
    koch(n-1, u, t)
    print(t.x, t.y)
    koch(n-1, t, p2)
    
def main():
       
    p1 = Point()
    p2 = Point()
    
    n = int(input())
    
    p2.x = 100
    
    print(p1.x, p1.y)
    koch(n, p1, p2)
    print(p2.x, p2.y)
    
    return 0
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5796
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B = inpl()
def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

def lcm(a,b):
	return a*b // gcd(a,b)

print(lcm(A,B))


Measured memory_bytes: 39020
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	long long h,w,limit,nw=0,nh=0,ans=0,n,m;
	long double l,lll,dans;
	llint anw, anh, ans2=0;
	char c;
	bool check=false,acheck=false;
	string s, rs,ss,rss,sss,rsss;
	cin >> l;
	lll = l / 3.0000000000000;
	dans = lll * lll * lll;
	cout <<fixed<<setprecision(12)<< dans << endl;
	
	please AC;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
#define PB push_back
const int N=5e3+10;
int main(){
    int n,m,l,r,d[N],nxt;
    vector<int> graph[N];
    queue<int> q;
    bool y=false;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)d[i]=0;
    while(m--){
        scanf("%d%d",&l,&r);
        graph[l].PB(r);
        d[r]++;
    }
    for(int i=1;i<=n;i++)if(d[i]==0)q.push(i);
    while(!q.empty()){
        nxt=q.front();
        q.pop();
        printf("%d\n",nxt);
        y|=!q.empty();
        for(int i:graph[nxt]){
            d[i]--;
            if(d[i]==0)q.push(i);
        }
    }
    printf("%d\n",y?1:0);
}


Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll n; std::cin>>n;
    std::vector<ll> a;
    for(int i=0; i<n; ++i){
        ll b; std::cin>>b; a.push_back(b);
    }

    std::sort(a.begin(), a.end());

    std::vector<ll> d(a.back()+3, 0);
    for(int i=0; i<a.size(); ++i){
        ++d[a[i]];
    }

    ll cnt=0;
    for(int i=0; i<a.back()+1; ++i){
        ll buf = d[i] + d[i+1] + d[i+2];
        cnt = std::max(cnt, buf);
    }
    std::cout << cnt;
    return 0;
}


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

using namespace std;

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s >= d)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
	return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    vi cnt(4, 0);
    for (int i=0;i<3;i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
    }

    int num_odd = 0;
    for (int c : cnt) if (c %2 == 1) num_odd++;
    if (num_odd > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	int a[n];
	
	for (int i = 0; i < n; i++){
		
		cin >> a[i];
		
	}
	
	bool ans = true;
	
	for (int i = 0; i < n-1; i++){
		if (a[i] < a[i+1]){
			a[i+1]--;
		}
	}
	
	for (int i = 0; i < n-1; i++){
		if (a[i] > a[i+1]){
			ans = false;
		}
	}
	
	if (ans){
		cout << "Yes";
	} else {
		cout << "No";
	}
	
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main () {
  int K;
  scanf("%d",&K);
  char str[100];
  scanf("%s",str);
  int len = (int)strlen(str);
  if(len <= K){
    printf("%s",str);
  }
  else {
	for(int i = 0; K > i; i++){
	  printf("%c",str[i]);
    }
	printf("...");
  }
  return 0;
}


Measured memory_bytes: 1700
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i64, b: i64) -> i64 {
    fn gcd1(m: i64, n: i64) -> i64 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i64 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut m = gcd(a, b);

    let mut ans = 1;
    for i in 2..m {
        if i * i > m {
            break;
        }
        if m % i == 0 {
            ans += 1;
            while m % i == 0 {
                m = m / i;
            }
        }
    }
    if m > 1 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
def input():
    return sys.stdin.readline()[:-1]

import heapq

def insert(S, v):
    heapq.heappush(S, -v)

def extract(S):
    return -heapq.heappop(S)

S = []
while True:
    args = input().split()
    if args[0] == 'end':
        break
    elif args[0] == 'insert':
        insert(S, int(args[1]))
    else:
        print(extract(S))


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

int main(){
  int h,w;
  cin >> h >> w;
  string s[2010];
  for (int i=0; i<h; i++){
    cin >> s[i];
  }
  int a[2010][2010];
 
  for (int i=0; i<h; i++){
    int x = 0;
    for (int j=0; j<w; j++){
      if(s[i][j] == '.'){
        x++;
        a[i][j] += x;
      } else {
        x = 0;
      }
    }
  }

  for (int i=0; i<h; i++){
    int x = 0;
    for (int j=0; j<w; j++){
      if(s[i][w-1-j] == '.'){
        x++;
        a[i][w-1-j] += x;
      } else {
        x = 0;
      }
    }
  }
  
  for (int j=0; j<w; j++){
    int x = 0;
    for (int i=0; i<h; i++){
      if(s[i][j] == '.'){
        x++;
        a[i][j] += x;
      } else {
        x = 0;
      }
    }
  }
  
  for (int j=0; j<w; j++){
    int x = 0;
    for (int i=0; i<h; i++){
      if(s[h-1-i][j] == '.'){
        x++;
        a[h-1-i][j] += x;
      } else {
        x = 0;
      }
    }
  }
  
  int m=0;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      m = max(m, a[i][j]-3);
    }
  }
  cout << m;
}

Measured memory_bytes: 20096
from collections import defaultdict

def calc_dp(ans_data, num, toru):
    key_list = min(max(ans_data.keys()) + 1, toru)
    jissai = max(ans_data.keys())

    for key_num in range(key_list)[::-1]:
        if key_num >= toru:
            continue
        if key_num == key_list - 1 and jissai != toru:
            ans_data[key_num + 1] = ans_data[key_num] + num
        else:
            ans_data[key_num + 1] = max(ans_data[key_num + 1], ans_data[key_num] + num)
    return ans_data



def main():
    num, toru = map(int, input().split())

    ans_data = [defaultdict(int) for i in range(8)]
    for i in range(8):
        ans_data[i][0] = 0

    for _ in range(1, num + 1):
        data = list(map(int, input().split()))

        a = data[0] + data[1] + data[2]
        b = data[0] + data[1] - data[2]
        c = data[0] - data[1] + data[2]
        d = data[0] - data[1] - data[2]
        e = -1 * data[0] + data[1] + data[2]
        f = -1 * data[0] + data[1] - data[2]
        g = -1 * data[0] - data[1] + data[2]
        h = -1 * data[0] - data[1] - data[2]
        data_list = [a, b, c, d, e, f, g, h]

        for i in range(8):
            ans_data[i] = calc_dp(ans_data[i], data_list[i], toru)

    ans = 0
    for i in range(8):
        if ans < ans_data[i][toru]:
            ans = ans_data[i][toru]
    print(ans)

if __name__ == '__main__':
    main()

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

using ll = long long;
const ll MOD = 998244353;

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[0] * A[1] / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000
void sellSort(int *A,int n);
void insertionSort(int *A,int n, int g);
int cnt;
int m=7;
int main(){
  int i,j,n,A[N];
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  
  
  sellSort(A,n);
  
 
  
  return 0;
  
}

void sellSort(int *A,int n){
  int i,j=0,G[]={1093,364,121,40,13,4,1};
  
  cnt = 0;
  if(n<1093)j++;
  if(n<364)j++;
  if(n<121)j++;
  if(n<40)j++;
  if(n<13)j++;
  if(n<4)j++;
  
  for(i=j;i<m;i++){
    
    insertionSort(A,n,G[i]);
  }
  printf("%d\n",m-j);
  
  for(i=j;i<m;i++){
    if(i<m-1)
      printf("%d ",G[i]);
    else
      printf("%d\n",G[i]);
  }
  printf("%d\n",cnt);
  for(i=0;i<n;i++)printf("%d\n",A[i]);
  
  
}


void insertionSort(int *A,int n, int g){
  int i,j,v;
  
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g] = A[j];
      j=j-g;
      cnt++;
      
    }
    A[j+g] = v;
  }
}

Measured memory_bytes: 4504
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1

if __name__ == "__main__":
    s = int(sys.stdin.readline())
    cnt = 0
    nums = set()
    while True:
        nums.add(s)
        cnt += 1
        s = f(s)
        if s in nums:
            #print(nums)
            print(cnt + 1)
            exit()



Measured memory_bytes: 5348
<?php
fscanf(STDIN,"%d %d",$sheets,$total);

// 1万 5千 千
// 9000z = 10000*$sheets -$total - 5000y
// 9z    = 10*$sheets  -$total/1000 - 5y

$find = "No";
//$yを変化させて代入していく
for ($i = 0; $i <= $sheets ; $i++)
{
    $amari = (10*$sheets - $total/1000 - 5*$i) % 9;
    $syou = (10*$sheets - $total/1000 - 5*$i) / 9;
    if( $amari == 0 && $syou >= 0 && $syou <= $sheets )
    {
        $y = $i;
        $z = $syou;
        $x = $sheets -$y - $z;
        if ($x >= 0)
        {
            $find = "Yes";
            break;
        }
    }
}

if ( $find == "Yes" )
{
    echo $x," ",$y," ",$z,"\n";
}
else
{
    echo "-1 -1 -1\n";
}
?>


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;

void solve() {
    int N; cin >> N;
    vector<Tuple> ps(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        ps[i] = make_tuple(x, y, i);
    }
    dsu uf(N);
    rep(_, 2) {
        sort(ps.begin(), ps.end());
        set<P> st;
        auto[x, y, id] = ps[0];
        st.emplace(y, id);
        for(int i = 1; i < N; ++i) {
            auto[x, y, id] = ps[i];
            auto [mn, mid] = *st.begin();
            if(mn < y) uf.merge(mid, id);
            else mn = y, mid = id;
            auto it = st.lower_bound({y, id});
            if(it != st.begin()) {
                it = prev(it);
                assert(it->first < y);
                uf.merge(id, it->second);
            }
            st.insert({y, id});
        }
        rep(i, N) {
            auto[x, y, id] = ps[i];
            ps[i] = make_tuple(-x, -y, id);
        }
    }
    rep(i, N) cout << uf.size(i) << '\n';
}

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


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

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }
  else{
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}
  
    

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int  a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,a,b,c,d,e,x,y,X,Y;
  char max;

    while(1){
      scanf("%d %d\n%d %d\n%d %d\n%d %d\n%d %d",&a1,&a2,&b1,&b2,&c1,&c2,&d1,&d2,&e1,&e2);
      
      if(a1==0||a2==0)break;
      
      a=a1+a2;
      b=b1+b2;
      c=c1+c2;
      d=d1+d2;
      e=e1+e2;

      if(a>b){
	x=a;
      }else if(a<b){
	x=b;
      }
      if(c>d){
	y=c;
      }else if(c<d){
	y=d;
      }
      if(x>y){
	X=x;
      }else if(x<y){
	X=y;
      }
      if(X>e){
	Y=X;
      }else if(X<e){
	Y=e;
      }

      if(Y==a){
	max='A';
      }else if(Y==b){
	max='B';
      }else if(Y==c){
	max='C';
      }else if(Y==d){
	max='D';
      }else if(Y==e){
	max='E';
      }
      
      printf("%c %d\n",max,Y);
    }
    return 0;
}
      

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int n;
  cin>>n;
  REP(i,101){
    if( 4*i>n ) break;
    if( (n-4*i)%7==0 ) return cout<<"Yes"<<endl,0;
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=502;
int n,M,i,j,k,L[N],R[N],o,t;
ll f[N][N],Ans;
struct Uzi{
    int id,u,v;
    bool operator<(const Uzi &k)const{
        if(u!=k.u)
            return u<k.u;
        return v<k.v;
    }
}p[N];
void init(){
    scanf("%d%d",&n,&M);
    for(i=0;i<2*n;i++){
        L[i]=R[i]=-1;
        for(j=0;j<2*n;j++)
            if(n*n<=i*i+j*j&&i*i+j*j<=n*n*4){
                if(L[i]==-1)
                    L[i]=j;
                R[i]=j;
            }
        if(i<n)
            p[i+1]=(Uzi){i,L[i]-1,R[i]};
        else
            p[i+1]=(Uzi){i,R[i],L[i]};
    }
    sort(p+1,p+2*n+1);
}
void work(){
    for(k=0;k<=n;k++){
        memset(f,0,sizeof(f));
        f[0][0]=1;
        t=0;
        for(i=1;i<=n*2;i++){
            o=p[i].id;
            for(j=0;j<=k;j++){
                if(o>=n){
                    f[i][j]=f[i-1][j]*(R[o]+1-t-j)%M;
                }
                else{
                    f[i][j]=f[i-1][j]*(R[o]+1-(2*n-1-o)-(k-j))%M;
                    if(j&&L[o]>t+j-1)
                        f[i][j]=(f[i][j]+f[i-1][j-1]*(L[o]-t-j+1))%M;
                    
                }
            }
            if(o>=n)
                t++;
        }
        Ans=(Ans+f[n*2][k]*(k%2?-1:1)+M)%M;
    }
    printf("%lld",Ans);
}
int main(){
    init();
    work();
    return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  string w;
  cin>>w;
  map<char,int>m;
  for(int i=0;i<w.size();i++){
    m[w[i]]++;
  }
  bool flg=true;
  for(auto it:m){
    if(it.second%2)flg=false;
  }
  if(flg)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


Measured memory_bytes: 256