akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s;
		int num;
		int[] count = new int[9];
		int[] ans = new int[10];
		int anscnt;
		while(sc.hasNext()){
			s = sc.next();
			anscnt = 0;
			//ÇÌª½Â é©²×é
			Arrays.fill(count, 0);
			for(int i = 0; i < 13; i++){
				count[ s.charAt(i) - '1']++;
			}

			for(int i = 0; i < 9; i++){
				if(count[i] < 4){
					count[i]++;
					if(check(count, 14)){
						ans[anscnt++] = i + 1;
					}
					count[i]--;
				}
			}
			if(anscnt == 0){
				System.out.println(0);
			}else{
				System.out.print(ans[0]);
				for(int i = 1; i < anscnt; i++){
					System.out.print(" " + ans[i]);
				}
				System.out.println();
			}
		}
	}
	public static boolean check(int[] count, int nokori){
		if(nokori == 2){
			for(int i = 0; i < 9; i++){
				if(count[i] >= 2){
					return true;
				}
			}
			return false;
		}

		for(int i = 0; i < 9; i++){
			if(count[i] >= 3){
				count[i] -= 3;
				if(check(count, nokori - 3)){

					count[i] += 3;
					return true;
				}
				count[i] += 3;
			}
		}
		for(int i = 0; i < 7; i++){
			if(count[i] >= 1 && count[i + 1] >= 1 && count[i + 2] >= 1){
				count[i]--;
				count[i + 1]--;
				count[i + 2]--;
				if(check(count, nokori - 3)){
					count[i]++;
					count[i + 1]++;
					count[i + 2]++;
					return true;
				}
				count[i]++;
				count[i + 1]++;
				count[i + 2]++;
				
			}
		}
		return false;
	}
}

Measured memory_bytes: 0
#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,MOD2=998244353;



int main() {
    int N,K,C;
    string S;
    cin>>N>>K>>C>>S;
    vector<int> L,R,l(K),r(K);
    int point=0;
    while(point<N){
        
        if(S.at(point)=='o'){
            L.push_back(point);
            point+=C+1;
        }
        else if(S.at(point)=='x'){point++;}
    }
    rep(i,K){
        l.at(i)=L.at(i);
    }

    point=0;
    reverse(S.begin(),S.end());
    while(point<N){
        
        if(S.at(point)=='o'){
            R.push_back(point);
            point+=C+1;
        }
        else if(S.at(point)=='x'){point++;}
    }
    rep(i,K){
        r.at(i)=N-1-R.at(i);
    }
    reverse(r.begin(),r.end());
    int ans=0;
    rep(i,K){
        if(r.at(i)==l.at(i))cout<<r.at(i)+1<<endl;;
    }
}

Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n)cout<<"x";
    cout<<endl;
    return 0;
}

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

int main() {
  
  while(1){
    
    int n,r,i,j,k;
    cin >>n>>r;
    if (n==0&&r==0)break;
    
    vector<int> nom;
    for(i=0;i<n;i++)
      nom.push_back(n-i);
    
    for(i=0;i<r;i++){
      int p,c;
      cin >>p>>c;
      for(j=0;j<p-1;j++){
	int temp;
	temp = nom[0];
	for(k=0;k<p+c-2;k++)nom[k]=nom[k+1];
	nom[c+p-2] = temp;
      }
    }
    cout << nom[0] <<endl;
    
  }
  return 0;
  
}

Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cout<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define all(x) (x).begin(),(x).end()

typedef long long int64;


int main() {
    string w;
    cin >> w;
    int n = w.size();
    vector<bool> beautiful(26, true);

    for (int i=0; i<n; i++) {
        beautiful[w[i] - 'a'] = !beautiful[w[i] - 'a'];
    }

    if (all_of(all(beautiful), [](bool x){return x;}))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  map<string, int> m;
  REP(i, n) {
    string s;
    cin >> s;
    if (!m.count(s)) {
      m[s] = 1;
    } else {
      m[s]++;
    }
  }
  int ans = 0;
  auto it = m.begin();
  while (it != m.end()) {
    ans++;
    it++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

list = []
for x in range(4):
    building = []
    for y in range(3):
        floor = []
        for z in range(10):
            floor.append(0)
        building.append(floor)
    list.append(building)

for x in range(n):
    building, floor, room, num = map(int, input().split())
    list[building - 1][floor - 1][room - 1] += num

flag = False
for building in list:
    if(flag):
        print("####################")
    else:
        flag = True

    for floor in building:
        string = ""
        for room in floor:
            string += " " + str(room)

        print(string)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();

  vector<ll> t;
  for (auto &x: s) t.push_back(x - '0');

  ll total = 0;
  for (int i = 0; i < (1 << (n-1)); i++) {
    int m = i;
    ll a = t[0];
    for (int j = 1; j < n; j++) {
      if (m & 1) {
        total += a;
        a = t[j];
      }
      else {
        a *= 10;
        a += t[j];
      }
      m >>= 1;
    }
    total += a;
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
import queue
def main():
    n = int(input())
    a = []
    b = []
    c = []
    lst = [[] for _ in range(n)]

    for i in range(n - 1):
        aa, bb, cc = map(int,input().split())
        lst[aa - 1].append((bb - 1, cc))
        lst[bb - 1].append((aa - 1, cc))

    q, k = map(int,input().split())
    x = []
    y = []
    for i in range(q):
        xx, yy = map(int,input().split())
        x.append(xx - 1)
        y.append(yy - 1)
    qq = queue.Queue()
    qq.put(k - 1)
    dist = [0] * n
    while not qq.empty():
        now = qq.get()
        for to, w in lst[now]:
            if dist[to] != 0:
                continue
            dist[to] = dist[now] + w
            qq.put(to)

    for i in range(q):
        print(dist[x[i]] + dist[y[i]])





if __name__ == '__main__':
    main()


Measured memory_bytes: 52420
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

long long A, B, C, D;
long long INF = 5e18;

void min_self(long long& a, long long b) {
	a = min(a, b);
}

map<long long, long long> mapka;

long long f(long long goal) {
	if(goal == 0) {
		return 0;
	}
	if(goal == 1) {
		return D;
	}
	if(mapka.count(goal)) {
		return mapka[goal];
	}
	long long best = INF;
	if(D < INF / goal) {
		min_self(best, D * goal);
	}
	for(int i = 0; i < 3; ++i) {
		int mul = vector<int>{2,3,5}[i];
		long long cost = vector<long long>{A,B,C}[i];
		if(goal % mul == 0) {
			min_self(best, cost + f(goal / mul));
		}
		else {
			long long down = goal / mul * mul;
			min_self(best, cost + D * (goal - down) + f(goal / mul));
			long long up = down + mul;
			min_self(best, cost + D * (up - goal) + f(goal / mul + 1));
		}
	}
	return mapka[goal] = best;
}

void test_case() {
	long long N;
	cin >> N;
	cin >> A >> B >> C >> D;
	cout << f(N) << endl;
	mapka.clear();
}

int main() {
	int T;
	cin >> T;
	while(T--) {
		test_case();
	}
}


Measured memory_bytes: 4500
#include <stdio.h>
int main(void){
        int n;
        int i;

        scanf("%d",&n);

        int k[n],p[n],w[i];

    for(i=0; i<n; i++){

                scanf("%d %d",&k[i],&p[i]);

                if(k[i]%p[i]==0)
                        w[i]=p[i];

                else
                        w[i]=k[i]%p[i];

                }

        for(i=0; i<n; i++){

                printf("%d\n",w[i]);

        }

        return 0;

}

Measured memory_bytes: 596
//Gaurav Singh (saintpopo)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ii pair<ll,ll>;
#define vi vector<int>;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(int i = a; i < b; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
    ll n,x;
    cin >> n;
    unordered_map<ll, ll>m;
    while(n--){
        cin>>x;
        if(m[x]){
            m[x]-=1;
        }
        else{
            m[x]=1;
        }
    }
    ll c=0;
    for(auto it : m){
        if(it.second == 1){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
int n,x,v[1005],f[1005],g[2][5005];vector<int>e[1005];
bool dfs(int x)
{
    if(!e[x].size()){f[x]=0;return 1;}
    for(int i=0;i<e[x].size();i++) if(!dfs(e[x][i])) return 0;
    int w=1;memset(g[w],0x3f,sizeof(g[w]));g[w][0]=0;
    for(int i=0;i<e[x].size();i++)
    {
        w=!w;memset(g[w],0x3f,sizeof(g[w]));
        for(int j=0;j<=v[x];j++)
        {
            if(j>=f[e[x][i]]) g[w][j]=min(g[w][j],g[w^1][j-f[e[x][i]]]+v[e[x][i]]);
            if(j>=v[e[x][i]]) g[w][j]=min(g[w][j],g[w^1][j-v[e[x][i]]]+f[e[x][i]]);
        }
    }
    int gg=2147483647;
    for(int i=0;i<=v[x];i++) gg=min(gg,g[w][i]);
    if(gg>1e9) return 0;f[x]=gg;return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++) scanf("%d",&x),e[x].push_back(i);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    if(dfs(1)) puts("POSSIBLE");else puts("IMPOSSIBLE");
}

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

double distpp(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double distpl(double xp, double yp,
              double x1, double y1,
              double x2, double y2){
    return abs((y1-y2)*(xp-x1)-(x1-x2)*(yp-y1))
           /distpp(x1, y1, x2, y2);
}

int main(){
    int n, m, i, j;
    while( cin >> n, n ){
        vector<double> wx(n),wy(n),r(n);
        for(i=0;i<n;i++){
            cin>>wx[i]>>wy[i]>>r[i];
        }
        cin >> m;
        double tx, ty, sx, sy;
        for(i=0;i<m;i++){
            cin>>tx>>ty>>sx>>sy;
            bool safe = false;
            for(j=0;j<n;j++){
                double d1 = distpp(wx[j],wy[j],tx,ty),
                       d2 = distpp(wx[j],wy[j],sx,sy);
                if( (d1-r[j])*(d2-r[j]) < 0 ){
                    safe = true; break;
                }
                if( d1 < r[j] ) continue;
                if( distpl(wx[j],wy[j],tx,ty,sx,sy) <= r[j] &&
                    ((sx-tx)*(sx-wx[j])+(sy-ty)*(sy-wy[j]))*
                    ((sx-tx)*(tx-wx[j])+(sy-ty)*(ty-wy[j])) < 0 ){
                    safe = true; break;
                }
            }
            if( safe ){
                cout << "Safe" << endl;
            }else{
                cout << "Danger" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=55;
int n;
int a[N][N],b[N];
bool check(int *a,int b,int k){
	static int dp[N];
	clr(dp);
	dp[b]=1;
	For(i,1,k)
		For(j,0,50)
			dp[j]|=dp[j%i];
	For(i,0,50)
		if (dp[i]&&a[i])
			return 1;
	return 0;
}
bool check(int a[N][N],int k){
	For(i,1,n)
		if (!check(a[i],b[i],k))
			return 0;
	return 1;
}
int main(){
	n=read();
	For(i,1,n)
		a[i][read()]=1;
	For(i,1,n)
		b[i]=read();
	if (!check(a,50))
		return puts("-1"),0;
	LL ans=0;
	Fod(i,50,1)
		if (!check(a,i-1)){
			ans+=1LL<<i;
			For(j,1,n)
				For(k,0,50)
					a[j][k%i]|=a[j][k];
		}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    using namespace std;
    size_t N, K;
    cin >> N >> K;
    deque<unsigned long> A(N), next(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    {
        auto mx = *max_element(A.cbegin(), A.cend());
        deque<unsigned long> prev(mx + 1, ~0UL);
        vector<pair<unsigned long, unsigned long>> first;
        for(unsigned long index = 0; index < N; ++index){
            const auto i = A[index];
            if(~prev[i]){
                next[prev[i]] = index;
            }else{
                first.emplace_back(index, i);
            }
            prev[i] = index;
        }
        for(const auto& i : first)next[prev[i.second]] = i.first + N;
    }

    vector<unsigned long> dist(N, ~0UL);
    deque<unsigned long> ans;
    {
        unsigned long now = 0, d = 0;
        while(!~dist[now]){
            dist[now] = d;
            auto t = next[now] + 1;
            if(t >= N){
                d += t / N;
                t %= N;
            }
            now = t;
        }
        d += (K - d) / (d - dist[now]) * (d - dist[now]);
        while(d < K){
            auto t = next[now] + 1;
            if(t >= N){
                d += t / N;
                t %= N;
            }
            if(d == K)break;
            now = t;
        }
        unordered_map<unsigned long, unsigned long> mp;
        for(; now < N; ++now){
            const auto a = A[now];
            if(mp[a]){
                while(ans.back() != a){
                    mp[ans.back()] = 0;
                    ans.pop_back();
                }
                ans.pop_back();
            }else{
                ans.push_back(a);
            }
            mp[a] ^= 1;
        }
    }
    copy(ans.begin(), ans.end(), ostream_iterator<unsigned long>(cout, " "));
    return 0;
}

Measured memory_bytes: 16180
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vector<pi> p;
	rep(i, n){
		int a, b; cin >> a >> b;
		p.emplace_back(a, b);
	}
	sort(all(p),[]
		(pi a, pi b){
			return a.second < b.second;
		});
	int prev = 0;
	rep(i, n){
		//dbg(prev, p[i].first, p[i].second);
		if(prev + p[i].first > p[i].second){
			cout << "No" << endl;
			return 0;
		}
		prev += p[i].first;
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 2420
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val input = listOfInt()
  	val a = input[0]
  	val b = input[1]
    if((a%2==0 && b%2!=0) || (a%2!=0 && b%2==0)){
      println("IMPOSSIBLE")
    }else{
      if(a%2!=0){
        println(a/2+b/2+1);
      }else{
        println(a/2+b/2);
      }
    }
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

fun println(value : Any) {
    pw.println(value)
}


Measured memory_bytes: 37904
import sys
N, K = map(int, input().split())
num = []
for _ in range(N):
    a, b = map(int, input().split())
    num.append((a, b))
num = sorted(num, key=lambda x: x[0])
s = 0
for item in num:
    s += item[1]
    if s >= K:
        print(item[0])
        sys.exit()

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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(i % 2 && x % 2)
            cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 3620
n=int(input())
l=list(map(int,input().split()))
l.sort()
from bisect import bisect_left
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        ans+=max(0,bisect_left(l,a+b)-j-1)
print(ans)


Measured memory_bytes: 44636
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, done = 0, c = 0;
    ll ans = 0;
    cin >> n;
    vector <ll> v(n);
    for (ll &x : v) cin >> x;
    sort (v.rbegin(), v.rend());
    ans += v[0];
    c++;
    done += 2;
    while (done + 2 <= n) {
        ans += 2*v[c];
        c++;
        done += 2;
    }
    if (done != n) ans += v[c];
    cout << ans;
    return 0;
}




Measured memory_bytes: 4776
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	if (S[0] == 'A')
	{
		bool flag[2] = { false };
		flag[1] = true;
		rep(i, 1, SZ(S))
		{
			if (S[i] == 'C')
			{
				if (2 <= i && i <= SZ(S) - 2 && !flag[0])
				{
					flag[0] = true;
				}
				else
				{
					flag[0] = false;
					break;
				}
			}
			else if (!('a' <= S[i] && S[i] <= 'z'))
			{
				flag[1] = false;
				break;
			}
		}

		if (flag[0] && flag[1])
		{
			cout << "AC" << endl;
			return 0;
		}
	}

	cout << "WA" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;


int main()
{
	long long int N, power;
	power = 1;

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		power = (i * power) % ((int)pow(10, 9) + 7);
	}

	cout << power  << endl;

	return 0;
}

Measured memory_bytes: 256
n , m , x = map(int, input().split())
a = list(list(map(int, input().split())) for _ in range(n))

c = []
for i in range(n):
    c.append(a[i][0])
    a[i].pop(0)

ans = 1000000000

# bit全探索
for i in range(1 << n):
    score = [0] * m
    tmp = 0
    for j in range(n):
        if (i >> j) % 2 == 1:
            tmp += c[j]
            for k in range(m):
                score[k] += a[j][k]

    if min(score) >= x:
        ans = min(ans , tmp)

if(ans == 1000000000):
    print(-1)
else:
    print(ans)


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    
    int a[n+1];
    f1(i,1,n+1)
    cin>>a[i];

    int ans = 0;
    int temp = 0, curr = 1;

    int vis[n+1];
    memset(vis, -1, sizeof vis);
    vis[1] = 0;
    int cyc = -1,start = -1, base = -1;
    while(1)
    {
        curr = a[curr];
        temp++;
        if(temp == k)
        {
            cout<<curr<<endl;
            return 0;
        }
        else if(curr == a[curr])
        {
            cout<<curr<<endl;
            return 0;
        }
        if(vis[curr] >= 0)
        {
            k -= (vis[curr]);
            base = vis[curr];
            cyc = temp - vis[curr];
            start = curr;
            break;
        }
        vis[curr] = temp;
    }
    k %= cyc;

    f1(i,1,n+1)
    if(vis[i] == base + k) cout<<i<<endl;

    return 0;
}

Measured memory_bytes: 6760
N = int(input())
TT,AA= map(int,input().split())
for k in range(1,N):
    T,A = map(int,input().split())
    j = max((TT-1+T)//T,(AA-1+A)//A)
    TT = T*j 
    AA = A*j
        
print(TT + AA)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
map<int,ll>::iterator it;
int n,m;
int main(){
	cin>>n>>m;
	map<int,ll> mp;
	multiset<ll> values;
	for(int i=1; i<=m; i++){
		mp[i] = 0;
		values.insert(0);
	}
	for(int i=1; i<=n; i++){
		int l, r;
		cin >> l >> r;
		if(r != m){
			it = mp.upper_bound(r+1);
			if(it != mp.begin()){
				it--;
				if(it->first != r+1){
					int64_t v = it->second + (r+1-it->first);
					mp[r+1] = v;
					values.insert(v);
				}
			}
		}
		it = mp.lower_bound(l);
		while(it != mp.end() && it->first <= r){
			values.erase(values.find(it->second));
			it = mp.erase(it);
		}
		if(values.size())
			cout << i + *values.begin() << endl;
		else
			cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 25488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n<10)cout<<n<<endl;
    else if(n<100)cout<<9<<endl;
    else if(n<1000)cout<<n-90<<endl;
    else if(n<10000)cout<<909<<endl;
    else if(n<100000)cout<<n-9090<<endl;
    else cout<<90909<<endl;

    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;
//int n,k,l,x,y,head,tail;
//int ans[210000];
//struct node
//{
//    int a,b;
//}v[210000];
//bool cmp(node x,node  y)
//{
//    if(x.a==y.a)
//    {
//        return x.b<y.b;
//    }
//    else return x.a<y.a;
//}
ll a,b;
char c;
int main()
{
    cin>>a>>c>>b;
    if(c=='+')
        cout<<a+b;
    else if(c=='-')
        cout<<a-b;
//   cin>>n>>k>>l;
//
//    for(int i=1;i<=k;++i)
//    {
//        cin>>x>>y;
//        if(x<y)
//        {
//            v[i].a=x;
//            v[i].b=y;
//        }
//        else
//        {
//            v[i].b=x;
//            v[i].a=y;
//        }
//    }
//    for(int i=k+1;i<=k+l;++i)
//    {
//        cin>>x>>y;
//        if(x<y)
//        {
//            v[i].a=x;
//            v[i].b=y;
//        }
//        else
//        {
//            v[i].b=x;
//            v[i].a=y;
//        }
//    }
//    sort(v+1,v+1+l+k,cmp);
//    head=v[1].a;
//    tail=v[1].b;
//    ans[v[1].a]++;
//    ans[v[1].b]++;
//    for(int i=2;i<=k+l;++i)
//    {
//        while(v[i].a!=head||v[i].b!=tail)
//        {
//            ans[v[i].a]++;
//            ans[v[i].b]++;
//            head=v[i].a;
//            tail=v[i].b;
//        }
//    }
//    for(int i=1;i<=n;++i)
//    {
//        cout<<ans[i]<<endl;
//    }


//    FOR(i,1,k+l)
//    {
//        cout<<v[i].a<<" "<<v[i].b<<endl;
//    }


}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n; // 2 <= N <= 80
  cin >> n; // N日
  vector<int> a(n+1, 0); // 100 <= a <= 200
  rep(i, n) {
    cin >> a[i];
  }
  ll money = 1000;
  ll stock = 0;

  int last = a[0];
  for(int i = 1; i < n+1; ++i) {
    const int ai = a[i];
    if (last < ai) { // 上がる
      stock += money / last;
      money -= (money / last) * last;
    } else if (last > ai) {
      money += stock * last;
      stock = 0;
    }
    last = ai;
  }
  cout << money << endl;
  return 0;
}


Measured memory_bytes: 3556
import java.util.*;
import java.awt.geom.*;
public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int s = sc.nextInt();
			int numbers = n * 2;
			int [] takestone = new int[numbers];
			for(int i = 0; i < numbers; i++){
				takestone[i] = sc.nextInt();
			}
			boolean [][] dp = new boolean[numbers][s + 1];
			for(int i = 0; i < numbers; i++){
				if(i % 2 == 0){
					dp[i][1] = false;
				}
				else{
					dp[i][1] = true;
				}
			}
			for(int i = 2; i <= s; i++){
				for(int j = 0; j < numbers; j++){
					boolean iswin = dp[(j+1) % numbers][i-1];
					for(int k = 2; k <= takestone[j]; k++){
						if(i- k < 0) break;
						if(j % 2 == 0){
							iswin = iswin || dp[(j+1) % numbers][i - k];
						}
						else{
							iswin = iswin && dp[(j+1) % numbers][i - k];
						}
					}
					dp[j][i] = iswin;
				}
			}

			System.out.println(dp[0][s] ? 1 : 0);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> seti;
    for (int n = 0; n < N; ++n) {
        int tmp;
        cin >> tmp;
        seti.insert(tmp);
    }
    
    cout << seti.size() << "\n";

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let xor = a.iter().fold(0, |xor, &a| xor ^ a);
    let mut a = a.into_iter().map(|a| a & !xor).collect::<Vec<_>>();

    let mut rank = 0;
    for i in (0..61).rev() {
        let bit = 1 << i;
        if let Some(j) = (rank..n).find(|&i| a[i] & bit != 0) {
            a.swap(rank, j);
            rank += 1;
            for i in 0..n {
                if i == rank - 1 {
                    continue;
                }
                if a[i] & bit != 0 {
                    a[i] ^= a[rank - 1];
                }
            }
        }
    }
    let t = a.into_iter().fold(0, |xor, a| xor ^ a);
    let ans = t * 2 + xor;
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

map<ll, ll> mp;

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

  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0)cout<<s[i];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 592
def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
        return
    for i in range(N//2):
        if S[i] != S[i + N//2]:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
bool vh[1000005],vw[1000005],ban[65][65];
int bh[1000005],bw[1000005],nh[1000005];
int nw[1000005],h,w,n,x[31],y[31],c1=0,c2=0;
int kh[105],kw[105],wgt[65][65],dis[65][65];
int que[10005][2],l=1,r=0;
inline int mul(int a,int b){
	return 1ll*a*b%mod;
}

inline int sub(int a,int b){
	return(a-b<0?a-b+mod:a-b);
}

inline bool ok(int a,int b){
	if(a<=0||a>c1||b<=0||b>c2||ban[a][b])
	return 0;
	return 1;
}

int main(){
	int i,j,k,l,ans=0;
	scanf("%d%d%d",&h,&w,&n);
	for(i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		++x[i];++y[i];
		++nh[x[i]];++nw[y[i]];
		vh[x[i]]=vw[y[i]]=1;
	}
	bh[1]=++c1;++kh[1];
	int lo=0,tot=mul(h,w)-n;
	if(tot<0) tot+=mod;
	for(i=2;i<=h;++i){
		lo+=(w-nh[i-1]);
		if(lo>=mod)lo-=mod;
		if((!vh[i-1])&&(!vh[i])){
			ans+=mul(lo,sub(tot,lo));
			if(ans>=mod)ans-=mod;
			bh[i]=bh[i-1];++kh[c1];
		}else{
			bh[i]=++c1;
			kh[c1]=1;
		}
	}
	bw[1]=++c2;++kw[1];
	lo=0;tot=mul(h,w)-n;
	if(tot<0)tot+=mod;
	for(i=2;i<=w;++i){
		lo+=(h-nw[i-1]);
		if(lo>=mod)lo-=mod;
		if((!vw[i-1])&&(!vw[i])){
			ans+=mul(lo,sub(tot,lo));
			if(ans>=mod)ans-=mod;
			bw[i]=bw[i-1];++kw[c2];
		}else{
			bw[i]=++c2;
			kw[c2]=1;
		}
	}
	for(i=1;i<=c1;++i){
		for(j=1;j<=c2;++j){
			wgt[i][j]=mul(kh[i],kw[j]);
		}
	}
	for(i=1;i<=n;++i){
		ban[bh[x[i]]][bw[y[i]]]=1;
	}
	ans<<=1;
	if(ans>=mod)ans-=mod;
	for(i=1;i<=c1;++i){
		for(j=1;j<=c2;++j){
			if(ban[i][j])continue;
			l=1;r=0;que[++r][0]=i;
			que[r][1]=j;
			memset(dis,0x7f,sizeof(dis));
			dis[i][j]=0;
			while(l<=r){
				int a=que[l][0],b=que[l][1];
				++l;
				if(ok(a-1,b)&&
				dis[a-1][b]>dis[a][b]+1){
					dis[a-1][b]=dis[a][b]+1;
					que[++r][0]=a-1;
					que[r][1]=b;
				}
				if(ok(a+1,b)&&
				dis[a+1][b]>dis[a][b]+1){
					dis[a+1][b]=dis[a][b]+1;
					que[++r][0]=a+1;
					que[r][1]=b;
				}
				if(ok(a-1,b)&&
				dis[a-1][b]>dis[a][b]+1){
					dis[a-1][b]=dis[a][b]+1;
					que[++r][0]=a-1;
					que[r][1]=b;
				}
				if(ok(a,b-1)&&
				dis[a][b-1]>dis[a][b]+1){
					dis[a][b-1]=dis[a][b]+1;
					que[++r][0]=a;
					que[r][1]=b-1;
				}
				if(ok(a,b+1)&&
				dis[a][b+1]>dis[a][b]+1){
					dis[a][b+1]=dis[a][b]+1;
					que[++r][0]=a;
					que[r][1]=b+1;
				}
			}
			int tp=0;
			for(k=1;k<=c1;++k){
				for(l=1;l<=c2;++l){
					if(ban[k][l])continue;
					int x=dis[k][l];
					tp+=mul(x,wgt[k][l]);
					if(tp>=mod)tp-=mod;
				}
			}
			tp=mul(tp,wgt[i][j]);
			ans+=tp;
			if(ans>=mod)ans-=mod;
		}
	}
	if(ans&1)ans+=mod;
	printf("%d\n",ans>>1);
	return 0;
}

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

int main() {
  int N,a=0,b=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    if(a<p.at(i)){
      b=a;
      a=p.at(i);
    }
    else{
      b=max(b,p.at(i));
    }
  }
  for(int i=0;i<N;i++){
    if(p.at(i)==a){
      cout<<b<<endl;
    }
    else{
      cout<<a<<endl;
    }
  }
}

Measured memory_bytes: 2432
#include <stdio.h>

int main(void)
{
	unsigned int in_age;
	int no;
	int i;
	
	while (1){
		int data[7] = { 0 };
		scanf("%d", &no);
		if (no == 0){
			break;
		}
		
		while (no-- > 0){
			scanf("%d", &in_age);
			
			if (in_age >= 60){
				data[6]++;
			}
			
			else {
				data[in_age / 10]++;
			}
		}
		
		for (i = 0; i < 7; i++){
			printf("%d\n", data[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 408
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x*res);
    x=(x*x);
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

bool issafe(int x,int y,int n,int m){
  return (x>=0 && y>=0 && x<n && y<m);
}
int ans;



void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
       int n;
       cin>>n;
       
       int a[n];
       forn(i,0,n)
       cin>>a[i];
       
       int lmin[n];
       lmin[0]=a[0];
       
       for(int i=1;i<n;i++)
       lmin[i]=min(a[i],lmin[i-1]);
       
       int ans=0;
       forn(i,0,n){
           if(lmin[i]>=a[i])
           ans++;
       }
       cout<<ans;
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 1792
while True:
    n = int(input())
    if n == 0:
        break
    gems = {tuple(int(i) for i in input().split()) for _ in range(n)}
    m = int(input())
    nx = ny = 10

    for _ in range(m):
        d, l = input().split()
        l = int(l)
        for i in range(l):
            if d == 'N':
                ny += 1
            if d == 'E':
                nx += 1
            if d == 'S':
                ny -= 1
            if d == 'W':
                nx -= 1
            if (nx, ny) in gems:
                gems.remove((nx, ny))
    if len(gems) == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7776
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using Pii = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    REP(i, h) REP(j, w) cin >> s[i][j];
    vector<vector<char>> t = s;
    int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
    int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
    REP(i, h) REP(j, w){
        if(s[i][j] == '#') continue;
        int cnt = 0;
        REP(d, 8){
            int ni = i + dy[d], nj = j + dx[d];
            if(ni < 0 || h <= ni) continue;
            if(nj < 0 || w <= nj) continue;
            if(s[ni][nj] == '#') ++cnt;
        }
        t[i][j] = char(cnt + '0');
    }
    REP(i, h){
        REP(j, w) cout << t[i][j];
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 1010;

int cnt[N];

void solve() {
	double a, b, n;
	cin >> a >> b >> n;
	double x = min(n, b - 1);
	cout << floor(a * x / b) - a * floor(x / b) << endl;
}

int main() {
	//FRE;
	int t;
	solve();
	return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

void test_case() {

}

const int mxN = 1e5 + 1;


int main() {
	fastio;
	int n, m;
	ll k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1), b(m + 1);
	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		a[i + 1] = a[i] + x;
	}
	for (int i = 0; i < m; ++i) {
		ll x;
		cin >> x;
		b[i + 1] = b[i] + x;
	}
	ll ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (a[i] <= k) {
			// a[i] + sb <= k
			// sb <= k - a[i]
			auto it = upper_bound(b.begin(), b.end(), k - a[i]);
			--it;
			int pos = it - b.begin();
			ans = max(ans, ll(i + pos));
		}
		else
			break;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6372
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

map<ll,ll> pfmp; //各素因数の冪指数の総和を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void pf(ll N){
  ll n=N;
  if(n<=0) return;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    while(n%2==0){
      n/=2;
      pfmp[2]++;
    }
  }
  if(n==1) return;
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      while(n%i==0){
        n/=i;
        pfmp[i]++;
      }
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
    else{
      pfmp[n]++;
    }
  }
  //sort(all(pfv));
}

int kosuu[100];

int main(){
  int n; cin >> n;
  rep(i,n){
    pf(i+1);
  }
  ll ans=0;
  for(auto c:pfmp){
    if(c.second>=74) kosuu[74]++;
    if(c.second>=24) kosuu[24]++;
    if(c.second>=14) kosuu[14]++;
    if(c.second>=4) kosuu[4]++;
    if(c.second>=2) kosuu[2]++;
  }
  ans+=kosuu[74];
  ans+=(kosuu[2]-1)*kosuu[24];
  ans+=(kosuu[4]-1)*kosuu[14];
  ans+=(kosuu[4])*(kosuu[4]-1)/2*(kosuu[2]-2);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    const int n = t;
    int arry[n];
    for(int i = 0; i < n; i++){
        cin >> arry[i];
    }
    for(int i = n-1; i >= 0; i--){
        if(i == n-1){
            cout << arry[i];
        }
        else{
            cout << " " << arry[i];
        }


    }
    cout << endl;
}

Measured memory_bytes: 3064
n,m=gets.split.map(&:to_i)
array=gets.split.map(&:to_i).sort
bcarray=[]
m.times{
    b,c=gets.split.map(&:to_i)
    bcarray.push([b,c])
}
ans=array.inject(:+)

bcarray=bcarray.sort_by{|value| value[1]}.reverse
index=0
isbreak=false

bcarray.map{|i|
    
    if isbreak
        break
    end
    
    b=i[0]
    c=i[1]
    
    b.times{
        
        if index==n
            isbreak=true
            break
        end
        
        
       if c>array[index]
           ans+=c-array[index]
           index+=1
        else
            isbreak=true
            break
        end
    }
}

puts ans

Measured memory_bytes: 21408