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

int main()
{
	long long n;
	cin>>n;
	long long a[n];
	long long freq[n+1]={0},ans[n+1]={0};
	unordered_map<long long,long long> x;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		x[a[i]]++;
		freq[a[i]]++;
	}
	long long total=0;
	for(int i=1; i<=n; i++)
	{
		long long z=freq[i];
		ans[i]=(z*(z-1))/2;
		total+=ans[i];
	}
	for(int i=0; i<n; i++)
		cout<<total-freq[a[i]]+1<<endl;
	return 0;
}


Measured memory_bytes: 12232
import sys,collections,random,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
t = I()
if t != 0:
    print(-1)
    exit()
sums = 0
for i in range(n-1):
    c = I()
    if c-t > 1 or c > i+1:
        print(-1)
        exit()
    if c-t != 1:
        sums += t
        s = 0
    if i == n-2:
        sums += c
    t = c
print(sums)

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

// int main(){
//     srand(time(0));
//     int n;
//     cin >> n;
//     vector<P> ps(n);
//     for(int i = 0; i < n; ++i){
//         ld x,y;
//         cin >> x >> y;
//         ps[i] = P(x,y);
//     }

//     printf("%.2lf\n", (double)smallest_enclosing_disc(ps).rad*2);
// }


int n,m;
ld r[111], mb[111];
 
bool used[111];

bool chk(int s){
    vector<int> b;
    rep(i,n)if(!used[i]) b.emplace_back(r[i]);
    vector<ld> a;
    for(int i = s; i < m; ++i) a.emplace_back(mb[i]);
    sort(all(a));
    sort(all(b));
    int last = -1;
    rep(i,a.size()){
        bool found = false;
        for(int j = last+1; j < (int)b.size(); ++j){
            if(a[i] < b[j] + eps){
                found = true;
                last = j;
                break;
            }
        }
        if(!found)return false;
    }
    return true;
}

int main(){
    cin >> n;
    double ans = 0.0;
    G g(n);
    rep(i,n){
        ld x,y;
        cin >> x >> y;
        g[i] = P(x,y);
    }
    ans = smallest_enclosing_disc(g).rad;
    printf("%.12lf\n", ans);
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main()
{
	long long x; cin >> x; 
	for (long long a = 0; a < 1000; a++) {
		long long diff = x - pow(a, 5);
		if (diff > 0) { // b should be negative
			for (long long b = 0; pow(a, 5) + pow(b, 5) <= x; b++) {
				if (pow(a, 5) + pow(b, 5) == x) {
					cout << a << " " << -b << endl;
					return 0;
				}
			}
		}
		else {
			for (long long b = 0; pow(a, 5) - pow(b, 5) >= x; b++) {
				if (pow(a, 5) - pow(b, 5) == x) {
					cout << a << " " << b << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];

    
    
  }
  int count=0;
  for(int i=1;i<=n;i++)
  {
    if(i%2!=0 && arr[i]%2!=0)
      count++;

    
    
  }
  cout<<count<<endl;

  
  
}

Measured memory_bytes: 3588
N = int(input())
lst = list(map(int, input().split()))
for idx, n in enumerate(lst[:-1]):
    if lst[idx] > lst[idx + 1]:
        if lst[idx] > (lst[idx + 1] + 1) :
            print('No')
            exit(0)
        else:
            lst[idx + 1] += 1
print('Yes')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long sum=n*(n+1)/2;
	rep(i,1,n+1){
		if(i%3==0 && i%5==0)
			sum-=i;
		else if(i%3==0)
			sum-=i;		
		else if(i%5==0)
			sum-=i;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdio.h>
#define HMAX 500001
int H;
void maxHeapify(int A[H],int i){
  int l=2*i;
  int r=2*i+1;
  int largest,tmp;
  //printf("%d\n",i);
  if(l<=H && A[l]>A[i]){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=H && A[r]>A[largest]){
    largest=r;
  }

  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;

    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int A[H]){
  int i;
  for(i=H/2; i>=1; i--){
    maxHeapify(A,i);
  }
}
  
int main(){
  int i,j;
  int A[HMAX];
  scanf("%d",&H);
  for(i=1; i<=H; i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A);

  for(i=1; i<=H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int N,sn=0;;
    scanf("%d",&N);
    int N0 = N;
    do{
        sn += N0%10;
        N0 /= 10;
    }while( N0 != 0 );

    if( N % sn == 0 ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll x,y;
    cin >> x >> y;
    int ans = 1;
    while(x*2 <= y) {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
//#include <boost/multiprecision/cpp_int.hpp>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll  long long
#define fp cout<<fixed<<setprecision(9);
#define ifor(j,n) for(int i=j ;i<n;i++)
#define jfor(k,n) for(ll j=k ;j<n;j++)
#define pb push_back
#define mod 1000000007
using namespace std;
//using namespace boost::multiprecision;

//Compiler version g++ 6.3.0
struct node
{
 float p;
};
int search (vector <long long> v,long long m,int n) 
{ 

    int start = 0;
    int ans = -1; 
    while (start <=n) 
    { 
     int mid = (start + n) / 2;
     if (v[mid] <= m) 
         start = mid + 1;
     else
   { 
   ans = mid; 
   n = mid - 1; 

       } 

    } 
    return ans; 
} 

int main()
{
 FAST 
   int t;
   cin>>t;
    if(t<=599)
    {
      cout<<8;
    }
    else if(t<=799)
       cout<<7;
    else if(t<=999)
       cout<<6;
       else if(t<=1199)
         cout<<5;
         else if(t<=1399)
           cout<<4;
             else if(t<=1599)
               cout<<3;
               else if(t<=1799)
                 cout<<2;
                 else if(t<=1999)
                   cout<<1;
     }
     

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e2+7;
const int K = 1e5+7;
int n,k;
ll dp[N][K];
ll a[N];
ll bit[N][K];

void add(int i,int k1,ll x)
{
    k1++;
    while(k1 <= k+1)
    {
        bit[i][k1] = (bit[i][k1]+x)%MOD;
        k1 += k1&-k1;
    }
}

ll sum(int i,int k)
{
    k++;
    if (k == 0) return 0;
    ll ret = 0;
    while(k >= 1)
    {
        ret = (ret+bit[i][k])%MOD;
        k -= k&-k;
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    cin >> n >> k;
    REP(i,1,n) cin >> a[i];
    dp[0][0] = 1;
    add(0,0,1);
    REP(i,1,n)
    {
        REP(j,0,k)
        {
            int l = max(0LL,j-a[i]);
            int r = j;
            dp[i][j] = (dp[i][j]+(sum(i-1,r)-sum(i-1,l-1)+MOD)%MOD)%MOD;
            add(i,j,dp[i][j]);
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}


Measured memory_bytes: 161408
#include<stdio.h>
int main()
{
    int n,k,x,y,sum=0,i=0;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    if(n<=k)
    {
        sum=n*x;

    }
    else if(n>k)
    {
        sum=k*x;
        n=n-k;
        sum=sum+(n*y);

    }
    printf("%d\n",sum);
    return 0;


}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    vec<bool> flag(n * 2010, false);
    ll all = 1LL << n;
    REP(bit, all) {
        ll sum = 0;
        REP(i, n) {
            if((bit >> i) & 1) {
                sum += a[i];
            }
        }
        flag[sum] = true;
    }

    ll q;
    cin >> q;
    while(q--) {
        ll m;
        cin >> m;
        if(flag[m])
            cout << "yes" << en;
        else
            cout << "no" << en;
    }
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 3172
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    s = list(input())
    t = list(input())
    n = len(s)
    m = len(t)
    ans = ''
    for i in range(n - m,-1,-1):
        flag = True
        for j in range(m):
            if s[i + j] != t[j] and s[i + j] != '?':
                flag = False
                break
        if flag:
            ans = s[:i] + t + s[i + m:]
            break
    if ans:
        for i in range(n):
            if ans[i] == '?':
                ans[i] = 'a'
        print(''.join(ans))
    else:
        print('UNRESTORABLE')
if __name__ == '__main__':
    main()

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF (1e9+7)

using namespace std;

struct conv{
  int time;
  string content;
  vector<int> child;
  conv(int t, string c) : time(t), content(c) {}
};

vector<conv> posts;

void dfs(int parent, int depth){
  REP(i, depth) cout << ".";
  cout << posts[parent].content << endl;
  REP(i, posts[parent].child.size()) dfs(posts[parent].child[i], depth+1);
  return;
}

int main(){
  int n; cin >> n;
  REP(i, n){
    int to; cin >> to;
    string cont; cin >> cont;
    posts.emplace_back(conv(i, cont));
    if(to != 0) posts[to-1].child.push_back(i);
  }
  dfs(0, 0);
  return 0;
}

Measured memory_bytes: 3364
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var w = new long[nk[0]];
        for (var i = 0; i < nk[0]; i++)
            w[i] = ToInt32(ReadLine());
        var right = w.Sum();
        var left = 0L;
        while (right > left)
        {
            var p = (right + left) / 2;
            var cou = 0;
            for(var i = 0; i < nk[1]; i++)
            {//連続する荷物より貪欲にいけばよい
                var we = 0L;
                while (we + w[cou] <= p)
                {
                    we += w[cou];
                    cou++;
                    if (cou == nk[0]) break;
                }
                if (cou == nk[0]) break;
            }
            if (cou == nk[0]) right = p;
            else left = p + 1;
        }
        WriteLine(right);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}



Measured memory_bytes: 22652
// glory be to the sky
#include<bits/stdc++.h> 


using namespace std;
	
typedef long long ll;  

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int R, C;
	string st, ss;
	cin >> st;
	int curr = 0;
	for (int i = 0; i < st.length(); i++) {
		if (st[curr] == 'd') {
			// get dreamer
			if (curr + 7 <= st.length()) {
				ss = st.substr(curr, 7);
				if (ss == "dreamer") {
					if (curr + 7 < st.length()) {
						if (st[curr + 7] != 'a') curr += 7;
						else curr += 5;
					}
					else curr += 7;
				}
				else {
					ss = st.substr(curr, 5);
					if (ss == "dream") curr += 5;
					else break;
				}
			}
			else if (curr + 5 <= st.length()) {
				ss = st.substr(curr, 5);
				if (ss == "dream") curr += 5;
				else break;
			}
		}	
		else if (st[curr] == 'e') {
			if (curr + 6 <= st.length()) {
				ss = st.substr(curr, 6);
				if (ss == "eraser") curr += 6;
				else {
					ss = st.substr(curr, 5);
					if (ss == "erase") curr += 5;
					else break;
				}
			}
			else if (curr + 5 <= st.length()) {
				ss = st.substr(curr, 5);
				if (ss == "erase") curr += 5;
				else break;
			}
		}
		else break;
	}
	if (curr != st.length()) cout << "NO";
	else cout << "YES";
	return 0;	
}


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

int main(){
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if (op == '?') break;
        
        if(op == '+') cout<< a + b << endl;
        else if ( op == '-' ) cout << a - b << endl;
        else if ( op == '*' ) cout << a * b << endl;
        else if ( op == '/' ) cout << a / b << endl;
    }
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> h(N), dp(N, 1000000000);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for (int i = 1; i < N; i++)
    {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
        {
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[N - 1] << endl;

    return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

  long long ans = (n - m) * 100 + m * 1900;
  for (int i = 0; i < m; ++i) {
    ans *= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
s="#"
for c in range(input()):
  n = input()
  A = [list(' '*n) for _ in [0]*n]
  for i in range((n+3)/4):
    i2 = i*2
    if i2>0: A[n-i2][i2]=s
    for j in range(i2, n-i2):
      A[j][i2]=s
      A[i2][j]=s
      if j<n-i2-1: A[j][n-i2-1]=s
      if j>i2+1: A[n-i2-1][j]=s
  if c: print
  for e in A: print "".join(e)

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a+b == c+d)cout << "Balanced" << endl;
  else if(a+b > c+d)cout << "Left" << endl;
  else cout << "Right" << endl;
  system("pause");
}

Measured memory_bytes: 504
#include <iostream>

using namespace std;


int main(){
    int d;
    cin >> d;
    if (d==22)
        cout << "Christmas Eve Eve Eve";
    else if (d==23)
        cout << "Christmas Eve Eve";
    else if (d==24)
        cout << "Christmas Eve";
    else
        cout << "Christmas";
    cout << endl;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, r;
  cin >> n >> r;
  if(n > 10) {
    cout << r;
  } else {
    cout << r + (100 * (10 - n));
  }
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size()/2;
    int m=n/2;
    int count=0;
    for(int i=0;i<m;i++){
        if(s.at(i)!=s.at(n-i-1)) count++;
        else if(s.at(n+1+i)!=s.at(s.size()-i-1)) count++;
    }
    for(int i=0;i<m;i++){
        if(s.at(i)!=s.at(s.size()-i-1)) count++;
    }
    if(n%2!=0){
        if(s.at(m)!=s.at(n+m+1)) count++;
    }
    if(count>0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
}

Measured memory_bytes: 3628
N, M = gets.split.map(&:to_i)

ans = 1
1.upto(Math.sqrt(M).to_i) do |i|
  if M % i == 0
    j = M / i # M = i * j となるもう一つの約数 j が存在する
    ans = i if i * N <= M && ans < i
    ans = j if j * N <= M && ans < j
  end
end

puts ans


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 4010;

int n, p[N], A, B, type[N], res[N];

inline char read_char() {
	char ch(getchar());
	for (; !isupper(ch); ch = getchar());
	return ch;
}

inline int Ask(int x, int y) {
	static int tot = 0; assert(++ tot <= 2 * n);
	cout << "? " << x - 1 << ' ' << y - 1 << endl; return read_char() == 'Y';
}

int main () {

	//File();

	A = read(), B = read();

	if (B >= A) return puts("Impossible"), 0;

	For (i, 1, n = A + B) p[i] = i, type[i] = -1;

	srand(time(0));
	random_shuffle(p + 1, p + n + 1);

	int cur = 0;
	for (;;) {
		int pos = 0; For (i, 1, n) if (!~type[p[i]]) pos = p[i];

		int tot[2] = {0, 0}; Set(res, -1);
		For (i, 1, n) if (type[p[i]] != 0) {
			++ tot[res[p[i]] = Ask(p[i], pos)];
			if (max(tot[0], tot[1]) > B) break;
		}
		type[pos] = tot[1] > tot[0];

		For (i, 1, n) if (~res[p[i]] && res[p[i]] != type[pos]) type[p[i]] = 0, -- B;
		if (type[pos]) { cur = pos; -- A; break; } else -- B;
	}

	if (A && B) {
		For (i, 1, n) if (!~type[p[i]]) {
			type[p[i]] = Ask(cur, p[i]);
			if (type[p[i]] == 1) -- A; else -- B; if (!A || !B) break;
		}
	}
	For (i, 1, n) if (!~type[i]) type[i] = A ? 1 : 0;

	cout << "! "; For (i, 1, n) putchar(type[i] + '0'); cout << endl;

	return 0;

}

Measured memory_bytes: 848
'use strict'

// 与えられた数字が100で何回割り切れるか
const calc = (num) => {
    let ret = 0
    while(num % 100 === 0){
        num /= 100
        ret++
    }
    return ret
}

const main = (input) => {
    input = input.split('\n')[0].split(' ').map(i => parseInt(i))
    const D = input[0]
    const N = input[1]
    let cnt = 0
    let val = 0
    while(cnt < N){
        val++
        if(calc(val) === D) cnt++
    }
    console.log(val)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split();
            var n = Int32.Parse(str[0]);
            var k = Int32.Parse(str[1]);

            var e = new List<List<int>>();
            for (int i = 0; i < n; i++) e.Add(new List<int>());

            for (int i = 0; i < n - 1; i++)
            {
                str = Console.ReadLine().Split();
                var a = Int32.Parse(str[0]) - 1;
                var b = Int32.Parse(str[1]) - 1;
                e[a].Add(b);
                e[b].Add(a);
            }

            Console.WriteLine(Solver.Solve(n, k, e));
        }
    }

    public class Solver
    {
        static int maxDist;
        static List<List<int>> edges;

        public static int Solve(int n, int k, List<List<int>> e)
        {
            maxDist = k / 2;
            edges = e;

            var ret = Int32.MaxValue;
            for (int i = 0; i < n; i++ )
            {
                if (k % 2 == 0)
                    ret = Math.Min(ret, Dfs(i, -1, 0));
                else
                    foreach(var j in e[i]) 
                        ret = Math.Min(ret, Dfs(i, j, 0) + Dfs(j, i, 0));
            }
            return ret;
        }

        static int Dfs(int cur, int prev, int dist)
        {
            var ret = dist > maxDist ? 1 : 0;
            foreach (var next in edges[cur])
            {
                if (next == prev) continue;
                ret += Dfs(next, cur, dist + 1);
            }
            return ret;
        }
    }
}


Measured memory_bytes: 3800
#include <cstdio>

using namespace std;
using ll = long long;

constexpr int MAX_N = 100100;
constexpr int MOD = 1000000007;

int n;
int arr[MAX_N];

ll fact[MAX_N];
ll sum_inv[MAX_N];

int mod_pow(int b, int e) {
    if (e == 0) return 1;
    ll x = mod_pow(b, e >> 1);
    x = (x * x) % MOD;
    if (e & 1) x = (x * b) % MOD;
    return (int) x;
}

int mod_inv(int x) {
    return mod_pow(x, MOD - 2);
}

int main() {
    scanf(" %d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf(" %d", &arr[i]);
    }

    fact[0] = 1LL;
    for (int i = 1; i <= n; ++i) {
        fact[i] = (fact[i - 1] * i) % MOD;
    }

    sum_inv[0] = 0LL;
    for (int i = 1; i <= n; ++i) {
        sum_inv[i] = (sum_inv[i - 1] + mod_inv(i)) % MOD;
    }

    ll ans = 0LL;
    for (int i = 1; i <= n; ++i) {
        ll prob = 1LL;
        prob = (prob + sum_inv[i] - sum_inv[1] + MOD) % MOD;
        prob = (prob + sum_inv[n - i + 1] - sum_inv[1] + MOD) % MOD;
        ans = (ans + prob * arr[i]) % MOD;
    }

    ans = (ans * fact[n]) % MOD;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2176
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t func(const int64_t n, const int64_t x) {
  if (n < 0) {
    return 0;
  }
  const int64_t result = max(n / x + static_cast<int64_t>(1), static_cast<int64_t>(0));
  return result;
}

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

  int64_t a, b, x;
  cin >> a >> b >> x;
  const int64_t result = func(b, x) - func(a - 1, x);
  cerr << func(a - 1, x) << ", " << func(b, x) << endl;
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  int ans =0;
  for(int i = 0 ; i < N; i++){
      int l,r;
      cin >> l >> r;
      ans += (r - l + 1);
    }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner o = new Scanner(System.in);
        int a = o.nextInt();
        int b = o.nextInt();
        int c = o.nextInt();
        int k = o.nextInt();

        int ans = 0;
        ans += Math.min(k,a);
        k -= ans;
        a -= ans;
        int x = Math.min(k,b);
        k -= x;
        b -= x;
        int y = Math.min(k,c);
        ans -= y;

        System.out.println(ans);
    }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    string s,w;cin>>s;int cnt=0;
    while(1){
        cin>>w;
        if(w=="END_OF_TEXT") break;
        for(int i=0;i<w.size();i++) if(w[i]>=65&&w[i]<=90) w[i]-=('A'-'a');
        if(w==s) cnt++;
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  for (int i = 0; i < B; i++) {
    if (A*(i+1) % B == C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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



int main(void){
    int N;
    cin >> N;
    for(int i=1; i<=50000; i++) {
        if(floor(i*1.08) == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

#define N 20000

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int n, s;
    int r[ N ];
    int c = 0;

    scanf ( "%d%d", &n, &s );
    if ( n == 0 && s == 0 ) break ;
    for ( i = 0; i < n; ++i )
      scanf ( "%d", &r[ i ] );

    for ( i = 0; i < n; ++i )
    for ( j = i + 1; j < n; ++j )
      c += !!( r[ i ] + r[ j ] > s );

    printf ( "%d\n", c );
  }

  return ( EXIT_SUCCESS );
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	int n;
	cin >> n;
	vi a(n), b(n);
	forn
	{
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(all(b));
	// print(a);
	// print(b);
	int x, y;
	// find median
	// a[i] always < b[i]
	if (n % 2)
	{
		x = a[n / 2];
		y = b[n / 2];
	}
	else
	{
		// no need to /2 because range stays the same
		x = a[n / 2] + a[n / 2 - 1];
		y = b[n / 2] + b[n / 2 - 1];
	}
	// range = (max - min + 1)
	// cout << x << " " << y << en;
	cout << y - x + 1 << en;
	return 0;
}

Measured memory_bytes: 4796
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
    import sys

    input = sys.stdin.readline

    n, m = [int(x) for x in input().rstrip().split(" ")]

    uf = UnionFind(n)

    for i in range(m):
        a, b = [int(x) for x in input().rstrip().split(" ")]
        uf.union(a-1, b-1)

    print(len(uf.roots()) - 1)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 73156
s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol+sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_,mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        elif sdict[target][0]>mark:
            mark = sdict[target][0]
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)


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

int main(){
	int N, M, i;
	cin >> N >> M;
	int A[N];
	for(i=0; i<M; i++){
		cin >> A[i];
	}
	
	int sum=0;
	for(i=0; i<M; i++){
		sum += A[i];
	}
	
	int ans = N-sum;
	if(ans < 0)	ans = -1;
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;


void solve()
{
	string s;
	cin >> s;
	int size = s.size();
	int K;
	cin >> K;
	set<string> Set;
	for (int i = 0; i <= K; ++i)
	{
		for (int j = 0; j < size; ++j)
		{
			string t = "";
			for (int k = 0; k < i; ++k)
			{
				if (j + k < size)
				{
					t += s[j + k];
				}
			}
			Set.insert(t);
		}
	}
	int cnt = 0;
	for (set<string>::iterator it = Set.begin(); it != Set.end(); ++it)
	{
		if (cnt == K)
		{
			cout << *it << endl;
			break;
		}
		++cnt;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

ll ai,ao,aj,al;
ll ans;

int main()
{
	scanf("%lld%lld%*lld%lld%lld%*lld%*lld",&ai,&ao,&aj,&al);

	bool f=0;
	if(ai>0 && aj>0 && al>0)f=1;
	ans+=ao+aj+al+ai;
	ai%=2;
	aj%=2;
	al%=2;
	if(f && 3-(ai+aj+al)<ai+aj+al)
		ans-=3-ai-aj-al;
	else
		ans-=ai+aj+al;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int N, R;
	cin >> N >> R;
	if (N < 10) {
		cout << R+100 * (10 - N) << endl;
	}
	else {
		cout << R << endl;
	}
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
h = LIST()
cnt = 0

for i in range(N):
  if h[i] >= K:
    cnt += 1
    
print(cnt)

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

typedef long long ll;
const int MOD = 1000000007;

vector<vector<pair<ll, ll>>> G;
vector<ll> dist;
int N,K;

void bfs(int a){
  dist[a] = 0;
  queue<int> que;
  que.push(a);
  ll res = 0;
  while(!que.empty()){
    int n = que.front();
    que.pop();
    res = dist[n];
    for(auto x: G[n]){
      if(dist[x.first] == -1){
	// cout << "n,x=" << n << " " << x.first << " " << x.second << endl;
	dist[x.first] = res + x.second;
	que.push(x.first);
      }
    }
  }
}

int main(){
  cin >> N;
  G.resize(N);
  dist.resize(N, -1);
  for(int i = 0; i < N-1; i++){
    ll a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  int Q;
  cin >> Q >> K;
  bfs(K-1);			
  vector<ll> ans(Q);
  for(int i = 0; i < Q; i++){
    int x,y;
    cin >> x >> y;
    x--; y--;
    ans[i] = dist[x] + dist[y];
  }
  // for(auto x: dist){
  //   cout << x << " ";
  // }
  // cout << endl;
  for(int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int x[200000], y[200000];

signed main() {
	int i;
	int mmin = 1e+10;
	int mmax = 0;
	
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> y[i];
		mmin = min(mmin, x[i] + y[i]);
		mmax = max(mmax, x[i] + y[i]);
	}
	int ans1 = mmax - mmin;
	
	mmin = 1e+10;
	mmax = -1e+10;
	rep(i, n) {
		mmin = min(mmin, x[i] - y[i]);
		mmax = max(mmax, x[i] - y[i]);
	}
	int ans2 = mmax - mmin;
	
	cout << max(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 6776
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<min(C,B/A)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<LL> A(N); cin >> A;

  LL cache = 1000;
  LL stock = 0;
  for (int i = 0; i + 1 < N;++i) {
    if (A[i] < A[i+1]) {
      int x = cache / A[i];
      cache -= x * A[i];
      stock += x;
    } else {  // A[i] > A[i + 1]
      cache += stock * A[i];
      stock = cache / A[i + 1];
      cache -= stock * A[i + 1];
    }
  }
  cache += stock * A[N-1];
  cout << cache << endl;
}


Measured memory_bytes: 3508
import sys
readline = sys.stdin.buffer.readline

def main():
    A, B, C = map(int, readline().rstrip().split())

    m = max(A, B, C)
    if m == A:
        ma = max(B, C)
        ans = m - ma
        B += ans
        C += ans
    elif m == B:
        ma = max(C, A)
        ans = m - ma
        C += ans
        A += ans
    else:
        ma = max(A, B)
        ans = m - ma
        A += ans
        B += ans
    
    b = (max(A, B, C) - min(A, B, C)) % 2
    ans += (max(A, B, C) - min(A, B, C)) // 2 + b * 2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def shuffle_v2():
    while True:
        cards = input()
        if cards == "-":
            break

        m = int(input())
        shuffle_times = [int(input()) for _ in range(m)]

        for i in range(m):
            cards = cards[shuffle_times[i]:] + cards[:shuffle_times[i]]

        print(cards)


if __name__ == "__main__":
    shuffle_v2()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h,w,n,count=0;
    cin>>h>>w>>n;
    if(h>=w){
        while(n>0){
            count++;
            n-=h;
        }
    }
    else{
        while(n>0){
            count++;
            n-=w;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;

  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }

  vector<int> L(N);
  L.at(0) = P.at(0);
  for (int i = 1; i < N; i++) {
    L.at(i) = min(L.at(i - 1), P.at(i));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (P.at(i) <= L.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e9+7;

int main(){

    int n;
    cin>>n;
    int f = n%10;

    if (f == 3){
        cout << "bon" << endl;

    }else if (f<= 1 || f==6||f==8){
        cout << "pon"<<endl;

    }else{
        cout << "hon" << endl;
    }


}




Measured memory_bytes: 3620
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c = collections.OrderedDict(sorted(c.items(), key=lambda x:x[0],reverse=True))
high=0
low=0
for i,j in zip(c.keys(),c.values()):
    if(j>=4):
        if(high==0):
            high=i
        if(low==0):
            low =i
        break
    elif(j>=2):
        if(high==0):
            high=i
        else:
            low=i
            break
print(high*low)

Measured memory_bytes: 38740
#include <stdio.h>
int main(void){
	int t,h,m,s;
	scanf("%d",&t);
	h = t/3600;
	m = (t-h*3600)/60;
	s = t-(h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = abs(x - k*d)
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = abs(x + k*d)
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)

Measured memory_bytes: 61728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n,x,t;
  cin >> n >> x >> t;
  int ans = 0;
  while (n > 0) {
    n -= x;
    ans +=t;
  }
  cout << ans << endl;
}


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

int main() {
  string s;
  char c;
  stack<int> st_n;
  int n, m;
  int i;
  while (cin >> s) {
    if (s.size() == 1) {
      c = s.at(0);
      if ('0' <= c && c <= '9') {
        st_n.push(c - '0');
      } else {
        m = st_n.top();
        st_n.pop();
        n = st_n.top();
        st_n.pop();
        if (c == '+') {
          st_n.push(n + m);
        } else if (c == '-') {
          st_n.push(n - m);
        } else if (c == '*') {
          st_n.push(n * m);
        }
      }
    } else {
      n = 0;
      for (i = 0; i < s.size(); i++) {
        n *= 10;
        n += s.at(i) - '0';
      }
      st_n.push(n);
    }
  }
  cout << st_n.top() << endl;
  return 0;
}



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

int main() {
	string S;
	cin >>S;
	int Q;
	cin >>Q;
	int a,b,p;
	p=0;
	char c;
	string t,u;

	for(int i=1;i<=Q;i++){
		cin >>a;
		if(a==1){
			p++;
		}
		else{
			cin >>b>>c;
			if(p%2==0){
				if(b==1){
					t=t+c;
				}
				else{
					u=u+c;
				}
			}
			else{
				if(b==1){
					u=u+c;
				}
				else{
					t=t+c;
				}
			}

		}
	}
	if(p%2==0){
		for(int i=0; i<t.length()/2;i++){
			char temp=t.at(i);
			t.at(i)=t.at(t.length()-i-1);
			t.at(t.length()-i-1)=temp;
		}
		cout <<t+S+u;
	}
	else{
		for(int i=0; i<S.length()/2;i++){
			char temp=S.at(i);
			S.at(i)=S.at(S.length()-i-1);
			S.at(S.length()-i-1)=temp;
		}
		for(int i=0; i<u.length()/2;i++){
			char temp=u.at(i);
			u.at(i)=u.at(u.length()-i-1);
			u.at(u.length()-i-1)=temp;
		}
		cout << u+S+t;
	}


}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;



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

	int N, M;
	cin >> N >> M;
	vector<vector<int>> memo(N, vector<int>(N, INT_MAX)), matrix(N, vector<int>(N, INT_MAX));
	FOR(i, 0, M) {
	    int a, b, c;
	    cin >> a >> b >> c;
	    a--; b--;
	    matrix[a][b] = c;
	    matrix[b][a] = c;
	    memo[a][b] = c;
	    memo[b][a] = c;
	}

    const unsigned long num_node = matrix.size();
    for (int i = 0; i < num_node; ++i) {
        matrix.at(i).at(i) = 0;
    }

    for (int m = 0; m < num_node; ++m) {
        for (int s = 0; s < num_node; ++s) {
            for (int e = 0; e < num_node; ++e) {
                if (matrix.at(s).at(m) != INT_MAX and matrix.at(m).at(e) != INT_MAX) {
                    matrix.at(s).at(e) = std::min(matrix.at(s).at(e), matrix.at(s).at(m) + matrix.at(m).at(e));
                }
            }
        }
    }

    int ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            if (memo[i][j] != INT_MAX) {
                ans += matrix[i][j] < memo[i][j];
            }
        }
    }

    print(ans / 2);

	return 0;
}

Measured memory_bytes: 384