akhauriyash/Code-Regression huggingface dataset:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    s=STR()
    if s[2]==s[3] and s[4]==s[5]:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

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

int n, a;
double memo[310][310][310];

double dp(int x, int y, int z) {
	double ret;
	int tot = x + y + z;
	if (tot == 0)
		return 0.0;
	if (memo[x][y][z] > -0.5)
		return memo[x][y][z];
	ret = (double) n / (double) tot;
	if (x > 0)
		ret += (dp(x - 1, y, z) * (double) x / (double) tot);
	if (y > 0)
		ret += (dp(x + 1, y - 1, z) * (double) y / (double) tot);
	if (z > 0)
		ret += (dp(x, y + 1, z - 1) * (double) z / (double) tot);
	memo[x][y][z] = ret;
	return ret;
}

int main() {
	int t[5];
	double ans;
	scanf("%d", &n);
	memset(t, 0, sizeof t);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		t[a]++;
	}
	for (int i = 0; i < 301; i++)
		for (int j = 0; j < 301; j++)
			for (int k = 0; k < 301; k++)
				memo[i][j][k] = -1.0;
	ans = dp(t[1], t[2], t[3]);
	printf("%.14lf\n", ans);
	return 0;
}

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

bool isPrime(llong N) {
    llong i;
    if (N<2) return false;
    else if (N==2) return true;
    if (N%2==0) return false;
    for(i=3; i*i<=N; i+=2) {
        if(N%i==0) return false;
    }
    return true;
}

int main(void) {
  int X;
  cin >> X;

  while(!isPrime(X)) {
    X++;
  }

  cout << X << endl;

  return (0);
}


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

using namespace std;

int main() {
	int n;
	int count=0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());                           

	s.erase(unique(s.begin(), s.end()), s.end());  
	cout << s.size();
	return 0;
}

Measured memory_bytes: 9544
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

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

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, m;
    cin >> n >> m;
    vpll a(n + m);
    forn(i, n){
        cin >> a[i].F;
    }
    forn(i, m){
        cin >> a[i + n].F;
        a[i + n].S = 1;
    }
    Sort(a);
    ll ans = 0;
    int N = n + m;
    n++, m++;
    forn(i, N){
        ll k;
        if (a[i].S == 0) k = m; else k = n;
        ans += a[i].F * k;
        if (a[i].S == 0) n--; else m--;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 6372
import java.io.*;
import java.util.*;

/**
 * @author:26019
 */
public class Main {

    public static void main(String[] args) throws Exception {
        solve();
    }

    private static long gcd(long x, long y) {
        if (y == 0) return x;
        return gcd(y, x % y);
    }

    private static int cal(int x) {
        int res = 1;
        while (x != 1) {
            if ((x & 1) == 1) {
                x = x * 3 + 1;
            } else {
                x >>= 1;
            }
            res++;
        }
        return res;
    }

    private static void solve() throws Exception {
        FastScanner cin = new FastScanner();
        long t = 1;
        while (t-- > 0) {
            int n = cin.nextInt();
            int[] arr = cin.readArray(n);
            Arrays.sort(arr);
            int res = 0;
            for (int i = 0; i < n; i++) {
                int k = i + 2;
                for (int j = i + 1; j < n; j++) {
                    while (k < n && arr[k] < arr[i] + arr[j]) {
                        k++;
                    }
                    res += k - j - 1;
                }
            }
            System.out.println(res);
        }
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        FastScanner() throws IOException {
        }

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        private void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 33512
#include<iostream>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;

int main() {
    string s;
    cin >> s;
    replace(s.begin(), s.end(), '?', 'D');
    cout << s;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int dp[1<<26];

int main(){
	string s;
	cin>>s;
	int n = s.size();
	fill(dp, dp+(1<<26), INF);
	dp[0] = 0;
	int a = 0;
	rep(i, n){
		int c = s[i]-'a';
		a ^= 1<<c;
		//dp[a]++;
		rep(j, 26){
			int a2 = a^(1<<j);
			chmin(dp[a], dp[a2]+1);
		}
	}
	cout<<max(dp[a], 1)<<endl;
	return 0;
}


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

int main(){
 int S,W; //羊と狼の数の変数宣言
 cin >> S >> W;
    
    if(S > W){
      cout << "safe" << endl;
    }
  else{
    cout << "unsafe" << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N, K;

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

    int dist = x[K-1] - x[0];
    int res = INF;
    for (int i = 0; i < N-K+1; i++) {
        res = min(res, dist+min(abs(x[i]),abs(x[i+K-1])));
        if (i == N - K) break;
        dist = x[i+K] - x[i+1];
    }
    cout << res << endl;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		String c = stdIn.next();
		ArrayList<Integer> C = new ArrayList<Integer>();
		for(int i = 0; i < N; i ++) {
			if(c.substring(i, i + 1).equals("R")) {
				C.add(0);
			}else {
				C.add(1);
			}
		}
		
		int ans = 0;
		int left = 0;
		int right = N - 1;
		while(true) {
			while(C.get(left) == 0) {
				left ++;
				if(N <= left) {
					break;
				}
			}
			while(C.get(right) == 1) {
				right --;
				if(right < 0) {
					break;
				}
			}
			if(right < left) {
				break;
			}else {
				ans ++;
				C.set(left, 0);
				C.set(right, 1);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 52680
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[1000005], finv[1000005], inv[1000005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000005; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
    int N;
    cin >> N;
    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    cout << (mod_pow(10,N)+mod-mod_pow(9,N)+mod-mod_pow(9,N)+mod_pow(8,N))%mod << endl;
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b, c; cin >> a >> b >> c;

  if (a + b >= c) cout << "Yes\n";
  else cout << "No\n";
  
  return (0);
}

Measured memory_bytes: 3636
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
string ans;
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
string bo = "DURL";
int n, m;
int grid[10][10];
int cnt = -1;
void dfs(tuple<int, int, int> now) {
    if (cnt == 0) {
        cout << ans << endl;
        exit(0);
    }
    grid[get<0>(now)][get<1>(now)] = 0;
    cnt--;
    REP(i, 4) {
        if ((i ^ 1) == get<2>(now)) continue;
        for (int j = 1;; ++j) {
            int x = get<0>(now) + dx[i] * j;
            int y = get<1>(now) + dy[i] * j;
            if (x >= 0 && x < n && y >= 0 && y < m) {
                if (grid[x][y] == 1) {
                    ans.push_back(bo[i]);
                    dfs(make_tuple(x, y, i));
                    ans.pop_back();
                    break;
                }
            }
            else break;
        }
    }
    cnt++;
    grid[get<0>(now)][get<1>(now)] = 1;
}

void solve() {
    cin >> n >> m;
    tuple<int, int, int> now;
    REP(i, n) {
        string s;
        cin >> s;
        REP(q, m) {
            if (s[q] == 'o') grid[i][q] = 1;
            REP(j, bo.size()) {
                if (bo[j] == s[q]) {
                    now = make_tuple(i, q, j);
                    grid[i][q] = 1;
                }
            }
            cnt += grid[i][q];
        }
    }
    dfs(now);
}

#undef int
int main() {
    init();
    solve();
}



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

int main() {
    int n;
    cin >> n;

    int c[n], v[n];

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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            ans += (v[i] - c[i]);

        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()

i = len(S)
ok = True

while ok and i > 0:
    if i - 7 >= 0 and S[i - 7:i] == "dreamer":
        i = i - 7
    elif i - 5 >= 0 and S[i - 5:i] == "dream":
        i = i - 5
    elif i - 6 >= 0 and S[i - 6:i] == "eraser":
        i = i - 6
    elif i - 5 >= 0 and S[i - 5:i] == "erase":
        i = i - 5
    else:
        ok = False

print("YES" if i == 0 else "NO")


Measured memory_bytes: 9640
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int x = sc.nextInt();
	    
	    if(x < 1200) {
	    	System.out.println("ABC");
	    }else {
	    	System.out.println("ARC");
	    }
	}
}

Measured memory_bytes: 21844
import re
import functools

N = int(input())
MOD = 10 ** 9 + 7


@functools.lru_cache(maxsize=None)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD


print(dfs(0, 'TTT'))


Measured memory_bytes: 55384
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll n;
	cin >> n;
	vl a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	ll dp[n];
	clr(dp);
	dp[0] = 0, dp[1] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++) dp[i] = min((dp[i-1]+abs(a[i]-a[i-1])), (dp[i-2]+abs(a[i]-a[i-2])));
	cout << dp[n-1] << endl;
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


Measured memory_bytes: 4732
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

def divisor(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return sorted(res, reverse = True)

A, B, K = map(int, input().split())

x = gcd(A, B)
X = divisor(x)

print(X[K - 1])

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

const int MXN = 4e2 + 20;

long long n, a[MXN], ps[MXN], dp[MXN][MXN];

void npt() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		ps[i] = ps[i - 1] + a[i];
	}
	for (int i = 0; i < MXN; i++)
		for (int j = 0; j < MXN; j++)
			dp[i][j] = 1e15 + 20;
}

void prnt() {
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++)
			cerr << dp[i][j] << ' ';
		cerr << endl;
	}
	cerr << "-----------------------\n";
}

void slv() {
    for (int i = 0; i <= n; ++i) {
        for (int l = 0; l <= n - i; ++l) {
            int r = l + i;
            if (r - l < 2) {
                dp[l][r] = 0;
                continue;
            }
            long long tmp = ps[r] - ps[l];
            for (int mid = l; mid <= r; ++mid)
                dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid][r] + tmp);
        }
    }
	cout << dp[0][n] << endl;
}

int main() {
	npt();
	slv();
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    string s_, t;
    char s[60];
    cin >> s_ >> t;
    if (s_.size() >= t.size()) {
        // ushiro kara
        for (int i = s_.size() - t.size(); i >= 0; i--) {
            bool ok = true;
            rep (j, t.size()) {
                if (s_[i + j] != t[j] && s_[i + j] != '?') ok = false;
            }
            if (ok) {
                rep (j, s_.size()) {
                    if (j < i || j >= i + t.size()) cout << (s_[j] == '?' ? 'a' : s_[j]);
                    else cout << t[j - i];
                }
                cout << '\n';
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
struct WeightedUnionFind{
  vector<int> par;
  vector<int> rank;
  vector<int> diff;
  void init(int n){
    par.resize(n);
    for(int i=0;i<n;i++)par[i]=i;
    rank.resize(n,0);
    diff.resize(n);
  }
  int find(int x){
    if(par[x]==x)return x;
    else{
      int r = find(par[x]);
      diff[x] += diff[par[x]];
      return par[x] = r;
    }
  }
  int weight(int x){
    find(x);
    return diff[x];
  }
  int dist(int x,int y){ // x -> y
    assert(same(x,y));
    return weight(y)-weight(x);
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,int w){ // set diff(x,y) = w
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
      swap(x,y);
      w = -w;
    }
    if(rank[x]==rank[y])rank[x]++;
    par[y] = x;
    diff[y] = w;
    return;
  }
};
WeightedUnionFind uf;
int N,M;
int main(){
  cin >> N >> M;
  uf.init(N);
  for(int i=0;i<M;i++){
    int l,r,d;
    cin >> l >> r >> d;
    l--;r--;
    if(uf.same(l,r)){
      if(uf.dist(l,r)!=d){
        cout << "No" << endl;
        return 0;
      }
    }else{
      uf.unite(l,r,d);
    }
  }
  cout << "Yes" << endl;
	return 0;
}


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

int main()
{
    int N, cnt = 0, ans = 0;
    string X;
    queue<int> T;
    queue<string> S;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int t;
        string s;

        cin >> s >> t;
        T.push(t);
        S.push(s);
    }

    cin >> X;

    for (int i = 0; i < N; i++)
    {
        string s = S.front();
        S.pop();
        T.pop();
        cnt++;

        if (s == X)
        {
            break;
        }
    }

    for (int i = cnt; i < N; i++)
    {
        int t = T.front();
        T.pop();
        ans += t;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
h,w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

ans = deque()
for i,a in zip(list(range(1,n+1)), A):
    for _ in range(a):
        ans.append(i)
check = 0
for i in range(h):
    a = []
    for _ in range(w):
      a.append(ans.popleft())
    if check%2==0: print(" ".join(map(str,a)))
    else:print(" ".join(map(str,a[::-1])))
    check += 1

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,a[30030],taken[30030] = {0};
int main() {
	read(n);
	if(n == 3){
		cout<<"2 5 63\n";
		return 0;
	}
	if(n%2 == 1){
		cout<<30000<<' ';
		n-=1;
	}
	n/=2;
	int typ = 0;
	int p1 = 2,p2 = 3,a = 0,t = 0;
	for(int j=1;j<=n;j++){
		if(p1+2<30000 && t !=0){
			cout<<p1<<' '<<p1+2<<' ';
			p1+=6;
		}else{
			t = 1;
			cout<<p2<<' '<<p2+6<<' ';
			p2+=3;
			if(a)p2+=6;
			a^=1;
		}
		typ^=1;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
int C,D,E,F;
  C=A+(A-1);
  D=A+B;
  E=B+(B-1);
  F=max({C,D,E});
  cout<<F<<endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
D = [1]*(N+1) #0段目からn段目まで
MOD = 10**9 + 7

for _ in range(M):
    D[int(input())] = 0

for i in range(N+1):
    if i <2 or D[i] == 0:
        continue
    D[i] = (D[i-1] + D[i-2]) % MOD

print(D[i])

Measured memory_bytes: 44248
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

n,m = LI()
h = LI()
high = [0]*n

for i in range(m):
    a, b = LI()
    if h[a-1]>h[b-1]:
        high[b-1] += 1
    elif h[a-1]==h[b-1]:
        high[a-1] += 1
        high[b-1] += 1
    else:
        high[a-1] += 1
print(high.count(0))

Measured memory_bytes: 20256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

struct Output {
private:
	vector<ll> contestList;
	
public:
	
	
};


class Input {
	vector<ll> decreaseRates;
	vector<vector<ll>> satisfacitons;
	ll numContests = 26;
	ll numDay = 365;
	vector<ll> contestList;
	vector<ll> lastContest;
	
public:
	void initialize() {
		contestList.resize(numDay + 1);
		lastContest.resize(numContests + 1);
	}
	void readInputs() {
		decreaseRates.resize(numContests + 1);
		for (ll i = 1; i <= numContests; i++) {
			cin >> decreaseRates[i];
		}
		satisfacitons.resize(numDay + 1);
		for (ll i = 1; i <= numDay; i++) {
			satisfacitons[i].resize(numContests + 1);
			for (ll j = 1; j <= numContests; j++) {
				cin >> satisfacitons[i][j];
			}
		}
	}

	ll getNumContests() { return numContests; }
	ll getNumDay() { return numDay; }
	vector<ll> getDecreaseRates() { return decreaseRates; }
	vector<vector<ll>> getSatisfactions() { return satisfacitons; }
	ll getContest(ll day) {
		return contestList[day];
	}
	vector<ll> getContestList() { return contestList; }
	void setNumContests(ll num) { numContests = num; }
	void setNumDay(ll day) { numDay = day; }
	void setContest(ll day, ll contest) {
		contestList[day] = contest;
	}

	

	ll calcScore() {
		ll score = 0;
		
		for (ll day = 1; day <= numDay; day++) {
			ll dayContest = contestList[day];
			lastContest[dayContest] = day;
			score += satisfacitons[day][dayContest];
			for (ll contest = 1; contest <= numContests; contest++) {
				score -= decreaseRates[contest] * (day - lastContest[contest]);
			}
			cout << score << endl;
		}

		return score;
	}

};




int main() {
	ll numDay;
	cin >> numDay;

	Input input;
	input.setNumDay(numDay);
	input.initialize();
	input.readInputs();
	for (ll i = 1; i <= numDay; i++) {
		ll contest;
		cin >> contest;
		input.setContest(i, contest);
	}
	ll score = input.calcScore();
	
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  
  bool ans1 = false;
  bool ans2 = false;
  bool ans3 = false;
  
  rep(i, 0, 3) {
    if(s.at(i) == 'a')
      ans1 = true;
  }
  rep(i, 0, 3) {
    if(s.at(i) == 'b')
      ans2 = true;
  }
  rep(i, 0, 3) {
    if(s.at(i) == 'c')
      ans3 = true;
  }
    
  cout << ((ans1 and ans2 and ans3) ?"Yes" :"No" ) << "\n";

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] $) {
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int m=sc.nextInt();
        int[] b=new int[m];
        for (int i = 0; i < m; i++) {
            b[i]=sc.nextInt();
        }
        TreeSet<Integer> ts=new TreeSet<>();
        for (int i = 0; i < (1 << n); i++) {
            int temp=0;
            for (int j = 0; j < n; j++) {
                if(((i>>j)&1)==1){
                    temp+=a[j];
                }
            }
            ts.add(temp);
        }
        for (int i = 0; i < m; i++) {
            out.println(ts.contains(b[i])?"yes":"no");
        }
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner scanner = new Scanner(System.in);

        static String next() {
            return scanner.next();
        }

        static String nextLine() {
            return scanner.nextLine();
        }

        static int nextInt() {
            return Integer.parseInt(scanner.next());
        }

        static long nextLong() {
            return Long.parseLong(scanner.next());
        }

        static double nextDouble() {
            return Double.parseDouble(scanner.next());
        }

        static boolean hasNext() {
            return scanner.hasNext();
        }

        static boolean hasNextInt() {
            return scanner.hasNextInt();
        }

        static boolean hasNext(String str) {
            return scanner.hasNext(str);
        }
    }

}


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

using namespace std;

typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli n;
	cin>>n;
	lli sum=0;
	for (int i=1;i<n;i++){
		int k=(n-1)/i;
		if (k>i) sum+=(k-i)*2;
		if (k>=i) sum++;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct drink {
  int price;
  int number;
};

int main() {
  vector<drink> drinks;
  int N, M;
  cin >> N >> M;
  int n, p;
  for (int i = 0; i < N; i++) {
    drink d;
    cin >> d.price >> d.number;
    drinks.push_back(d);
  }
  sort(drinks.begin(), drinks.end(), 
     [](const drink& x, const drink& y) { return x.price < y.price;});

  long ans = 0;
  int rem = M;
  for (int i = 0; i < N; i++) {
    drink d = drinks[i];
    if (rem > d.number) {
      ans += (long)d.number*d.price;
      rem -= d.number;
    }
    else {
      ans += (long)rem*d.price;
      break; 
    }
  }
  cout << ans  << endl;
  return 0; 
  
}

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

int main() {
  string s;
  cin >> s;
  int n = 0;
  for (char c : s) {
    switch(c) {
      case '+':
        ++n;
        break;
      case '-':
        --n;
        break;
      default:
        break;
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n,a;
  while( cin >> n,n ){
    map<int,int> col;
    int M = 0,ans;
    for(long long int i = 0 ; i < n ; i++ ){
      cin >> a;
      ++col[a];
      if(M < col[a]){
	M = col[a];
	ans = a;
      }
    }
    if(M > n/2)cout << ans << endl;
    else cout << "NO COLOR" << endl;
  }
  return 0;
}

Measured memory_bytes: 2732
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int x;
	cin >> x;
	ll sum = 0;
	sum += (x / 500) * 1000;
	x = x % 500;
	sum += x / 5 * 5;
	cout << sum << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

char grid[6][6];
char work[6][6];
int H, W, K;

void init(){
    rep(i, 6) rep(j, 6) work[i][j] = grid[i][j];
}

bool solve(vector<int> row, vector<int> col){
    //rep(i, H) cout << row[i] << " "; cout << endl;
    //rep(i, W) cout << col[i] << " "; cout << endl;
    rep(i, H){
        if(row[i]) rep(j, W) work[i][j] = '.';
    }
    rep(i, W){
        if(col[i]) rep(j, H) work[j][i] = '.';
    }
    //cout << "____" << endl;
    /*rep(i, H){
        rep(j, W){
            cout << work[i][j];
        }
        cout << endl;
    }*/
    int num = 0;
    rep(i, H) rep(j, W) if(work[i][j] == '#') num++;
    return num == K;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> H >> W >> K;
    string S[H];
    rep(i, H){
        cin >> S[i];
        rep(j, W) grid[i][j] = S[i][j];
    }
    int rowloop = (1 << H);
    int colloop = (1 << W);
    int ans = 0;
    rep(i, rowloop){
        vector<int> row;
        int rowval = i;
        rep(j, H){
            row.push_back(rowval%2);
            rowval /= 2;
        }
        rep(j, colloop){
            vector<int> col;
            init();
            int colval = j;
            rep(k, W){
                col.push_back(colval%2);
                colval /= 2;
            }
            if(solve(row, col)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>                                                                                                                                                                       
using namespace std;                                                                                                                                                                           
                                                                                                                                                                                               
int main(){                                                                                                                                                                                    
                                                                                                                                                                                               
        string s;                                                                                                                                                                              
        cin >> s;                                                                                                                                                                              
        if(s=="Sunny"){                                                                                                                                                                        
                cout << "Cloudy\n";                                                                                                                                                            
        } else if(s=="Cloudy"){                                                                                                                                                                
                cout << "Rainy\n";                                                                                                                                                             
        } else if(s=="Rainy"){                                                                                                                                                                 
                cout << "Sunny\n";                                                                                                                                                             
        }                                                                                                                                                                                      
        return 0;                                                                                                                                                                              
}      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ga,sa,ba,gb,sb,bb;
  cin>>N>>ga>>sa>>ba>>gb>>sb>>bb;
  vector<ll> dp1(N+1);
  for(int i=1;i<=N;i++){
    if(i-ga>=0){
      dp1[i]=max(dp1[i],dp1[i-ga]+gb);
    }
    if(i-sa>=0){
      dp1[i]=max(dp1[i],dp1[i-sa]+sb);
    }
    if(i-ba>=0){
      dp1[i]=max(dp1[i],dp1[i-ba]+bb);
    }
  }
  ll M=0;
  for(int i=0;i<=N;i++){
    M=max((ll)M,dp1[i]+N-i);
  }

  vector<ll> dp2(M+1);
  for(int i=1;i<=M;i++){
    if(i-gb>=0){
      dp2[i]=max(dp2[i],dp2[i-gb]+ga);
    }
    if(i-sb>=0){
      dp2[i]=max(dp2[i],dp2[i-sb]+sa);
    }
    if(i-bb>=0){
      dp2[i]=max(dp2[i],dp2[i-bb]+ba);
    }
  }
  ll ans=0;
  for(int i=0;i<=M;i++){
    ans=max((ll)ans,dp2[i]+M-i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 195584
N, M = map(int, input().split())
PSList = [list(input().split()) for i in range(M)]

ACWAList = []
for i in range(N):
    ACWAList.append([0, 0])

for i in range(M):
    P = int(PSList[i][0])

    if ACWAList[P-1][0] == 1:
        continue

    if PSList[i][1] == "AC":
        ACWAList[P-1][0] = 1
    else:
        ACWAList[P-1][1] += 1

ACSum = 0
WASum = 0
for i in range(N):
    if ACWAList[i][0] != 1:
        continue
    ACSum += ACWAList[i][0]
    WASum += ACWAList[i][1]

print(str(ACSum) + " " + str(WASum))

Measured memory_bytes: 80344
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
	// your code goes here
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int h,w,k;
	cin>>h>>w>>k;
	int dp[h+1][w];
	memset(dp,0,sizeof dp);
//	cout<<dp[1][1]<<endl;
	dp[0][0]=1;
	
	int i,j,a,b;
	bool f=0;
	for(i=0;i<h;i++)
	{
	    for(j=0;j<w;j++)
	    {
	        
	        for(a=0;a<(1<<(w-1));a++)
	        {
	            f=1;
	            
	            
	            for(b=0; b < w-2 ;b++)
	            {
	                if( ((a>>b)&1) &&  ((a>>(b+1))&1))
	                f=0;
	            }
	            if(f)
	            {
	                
	                if(j>0 && ((a>>(j-1))&1))
	                dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%mod;
	                
	                else if(j<(w-1) && ((a>>j)&1))
	                dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
	                
	                else
	                dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
	                
	            }
	        }
	    }
	}
	
	cout<<dp[h][k-1];

	return 0;
}


Measured memory_bytes: 256
using System;

class A{
	public static void Main(){

		string[] input = Console.ReadLine ().Split (' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int c = int.Parse(input[2]);

		if (a < b && b < c) {
			Console.WriteLine ("Yes");
		} else {
			Console.WriteLine ("No");
		}
	
	}
}

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

int main(){
	int child[20] = {};
	vector<int> G[20];
	vector<int> list;
	queue<int> que;
	int m,n;
	cin >> m >> n;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		G[x - 1].push_back(y - 1);
		child[y - 1]++;
	}
	for(int i = 0;i < m;i++){
		if(!child[i]) que.push(i);
	}
	while(!que.empty()){
		int v = que.front();que.pop();
		list.push_back(v);
		for(int i = 0;i < G[v].size();i++){
			child[G[v][i]]--;
			if(!child[G[v][i]]) que.push(G[v][i]);
		}
	}
	for(int i = 0;i < list.size();i++) cout << list[i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 3144
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0537
// status:
// tag: [DP]

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MOD = 100000;
// dp[i][j] 場所iで今の合計がjになる組み合わせの数
int dp[7 * 7 + 1][3000 + 1];
int N, M, S;

// 1以上M以下の自然数のみを用いてSのN分割を求める
int solve(int N, int M, int S, int mod) {
    // init
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int m = 1; m <= M; ++m) { // 使える自然数
        for (int n = N * N; n >= 1; --n) { // 今の位置
            for (int s = m; s <= S; ++s) { // 総和
                dp[n][s] = (dp[n][s] + dp[n - 1][s - m]) % mod;
            }
        }
    }

    return dp[N * N][S];
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(3 9 45
3 100 50
5 50 685
0 0 0
)");
#endif
    while (true) {
        stream >> N >> M >> S;
        if (N == 0 && M == 0 && S == 0) break;

        auto ans = solve(N, M, S, MOD);
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    int x = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) x++;
    }
    if (x == 8) ans++;
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    int x = p[0], ans = 0;
    for (int i = 0; i < n; i++){
        if (x >= p[i]) ans += 1;
        x = min(x, p[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>

const int MaxN = 200000 + 5;

int N;
int H[MaxN], A[MaxN];

template <typename Typ>
inline Typ max(Typ x, Typ y) { return x > y ? x : y; }

struct FenwickTree {
  long long t[MaxN];

  inline int lowbit(int i) {
    return i & -i;
  }

  inline void update(int x, long long v) {
    for (int i = x; i <= N; i += lowbit(i))
      t[i] = max(t[i], v);
  }

  inline long long query(int x) {
    long long res = 0;
    for (int i = x; i > 0; i -= lowbit(i))
      res = max(res, t[i]);
    return res;
  }
};
FenwickTree T;

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

void solve() {
  for (int i = 1; i <= N; ++i)
    T.update(H[i], T.query(H[i] - 1) + A[i]);
  printf("%lld\n", T.query(N));
}

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

Measured memory_bytes: 3328
A, B, K = [int(i) for i in input().split(" ")]

t = K-A
A = A-K
if A>0:
    print("%d %d" % (A, B))
    exit(0)

A = 0
B = B-t
if B<0:
    B = 0

print("%d %d" % (A, B))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll tt) {
    ll n;
    cin>>n;
    ll a[n];
    repf(i,0,n) cin>>a[i];
    ll suf[n];
    suf[n-1]=a[n-1];
    repb(i,n-2,0) suf[i]=(suf[i+1]+a[i])%mod;
    ll ans=0;
    repf(i,0,n-1) {
        ans=(ans+(a[i]*suf[i+1])%mod)%mod;
    }
    cout<<ans<<endl;
} 

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 6796
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a)
    cout << "delicious\n";
  else if (b <= (a + x))
    cout << "safe\n";
  else
    cout << "dangerous\n";
  return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s; cin >> s;
    long long k; cin >> k;
    int one = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') one++;
        else break;
    }
    if (k <= one) cout << 1 << '\n';
    else cout << s[one] << '\n';
}

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

    solve();

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int x = n + 1;
	if (n % 2 == 1)x--;
	vector<pair<int, int>>ans;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (i + j == x)continue;
			else ans.push_back({ i,j });
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++)cout << ans.at(i).first << " " << ans.at(i).second << endl;
}

Measured memory_bytes: 384