akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef vector <int> vi;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n;
    cin >> n;
    vector <vi> dp (n, vi (3)), hap (n, vi (3));
    // dp[i][j] felicidade maxima dia i, escolhendo j
    trav (v, hap)
        trav (a, v)
            cin >> a;
    for (i = 0; i < 3; ++i)
        dp[0][i] = hap[0][i];
    for (i = 1; i < n; ++i)
    {
        dp[i][0] = max (dp[i-1][1], dp[i-1][2]) + hap[i][0];
        dp[i][1] = max (dp[i-1][0], dp[i-1][2]) + hap[i][1];
        dp[i][2] = max (dp[i-1][0], dp[i-1][1]) + hap[i][2];
    }
    cout << max (dp[n-1][0], max (dp[n-1][1], dp[n-1][2])) << '\n';

    return 0;
}


Measured memory_bytes: 11264
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val t = sc.nextLine()
    val n = s.length
    var count = 0
    for (i in 0 until n) {
        if (s[i] != t[i]) count++
    }
    println(count)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string S;
cin>>N>>S;
int count=0;
for(int i=0; i<N-1; i++){
if(S.at(i)==S.at(i+1)){
count++;
}
}
cout<<N-count<<endl;
}

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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  vector<int> a(3*n);
  for(int i = 0; i < 3*n; ++i)
    cin >> a[i];

  vector<ll> lf(3*n), rg(3*n);
  multiset<int, greater<int>> l;
  ll sum = 0;
  for(int i = 0; i < 2*n; ++i) {
    sum += a[i];
    l.insert(a[i]);
    if(l.size() > n) {
      auto f = --l.end();
      sum -= *f;
      l.erase(f);
    }
    lf[i] = sum;
  }

  sum = 0;
  multiset<int> r;
  for(int i = 3*n-1; i >= n; --i) {
    sum += a[i];
    r.insert(a[i]);
    if(r.size() > n) {
      auto f = --r.end();
      sum -= *f;
      r.erase(f);
    }
    rg[i] = sum;
  }

  ll ans = -1e18;
  for(int i = n-1; i < 2*n; ++i)
    ans = max(ans, lf[i]-rg[i+1]);

  cout << ans << endl;
}

Measured memory_bytes: 15488
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner input=new Scanner(System.in);
		int n,f=0;
		BigInteger a[]=new BigInteger[100005];
		n=input.nextInt();
		BigInteger b=new BigInteger("1");
		BigInteger c=new BigInteger("1000000000000000000");
		BigInteger d=new BigInteger("0");
		for(int i=1;i<=n;i++){
			a[i]=input.nextBigInteger();
			if(a[i].equals(d)){
				f=2;
				break;
			}
		}
		if(f==2){
			System.out.println("0");
		}
		else{
			for(int i=1;i<=n;i++){
				b=b.multiply(a[i]);
				if(b.compareTo(c)>0){
					f=1;
					break;
				}
			}
			if(f==1){
			System.out.println("-1");
		}
			else{
			System.out.println(b);
		}
		}
		
		
	}


}


Measured memory_bytes: 64892
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main(void){
  long long h, w, k, dp[128][16] = {}, c[9] = {1, 1, 2, 3, 5, 8, 13, 21, 34};
  cin >> h >> w >> k;
  dp[0][1] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 1; j <= w; j++) {
      dp[i + 1][j] += dp[i][j] * c[j - 1] % MOD * c[w - j] % MOD;
      dp[i + 1][j] %= MOD;
      if (j - 1 >= 1)
        dp[i + 1][j - 1] += dp[i][j] * c[j - 2] % MOD * c[w - j] % MOD;
        dp[i + 1][j - 1] %= MOD;
      if (j + 1 <= w)
        dp[i + 1][j + 1] += dp[i][j] * c[j - 1] % MOD * c[w - (j + 1)] % MOD;
        dp[i + 1][j + 1] %= MOD;
    }
  }
      
  cout << dp[h][k] << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = list(map(int, input().split()))
delist = set(range(1,n+1))
for i in range(m):
    a,b = map(int, input().split())
    if l[a-1] >= l[b-1]:
        delist.discard(b)
    if l[a-1] <= l[b-1]:
        delist.discard(a)
print(len(delist))
 

Measured memory_bytes: 22492
from sys import stdin, setrecursionlimit
from collections import deque


def main():

    setrecursionlimit(2000001)

    n, q = [int(x) for x in stdin.readline().split()]

    tree = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        a, b = [int(x) for x in stdin.readline().split()]
        tree[a].append(b)
        tree[b].append(a)

    count = [0] * (n + 1)
    for _ in range(q):
        parent, x = [int(x) for x in stdin.readline().split()]
        count[parent] += x

    queue = deque([])
    visited = [False] * (n + 1)

    queue.append((0, 1))

    while len(queue) > 0:
        parent, current = queue.popleft()
        visited[current] = True
        count[current] += count[parent]
        for child in tree[current]:
            if not visited[child]:
                queue.append((current, child))

    print(*count[1:])


main()

Measured memory_bytes: 58996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	if(n % 10 == 3) {
		cout << "bon" << '\n';
	} else if(n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8) {
		cout << "pon" << '\n';
	} else {
		cout << "hon" << '\n';
	}
	return 0;
}

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

int data[100500];

int main(void)
{
	int n, k;
	while (1){
		cin >> n >> k;
		if(n==0&&k==0)break;
		for (int i = 1; i <= n; i++){
			cin >> data[i];
			data[i] += data[i-1];
		}
		
		int res = 0;
		for (int i = k; i <= n; i++){
			res = max(res, data[i] - data[i-k]);
	//		cout <<"*"<< i << " " << i-k << endl;
		}
	//	for (int i = 0; i <= n; i++){
	//		cout << data[i] << " ";
	//	}
	//	puts("");
		cout << res << endl;
	}
	return 0;
}

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

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

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

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    ll m; cin>>m;
    vi a(n);
    rep(i,0,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    vector<pii> v;
    rep(i,0,m){
        int b,c;
        cin>>b>>c;
        pii e=make_pair(c,b);
        v.push_back(e);
    }
    sort(v.rbegin(),v.rend());
    int vp=0;
    int ap=0;
    ll res=0;
    rep(i,0,n){
        if(a[ap]>=v[vp].first)res+=a[ap++];
        else {
            res+=v[vp].first;
            v[vp].second--;
            if(v[vp].second==0)vp++;
        }
    }
    cout<<res<<endl;
    return 0;
}




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


int main(){
    string s;
    cin >> s;
    int n = s.size(), cnt = 0;
    rep(i,n-1){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#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)
#define srep2(j,s,t) for (int j = s; i < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N,W;
  cin >> N >> W;
  int weight[N];
  int value[N];
  rep(i,N) {
    cin >> weight[i] >> value[i];
  }
  ll dp[N][W+1];
  rep(i,N){
    rep2(j,W+1){
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  dp[0][weight[0]] = value[0];
  srep(i,1,N) {
    rep2(j,W+1) {
      if(dp[i-1][j] != -1 ){
        dp[i][j] = max(dp[i-1][j],dp[i][j]);
      }
      if(j - weight[i] > -1 && dp[i-1][j - weight[i]] != -1) {
        dp[i][j] = max(dp[i-1][j - weight[i]] + value[i] ,dp[i][j]);
      }
    }
  }
  ll ans = 0;
  rep(i,W+1){
    ans = max(ans, dp[N-1][i]);
  }
  cout << ans << endl;
  return 0;
}

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

const int MOD = 1000000007;

int main(void) {
	int n, m;
	cin >> n >> m;

	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}

	if (n < m) swap(n, m);

	ll lastComb;
	if (n - m) lastComb = 1;
	else lastComb = 2;
	ll res = lastComb;
	for (int i = 1; i <= n; i++) {
		res *= i;
		res %= MOD;
	}
	for (int i = 1; i <= m; i++) {
		res *= i;
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-5;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}



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

	cin >> N >> K;
	set<pair<int, int>>st;
	st.insert({ 0,1 });
	st.insert({ N,0 });
	vector<long long int>ten(N + 1, 1);
	vector<long long int>one(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		ten[i] = ten[i - 1] * 10 % MOD;
		one[i] = one[i - 1] * 10 + 1;
		one[i] %= MOD;
	}
	long long int ans = one[N - 1];
	while (K--) {
		cin >> L >> R >> M;
		L--;
		ans += ten[N - R] * one[R - L - 1] % MOD*M;
		ans %= MOD;
		int nl = L;
		while (nl < R) {
			auto it = st.lower_bound({ nl,10 });
			int nr = min((int)R, it->first);
			if (it != st.begin()) {
				ans += MOD;
				ans -= ten[N - nr] * one[nr - nl -1] % MOD*prev(it)->second%MOD;
				auto box = *prev(it);
				if (nr != it->first) {
					st.insert({ nr,prev(it)->second });
				}
				if (box.first == nl) {
					st.erase(box);
				}
			}
			nl = nr;
		}
		st.insert({ L,M });
		ans %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 15940
def min(a, b) a<b ? a:b end

An,Bn,M=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
B=gets.split.map(&:to_i)
XYC=M.times.map{gets.split.map(&:to_i)}

ans = A.min + B.min
XYC.each do |x,y,c|
  v = A[x-1] + B[y-1] - c
  ans = min(ans, v)
end

p ans

Measured memory_bytes: 18972
#include<iostream>
using namespace std;
int main(){
  unsigned long long h;
  cin>>h;
  unsigned long long count =0;
  while(h){
    count++;
     h=h/2;
  }
  unsigned long long product=1;
  for(unsigned long long i=0;i<count;i++){
    product=product*2;
  }
  cout<<product-1;
  return 0;
}


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

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

    std::string s, t;
    std::cin >> s >> t;

    int ns = s.size();
    int nt = t.size();

    int max = 0;
    for (int i = 0; i + nt - 1 < ns; i++) {
        int cnt = 0;

        for (int j = 0; j < nt; j++) {
            cnt += (s[i + j] == t[j]);
        }

        max = std::max(max, cnt);
    }

    std::cout << nt - max;

    return 0;
}


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

int main(){
	int n;
	string str,ord,c;
	cin >> str;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> ord >> a >> b;
		int len = b-a;
		if(ord == "print"){
			cout << str.substr(a,len+1) << "\n";
		}
		else if(ord == "reverse"){
			string swap,swap2;
			swap = str.substr(a,len+1);
			for(int i = len;i >= 0;i--){
				swap2.push_back( swap.at(i) );
			}
			str = str.substr(0,a) + swap2 + str.substr(b+1);
		}
		else if(ord == "replace"){
			cin >> c;
			str = str.substr(0,a) + c + str.substr(b+1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 3164
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String line = br.readLine();
 
        while(!(line.equals("0 0"))){
            String[] input = line.split(" ");
            int h = Integer.valueOf(input[0]);
            int w = Integer.valueOf(input[1]);
            StringBuilder sb = new StringBuilder();
 
            for(int i = 0; i < h; i++){
                boolean which = i%2 == 0;
                for(int j = 0; j < w; j++){
                    if(which) sb.append("#");
                    else sb.append(".");
                    which = !which;
                }
                sb.append("\n");
            }
 
            System.out.println(sb);
             
            line = br.readLine();
        }
 
    }
}


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

ll l1[10];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,s=0;map<ll,ll>m;
    cin>>n;
    set<ll>se;
    for(int i=1;i<=n;i++){
        cin>>a;
        m[a]++;
        se.insert(a);
    }
    for(auto it=se.begin();it!=se.end();it++){
        if(m[*it]>*it)s+=m[*it]-*it;
        else if(m[*it]<*it)s+=m[*it];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 13972
#include<bits/stdc++.h>
using namespace std;
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto & e : v) cin >> e;
    array<short,13> cnt = {0};
    cnt[0]++;
    for(auto  e : v)cnt[e]++;
    for(auto  e : cnt) if(e >= 3) return puts("0") * 0;
    if(cnt[0] >= 2 or cnt[12] >= 2) return puts("0")* 0;
    int ans = -INF;
    
    for(int bit = 0; bit < (1LL << 12); ++bit){
        vector<int>pos(25,0LL);
        pos[0] = cnt[0];
        pos[12] = cnt[12];
        int tans = INF;
        for(int i = 1; i <= 12; ++i){
            if(cnt[i] == 0) continue;
            if(cnt[i] == 2) pos[i] = pos[24 - i] = 1;
            if(cnt[i] == 1){
                ((bit & (1LL << (i - 1))) >= 1 ? pos[i] : pos[24 - i]) = 1;
            }
        }
        for(int i = 0; i < pos.size(); ++i){
            for(int j = 0; j < pos.size(); ++j){
                if(i != j and pos[i] == 1 and pos[j] == 1)
                    cmin(tans, min(abs(i-j),24 - abs(i-j)));
            }
        }
        if(tans == INF)continue;
        cmax(ans, tans);
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

ll n,m,dp[1003][1003];
char arr[1003][1003];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    if(arr[0][0]=='.')dp[0][0]=1;
    for(int i=1;i<(max(n,m));i++){
        if(arr[i][0]!='#')dp[i][0]=dp[i-1][0];
        if(arr[0][i]!='#')dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(arr[i][j]!='#')dp[i][j]=(dp[i][j-1]+dp[i-1][j])%MOD;
            else dp[i][j]=0;
        }
    }
    cout<<dp[n-1][m-1];
}

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


int main(){
    int N, L;
    cin >> N >> L;
    if(L > 0){
        cout <<(L-1)*N + N*(N+1)/2 -L <<endl;
    }
    else if(1-L > N){
        cout <<(L-1)*N + N*(N+1)/2 -(L +N -1) <<endl;
    }
    else 
    cout <<(L-1)*N + N*(N+1)/2 <<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec P(N);
    REP(i,0,N) cin >> P[i];

    ll m = P[0], cnt = 0;
    REP(i,0,N) {
        if(m >= P[i]) {
            ++cnt;
            m = MIN(m,P[i]);
        }
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 1792
//Bismillahir Rahmanir Rahim
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;


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

    long long int n,count=0,a=0,b=0,c=0,d=0;
    cin >> n;
    string st;
    while(n--)
    {
        cin >> st;
        if(st=="AC")
        {
            a++;
        }
        else if(st=="WA")
        {
            b++;
        }
        else if(st=="TLE")
        {
            c++;
        }
        else if(st=="RE")
        {
            d++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;

    return 0;

}



Measured memory_bytes: 3620
#include<cstdio>
#include <cmath>

int a[100];

const int INF = 100000;

int main() {
	int n;
	int sum = 0;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	int d = INF;
	int ans = 0;
	for(int i=0;i<n;i++) {
		int e = std::abs(a[i]*n - sum);
		if(e < d) {
			ans = i;
			d = e;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int ab[6], i, x[4];
  for (i=0; i<6; ++i) {
    scanf("%d", &ab[i]);
  }

  memset(x, 0, sizeof(x));
    for (i=0; i<6; ++i) {
      if (ab[i]==1) { x[0]++; }
      else if (ab[i]==2) { x[1]++; }
      else if (ab[i]==3) { x[2]++; }
      else if (ab[i]==4) { x[3]++; }
    }
  
    for (i=0; i<4; ++i) {
      if (x[i] == 0 || x[i] == 3) {
        printf("NO\n");
        return 0;
      }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 5000
#define MAXH 4
#define MAXM 4
#define INF 1LL << 62
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 200005;
ll cnt = 0;
long long t[N + 5];

void inc(int x,long long val){
	for(++x;x <= N;x += x&-x){
		t[x] += val;
	}
}

long long query(int x){
	ll res = 0;
	for(++x;x > 0; x&=x-1){
		res += t[x];
	}
	return res;
}

int main(){
	fast_io();
	ll n,k;
	cin >> n >> k;
	ll a[n+1];
	fu(i,1,n)cin >> a[i];
	fu(i,1,n)a[i] += a[i-1];
	vector<pll> v(n+1);
	fu(i,0,n){
		v[i] = {a[i] - k * i, i};
	}
	sort(all(v), greater<pll>());
	ll ans = 0;
	fu(i,0,n){
		++cnt;
		inc(v[i].S, 1);
		ans += cnt - query(v[i].S);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    int total_dame = 0;
    for (int i = 0; i < N; i++){
       total_dame += a[i];
    }
    if (total_dame >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

inf = float('inf')
#inf = pow(10, 10)

def main():
    # input
    N = int(readline())
    A = list(map(int, readline().split()))

    K = N//2
    DP0 = [-inf] * N
    DP1 = [-inf] * N
    DP2 = [-inf] * N

    DP2[0] = A[0]
    DP2[1] = max(A[0], A[1])
    DP1[:2] = [0] * 2
    DP0[:4] = [0] * 4
    for i in range(2, N):
        if i%2 == 0:
            DP2[i] = DP2[i-2] + A[i]
            DP1[i] = max(DP2[i-1], DP1[i-2] + A[i])
            DP0[i] = max(DP1[i-1], DP0[i-2] + A[i])
        else:
            DP2[i] = max(DP2[i-2] + A[i], DP2[i-1])
            DP1[i] = max(DP1[i-1], DP1[i-2] + A[i])
            DP0[i] = max(DP0[i-1], DP0[i-2] + A[i])

    if N%2 == 0:
        ans = DP2[N-1]
    else:
        ans = DP1[N-1]

    #print(DP0)
    #print(DP1)
    #print(DP2)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49952
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;
	if(2*k-1<=n){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
//ABC154 C

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

int N;
int A[200000];

int main() {
  cin >> N;

  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  sort(A,A+N);
  string ansstr = "YES";
  for(int i=0;i<N-1;i++){
    if(A[i] == A[i+1]){
      ansstr = "NO";
      break;
      }
  }
  printf("%s\n",ansstr.c_str());
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1234567;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>a(N);
    int cnt = 1;
    int res = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(a[i] == cnt) {
            res++;
            cnt++;
        }
    }
    if(res == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << N-res << endl;
}


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

int maxplan(vector<int> x){
  int m = -998244353;
  int n = x.size();
  for (int i=0;i<n;i++){
    if (m < x[i]){
      m = x[i];
    }
  }
  return m;
}

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (int i=0;i<H;i++){
    cin >> S[i];
  }
  int d = 1;
  for (int i=0;i<H-1;i++){
    d *= 2;
  }
  int mcut = 1008;
  vector<int> L(H);
  vector<int> C(0);
  vector<int> tmp(0);
  bool cutp = true, cutq = true;
  int cut, M = 0;
  int tmpp;
  for (int i=0;i<d;i++){
    tmpp = i;
    for (int j=1;j<H;j++){
      L[j] = L[j-1] + tmpp % 2;
      tmpp /= 2;
    }
    C = vector<int>(L[H-1]+1, 0);
    cutp = true, cutq = true;
    cut = L[H-1];
    for (int m=0;m<W;m++){
      tmp = vector<int>(L[H-1]+1, 0);
      for (int l=0;l<H;l++){
        if (S[l][m] == '1'){
          tmp[L[l]] += 1;
          C[L[l]] += 1;
        }
      }
      M = maxplan(C);
      if (cutq){
        cutq = false;
        if (M > K){
          cutp = false;
          break;
        }
      }
      else{
        if (M > K){
          cut += 1;
          C = tmp;
        }
      }
      tmp = vector<int>(L[H-1]+1, 0);
      if (cutp == false){
        break;
      }
    }
    if (cutp){
      if (cut < mcut){
        mcut = cut;
      }
    }
  }
  cout << mcut << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef vector<int> vi;
typedef complex<int> point;

point calc(int i,vi& n,vi& d,vector<point>& p,vi& flg)
{
	int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
	if(flg[i]) return p[i];
	
	point pp=calc(n[i],n,d,p,flg),dd(dx[d[i]],dy[d[i]]);
	flg[i]=1;
	return pp+dd;
}

int main()
{
	for(int N;cin>>N,N;){
		vi n(N),d(N);
		for(int i=1;i<N;i++)
			cin>>n[i]>>d[i];
		
		vector<point> p(N);
		vi flg(N);
		flg[0]=1;
		for(int i=1;i<N;i++)
			p[i]=calc(i,n,d,p,flg);
		
		point mn=p[0],mx=p[0];
		for(int i=0;i<N;i++){
			real(mn)=min(real(mn),real(p[i]));
			imag(mn)=min(imag(mn),imag(p[i]));
			real(mx)=max(real(mx),real(p[i]));
			imag(mx)=max(imag(mx),imag(p[i]));
		}
		
		cout<<real(mx-mn)+1<<" "<<imag(mx-mn)+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main(){
    char str[19];
    scanf("%[^\n]", str);
    for(int a = 0; a < 19; a++){
      if(str[a] == ','){
        printf(" ");
      } else{
        printf("%c", str[a]);
      }
    }

    return 0;
}

Measured memory_bytes: 1560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n - 1)cin >> a[i];
	sort(all(a));
	double l = a[n - 1];
	double u = a[n - 2];

	rep(i, 0, n - 2)
	{
		if (abs(u - l / 2) > abs(a[i] - l / 2))u = a[i];
	}
	int x = l;
	int y = u;
	cout << x << " " << y << endl;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> cnt(n + 1);
  for (int d = 1; d <= n; ++d) {
    for (int i = d; i <= n; i += d) {
      ++cnt[i];
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    res += (long long)i * cnt[i];
  }
  cout << res << '\n';
}


Measured memory_bytes: 42236
#include<iostream>
#include<string>

using namespace std;

int main(void) {
	int H, W;
	int ansi, ansj;

	string str;

	cin >> H >> W;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> str;
			if (str == "snuke") {
				ansi = i;
				ansj = j;
			}
		}
	}

	cout << (char)('A' + ansj) << ansi + 1 << endl;

	//system("pause");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _dbg(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_dbg(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){

    int n,a,b;cin>>n>>a>>b;
    cout<<min(n*a,b)<<'\n';

    return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
*A, = map(int, input().split())
ans = max(A[0] - x, 0)
if A[0] > x: A[0] = x
for i in range(N-1):
    S = A[i] + A[i+1]
    if S > x:
        ans += S - x
        A[i+1] -= min(S - x, A[i+1])
print(ans)

Measured memory_bytes: 14472
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

vl adj[200010];
int vis[200010], loc[200010], dis[200010];


void bfs(int k){
    queue<int> q;
    q.push(k);
    vis[k] = 1;
    while(!q.empty()){
        int node = q.front();
        q.pop();
        for(int i = 0; i < adj[node].size(); i++){
            int p = adj[node][i];
            if(!vis[p]){
                dis[p] = dis[node] + 1;
                vis[p] = 1; 
                loc[p] = node;
                q.push(p);
            }
        }
    }
}


void solve(){
    int n, m;
    cin>>n>>m;
    f(i,m){
        int x, y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    bfs(1);
    for(int i = 1; i <= n; i++)if(vis[i] == 0){
        cout<<"No";
        return ;
    }
    cout<<"Yes\n";
    for(int i = 2; i <= n; i++)cout<<loc[i]<<"\n";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 16852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int H, W;
  cin >> H >> W;
  char mp[H][W];
  int dp[H][W][2];

  for (int i = 0; i < H; i++) {
    string input;
    cin >> input;
    for (int j = 0; j < W; j++) {
      mp[i][j] = input[j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 2; k++) {
        dp[i][j][k] = INF;
      }
    }
  }

  int plus_s = (mp[0][0] == '#') ? 1 : 0;
  dp[0][0][plus_s] = plus_s;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k] == INF) continue;

        if (i + 1 < H) {
          int new_k = (mp[i+1][j] == '#') ? 1 : 0;
          int plus = (k == 1) ? 0 : new_k;
          chmin(dp[i+1][j][new_k], dp[i][j][k] + plus);
        }

        if (j + 1 < W) {
          int new_k = (mp[i][j+1] == '#') ? 1 : 0;
          int plus = (k == 1) ? 0 : new_k;
          chmin(dp[i][j+1][new_k], dp[i][j][k] + plus);
        }
      }
    }
  }

  cout << min(dp[H-1][W-1][0], dp[H-1][W-1][1]) << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


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

	vector<int> Bs(M, 0);
	vector<int> As(M, 0);

	for (int mi = 0; mi < M; mi++) {
		cin >> Bs[mi];
	}

	int sum;
	int ans = 0;
	for (int ni = 0; ni < N; ni++) {
		sum = C;
		for (int mi = 0; mi < M; mi++) {
			cin >> As[mi];
			sum += As[mi] * Bs[mi];
		}
		if (sum > 0) {
			ans++;
		}
	}

	printf("%d",ans);


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




#define SIZE 105

int H,W;
int dp[SIZE][SIZE];
char table[SIZE][SIZE];

int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);
	}

	if(table[0][0] == '#'){

		dp[0][0] = 1;

	}else{

		dp[0][0] = 0;
	}

	for(int col = 1; col < W; col++){
		if(table[0][col] == '#' && table[0][col-1] == '.'){

			dp[0][col] = dp[0][col-1]+1;

		}else{

			dp[0][col] = dp[0][col-1];
		}
	}

	for(int row = 1; row < H; row++){
		if(table[row][0] == '#' && table[row-1][0] == '.'){

			dp[row][0] = dp[row-1][0]+1;

		}else{

			dp[row][0] = dp[row-1][0];
		}
	}

	for(int row = 1; row < H; row++){
		for(int col = 1; col < W; col++){
			if(table[row][col-1] == '.' && table[row][col] == '#'){

				dp[row][col] = dp[row][col-1]+1;

			}else{

				dp[row][col] = dp[row][col-1];
			}

			if(table[row][col] == '#' && table[row-1][col] == '.'){

				dp[row][col] = min(dp[row][col],dp[row-1][col]+1);

			}else{

				dp[row][col] = min(dp[row][col],dp[row-1][col]);
			}
		}
	}

	printf("%d\n",dp[H-1][W-1]);

	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define LL

void solve()
{
    ll n, x; cin >> n >> x;
    vi a(n);
    vi b(n);
    REP(i, n)
    {
        ll c; cin >> c;
        a[i] = b[i] = c;
        if(c > x) b[i] = x;
    }
    REP(i, n-1)
    {
        ll sum = b[i] + b[i+1];
        if(sum <= x) continue;
        b[i+1] -= sum - x;
    }
    ll ans = 0;
    REP(i, n)
    {
        ans += a[i] - b[i];
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    }else if (A <= 5) {
        cout << 0 << endl;
    }else{
        cout << B/2;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int k = 38;
	int trans[38];
	int n = k * k - k + 1;
	cout << n << " " << k << endl;
	rep(i, k) {
		cout << 1;
		int x = 1 + i * (k - 1);
		Rep(j,x, x+k-1) {
			cout << " " << j + 1;
		}
		cout << endl;
	}
	rep(i, k - 1) {
		rep(j, k-1){
			trans[j] = (i + j) % (k - 1);
		}
		rep(j, k - 1) {
			cout << i + 2;
			int now = j;
			rep(l, k - 1) {
				int x = k + l * (k - 1) + now;
				now = trans[now];
				cout << " " << x + 1;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
N, x=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
j=1
S=a[0]
while (S<x)and(j<N):
  S=S+a[j]
  j=j+1
if S==x:
  print(j)
else:
  print(j-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2000+10;
int res,Begin[maxn],Next[maxn<<1],to[maxn<<1],e=1;
inline void add_edge(int x,int y){
	to[++e]=y;
	Next[e]=Begin[x];
	Begin[x]=e;
}
void dfs(int x,int ff,int dep,int d){
	if(dep>d) ++res;
	for(int i=Begin[x];i;i=Next[i]) if(to[i]!=ff) dfs(to[i],x,dep+1,d);
}
int main(){
	int n=read(),k=read();
	REP(i,1,n-1){
		int x=read(),y=read();
		add_edge(x,y),add_edge(y,x);
	}
	int ans=n;
	if(k&1){
		REP(i,1,n-1){
			res=0;
			dfs(to[i<<1],to[i<<1|1],0,k/2);
			dfs(to[i<<1|1],to[i<<1],0,k/2);
			chkmin(ans,res);
		}
	}
	else{
		REP(i,1,n){
			res=0;
			dfs(i,0,0,k/2);
			chkmin(ans,res);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#include<string.h>
int main (void){
  
 long long int c,max=0,n=0,i,k,flag=0,sum=0,count;
scanf("%lld",&n);
while((i*i)<n)
{
    i++;
    
}
 printf("%ld",(i*i>n)?(i-1)*(i-1):i*i);
return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
ll dp[102][100005];
int main()
{
    fastio;
    int n,w;
    cin>>n>>w;
    for(int i=0;i<=n;i++)for(int j=0;j<=100000;j++)dp[i][j] = inf;
    dp[0][0] = 0;
    int sum = 0;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        sum+=y;
        for(int j=0;j<=sum;j++)
        {
            if(j<y)
                dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j-y]+1LL*x,dp[i-1][j]);
            //trace3(i,j,dp[i][j]);
            if(i==n && dp[i][j]<=w)
                ans = max(ans,j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int bubble_sort(int * nums, int N){
    int swaps = 0;
    for (int i=0; i != N; ++i){
        for (int j=N-1; j!=i; --j){
            if (nums[j] < nums[j-1]){
                int tmp = nums[j];
                nums[j] = nums[j-1];
                nums[j-1] = tmp;
                ++swaps;
            }
        }
    }
    return swaps;
}



int main()
{
    int N = 0;
    cin >> N;
    int *nums = new int[N];
    for (auto i=0; i!=N; ++i) cin >> nums[i];
    int swaps = bubble_sort(nums, N);
    for (auto i=0; i!=N-1; ++i) cout << nums[i] << ' ';
    cout << nums[N-1] << endl;
    cout << swaps << endl;
//    for (auto &num : nums) cin >> num;
//    for (auto const & num : nums) cout << num << endl;
    return 0;
}

Measured memory_bytes: 3092
from fractions import gcd
from sys import exit

N = int(input())
A = list(map(int, input().split()))

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.append(gcd(r_gcd_list[i], A[-(i+1)]))
r_gcd_list = r_gcd_list[::-1]
# print(l_gcd_list)
# print(r_gcd_list)

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))


Measured memory_bytes: 16048
#include <bits/stdc++.h>
#define plskz ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;

int main() {
    plskz

    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k)
        cout << s;
    else {
        for(int i=0; i<k; ++i) {
            cout << s[i];
        }
        cout << "...";
    }
}   

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<P> pairs(n);
    rep(i,n)
    {
        cin >> pairs[i].first >> pairs[i].second;
    }
    sort(pairs.begin(),pairs.end());
    
    for (auto s : pairs)
    {
        k -= (ll)s.second;
        if(k<=0)
        {
            cout << s.first << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N,Y;
	cin >> N >> Y;
	for (int x = 0; x <= Y / 10000; ++x) {
		int now = Y - x * 10000;
		for (int y = 0; y <= now / 5000; ++y) {
			int z = N - x - y;
			if (z < 0) {
				break;
			}
			if (now == y * 5000 + z * 1000) {
				cout << x << " " << y << " " << z << endl;
				return;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define test
#ifdef test
#define IOS()
#define time() cout<<double(end-start)/CLOCKS_PER_SEC<<"S\n"
#else
#define IOS() ios::sync_with_stdio(0)
#define time()
#endif
typedef long long ll;
using namespace std;
ll n[200001];
int main()
{
	int t;
	while(cin>>t)
	{
		double start=clock(),end;
		for(int i=0;i<t;i++) cin>>n[i];
		ll first=n[0];
		ll ans=0;
		for(int i=1;i<t;i++)
		{
			if(n[i]<=first) ans+=first-n[i];
			else first=n[i];
		}
		end=clock();
		time();
		cout<<ans<<"\n";
	}
} 

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	int N; cin >> N;
	vector<int> ans(N+1, 0);
	for(int i=0;i<N-1;i++) {
		int a;
		cin >> a;
		ans[a]++;
	}
	for(int i=1;i<=N;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4052