akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};
use std::cmp::max;
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize
    }
    let mut info = vec![vec![]; n];
    for i in 0..n {
        input! {
            a: usize
        }
        for _ in 0..a {
            input! {
                p: usize,
                tf: usize
            }
            info[i].push((p - 1, tf));
        }
    }

    let mut res = 0;
    for bit in 0usize..(1 << n) {
        let mut can = true;
        for i in 0..n {
            //仮定した正直者だけ発言に矛盾がないか吟味する
            if bit & (1 << i) != 0 {
                for (p, tf) in info[i].iter() {
                    //もし矛盾していたらその組み合わせは没
                    if !((*tf == 0 && (bit & (1 << *p)) == 0)
                        || (*tf == 1 && (bit & (1 << *p)) != 0))
                    {
                        can = false;
                    }
                }
            }
        }

        if can {
            res = max(res, bit.count_ones());
        }
    }

    println!("{}", res);
}


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

namespace MinCostFlow{
	const int inf=1145141919;
	struct Edge{
		int to,rev,cost,cap;
	};
	vector<vector<Edge>> g;
	int n;
	vi h,dist,prevv,preve;
	void Init(int _n){
		n=_n;
		g.assign(n,vector<Edge>());
		h.assign(n,0);
		dist.assign(n,0);
		prevv.assign(n,0);
		preve.assign(n,0);
	}
	void AddEdge(int from,int to,int cost,int cap){
		g[from].PB({to,(int)g[to].size(),cost,cap});
		g[to].PB({from,(int)g[from].size()-1,-cost,0});
	}
	pii go(int s,int t,int f){
		priority_queue<pii,vector<pii>,greater<pii>> q;
		fill(dist.begin(),dist.end(),inf);
		dist[s]=0;
		q.push(MP(0,s));
		while(!q.empty()){
			int v=q.top().second,d=q.top().first;q.pop();
			if(dist[v]<d)
				continue;
			REP(i,(int)g[v].size()){
				Edge e=g[v][i];
				if(e.cap>0){
					int w=dist[v]+e.cost+h[v]-h[e.to];
					if(w<dist[e.to]){
						dist[e.to]=w;
						q.push(MP(w,e.to));
						prevv[e.to]=v;
						preve[e.to]=i;
					}
				}
			}
		}
		if(dist[t]==inf)
			return MP(0,0);
		REP(i,n)
			h[i]+=dist[i];
		int d=f;
		for(int v=t;v!=s;v=prevv[v])
			chmin(d,g[prevv[v]][preve[v]].cap);
		for(int v=t;v!=s;v=prevv[v]){
			Edge& e=g[prevv[v]][preve[v]];
			e.cap-=d;
			g[e.to][e.rev].cap+=d;
		}
		return MP(d,d*h[t]);
	}
	pii Calc(int s,int t,int f){
		REP(i,n)
			for(auto e:g[i])if(e.cap>0)
				chmin(h[e.to],h[i]+e.cost);
		int z=-h[n-1];
		int res=0;
		while(f>0){
			pii w=go(s,t,f);
			f-=w.first;
			res+=w.second;
		}
		return MP(res,z);
	}
}

int main(){
	int n=read(),m=read();
	MinCostFlow::Init(n+2);
	MinCostFlow::AddEdge(0,1,0,m);
	MinCostFlow::AddEdge(n,n+1,0,m);
	REP(i,m){
		int x=read()+1,y=read()+1,s=read();
		MinCostFlow::AddEdge(x,y,-s,MinCostFlow::inf);
		MinCostFlow::AddEdge(0,y,-s,1);
		MinCostFlow::AddEdge(x,n+1,0,1);
	}
	pii ans=MinCostFlow::Calc(0,n+1,m*2);
	cout<<ans.first+m*ans.second<<endl;
}

Measured memory_bytes: 3324
#include<cstdio>
using namespace std;
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		while (!(x&1)) x>>=1,ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> F(M);         //i+1番目の食べ物が好きな人の人数
  int count = 0;                    //条件一致数

  for(int i = 0; i < N; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int food;
      cin >> food;
      F[food-1]++;
    }
  }

  for(int i = 0; i < M; i++)
    if(F[i] == N)  count++;

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

vector<int> a;
int n;

map<int,int> table;

int dfs(int index,int val){
	if(index==n){
		table[val]+=1;
		return 0;
	}
	dfs(index+1,val);
	dfs(index+1,val+a[index]);
	return 0;
}


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	in(n);
	a.resize(n);
	in(a);
	int q;
	in(q);
	dfs(0,0);
	rep(i,q){
		int mi;
		in(mi);
		table[mi]+=0;
		if(table[mi]==0)out("no");
		else out("yes");
	}
	return 0;
}



Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

struct P {
  int L, R;
};
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int N, M;
  cin >> N >> M;
  vector<P> X(M);
  rep(i, M) cin >> X[i].L >> X[i].R;
  int super_left {};
  int super_right {N};
  rep(i, M) {
    maxs(super_left, X[i].L);
    mins(super_right, X[i].R);
  }
  if (super_left <= super_right) {
    cout << super_right - super_left + 1 << '\n';
  } else {
    cout << '0' << '\n';
  }
}


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

const int N = 200005;

int n;
int a[N];

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

  sort(a, a + n);

  long long ans = a[n-1];
  for (int i = 2; i < n; ++i) {
    ans += a[n - i/2 - 1];
  }

  printf("%lld\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 4536
#inputは文字列として取得
input1=input()
input2=input()
#splitする必要がある
input2=input2.split(" ")

N=int(input1)
D=[int(s) for s in input2]

ans=None


if D.count(0)==1 and D[0]==0:

    L=[0]*(max(D)+1)

    for i in range(len(D)):
        L[D[i]]+=1

    mul=1

    for i in range(len(L)-1):
        mul*=L[i]**L[i+1]%998244353
    
    ans=mul%998244353

else:
    ans=0

print(int(ans))

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

#define LOOP(val,times) for(val = 0;val < (times);++val)

int dp[1010][1010];

int lcs(string X, string Y){
    int i,j;
    LOOP(i,1010){
        dp[0][i] = i;
        dp[i][0] = i;
    }
    LOOP(i,Y.size()){
        LOOP(j,X.size()){
            if(X[j] == Y[i]){
                dp[i+1][j+1] = min(dp[i][j],min(dp[i+1][j]+1,dp[i][j+1]+1));
            }
            else{
                dp[i+1][j+1] = min(dp[i][j+1]+1,min(dp[i+1][j]+1,dp[i][j]+1));
            }
        }
    }
    return dp[Y.size()][X.size()];    
}

int main(){
    int i;
    string X,Y;
    cin >> X >> Y;
    cout << lcs(X,Y) << endl;
    int k;cin >> k;
}


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

	 
int main()
{
	string s; cin >> s;
	bool ok = true;
	if (s.size() % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		for (int i = 0; i < s.size() - 1; i += 2) {
			if (s[i] != 'h' || s[i + 1] != 'i') {
				ok = false;
			}
		}
		if (ok) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
		return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    A.push_back(INF);
    sort(all(A));
    reverse(all(A));
    A.push_back(-INF);
    
    bool ans=true;
    
    int now=0;
    while(1){
        if(now+1<A[now+2]) now++;
        else{
            int a=A[now+1]-now-1,b=0;
            while(now<A[now+b+2]){
                b++;
            }
            if(a%2==0&&b%2==0) ans=false;
            break;
        }
    }
    
    if(ans) cout<<"First\n";
    else cout<<"Second\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	string S;
	cin>>S;
	char ch=S[0];
	int ans=1;
	for (int i=1;i<N;i++){
		if (ch!=S[i]){
			ans++;
			ch=S[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    vector<string> s(3);
    for(int i=0; i<3; ++i)
        cin >> s[i];
    sort(s.begin(), s.end());

    int ans = INT_MAX;
    do{
        vector<vector<vector<bool> > > v(3, vector<vector<bool> >(3));
        for(int a=0; a<3; ++a){
            for(int b=a+1; b<3; ++b){
                v[a][b].assign(s[a].size(), true);
                for(unsigned i=0; i<s[a].size(); ++i){
                    unsigned n = min(s[a].size() - i, s[b].size());
                    for(unsigned j=0; j<n; ++j){
                        if(s[a][i+j] != '?' && s[b][j] != '?' && s[a][i+j] != s[b][j]){
                            v[a][b][i] = false;
                            break;
                        }
                    }
                }
            }
        }

        for(unsigned i=0; i<=s[0].size(); ++i){
            if(i < s[0].size() && !v[0][1][i])
                continue;
            for(unsigned j=i; ; ++j){
                if(j < s[0].size() && !v[0][2][j])
                    continue;
                if(j - i < s[1].size() && !v[1][2][j-i])
                    continue;
                ans = min(ans, (int)max({s[0].size(), i + s[1].size(), j + s[2].size()}));
                break;
            }
        }
    }while(next_permutation(s.begin(), s.end()));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);
int main(){
  int N,A,B,C,D;
  string S;
  bool ok=false,dam=true,damdam=false;
  cin>>N>>A>>B>>C>>D>>S;
  
  for(int i=A;i<max(C,D)-3;i++){
    if(S[i]=='#' && S[i+1]=='#'){
      dam=false;
      break;
    }
    if(i>B-3 && i<D-1 && S[i]=='.' && S[i+1]=='.' && S[i+2]=='.') damdam=true;
  }
    
    
  if(dam){
    if(C<D){
      ok=true;
    }
    /*else if(S[B-2]=='.' && S[B]=='.'){
      ok=true;
  }*/
    else if(damdam) ok=true;
  }
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
// E - ∙ (Bullet)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using PR = pair<ll,ll>;
using MP = map<PR,vi>;
#define MOD 1'000'000'007LL

// a^n mod m を計算する(繰り返し二乗法,二分累乗法:O(logn)) (再帰版)
ll modpow(ll a,ll n){return n?modpow(a*a%MOD,n/2)*(n%2?a:1)%MOD:1;}

int main(){
	int N; cin>>N;
	ll zero = 0;
	MP bad;
	while(N--){
		ll x,y; cin>>x>>y;
		if(x==0 && y==0){ zero++; continue; }
		ll g = gcd(x, y);
		x /= g, y /= g;
		if(y < 0) x = -x, y = -y;
		if(y==0 && x<0) x = -x, y = -y;
		int is_rotate90 = (x <= 0);
		if(is_rotate90){ swap(x, y); y = -y; }
		if(bad.count({x, y}) == 0) bad[PR(x, y)] = {0, 0};
		bad[PR(x, y)][is_rotate90]++;
	}

	ll ans = 1;
	for(auto x:bad){
		vi c = x.second;
		ans *= (modpow(2, c[0]) - 1) + (modpow(2, c[1]) - 1) + 1;
		ans %= MOD;
	}

	ans += zero - 1;
	ans = (ans + MOD) % MOD;
	cout<< ans <<endl;
}


Measured memory_bytes: 25396
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());
    reverse(vs.begin(), vs.end());
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += vs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	T, A := float64(sc.NextInt()), float64(sc.NextInt())
	H := sc.NextIntArray()

	index := 0
	mn := abs(A - (T - float64(H[0])*0.006))
	for i := 0; i < N; i++ {
		v := abs(A - (T - float64(H[i])*0.006))

		if mn > v {
			mn = v
			index = i
		}
	}
	fmt.Println(index + 1)

}

func abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
def solve():
	n=int(input())
	arr=[int(i) for i in input().split()]
	#arr=list(set(arr))
	arr.sort()
	count=0
	for i in range(len(arr)):
		for j in range(i+1,len(arr)):
			for k in range(j+1,len(arr)):
				if(arr[i]+arr[j]>arr[k]):
					if(arr[i]!=arr[j] and arr[j]!=arr[k]):
						count+=1
					
	print(count)




	


	   
	    
	
	
#test=int(input())
test=1
while test:

	solve()
	test-=1    
    
    
    
        

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int main() {
  int X;
  scanf("%d", &X);
  int r = 0;
  while (r * (r+1) / 2 < X) ++r;
  printf("%d\n", r);
}


Measured memory_bytes: 256
def examB():
    N = I()
    A = [I() for _ in range(N)]
    d = defaultdict(int)
    for i in A:
        d[i] +=1
    ans = len(d)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

long long int check(long long int n){
    if(n==1)
    return 1;
    else
    return 1+2*check(n/2);
}
int main() {
	long long int n;
	cin>>n;
	if(n==1)
	cout<<"1";
	else
	cout<<check(n);
	return 0;
}

Measured memory_bytes: 256
# Heron
module Heron
  def self.calc(a, b, c)
    s = (a + b + c) * 0.5
    Math.sqrt(s * (s - a) * (s - b) * (s - c))
  end
end

def dist(x1, y1, x2, y2)
  Math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
end

def ccw(p1, p2, p3)
  dx1 = p2[0] - p1[0]
  dy1 = p2[1] - p1[1]
  dx2 = p3[0] - p1[0]
  dy2 = p3[1] - p1[1]

  cross_product = dx1 * dy2 - dy1 * dx2

  if cross_product < 0
    return -1
  elsif cross_product > 0
    return 1
  else
    return 0
  end
end

points = []

while line = gets
  points << line.chomp.split(',').map(&:to_f)
end

# sort by lower y-cordinate
points.sort! do |a, b|
  if a[1] == b[1]
    a[0] <=> b[0]
  else
    a[1] <=> b[1]
  end
end

# sort by polar angle with respect to base of points[0]
points[1...points.size] = points[1...points.size].sort! do |a, b|
  -ccw(points[0], a, b)
end

s = 0
for i in 1...points.size - 1
  p1 = points[0]
  p2 = points[i]
  p3 = points[i + 1]
  s += Heron.calc(dist(p1[0], p1[1], p2[0], p2[1]), dist(p2[0], p2[1], p3[0], p3[1]), dist(p3[0], p3[1], p1[0], p1[1]))
end

puts sprintf('%0.6f', s)

Measured memory_bytes: 8740
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin. tie(0);
using namespace std;
typedef long long ll;
ll a,b,k,n,sum;
ll num[3];
int main()
{
sum=0;
rep(i,3)
{
  cin>>num[i];
  sum+=num[i];
}
sort(num,num+3);
cout<<sum-num[2]<<"\n";

}

Measured memory_bytes: 256
A, B, C, K = map(int, input().split())
sum = 0
ans = 0
add = max(0, min(K - sum, A))
sum += add
ans += add * 1
add = max(0, min(K - sum, B))
sum += add
ans += add * 0
add = max(0, min(K - sum, C))
sum += add
ans += add * (-1)
print(ans)


Measured memory_bytes: 61660
def calc_cost(height1, height2):
    return abs(height1 - height2)


def main(dest, heights):
    costs = list()
    costs.append(0)
    costs.append(calc_cost(heights[0], heights[1]))
    for i in range(2, dest):
        cost_from_pre2 = calc_cost(heights[i - 2], heights[i]) + costs[i - 2]
        cost_from_pre1 = calc_cost(heights[i - 1], heights[i]) + costs[i - 1]
        costs.append(min(cost_from_pre2, cost_from_pre1))
    return costs[dest - 1]


if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x; cin >> x;
    // m*11 <= x
    ll ans = (x/11)*2;
    ll acc = (ans/2)*11;
    if(acc < x){
        acc += 6;
        ans++;
    }
    if(acc < x){
        acc += 5;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1], K = ip[2];
	auto friendUF = new UnionFind!int(N);
	int[][] farr = new int[][](N, 0);
	int[][] barr = new int[][](N, 0);

	debug farr.writeln;
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), A = ip2[0], B = ip2[1];
		friendUF.unite(A-1, B-1);
		debug writefln("%d %d", A, B);
		farr[A-1] ~= B-1;
		farr[B-1] ~= A-1;
	}
	foreach(i; 0..K) {
		auto ip3 = readAs!(int[]), C = ip3[0], D = ip3[1];
		barr[C-1] ~= D-1;
		barr[D-1] ~= C-1;
	}

	ulong[] res;
	foreach(i; 0..N) {
		auto n = farr[i].length;
		auto tmp = friendUF.size(i) - n;
		foreach(v; barr[i]) {
			if(friendUF.same(v, i)) tmp--;
		}
		res ~= (tmp - 1);
	}
	writefln("%(%d %)", res);
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 26620
N,K =map(int,input().split())
h = list(map(int,input().split()))+[0]*K
inf = float('inf')
dp= [inf for _ in range(N+100)]
dp[0]=0#初期値
f = lambda a,b:abs(b-a)
for i in range(N):
    for j in range(1,K+1):
        #iからk個前へ飛んだ場合
        dp[i+j]=min(dp[i+j],dp[i]+f(h[i],h[i+j]))
print(dp[N-1])

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

int main(void) {

	int n,m,l;
	cin >> n >> m >> l;

	int A[n][m];
	int B[m][l];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			cin >> A[i][j];
		}
	}

	for(int i=0;i<m;i++) {
		for(int j=0;j<l;j++) {
			cin >> B[i][j];
		}
	}

	for(int i=0;i<n;i++) {
		for(int j=0;j<l;j++) {
			long long tmp = 0;
			for(int k=0;k<m;k++) {
				tmp += A[i][k] * B[k][j];
			}
			if(j != l-1) {
				cout << tmp << " ";
			} else {
				cout << tmp;
			}
		}
		cout << endl;
	}

}

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

int main (void){
  int n;
  cin >> n;
  vector<long> h(n);
  
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  
  int ok = 1;
  for(int i = 0; i < n - 2; i++){
    if(h[i] - h[i + 1] > 1){
      ok = 0;
      break;
    }
    else if(h[i] - h[i + 1] == 1){
      for(int j = i+2; j < n; j++){
        if(h[i+1] > h[j]){
          ok = 0;
          break;
        }
      }
    }
  }
  if(ok){
    cout << "Yes";
  } else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
 
 
#define TIMES(i) while(i--) 
#define REP(i, n) for ( int i = 0; i < n; i++ ) 
 
 
 using namespace std;
 
 int main() { 
     int n; 
     cin >> n; 
 
     TIMES(n) { 
         // ??\??? 
         double ax, ay, ar, bx, by, br; 
         cin >> ax >> ay >> ar >> bx >> by >> br; 
 
         // ?????¢????±??????? 
         double dis_x = abs(ax-bx), 
           dis_y = abs(ay-by), 
             dist = sqrt(dis_x * dis_x + dis_y * dis_y); 
 
         // cout << dis_x << " " << dis_y << " " << dist << endl; 
 
         // ??¢???????????? 
         if ( dist > ar + br ) { 
             cout << 0; 
 
         // a???????????????????????? 
         } else if ( dist + ar < br ) { 
             cout << -2; 
 
         // b???????????????????????? 
         } else if ( dist + br < ar ) { 
             cout << 2; 
 
         // ????????£????????? 
         } else { 
             cout << 1; 
         } 
         cout << endl; 
     } 
 
 
     return 0; 
 } 

Measured memory_bytes: 1232
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

#define CITY_NUM 51
static vector<uint32_t> roads[CITY_NUM];

int32_t main()
{
  uint32_t city_num, road_num;
  cin >> city_num >> road_num;

  for (uint32_t i = 0; i < road_num; i++) {
    uint32_t a, b;
    cin >> a >> b;
    roads[a].push_back(b);
    roads[b].push_back(a);
  }

  for (uint32_t i = 1; i <= city_num; i++) {
    cout << roads[i].size() << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> T MV(T v) { return v; }
template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); }

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	auto a = MV(0, 3, 3);
	cin >> a;
	IN(int, n);
	vector<int> b(n);
	cin >> b;
	bool ans = false;
	inc(i, 3) {
		bool f = true;
		inc(j, 3) { f &= (count(ALL(b), a[i][j]) > 0); }
		ans |= f;
	}
	
	inc(j, 3) {
		bool f = true;
		inc(i, 3) { f &= (count(ALL(b), a[i][j]) > 0); }
		ans |= f;
	}
	
	{
		bool f = true;
		inc(i, 3) { f &= (count(ALL(b), a[i][i]) > 0); }
		ans |= f;
	}
	
	{
		bool f = true;
		inc(i, 3) { f &= (count(ALL(b), a[i][2 - i]) > 0); }
		ans |= f;
	}
	
	OUT(ans ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int k;
	cin>>k;
	
	long long ans=0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int u=1; u<=k; u++){
				ans+=__gcd(i,__gcd(j,u));
			}
		}
	}
	cout<<ans;
	

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
  int k[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  
  scanf("%d", &n);
  printf("%d", k[n - 1]);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int res;
    while (n > 0)
    {
        if (n % 10 == 1)
            res++;
        n /= 10;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    from itertools import combinations

    _ = int(input())
    *L, = map(int, input().split())
    L.sort(reverse=True)

    cnt = 0
    for comb in combinations(L, r=3):  # 降順維持
        cond = all([
            len(set(comb)) == 3,
            sum(comb) - comb[0] * 2 > 0
        ])
        if cond:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    vector<long long> ans(N);
    multiset<long long> set;
    REP(i, N) set.insert(a[i]);

    long long max_a = 0;
    REP(i, N){
        if(a[i] > max_a){
            auto itr = set.begin();
            while(itr != set.end() and *itr <= a[i]){
                ans[i] += *itr-max_a;
                set.erase(itr++);
            }
            ans[i] += set.size()*(a[i]-max_a);
            max_a = a[i];
        }
    }

    REP(i, N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<ll,ll>;
 
int main() {
    ll N;
    cin>>N;
    ll A[N];
    ll answer=0;
    rep(i,N){cin>>A[i];}
    for(int i=0;i<N-1;i++)
    {
      if(A[i]>A[i+1])
      {
        answer+=A[i]-A[i+1];
        A[i+1]+=A[i]-A[i+1];
      }
    }
    cout<<answer<<endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll gcd(ll a, ll b){
  if(a<b)
    return gcd(b,a);

  if(b==0)
    return a;

  return gcd(b, a%b);
}

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

  ll n,k;
  cin >> n >> k;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  sort(a.begin(), a.end());
  ll g = gcd(a[0],a[1]);
  REP(i,n){
    g = gcd(a[i], g);
  }

  if(k%g==0 && k<=a[n-1])
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;


}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace DPL_1_G
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]); int limit = int.Parse(s[1]);
            int[] v = new int[n]; int[] w = new int[n]; int[] m = new int[n];
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                v[i] = x[0]; w[i] = x[1]; m[i] = x[2];
            }
            int[] dp = new int[limit + 1];
            for (int i = 0; i < n; i++)
            {
                int num = m[i];
                for (int j = 1; num > 0; j <<= 1)
                {
                    int mul = Math.Min(j,num);
                    for (int k = limit; k >= w[i] * mul; k--)
                    {
                        dp[k] = Math.Max(dp[k],dp[k - w[i] * mul] + v[i] * mul);
                    }
                    num -= mul;
                }
            }
            Console.WriteLine(dp[limit]);
        }
    }
}


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

signed main(){
    int N;
  	string S;
    cin>>N>>S;
    int x=0;
    int ans=0;
    REP(i,N){
        if(S[i]=='I')x++;
        if(S[i]=='D')x--;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//atcoder ABC 174 F
//https://www.youtube.com/watch?v=h0MGG8rxrYc&t=5781s
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> pi(N+1, -1);//数字が出てきた位置
    vector<vector<int>> ps(N);//red arrow
    rep(i, N)
    {
        int l = pi[a[i]];
        if(l != -1) ps[l].push_back(i);
        pi[a[i]] = i;
    }


    vector<vector<P>> qs(N);
    rep(i, Q)
    {
        int l, r;
        cin >> l >> r;
        --l;--r;
        qs[l].emplace_back(r, i);
    }
    BIT<int> d(N);
    vector<int> ans(Q);
    for(int x = N-1 ; x >= 0 ; --x)
    {
        for(int y : ps[x]) d.add(y, 1);
        for(P query : qs[x])
        {
            int r = query.first, i = query.second;
            ans[i] = (r - x + 1) - d.sum(r);
        }
    }
    rep(i, Q)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 59748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll k,a,b;cin>>k>>a>>b;
	ll v=1,y=0;

	while(k){
		if(v>=a){
			if(b-a>2&&k>=2){
				v+=b-a;
				k-=2;
			}

			else{
				v++;
				k--;
			}
		}
		else {
			v++;
			k--;
		}
	}

	cout<<v<<endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
def print_ans(N):
    """Test Case
    >>> print_ans(4)
    1
    >>> print_ans(999999)
    499999
    """
    q, mod = divmod(N,2)
    if(mod == 0):
        print(q - 1)
    else:
        print(q)


if __name__ == '__main__':
    N = int(input().rstrip())
    print_ans(N)


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

const int mxN=2e6+7;
const ll MOD=1e9+7;
ll fact[mxN], inv[mxN], comb;
int k, n;
string s;

ll binpow(ll a, ll b) {
    a%=MOD;
    ll ans=1;
    while (b) {
        if (b&1)
            ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}

void getfacts() {
    fact[0]=inv[0]=1;
    for (int i=1; i<mxN; ++i) {
        fact[i]=(fact[i-1]*i)%MOD;
        inv[i]=binpow(fact[i], MOD-2);
    }
}

int main(void) {
    cin >> k >> s;
    n=s.size()+k;
    getfacts();
    comb=binpow(26, n);
    for (int i=0; i<s.size(); ++i) {
        ll buf=fact[n]*inv[i]%MOD;
        buf=(buf*inv[n-i])%MOD;
        buf=(buf*binpow(25, n-i))%MOD;
        comb=(MOD*MOD+comb-buf)%MOD;
    }
    cout << comb << '\n';
}


Measured memory_bytes: 35536
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll  primeFactors(ll n)
{
    set<ll>s;
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);

    return (ll)s.size()+1ll;
}
int main()
{
fast;
ll a,b;
cin>>a>>b;
ll n=__gcd(a,b);
cout<<primeFactors(n)<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5000*5000+100;
long long f[N];
void add(int w,int c)
{
	if(c<=0) return;
	for(int i=0;i<=5000*5000-w;i++)
	{
		f[i+w]=max(f[i+w],f[i]+c);
	}
	
}
int main()
{
	int n,ga,gb,sa,sb,ba,bb;
	cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
	memset(f,0,sizeof(f));
	add(ga,gb-ga);add(sa,sb-sa);add(ba,bb-ba);
	n=n+f[n];
	memset(f,0,sizeof(f));
	add(gb,ga-gb);add(sb,sa-sb);add(bb,ba-bb);
	cout<<n+f[n]<<endl;
	return 0;
}

Measured memory_bytes: 195584
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    tot=[[] for _ in range(N+1)]
    ys=[0]*M
    for i in range(N):
        heapify(tot[i])
    for i in range(M):
        P, Y = map(int, input().split())
        heappush(tot[P],[Y,i])
        ys[i]=Y
    tset=[]
    ans=['']*M
    for i in range(N+1):
        t1=tot[i]
        if len(t1)<1:continue
        p=str(i).zfill(6)
        j=0
        while len(t1):
            t, i1=heappop(t1)
            tx=str(j+1).zfill(6)
            ans[i1]=p+tx
            j+=1
    print('\n'.join(ans))





if __name__ == "__main__":
    main()

Measured memory_bytes: 89888
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }

int main() {
	int n, a, mina = INF, ans = -INF;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (i > 0) {
			ans = max(ans, a - mina);
		}
		mina = min(mina, a);
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

#define MAX 100005
#define forl(i, start, stop, step) for (int i = start; i < stop; i += step)
#define vi vector<int>
#define pb push_back

vi g1[MAX], g2[MAX];
int visited1[MAX], visited2[MAX], ans1[MAX], ans2[MAX];

int dfs1(int u) {
	visited1[u] = 1;
	int ret = 0;
	for (int v : g1[u]) {
		if (!visited1[v]) ret = max(ret, dfs1(v));
		else ret = max(ret, ans1[v]);
	}
	return ans1[u] = ++ret;
}

int dfs2(int u) {
	visited2[u] = 1;
	int ret = 0;
	for (int v : g2[u]) {
		if (!visited2[v]) ret = max(ret, dfs2(v));
		else ret = max(ret, ans2[v]);
	}
	return ans2[u] = ++ret;
}

int main() {
	int n, m, u, v; scanf("%d%d", &n, &m);
	forl(i, 0, m, 1) {
		scanf("%d%d", &u, &v);
		g1[u].pb(v);
		g2[v].pb(u);
	}
	int ans = 0;
	forl(i, 1, n + 1, 1) {
		if (!visited1[i]) ans = max(ans, dfs1(i));
	}
	forl(i, 1, n + 1, 1) {
		if (!visited2[i]) ans = max(ans, dfs2(i));
	}
	--ans;

	cout << ans;

	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    int a;
    int p = -1;
    ll ans = -1;
    Rep(i,N){
        Scd(a);
        if( a == p+1 ) ans++;
        else if( a <= p ) ans += a;
        else ans = -INF*INF;
        p = a;
    }

    printf ("%lld\n", ans >= 0 ? ans : -1 );

    return 0;
}



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

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

    string S; cin >> S;
    string a = S.substr(0, 2);
    string b = S.substr(2, 2);

    auto f = [](string s) {
        return s >= "01" && s <= "12";
    };

    if (!f(a) && f(b))
        cout << "YYMM\n";
    else if (f(a) && !f(b))
        cout << "MMYY\n";
    else if (f(a) && f(b))
        cout << "AMBIGUOUS\n";
    else
        cout << "NA\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
ll sum;
int main() {
    io();
    int n;
    cin >> n;
    while(n >= 500) {
        n = n - 500;
        sum += 1000;

    }

    while(n > 5) {
        n = n - 5;
        sum += 5;
    }
    cout << sum;

}
    

Measured memory_bytes: 256