akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);

		//String[] tmpArray = br.readLine().split(" ");
		//int[] input = new int[n];
//		for(int i = 0; i < n; i++){
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int m = Integer.parseInt(tmpArray[0]);
			int f = Integer.parseInt(tmpArray[1]);
			int r = Integer.parseInt(tmpArray[2]);
//			int v = Integer.parseInt(tmpArray[3]);
			
			if(m == -1 && f == -1 && r == -1){
				break;
			}
			String grade;
			if(m == -1 || f == -1){
				grade ="F";
			}
			else {
				int sum = m + f;
				if(sum >= 80){
					grade = "A";
				}
				else if(sum >= 65){
					grade = "B";
				}
				else if(sum >= 50){
					grade = "C";
				}
				else if(sum >= 30){
					grade = "D";
					if(r >= 50){
						grade = "C";
					}
				}
				else{
					grade = "F";
				}
			}
			
			System.out.println(grade);
			
		}
			
//		System.out.print(input[0]);
//		for(int i = 1 ; i < n; i++){
//			System.out.print(" "+ input[i]);
//		}
//		System.out.println();
////		
//		Arrays.sort(input);
//		System.out.printf("%d %d %d\n", input[0], input[input.length - 1], sum);
//		
//		while(true){
//			String[] tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[1]);
//			if(a == 0 && b == 0){
//				break;
//			}
//			
//			for(int i = 0; i < a; i++){
//				for(int j = 0; j < b; j++){
//					if((i + j)%2 == 1){
//						System.out.print(".");
//					}
//					else{
//						System.out.print("#");
//					}
//				}
//				System.out.println();
//			}
//			System.out.println();
//		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 24160
n = int(input())
s = [input() for i in range(n)]
AC = 0
WA = 0
TLE = 0
RE = 0
for t in s:
    if (t == 'AC'):
        AC += 1
    elif (t == 'WA'):
        WA += 1
    elif (t == 'TLE'):
        TLE += 1
    else:
        RE += 1

print('AC x ', AC)
print('WA x ', WA)
print('TLE x ', TLE)
print('RE x ', RE)

Measured memory_bytes: 16336
n = int(input())

def make_divisor_list(n):
  divisor_list = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisor_list.append(i)
      if i != n // i:
        divisor_list.append(n//i)
  divisor_list = sorted(divisor_list)
  return divisor_list
  
li = make_divisor_list(n)

if len(li)%2 ==1:
  print(len(str(li[len(li)//2])))
else:
  print(max(len(str(li[len(li)//2-1])),len(str(li[len(li)//2]))))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void){
    char s;
   cin >> s;

    if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
	int m, f, r;

	while(1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) {
			break;
		}

		if (m == -1 || f == -1) {
			printf("F\n");
		} else if (m + f >= 80) {
			printf("A\n");
		} else if (m + f >= 65) {
			printf("B\n");
		} else if (m + f >= 50 || r >= 50) {
			printf("C\n");
		} else if (m + f >= 30) {
			printf("D\n");
		} else {
			printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
 
const int MAXN = 1e6 + 5;

char s[MAXN];
int dp[2][MAXN], N;
int A[MAXN], B[MAXN];
 
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s+1;
	N = strlen(s+1);
	for(int i=1; i<=N; i++) A[i] = s[i] - '0';
	for(int i=1; i<N; i++) B[i] = 9 - A[i];
	B[N] = 10 - A[N];
	dp[1][0] = 1;
	for(int i=1; i<=N; i++) {
		int a = A[i], b = B[i];
		dp[0][i] = min(dp[0][i-1]+a, dp[1][i-1]+b+1);
		dp[1][i] = min(dp[0][i-1]+a+1, dp[1][i-1]+b);
	}
	cout << min(dp[0][N], dp[1][N]);
}


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

int main() 
{
    int n, a=0, ans=0;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int h;
        cin >> h;
        if (h>a)
            ans += h-a;
        a = h;
    }
    cout << ans;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    long long x,a=100;
    cin >> x;
    int counter = 0;
    while(1){
        counter++;
        a*=1.01;
        if(x<=a){
            cout << counter << endl;
            return 0;
        }
    }

}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, L;
    cin >> N >> L;

    vector<ll> aji(N);
    for (ll i = 0; i < N; i++) {
        aji[i] = L+i;
    }

    ll mi = INF;
    ll memo = 0;
    rep (i, N) {
        if (abs(aji[i]) < mi) {
            mi = abs(aji[i]);
            memo = aji[i];
        }
    }

    ll ans = 0;
    rep (i, N) {
        ans += aji[i];
    }

    ans -= memo;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Contest: -
Problem: Atcoder Beginner Contest 152 F
Author: tzc_wk
Time:
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define y1			y1010101010101
#define y0			y0101010101010
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-') neg=-1;
		c=getchar();
	}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*neg;
}
int n=read();
vector<int> g[55];
int a[25],b[25],fa[55],dep[55];
bool vis[55];
inline void dfs(int x,int f){
	fa[x]=f;
	foreach(it,g[x]){
		int y=*it;
		if(y!=f){
			dep[y]=dep[x]+1;
			dfs(y,x);
		}
	}
}
signed main(){
	fz(i,1,n-1){
		int u=read(),v=read();
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0); 
	int m=read();
	fz(i,1,m) a[i]=read(),b[i]=read();
	int ans=0;
	for(int i=0;i<(1<<m);i++){
//		cout<<i<<endl;
		fill0(vis);
		for(int j=1;j<=m;j++){
			if(i>>(j-1)&1){
				int x=a[j],y=b[j];
				if(dep[x]<dep[y]) swap(x,y);
				while(dep[x]>dep[y]) vis[x]=1,x=fa[x];
				while(x!=y) vis[x]=vis[y]=1,x=fa[x],y=fa[y];
			}
		}
		int t=1;
		fz(j,2,n) if(!vis[j]) t<<=1;
		ans+=pow(-1,__builtin_popcount(i))*t;
//		cout<<i<<" "<<t<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e6 + 1 , S = 1e4 , N = 3e4 + 30 , sig = 2e4 , INF = 1e9 , mod = 1e9 + 7;

ll a[maxn] , num[maxn + 1];
vector <int> divi[maxn];

inline void finddivi() {
    for (int i = 1; i < maxn; ++i) {
        for (int j = i; j < maxn; j += i) {
            divi[j].PB(i);
        }
    }
}

int main() {
    finddivi();
    int n , ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        // mark[a[i]] = 1;
        num[a[i]]++;
    }
    for (int i = 0; i < n; ++i) {
        int cnt = 0;
        for (int u : divi[a[i]]) {
            cnt += num[u];
        }
        if(cnt <= 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int n, m, x;
int A[200];

int main() {
	cin >> n >> m >> x;
	for (int i = 0; i < m; ++i) cin >> A[i];

	int resn = 0;
	for (int k = 0; k < m; k++) {
		if (A[k] >= x) resn++;
	}

	int res0 = 0;
	for (int k = 0; k < m; k++) {
		if (A[k] <= x) res0++;
	}
	
	if (resn <= res0) {
		cout << resn << endl;
	}
	else {
		cout << res0 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main(){
    string x,y;
    cin >> x >> y;
    x = x+x+x;
    int n = y.size();
    for(int i = 0; i < x.size()-n; i++){
        if(x.substr(i,n) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3216
package main

import "fmt"

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var n, cm int
	var s, t string
	fmt.Scan(&n, &s, &t)
	for i := 1; i <= len(s); i++ {
		if s[len(s)-i:] == t[:i] {
			cm = max(cm, len(t[0:i]))
		}
	}
	fmt.Println(2*n - cm)
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  ll s = accumulate(v.begin(), v.end(), 0ll);

  int m;
  cin >> m;
  int p, x;
  for (int i = 0; i < m; i++) {
    cin >> p >> x;
    cout << s - (v[p - 1] - x) << endl;
  }
}


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

int main() {
  int N, count1 = 100, count2;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    count2 = 0;
    while(1) {
      if (A % 2 == 0) {
        A /= 2; 
        count2++;
      }
      else {
        if (count1 >= count2)
          count1 = count2;
        break;
      }
    }
  }
  cout << count1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<18, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int fact[maxn], inv[maxn];
void setup() {
	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2; i < maxn; i++) inv[i] = mod - (mod/i)*1ll*inv[mod%i]%mod;
	for(int i = 2; i < maxn; i++) inv[i] = inv[i-1]*1ll*inv[i]%mod, fact[i] = fact[i-1]*1ll*i%mod;
}
int bp(int a, int p) {
	int r = 1;
	while(p) {
		if(p&1) r = r*1ll*a%mod;
		p>>=1, a = a*1ll*a%mod;
	}
	return r;
}
struct ctx {
	int sz, val;
	ctx() : sz(1), val(1) {}
	void root() {
		val = get()*1ll*inv[sz]%mod;
		sz++;
	}
	int get() {
		return val*1ll*fact[sz-1]%mod;
	}
	void add(ctx a) {
		val = val*1ll*a.get()%mod;
		val = val*1ll*inv[a.sz]%mod;
		sz += a.sz;
	}
	void rem(ctx a) {
		val = val*1ll*bp(a.get(), mod-2)%mod;
		val = val*1ll*fact[a.sz]%mod;
		sz -= a.sz;
	}
};
ctx dp[maxn];
vi g[maxn];
int n, ans[maxn];
void calc(int v, int p, ctx cur) {
	for(auto &i : g[v]) if(i != p) cur.add(dp[i]);
	ans[v] = cur.get();
	for(auto &i : g[v]) {
		if(i == p) continue;
		ctx t = cur;
		t.rem(dp[i]);
		t.root();
		calc(i, v, t);
	}
}
void dfs(int v, int p) {
	for(auto i : g[v]) if(i!=p) dfs(i, v), dp[v].add(dp[i]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	setup();
	cin >> n;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	dfs(1, 1);
	calc(1, 1, ctx());
	for(int i = 1; i <= n; i++) cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 21104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=1e5+7;
const ll modn=1000000007;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll a[111],n,sum;
ll f(ll mid)
{
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=(a[i]-mid)*(a[i]-mid);
    return ans;
}
int main()
{
    while(scanf("%lld",&n)==1)
    {
        sum=0;
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum+=a[i];
        printf("%lld\n",min(f(sum/n),f(sum/n+1)));
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N,K,Q;
  cin>>N>>K>>Q;
  vector<ll> A(Q);
  vector<ll> seikai(N,0);
  FOR(i,Q){
    cin>>A[i];
    A[i]--;
    seikai[A[i]]++;
  }
  if(K>Q){
    FOR(i,N){
      cout<<"Yes"<<endl;
    }
    return 0;
  }
  FOR(i,N){
    if(Q-seikai[i]>=K){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 16777215
#include <stdio.h>
#include <stdlib.h>


void insert(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p <<= 2;
			p += 4;
			break;
		case 'C':
			p <<= 2;
			p += 5;
			break;
		case 'G':
			p <<= 2;
			p += 6;
			break;
		case 'T':
			p <<= 2;
			p += 7;
			break;
		}
	}
	D[p] = 'Y';
}

int find(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p <<= 2;
			p += 4;
			break;
		case 'C':
			p <<= 2;
			p += 5;
			break;
		case 'G':
			p <<= 2;
			p += 6;
			break;
		case 'T':
			p <<= 2;
			p += 7;
			break;
		}
	}
	return D[p] == 'Y';
}

int main() {
	char *D = (char *)malloc(sizeof(char) * MaxSize);
	int i;
	for (i = 0; i < MaxSize; ++i) {
		D[i] = 'N';
	}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, s);
		}
		else {
			if (find(D, s)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

Measured memory_bytes: 16784
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	string str;
	long long k;
	cin >> str;
	cin >> k;
	int count = 0;
	int minn = 0;
	while (minn < str.length()) {
		if (str[minn] >= 123 - k + count && str[minn] != 'a') {
			count += 123 - str[minn];
			str[minn] = 'a';
		}
		minn++;
	}
	int l = (k - count) % 26;
	for (int i = 0; i < l; i++)
	{
		str[str.length() - 1]++;
		if (str[str.length() - 1] == 123)str[str.length() - 1] = 'a' + str[str.length() - 1] - 123;
	}
	cout << str << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long x;
    cin >> x;
    ld cur = 100;
    int iters = 0;
    while (cur < x) {
        ++iters;
        cur = (1.01 * cur);
        cur = floor(cur);
    }
    cout << iters;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

void init(int A[],int N);

int main(){
  int N,D,X;
  int A[100];
  int i;
  int ct=0;

  scanf("%d%d%d",&N,&D,&X);
  init(A,N);

  for(i=0;i<N;i++){
    ct+=D/A[i];
    if(D%A[i]){
      ct++;
    }
  }
  printf("\n%d\n",ct+X);

  return 0;
}
void init(int A[],int N){
  for(int i=0;i<N;i++)scanf("%d",&A[i]);
}

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


int compare(const void *a, const void *b) {
  if (*(double*)b > *(double*)a) {
    return 1;
  } else if (*(double*)b == *(double*)a) {
    return 0;
  } else {
    return -1;
  }
}



int main(void) {
  int N, last_index;
  double v[50];

  scanf("%d", &N);
  for (int i=0;i<N;i++) {
    scanf("%lf", &(v[i]));
  }

  qsort(v, N, sizeof(double), compare);

  last_index = N-1;
  while (last_index > 0) {
    v[last_index-1] = (v[last_index] + v[last_index-1]) / 2;
    v[last_index] = 0;
    last_index--;
  }

  printf("%f", v[0]);

  return 0;
}

Measured memory_bytes: 128
N = int(input())
P = list(map(float, input().split()))

#dp[i][j] = i枚目までのコインでj枚が表になる確率
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(N+1):
        if j == 0:
            dp[i][j] = (1-P[i-1])*dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j-1]*P[i-1] + dp[i-1][j]*(1-P[i-1])

ans = 0
for j in range(N+1):
    if j > (N-j):
        ans += dp[N][j]
print(ans)

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

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	int n,m;
	cin >> n >> m;
	vector<vi> e(n);


	rep(i,m){
		int a,b;
		cin >> a >> b;
		e[--a].pb(--b);
		e[b].pb(a);
	}

	bool f = false;
	rep(i,e[0].size()){
		int idx = e[0][i];
		rep(j,e[idx].size()){
			if(e[idx][j] == n-1) {
				f = true;
				break;
			}
		}
		if(f) break;
	}

	cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	
	return 0;
}


Measured memory_bytes: 12016
a = [int(input()) for i in range(5)]
a.sort(key=lambda x: abs(int(str(x)[-1]) - 10) % 10)
result = 0
for i, t in enumerate(a):
    if i == 4:
        result += t
    else:
        result += t
        result += (10 - int(str(t)[-1])) % 10
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int n, par[150005];
vector<int> gph[150005];
vector<int> ord;

void dfs(int x, int p){
	ord.push_back(x);
	for(auto &i : gph[x]){
		if(i == p) continue;
		par[i] = x;
		dfs(i, x);
	}
}

double dp[150005], pdp[150005], val[150005];
int cnt[150005];

int main(){
	cin >> n;
	for(int i=0; i<n-1; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	dfs(1, -1);
	for(int i=ord.size()-1; i>=0; i--){
		int p = ord[i];
		for(auto &j : gph[p]){
			if(j != par[p]){
				cnt[p]++;
				val[p] += 1 + dp[j];
			}
		}
		if(cnt[p]) dp[p] = val[p] / cnt[p];
		else dp[p] = 0;
	}
	for(int i=1; i<ord.size(); i++){
		int p = ord[i];
		int cs = cnt[par[p]];
		double vs = val[par[p]];
		if(par[p] != 1){
			cs++;
			vs += 1 + pdp[par[p]];
		}
		cs--;
		vs -= 1 + dp[p];
		if(cs) pdp[p] = vs / cs;
		else pdp[p] = 0;
	}
	for(int i=1; i<=n; i++){
		double tsum = val[i];
		int tcnt = cnt[i];
		if(i > 1){
			tcnt++;
			tsum += pdp[i] + 1;
		}
		printf("%.10f\n", tsum / tcnt);
	}
}


Measured memory_bytes: 19316
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(auto& x : a) cin >> x;
    for(auto& x : b) cin >> x;
    
    for(int i = 1; i < m; ++i) b[i] += b[i - 1];
    for(int i = 1; i < n; ++i) a[i] += a[i - 1]; 
    long long ans = 0;
    for(int i = 0; i <= n; ++i)
    {
        long long take = 0;
        if(i > 0) take += a[i - 1];
        
        if(take > k) {
            break;
        }
        long long rem = k - take;
        
        auto it = upper_bound(all(b), rem);
        long long cur = i;

        if(it == b.end()) {
            cur += m;
        }
        else {
            int dist = (int) (it - b.begin());
            cur += dist;
        }
        ans = max(ans, cur);
    }
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 6360
package main

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

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	X := sc.NextIntArray()

	box := make([]int, M)

	for i := 0; i < N; i++ {
		box[X[i] % M] += 1
	}

	ans := 0
	for k := 1; k <= M / 2; k++ {
		if k * 2 == M {
			continue
		}
		v := min(box[k], box[M - k])
		ans += v
		box[k] -= v
		box[M - k] -= v
	}
	ans += box[0] / 2
	box[0] %= 2
	if M % 2 == 0 {
		ans += box[M / 2] / 2
		box[M / 2] %= 2
	}
	mp := make([]int, 100000 + 1)
	for i := 0; i < N; i++ {
		mp[X[i]]++

		if mp[X[i]] == 2 {
			if box[X[i] % M] >= 2 {
				mp[X[i]] = 0
				box[X[i] % M] -= 2
				ans += 1
			}
		}

	}
	fmt.Println(ans)
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

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

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

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

	return result
}

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

	return mp
}

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

Measured memory_bytes: 7296
#include <iostream>
#include <climits>
int s[500001], l[250001], r[250001];
static long mg(int left, int m, int right) {
    int n1 = m - left, n2 = right - m, i = 0, j = 0;
    long c = 0;
    for (int k = 0; k < n1; ++k) {
        l[k] = s[left + k];
    }
    for (int k = 0; k < n2; ++k) {
        r[k] = s[m + k];
    }
    l[n1] = INT_MAX;
    r[n2] = INT_MAX;
    for (int k = left; k < right; ++k) {
        if (l[i] <= r[j]) {
            s[k] = l[i++];
        } else {
            s[k] = r[j++];
            c += n1 - i;
        }
    }
    return c;
}
static long msort(int left, int right) {
    long c = 0;
    if (left + 1 < right) {
        int m = left + (right - left) / 2;
        c += msort(left, m);
        c += msort(m, right);
        c += mg(left, m, right);
    }
    return c;
}
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> s[i];
    }
    long c = msort(0, n);
    std::cout << c << std::endl;
}



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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N,A,B;
  string s;
  cin>>N>>A>>B>>s;
  int cnt(0),cntb(0);
  for(int i(0);i<N;i++){
    if(s[i] == 'a'){
      if(cnt < A+B){
        cnt++;
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else if (s[i] == 'b'){
      if(cnt < A+B && cntb < B){
        cnt++;
        cntb++;
        cout << "Yes" << endl;
      } else cout << "No" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 896
// template {{{

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

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

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

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

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(std::begin(c), std::end(c))); }

// }}}

int n, m, c, a, b;
int g[20][100][100];
int g2[100][100];
int p[20], q[20][50], r[20][50];
int cost[20][20010];

int main()
{
	while (cin >> n >> m >> c >> a >> b, n){
		a--, b--;
		memset(cost, 0, sizeof(cost));
		fill_n(**g, 20 * 100 * 100, INF);
		rep(i, c) rep(j, n) g[i][j][j] = 0;
		fill_n(*g2, 100 * 100, INF);
		rep(i, n) g2[i][i] = 0;
		
		rep(i, m){
			int xi, yi, di, ci;
			cin >> xi >> yi >> di >> ci;
			xi--, yi--, ci--;
			chmin(g[ci][xi][yi], di);
			chmin(g[ci][yi][xi], di);
		}
		
		rep(i, c) cin >> p[i];
		rep(i, c){
			loop(j, 1, p[i]) cin >> q[i][j];
			q[i][0] = 0;
			q[i][p[i]] = 20005;
			rep(j, p[i]) cin >> r[i][j];
			rep(j, p[i]){
				loop(k, q[i][j], q[i][j + 1]){
					cost[i][k + 1] += cost[i][k] + r[i][j];
				}
			}	
		}

		rep(i, c) rep(j, n) rep(k, n) rep(l, n){
			chmin(g[i][k][l], g[i][k][j] + g[i][j][l]);
		}
		
		rep(i, c) rep(j, n) rep(k, n){
			if (g[i][j][k] == INF) continue;
			chmin(g2[j][k], cost[i][g[i][j][k]]);
		}
		
		rep(i, n) rep(j, n) rep(k, n){
			chmin(g2[j][k], g2[j][i] + g2[i][k]);
		}
		
		if (g2[a][b] == INF) cout << "-1\n";
		else cout << g2[a][b] << endl;
	}
}

Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int n;
ll ans=0;
int main()
{
   cin>>s;
   n=s.size();
   ll num=0;
   for(int i=0;i<n;i++)
   {
        if(s[i]=='A')
            num++;
        else if(s[i]=='B')
        {
            if(i+1<n && s[i+1]=='C')
                ans+=num,i++;
            else
                num=0;
        }
        else
            num=0;
   }
   printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int dp[50];

int fib(int n){
    if(n == 0 || n == 1) return dp[n] = 1;
    if(dp[n] != -1) return dp[n];
    return dp[n] = fib(n - 1) + fib(n - 2);
}
int main(){
    int n,i;
    for(i = 0;i < 50;i++){
        dp[i] = -1;
    }
    scanf("%d",&n);
    printf("%d\n",fib(n));
    
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int N;
int a[10001];
int dp1[10001];int dp1_[10001];
int dp2[10001];int dp2_[10001];
int main(){
	scanf("%d",&N);
	for(int i=1;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<10001;i++){
		dp1[i]=1<<30;dp1_[i]=1<<30;dp2[i]=1<<30;dp2_[i]=1<<30;
	}
	dp1[0]=0;
	for(int i=1;i<=N;i++){
		for(int j=0;j<10001;j++){
			dp1_[j]=1<<30;
		}
		for(int j=0;j<10001;j++){
			dp2_[j]=1<<30;
		}
		for(int j=1;j<=i;j++){
		//not cut
		dp1_[j]=min(dp1[j-1],dp1_[j]);
		dp2_[j]=min(dp2[j],dp2_[j]);
		//cut
		dp1_[j]=min(dp2[j-1]+a[i-1],dp1_[j]);
		dp2_[j]=min(dp1[j]+a[i-1],dp2_[j]);
		}
		for(int j=0;j<=i;j++){
			//if(j>=1)printf("%d %d:%d %d\n",i,j,dp1_[j],dp2_[j]);
			dp1[j]=dp1_[j];
			dp2[j]=dp2_[j];
		}
	}
	printf("%d\n",min(dp1[N/2],dp2[N/2]));
	return 0;
}

Measured memory_bytes: 3384
#include<stdio.h>
#include<string.h>
int main(){
	char s[1024];
	int ch,i,a[26];
	for(i=0;i<26;i++)a[i]=0;
	while(fgets(s,sizeof(s),stdin)!=NULL){
		for(i=0;i<strlen(s);i++){
			if('A'<=s[i]&&s[i]<='Z')a[s[i]-'A']++;
			else if('a'<=s[i]&&s[i]<='z')a[s[i]-'a']++;
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,a[i]);
	}
	return 0;
}
	

Measured memory_bytes: 524
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
    string s;
    map<char,int>m;
    cin >> s;

    for(char c = 'a';c <= 'z';c++)
        m[c] = 0;
    
    for(int i = 0;i < s.size();i++){
        m[s[i]]++;
    }

    for(auto &i:m)
        if(i.second == 0){
            cout << i.first << endl;
            return 0;
        }

    cout << "None" << endl;


    return 0;
}

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

int lpath(vector<int> g[],int x,int dp[])
{
	if(dp[x]!=-1)
		return dp[x]+1;
		
	int c=0;
	for(int i=0;i<g[x].size();i++)
	{
		c=max(c,lpath(g,g[x][i],dp));
	}	

	dp[x]=c;
	
	return c+1;
}

int main()
{
	int n,m;
	cin>>n>>m;
	
	vector<int> g[n+1];
	int x,y;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
	}

	int dp[n+1],ans=0;
	memset(dp,-1,sizeof dp);
	
	for(int i=1;i<=n;i++)
	{
		if(dp[i]==-1)
		{
			lpath(g,i,dp);
//			cout<<endl;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;

	return 0;
}

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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    
    int x, y;
    int left = -1e5, right = 1e5;
    bool flag = false;    

    for(int i=0; i<N; i++){
	cin >> x;
	left = max(left, x);
    }    
    for(int i=0; i<M; i++){
	cin >> y;
	right = min(y, right);
    }

    for(int i=left+1; i<=right; i++){
    	if(X<i && i<=Y)
    	    flag=true;
    }
    
    if(flag)
    	puts("No War");
    else
    	puts("War");            
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> F[102];
int start[102]={0},END[102]={0};
bool visit[102]={0};
int Count=0;
void dfs(int now){
	start[now]=Count++;
	visit[now]=true;
	int len=F[now].size();
	for(int i=0;i<len;i++){
		int p=F[now][i];
		if(visit[p]==false){
		     dfs(p);
		}
	}
	END[now]=Count++;
}
int main() {
	int n;
    cin>>n;
    for (int i=0;i<n;i++) {
            int s,num;
            cin>>s>>num;
            s--;
            for (int j=0;j<num;j++) {
                int e;
                cin>>e;
                e--;
				if(e!=s){
					F[s].push_back(e);
				}
            }
        }
        for (int i=0;i<n;i++){
			if(visit[i]==false){
				dfs(i);
			}
        }      
        for (int i = 0; i < n;i++) {
            cout<<i+1<<" "<<start[i]+1<<" "<<END[i]+1<<endl;
        }
    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
int main(){
    int a,b,c,d,e,n,m;
    string s;
    bool flag=false;
    cin>>a>>b;
    for(int i=0;i<max(a,b);i++){
        if(abs(a-i)==abs(b-i)){
            cout<<i<<endl;
            flag=true;
            break;
        }
    }
    if(!flag)cout<<"IMPOSSIBLE"<<endl;


}

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

using namespace std;

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


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  int lo=n+1;
  int ans=0;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    ans += x<=lo;
    lo = min(lo,x);
  }
  out(ans);
  

  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int r,s,p; cin >> r >> s >> p;
    string t; cin >> t;
    ll ans = 0;
    for(int i=0;i<k;i++){
        int j=i;
        if(t[j]=='r') ans+=p;
        if(t[j]=='s') ans+=r;
        if(t[j]=='p') ans+=s;

        while(j<n){
            if(t[j]==t[j+k]) t[j+k]='a';
            if(t[j]!=t[j+k]){
                if(t[j+k]=='r') ans+=p;
                if(t[j+k]=='s') ans+=r;
                if(t[j+k]=='p') ans+=s;
            }
            j+=k;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N = in< int >();
  vec<int>a(N);
  REP(i,N){
      cin>>a[i];
  }
  double sum=0;
  REP(i,N){
      sum+=1.0/a[i];
  }
  cout << setprecision(10) << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<vector>
#include<memory>
using namespace std;
int n,m,a[100005],dp[100005];
long long sol(int x){
	if(x>=n-1)return 0;
	if(dp[x]!=-1){
		return dp[x];
	}else {
		int t=0,y=0;	
		y=sol(x+1)+abs(a[x+1]-a[x]);
		if(x==n-2){
			t=y;
		}else t=sol(x+2)+abs(a[x+2]-a[x]);
		dp[x]= min(y,t);
		return dp[x];
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		dp[i]=-1;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	long long r=sol(0);
	cout<<r;
}

Measured memory_bytes: 4096
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, M;
    cin >> N >> M;
    struct Edge {
        ll from;
        ll to;
    };
    vector<Edge> edges;
    rep(i,0,M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges.push_back(Edge{a, b});
        edges.push_back(Edge{b, a});
    }
    ll Q;
    cin >> Q;
    struct Query {
        ll v;
        ll d;
        ll c;
    };
    vector<Query> queries(Q);
    rep(q,0,Q) {
        ll v, d, c;
        cin >> v >> d >> c;
        v--;
        queries[q] = {v, d, c};
    }
    struct Data {
        ll p; // priority
        ll c; // color
        void add(const Data& rhs) {
            if (rhs.p > p) {
                *this = rhs;
            }
        }
    };
    vector<vector<Data>> data(N);
    rep(i,0,N) {
        data[i] = vector<Data>(11, Data{-1, 0});
    }
    rep(i,0,Q) {
        Query q = queries[i];
        data[q.v][q.d].add(Data{i, q.c});
    }
    rep(loop,0,11) {
        for (Edge& e : edges) {
            rep(d,1,11) {
                data[e.to][d-1].add(data[e.from][d]);
            }
        }
    }
    rep(i,0,N) {
        Data ans{-1, 0};
        rep(d,0,11) {
            ans.add(data[i][d]);
        }
        cout << ans.c << endl;
    }
}



Measured memory_bytes: 28140
n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append((i, a, b))

rm = []
for i, a, b in sorted(ab, key=lambda x:x[2]):
    pre = ab[rm[-1]][2] - 1 if len(rm) else 0
    if a <= pre:
        continue
    else:
        rm.append(i)
print(len(rm))


Measured memory_bytes: 64600
N,P = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0 for _ in range(2)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(1,N+1):
	if A[i-1]%2 == 0:
		dp[i][0] = 2*dp[i-1][0]
		dp[i][1] = 2*dp[i-1][1]
	else:
		dp[i][0] = dp[i-1][0] + dp[i-1][1]
		dp[i][1] = dp[i-1][0] + dp[i-1][1]

print(dp[N][P])

Measured memory_bytes: 3064
/* ***************************************
Author        :Scau.ion
Created Time  :2017/09/23 20:17:18 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
    IOS;
    int n, m;
    cin>>n>>m;
    int sum[26];
    memset(sum, 0, sizeof sum);
    char s[1010];
    for (int j = 1; j <= n; ++ j)
    {
        cin>>(s + 1);
        for (int k = 1; k <= m; ++ k)
        {
            ++ sum[s[k] - 'a'];
        }
    }
    int s1 = 0, s2 = 0;
    for (int j = 0; j < 26; ++ j)
    {
        if (sum[j] % 2)
        {
            ++ s1;
            -- sum[j];
        }
        if (sum[j] % 4)
        {
            ++ s2;
            sum[j] -= 2;
        }
    }
    bool flag = 1;
    if (s1 > 0 && (n % 2 == 0 || m % 2 == 0)) flag = 0;
    if (s1 == 0 && n % 2 == 1 && m % 2 == 1) flag = 0;
    if (s1 > 1) flag = 0;
    int ok = 0;
    if (n % 2) ok += m / 2;
    if (m % 2) ok += n / 2;
    if (ok < s2) flag = 0;
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i, N) cin >> L[i];
	sort(L.begin(), L.end());

	int ans = 0;
	rep(b, N)rep(a, b) {
		int ab = L[a] + L[b];
		int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
		int l = b + 1;
		// c = [l, r)
		ans += max(0, r - l);
	}

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


Measured memory_bytes: 256
#!/usr/bin/env ruby

ball = {A: 1, B: 0, C: 0}

while line = gets
  a, b = line.chomp!.split(?,).map(&:to_sym)

  ball[a], ball[b] = ball[b], ball[a]
end

ball.each do |k, v|
  puts k.to_s if v == 1
end

Measured memory_bytes: 8628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  vector<ll> A(N);
  rep(i,N)
  {
    cin>>A.at(i);
  }
  sort(A.rbegin(),A.rend());
  ll ans=0;
  ans+=A.at(0);
  for(int i=1;i<(N-2)/2+1;i++)
  {
    ans+=2*A.at(i);
    if(N%2==1&&i==(N-2)/2)
    {
      ans+=A.at(i+1);
    }  
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4916
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void swap_int(int *x, int *y) {int temp;temp = *x;*x = *y;*y = temp;}
void swap_char(char *x, char *y) {char temp;temp = *x;*x = *y;*y = temp;}
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x > y ? y : x; }

int main(){
    int n,x,l[200],d[200];
    int i,j,k;

    scanf("%d %d",&n,&x);
    for(i=0;i<n;i++)scanf("%d",&l[i]);

    d[0]=0;
    for(i=1;i<n+1;i++)d[i]=d[i-1]+l[i-1];
    
    int cnt=0;
    for(i=0;i<n+1;i++){
        if(d[i]<=x)cnt++;
    }
    printf("%d\n",cnt);
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

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

int main() {
    int n; cin >> n;
    map<string, int> mp;
    vector<string> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        mp[v[i]]++;
        if (i == 0){
            continue;
        }
        if (mp[v[i]] > 1){
            print("No");
            return 0;
        }
        if (v[i-1][v[i-1].size()-1] != v[i][0]){
            print("No");
            return 0;
        }
    }
    print("Yes");
}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int n;
	cin>>n;
	ll arr[n],x=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		x^=arr[i];
	}
	for(int i=0;i<n;i++){
		arr[i]=x^arr[i];
		cout<<arr[i]<<" ";
	}
	
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
 	return 0;
}


Measured memory_bytes: 5164
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

#define maxN 100100
uint64_t dp[maxN];
uint16_t H[maxN];

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

  for (int n=0; n<N; ++n)
    cin >> H[n];

  dp[0] = 0;
  for (int n=1; n<N; ++n)
    dp[n] = UINT64_MAX;

  for (int n=0; n<N; ++n) {
    for (int k=1; k<=K; ++k) {
      dp[n+k] = min(dp[n+k], dp[n]+abs(H[n+k]-H[n]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1280