akhauriyash/Code-Regression huggingface dataset:
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

bool comp1(pii a,pii b){
    if(a.F!=b.F) return a.F<b.F;
    return a.S>b.S;
}
bool comp2(pii a,pii b){
    return a.S>b.S;
}
signed main(){
    FastIO;
    int n;
    cin>>n;
    vector<pii>pos,neg;
    rep(i,1,n){
        string s;
        cin>>s;
        int maxi=0,cnt=0;
        for(char c:s){
            if(c=='(') cnt++;
            else cnt--;
            if(cnt<0) maxi=max(maxi,abs(cnt));
        }
        if(cnt>0) pos.pb({maxi,cnt+maxi});
        else neg.pb({maxi,cnt+maxi});
    }
    sort(all(pos),comp1);
    sort(all(neg),comp2);
    int bal=0;
    for(pii p:pos){
        bal-=p.F;
        if(bal<0) return cout<<"No",0;
        bal+=p.S;
    }
    for(pii p:neg){
        bal-=p.F;
        if(bal<0) return cout<<"No",0;
        bal+=p.S;
    }
    cout<<(bal?"No":"Yes");
    return 0;
}


Measured memory_bytes: 11232
let swap a i j =
  let temp = a.(i) in
  a.(i) <- a.(j);a.(j) <- temp;;

let rec find (a:(string*int) array) (x,y) n =
  if (fst a.(n)) = x && (snd a.(n)) = y then n else find a (x,y) (n+1);;

let is_stable org (c:(string*int) array) n =
  let rec loop = function
      i when i = n -> "Stable"
    | i ->
       if (snd c.(i)) = (snd c.(i-1)) then
         if find org c.(i) 0 > find org c.(i-1) 0 then loop (i+1)
         else "Not stable"
       else
         loop (i+1)
  in loop 1
;;

let partition (a:(string*int) array) p r =
  let (_,x) = a.(r) and
      i = ref (p-1) in
  for j = p to (r-1) do
    if (snd a.(j)) <= x then
      begin
        i := (!i) + 1;
        swap a (!i) j;
      end;
  done;
  swap a ((!i)+1) r;
  (!i) + 1
;;

let rec quick_sort a p r =
  if p < r then
    let q = partition a p r in
    quick_sort a p (q-1);
    quick_sort a (q+1) r
;;

let () =
  let n = read_int () in
  let a1 = Array.init n (fun x -> Scanf.scanf "%s %d\n" (fun y z-> (y,z))) in
  let a2 = Array.copy a1 in
  quick_sort a2 0 (n-1);
  print_endline (is_stable a1 a2 n);
  Array.iter (fun (x,y) -> Printf.printf "%s %d\n" x y) a2
;;

Measured memory_bytes: 10616
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdio>

using namespace std;
int H,W,N,sx,sy,ans = 0,Index;
int imap[1400][1400];
char cmap[1400][1400];
bool used[1400][1400];
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
typedef pair<int,int> P;
void Init(){
  for(int i=0;i<1400;i++)for(int j=0;j<1400;j++)used[i][j] = false;
}

void bfs(int x,int y){
  queue<P> que;
  que.push(P(x,y));
  used[y][x] = true;

  while(que.size()){
    /*
   
    */

    P p = que.front(); que.pop();
if(cmap[p.second][p.first]-'0' == Index){
  // cout << Index << " is INNNNNNNNN" << endl;
      ans+=imap[p.second][p.first];
      Index++;
      Init();
      imap[p.second][p.first] = 0;
      bfs(p.first,p.second);
      return;
    }
    

    for(int i=0;i<4;i++){
      int nx = p.first+dx[i],ny = p.second+dy[i];
      if(!used[ny][nx] && 0<=nx && nx < W && 0<=ny && ny < H && imap[ny][nx] != -1){

	imap[ny][nx] = imap[p.second][p.first]+1;
	que.push(P(nx,ny));
	used[ny][nx] = true;
      }
    }

  }

  return;
}


int main(){
  char c;
  while(cin >> H >> W >> N){
    ans = 0;
    Index = 1;
    Init();
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)imap[i][j] = 0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin >> c;
	cmap[i][j] = c;
	if(c == '.'){
	  imap[i][j] = 0;
	}
	else if(c == 'X'){
	  imap[i][j] = -1;
	}
	else if(c == 'S'){
	  sx = j;
	  sy = i;
	}
	else{
	  imap[i][j] = 0;
	}
      }
    }
    
    bfs(sx,sy);

    cout << ans << endl;

  }
  return 0;
}

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

int cnt_digits(ll n){
    int digits = 0;
    while(n > 0){
        n /= 10;
        digits++;
    }
    return digits;
}

int main() {
    ll n;
    cin >> n;
    int ans = cnt_digits(n);

    for(ll i = 1LL; i*i <= n; ++i){
        if(n%i != 0) continue;
        const ll j = n/i;

        const int cur = max(cnt_digits(i), cnt_digits(j));

        if(ans > cur) ans = cur;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def calc_dist(y, z):
  l = []
  for each_y, each_z in zip(y, z):
    l.append((each_y - each_z)**2)
  return sum(l) ** 0.5

n, d = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
  for j in range(i+1, n):
    tmp = calc_dist(points[i], points[j])
    if tmp == int(tmp):
      ans += 1
      
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, t, s, k, num, cnt, a[N];
int main()
{
	ll i;
	cin >> n;
	if (n == 1) {
		cout << "YES" << endl;
		return 0;
	}
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		s += a[i];
	}
	t = n * (n + 1) / 2;
	if (s % t > 0) {
		cout << "NO" << endl;
		return 0;
	}
	k = s / t;
	num = k - (a[0] - a[n - 1]);
	if (num < 0 || num % n > 0) {
		cout << "NO" << endl;
		return 0;
	}
	cnt = num / n;
	for (i = 0; i < n - 1; i++) {
		num = k - (a[i + 1] - a[i]);
		if (num < 0 || num % n > 0) {
			cout << "NO" << endl;
			return 0;
		}
		cnt += num / n;
	}
	cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int x, y, n, cnt = 0, a , b;
    cin >> n >> x >> y;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        if(a >= x && b >= y) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
H_input = list()
ABS = float('inf')

for i in range(N):
    H_input.append(int(input()))
H_input.sort()

# print(H_input)
for i in range(N-K+1):
    # print(H_input[i:(i+K)])
    if ABS > (H_input[i+K-1] - H_input[i]):
        # print('Before:',ABS)
        ABS = H_input[i+K-1] - H_input[i]
        # print('After:',ABS)
print(ABS)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x+mo_num)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pnumr<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int sum;
struct node{
    int num,l,r,val;
};
pq<node>T;
bool operator<(const node&a,const node&b)
{
    return a.val<b.val;
}
int Ceil(int x,int y)
{
    return x/y+(x%y!=0);
}
vc<node>take;
int32_t main()
{
    IOS
    cin>>n>>m;
    fun(i)
    {
        int num,x,y;
        cin>>num>>x>>y;
        T.push({num,x,y,(m-num)*y+num*x});
        sum-=num*x;
    }
    ans=INF;
    int lnum,lx,ly,key=0,lval,least=0;
    while(!T.empty())
    {
        auto tp=T.top();
        T.pop();
        if(!key && sum+tp.val>=0) {
            key = 1;
            lnum=tp.num;
            lx=tp.l;
            ly=tp.r;
            lval=tp.val;
        }else if(!key)
        {
            sum+=tp.val;
            least+=m;
        }
        if(key) {
            int nn= least+min(Ceil(abs(sum),tp.l),Ceil(abs(sum)+tp.num*(tp.r-tp.l),tp.r));
            ans=min(ans,nn);
        }
        else take.pb(tp);
    }
    sum+=lval;
    fa(i,take)
    {
        int now=sum-i.val;
        int nn= least+min(Ceil(abs(now),i.l),Ceil(abs(now)+i.num*(i.r-i.l),i.r));
        ans=min(ans,nn);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11628
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }


        int[][] dp = new int[n][3];
        int ax = 0, bx = 1, cx = 2;
        dp[0][ax] = Math.max(b[0], c[0]);
        dp[0][bx] = Math.max(a[0], c[0]);
        dp[0][cx] = Math.max(a[0], b[0]);
        
        for (int i = 1; i < n; i++) {
            dp[i][ax] = a[i] + Math.max(dp[i-1][bx], dp[i-1][cx]);
            dp[i][bx] = b[i] + Math.max(dp[i-1][ax], dp[i-1][cx]);
            dp[i][cx] = c[i] + Math.max(dp[i-1][ax], dp[i-1][bx]);
        }
        
        int max = Math.max(dp[n-1][ax], dp[n-1][bx]);
        max = Math.max(max, dp[n-1][cx]);
        System.out.println(max);
    }
}



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



int main()
{
    string S;
    cin >> S;

    if( S == "SUN")
        cout << 7 << endl;
    else if ( S == "MON")
        cout << 6 << endl;
    else if (S == "TUE")
        cout << 5 << endl;
    else if (S == "WED")
        cout << 4 << endl;
    else if (S == "THU")
        cout << 3 << endl;
    else if (S == "FRI")
        cout << 2 << endl;
    else if (S == "SAT")
        cout << 1 << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb push_back
#define mp make_pair
#define M 10e9+7
int main(){
    ll t=1;
    while(t--){
    string s;
    cin>>s;
    set<char>st;
    for(ll i=0;i<s.size();i++){
        st.insert(s[i]);
    }
    if(st.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}}

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

using namespace std;

// [l, r)
int cnt_w(vector<int> &csum, int l, int r) { return csum[r] - csum[l]; }
int cnt_e(vector<int> &csum, int l, int r) {
  return (r - l) - (csum[r] - csum[l]);
}

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;

  vector<int> csum(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    csum[i] = csum[i - 1];
    if (s[i - 1] == 'W') {
      csum[i]++;
    }
  }

  int ans;
  for (int i = 0; i < n; ++i) {
    int cnt = cnt_w(csum, 0, i) + cnt_e(csum, i + 1, n);
    if (i == 0 || ans > cnt) {
      ans = cnt;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N, D; cin >> N >> D;
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= D * D) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
def calc_range(x, rate):
    return -(-x//rate), -(-(x+1)//rate)

a,b = list(map(int, input().split()))
a_min, a_max = calc_range(a, 0.08)
b_min, b_max = calc_range(b, 0.10)
if b_max <= a_min or a_max <= b_min:
    print(-1)
elif a_min <= b_min:
    print(int(b_min))
elif b_min < a_min:
    print(int(a_min))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define MOD2 1000000009
#define endl "\n"
#define pii pair <int, int>
#define pll pair <ll, ll>
#define F first
#define S second



int main()
{   
    IOS;
        #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
        #endif

    
    int n;
    cin >> n;
    std::vector<pii> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].F >> v[i].S;
    }
    int cnt = 0;
    if(v[0].F == v[0].S) 
        cnt++;
    for(int i = 1; i < n; i++) {
        if(v[i].F == v[i].S) {
            cnt++;
        }
        else 
            cnt = 0;
        if(cnt == 3) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    

return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[110000];

long long dp[110000];

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

    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

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

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    int n ; cin >> n ;
    int k ; cin >> k ;

    int ans = 0 ;
    while ( n-- )
    {
        int temp ; cin >> temp ;

        if ( temp >= k ) ans ++ ;
    }

    cout << ans ; line
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        s=input()
        if s[-1]!="s":
            print(s+"s")
        else:
            print(s+"es")
        







    
except EOFError as e:
    print(e)


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

struct Problem {

    UL D[15][15];
    UL dp[1 << 15][15];

    void Solve() {
        UL N, M; scanf("%d%d", &N, &M);
        rep(i, N) rep(j, N) D[i][j] = 1000000;
        rep(i, M) {
            UL u, v, d; scanf("%d%d%d", &u, &v, &d);
            D[u][v] = d;
        }
        rep(i, 1 << N) rep(j, N) dp[i][j] = 1000000;
        dp[0][0] = 0;
        rep(i, 1 << N) {
            rep(j, N) {
                rep(k, N) {
                    if (i & 1 << k) continue;
                    dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + D[j][k]);
                }
            }
        }
        if (dp[(1 << N) - 1][0] >= 1000000) printf("-1\n");
        else printf("%d\n", dp[(1 << N) - 1][0]);
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}



Measured memory_bytes: 4560
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])puts("Bad");
	else puts("Good");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    if(c >= a && c <= b){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
int _gap;char r(char g){return(g-'a'+_gap)%26+'a';}int main(){std::string s;while(std::getline(std::cin,s)){char b[81],*p,*c;c=b;strcpy(b,s.c_str());int gap=0;do{p=strtok(c," .\n");if(p!=NULL){int l=strlen(p);if(l>=3){_gap='t'-p[0];if(r(p[1])=='h'){if(l==3){if(r(p[2])=='e'){gap=_gap;}}else if(l==4){if(r(p[2])=='i'&&r(p[3])=='s'||r(p[2])=='a'&&r(p[3])=='t'){gap=_gap;break;}}}}}c=NULL;}while(p!=NULL);for(std::string::iterator it=s.begin();it!=s.end();++it){if(*it!=' '&&*it!='.'&&*it!='\n'){std::cout<<static_cast<char>((*it+gap-'a')%26+'a');}else{std::cout<<*it;}}puts("");}}

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

int main(){
    int N;
    cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    rep(i, N-1) cin >> C[i] >> S[i] >> F[i];

    rep(i, N) {
        int t = 0;
        for (int j=i; j<N-1; j++) {
            if (t < S[j]) t = S[j];
            else if (t%F[j] == 0);
            else t = t + F[j] - t%F[j];
            t += C[j];
        }
        cout << t << endl;
    }
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

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

const int L = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = (1LL << 61);

int n;
vector <int> a;

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

    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int mn = a[0];
    int ans = 1;
    for (int i = 1; i < n; ++i) {
        if (a[i] < mn) {
            ++ans;
            mn = a[i];
        }
    }
    cout << ans;

    return 0;
}
/// ACTUAL CODE STARTS HERE:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)

int n,l;
vector<pii> ants;

void solve(){
	for(int t=1;;t++){
		REP(i, n){
			ants[i].first += ants[i].second;
//			cout << ants[i].first << " ";
		}

		int inner = 0;
		REP(i, n){
			if(0 <= ants[i].first && ants[i].first < l) inner++;
			for(int j=i+1;j<n;j++)
				if(ants[i].first == ants[j].first) swap(ants[i].second, ants[j].second);
		}
		if(!inner){
			REP(i, n){
				if(-1 == ants[i].first){
					cout << t << " " << i+1 << endl;
					return;
				}
			}
			REP(i, n){
				if(l == ants[i].first){
					cout << t << " " << i+1 << endl;
					return;
				}
			}
		}
	}
}

main(){
	int i,j;
	while(cin >> n >> l, n){
		l --;
		ants.clear();
		REP(i, n){
			int p;char c;
			cin >> c >> p;
			ants.push_back(pii(p-1, (c=='L'?-1:1)));
		}
		solve();
	}
	return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define INF 1e9
#define MOD 1e9+7

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

//library----------------------------------------------



int main() {
    CIN(N,R);
    printf("%d\n",N<10?R+(10-N)*100:R);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
const int N=3010,mod=998244353;
ll dp[N][N];
int a[N];
int qmi(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
int main()
{
	int n,s;
	cin>>n>>s;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	dp[0][0]=qmi(2,n);
	int inv2=qmi(2,mod-2);
	for(int i=1;i<=n;i++)
	for(int j=0;j<=s;j++)
	{
		if(j>=a[i])
		dp[i][j]=1ll*dp[i-1][j-a[i]]*inv2%mod;
		dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
	}
	printf("%lld\n",dp[n][s]);
	return 0;
 } 

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

ans = 0

dic = dict()
for i in A:
    if i not in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
#print(dic)

for j in dic.values():
    if j >= 2:
        ans += (j*(j-1))//2

    #print(ans)

for k in A:
    yo = dic[k]
    if yo >= 3:
        ans_k = ans - (yo*(yo-1))//2 + ((yo-1)*(yo-2))//2
    elif yo == 2:
        ans_k = ans -(yo*(yo-1))//2
    else:
        ans_k = ans
        pass
    print(ans_k)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> x >> y;
       if(x==y){
           Cout(0);
           return 0;
       }
       if(x<0 && y==0){
           cmp=x*-1;
           Cout(cmp);
           return 0;
       }
       if(x>0 && y==0){
           Cout(x+1);
           return 0;
       }
       if(x>=0 && y>=0){
           if(x<=y){
           Cout(Abs(x,y));
           }
           else{
               Cout(Abs(x,y)+2);
           }
       }
       else if(x>=0 && y<0){
           cmp=y*-1;
           Cout(Abs(x,cmp)+1);
       }
       else if(x<0 && y>=0){
           //if(x*-1<=y){
           cmp=x*-1;
           Cout(Abs(cmp,y)+1);
           //}
           //else{
               
           //}
       }
       else{
           if(x*-1<=y*-1){
           cmp=x*-1;
           cmpp=y*-1;
           Cout(Abs(cmp,cmpp)+2);
           }
           else{
             cmp=x*-1;
             cmpp=y*-1;
             Cout(Abs(cmp,cmpp));
           }
       }
return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        Console.WriteLine(A.Count(a => a % 2 == 1) % 2 == 0 ? "YES" : "NO");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 24540
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

struct UnionFind
{
    std::vector<int> par; // parent node
    std::vector<int> rank; // tree height
    
    UnionFind(int n=1) // constructor
    {
        init(n);
    }

    void init(int n=1) // initialize
    {
        par.resize(n);rank.resize(n);
        // All vertices are root and height of 0 in the beginning.
        for(int i=0; i<n; ++i) par[i]=i, rank[i]=0; 
    }

    int root(int x)
    {
        if(par[x]==x)
        {
            return x;
        }
        else
        {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool isSame(int x, int y) // judging of whether x and y belong to same group.
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y) // merge the group to which x belongs and the group to which group y belongs. 
    {                        // merge the group of y into the group of x. x <--- y
        x = root(x); y= root(y);
        if(x==y) return false;
        if(rank[x]<rank[y]) swap(x,y);
        if(rank[x]==rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main()
{
    int n,m;
    cin >> n >> m;
    UnionFind utree = UnionFind(n);
    int p[n]; bool is[n];
    for (int i=0; i<n; ++i)
    {
        int tmp;
        cin >> tmp; 
        p[i] = tmp - 1;
        if(i==p[i]) is[i] = true;
        else is[i] = false;
    }

    for (int i=0; i<m; ++i)
    {
        int x,y;
        cin >> x >> y;
        // cout << x << y << endl;
        utree.merge(x-1,y-1); 
    }

    int cnt = 0;
    for (int i=0; i<n; ++i)
    {
        if(!is[i])
        {
            if(utree.root(i) != utree.root(p[i])) ++cnt;
            // if(utree.par[i] != utree.par[p[i]]) ++cnt;
        }
    }

    cout << n - cnt << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, pair<ll, ll> > p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    vector<ll> F(N);

    ll count = 0;

    for(int i = 0; i < N; i++) {
        cin >> A[i];
        count += A[i];
    }

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

    if(count <= K) {
        cout << 0 << endl;
        return 0;
    }

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());

    vector<ll> X(N);

    for(int i = 0; i < N; i++) {
        X[i] = A[i] * F[i];
    }

    ll mx = *max_element(X.begin(), X.end());

    ll line = mx;

    count = 0;

    ll front = 0LL;
    ll back = mx;
    
    ll mid = (front + back) / 2LL;

    while(front < back) {
        ll c_c = 0;
        for(int i = 0; i < N; i++) {
            if(mid < X[i]) {
                ll c = (X[i] - mid) / F[i];
                if(c * F[i] != X[i] - mid) {
                    c++;
                }
                c_c += c;
            }
        }
        if(c_c <= K) {
            count = c_c;
            line = mid;
            back = mid;
        } else {
            front = mid + 1LL;
        }
        mid = (front + back) / 2LL;
    }

    for(int i = 0; i < N; i++) {
        if(line < X[i]) {
            ll c = (X[i] - line) / F[i];
            if(c * F[i] != X[i] - line) {
                c++;
            }
            A[i] -= c;
            X[i] = A[i] * F[i];
        }
    }

    K -= count;

    priority_queue<p> pq;

    for(int i = 0; i < N; i++) {
        pq.push(make_pair(X[i], make_pair(A[i], F[i])));
    }

    while(K) {
        K--;
        ll x = pq.top().first;
        ll a = pq.top().second.first;
        ll f = pq.top().second.second;
        pq.pop();
        a--;
        pq.push(make_pair(a * f, make_pair(a, f)));
    }

    cout << pq.top().first << endl;
}

Measured memory_bytes: 14184
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  ll count[N] = {};
  REP(i, Q) {
    ll a;
    cin >> a;
    a--;
    count[a]++;
  }
  ll l[N] = {}, r[N] = {};
  l[0] = count[0];
  r[N-1] = count[N-1];
  REP(i, N-1) l[i+1] = l[i] + count[i+1];
  for (int i = N-1; i >= 1; i--) r[i-1] = r[i] + count[i - 1];
  REP(i, N) {
    string ans;
    if (i == 0) {
      if (r[1] >= K) ans = "No";
      else ans = "Yes";
      cout << ans << '\n';
      continue;
    }
    if (i == N-1) {
      if (l[N-2] >= K) ans = "No";
      else ans = "Yes";
      cout << ans << '\n';
      continue;
    }
    if (l[i-1]+r[i+1] >= K) ans = "No";
    else ans = "Yes";
    cout << ans << '\n';
  }
  // REP(i, N) cout << l[i] << ' ';
  // cout << '\n';
  // REP(i, N) cout << r[i] << ' ';
  // cout << '\n';
}


Measured memory_bytes: 2944
r,c = list(map(int, input().split() ))
table = [[0 for i in range(c)] for j in range(r)];
rm = [0 for i in range(r)]
cm = [0 for i in range(c)]
for ri in range(r):
 table[ri] = list(map(int, input().split() ))
 rm[ri] = sum(table[ri])
for ci in range(c):
 for ri in range(r):
  cm[ci] = cm[ci] + table[ri][ci]
for ri in range(r):
 print(" ".join(map(str,table[ri])), end = "" )
 print(f" {rm[ri]}")
print(" ".join(map(str, cm)), end="")
print(f" {sum(cm)}")



Measured memory_bytes: 5740
/* By : rupesh282
 * link :https://atcoder.jp/contests/dp/tasks/dp_b 
 * */

#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;

int n , k;
vector<int>arr;
ll dp[MAX];

//this is memiozation using 1D dp

ll recur(int ind){
    if(ind == 1)return 0;
    else if(ind < 0)return INT_MAX;

    if(dp[ind]!=-1)return dp[ind];

    ll ans=INT_MAX;
    for(int i=1;i<=k;i++){
        if(ind - i > 0)
            ans = min(ans ,abs(arr[ind] - arr[ind - i]) + recur(ind-i));
    }
    return dp[ind] = ans;
}
                



void solve(){
    cin>>n>>k;
    memset(dp , -1 , sizeof(dp));
    arr.resize(n+1);
    for(int i=1;i<=n;i++)cin>>arr[i];

    //for(int i=2;i<=n;i++)dp[i] = INT_MAX;

    cout<<(recur(n))<<endl;

    //bottomup
  //for(int i=1;i<=n;i++){
  //    for(int j=1;j<=k;j++){
  //        if(i-j > 0)
  //            dp[i] = min(dp[i]  , abs(arr[i] - arr[i - j]) + dp[i-j]);
  //    }
  //}
  //cout<<(dp[n])<<endl;
    return;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

typedef long long ll;

const int MAX_N = 1e2+10, MAX_V = 1e3+10;
const ll MAX_W = 1e9+10;
const int INF = std::numeric_limits<int>::max();

struct Item
{
	int v;
	ll w;
};

ll dp[MAX_N][MAX_N * MAX_V];
int N;
ll W;
Item items[MAX_N];

void solve() {
	fill(dp[0], dp[0] + MAX_N * MAX_V, INF);
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		Item item = items[i];
		for (int j = 0; j < MAX_N * MAX_V; ++j) {
			if (j < item.v) {
				dp[i+1][j] = dp[i][j];
			} else {
				dp[i+1][j] = min(dp[i][j], dp[i][j-item.v]+item.w);
			}
		}
	}
}

int main(int argc, char const *argv[])
{
	cin >> N >> W;
	for (int i = 0; i < N; ++i) {
		cin >> items[i].w >> items[i].v;
	}

	solve();

	int ans = 0;
	for (int i = 0; i < MAX_N * MAX_V; ++i) {
		if (dp[N][i] <= W) ans = i;
	}

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

Measured memory_bytes: 88320
#n=int(input())
h,n=map(int,input().split())
#a=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(n)]
#l=[list(input().split()) for i in range(n)]


        
ldp=[[0 for j in range(h)]for i in range(n)]
for i in range(n):
    for j in range(h):
        if i==0:
            ldp[i][j]=-(-(j+1)//l[i][0])*l[i][1]
        else:
            if j>=l[i][0]:
                ldp[i][j]=min(ldp[i-1][j],ldp[i][j-l[i][0]]+l[i][1])
            else:
                ldp[i][j]=min(ldp[i-1][j],l[i][1])
print(ldp[-1][-1])


Measured memory_bytes: 125504
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>E[200000];

ll n,K;
ll ans=1;
void dfs(int v,int p,int d,int cnt){
	if(d>=2)(ans*=(K-cnt-2))%=MOD;
	else if(d>=1)(ans*=(K-cnt-1))%=MOD;
	else (ans*=(K-cnt))%=MOD;
	int k=0;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,d+1,k);
		k++;
	}
}

int main(){
	cin>>n>>K;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	dfs(0,-1,0,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 12800
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<vector<ll>> edge;

vector<ll> color;
bool j=false;


ll dfs(ll w,ll p){
    ll cntw=0,cntb=0;
    for(auto &I:edge[w]){
        if(I==p){continue;}
        ll ret=dfs(I,w);
        if(ret==1){cntb++;}
        else{cntw++;}
    }
    if(cntw+cntb==0){return color[w]=0;}
    if(p==-1 && cntw==0){j=true; return color[w]=1;}
    if(cntw==0){return color[w]=0;}
    if(cntw>=2){j=true; return color[w]=1;}
    return color[w]=1;
}



int main(){
    cin>>n;
    edge.resize(n);
    color.resize(n,-1);
    for(int i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll mx=0;
    for(auto &I:edge){mx=max(mx,(ll)I.size());}
    if(mx<=2){cout<<(n&1?"First":"Second")<<endl; return 0;}
    for(int i=0;i<n;i++){
        if(edge[i].size()>=3){dfs(i,-1); break;}
    }
    cout<<(j?"First":"Second")<<endl;
    
    
    return 0;
}


Measured memory_bytes: 7168
#include<stdio.h>

#define N 100

int main(){
  int m[N][N];
  int n, i, j, u, k, v;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++) m[i][j] = 0;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d", &v);
	v--;
	m[u][v] = 1;
    }
  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      if(j) printf(" ");
      printf("%d", m[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2112
import sys
input = sys.stdin.readline

S = input()

d = {}

for c in S:
    if c in d:
        if d[c] > 1:
            #print(d)
            print("No")
            exit()
        d[c] += 1
    else:
        d[c] = 1

#print(d)
if 3 < len(d):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 38384
from bisect import bisect_left, bisect, bisect_right
a, b, q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(a)] + [INF]
T = [-INF] + [int(input()) for _ in range(b)] + [INF]
start = [int(input()) for _ in range(q)]

for now_start in start:
    s_id = bisect_left(S, now_start)
    t_id = bisect_left(T, now_start)
    dist1 = abs(now_start - min(S[s_id - 1], T[t_id - 1]))
    dist2 = abs(now_start - max(S[s_id], T[t_id]))
    if max(S[s_id - 1], T[t_id - 1]) == S[s_id - 1]:
        dist3 = abs(now_start - S[s_id - 1]) + abs(T[t_id] - S[s_id - 1])
    elif max(S[s_id - 1], T[t_id - 1]) == T[t_id - 1]:
        dist3 = abs(now_start - T[t_id - 1]) + abs(S[s_id] - T[t_id - 1])
    if min(S[s_id], T[t_id]) == S[s_id]:
        dist4 = abs(now_start - S[s_id]) + abs(T[t_id - 1] - S[s_id])
    elif min(S[s_id], T[t_id]) == T[t_id]:
        dist4 = abs(now_start - T[t_id]) + abs(S[s_id - 1] - T[t_id])
    print(min(dist1, dist2, dist3, dist4))

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n;
ll h[100100];
ll Dp[100100];

int main()
{
  cin>>n;
  
  for(ll i=0;i<n;i++)	scanf("%I64d",h+i);
    
  Dp[n-1] = 0;
  Dp[n-2] = abs(h[n-2]-h[n-1]);
  
  for(ll i=n-3;i>=0;i--)	Dp[i] = min( abs(h[i]-h[i+1]) + Dp[i+1] , abs(h[i]-h[i+2]) + Dp[i+2] );
  
  cout<<Dp[0];
  
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val s = readLine()!!
    val cs = s.contains("S")
    val cn = s.contains("N")
    val cw = s.contains("W")
    val ce = s.contains("E")
    println(if ((cs && cn || !cs && !cn) && (cw && ce || !cw && !ce)) "Yes" else "No")
}


Measured memory_bytes: 35868
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int X;
  cin >> X;
  ll p=0, t=0;
  for(int i=1; p<X; i++) {
    p += i;
    t++;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

e = (sum(p[0:K])+K) / 2
max_e = e
for i in range(1, N-K+1):
    e += -(p[i-1]+1)/2 + (p[i+K-1]+1)/2
    max_e = max(max_e, e)
    
print(max_e)

Measured memory_bytes: 99052
#Coding:Utf-8

N=int(input())
T,A=list(map(int, input().split()))
H=list(map(int, input().split()))


for i in range(N):
    if i==0:
        temp=abs(A-(T-H[i]*0.006))
        point=i+1
    else:
        if temp>abs(A-(T-H[i]*0.006)):
            temp=abs(A-(T-H[i]*0.006))
            point=i+1

print(point)

Measured memory_bytes: 3064
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

from collections import Counter
cD = Counter(D)
cT = Counter(T)

ans = 'YES'
for k in cT:
    if (k not in cD.keys()) or (cT[k] > cD[k]):
        ans = 'NO'
        break
print(ans)

Measured memory_bytes: 56800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x, n; cin >> x >> n;
    set<int> p;
    rep(i,n){
        int a; cin >> a;
        p.insert(a);
    }
    int m = 1001001001;
    int ans = -1;
    for(int i = 0; i <= 101; i++){
        if(p.count(i)) continue;
        int tmp = abs(i - x);
        if(tmp < m){
            m = tmp;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N], rem[N], ans[N];
vector<int> g[N];
multiset<int> s;

void dfs(int u, int p=0, int d = 1){
	auto it = s.lower_bound(a[u]);
	if(it != s.end()){
		rem[u] = *it;
		s.erase(it);
	}
	s.insert(a[u]);
	ans[u] = s.size();
	for(auto i: g[u]){
		if(i == p)	continue;
		dfs(i, u, d+1);
	}
	it = s.lower_bound(a[u]);
	s.erase(it);
	if(rem[u] != 0)
		s.insert(rem[u]);
}

signed main() {
	IOS;
	int n;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];	
	for(int i = 1; i <= n-1; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	for(int i = 1; i <= n; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 33572
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll x,ans=0;
	cin >> x;
	for(ll b=1;b<=sqrt(x);++b){
		for(ll p=2;p<=10;++p){
			ll tmp=pow(b,p);
			if(tmp<=x) ans=max(ans,tmp);
		}
	}
	cout << ans << endl;
    return 0;
}


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

int main() {
  string s; cin >> s;
  int q; cin >> q;
  bool check = true;
  string r = "", l = "";
  for (int i = 0; i < q; i ++) {
    int t; cin >> t;
    if (t == 1) {
      check = !check;
    } else {
      int f; cin >> f;
      string c; cin >> c;
      if ((f == 1 && check) || (f == 2 && !check)) {
        r += c;
      } else {
        l += c;
      }
    }
  }

  reverse(all(r));
  s = r + s + l;

  if (!check) {
    reverse(all(s));
  }

  cout << s << endl;
}


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

int main(){
  int n,k,q,a;
  cin>>n>>k>>q;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    p.at(i)=k;
  }
  for(int i=0;i<q;i++){
    cin>>a;
    p.at(a-1)+=1;
  }
  for(int i=0;i<n;i++){
    if(p.at(i)-q<=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024