akhauriyash/Code-Regression huggingface dataset:
// C - Vacation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

// void vprn(vi &v){ for(int i=0;i<v.size();i++) printf("%4d%c",v[i],(i<v.size()-1?',':'\n')); }
// void vvprn(vvi &vv){ for(auto v:vv){ vprn(v); } }
// void dpprn(vvi &dp){
// 	cout<<"dp a,   b,   c\n----------------\n";
// 	vvprn(dp);cout<<"-----------------\n";
// }

int main(){
	int N; cin>>N;
	vvi dp(N, vi (3));
	int a, b, c;
	cin>>a>>b>>c;
	dp[0] = {a, b, c};
	for(int n=1; n<N; n++){
		cin>>a>>b>>c;
		dp[n] = {
			//              a           b           c
			a + max(            dp[n-1][1], dp[n-1][2]),
			b + max(dp[n-1][0],             dp[n-1][2]),
			c + max(dp[n-1][0], dp[n-1][1])
			};
	}
	// dpprn(dp);
	cout<< *max_element(dp[N-1].begin(), dp[N-1].end()) <<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;
using P = pair<int, int>;
using ll = long long;

class UnionFind {
	vector<int> data;
	vector<int> rank;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1), rank(n, 1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (rank[a] < rank[b]) {
			data[a] += data[b];
			data[b] = a;
		}
		else {
			data[b] += data[a];
			data[a] = b;
			if (rank[a] == rank[b]) rank[b]++;
		}
	}
	int Size(int a) {
		return -data[root(a)];
	}
	int Rank(int a) {
		return rank[root(a)];
	}
};

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	vector<T> xy(N), yx(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		xy[i] = make_tuple(x[i], y[i], i);
		yx[i] = make_tuple(y[i], x[i], i);
	}
	sort(xy.begin(), xy.end());
	sort(yx.begin(), yx.end());
	vector<T> es;
	for (int i = 1; i < N; i++) {
		es.push_back(T(min(abs(x[get<2>(xy[i])] - x[get<2>(xy[i - 1])]), abs(y[get<2>(xy[i])] - y[get<2>(xy[i - 1])])), get<2>(xy[i]), get<2>(xy[i - 1])));
		es.push_back(T(min(abs(x[get<2>(yx[i])] - x[get<2>(yx[i - 1])]), abs(y[get<2>(yx[i])] - y[get<2>(yx[i - 1])])), get<2>(yx[i]), get<2>(yx[i - 1])));
	}
	sort(es.begin(), es.end());
	UnionFind uf(N);
	int res = 0;
	for (auto e : es) {
		if (!uf.Find(get<1>(e), get<2>(e))) {
			res += get<0>(e);
			uf.Union(get<1>(e), get<2>(e));
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 7848
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
ll arr[100005];
ll mabs(ll x){
	if(x>0) return x;
	x=(-x);
	return x;
}
int main(){
	int n;
	while(~getI(n)){
		F(i,0,n) scanf("%lld",&arr[i]);
		ll neg=0,minV=INF,sum=0;
		F(i,0,n){
			if(arr[i]<0) neg++,sum+=(-arr[i]);
			else sum+=arr[i];
			if(mabs(arr[i])<minV) minV=abs(arr[i]);
		}
		printf("%lld\n",neg%2==0?sum:sum-2*minV);
	}
}


Measured memory_bytes: 1024
n=io.read("*n","*l")
a={}
b={}
for i=1,n+1 do
    a[i]=io.read("*n")
end
for i=1,n do
    b[i]=io.read("*n")
end

counter=0
for i=1,n do
    
    if a[i]<b[i] then
        counter=counter+a[i]
        b[i]=b[i]-a[i]
    else
        counter=counter+b[i]
        b[i]=0
    end

    if a[i+1]<b[i] then
        counter=counter+a[i+1]
        a[i+1]=0
    else
        counter=counter+b[i]
        a[i+1]=a[i+1]-b[i]
    end
    
end

print(counter)

Measured memory_bytes: 4472
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRingoSFavoriteNumbers solver = new BRingoSFavoriteNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRingoSFavoriteNumbers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int d = in.nextInt(), n = in.nextInt();
            int b = 1;
            for (int i = 0; i < d; i++) {
                b *= 100;
            }
            out.println(n == 100 ? b * (n + 1) : b * n);
        }

    }
}



Measured memory_bytes: 23124
fun main(arr: Array<String>) {
    val (n,a,b) = readLine()!!.split(" ").map { it.toLong() }
    val (p1,p2) = listOf(a,b).sorted()
    if((p2-p1) % 2 == 0L) {
        println(Math.abs(p2-p1)/2)
    } else if(p1 - 1 < n - p2) {
        var ans = p1-1
        ans++
        ans += (p2-p1)/2
        println(ans)
    } else {
        var ans = n -p2
        ans++
        ans += (p2-p1)/2
        println(ans)
    }
}



Measured memory_bytes: 38948
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{
    static int INF = 10000000;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int min = INF;
        int ans = 0;
        for(int i = 0; i < n; i++)
        {
            if(arr[i] < min)
            {
                min = arr[i];
                ans++;
            }
        }
        Console.WriteLine(ans);
    }

}

   

Measured memory_bytes: 43056
// printing all coordinates that cointain a stone painted black in ascending order
#include<bits/stdc++.h>
using namespace std;

int K, X;

int main() {
    cin >> K >> X;
    int ans = X-K+1;
    while (ans != X+K) {
        cout << ans << " ";
        ans++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3564
a = []

for i in range(5):
    a.append(int(input()))


result = 0
min_min = 10
for each in a:
    if each % 10 != 0:
        result += each + 10 - (each % 10)
        if min_min > each % 10:
            min_min = each % 10
    else:
        result += each
print(result - (10 - min_min))


Measured memory_bytes: 2940
import java.io.*;
 
class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuffer sb = new StringBuffer();
         
        while(true)
        {
            String[] strAry = (br.readLine()).split(" ");
            int h = Integer.parseInt(strAry[0]);
            int w = Integer.parseInt(strAry[1]);
         
            if(0 == h & 0 == w)
            {
                break;
            }
 
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    sb.append("#");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25640
import java.util.*

fun Char.toLower() = Character.toLowerCase(this)

fun main(args : Array<String>) {
  val (n, k) = readLine()!!.split(' ').map(String::toInt)
  readLine()!!.mapIndexed { i, c -> if (i + 1 == k) c.toLower() else c }
    .forEach(::print)
  println()
}


Measured memory_bytes: 38168
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    m_t = 10 ** 10
    for i in range(1, n):
        a = list(map(int, list(str(i))))
        b = list(map(int, list(str(n-i))))
        m_t = min(m_t, sum(a) + sum(b))
    print(m_t)


if __name__ == '__main__':
    slove()


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

int main(){
    int five=0,seven=0;
    for(int i=0;i<3;i++){
        int n;
        cin >> n;
        if(n==5){
            five++;
        }
        if(n==7){
            seven++;
        }
    }
    if(five==2&&seven==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
int x[500];
int a[500*500];
typedef pair<int,int> P;
bool isok(){
	int it[500]={};
	rep(i,N*N){
		int v=a[i];
		it[v]++;
		if(it[v]==v){
			if(i!=x[v-1]) return 0;
		}
	}
	return 1;
}
int main(){
	cin>>N;
	rep(i,N) cin>>x[i],x[i]--,a[x[i]]=i+1;
	vector<P> ps;
	rep(i,N) ps.pb(P(x[i],i+1));
	sort(all(ps));
	vector<int> vs,gomi;
	rep(i,N){
		int v=ps[i].sc;
		rep(j,v-1) vs.pb(v);
	}
	int K=vs.size();
	int I=0,J=0;
	rep(i,N*N){
		if(a[i]>0){
			int v=a[i];
			rep(j,N-v) gomi.pb(v);
			continue;
		}
		if(I<K){
			a[i]=vs[I];
			I++;
			continue;
		}else{
			if(J<gomi.size()){
				a[i]=gomi[J];
				J++;
			}else{
				puts("No");
				return 0;
			}
		}
	}
	if(isok()){
		puts("Yes");
		rep(i,N*N) cout<<a[i]<<" ";
		puts("");
	}else puts("No");
}


Measured memory_bytes: 3204
/*A - Poor*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	
	set <int> arr;
	int num;
	for (int i = 0; i < 3; ++i)
	{
		cin >> num;
		arr.insert(num);
	}

	if(arr.size() == 2)
		cout << "Yes";
	else
		cout << "No";
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int i,j,n,minj,a,b = 0;
  int A[N];
  scanf("%d",&n);

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

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

    for(j = i ; j < n ; j++){
      
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(i != minj) b++;
    
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
  }

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

  return 0;
}

Measured memory_bytes: 604
// 2017/05/12 Tazoe

#include <iostream>
using namespace std;

const int NOT_FOUND = -1;

int binarySearch(int key, int A[], int n)
{
	int left = 0;
	int right = n;

	while(left<right){
		int mid = (left+right)/2;

		if(A[mid]==key){
			return mid;
		}
		else if(key<A[mid]){
			right = mid;
		}
		else{
			left = mid+1;
		}
	}

	return NOT_FOUND;
}

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

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

	int q;
	cin >> q;

	int T[50000];
	for(int i=0; i<q; i++){
		cin >> T[i];
	}

	int C = 0;

	for(int i=0; i<q; i++){
		if(binarySearch(T[i], S, n)!=NOT_FOUND){
			C++;
		}
	}

	cout << C << endl;

	return 0;
}

Measured memory_bytes: 3672
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut hs = HashSet::new();
    for i in s.iter(){
        hs.insert(i);
    }
    let ans = hs.len();
    println!("{}", ans);
}


Measured memory_bytes: 18524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/

int a[100009],b[100009];
int main()
{
	int		i,n;
	long long ans = 0;
	
	scanf("%d", &n);
	for(i=1;i<=n+1;i++) scanf("%d", &a[i]);
	for(i=1;i<=n;i++)   scanf("%d", &b[i]);
	
	for(i=1;i<=n;i++) {
		// i mon
		if (a[i] < b[i]) {
			ans += a[i];
			b[i] -= a[i];
			//i+1 mon
			if (a[i+1] < b[i]) {
				ans += a[i+1];
				a[i+1] = 0;
			} else {
				ans += b[i];
				a[i+1] -= b[i];
			}
		} else {
			ans += b[i];
		}
	}
	
	printf("%lld\n",ans);


	return 0;
}


Measured memory_bytes: 1024
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInt()
	b := scanInt()
	c := scanInt()
	l := scanInts(n)

	ans := 1 << 31-1

	bitExhaustiveSearch(n,func(a1 []int) {
		bitExhaustiveSearch(n, func(a2 []int) {
			// d := make([]int, n)
			// for i := 0; i < n; i++ {
			// 	d[i] = a1[i]*2+a2[i]
			// }
			// debug(a1,a2)
			na,nb,nc := 0,0,0
			cost := 0
			for i := 0; i < n; i++ {
				switch a1[i]*2+a2[i] {
				case 1:
					if na != 0 {
						cost += 10
					}
					na += l[i]
				case 2:
					if nb != 0 {
						cost += 10
					}
					nb += l[i]
				case 3:
					if nc != 0 {
						cost += 10
					}
					nc += l[i]
				}
			}

			if na==0||nb==0||nc==0 {
				return
			}
			cost += abs(a-na)+abs(b-nb)+abs(c-nc)
			ans = min(ans, cost)
		})
	})

	fmt.Fprintln(wr, ans)
}

func bitExhaustiveSearch(n int, fn func(a []int)) {
	all := 1 << uint(n)
	a := make([]int, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = 1 } else {a[j] = 0 }
		}
		fn(a)
	}
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A + B >= C) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 300;
const int INF = 1e9;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  ll a[n][n],d[n][n];
  rep(i,n){
    rep(j,n){
      cin >> a[i][j];
      d[i][j]=a[i][j];
    }
  }
  
  rep(k,n){
    rep(i,n){
      rep(j,n){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        if(d[i][j]!=a[i][j]){
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  
  ll sum=0;
  rep(i,n){
    for(int j=i;j<n;j++){
      bool ok = true;
      rep(k,n){
        if(k==i || k==j)continue;
        if(d[i][j]==d[i][k]+d[k][j]) ok=false;
      }
      if(ok) sum+=d[i][j];
    }
  }
  cout << sum << endl;     
      
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


//------------------変数-----------------------//
ll n, d, h, w, goukei[1030] = {};
P p[100001];
vector<ll> v;
vector<vector<ll>> block(100001);
//-------------------関数----------------------//
ll check(ll x, ll y) {
	if (x < 1 || y < 1 || x >= w-1 || y >= h-1) { return 114; }
	ll cnt = 0;
	for (ll i = y - 1; i < y + 2; i++)
	{
		vector<ll>::iterator iter = lower_bound(v.begin(), v.end(), i);
		if (*iter == i&&*iter!=INF) {
			ll point = distance(v.begin(), iter);
			for (ll j = x - 1; j < x + 2; j++)
			{
				vector<ll>::iterator yiter = lower_bound(block[point].begin(), block[point].end(), j);
				if (*yiter == j&&*yiter!=INF) {
					cnt++;
				}
			}
		}
	}
	return cnt;
}
int main() {
	cin >> h >> w >> n;
	REP(i, n) {
		cin >> p[i].first >> p[i].second; p[i].second--; p[i].first--;
	}
	sort(p, p + n);
	ll mae = -1, hoge = -1;
	REP(i, n) {
		if (p[i].first != mae) {
			v.push_back(p[i].first);
			hoge++;
			mae = p[i].first;
		}
		block[hoge].push_back(p[i].second);
	}
	v.push_back(INF);
	REP(i, 100000) {
		block[i].push_back(INF);
	}
	REP(a, hoge + 1) {
		REP(b, block[a].size()-1) {
			for (ll i = v[a] - 1; i < v[a] + 2; i++)
			{
				for (ll j = block[a][b] - 1; j < block[a][b] + 2; j++)
				{
					goukei[check(j, i)]++;
				}
			}
		}
	}
	ll izryt = 0;
	for (ll i = 1; i < 10; i++)
	{
		goukei[i] /= i;
		izryt += goukei[i];
	}
	cout << (h - 2)*(w - 2) - izryt << endl;
	for (ll i = 1; i < 10; i++)
	{
		cout << goukei[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 8448
def binary_search(num, numlist):
    left = 0
    right = len(numlist)
    while left < right:
        mid = (left + right) // 2
        if numlist[mid] == num:
            return mid
        elif numlist[mid] < num:
            left = mid + 1
        else:
            right = mid
    return -1

if __name__ == '__main__':
    n = input()
    numlist1 = [int(num) for num in input().split()]
    m = input()
    numlist2 = [int(num) for num in input().split()]

    tot = 0
    for num in numlist2:
        if binary_search(num, numlist1) >= 0:
            tot += 1
    print(tot)


Measured memory_bytes: 16896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int H, W;
    cin >> H >> W;
    string space[H];
    for(int i = 0; i < H; i++){
        cin >> space[i];
    }
    bool is_blank_row[H];
    for(int i = 0; i < H; i++){
        is_blank_row[i] = true;
        for(int j = 0; j < W; j++){
            is_blank_row[i] &= (space[i][j] == '.');
        }
    }
    bool is_blank_column[W];
    for(int i = 0; i < W; i++){
        is_blank_column[i] = true;
        for(int j = 0; j < H; j++){
            is_blank_column[i] &= (space[j][i] == '.');
        }
    }
    for(int i = 0; i < H; i++){
        if(is_blank_row[i]){
            continue;
        }
        for(int j = 0; j < W; j++){
            if(!is_blank_column[j]){
                cout << space[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, c;
    while(cin >> a >> b >> c, a){
        int n, m = a+b+c;
        int ok[305];
        vector<vector<int> > ls;
        fill(ok,ok+m+1,2);
        cin >> n;
        REP(i,n){
            int x, y ,z, r;
            cin >> x >> y >> z >> r;
            if(r){
                ok[x] = 1;
                ok[y] = 1;
                ok[z] = 1;
            }
            else{
                vector<int> tmp;
                tmp.push_back(x);
                tmp.push_back(y);
                tmp.push_back(z);
                ls.push_back(tmp);
            }
        }
        for(auto v : ls){
            int cnt = 0;
            for(auto i : v) if(ok[i]==1) cnt++;
            if(cnt==2){
                for(auto i : v) if(ok[i]==2) ok[i] = 0;
            }
        }
        REP(i,m){
            cout << ok[i+1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;cin>>n>>a>>b;
    vector<ll> x; x.resize(n);
    rep(i,n) cin>>x[i];
    ll ans = 0;
    for(int nw = 0; nw<n-1; nw++){
        ans += min(a*(x[nw+1]-x[nw]), b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
def solve(N, Ps):
    ans = 0
    for i in range(1, N-1):
        if Ps[i-1] < Ps[i] < Ps[i+1]:
            ans += 1
        if Ps[i-1] > Ps[i] > Ps[i+1]:
            ans += 1
    return ans

if __name__ == "__main__":
    N = int(input())
    Ps = list(map(int, input().split(" ")))
    print(solve(N, Ps))


Measured memory_bytes: 3316
n=int(input())
a=input().split()
count=0

for t in range(n):
  a[t]=int(a[t])
  
for i in range(n-2):
  for j in range(n-2):
    if j>=i:
      for k in range(n-2):
        if k>=j:
          if a[i]!=a[j+1] and a[j+1]!=a[k+2] and a[k+2]!=a[i]:
            if a[i]+a[j+1]>a[k+2] and a[j+1]+a[k+2]>a[i] and a[k+2]+a[i]>a[j+1]:
              count+=1
print(count)

Measured memory_bytes: 9072
import  numpy   as  np
s_input =   input().split()
i_input =   np.array(s_input).astype("int32")

diff =  i_input[0] - i_input[1]

if(i_input[2] - diff <= 0):
    print("0")
else:
    print("{}".format(i_input[2]-diff))

Measured memory_bytes: 12504
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v)

N = int(input())
C = [0] * N
E = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    E[u].append((w % 2, v))
    E[v].append((w % 2, u))
dfs(0, 0, -1)
print(*C, sep='\n')

Measured memory_bytes: 76464
import java.io.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bu.readLine()),t=0,ans=-1; long cur=0;
        while(t!=n)
        {
            cur=(cur*10)+7;
            cur%=n;
            if(cur==0) {ans=t+1; break;}
            t++;
        }
        System.out.print(ans);
    }
}

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

int main() {
  
  int r;
  int D;
  int x;
  int count = 0;
  
  cin >> r >> D >> x;
  
  while(count < 10){
    x = x * r - D;
    cout << x << endl;
    ++count;
  }
  
}



Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())

while(A>=B and K > 0):
    B *=2
    K -=1

while(B>=C and K > 0 ):
    C *=2
    K -=1

if A<B and B<C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61664
// https://atcoder.jp/contests/abc111/tasks/abc111_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[0] >= s[1] && s[0] >= s[2]) {
        REP(i, 3) cout << s[0];
        cout << endl;
    } else {
        char c = ++s[0];
        REP(i, 3) cout << c;
        cout << endl;
    }

    return 0;
}


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

#define MAX_H 251

int main() {
	int h = 0;
	scanf("%d", &h);
	int heap[MAX_H] = { 0 };
	for (int i = 1; i <= h; i++) {
		scanf("%d", &heap[i]);
	}
	for (int i = 1; i <= h; i++) {
		int parent = heap[i/2];
		int left = heap[i*2];
		int right = heap[i*2 + 1];
		printf("node %d: ",i);
		printf("key = %d, ", heap[i]);
		if ((i/2) >= 1) printf("parent key = %d, ", parent);
		if ((i*2) <= h) printf("left key = %d, ",left);
		if ((i * 2+1) <= h) printf("right key = %d, ", right);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3204
#!/usr/bin/env python3
import sys
import numpy as np

# dp = np.ones((100, 4, 4, 4))

# tot = 0
# for x in itertools.product(*["ACGT"]*5):
#     x = "".join(x)
#     if "AGC" in x or "ACG" in x or "GAC" in x:
#         tot += 0
#     else:
#         tot += 1
# print(tot)

MOD = 1000000007  # type: int

# 例外をカウントすべきだ。
# AGCT = "AGCT"
# dp = [[0]*4 for _ in range(4) for _ in range()]
# buf = [1, 4, 16, 64]
# ans = [1, 4, 16, 61]


def solve(N: int):
    A, C, G, T = 0, 1, 2, 3
    dp = np.zeros((102, 4, 4, 4))
    dp[3] = np.ones((4, 4, 4))
    dp[3][A][G][C] = 0
    dp[3][G][A][C] = 0
    dp[3][A][C][G] = 0
    for i in range(3, N):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        if k == A and l == G and m == C:
                            # print("AGC")
                            continue
                        elif k == G and l == A and m == C:
                            # print("GAC")
                            continue
                        elif k == A and l == C and m == G:
                            # print("ACG")
                            continue
                        elif j == A and k == G and m == C:
                            # print("AG*C")
                            continue
                        elif j == A and l == G and m == C:
                            # print("A*GC")
                            continue
                        else:
                            dp[i+1][k][l][m] += dp[i][j][k][l] % MOD
        # print(dp[i])
    print(int(np.sum(dp[N])) % MOD)
    # n = 3
    # while 1:
    #     if n == N:
    #         break
    #     dp.append(((dp[n]*4 % MOD)+(2*ans[n-2] %
    #                                 MOD)+(5*ans[n-3] % MOD)) % MOD)
    #     buf.append((buf[-1]*4) % MOD)
    #     ans.append((buf[-1]-dp[-1]) % MOD)
    #     n += 1
    # print(dp)
    # print(ans[-1])
    # print(MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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


int main(void){

int a,b,h,m;
scanf("%d%d%d%d",&a,&b,&h,&m);

long double xa,ya,xb,yb;

xa = a*sin(1.00*h/1.0/12*2*M_PI+1.00*m/1.0/60*2*M_PI/12);
ya = a*cos(1.00*h/1.0/12*2*M_PI+1.00*m/1.0/60*2*M_PI/12);

xb = b*sin(1.00*m/60*2*M_PI);
yb = b*cos(1.00*m/60*2*M_PI);

//printf("%lf\n%lf\n%lf\n%lf\n",xa,ya,xb,yb);

long double x_distance,y_distance;

x_distance = xa-xb;
y_distance = ya-yb;

long double distance_pow;
distance_pow = 1.0*x_distance*x_distance+1.0*y_distance*y_distance;

long double distance;
distance =  sqrtl(distance_pow);

printf("%10.10Lf\n",distance);
return 0;
}

Measured memory_bytes: 2520
def Bellman_Ford(s, g, inf=1 << 60):
    # https://tjkendev.github.io/procon-library/python/graph/bellman-ford.html
    N = len(g)
    dist = [inf] * N
    dist[s] = 0

    for _ in range(N):
        not_updated = True
        for v in range(N):
            for u, c in g[v]:
                if (dist[v] == inf) or (dist[v] + c >= dist[u]): continue
                dist[u] = dist[v] + c
                not_updated = False
        if not_updated: break

    else:
        # 負閉路が存在する
        ret = dist[N - 1]
        for v in range(N):
            for u, c in g[v]:
                if (dist[v] == inf) or (dist[v] + c >= dist[u]): continue
                dist[u] = dist[v] + c

        if ret == dist[N - 1]:
            return -ret
        else:
            return 'inf'

    return -dist[N - 1]


def main():
    import sys
    input = sys.stdin.readline

    sys.setrecursionlimit(10 ** 7)

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        g[a].add((b, -c))

    ans = Bellman_Ford(s=0, g=g)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


int main(){
  int n;
  cin >> n;  
  int sum = findSumOfDigits(n);
if(n%sum == 0){
    cout << "Yes" << endl;
  }
else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
function Main(input){
	input = input.split(" ").map(Number);
	var n = input[1];
	var m = input[0]+n-1;
	var p = 0
	if(m<0) p = m;
	else if(n>0) p = n;
	var ans = (m*(m+1)/2)-(n*(n-1)/2)-p;
	console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
using System;

namespace Atcoder
{
    class Program
    //diverta 2019 Programming Contest B - RGB Boxes
    {
        private static void Main(string[] args)
        {
            var line = Console.ReadLine()?.Split(' ');
            var r = int.Parse(line[0]);
            var g = int.Parse(line[1]);
            var b = int.Parse(line[2]);
            var n = int.Parse(line[3]);

            var count = 0;

            for (var i = 0; i <= n; i++)
            {
                for (var j = 0; j <= n - i; j++)
                {
                    var rest = n - i * r - j * g;
                    if (rest >= 0 ? true : false)
                    {
                        if (rest % b == 0)
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

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

int ttt(int w){
    int p=0;
    while(w%2==0){
        w=w/2;
        p++;
        }
        return p;
        }
int main(){ 
    int n; cin>>n;
    int t,ans=10000000,w;

    for(int i=0;i<n;i++){
        cin>>w;
        t=ttt(w);
        ans=min(ans,t);
        }
        cout<<ans<<endl;
    }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(),(c).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define debug2(x,y) cerr<<"("<<#x<<","<<#y<<") = ("<<x<<","<<y<<")\n";
#define debugM(x,n,m) rep(i,0,n){ rep(j,0,m) cerr<<x[i][j]<<" ";cerr<<endl;}
#define debugV(x,n) rep(i,0,n){cerr<<x[i]<<" ";}cerr<<endl; 
#define pi 3.14159265358979323846264338
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const int MOD = 1e9+7;

int main(){
	int n,a,b;
	while(cin>>n>>a>>b){
		cout<<(n-a+1)*(n-b+1)<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int tp=n;
  int sum=0;
  while(tp)
  {
  	int r=tp%10;
  	sum+=r;
  	tp/=10;
  }
  if(n%sum==0)
  cout<<"Yes"<<"\n";
  else
  cout<<"No"<<"\n";
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int M;
int d[220000], c[220000];
signed main() {
    cin >> M;
    int sum = 0;
    int all = 0;
    rep(i, M) {
        cin >> d[i] >> c[i];
        sum += c[i];
        all += c[i] * d[i];
    }
    if (all % 9 == 0) { sum--; }
    cout << sum - 1 + all / 9 << endl;
}


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

int main()
{
    int a, b, Count = 1;
    cin>>a>>b;
    if((b - 1) % (a - 1) == 0)
        cout<<(b-1)/(a-1);
    else
        cout<<((b - 1)/(a - 1) + 1);
    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,k,q = map(int,input().split())
	a = defaultdict(int)
	for i in range(q):
		a[int(input())] += 1
	for i in range(1,n+1):
		suc = a[i]
		if(k-(q-suc) > 0):
			print('Yes')
		else:
			print('No')


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 90528
K, N = list(map(int,input().split()))
A = list(map(int,input().split()))
diff = [K - A[-1] + A[0]]
for i in range(1, N):
    diff.append(A[i] - A[i - 1])
diff = sorted(diff)
ans = sum(diff) - diff[-1]
print(ans)

Measured memory_bytes: 89676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  
  int x = 0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      x += vec[i]*vec[j];
    }
  }
  
  cout << x << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int cel(int d,int n)
{
	int ans=d/(n+1);
	if((d%(n+1))!=0)ans++;
	return ans;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int min_so_far=a[0];
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	min_so_far=min(min_so_far,a[i]);
    	if(min_so_far>=a[i])
    	{
    		ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}













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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string k;
  cin >> k;
  if (k == "ABC"){
    k = "ARC";
  }
  else{
    k = "ABC";
  }
  cout << k << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			if (h == 0) {
				sc.close();
				break;
			}

			int w = sc.nextInt();
			int c = sc.nextInt();

			int[][] panel = new int[h][w];
			int[][] dummy = new int[h][w];
			for (int i = 0; i < panel.length; i++) {
				for (int j = 0; j < panel[i].length; j++) {
					panel[i][j] = sc.nextInt();
				}
			}

			int max = 0;
			for (int i1 = 1; i1 <= 6; i1++) {
				for (int i2 = 1; i2 <= 6; i2++) {
					for (int i3 = 1; i3 <= 6; i3++) {
						for (int i4 = 1; i4 <= 6; i4++) {
							for (int i = 0; i < dummy.length; i++) {
								for (int j = 0; j < dummy[0].length; j++) {
									dummy[i][j] = panel[i][j];
								}
							}
							check(dummy, i1);
							check(dummy, i2);
							check(dummy, i3);
							check(dummy, i4);
							check(dummy, c);
							max = Math.max(max, check(dummy, c));
						}
					}
				}
			}

			System.out.println(max);
			System.gc(); // 1テストケースごとにメモリを解放
		}

	}

	static int check(int[][] dummy, int c) {
		int old = dummy[0][0];
		boolean[][] used = new boolean[dummy.length][dummy[0].length];
		Deque<Integer[]> deque = new ArrayDeque<Integer[]>();
		Integer[] first = { 0, 0 };
		deque.add(first);
		used[0][0] = true;
		dummy[0][0] = c;
		int ret = 1;

		int[][] dir = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		while (!deque.isEmpty()) {
			Integer[] poll = deque.poll();
			int i = poll[0];
			int j = poll[1];

			for (int k = 0; k < dir.length; k++) {
				if (i + dir[k][0] >= 0 && i + dir[k][0] < dummy.length && j + dir[k][1] >= 0
						&& j + dir[k][1] < dummy[0].length && !used[i + dir[k][0]][j + dir[k][1]]
						&& dummy[i + dir[k][0]][j + dir[k][1]] == old) {
					Integer[] put = { i + dir[k][0], j + dir[k][1] };
					deque.add(put);
					used[i + dir[k][0]][j + dir[k][1]] = true;
					dummy[i + dir[k][0]][j + dir[k][1]] = c;
					ret++;
				}
			}
		}
		return ret;
	}

}

Measured memory_bytes: 38140
import java.util.*;
import java.awt.geom.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			String s = sc.next();
			while(n-- > 0){
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < s.length();){
					char num = s.charAt(i);
					int count = 0;
					while(i < s.length() && num == s.charAt(i)){
						count++;
						i++;
					}
					sb.append(count + "" + num);
				}
				s = sb.toString();
			}
			System.out.println(s);
		}
	}

	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

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

int main(){
	string x,y;
	cin>>x;
	cin>>y;
	int n=x.size();
	int m=y.size();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
          	if(i==0 || j==0)
            dp[i][j]=0;
			else if(x[i-1]==y[j-1])
			dp[i][j]=dp[i-1][j-1]+1;
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}	
	}
	int i=n,j=m;
  	string ans="";
  	while(i>0 && j>0){
      if(x[i-1]==y[j-1]){
        ans+=x[i-1];
        i--;
        j--;}
      else if(dp[i-1][j]>dp[i][j-1]){
        i--;
      }
      else
        j--;
    }
  	reverse(ans.begin(),ans.end());
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
// const int INF = +100100100;
typedef pair<int,int> P;

#define MAX 10001
#define NIL  -1

struct Node{
    int l,r,p;
};
Node T[MAX];


vector<int> PRE;
void preoder(int i){
    PRE.push_back(i);
    if(T[i].l==NIL&&T[i].r==NIL)return;
    if(T[i].l!=NIL){
        preoder(T[i].l);
    }
    if(T[i].r!=NIL){
        preoder(T[i].r);
    }
}

vector<int> INO;
void inorder(int i){
    // if(T[i].l==NIL)INO.push_back(i);
    if(T[i].l==NIL && T[i].r==NIL){
        INO.push_back(i);
        return;
    }
    if(T[i].l!=NIL)inorder(T[i].l);
    INO.push_back(i);
    if(T[i].r!=NIL)inorder(T[i].r);
}

vector<int> POS;
void postoder(int i){
    if(T[i].l==NIL&&T[i].r==NIL){
        POS.push_back(i);
        return;
    }
    if(T[i].l!=NIL)postoder(T[i].l);
    if(T[i].r!=NIL)postoder(T[i].r);
    POS.push_back(i);
}

int main(){
    int n;
    cin >> n;
    rep(i,n)T[i].l=T[i].p=T[i].r=NIL;
    // 木の作成
    rep(i,n){
        int v,l,r;
        cin >> v>> l>>r;
        T[v].l=l; T[v].r=r;
        if(l!=-1){
            T[l].p=v;
        }
        if(r!=-1){
            T[r].p=v;
        }   
    }
    int parent;
    rep(i,n)if(T[i].p==NIL)parent=i;
    preoder(parent);
    inorder(parent);
    postoder(parent);
    cout<<"Preorder"<<endl;
    rep(i,n){
        // if(i==0)cout<<PRE[i];
        // else cout << " "<<PRE[i];
        cout <<" "<< PRE[i];
    }
    cout<<endl;
    cout<<"Inorder"<<endl;
    rep(i,n){
        // if(i==0)cout<<INO[i];
        // else cout << " "<<INO[i];
        cout <<" "<< INO[i];
    }
    cout<<endl;
    cout<<"Postorder"<<endl;
    rep(i,n){
        // if(i==0)cout<<POS[i];
        // else cout << " "<<POS[i];
        cout <<" "<< POS[i];
    }
    cout<<endl;
    return 0;
}


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

int main(){
    long A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;

    C*=2;

    long ans=0;

    if(A+B>C){
        ans=min(X,Y)*C;
        if(X==Y){}
        else if(X>Y&&A<=C)ans+=(X-Y)*A;
        else if(X<Y&&B<=C)ans+=(Y-X)*B;
        else{
            ans=max(X,Y)*C;
        }
    }else{
        ans=A*X+B*Y;
    }

cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String... args){
    Scanner sc = new Scanner(System.in);
    String array[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    String S = sc.next();
    for(int i = 0; i < array.length; i++){
      if(S.equals(array[i])){
        System.out.println(7 - i);
        break;
      }
    }
  }
}

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

int main(){
  string S;
  cin >> S;
  
  int out = 0;
  rep(i, S.size()){
    if (S[i] == '+') out++;
    else out--;
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256