solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
def fun(ls,n): print(3*n) for i in range(0,n,2): index=i+1 print(1,index,index+1) print(2,index,index+1) print(1,index,index+1) print(1,index,index+1) print(2,index,index+1) print(1,index,index+1) T = int(input()) for _ in range(T): n=int(input()) ls= list(map(int, input().split())) fun(ls,n) # Concept # let num be a,b # apply 1 a+b,b # apply 2 a+b,-a # apply 1 b,-a # apply 1 -a+b,-a # apply 2 -a+b,-b # apply 1 -a,-b # 6 operation for 2 num = 3 operation for one number sototal 3*n operation
8
PYTHON3
#include<bits/stdc++.h> #define ll long long using namespace std; void solve(){ ll a[1005], n, i, j; cin >> n ; for ( i = 1; i <= n; i ++ ){ cin >> a[i]; } cout << n * 3 << "\n"; for ( i = 1; i <= n ; i ++ ){ if ( i % 2 == 1 ){ cout << "2 " << i << " " << i + 1 << "\n"; cout << "1 " << i << " " << i + 1 << "\n"; cout << "1 " << i << " " << i + 1 << "\n"; cout << "2 " << i << " " << i + 1 << "\n"; cout << "1 " << i << " " << i + 1 << "\n"; cout << "1 " << i << " " << i + 1 << "\n"; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; while(t--) solve(); }
8
CPP
#include<bits/stdc++.h> using namespace std; #define ll long long #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define vll vector<ll> #define endl "\n" #define tab "\t" #define mod 100000000 int main() { fast; ll t; cin>>t; while(t--) { ll n,i,f=1; cin>>n; ll a[n]; for(i=0;i<n;i++) cin>>a[i]; cout<<3*n<<endl; for(i=0;i<n;i+=2) { f=6; while(f--){ f&1 ? cout<<2 : cout<<1; cout<<" "<<i+1<<" "<<i+2<<endl; } } } }
8
CPP
from sys import stdin from collections import defaultdict, deque, Counter from math import floor, ceil, log, inf, sqrt from heapq import * from functools import lru_cache import itertools from bisect import bisect_left, bisect_right T = int(stdin.readline()) for t in range(T): N = int(stdin.readline()) nums = [int(x) for x in stdin.readline().split()] print((N//2)*6) for i in range(0,N,2): print("1 {} {}".format(i+1,i+2)) print("2 {} {}".format(i+1,i+2)) print("1 {} {}".format(i+1,i+2)) print("1 {} {}".format(i+1,i+2)) print("2 {} {}".format(i+1,i+2)) print("1 {} {}".format(i+1,i+2))
8
PYTHON3
from sys import stdin,stdout import math, bisect, heapq from collections import Counter, deque, defaultdict L = lambda: list(map(int, stdin.readline().strip().split())) I = lambda: int(stdin.readline().strip()) S = lambda: stdin.readline().strip() C = lambda: stdin.readline().strip().split() def pr(a): return("".join(list(map(str, a)))) #_________________________________________________# def solve(): n = I() a = L() print(3*n) for i in range(1,n+1,2): print(1,i,i+1) print(2,i,i+1) print(1,i,i+1) print(2,i,i+1) print(1,i,i+1) print(2,i,i+1) for _ in range(I()): solve()
8
PYTHON3
for tc in range(int(input())): n = int(input()) arr = list(map(int,input().split())) print(3*n) for i in range(1,n,2): print(1,i,i+1) print(2,i,i+1) print(2,i,i+1) print(1,i,i+1) print(2,i,i+1) print(2,i,i+1)
8
PYTHON3
#include<bits/stdc++.h> #define rep(i,st,en) for(int i=st;i<=en;i++) using namespace std; typedef long long ll; int t,x,y,i,n; int main() { scanf("%d",&t); while(t--) { scanf("%d",&n); rep(i,1,n)scanf("%d",&x); printf("%d\n",3*n); rep(i,1,n/2) { x=2*i-1; y=2*i; printf("2 %d %d\n",x,y); printf("2 %d %d\n",x,y); printf("1 %d %d\n",x,y); printf("2 %d %d\n",x,y); printf("2 %d %d\n",x,y); printf("1 %d %d\n",x,y); } //TODO } return 0; }
8
CPP
q=int(input()) for i in range(q): w=int(input()) e=input() print(w*3) for j in range(w//2): print(*[2,2*j+1,2*j+2],sep=' ') print(*[1,2*j+1,2*j+2],sep=' ') print(*[2,2*j+1,2*j+2],sep=' ') print(*[1,2*j+1,2*j+2],sep=' ') print(*[2,2*j+1,2*j+2],sep=' ') print(*[1,2*j+1,2*j+2],sep=' ')
8
PYTHON3
#pragma GCC optimize ("Ofast") #define _USE_MATH_DEFINES #include <bits/stdc++.h> #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define FORD(i, a, b) for (int i=(a); i>(b); i--) #define PPC(x) __builtin_popcount(x) #define MSB(x) (63 - __builtin_clzll(x)) #define SZ(x) ((int)(x).size()) #define HASK(S, x) (S.find(x) != S.end()) #define pb push_back #define ALL(x) (x).begin(), (x).end() #define ARG(x, i) (get<i>(x)) #define ithBit(m, i) ((m) >> (i) & 1) #define ft first #define sd second #define kw(a) ((a) * (a)) #ifdef DEBUG #include "debug.h" #else #define dbg(...) 0 #endif using namespace std; template <typename T1, typename T2> inline void remin(T1& a, T2 b) { a = min(a, (T1)b); } template <typename T1, typename T2> inline void remax(T1& a, T2 b) { a = max(a, (T1)b); } const int maxN = 1 << 18, maxL = 18; int T[maxN]; void solve() { int n; scanf ("%d", &n); FOR(i, 1, n+1) scanf ("%d", T+i); printf("%d\n", n * 3); for (int i=1; i<n; i+=2) FOR(s, 0, 3) printf("1 %d %d\n2 %d %d\n", i, i+1, i, i+1); } int main() { int t = 1; scanf ("%d", &t); FOR(tid, 1, t+1) { //printf("Case #%d: ", tid); solve(); } return 0; }
8
CPP
""" ai = ai + aj aj = aj - ai 1 ai + aj, aj 2 ai + aj, -ai 1 aj, -ai 2 aj, -ai-aj 1 -ai, -ai-aj 2 -ai, -aj """ def test(): n = int(input()) arr = list(map(int, input().split())) opts = int(n / 2 * 6) print(opts) for i in range(1, n + 1, 2): for _ in range(3): print(f'1 {i} {i + 1}') print(f'2 {i} {i + 1}') if __name__ == "__main__": num_cases = int(input()) for _ in range(0, num_cases): test()
8
PYTHON3
import sys,math,heapq from collections import defaultdict,deque input=sys.stdin.readline T=int(input()) for _ in range(T): n=int(input()) A=list(map(int,input().split())) ans=[] for i in range(n//2): x=i+1 y=n-i ans.append([2,x,y]) ans.append([1,x,y]) ans.append([2,x,y]) ans.append([2,x,y]) ans.append([1,x,y]) ans.append([2,x,y]) print(len(ans)) for v in ans: print(*v)
8
PYTHON3
#Fast I/O import sys,os import math # To enable the file I/O i the below 2 lines are uncommented. # read from in.txt if uncommented if os.path.exists('in.txt'): sys.stdin=open('in.txt','r') # will print on Console if file I/O is not activated #if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w') # inputs template from io import BytesIO, IOBase def main(): for _ in range(int(input())): n=int(input()) arr=list(MI()) print(3*n) for i in range(n//2): print(1,2*i+1,2*i+2) print(2,2*i+1,2*i+2) print(2,2*i+1,2*i+2) print(1,2*i+1,2*i+2) print(2,2*i+1,2*i+2) print(2,2*i+1,2*i+2) # Sample Inputs/Output # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") #for array of integers def MI():return (map(int,input().split())) # endregion #for fast output, always take string def outP(var): sys.stdout.write(str(var)+'\n') # end of any user-defined functions MOD=10**9+7 mod=998244353 # main functions for execution of the program. if __name__ == '__main__': #This doesn't works here but works wonders when submitted on CodeChef or CodeForces main()
8
PYTHON3
#------------------------template--------------------------# import os import sys from math import * from collections import * # from fractions import * # from functools import * # from heapq import * from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") ALPHA='abcdefghijklmnopqrstuvwxyz' M = 998244353 EPS = 1e-6 def Ceil(a,b): return a//b+int(a%b>0) def value():return tuple(map(int,input().split())) def array():return [int(i) for i in input().split()] def Int():return int(input()) def Str():return input() def arrayS():return [i for i in input().split()] #-------------------------code---------------------------# # vsInput() for _ in range(Int()): n = Int() ans = [] a = array() for i in range(0,n,2): ans.append((2,i + 1, i + 2)) ans.append((1,i + 1, i + 2)) ans.append((1,i + 1, i + 2)) ans.append((2,i + 1, i + 2)) ans.append((1,i + 1, i + 2)) ans.append((1,i + 1, i + 2)) # for t,i,j in ans: # i -= 1 # j -= 1 # if(t == 1): a[i] += a[j] # else: a[j] -= a[i] # print(a) print(len(ans)) for i in ans: print(*i)
8
PYTHON3
#include<bits/stdc++.h> using namespace std; #define int long long #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define ff first #define ss second #define mp make_pair #define pb push_back #define ppb pob_back #define all(x) x.begin(), x.end() int binpow(int a, int b); int binpow(int a, int b, int mod); int gcd(int a, int b); int lcm (int a, int b); int inversemod(int a, int mod); void subMain() { //main part of code int n; cin>>n; vi a(n); for(int i=0; i<n; i++) cin>>a[i]; cout<<(n/2)*6<<'\n'; for(int i=0, j=1; i<n-1, j<n; i+=2, j+=2) { for(int k=0; k<3; k++) { cout<<"1 "<<i+1<<' '<<j+1<<'\n'; cout<<"2 "<<i+1<<' '<<j+1<<'\n'; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; while(t--) { subMain(); } return 0; } int binpow(int a, int b) { int res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; } int binpow(int a, int b, int mod) { int res = 1; while (b > 0) { if (b & 1) res = (res * a)%mod; a = (a * a)%mod; b >>= 1; } return res%mod; } int gcd(int a, int b) { if(b==0) return a; return gcd(b,a%b); } int lcm (int a, int b) { return ((a / gcd(a, b)) * b); } int inversemod(int a, int mod) { return binpow(a, mod-2, mod); }
8
CPP
#include<bits/stdc++.h> #define ll long long using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; cout<<n*3<<endl; for(int i=0;i<n;i=i+2) { cout<<1<<" "<<i+1<<" "<<i+2<<endl; cout<<2<<" "<<i+1<<" "<<i+2<<endl; cout<<2<<" "<<i+1<<" "<<i+2<<endl; cout<<1<<" "<<i+1<<" "<<i+2<<endl; cout<<2<<" "<<i+1<<" "<<i+2<<endl; cout<<2<<" "<<i+1<<" "<<i+2<<endl; } } }
8
CPP
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define mp make_pair #define int long long int #define pii pair<int, int> #define rep(i, a, b) for (int i = a; i < b; i++) #define vi vector<int> #define mii unordered_map<int, int> #define MAX 2000002 #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcount(x) #define zrobits(x) __builtin_ctz(x) #define all(x) x.begin(), x.end() #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define w(x) \ int x; \ cin >> x; \ while (x--) #define bakchodi \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) vector<bool> primes(100006, true); int recpow(int base, int exp) { int result = 1; while (exp > 0) { if (exp & 1) result = ((int)result * base); base = ((int)base * base); exp >>= 1; } return result; } //Euler Totient Function for no of coprimes with n from 1 to n-1 /*int phi(int n) { int result = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { while (n % i == 0) n /= i; result -= result / i; } } if (n > 1) result -= result / n; return result; }*/ /*int modInverse(int n, int p) { return recpow(n, p - 2); } int nCrModPFermat(int n, int r) { if (r == 0) return 1; int fac[n + 1]; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % M; return (fac[n] * modInverse(fac[r], M) % M * modInverse(fac[n - r], M) % M) % M; }*/ void code() { int n; cin >> n; int a[n]; rep(i, 0, n) { cin >> a[i]; } cout << 3*n << "\n"; for (int i = 0; i < n; i += 2) { cout << 1 << " " << i + 1 << " " << i + 2 << "\n"; cout << 2 << " " << i + 1 << " " << i + 2 << "\n"; cout << 1 << " " << i + 1 << " " << i + 2 << "\n"; cout << 1 << " " << i + 1 << " " << i + 2 << "\n"; cout << 2 << " " << i + 1 << " " << i + 2 << "\n"; cout << 1 << " " << i + 1 << " " << i + 2 << "\n"; } } int32_t main() { bakchodi; int t; cin >> t; // t = 1; while (t--) { code(); } }
8
CPP
#include<bits/stdc++.h> using namespace std; #define CIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ll long long int #define pb push_back vector<ll>v1, v2 , v3; void fun(ll id ,ll i) { v1.pb(id); v2.pb(i); v3.pb(i+1); } int main() { CIN; ll a,i,T=1; cin>> T ; while(T--) { v1.clear(); v2.clear(); v3.clear(); cin >> a ; ll ara[a+3]; for( i = 1 ; i <= a ; i++) cin >> ara[i]; for( i = 1 ; i<= a ; i+=2) { if(ara[i]>ara[i+1]) { fun(1,i); fun(2,i); fun(1,i); fun(2,i); fun(1,i); fun(2,i); } else if(ara[i]==ara[i+1]) { fun(1,i); fun(2,i); fun(1,i); fun(1,i); fun(1,i); } else { fun(2,i); fun(1,i); fun(2,i); fun(1,i); fun(2,i); fun(1,i); } } cout<<v1.size()<<endl; for( i = 0 ; i < v1.size() ; i++) cout<<v1[i]<<" "<<v2[i]<<" "<<v3[i]<<endl; } return 0 ; }
8
CPP
import collections ''' 2 1 2 a b a b-a b, b-a b, -a ... -a, -b ''' if __name__ == '__main__': q = int(input()) ans_amount = [] ans_ops = [] for _ in range(q): n = int(input()) nums = list(map(int, input().split())) ans_amount += [n * 3] operations = [] for i in range(1, n+1, 2): operations += [[2, i, i + 1], [1, i, i + 1], [2, i, i + 1]] * 2 ans_ops.append(operations) for que in range(q): print(ans_amount[que]) for line in ans_ops[que]: print(' '.join(map(str, line)))
8
PYTHON3
//#pragma comment(linker, "/STACK:102400000,102400000") #include<bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll typedef pair<int,int>pii; #define ff first #define ss second #define debug(x) std:: cerr << #x << " = " << x << std::endl; const int maxn=2e5+10,inf=0x3f3f3f3f,mod=1000000007; const ll INF=0x3f3f3f3f3f3f3f3f; const double eps=1e-9; //#define DEBUG//#define lowbit(x) ((x) & -(x))//<<setiosflags(ios::fixed)<<setprecision(9) void read(){} template<typename T,typename... T2>inline void read(T &x,T2 &... oth) { x=0; int ch=getchar(),f=0; while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();} while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} if(f)x=-x; read(oth...); } int a[maxn]; void ope(int &x,int &y) { x+=y; x+=y; y-=x; x+=y; // y+=x; x+=y; y-=x; } void show(int x,int y) { printf("1 %d %d\n",x,y); printf("1 %d %d\n",x,y); printf("2 %d %d\n",x,y); printf("1 %d %d\n",x,y); // printf("1 %d %d\n",y,x); printf("1 %d %d\n",x,y); printf("2 %d %d\n",x,y); } signed main(signed argc, char const *argv[]) { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); #ifdef DEBUG freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif int t,n; scanf("%d",&t); // cin>>t; while(t--) { scanf("%d",&n); // cin>>n; for(int i=1;i<=n;i++) scanf("%d",&a[i]); // cin>>a[i]; printf("%d\n",3*n); for(int i=1;i<=n;i+=2) { show(i,i+1); // show(i,i+1); // ope(a[i],a[i+1]); // ope(a[i],a[i+1]); } // for(int i=1;i<=n;i++) // cerr<<a[i]<<' '; // cerr<<endl; } return 0; } /* * 2021-05-30-22.55.50 * C:\Users\dell\Desktop\C++\网赛\2021年5月30日Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)\B.cpp * */
8
CPP
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define loop(i,n) for(int i=0;i<n;i++) const int mod = 1e9 + 7; const int N = 2e2 + 4; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--){ int n; cin>>n; ll a[n]; loop(i,n)cin>>a[i]; cout<<3*n<<"\n"; loop(i,n/2){ cout<<1<<" "<<i+1<<" "<<n-i<<"\n"; cout<<2<<" "<<i+1<<" "<<n-i<<"\n"; cout<<1<<" "<<i+1<<" "<<n-i<<"\n"; cout<<2<<" "<<i+1<<" "<<n-i<<"\n"; cout<<1<<" "<<i+1<<" "<<n-i<<"\n"; cout<<2<<" "<<i+1<<" "<<n-i<<"\n"; } } }
8
CPP
n=int(input()) a=list(map(int,input().split())) c=[] d=0 c.append(a[0]) for i in range(1,n): y=a[i]-a[i-1] if y>0 and a[i]>max(c): c.append(a[i]) d+=1 elif y<0 and a[i]<min(c): c.append(a[i]) d+=1 print(d) #print(c)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) s = 0 max_a = a[0] min_a = a[0] for i in a: if i > max_a or i < min_a: s += 1 if i > max_a: max_a = i if i < min_a: min_a = i print(s)
7
PYTHON3
n=int(input()) nlist=[int(i) for i in input().split()] result=0 for i in range(n): if i==0: continue else: large=0 small=0 for j in range(i): if nlist[i]>nlist[j]: large+=1 elif nlist[i]<nlist[j]: small+=1 if (i!=0) and (large==i or small==i): result+=1 print(result)
7
PYTHON3
#include <bits/stdc++.h> int main() { int n, cnt = 0; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } int maxx = a[0]; int minn = a[0]; for (int i = 0; i < n; i++) { if (a[i] > maxx) { maxx = a[i]; cnt++; } if (a[i] < minn) { minn = a[i]; cnt++; } } printf("%d\n", cnt); return 0; }
7
CPP
n = int(input()) s = [int(i) for i in input().split()] c = s[0] d = s[0] r = 0 for i in range(1,n): if s[i]>c: c = s[i] r+=1 elif s[i]<d: d = s[i] r+=1 print(r)
7
PYTHON3
x=int(input()) y=list(map(int,input().split())) h=y[0] l=y[0] f=0 for n in range(1,x): if y[n]>h: h=y[n] f=f+1 elif y[n]<l: l=y[n] f=f+1 else: f=f print(f)
7
PYTHON3
n=int(input()) line=input().split() nums=[] for i in range(n): nums.append(int(line[i])) i=1 sums=0 while i <n: if nums[i]<min(nums[:i]) or nums[i]>max(nums[:i]): sums+=1 i+=1 else: i+=1 print(sums)
7
PYTHON3
n = int(input()) score = [int(x) for x in input().split()] worst = score[0] best = score[0] count = 0 for i in range(1, n): if(score[i] > best): count += 1 best = score[i] elif(score[i] < worst): count += 1 worst = score[i] print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) maxx=l[0] minn=l[0] ans=0 for i in range(1,n): if l[i]> maxx: maxx=l[i] ans+=1 elif l[i]<minn: minn=l[i] ans+=1 print(ans)
7
PYTHON3
n = int(input()) h = list(map(int, input().split())) if n == 1: print(0) quit() if h[0] == h[1]: a = 0 else: a = 1 b = max(h[0], h[1]) w = min(h[0], h[1]) for i in range(2, n): if h[i] > b: a += 1 b = h[i] continue if h[i] < w: a += 1 w = h[i] print(a)
7
PYTHON3
n=int(input()) lis=list(int(i) for i in input().split()) min_n,max_n=lis[0],lis[0] count=0 for i in lis: if i>max_n: count+=1 max_n=i if i<min_n: count+=1 min_n=i print(count)
7
PYTHON3
n = int(input()) l = [int(x) for x in input().split()] s = 0 for i in range(1,n): if l[i] > max(l[:i]) or l[i] < min(l[:i]): s += 1 print(s)
7
PYTHON3
n = int(input()) scores = list(map(int, input().split())) minscore = scores[0] maxscore = minscore ret = 0 for i in range(1, n): if scores[i] > maxscore: ret += 1 maxscore = scores[i] elif scores[i] < minscore: ret += 1 minscore = scores[i] print(ret)
7
PYTHON3
n = int(input()) scores=[int(i) for i in input().split()] min=scores[0] max=scores[0] cont=0 for i in range(1, n): if scores[i] > max: max = scores[i] cont+=1 if scores[i] < min: min = scores[i] cont+=1 print(cont)
7
PYTHON3
n = int(input()) listT = list(map(int, input().split())) i = k = 1 ma = mi = listT[0] while i < n: if listT[i] > ma: ma = listT[i] k += 1 if listT[i] < mi: mi = listT[i] k += 1 i += 1 print(k - 1)
7
PYTHON3
n = int(input()) l = [] count = 0 point = [int(x) for x in input().split()] l.append(point[0]) for i in range(1,n): if point[i] > max(l) or point[i] < min(l): count += 1 l.append(point[i]) print(count)
7
PYTHON3
n = int(input()) arr = list(map(int, input().split())) maxi = arr[0] mini = arr[0] count = 0 for i in arr: if i > maxi: count += 1 maxi = i elif i < mini: count += 1 mini = i print(count)
7
PYTHON3
t = int(input()) points = list(map(int, input().split(' '))) minValue, maxValue = points[0], points[0] ans = 0 for i in range(1, len(points)): if maxValue < points[i]: maxValue = points[i] ans += 1 if points[i] < minValue: minValue = points[i] ans += 1 print(ans)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) ma=l[0] mi=l[0] c=0 for i in range(1,n): if(l[i]>ma): ma=l[i] c=c+1 if(l[i]<mi): mi=l[i] c=c+1 print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, maxscore, minscore; int main() { cin >> n; cin >> maxscore; minscore = maxscore; int ans = 0; for (int i = 1; i < n; i++) { int score; cin >> score; if (score > maxscore || score < minscore) { ans++; maxscore = max(maxscore, score); minscore = min(minscore, score); } } cout << ans << "\n"; return 0; }
7
CPP
n=int(input()) r=list(map(int,input().split())) ma,mi=r[0],r[0] ama=0 for i in range(1,n): if r[i]>ma or r[i]<mi: ama+=1 ma,mi=max(r[i],ma),min(r[i],mi) print(ama)
7
PYTHON3
n=int(input()) a=[int(x) for x in input().split()] max_a=a[0] min_a=a[0] k=0 for i in range(1,n): if a[i]>max_a: k+=1 max_a=a[i] if a[i]<min_a: k+=1 min_a=a[i] print(k)
7
PYTHON3
n = int(input()) answer = 0 a = list(map(int, input().split())) for i in range(n): try: if a[i] > max(a[:i]) or a[i] < min(a[:i]): answer += 1 except: continue print(answer)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) max=min=a[0] cnt=0 for i in range(1,n): if a[i]>max: cnt+=1 max=a[i] if a[i]<min: cnt+=1 min=a[i] print(cnt)
7
PYTHON3
x=int(input()) results=[int(i) for i in input().split()] mas=[results[0]] wow=0 for i in range(1,len(results)): if results[i]> max(mas): wow+=1 elif results[i]< min(mas): wow+=1 mas.append(results[i]) print(wow)
7
PYTHON3
num = int(input()) grades = list(map(int, input().split())) ming = 0 maxg = 0 amazing = 0 if len(grades) > 1: if grades[1] > grades[0]: maxg = grades[1] ming = grades[0] amazing += 1 del grades[1] del grades[0] elif grades[1] < grades[0]: ming = grades[1] maxg = grades[0] amazing += 1 del grades[1] del grades[0] else: ming = grades[0] maxg = grades[0] del grades[1] del grades[0] for x in range(len(grades)): if maxg < grades[x]: maxg = grades[x] amazing += 1 elif grades[x] < ming: ming = grades[x] amazing += 1 else: amazing = 0 print(amazing)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) b=[a[0]] amazing=0 for i in range (1,n): if a[i]>max(b) or a[i]<min(b): amazing+=1 b.append(a[i]) print(amazing)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) mi=l[0] ma=l[0] c=0 for i in range(1,n): if(l[i]>ma): c+=1 ma=l[i] if(l[i]<mi): c+=1 mi=l[i] print(c)
7
PYTHON3
n = int(input()) nums = [int(x) for x in input().split()] worst,best = nums[0],nums[0] ans = 0 for num in nums[1:]: if num < worst or num > best: ans += 1 worst = min(worst,num) best = max(best,num) print(ans)
7
PYTHON3
n = int(input()) lst = list(map(int,input().split())) amaze = 0 for i in range(len(lst)) : if (lst[i] == max(lst[:i+1]) or lst[i] == min(lst[:i+1])) and i != 0 and lst[i] != max(lst[:i]) and lst[i] != min(lst[:i]): amaze += 1 print(amaze)
7
PYTHON3
n=int(input()) x=list(map(int,input().split())) m1=x[0] m2=x[0] c=0 for i in range(1,n): if m1<x[i]: c+=1 m1=x[i] elif m2> x[i]: c+=1 m2=x[i] print(c)
7
PYTHON3
num = int(input()) line = input().split() count_num = 0 min_point = int(line[0]) max_point = int(line[0]) for i in range(num): point = int(line[i]) if point > max_point: count_num += 1 max_point = point elif point < min_point: count_num += 1 min_point = point print(count_num)
7
PYTHON3
e=input() l=list(map(int,input().split())) m=l[0] mi=l[0] c=0 for i in l[1:]: if(i>m and i>mi): c=c+1 m=i elif(i<mi and i<m): c=c+1 mi=i print(c)
7
PYTHON3
n=int(input()) a=[int(j) for j in input().split()] l=list([]) l.append(a[0]) jieguo=0 for i in range(1,n): if a[i]>int(max(l)) or a[i]<int(min(l)): l.append(a[i]) jieguo=jieguo+1 else: l.append(a[i]) print(jieguo)
7
PYTHON3
n = int(input()) a = list(map(int, input().split(' '))) ans=0 for i in range(1,n): k1=0 k2=0 for j in range(i): if a[j]<a[i]: k1+=1 elif a[j]>a[i]: k2+=1 if k1 == i or k2 == i: ans+=1 print(ans)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) m=l[0];s=l[0];a=0 for i in l[1:]: if i>m: a+=1 m=i if i<s: a+=1 s=i print(a)
7
PYTHON3
def funct(n,l): cnt=0 max=l[0] min=l[0] for i in range(n): if(l[i]>max): max=l[i] cnt+=1 if(l[i]<min): min=l[i] cnt+=1 return cnt n=int(input()) l=list(map(int,input().split())) print(funct(n,l))
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) c=0 ma=l[0] mi=l[0] for i in l: if(i>ma): ma=i c=c+1 elif(i<mi): mi=i c=c+1 print(c)
7
PYTHON3
t = int(input()) l = list(map(int,input().split())) maxi,mini,cnt = l[0],l[0],0 for i in range(1,len(l)): if l[i] < mini: mini = l[i] cnt += 1 elif l[i] > maxi: maxi = l[i] cnt += 1 print(cnt)
7
PYTHON3
a=int(input()) mas=[int(i) for i in input().split()] ch=0 first_mas=[mas[0]] for i in range(1, len(mas)): if mas[i]>max(first_mas): ch+=1 elif mas[i]<min(first_mas): ch+=1 first_mas.append(mas[i]) print(ch)
7
PYTHON3
n=int(input()) s=[int(i) for i in input().split()] k=0 a=s[0] b=s[0] for i in s[1:]: if i>a: a=i k+=1 if i<b: b=i k+=1 print(k)
7
PYTHON3
n = int(input()) an = [ int(x) for x in input().split(' ') ] max = an[0] min = an[0] count = 0 for x in an: if x > max: max = x count += 1 if x < min: min = x count += 1 print(count)
7
PYTHON3
inp = int(input()) max = 0 min = 0 listt = list(map(int,input().split())) max = listt[0] min = listt[0] res = 0 for i in range(inp): if listt[i] > max: max = listt[i] res = res +1 elif listt[i] < min: min = listt[i] res = res+1 print(res)
7
PYTHON3
n=eval(input()) x = list(map(int, input().split())) z=list() count=0 z.append(x[0]) for element in x: if element not in z: z.append(element) if element==min(z) or element==max(z): count=count+1 print(count)
7
PYTHON3
n=int(input());s=input().split();k=[];ans=0 k.append(int(s[0])) for i in range(1,n): if int(s[i])in k: k.append(int(s[i])) continue k.append(int(s[i])) if max(k)==int(s[i]) or min(k)==int(s[i]): ans+=1 print(ans)
7
PYTHON3
n = int(input()) l = list(map(int, input().split())) mmin = l[0] mmax = l[0] count = 0 for i in range(1, len(l)): if l[i] > mmax: count += 1 mmax = l[i] if l[i] < mmin: count += 1 mmin = l[i] print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int n, max1, i, min1, premax, premin, count = 0, a[100000]; cin >> n; cin >> a[1]; premin = a[1]; min1 = a[1]; premax = a[1]; max1 = a[1]; for (i = 2; i <= n; i++) { cin >> a[i]; min1 = min(a[i], min1); max1 = max(a[i], max1); if ((premax != max1) || (premin != min1)) { count++; } premax = max1; premin = min1; } cout << count; return 0; }
7
CPP
num = int(input()) st = input() balls = st.split() balls_min = balls[0] balls_max = balls[0] k = 0 for i in balls: if int(i) > int(balls_max): k += 1 balls_max = i elif int(i) < int(balls_min): k += 1 balls_min = i print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, a[1001], c, d, x = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; c = 0; d = 0; for (int j = (i - 1); j >= 1; j--) { if (a[i] < a[j]) c++; else if (a[i] > a[j]) d++; } if (c == (i - 1) || d == (i - 1)) x++; } x--; cout << x << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int t, arr[1001], ans = 0, x = 0, y = 0; cin >> t >> arr[0]; for (int i = 1; i < t; i++) { cin >> arr[i]; for (int j = 0; j < i; j++) { if (arr[j] < arr[i]) x = 1; else if (arr[j] > arr[i]) y = 1; else if (arr[j] == arr[i]) { y = 0; x = 0; j = i; } } if ((x == 1 && y == 0) || (x == 0 && y == 1)) ans++; x = 0; y = 0; } cout << ans << endl; return 0; }
7
CPP
# URL: http://codeforces.com/problemset/problem/155/A # ~ Basic Implementation Problem from typing import List, Tuple def parse_input() -> Tuple[int, List[int]]: n = int(input()) arr = [int(x) for x in input().split()] return n, arr def solve(n: int, arr: List[int]) -> int: best = arr[0] worst = arr[0] count = 0 for i in range(1, n): if arr[i] > best: best = arr[i] count += 1 if arr[i] < worst: worst = arr[i] count += 1 return count if __name__ == '__main__': n, arr = parse_input() print(solve(n, arr))
7
PYTHON3
n = int(input()) numbers = list(map(int, input().split())) maxi = mini = numbers[0] wow = 0 for i in numbers[1:]: if i < mini: wow+=1 mini = i if i > maxi: wow+=1 maxi = i print(wow)
7
PYTHON3
n, a, r = int(input()), [int(x) for x in input().split()], 0 for i in range(1,n): r += 1 if a[i]>max(a[:i]) or a[i]<min(a[:i]) else 0 print(r)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) x=l[:1] for i in l: n -=min(x)<=i<=max(x) x +=[i] print(n)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, m, mn, mx, c; int main() { cin >> n >> m; mx = mn = m; for (int i = 0; i < n - 1; i++) { cin >> m; if (mn < m) c++, mn = m; if (mx > m) c++, mx = m; } cout << c; return 0; }
7
CPP
n=int(input()) a=list(map(int,input().split())) minimum=a[0] maximum=a[0] c=0 for i in range(1,n): if(a[i]>a[i-1]): if(a[i]>maximum): c+=1 maximum=a[i] elif(a[i]<a[i-1]): if(a[i]<minimum): c+=1 minimum=a[i] print(c)
7
PYTHON3
n = int(input()) lst = list(map(int,input().split())) max_score = lst[0] min_score = lst[0] count = 0 for i in range(1,n): if lst[i] > max_score: max_score = lst[i] count += 1 if lst[i] < min_score: min_score = lst[i] count += 1 print(count)
7
PYTHON3
n=int(input()) k=[int(i) for i in input().split()] maxi,mini=k[0],k[0] cnt=0 for i in range(n): if k[i]>maxi: maxi=k[i] cnt+=1 if k[i]<mini: mini=k[i] cnt+=1 print(cnt)
7
PYTHON3
t=int(input()) a=list(map(int,input().split())) x=a[:1] for i in a: t-=min(x)<=i<=max(x) x+=[i] print(t)
7
PYTHON3
if __name__=="__main__": n=int(input()) count=0 numlist=list(map(int,input().split())) for i in range(1,n): if(numlist[i]<min(numlist[0:i]) or numlist[i]>max(numlist[0:i])): count=count+1 print(count)
7
PYTHON3
n=int(input()) score=list(map(int,input().split( ))) max=score[0] min=score[0] amazing=0 for i in range(1,len(score)): if score[i]<min or score[i]>max: amazing+=1 if score[i]<min: min=score[i] else: max=score[i] else: amazing=amazing print(amazing)
7
PYTHON3
n=int(input()) N = [int(num) for num in input().split(" ", n-1)] i=1 x=0 mi=N[0] ma=N[0] while(i<n): if(N[i]>ma): ma=N[i] x+=1 if(N[i]<mi): mi=N[i] x+=1 i+=1 print(x)
7
PYTHON3
# -*- coding: utf-8 -*- """ Created on Thu Jan 30 16:55:54 2020 @author: Zheng Jiajia """ n=int(input()) score=list(map(int,input().split())) # #print(score) #print (score[0]) amaze=0 best=score[0] worst=score[0] for i in range(1,n): if score[i]>best: best=score[i] amaze+=1 elif score[i]<worst: worst=score[i] amaze+=1 print (amaze)
7
PYTHON3
a=int(input()) b=[k for k in map(int,input().split())] c=[] i=1 u=0 while i<a: #dansnsn r=b[i] j=list(b[0:i]) c.extend(j) d=sorted(c) t=d[0] w=d[i-1] if t>r or w<r: u+=1 i+=1 c=[] print(u)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) max,min=l[0],l[0] sum=0 for i in range(1,n): if l[i]>max: max=l[i] sum+=1 if l[i]<min: min=l[i] sum+=1 print(sum)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) h=0 mn=a[0] mx=a[0] for i in range(1,n): if a[i]<mn: mn=a[i] h+=1 elif a[i]>mx: mx=a[i] h+=1 print(h)
7
PYTHON3
#include <bits/stdc++.h> int main(void) { int a[1000]; int n, i, min, max, cnt = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &a[i]); min = a[0]; max = a[0]; for (i = 1; i < n; i++) { if (a[i] > max) { cnt++; max = a[i]; } if (a[i] < min) { cnt++; min = a[i]; } } printf("%d", cnt); return 0; }
7
CPP
n = int(input()) a = [] a += map(int,input().split()) count = 0 for i in range(1,n): if a[i] > max(a[:i]) or a[i] < min(a[:i]): count += 1 print(count)
7
PYTHON3
judge = True if judge: from sys import stdin, stdout else: stdin = open('input.txt', 'r') stdout = open('output.txt', 'w') n = int(stdin.readline()) x = list(map(int, stdin.readline().split())) min = x[0] max = x[0] k = 0 for i in range(1, n): if x[i] < min: min = x[i] k += 1 if x[i] > max: max = x[i] k += 1 stdout.write(str(k)) stdin.close() stdout.close()
7
PYTHON3
input() x = list(map(int, input().split())) Max, Min, counter = x[0], x[0], 0 for i in x: if i > Max: Max = i counter += 1 elif i < Min: Min = i counter += 1 print(counter if len(x) > 1 else 0)
7
PYTHON3
n=int(input()) a=list(map(int,input().split(" "))) l=a[0] m=a[0] count=0 for i in range(1,len(a)): if a[i]>m: count+=1 m=a[i] elif a[i]<l: count+=1 l=a[i] print(count)
7
PYTHON3
n=int(input()) n1=list(map(int,input().split())) mi=n1[0] ma=n1[0] s=0 for i in range(n-1): if n1[i+1]<mi: mi=n1[i+1] s+=1 elif n1[i+1]>ma: ma=n1[i+1] s+=1 print(s)
7
PYTHON3
# holds the useless information n = int(input()) # creates and stores a list of all the scores scores = [int(s) for s in input().split()] # holds the number of amazing performances amazing = 0 for i in range(1, len(scores)): if scores[i] < min(scores[:i]) or scores[i] > max(scores[:i]): amazing += 1 print(amazing)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) maxi=l[0] mini=l[0] count=0 for i in range(1,n): if l[i]>maxi: count+=1 maxi=l[i] elif l[i]<mini: count+=1 mini=l[i] print(count)
7
PYTHON3
def solve(scores): smallest = largest = scores[0] amazing = 0 for score in scores[1:]: if(score < smallest): smallest = score amazing+=1 if(score > largest): largest = score amazing+=1 return amazing n = int(input()) scores = list(map(int,input().split(" "))) print(solve(scores))
7
PYTHON3
n = int(input()) a = list(map(int,input().split())); b =[]; count = 0 for i in range(1,n): for j in range(0,i): b.append(a[j]) if min(b)>a[i] or max(b)<a[i]: count+=1 b.clear() print(count)
7
PYTHON3
n = int(input()) lst = list(map(int, input().split())) mini = lst[0] maxi = lst[0] cnt = 0 for i in range(1, n): if lst[i] > maxi: maxi = lst[i] cnt += 1 elif lst[i] < mini: mini = lst[i] cnt += 1 print(cnt)
7
PYTHON3
n = int(input()) ln = input().split(" ") max = int(ln[0]) min = int(ln[0]) amazings = 0 for i in range(1,n): k = int(ln[i]) if k > max: amazings += 1 max = k elif k < min: amazings += 1 min = k print(str(amazings))
7
PYTHON3
import math n = int(input()) amaze = 0 arr = input().split() mx = int(arr[0]) mn = mx for ch in arr: a = int(ch) if a < mn: mn = a amaze += 1 if a > mx: mx = a amaze += 1 print(str(amaze))
7
PYTHON3
num = int(input()) scores = list(map(int,input().split())) count = 0 maxm = None minm = None for i in scores: if maxm is None and minm is None: maxm = scores[0] minm = scores[0] elif i > maxm: maxm = i count +=1 elif i < minm: minm = i count += 1 print(count)
7
PYTHON3