akhauriyash/Code-Regression huggingface dataset:
'''
問題文
S: 文字列，英小文字
条件１（長さK以下）→Sをそのまま出力
条件２（長さK以上）→先頭K文字+'...'を出力

アルゴリズム
1. Sの文字数を取得(len(S))
2. Sの文字数とKを比較
2-a. if(len(S)<=K)Sを出力
2-b. if(len(S)>K)先頭K文字+'...'を出力，for文を使って先頭K文字の配列を作り直して'...'を結合し出力．

'''

K = int(input())
S = input()

if(len(S)<=K):
    print(S)
else:
    S_K = ''
    for i in range(K):
        S_K += S[i]
    print(S_K + '...')




Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int rec(int ind,int x,int ccost,vector<int>cskill,vector<int>&cost,vector<vector<int>>&skill){
    int n=cost.size();
    int m=cskill.size();
    // if(ccost==1067){
    //     for(int i=0;i<m;i++){
    //         cout<<cskill[i]<<" ";
    //     }
    //     cout<<endl;
    // }
    if(ind>=n){
        bool flag=true;
        for(int i=0;i<m;i++){
            if(cskill[i]<x){
                flag=false;
                break;
            }
        }
        if(flag)
            return ccost;
        else
            return INT_MAX;
    }
    int ans=rec(ind+1,x,ccost,cskill,cost,skill);
    for(int i=0;i<m;i++){
        cskill[i]+=skill[ind][i];
    }
    ccost+=cost[ind];
    return min(ans,rec(ind+1,x,ccost,cskill,cost,skill));
}

int main() {
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>>skill(n,vector<int>(m,0));
    vector<int>cost(n,0);
    for(int i=0;i<n;i++){
        cin>>cost[i];
        for(int j=0;j<m;j++){
            cin>>skill[i][j];
        }
    }
    vector<int>cskill(m,0);
    int ans=rec(0,x,0,cskill,cost,skill);
    if(ans==INT_MAX)
        cout<<-1;
    else
        cout<<ans;
    cout<<"\n";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         INT_MAX
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)

const int N=1e5+5;
bool dp[N];
ll n,a[N],k;

void solve() // nim game 
{
    cin>>n>>k;
    rep(i,1,n+1)cin>>a[i];
    dp[0]=0;    
    rep(i,1,k+1){
        rep(j,1,n+1){
            if(i<a[j]) break;
            dp[i]|=!dp[i-a[j]];
        }
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}

int main()
{
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int a;
  cin >> a;
  int vmax = a;
  int g = a;
  for (int i = 1; i < n; ++i) {
    cin >> a;
    g = __gcd(g, a);
    vmax = max(a, vmax);
  }
  cout << (k / g * g == k && k <= vmax ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 3604
import math
def is_prime(N):
    if 1 >= N:
        return False
    for i in range(2,int(math.sqrt(N) + 1)):
        if N % i == 0:
            return False
    return True
  
answer = 0
N = int(input())
for i in range(N):
  a  = int(input())   
  if is_prime(a):
        answer += 1
print(answer)


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

int main() {
	int n,l;
	cin>>n>>l;
	vector<int> a(n);
	bool found=false;
	int index;
	for(int i=0;i<n;i++) 
		cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]+a[i+1] >= l)
		{
			found=true;
			index=i+1;
			break;
		}
	}
	if(found)
	{
		cout<<"Possible\n";
		for(int i=1;i<index;i++)
			cout<<i<<"\n";
		for(int i=n-1;i>=index;i--)
			cout<<i<<"\n";
	}
	else
		cout<<"Impossible\n";
	return 0;
}

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

int memo[200100],h[200100],n,k;

int dp(int i){
if(i > n)
    return 2e9;
 
if(i==n){
    return 0;
}
    if(memo[i]!=-1)
        return memo[i];
 
        int res = 2e9;
 
for(int j=1; j<=k; j++){
res = min(res,abs(h[i]-h[i+j])+dp(i+j)) ;
}
 
return memo[i]=res;
}
 
int main()
{
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>h[i];
        memset(memo,-1,sizeof(memo));
    cout<<dp(1);
 
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
ll m[103][103][103] = {0};

ll dfs(int a,int b,int c){
	if(m[a][b][c]!=0) return m[a][b][c];
	if(a>100||b>100||c>100) return m[a][b][c] = INF;
	
	if(a==b&&b==c) return m[a][b][c] = 0;

	auto ans = 0;
	auto s0 = dfs(a+1,b+1,c)+1;
	auto s1 = dfs(a,b+1,c+1)+1;
  	auto s2 = dfs(a+1,b,c+1)+1;
	auto s3 = dfs(a+2,b,c)+1;
	auto s4 = dfs(a,b+2,c)+1;
	auto s5 = dfs(a,b,c+2)+1;
	
	ans = min({s0,s1,s2,s3,s4,s5});
	
	return m[a][b][c] = ans;
}
	
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << dfs(a,b,c);

}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

template<typename T>
struct Network{ //ネットワーク
private:
    int n, s, t;
    struct edge{
        int to, rev; T cap;
        edge(int t = 0, T c = 0, int r = 0) : to(t), cap(c), rev(r) {}
    };
    vector<vector<edge>> graph;
    vector<bool> used;
public:
    Network(int n) : n(n), graph(n), used(n) {}
    void addEdge(int from, int to, T cap){ //辺を追加する
        graph[from].push_back((edge){ to, cap, (T)graph[to].size() });
        graph[to].push_back((edge){from, 0, (T)(graph[from].size() - 1) });
    }
    T dfs(int v, T f){ //増加路をdfsで探す
        if(v == t)return f;
        used[v] = true;
        for(auto &e : graph[v]){
            if(!used[e.to] and e.cap > 0){
                T d = dfs(e.to, min(f, e.cap));
                if(d > 0){
                    e.cap -= d; graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    T max_flow(int s_, int t_){ //Ford-Fulkerson法
        s = s_; t = t_;
        T flow = 0;
        while(true){
            fill(all(used), 0);
            T f = dfs(s, (T)100000000000);
            if(f == 0)return flow;
            flow += f;
        }
    }
};

struct Point{
    int x, y;
    Point(int x = 0, int y = 0) : x(x), y(y) {}
    inline bool operator < (const Point& p) const {
        return x < p.x and y < p.y;
    }
};

int main(){

    int N;
    cin >> N;
    
    vector<Point> red(N), blue(N);
    rep(i, N){
        int x, y;
        cin >> x >> y;
        red[i] = Point(x, y);
    }
    rep(i, N){
        int x, y;
        cin >> x >> y;
        blue[i] = Point(x, y);
    }

    Network<int> net(2 * N + 2);
    rep(i, N)rep(j, N){
        if(red[i] < blue[j])net.addEdge(i, j + N, 1);
    }
    rep(i, N){
        net.addEdge(2 * N, i, 1);
        net.addEdge(i + N, 2 * N + 1, 1);
    }

    cout << net.max_flow(2 * N, 2 * N + 1) << endl;
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,k;
    cin >> n >> k;
    vector<long double> a(n+5,1);
    rep(i,n)cin >> a[i];
    vector<long double> rui(n+1,1);
    repp(i,1,n+1){
        long double f = log10(rui[i-1]);
        long double b = log10(a[i-1]);
        rui[i] = rui[i-1] + b ;
    }
    for(ll i = k+1;i <= n;i++){
        long double th = rui[i] - rui[i-k];
        long double be = rui[i-1] - rui[i-1-k];
        if(th > be)cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const long double PI = acos(-1);
const LL mod = 200003;
const int N = 800010;

inline LL power(LL a, LL n, LL mod)
{
	LL Ans = 1;
	while (n)
	{
		if (n & 1) Ans = Ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return Ans;
}

struct cmplx
{
	long double a, b;

	cmplx() { }
	cmplx(long double _1, long double _2) : a(_1), b(_2) { }

	cmplx operator + (cmplx & x) { return cmplx(a + x.a, b + x.b); }
	cmplx operator - (cmplx & x) { return cmplx(a - x.a, b - x.b); }
	cmplx operator * (cmplx & x) { return cmplx(a*x.a - b*x.b, b*x.a + a*x.b); }
};


struct Mul
{
	int Len, Bit;
	int rev[800010];

	void getReverse()
	{
		for (int i = 0; i < Len; i++)
			rev[i] = (rev[i>>1] >> 1) | ((i&1) * (Len >> 1));
	}

	void FFT(cmplx *a, int opt)
	{
		getReverse();
		for (int i = 0; i < Len; i++)
			if (i < rev[i]) swap(a[i], a[rev[i]]);
		
		for (int i = 2; i <= Len; i <<= 1)
		{
			cmplx wn(cos(2.0*PI/i), opt * sin(2.0*PI/i));
			for (int j = 0; j < Len; j += i)
			{
				cmplx w(1.0, 0);
				for (int k = 0; k < (i>>1); k++)
				{
					cmplx x = a[j + k];
					cmplx y = w * a[j + k + (i>>1)];
					a[j + k] = x + y;
					a[j + k + (i>>1)] = x - y;
					w = w * wn;
				}
			}
		}
		
		if (opt == -1)
			for (int i = 0; i < Len; i++) a[i].a /= Len;
	}

	int getLen(int l)
	{
		Len = 1;
		for (; Len <= l; Len <<= 1);
		return Len;
	}
} Calc;

int n;
int a[N];
int pw[400010], id[400010];
cmplx tmp[N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	
	pw[0] = 1;
	for (int i = 1; i < mod-1; i++)
	{
		pw[i] = 1LL * pw[i-1] * 2 % mod;
		id[pw[i]] = i;
	}
	
	int len = Calc.getLen((mod-1) * 2);
	for (int i = 1; i <= n; i++)
		if (a[i]) tmp[id[a[i]]].a += 1.0;
	Calc.FFT(tmp, 1);
	for (int i = 0; i < len; i++)
		tmp[i] = tmp[i] * tmp[i];
	Calc.FFT(tmp, -1);
	
	LL Ans = 0, x = 1;
	for (int i = 0; i < (mod-1) * 2; i++)
	{
		LL res = ((LL) (tmp[i].a + 0.5)) * x;
		x = x * 2LL % mod;
		Ans += res;
	}
	for (int i = 1; i <= n; i++) Ans -= 1LL * a[i] * a[i] % mod;
	Ans /= 2;
	cout << Ans << endl;
	
	return 0;
}

Measured memory_bytes: 24852
#include <iostream>
#include <iomanip>

int main()
{
	int a;
	while (std::cin >> a) {
		if (a%39 != 0) std::cout << "3C" << std::setw(2) << std::setfill('0') << a%39 << std::endl;
		else std::cout << "3C39" << std::endl;
	}
	return 0;
}



Measured memory_bytes: 2980
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(M)] 
p = list(map(int, input().split()))
ans = 0

for i in range(2 ** N):
    light = True

    flag = []
    for k in range(N):
        if ((i>>k)&1):
            flag.append(1)
        else:
            flag.append(0)

    for j in range(M):
        tmp = 0 
        for n in range(1, s[j][0] + 1):
            if flag[s[j][n] - 1] == 1:
                tmp += 1    
        if tmp % 2 != p[j] % 2:
            light=False
    if light:
	    ans += 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,cnt[100][100],ma2,ma5,ans1,ans2;

signed main(){
	read(n);
	for(int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		int y=floor(x*1e9+0.5),cnt2=0,cnt5=0;
		while(y%2==0) y/=2,cnt2++;
		while(y%5==0) y/=5,cnt5++;
		cnt[cnt2][cnt5]++;
		ma2=max(ma2,cnt2);
		ma5=max(ma5,cnt5);
	}
	for(int i=0;i<=ma2;i++) for(int j=0;j<=ma5;j++) if(cnt[i][j])
		for(int x=0;x<=ma2;x++) for(int y=0;y<=ma5;y++) if(cnt[x][y]&&min(i+x,j+y)>=18)
			i==x&&j==y?ans1+=cnt[i][j]*(cnt[i][j]-1)/2:ans2+=cnt[i][j]*cnt[x][y];
	write(ans2/2+ans1);
}

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

int main() {
    pair< int, pair<int,int> > p1, p2;

    cin >> p1.first >> p1.second.first >> p1.second.second;
    cin >> p2.first >> p2.second.first >> p2.second.second;

    if ( p1 > p2 ) swap( p1, p2 );
    
    if ( p1.second < p2.second ) cout << p2.first - p1.first + 1 << endl;
    else cout << p2.first - p1.first << endl;
    
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {

    int n;
    cin >> n;

    int *S = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    int q;
    cin >> q;

    int total = 0;
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        for (int j = 0; j < n; ++j) {
            if (x == S[j]) {
                ++total;
                break;
            }
        }
    }

    printf("%d\n", total);

    return 0;
}

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

int main(){
	int h, w; cin >> h >> w;
	vector<vector<char>> a (h+2, vector <char> (w+2)); 
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h+2; i++){
		for(int j = 0; j < w+2; j++){
			if(i == 0 || i == h+1 || j == 0 || j == w+1){
				cout << "#";
			}else{
				cout << a[i][j];			}
		}
		cout << endl;
	}
}

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


ll N,M;
string S,T;

ll gcd(ll u, ll v){
	int r;
  	while (0 != v) {
    	r = u % v; u = v; v = r; 
  	}
  	return u;
}

ll lcm(ll u, ll v){
	return u * v / gcd(u,v);
}

int solve(){
	ll X = gcd(M,N);
	ll Y = lcm(M,N);
	N /= X;
	M /= X;
	for(int i = 0; i < X; i++){
		if(S[N*i] != T[M*i]){
			cout << -1 << endl;
			return 0;
		}
	}
	printf("%lld\n", Y);
	return 0;
}

int main(){
	cin >> N >> M;
	cin >> S;
	cin >> T;
	solve();
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
template<typename T>
vector<int> get_pi(const T &a) {
  int n = a.size();
  vector<int> pi(n);
  int j = 0;
  for (int i = 1; i < n; i++) {
    while (j > 0 && a[i] != a[j]) j = pi[j - 1];
    j += ((a[i] == a[j]) ? 1 : 0);
    pi[i] = j;
  }
  return pi;
}

int32_t main()
{
	int n; cin >> n;
	string s,t; cin >> s >> t;
	t = t + "#" + s;
    auto pi = get_pi(t);
    cout << 2*n - pi.back();
    		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
double dp[3001][3001];
double calc_prob(int n, vector<double>&pH, ll HC, vector<vector<double>>&dp)
{
	if (HC == 0)
	{
		return 1;
	}
	if (n < 0)
	{
		return 0;
	}
	if (dp[n][HC] > -0.9)
	{
		return dp[n][HC];
	}

	double ans = pH[n] * calc_prob(n - 1, pH, HC - 1, dp) + (1 - pH[n]) * calc_prob(n - 1, pH, HC, dp);
	return dp[n][HC] = ans;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vector<double>pH(n);
	for (int i = 0; i < n; i++)
	{
		double f;
		cin >> f;
		pH[i] = f;
	}

	// for (int i = 0; i < n; i++)
	// {
	// 	for (int j = 0; j < (n + 1) / 2; j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	vector<vector<double>>dp(n + 1, vector<double>((n + 1) / 2 + 1, -1));
	cout << fixed << setprecision(10) << calc_prob(n - 1, pH, (n + 1) / 2, dp) << endl;
	return 0;
}

Measured memory_bytes: 38936
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let _ = readDouble()
    var aryV = readDoubles()
    //_______________________ここまで入力
    while aryV.count > 1 {
        aryV.sort(by: <)
        aryV.append((aryV[0] + aryV[1]) / 2)
        
        aryV.removeFirst(2)
    }
    
    print(aryV[0])
}
main()


Measured memory_bytes: 13468
#include <stdio.h>
int rot[5][7]={{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];
int tr['Z'];
void dice_init(int*a){
    int i;
    int t[5]={0,'N','E','W','S'};
    for(i=1;i<=6;i++)assign[i]=a[i];
    for(i=1;i<=4;i++)tr[t[i]]=i;}
    
char s[102];
int main (){
    int i,k1,k2;
    int a[7],dice[2][7];
    char*p;
    for(i=1;i<=6;i++)scanf("%d",a+i);
    dice_init(a);
    scanf("%s",p=s);
    for(i=1;i<=6;i++)dice[0][i]=rot[0][i];
    for(k1=0,k2=1;*p;k1=k2,k2=!k2){
        for(i=1;i<=6;i++)dice[k2][i]=dice[k1][rot[tr[*p]][i]];
        p++;
    }
    printf("%d\n",assign[dice[k1][1]]);
    return 0;
}



Measured memory_bytes: 2104
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,sum=0,i=1; cin>>n; 
    vector <int> res;
    while (sum<n){
        sum += i; i++;
    }
    i--;
    for (int j=1;j<=i;j++)
        if (sum-n != j) cout << j << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve(); 
    return 0;
}


Measured memory_bytes: 3572
#!/usr/bin/env python3

S = int(input())

if S == 1 or S == 2 or S == 4:
    print(4)
    exit()

e = S
cnt = 0
while True:
    if e % 2 == 0:
        v = e//2
    else:
        v = 3*e+1
    e = v
    cnt += 1
    if v == 4:
        print(cnt+4)
        exit()



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

const int LIM = 400;
set<int> occurs[LIM];

bool check(char c, int l, int r){
    return *(occurs[c].lower_bound(l)) <= r;
}

int query(int l, int r){
    int cnt = 0;
    for(int i='a'; i<='z'; i++) if(check(i, l, r)) cnt++;
    return cnt;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    string str;
    cin >> n >> str;
    
    for(int i=0; str[i]!='\0'; i++) occurs[str[i]].insert(i);
    for(int i='a'; i<='z'; i++) occurs[i].insert(n);
    
    int nq, op, a, b;
    char mander;
    cin >> nq;
    
    while(nq--){
        cin >> op;
        if(op == 1){
            cin >> a >> mander;
            a--;
            occurs[str[a]].erase(a);
            occurs[mander].insert(a);
            str[a] = mander;
        }
        else {
            cin >> a >> b;
            a--, b--;
            cout << query(a, b) << "\n";
        }
    }
    
	return 0;
}

Measured memory_bytes: 24220
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 709;

int g[N][N];
bool was[N];
int q[N];
int color[N];
int f[N][N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(g, 0, sizeof g);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    g[x][y] = 1;
    g[y][x] = 1;
  }
  memset(was, false, sizeof was);
  int cnt = 0;
  bool good = true;
  for (int i = 0; i < n; ++i) {
    if (was[i]) {
      continue;
    }
    ++cnt;
    was[i] = true;
    q[0] = i;
    int edges = 0;
    int qt = 1;
    for (int qh = 0; qh < qt; ++qh) {
      int x = q[qh];
      for (int y = 0; y < n; ++y) {
        if (g[x][y] == 0) {
          continue;
        }
        ++edges;
        if (!was[y]) {
          was[y] = true;
          q[qt++] = y;
        }
      }
    }
    if (edges != qt * (qt - 1)) {
      good = false;
    }
  }
  if (cnt >= 3) {
    puts("-1");
    return 0;
  }
  if (cnt == 2) {
    printf("%d\n", good ? m : -1);
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j != i) {
        g[i][j] = 1 - g[i][j];
      }
    }
  }
  memset(color, -1, sizeof color);
  vector<int> a, b;
  for (int i = 0; i < n; ++i) {
    if (color[i] != -1) {
      continue;
    }
    color[i] = 0;
    q[0] = i;
    int cnt0 = 0;
    int qt = 1;
    for (int qh = 0; qh < qt; ++qh) {
      int x = q[qh];
      if (color[x] == 0) {
        ++cnt0;
      }
      for (int y = 0; y < n; ++y) {
        if (g[x][y] == 0) {
          continue;
        }
        if (color[y] == -1) {
          color[y] = 1 - color[x];
          q[qt++] = y;
        } else
        if (color[y] == color[x]) {
          puts("-1");
          return 0;
        }
      }
    }
    a.push_back(cnt0);
    b.push_back(qt - cnt0);
  }
  const int inf = 1'000'000'000;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      f[i][j] = inf;
    }
  }
  f[0][0] = 0;
  int s = 0;
  for (int i = 0; i < (int)a.size(); ++i) {
    int va = a[i] * (a[i] - 1) / 2;
    int vb = b[i] * (b[i] - 1) / 2;
    for (int j = 0; j <= n; ++j) {
      if (j + a[i] <= n) {
        f[i + 1][j + a[i]] = min(f[i + 1][j + a[i]], f[i][j] + j * a[i] + (s - j) * b[i] + va + vb);
      }
      if (j + b[i] <= n) {
        f[i + 1][j + b[i]] = min(f[i + 1][j + b[i]], f[i][j] + j * b[i] + (s - j) * a[i] + va + vb);
      }
    }
    s += a[i] + b[i];
  }
  int ans = inf;
  for (int i = 0; i <= n; ++i) {
    ans = min(ans, f[(int)a.size()][i]);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 4224
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

#include <cmath>
#include <cstdio>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

const double PI = 3.14159265358979;

void
solve(vector<int>& ans, const vector<vector<int>> & graph)
{
	queue<int> q;
	q.push(0);
	ans[0] = 0;
	while (!q.empty())
	{
		int room = q.front();
		q.pop();
		for (int next : graph[room])
		{
			if (ans[next] >= 0)
			{
				continue;
			}
			ans[next] = room;
			q.push(next);
		}
	}
}

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

	vector<int> A(M);
	vector<int> B(M);

	vector<vector<int>> graph(N);
	vector<int> ans(N, -1);

	rep(i, M)
	{
		int a, b;
		cin >> a >> b;
		A[i] = a - 1;
		B[i] = b - 1;
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	solve(ans, graph);

	for (int hoge : ans)
	{
		if (hoge < 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < N; i++)
	{
		cout << ans[i] +1 << endl;
	}

	return 0;
}


Measured memory_bytes: 11736
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <cstring>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
ll num=0;
int n,a[105][105],b[105][105]={0};
int main()
{
    scanf("%d",&n);
    for(int i=0;i<=1;i++)
    {
        for(int j=0;j<n;j++)
            scanf("%d",&a[i][j]);
    }
    for(int i=0;i<n;i++)
    {
        int sum=0;
        for(int j=0;j<=i;j++)
            sum+=a[0][j];
        for(int j=i;j<n;j++)
            sum+=a[1][j];
        if(num<sum)num=sum;
    }
    printf("%lld\n",num);
    return 0;
}


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

int main(){
    int n;cin>>n;
    int k=0;
    for(int i=1;i<=n;++i){
        int tmp;cin>>tmp;
        if(tmp!=i)k++;
    }
    k<=2?cout<<"YES"<<endl:cout<<"NO"<<endl;
}



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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  string a, b;
  cin >> a >> b;
  int num = stoi(a + b);
  for (int i = 1; i <= sqrt(100100); i++) {
    if (i * i == num) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Monoid
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,q] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  edges <- VU.replicateM (n-1) $ do
    [a,b] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    return (a-1,b-1)
  operations <- VU.replicateM q $ do
    [p,x] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    return (p-1,x)
  let graph :: V.Vector [Int]
      graph = V.create $ do
        vec <- VM.replicate n []
        VU.forM_ edges $ \(a,b) -> do
          VM.modify vec (b:) a
          VM.modify vec (a:) b
        return vec
      values :: VU.Vector Int
      values = VU.create $ do
        vec <- VUM.replicate n 0
        VU.forM_ operations $ \(p,x) -> 
          VUM.modify vec (+ x) p
        return vec
      result :: VU.Vector Int
      result = VU.create $ do
        vec <- VUM.new n
        let dfs parent q acc = do
              let acc' = acc + values VU.! q
              VUM.write vec q acc'
              forM_ (graph V.! q) $ \i ->
                when (i /= parent) $
                  dfs q i acc'
        dfs (-1) 0 0
        return vec
  mapM_ print $ VU.toList result

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

int main() {
  ll N,K; cin >> N >> K;
  ll ans;
  if (K % 2 == 0) {
    ll a = N / K;
    ll b = N*2 / K;
    ans = pow(a,3) + pow(b-a,3);
  } else {
    ll a = N / K;
    ans = pow(a,3);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int x,y,z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
 */
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[500005];
ll color_table[500005];
char s[400004];
ll dmax, didx;

void dfs(ll v,ll p,ll color){
    ll usingcolor = 0;
    for(int i=0;i<tree[v].size();i++){
        ll edge = tree[v][i].second;
        ll nv = tree[v][i].first;
        if(nv == p)continue;
        usingcolor++;
        while(usingcolor == color)usingcolor ++;
        //pe("used color");p(usingcolor);
        color_table[edge] = usingcolor;
        dfs(nv, v, usingcolor);
    }
    return;
}


int main(){
    cin >> n;
    for(int i=0;i<n-1;i++){
        cin >> x[i] >> y[i];
        z[x[i]]++; z[y[i]]++;
        tree[x[i]].pb(P(y[i],i));
        tree[y[i]].pb(P(x[i],i));
    }
    dmax = 0;
    didx = -1;
    for(int i=1;i<=n;i++){
        if(z[i] >= dmax){
            dmax = z[i];
            didx = i;
        }
    }
    p(dmax);
    dfs(didx,-1, -1);
    for(int i=0;i<n-1;i++){
        assert(color_table[i] <= dmax);
        p(color_table[i]);
    }

   

    return 0;
    
}


















Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()

int main(){
  int N;cin>>N;
  vector<pii> task;
  for(int i=0; i<N; i++){
    int a,b;cin>>a>>b;
    task.push_back({b,a});//締め切り, 必要時間
  }
  sort(all(task));

  ll used = 0;

  for(auto x: task){
    //cout<<x.first<<","<<x.second<<endl;
    used += x.second;
    if(used > x.first){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> box(n, 0);
	int ans = 0;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	for(int i = n - 1; i >= 0; i--){
		int temp = 0;
		for(int j = i; j < n; j = j + (i+1)){
			temp += box.at(j);
		}
		if(temp % 2 != a.at(i)){
			box.at(i) += 1;
			ans++;
		}
	}
	
	cout << ans << endl;
	rep(i, n){
		if(box.at(i) % 2 == 1) cout << i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
using namespace std;
struct Point { double x, y; };

bool intersect(Point a, Point b, Point c, Point d) {
  return ((a.x - b.x) * (c.y - a.y) + (a.y - b.y) * (a.x - c.x)) * ((a.x - b.x) * (d.y - a.y) + (a.y - b.y) * (a.x - d.x)) < 0;
}

int main() {
  Point A, B, C, D;
  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y, &D.x, &D.y)) {
    if (intersect(A, C, B, D) && intersect(B, D, A, C)) puts("YES");
    else puts("NO");
  }
}


Measured memory_bytes: 2516
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}

		int min = a[0];
		int ans = -1001001001;
		for(int i = 1 ; i < n ; i++) {
			ans = Math.max(ans, a[i] - min);
			min = Math.min(min, a[i]);
		}
		System.out.println(ans);
	}
}

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

typedef long long int ll;
ll n, m, q, a, b, c, d;
vector<pair<pair<ll, ll>, pair<ll, ll>>> v;

int main() {
    cin >> n >> m >> q;
    for(ll i = 0; i < q; ++i) {
        cin >> a >> b >> c >> d;
        v.push_back(make_pair(make_pair(a, b), make_pair(c, d)));
    }

    queue<vector<ll>> q;
    q.push({1});

    ll res = 0;
    while(!q.empty()) {
        vector<ll> f = q.front();
        q.pop();
        //for(ll i = 0; i < f.size(); ++i) cout << f[i] << ' ';
        //cout << endl;

        if(f.size() == n) {
            ll cnt = 0;
            for(ll i = 0; i < v.size(); ++i) {
                if(f[v[i].first.second - 1] - f[v[i].first.first - 1] == v[i].second.first) cnt += v[i].second.second;
            }

            res = max(res, cnt);
        } else {
            for(ll i = f[f.size() - 1]; i <= m; ++i) {
                vector<ll> g(f);
                g.push_back(i);
                q.push(g);
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9440
#include <stdio.h>

int main()
{
    int i,k,j,count=0;
    scanf("%d",&k);
    for(i=1;i<=k;i++)
    {
        for(j=i+1;j<=k;j++)
        {
            if((i%2==0&&j%2!=0)||(i%2!=0&&j%2==0))
               count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef vector<PII > VPII;
typedef vector<VPII> VVPII;

#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))

int main(int argc, char** argv) {
#ifdef HOME
	freopen("in.txt", "rb", stdin);
	freopen("out.txt", "wb", stdout);
#endif
	int N, x;
	scanf("%d %d", &N, &x);
	LL ans = 0;
	VI a(N);
	REP(i,N)
		scanf("%d", &a[i]);
	int rem = min(a[0],x);
	ans = max<int>(a[0] - x, 0);
	FOR(i, 1,N)
	{
		int tmp = (a[i] + rem) - x;
		if (tmp >= 0)
		{
			ans += tmp;
			a[i] -= tmp;
		}
		rem = a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    int n; cin >> n;
    lint m; cin >> m;
    V<> l(n), r(n), v;
    for (int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        v.push_back(l[i]);
        v.push_back(r[i]);
    }
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
    for (auto&& e : l) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }
    for (auto&& e : r) {
        e = lower_bound(begin(v), end(v), e) - begin(v);
    }

    V<> c(v.size() + 1);
    for (int i = 0; i < n; ++i) {
        ++c[l[i]];
        --c[r[i] + 1];
    }
    for (int i = 0; i < (int)v.size(); ++i) {
        c[i + 1] += c[i];
    }
    lint res = 0;
    for (int i = 0; i < (int)v.size(); ++i) {
        lint curr = -1;
        if (c[i] & 1) {
            curr = m * (c[i] - 1) + v[i];
        } else {
            curr = m * (c[i] - 1) + m - v[i];
        }
        res = max(res, curr);
    }
    cout << res << '\n';
}


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

int n, arr[25], maxi, ans;

int main(){
	scanf("%d", &n);
	ans = 1;
	scanf("%d", &arr[0]);
	maxi = arr[0];

	for(int i = 1; i < n; i++){
		scanf("%d", &arr[i]);
		maxi = max(maxi, arr[i-1]);
		if(arr[i] >= maxi){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
#define pb push_back
#define X first
#define Y second
typedef pair<int, int> pii;
const int N = 1e5 + 100;
vector<pii> vec[N];
string ans[N];
int t[10];
string getstring(int x){
    int p = 0;
    for (int i = 0; i < 6; i ++) t[i] = 0;
    while (x){
        t[p ++] = x % 10;
        x /= 10;
    }
    string tmp = "";
    for (int i = 5; i >= 0; i --) tmp += '0' + t[i];
    return tmp;
}
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i ++){
        int p, y;
        scanf("%d%d", &p, &y);
        vec[p].pb(pii(y, i));
    }
    for (int i = 1; i <= n; i ++){
        sort(vec[i].begin(), vec[i].end());
        for (int j = 0; j < vec[i].size(); j ++){
            int r = j + 1;
            ans[vec[i][j].Y] = getstring(i) + getstring(r);
        }
    }
    for (int i = 1; i <= m; i ++) printf("%s\n", ans[i].c_str());
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<vector<lint>> dp1(n + 1, vector<lint>(t, 0));
    vector<vector<lint>> dp2(n + 1, vector<lint>(t, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
            dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i][j]);
            if (j + a[i] < t) {
                dp1[i + 1][j + a[i]] =
                    max(dp1[i + 1][j + a[i]], dp1[i][j] + b[i]);
                dp2[i + 1][j + a[i]] =
                    max(dp2[i + 1][j + a[i]], dp2[i][j] + b[i]);
            }
            dp2[i + 1][j] = max(dp2[i + 1][j], dp1[i][j] + b[i]);
        }
    }
    lint ans = 0;
    for (int i = 0; i < t; i++) {
        ans = max(dp1[n][i], ans);
        ans = max(dp2[n][i], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 141184
#include "bits/stdc++.h"
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long long dp[100][2];

int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];

	for (int i = 0; i < 100; ++i) dp[i][0] = dp[i][1] = -1;
	dp[0][0] = 0;
	for (int d = 0; d < 45; ++d) {
		long long mask = 1LL << (44-d);
		int num = 0;
		for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;

		if (dp[d][1] >= 0) chmax(dp[d + 1][1], dp[d][1] + mask * max(num, N - num));
		if (dp[d][0] >= 0) {
			if (K & (1LL << (44 - d))) {
				chmax(dp[d + 1][1], dp[d][0] + mask * num);
				chmax(dp[d + 1][0], dp[d][0] + mask * (N - num));
			}
			else {
				chmax(dp[d + 1][0], dp[d][0] + mask * num);
			}
		}
	}
	cout << max(dp[45][0], dp[45][1]) << endl;
}

Measured memory_bytes: 4060
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ

// メモ化再帰
int dp[100100];
int rec(int v) {
    if (dp[v] != -1) return dp[v]; // 既に更新済み
    
    int res = 0;
    for (auto nv : G[v]) {
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}


int main() {
    // 入力受け取り
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
    }
    
    // 初期化
    for (int v = 0; v < N; ++v) dp[v] = -1;
    
    // 全ノードを一通り更新しながら答えを求める
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, rec(v));
    cout << res << endl;
}


Measured memory_bytes: 8192
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct Edge{
	int to, id;
    Edge(int to = 0, int id = 0): to(to), id(id){}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;


	vector<vector<Edge>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, i);
		edges[v].emplace_back(u, i);
	}

	vector<int> ans(N - 1);
	auto dfs = [&](auto &&f, int now) -> void {

		set<int> used;
		for (const auto &e : edges[now]) if (ans[e.id]) used.emplace(ans[e.id]);
		
		int cnt = 1;
		for (const auto &e : edges[now]) {
			if (!ans[e.id]) {
				while (used.find(cnt) != used.end()) cnt++;
				ans[e.id] = cnt++;
				f(f, e.to);
			}
		
		}

	};

	dfs(dfs, 0);

	cout << *max_element(ans.begin(), ans.end()) << "\n";
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,k,m; cin >> n >> k >> m;
		if(n==0&&k==0&&m==0)break;
		vector<int> a(n);
		for(int i=0;i<n;i++){
			a[i]=i+1;
		}
		int now=m-1;
		a.erase(a.begin()+m-1);
		while(a.size()>1){
			now=(now+k-1)%a.size();
			a.erase(a.begin()+now);
		}
		printf("%d\n",a[0]);
	}
}


Measured memory_bytes: 3344
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	REP(i,n)cout<<s[i]<<t[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
ans = "Yes"
t = 0

for i in  range(len(ab)):
    t += ab[i][0]
    if t > ab[i][1]:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 53600
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
const int maxn=2e5+7;

int a[maxn];

int main()
{
//	freopen("input.txt","r",stdin);
	
	int n;
	cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i>0)
		{
			if(a[i]<a[i-1]) 
			{
				ans+=(a[i-1]-a[i]);
				a[i]=a[i-1];
			}
		}
	}
	cout<<ans; 
	
	return 0;
} 

Measured memory_bytes: 3980
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<cmath>

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    double n;
    cin >> n;

    double ans = n*2*M_PI;

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

Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
#define MAX 30
 
int N,C,dp[MAX][1<<16];
int a[MAX],b[MAX+1];
 
int solve(int cur,int p){
    if(cur == N) return 0;
    if(dp[cur][p] >= 0) return dp[cur][p];
    int res = 0;
    for(int i = 0 ; i < C ; i++){
	int S = (a[cur] | p) & b[i];
	int next = ((a[cur] | p) ^ b[i]) & (a[cur] | p);
	res = max(res,solve(cur+1,next) + __builtin_popcount(S));
    }
    return dp[cur][p] = res;
}
 
int main(){
    int in,S;
    while(cin >> N >> C,(N | C)){
	memset(dp,-1,sizeof(dp));
	for(int i = 0 ; i < N ; i++){
	    S = 0;
	    for(int j = 0 ; j < 16 ; j++){
		cin >> in;
		if(in){
		    S |= 1<<j;
		}
	    }
	    a[i] = S;
	}
	for(int i = 0 ; i < C ; i++){
	    S = 0;
	    for(int j = 0 ; j < 16 ; j++){
		cin >> in;
		if(in){
		    S |= 1<<j;
		}
	    }
	    b[i] = S;
	}
	cout << solve(0,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 10800
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,sm=0;
    cin>>n;
    map<string,ll> mp;
    string s;
    for(ll i=0;i<n;i++){
        cin>>s;
        sort(all(s));
        mp[s]++;
    }
    for(auto i:mp){
        ll j=i.second;
        sm+=j*(j-1)/2;
    }
    cout<<sm<<endl;
    return 0;
}

Measured memory_bytes: 11136