akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

int main()
{
	int N;
	int temp;
	std::cin >> N;
	std::string res = "No";
	temp = N;
	if (N % 7 == 0)
	{
		std::cout << "Yes" << std::endl;
		return 0;
	}
	while (temp>0)
	{
		if (temp % 4 == 0)
		{
			res = "Yes";
			break;
		}
		temp = temp - 7;
	}
	std::cout << res.c_str() << std::endl;
	return 0;
}

Measured memory_bytes: 256
<?php 
 $input = trim(fgets(STDIN));
 $array = explode(' ',$input);
 
if($array[0]>=0 && $array[2]>=0){
  echo $array[1]*$array[3];
}elseif($array[0]>=0 && $array[2]<=0 && $array[3]>=0){
  echo $array[1]*$array[3];
}elseif($array[1]<=0 && $array[3]<=0){
  echo $array[0]*$array[2];
}elseif($array[0]>=0 && $array[3]<=0){
  echo $array[0]*$array[3];
}elseif($array[1]<=0 && $array[2]>=0){
  echo $array[1]*$array[2];
}elseif($array[1]<=0 && $array[2]<=0 && $array[3]>=0){
  echo $array[0]*$array[2];
}elseif($array[2]>=0 && $array[0]<=0 && $array[1]>=0){
  echo $array[1]*$array[3];
}elseif($array[3]<=0 && $array[0]<=0 && $array[1]>=0){
  echo $array[0]*$array[2];
}else{
 if($array[0]*$array[2]>=$array[1]*$array[3]){
   echo $array[0]*$array[2];
 }else{
   echo $array[1]*$array[3];
 }
}
?>

Measured memory_bytes: 15832
mod=1000000007
n,k=map(int,input().split())
DP=[[[0]*(k+1) for _ in range(n+1)] for _ in range(n+1)]
DP[0][0][0]=1
for i in range(1,n+1):
    for j in range(n+1):
        for l in range(k+1):
            if l-2*j>=0:
                DP[i][j][l]=(2*j+1)*DP[i-1][j][l-2*j]
                if j!=n:
                    DP[i][j][l]+=(j+1)**2*DP[i-1][j+1][l-2*j]
                if j!=0:
                    DP[i][j][l]+=DP[i-1][j-1][l-2*j]
            DP[i][j][l]%=mod
print(DP[-1][0][-1])

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

const int maxn = 2e6;

long long n, m;
map <long long, char> used;
string s, t;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	cin >> s >> t;
	if(n == m) {
		if(s == t) cout << n;
		else cout << -1;
		return 0;
	}
	if(n % m == 0 || m % n == 0) {
		return cout << -1, 0;
	}
	long long p = n * m / __gcd(n, m);
	for(long long i = 1, cur = 1; i <= p; i = i + p / n, cur++){
		if(!used[i]) used[i] = s[cur - 1];
		else if(used[i] != s[cur - 1]) return cout << -1, 0;
	}
	for(long long i = 1, cur = 1; i <= p; i = i + p / m, cur++){
		if(!used[i]) used[i] = t[cur - 1];
		else if(used[i] != t[cur - 1]) return cout << -1, 0;
	}
	cout << p;
}




Measured memory_bytes: 10880
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    rep(i, N - 2) {
        if (S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
MOD=10**9+7
n,m=map(int,input().split())
xlist=list(map(int,input().split()))
ylist=list(map(int,input().split()))

x0,y0=xlist[0],ylist[0]
for i in range(n):
  xlist[i]-=x0
for i in range(m):
  ylist[i]-=y0
#print(xlist)
#print(ylist)

xsum=0
for i in range(1,n):
  xsum+=xlist[i]*i
  xsum-=xlist[i]*(n-i-1)
  xsum%=MOD

ysum=0
for i in range(1,m):
  ysum+=ylist[i]*i
  ysum-=ylist[i]*(m-i-1)
  ysum%=MOD
  
print((xsum*ysum)%MOD)

Measured memory_bytes: 18556
h,w=map(int,input().split())
A=[input() for i in range(h)]
LR=[]
for i in range(h):
  l=A[i].find("#")
  r=A[i].rfind("#")
  LR.append([l,r])
ans=0
for i in range(1,h):
  if LR[i-1][1]==LR[i][0]:
    ans+=1
print("Possible" if ans==h-1 else "Impossible")

Measured memory_bytes: 3064
#include<cstdio>
#include<deque>
using namespace std;
int n,a;
int main()
{
	scanf("%d",&n);
	deque<int> b;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(i&1)b.push_front(a);
		else b.push_back(a);
	}
	if(n&1)for(int i=n-1;i>=0;i--)printf("%d ",b[i]);
	else for(int i=0;i<n;i++)printf("%d ",b[i]);
	puts("");
	return 0;
}


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

int main() {
int D,N,A,B; 
cin >> D >> N;
B=1;


if(N==100){
    for(int i=0;i<=D;i++)
    
        B=100*B;
        A=101*B/100;
}else if(D==0){
    A=N;
}else if(D==1){
    A=N*100;
}else {
    A=N*10000;
}

cout << A << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int A, B, N;

int f(int x) {
  return (A * x) / B - A * (x / B);
}

signed main() {
  cin >> A >> B >> N;
  int ans = f(min(B - 1, N));
  cout << ans << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main(){
    ios::sync_with_stdio(0);
    for(int i=1;i<=3;++i){
        cin>>a[i];
    }
    sort(a+1,a+4,greater<int>());
    cout<<max(a[1]*10+a[2]+a[3],a[1]+a[2]*10+a[3])<<endl;
    return 0;
    }


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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<vector<long long>> shop(n,vector<long long>(10));
	vector<vector<long long>> point(n,vector<long long>(11));

	for(long long i=0;i<n;i++){
		for(long long j=0;j<10;j++){
			cin>>shop.at(i).at(j);
		}
	}

	for(long long i=0;i<n;i++){
		for(long long j=0;j<11;j++){
			cin>>point.at(i).at(j);
		}
	}

	long long ans=inf*-1;

	for(long long tmp=1;tmp<(1<<10);tmp++){
		bitset<10> bits=tmp;
		vector<long long> zyuhuku(n,0);
		long long pre=0;

		for(long long i=0;i<n;i++){
			for(long long j=0;j<10;j++){
				if(shop.at(i).at(j)==1 && bits.test(j)){
					zyuhuku.at(i)++;
				}
			}
		}

		for(long long i=0;i<n;i++){
			pre+=point.at(i).at(zyuhuku.at(i));
		}

		ans=max(ans,pre);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3648
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
s = [[0]*w for i in range(h)]
for i in range(h):
    count = 0
    for j in range(w):
        if (a[i][j]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                s[i][k]=count
            count = 0
    for k in range(w-1,w-count-1,-1):
        s[i][k]=count
    count = 0

t = [[0]*w for i in range(h)]
for i in range(w):
    count = 0
    for j in range(h):
        if (a[j][i]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                t[k][i]=count
            count = 0
    for k in range(h-1,h-count-1,-1):
        t[k][i]=count
    count = 0

ans = 0
for i in range(h):
    for j in range(w):
        if (s[i][j]!=0):
            if (s[i][j]+t[i][j]-1 > ans):
                ans = s[i][j]+t[i][j]-1
print(ans)

Measured memory_bytes: 247176
N, M = map(int, input().split())
ab = []
for _ in range(M):
    ab.append(tuple(map(int, input().split())))

G = [[] for _ in range(N + 1)]
for el in ab:
    a, b = el
    G[a].append(b)
    G[b].append(a)
#print(G)

for i in range(1, N + 1):
    print(len(G[i]))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <limits>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 200000000000000;
typedef long long ll;
double pi = 3.141592653589793;
//setprecision(20) <<

const int MOD = 1000000007;

long long gcd(long long a, long long b)
{
  if (a < b)
    swap(a, b);
  if (a % b == 0)
    return b;
  return gcd(a % b, b);
}

long long lcm(long long a, long long b)
{
  return a / gcd(a, b) * b;
}
long myPow(long long x, long long n, long long m = MOD)
{
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point
{
public:
  long long x;
  long long y;
  char S;
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll r;
  cin >> r;
  cout << r * r << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Bitter Alchemy
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ms[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, x;
  scanf("%d%d", &n, &x);

  int msum = 0, minm = INF;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ms[i]);
    msum += ms[i];
    if (minm > ms[i]) minm = ms[i];
  }

  int cnt = n + (x - msum) / minm;
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int a=stoi(s.substr(0,2)),b=stoi(s.substr(2,2));
	if(a==0 || b==0){
		if(a>12 || b>12 || (a==0 && b==0)) cout << "NA" << endl;
		else if(a>0 && a<=12) cout << "MMYY" << endl;
		else cout << "YYMM" << endl;
	}
	else if(a>12 && b>12) cout << "NA" << endl;
	else if(a<=12 && b<=12) cout << "AMBIGUOUS" << endl;
	else if(a<=12) cout << "MMYY" << endl;
	else cout << "YYMM" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
int main(){
    cin>>k>>a>>b;
    if(k<=a)return puts("1"),0; 
    else if(a<=b)return puts("-1"),0; 
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int y, n;
  cin >> y >> n;
  bool a[105] = {false};

  rep(i, 0, n) {
    int x;
    cin >> x;
    a[x] = true;
  }

  int ans = 0;

  rep(i, 1, 102) {
    if (a[i] == false) {
      if (abs(max(ans, y) - min(ans, y)) > abs(max(i, y) - min(i, y))) ans = i;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
S = input()
N = len(S)
if S == S[::-1]:
    tmp = S[:(N - 1) // 2]
    if tmp == tmp[::-1]:
        t = S[(N + 3) // 2 - 1:N]
        if t == t[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  ll count = 0;
  REP(i, N) {
    cin >> A[i];
    count += A[i] % 2;
  }
  if (count % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3988
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		long x = scan.nextLong();
		long[] a = new long[n];
		for(int i = 0; i < n; i++){
			a[i] = scan.nextLong();
		}

		long before = 0;
		for(int i = 0; i < n; i++){
			before += a[i];
		}

		if(a[0] > x){
			a[0] = x;
		}
		for(int i = 1; i < n; i++){
			if(a[i-1] + a[i] > x){
				a[i] = x - a[i-1];
			}
		}
		long after = 0;
		for(int i = 0; i < n; i++){
			after += a[i];
		}
		System.out.println(before - after);
	}
}


Measured memory_bytes: 62608
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;

	vector<iii> v(n);
	int maxh = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i].second.first >> v[i].second.second >> v[i].first;
		if (v[i].first > maxh) maxh = v[i].first;
	}

	sort(v.begin(), v.end()); reverse(v.begin(), v.end());
	int xdef, ydef, hdef;
	for (int i = maxh + 201; i >= maxh; --i) {
		//A partir de la primera ecuacion probamos con distintos x y a partir de esos x sacamos los h;
		for (int x = 0; x <= 100; ++x) {
			//Sacamos la y
			for (int y = 0; y <= 100; ++y) {
				if (v[0].first == max(i - abs(v[0].second.first - x) - abs(v[0].second.second - y), 0)){
					//Verificamos que el resto de ecuaciones se cumplen
					for (int j = 1; j < v.size(); ++j) {
						if (j == v.size() - 1 && v[j].first == max(i - abs(v[j].second.first - x) - abs(v[j].second.second - y), 0)) {
							xdef = x; ydef = y; hdef = i;
							goto end;
						}
						else if (v[j].first != max(i - abs(v[j].second.first - x) - abs(v[j].second.second - y), 0)) break;
					}
				}
			}
		}
	}

end:;
	cout << xdef << ' ' << ydef << ' ' << hdef << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main() {
    int x, y;
    for (std::cin >> x >> y; x != 0 || y != 0; std::cin >> x >> y) {
        if (x < y) {
            std::cout << x << ' ' << y << std::endl;
        } else {
            std::cout << y << ' ' << x << std::endl;
        }
    }
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  ll now=inf,ans=0;
  rep(i,n){
    if(now<a[i]) continue;
    now=a[i]; ans++;
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
int main(){
    vector<pair<int,int> > map;
    while(true){
        int H,W;    cin>>H>>W;
        if(H==0&&W==0)break;
        map.push_back(make_pair(H,W));
    }
    rep(i,map.size()){
        rep(j,map[i].first){
            rep(k,map[i].second){
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3112
s=input()
n=len(s)
sum=0
if n==1:
  sum=int(s)
else:
  for i in range(2**(n-1)):
    tmp=s[0]
    for j in range(n-1):
      if ((i>>j)&1):
        tmp+=s[j+1]
      else:
        sum+=int(tmp)
        tmp=s[j+1]
    if tmp!='':
      sum+=int(tmp)
print(sum)

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    pair<int, int> sc[M];

    int s, c;
    for (int i = 0; i < M; i++){
        cin >> s >> c;
        sc[i] = pair<int, int>(s, c);
    }

    for( int i = 0; i < pow(10, N); i++){
        bool success = true;
        string s = to_string(i);
        if (s.size() != N){
            continue;
        }
        for (pair<int, int> p : sc){
            if (stoi(""s + s.at(p.first - 1)) != p.second) {
                success = false;
                break;
            }
        }
        if (success){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max(0, a - b * 2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
int r,g,b;
int main() {
  cin >>r>>g>>b;
  int a = r*100 + g*10 + b;
  cout << (a%4==0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int beki[5] = {1,10,100,1000,10000};

int keta(int N){
  int ans = 0;
  while(N>0){
    N /= 10;
    ans++;
  }
  return ans;
}

int main(){
  int a,b;
  cin >> a >> b;
  int c = a*beki[keta(b)] + b;
  for(int i=1;i*i<=c;i++){
    if(i*i == c){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

bool isOK( string s ) {
    bool ret = true;
    int a[26] = {0};
    for ( int i = 0; i < s.length(); i++ ) {
        a[ s[i]-'a' ]++;
    }
    for ( int i = 0; i < 26; i++ ) {
        if ( a[i] >= 2 ) { ret = false;} 
    }  
    return ret;
}

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

    
    int a[26] = {0};
    for ( int i = 0; i < S.length(); i++ ) {
        a[ S[i]-'a' ]++;
    }
    for ( int i = 0; i < 26; i++ ) {
        if ( a[i] == 0 ) {
            S += 'a' + i;
            cout << S << endl;
            return 0;
        }
    }

    for ( int i = S.length()-1; i >= 0 ; i-- ) {
        for ( char c = S[i]+1; c <= 'z'; c++ ) {
            string t = S;
            t[i] = c;
            if ( isOK( t.substr(0,i+1) ) ) { cout << t.substr(0,i+1) << endl; return 0; }
        }
    }

    cout << -1 << endl;


    return 0;
}

Measured memory_bytes: 256
def examA():
    N, M = LI()
    l = 1; r = N
    for _ in range(M):
        L, R = LI()
        l = max(L,l)
        r = min(R,r)
    ans = max(0,r-l+1)
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return read().rstrip().decode('utf-8')
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

using namespace std;
int main(){
	string S;
	cin >> S;
	int ans = 0;
	for( int i = 0, j = S.length() - 1; i < j; ){
		if( S[i]==S[j] ){
			i++;
			j--;
		} else{
			if( S[i]=='x' ){
				i++;
				ans++;
			} else if( S[j] == 'x' ){
				j--;
				ans++;
			} else{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
A, B = list(map(int,input().split()))
K = 50
field = [["" for j in range(2*K)] for i in range(2*K)]
ans = int(0)

for i in range(2*K):
    for j in range(K):
        field[i][j] = "."
    for j in range(K,2*K):
        field[i][j] = "#"
#for i in field:
#    print(*i)
n = int(0)
j = int(0)
while(j<K/2):
    i= int(0)
    while(i<K and n<B-1):
        field[2*i][2*j] = "#"
        i +=1
        n +=1
    j +=1


n = int(0)
j = int(K/2)
while(j<K):
    i= int(0)
    while(i<K and n<A-1):
        field[2*i][2*j+1] = "."
        i +=1
        n +=1
    j +=1

print(2*K,2*K)
for i in field:
#    print(i)
    print(*i,sep="")
#    a = str(i).replace(",", "")
#    print(a)


Measured memory_bytes: 4596
<?php
    $input = trim(fgets(STDIN));
    $length = strlen($input);
    $output = 999;
    
    for ($i = 0; $i < $length - 2; $i++) {
        $take = substr($input, $i, 3);
        $hantei = 753 - $take;
        if ($hantei < 0) $hantei *= -1;
        if ($hantei < $output) $output = $hantei;
        //echo $take."\n";
    }
    
    
    echo $output;

?>


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const ll inf = (ll) 1e15+77;
const int mod = (int) 1e9 + 7;
const ld pi = acos(-1);

int main() {
    fast;
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    vector<vector<int>> dp(n, vector<int>(m, 0));
    forn(i, n) cin >> s[i];
    dp[0][0] = 1;
    forn(i, n) forn(j, m) {
            if (s[i][j] == '#') continue;
            if (i > 0 and s[i - 1][j] == '.') dp[i][j] += dp[i - 1][j];
            dp[i][j] %= mod;
            if (j > 0 and s[i][j - 1] == '.') dp[i][j] += dp[i][j - 1];
            dp[i][j] %= mod;
        }
    cout << dp[n - 1][m - 1] << endl;
    return 0;
}

Measured memory_bytes: 5248
N, K = map(int, input().split())


def count_a(b, N, K):
    p = int((N + 1) / b)
    r = (N + 1) % b
    return (b - K) * p + max(0, r - K)


count = 0

for b in range(K + 1, N + 1):
    count += count_a(b, N, K)
    if K == 0:
        count -= 1
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	vector<LL> a(n);

	LL mxa = 0;
	for (auto &e : a) {
		cin >> e;
		mxa = max(mxa, e);
	}
	LL ans = 0;
	for (LL x = 1LL; x <= mxa; x *=2) {
		LL c1 = 0;
		for (LL i = 0; i < n; ++i) {
			if ((x & a[i]) == x) {
				c1++;
			}
		}
		//cout << x << ", " << c1 << "~";
		
		LL t1 = x%mod;
		t1 *= c1;
		t1 %= mod;
		t1 *= (n-c1);
		t1 %=mod;
		ans += t1;
		ans %= mod;
	}
	cout << ans << endl;

	
}

Measured memory_bytes: 2560
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var a = o.l();
  var s = a.reduce((a,b)=>a+b);
  var div = f(s);
  for(var i = 0; i < div.length; i++){
    var x = a.map(a=>a%div[i]).sort((a,b)=>a-b);
    var y = n;
    var sum = 0, mx = 0;
    for(var j = 0; j < y && mx <= k; j++){
      sum += x[j], mx += x[j];
      while(sum > 0)sum -= div[i]-x[--y];
    }
    if(mx <= k)return div[i];
  }
  return 1;
}

function f(n){
  var r = [n];
  var m = Math.sqrt(n);
  var x = m|0;
  if(x*x === n)r.push(x);
  for(var i = 2; i < m; i++){
    if(n%i === 0)r.push(i,n/i);
  }
  return r.sort((a,b)=>b-a);
}

Measured memory_bytes: 12056
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
	Scanner in= new Scanner(System.in);
	short n;
	short i = 0;
	while (true){
		i += 1;
		n = in.nextShort();
		if (n == 0) break;
	        System.out.printf("Case %d: %d%n", i, n);
	} 
    }   
}

Measured memory_bytes: 55768
N = int(input())
L = []
R = []
for i in range(N):
    l, r = map(int, input().split())
    L.append(r)
    R.append(l)
L.sort()
R.sort(reverse=True)
ans = 0
tak = 0
for r, l in zip(R, L):
    if tak < r:
        ans += r - tak
        tak = r
    else:
        break
    if l < tak:
        ans += tak - l
        tak = l
    else:
        break
ans += abs(tak)
ans_ = ans
ans = 0
tak = 0
for r, l in zip(R, L):
    if l < tak:
        ans += tak - l
        tak = l
    else:
        break
    if tak < r:
        ans += r - tak
        tak = r
    else:
        break
ans += abs(tak)
print(max(ans, ans_))


Measured memory_bytes: 11448
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0]*N
    B=[]
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            cons ^= ans[j-1]
        if A[i-1] != cons:
            ans[i-1] = 1
            B.append(i)
            continue
        if A[i-1] != cons:
            ans[i-1] = 1
            B.append(i)
            continue
            
    print(len(B))
    print(*B)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 66896
#include<stdio.h>

int main () {
  int a[100][100];
  int n,u,k,v;
  scanf("%d",&n);
  for(int i = 0;i<n;i++) {
    for (int j = 0; j<n;j++) a[i][j]=0;
  }

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

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

  return 0;
}

Measured memory_bytes: 1820
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ld A, B, X; cin >> A >> B >> X;
	bool rev = false;
	if (X * 2 > A*A*B) {
		X = A*A*B-X;
		cout << setprecision(20) << (ld) 90 / (ld) asin(1) * atan(X / A / A / A * 2);
	} else {
		ld val = X / A / B / B; val *= 2;
		val = atan(val);
		ld PI = asin(1) * 2;
		val *= 90;
		val /= PI / 2;
		val = 90 - val;
		cout << setprecision(20) << val;
	}
	
	cout << endl;
	
	
	return 0;
}
 

Measured memory_bytes: 256
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
wr = sc
wl = sc
hu = sr
hd = sr
def taka(k,wr,wl,hu,hd):
    if k=='U':
        hu -= 1
    if k=='D':
        hd += 1
    if k=='R':
        wr += 1
    if k=='L':
        wl -= 1
    return wr,wl,hu,hd
def ao(k,wr,wl,hu,hd):
    if k=='U':
        hd = max(1,hd-1)
    if k=='D':
        hu = min(h,hu+1)
    if k=='R':
        wl = min(w,wl+1)
    if k=='L':
        wr = max(1,wr-1)
    return wr,wl,hu,hd
for i in range(n):
    wr,wl,hu,hd = taka(s[i],wr,wl,hu,hd)
    if wl==0 or hu==0 or hd==h+1 or wr==w+1:
        print('NO')
        exit()
    wr,wl,hu,hd = ao(t[i],wr,wl,hu,hd)
print('YES')

Measured memory_bytes: 3788
import math 
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
 
a = int(input())
 
ans = 0
 
for i in range(1,a+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j and i == k:
                ans += gcd(i,j,k)
            elif i == j or i == k or j == k:
                ans += gcd(i,j,k)*3
            else:
                ans += gcd(i,j,k)*6
print(ans)

Measured memory_bytes: 9488
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x,1000) {
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      d.push_back(nx%10);
      nx /= 10;
    }
    reverse(d.begin(), d.end());
    if (d.size() != n) continue;
   
    bool ok = true;
    rep(i,m) {
        if (d[p[i].first-1] != p[i].second) ok = false;
        //std::cout << d[p[i].first - 1] << ":" << p[i].second << std::endl;
 
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

#define ll long long 
#define pb push_back
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()

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

	int n;
	cin >> n;
	ll l[n];
	for (int i = 0; i < n; ++i)
		cin >> l[i];

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j + 1; k < n; ++k) {
				if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;

				vector<ll> v;
				v.pb(l[i]);
				v.pb(l[j]);
				v.pb(l[k]);

				sort(all(v));

				if (v[2] < v[0] + v[1]) ans++;
			}
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
int n,a[51];
vector<II> List;
void input()
{
    cin>>n;
    up(i,1,n) cin>>a[i];
}
void solve()
{
    bool ok= true;
    up(i,2,n)
     if (a[i]< a[i-1]) ok= false;
    if (ok)
	{
		cout<<0; return;
	}

    int ma= 0, md= 0;
    up(i,1,n)
     if (a[i]>=0)
	 {
	 	if (a[i]> a[md]) md= i;
	 }
     else
	 {
	 	if (-a[i]> -a[ma]) ma= i;
	 }

    if (a[md]>= -a[ma])
	{
        up(i,1,n)
         if (a[i]< 0) List.push_back(II(md, i) ), a[i]+= a[md];
        up(i,2,n) List.push_back( II(i-1, i) ), a[i]+= a[i-1];
	}
	else
	{
        up(i,1,n)
         if (a[i]>=0) List.push_back( II(ma, i) ), a[i]+= a[ma];
        down(i,n-1,1) List.push_back( II(i+1, i) ), a[i]+= a[i+1];
	}
	cout<<(int)List.size()<<endl;
	for (auto u: List) cout<<u.X<<" "<<u.Y<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


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

class uf {
    vector<int> par;
public:
    uf(int n) {
        par.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x < y) {
            par[y] = x;
        } else {
            par[x] = y;
        }
    }
};

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        vector<char> c(M);
        vector<int> a(M);
        vector<int> b(M);
        vector<int> w(M);
        vector<map<int,int> > dict(N+1);
        set<int> s;
        for (int i = 0; i < M; i++) {
            cin >> c[i] >> a[i] >> b[i];
            if (c[i] == '!') {
                cin >> w[i];
                s.insert(a[i]);
                s.insert(b[i]);
                dict[a[i]][b[i]] = w[i];
                dict[b[i]][a[i]] = -w[i];
            }
        }

        vector<int> dist(N+1, 1111111);
        vector<int> used(N+1);
        for (auto i : s) {
            if (dist[i] != 1111111) continue;

            dist[i] = 0;
            queue<int> que;
            que.push(i);

            while (que.size()) {
                int k = que.front();
                que.pop();
                if (used[k]) continue;

                used[k] = true;
                for (auto p : dict[k]) {
                    if (used[p.first]) continue;
                    dist[p.first] = dist[k] + p.second;
                    que.push(p.first);
                }
            }
        }

        uf t(N+1);
        for (int i = 0; i < M; i++) {
            if (c[i] == '?') {
                if (t.find(a[i]) == t.find(b[i])) {
                    cout << dist[b[i]] - dist[a[i]] << endl;
                } else {
                    cout << "UNKNOWN" << endl;
                }
            } else {
                t.unite(a[i], b[i]);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 20100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		for (; ;) {
			// for()の中身は使わないなら；；だけでいい
			try {
				input = br.readLine();
				} catch (IOException e) {
				}
			String[] inputs = input.split(" ");
			int H = Integer.parseInt(inputs[0]);
			int W = Integer.parseInt(inputs[1]);
			for (int i = 1; i <= H; i++) {
				for(int j = 1; j <= W; j++) {
					if(j < W) {
						System.out.print("#");
						// printlnは改行して表示。printは横並びに書いていく
					}else {
						System.out.println("#");
						}
					}
				}
			if (H == 0 && W == 0) {
				break;
			}
			System.out.println();
		}
		}	
	}


Measured memory_bytes: 31572
from collections import defaultdict

a, b, c = map(int, input().split())
d = defaultdict(int)
i = 1
tmp = a % b
while True:
    if d[tmp] > 0:
        break
    d[tmp] = 1
    i += 1
    tmp = (a * i) % b

dd = [0 for _ in range(250)]
dd[0] = 1
for i in range(c + 1):
    for key, value in d.items():
        dd[i + key] = max(dd[i], dd[i + key])
# print(d)
# print(dd[:30])
if dd[c] > 0:
    print("YES")
else:
    print("NO")


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


ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int arr[123456];


int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    ll N;
    cin >> N;
    for(ll h = 1; h <= 3500; h++){
        for(ll n = 1; n <= 3500; n++){
            ll n1 = N*h*n;
            ll n2 = 4*h*n - N*(h+n);

            if(n2 > 0 && n1%n2 == 0){
                //cout << n1 << " " << n2 << " " << n1%n2 << endl;
               cout << h << " " << n << " " << (1LL*n1/n2);
               return 0;
            }
        }
    }
}


Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Homework
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  int sum = 0;
  for (int i = 0; i < m; i++) {
    int ai;
    scanf("%d", &ai);
    sum += ai;
  }
  
  printf("%d\n", (n < sum) ? -1 : n - sum);
  return 0;
}


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, k, s;

int main(){
	scanf("%d %d %d", &n, &k, &s);
	for(int i = 1; i <= k; i++){
		printf("%d ", s);
	}
	int garbage;
	if(s != 1000000000){
		garbage = s + 1;
	}else{
		garbage = 1;
	}
	for(int i = 1; i <= n - k; i++){
		printf("%d ", garbage);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String ans = "";
            int len = line.length();
            for (int i = 0; i < len ; i++) {
                char ch = line.charAt(i);
                if (Character.isLowerCase(ch)) {
                    ch = Character.toUpperCase(ch);
                } else {
                    ch = Character.toLowerCase(ch);
                }
                System.out.print(ch);
            }
            System.out.println();
        }
    }
}


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

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a >= b && b >= c)
		cout << c << " " << b << " " << a << endl;
	else if (a >= c && c >= b)
		cout << b << " " << c << " " << a << endl;
	else if (b >= a && a >= c)
		cout << c << " " << a << " " << b << endl;
	else if (b >= c && c >= a)
		cout << a << " " << c << " " << b << endl;
	else if (c >= a && a >= b)
		cout << b << " " << a << " " << c << endl;
	else if (c >= b && b >= a)
		cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k; cin >> n >> k;
    int arr[k];
    map <int,int> mp;
    for (int i = 0; i < k; i++) {
        cin >> arr[i];
        mp[arr[i]] = 1;
    }
    bool ok = true;
    while(ok) {
        ok  = false;
        int x = n;
        while (x > 0) {
            if (mp[x%10]) {
                ok = true;
                break;
            }
            x /= 10;
        }
        if (ok) n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 3608