akhauriyash/Code-Regression huggingface dataset:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n=int(input())
a=sorted(list(map(int,input().split())))
option=[]
x=make_divisors(a[0])
y=make_divisors(a[1])

for num in x:
    if num<=a[1]:
        option.append(num)
for num in y:
    if num<=a[1] and num not in option:
        option.append(num)

option=sorted(option,reverse=True)       

for i in option:
    cnt=0
    for j in a:
        if j%i!=0:
            cnt+=1
    if cnt<=1:
        print(i)
        exit()

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    
    for(int i=0;i<5;i++){
        if(a[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }





}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
      cout<<"Yes";
    else
      cout<<"No";
    nl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  ll n,k;
  cin>>n>>k;
  
  vector<pair<int,int>> p(n);
  rep(i,n){
  ll a,b;
  cin>>p[i].fi>>p[i].se;
  }
  
  sort(all(p));
  
  ll now=0;
  rep(i,n){
    if(now<k && k<=now+p[i].se) {
      cout << p[i].fi << endl;
      return 0;
    }
    else now+=p[i].se;
  }
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    string ans = "";
    for(int i = 0; i < n; i++)
    {
        if (s[i] != c) {
            ans += '*';
        }
        else
        {
            ans += s[i];
        }
    }
    OUT(ans);
}

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

int sort(const void *a, const void *b){
    return *(int*)b-*(int*)a ;
}

int main(void){
    int k,t;
    scanf("%d%d",&k,&t);
    int a[t+1];
    for (int i=0; i<t; i++){
        scanf("%d",&a[i]);
    }
    a[t]=0;
    qsort (a,t+1,sizeof(int),sort); 
    while (a[1]!=0){
        a[0]=a[0]-a[1];
        a[1]=0;
        qsort (a,t+1,sizeof(int),sort);
    }
    if (a[0]==0){
        a[0]++;
    }
    printf("%d\n",a[0]-1);
	return 0 ;
}

Measured memory_bytes: 128
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

int main() {
  while (true) {
    int h, w;
    cin >> w >> h;
    if (h == 0 && w == 0)
      break;

    vector<vector<vector<bool>>> grid(h, vector<vector<bool>>(w, vector<bool>(4, true)));
    REP(i, 2 * h - 1) {
      if (i % 2 == 0) {
        REP(j, w - 1) {
          int t;
          cin >> t;
          if (t == 1) {
            grid[i / 2][j][0] = false;
            grid[i / 2][j + 1][2] = false;
          }
        }
      } else {
        REP(j, w) {
          int t;
          cin >> t;
          if (t == 1) {
            grid[(i - 1) / 2][j][3] = false;
            grid[(i + 1) / 2][j][1] = false;
          }
        }
      }
    }

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

    vector<vi> ans(h, vi(w, 1000));
    queue<pair<pair<int, int>, int>> q;
    q.push({{0, 0}, 1});
    while (!q.empty()) {
      auto p = q.front();
      q.pop();
      int y = p.first.first, x = p.first.second, val = p.second;
      if (ans[y][x] <= val)
        continue;
      ans[y][x] = val;

      REP(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && grid[y][x][i]) {
          if (ans[ny][nx] > val + 1)
            q.push({{ny, nx}, val + 1});
        }
      }
    }

    if (ans[h - 1][w - 1] == 1000) {
      cout << 0 << endl;
    } else {
      cout << ans[h - 1][w - 1] << endl;
    }
  }
  return 0;
}



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

#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 rrep(i,n) for(int i = (int)(n); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

template<typename T>
void swap(T*,T*);


int main()
{
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    vector<char> ans;
    rep(i,N)
    {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }
    rep(i,N * 2)
    {
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

struct edge{
	int to;
	int id;
};
vector<vector<edge>> g;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	g.resize(n);
	vector<int> ans(n-1);
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		--a;--b;
		g[a].push_back((edge){b,i});
		g[b].push_back((edge){a,i});
	}
	queue<int> q;
	vector<int> used(n);
	q.push(0);
	used[0] = 1;
	while(!q.empty()){
		int v = q.front();q.pop();
		int c = -1;
		
		for(int i=0;i<g[v].size();i++){
			int u = g[v][i].to;
			int ei= g[v][i].id;
			if(used[u]) c = ans[ei];
		}
		int k = 1;
		rep(i,g[v].size()){
			int u = g[v][i].to;
			int ei= g[v][i].id;
			if(used[u])continue;
			if(k==c)k++;
			ans[ei] = k;
			k++;
			q.push(u);
			used[u] = 1;
		}
	}
	int mx = 0;
	rep(i,n)mx = max(mx,int(g[i].size()));
	cout << mx << endl;
	rep(i,n-1)cout << ans[i] << endl;
}

Measured memory_bytes: 7424
#include<stdio.h>
int main(void)
{
    int n,i,j=0,a=0;
    char s[101],t[51];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<n/2;i++)
        t[i]=s[i];
    t[i]='\0';
    for(i=n/2;i<n;i++){
        if(s[i]==t[j])
            a++;
        j++;
    }
    if(a*2==n)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}

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

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

using namespace std;

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

    ll n, m; cin >> n >> m;
    
    vector<pair<ll, ll>> pairs(n);
    
    for (ll i=0; i<n; i++) cin >> pairs[i].first >> pairs[i].second;
    
    sort(pairs.begin(), pairs.end());

    ll ans = 0;

    for (int i=0; i<n; i++) {
        if (pairs[i].second < m) {
            m = m - pairs[i].second;
            ans = ans + pairs[i].first * pairs[i].second;
        }
        else {
            ans += m * pairs[i].first;
            cout << ans << "\n";
            return 0;
        }
    }    


    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

const int MAX_H = 100;
const int MAX_W = 100;

//?入
int H, W;
char g[MAX_H][MAX_W + 1];

int d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};        //方向

//深度?先遍?g[i][j]同?局域
void dfs(int x, int y, int c){
    for(int i = 0; i < 4; i ++){
        int nx = x + d[i][0], ny = y + d[i][1];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && g[nx][ny] == c){
            g[nx][ny] = '1';
            dfs(nx, ny, c);
        }
    }
}

void solve(){
    //遍?果?，?到一个新位置，遍??位置能到?的地方
    int ans = 0;
    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            if(g[i][j] != '1'){
                ans ++;
                char c = g[i][j];
                g[i][j] = '1';
                dfs(i, j, c);
            }
        }
    }
    printf("%d\n", ans);
}

int main(int argc, char const *argv[]){

    while(scanf("%d %d", &H, &W)){
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i ++){
            scanf("%s", g[i]);
        }
        solve();
    }

    return 0;
}

Measured memory_bytes: 3132
n = int(input())
a = [int(input()) for i in range(n)]

if a[0] == 2:
    print(1)
else:
    next = a[0] - 1
    for i in range(1,len(a)):
        if a[next] == 2:
            print(i+1)
            break
        next = a[next]-1
    else:
        print(-1)

Measured memory_bytes: 7084
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val k = readInt()

    // 1 桁はすべて該当。
    // 2 桁は、3件ずつ。ただし90番台だけ2件。
    // 3桁目が2-7のとき、9通り。1,8のとき8通り。9のとき5通り。

    val a = mutableListOf<Long>()

    a.add(1)
    a.add(2)
    a.add(3)
    a.add(4)
    a.add(5)
    a.add(6)
    a.add(7)
    a.add(8)
    a.add(9)
    a.add(10)
    a.add(11)
    a.add(12)
    a.add(21)
    a.add(22)
    a.add(23)
    a.add(32)
    a.add(33)
    a.add(34)
    a.add(43)
    a.add(44)
    a.add(45)
    a.add(54)
    a.add(55)
    a.add(56)
    a.add(65)
    a.add(66)
    a.add(67)
    a.add(76)
    a.add(77)
    a.add(78)
    a.add(87)
    a.add(88)
    a.add(89)
    a.add(98)
    a.add(99)

    val b = mutableMapOf<Int, List<Long>>()
    b.put(0, listOf(0,1,10,11,12))
    b.put(1, listOf(100,101,110,111,112,121,122,123))
    b.put(2, listOf(210,211,212,221,222,223,232,233,234))
    b.put(3, listOf(321,322,323,332,333,334,343,344,345))
    b.put(4, listOf(432,433,434,443,444,445,454,455,456))
    b.put(5, listOf(543,544,545,554,555,556,565,566,567))
    b.put(6, listOf(654,655,656,665,666,667,676,677,678))
    b.put(7, listOf(765,766,767,776,777,778,787,788,789))
    b.put(8, listOf(876,877,878,887,888,889,898,899))
    b.put(9, listOf(987,988,989,998,999))

    a.addAll(b[1]!!)
    a.addAll(b[2]!!)
    a.addAll(b[3]!!)
    a.addAll(b[4]!!)
    a.addAll(b[5]!!)
    a.addAll(b[6]!!)
    a.addAll(b[7]!!)
    a.addAll(b[8]!!)
    a.addAll(b[9]!!)

    fun f(d: Int, c: List<Long>?) {
        if (c != null) {
            c.forEach {
                a.add(d * 1000L + it)
            }
        }
    }

    (1..5000000).filter(::lunlun).forEach {
        val c = it % 10
        f(it, b[c - 1])
        f(it, b[c])
        f(it, b[c + 1])
    }

    println(a[k - 1])
}

fun lunlun(r: Int): Boolean {
    if (r < 10) {
        return true
    }
    var od = r % 10
    var x = r / 10
    while (x != 0) {
        val d = x % 10
        if (Math.abs(od - d) > 1) {
            return false
        }
        od = d
        x /= 10
    }
    return true
}

Measured memory_bytes: 68964
N, K = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

min = 10 ** 9
0.upto(N - K) do |l|
  r = l + K - 1
  # l -> r
  distance1 = X[l].abs + (X[l] - X[r]).abs
  # r -> l
  distance2 = X[r].abs + (X[l] - X[r]).abs

  min = [min, distance1, distance2].min
end

puts min


Measured memory_bytes: 13060
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int x; cin >> x;
    FOR(i, 1, x) {
        if (100 * i <= x && 105 * i >= x) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3192
def main():
    H, W = (int(i) for i in input().split())
    S = [input() for i in range(H)]
    c = [[-3]*W for i in range(H)]
    for h in range(H):
        cur = 1
        for w in range(W):
            if S[h][w] == ".":
                c[h][w] += cur
            else:
                cur = 0
            cur += 1
    for h in range(H):
        cur = 1
        for w in range(W)[::-1]:
            if S[h][w] == ".":
                c[h][w] += cur
            else:
                cur = 0
            cur += 1
    for w in range(W):
        cur = 1
        for h in range(H):
            if S[h][w] == ".":
                c[h][w] += cur
            else:
                cur = 0
            cur += 1
    for w in range(W):
        cur = 1
        for h in range(H)[::-1]:
            if S[h][w] == ".":
                c[h][w] += cur
            else:
                cur = 0
            cur += 1
    ma = 0
    # print(*c, sep="\n")
    for h in range(H):
        for w in range(W):
            if ma < c[h][w]:
                ma = c[h][w]
    print(ma)


if __name__ == '__main__':
    main()


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

using namespace std;

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

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

  sort(as, as + n, [](const int &a, const int &b) -> bool { return a > b; });
  if (as[m - 1] * 4 * m >= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
n = int(input())
arr = [int(i) for i in input().split()]

left = [0]*n
xor = arr[0]
for i in range(1, n):
  left[i] = xor
  xor ^= arr[i]

right = [0]*n
xor = arr[n-1]
for i in range(n-2, -1, -1):
  right[i] = xor
  xor ^= arr[i]

for i in range(n):
  arr[i] = left[i] ^ right[i]

print(*arr)

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

using namespace std;

typedef long long ll;

struct flower {

	ll height;
	ll beauty;

};

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

	vector<flower> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i].height;
	for (int i = 1; i <= n; i++) cin >> a[i].beauty;



	ll ans[n + 1];
	memset(ans, 0, sizeof ans);
	ans[1] = a[1].beauty;
	ll final = ans[1];

	map<ll, ll> mp;
	mp[a[1].height] = a[1].beauty;

	for (int i = 2; i <= n; i++) {
		ans[i] = a[i].beauty;
		auto it = mp.lower_bound(a[i].height + 1);
		if (it != mp.begin()) {
			it--;
			ans[i] += it->second;
		}
		mp[a[i].height] = ans[i];
		it = mp.upper_bound(a[i].height);

		while (it != mp.end() and it->second <= ans[i]) {
			auto temp = it;
			temp++;
			mp.erase(it);
			it = temp;
		}

		final = max(final, ans[i]);
	}

	cout << final << endl;
	return 0;
}

/*

	i < j
	hi < hj
	dp[i] > dp[j] -> extend it

	h1	h2	h3	h4	...		hi 	hj
	b1	b2	b3	b4	...		bi 	bj




*/


Measured memory_bytes: 20292
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=;
//const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int k,x;

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>k>>x;
	k--;
	for(int i=x-k;i<=x+k;i++) cout<<i<<' ';
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    if (n % 2 == 1):
        print(0)
    else:
        sum = 0
        while(n > 0):
            k = (n // 5) // 2
            sum += k 
            n //= 5
        print(sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
while True:
    n, x = [int (x) for x in input().split(' ')]
    if n == 0 and x == 0: break
    count = 0
    for a in range(1,n+1):
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                if a+b+c == x: count += 1
    print("%d" % count)

Measured memory_bytes: 7704
using System;
using System.IO;

namespace DSL2_A
{
    class RMQ
    {
        internal int n;
        internal int[] dat;

        public RMQ(int t)
        {
            n = t;
            dat = new int[2 * n - 1];
            for (int i = 0; i < 2 * n - 1; i++)
            {
                dat[i] = int.MaxValue;
            }
        }

        public void update(int k, int a)
        {
            k += n - 1;
            dat[k] = a;
            while (k > 0)
            {
                k = (k - 1) / 2;
                dat[k] = Math.Min(dat[k * 2 + 1], dat[k * 2 + 2]);
            }  
        }

        public int query(int a, int b, int k, int l, int r)
        {
            if (r <= a || b <= l) return int.MaxValue;

            if (a <= l && r <= b) return dat[k];
            else
            {
                int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
                int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
                return Math.Min(vl, vr);
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var t = scan;
            int n_ = t[0];
            int q = t[1];

            int n = 1;
            while (n < n_) n *= 2;

            var ST = new RMQ(n);
            for (int i = 0; i < q; i++)
            {
                t = scan;
                if (t[0] == 0)
                {
                    ST.update(t[1], t[2]);
                }
                else if(t[0] == 1)
                {
                    Console.WriteLine(ST.query(t[1], t[2] + 1, 0, 0, n));
                }
            }
            Console.Out.Flush();
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }

}

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

using namespace std;
const int maxn=200005;
const int inf=0x3f3f3f3f;

int dp[maxn],a[maxn],n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) dp[i]=(i==1?0:inf);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=2;i<=n;i++) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),i>2?dp[i-2]+abs(a[i]-a[i-2]):inf);
	printf("%d\n",dp[n]);
 } 

Measured memory_bytes: 1024
#include <iostream>
int main(){
  int N,k,p;
  std::cin >> N;
  for(int i=0; i<N; i++){
    std::cin >> k >> p;
    if(k%p == 0)
      std::cout << p << std::endl;
    else
      std::cout << k%p << std::endl;
  }
  return 0;
}

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

const int MAX = 100005;

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

  int num_divisions = 1;
  int current_index = 1;
  bool is_increasing = false;
  while (current_index < N) {
    while ((current_index < N) && (A[current_index] == A[current_index - 1])) {
      current_index++;
    }
    while ((current_index < N) &&  (A[current_index] - A[current_index - 1] >= 0)) {
      is_increasing = true;
      current_index++;
    }
    if (!is_increasing) {
      while ((current_index < N) && (A[current_index] - A[current_index - 1] <= 0)) {
        current_index++;
      }
    }
    if (current_index == N) {
      break;
    }
    num_divisions++;
    current_index++;
    is_increasing = false;
  }
  cout << num_divisions << endl;
}


Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
		
	ll i,j,k,l,n;
	cin>>n;

	ll t=0,x=0,y=0;
	ll a,b,c;
	for(i=1;i<=n;i++){
		cin>>a>>b>>c;
		k=(a-t);
		l=abs(x-b)+abs(y-c);
		if(k<l||(k-l)%2){
			cout<<"No";return 0;
		}
		t=a; x=b; y=c;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <fstream>
#include <cmath>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
 
string makestring(int x)
{
    stringstream ss;
    ss << x;
    return ss.str();
}
 
int main()
{
 
 
    int n, l, t, c=0, x;
    vector<int> v;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        cin >> t;
        v.push_back(t);
    }
    for(int i = 0; i < n-1; i++){
        t=v[i]+v[i+1];
        if(c<t){
            c=t;
            x=i;
        }
 
    }
    if(c<l){
        cout << "Impossible";
    } else {
        cout << "Possible" << endl;
        for(int i = 1; i <= x; i++){
            cout << i << endl;
        }
        for(int i = n-1; i > x; i--){
            cout << i << endl;
        }
    }
 
 
 
 
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;
 
int a[220000];
int ans[220000];
vector<int> dp(220000, INF);

int main() {
    int ans = 0;
    Int a, b, c, k;
    cin >> a >> b >> c >> k;

    while ((a-- > 0) && (k-- > 0)) {
        ans++;
    }
    while ((b-- > 0) && (k-- > 0)) {
    }
    while ((c-- > 0) && (k-- > 0)) {
        ans--;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::pair<int, int>> result;
	int left = 0, right = m - 1;
	while (left < right) {
		result.push_back(std::make_pair(left++, right--));
	}
	left = m; right = m * 2;
	while (left < right) {
		result.push_back(std::make_pair(left++, right--));
	}
	std::sort(result.begin(), result.end(), [](const std::pair<int, int>& a, const std::pair<int, int>& b) {return (a.second - a.first) < (b.second - b.first); });
	for (auto i = 0; i < m; ++i) {
		std::cout << result[i].first + 1 << ' ' << result[i].second + 1 << '\n';
	}

}

Measured memory_bytes: 4320
import java.util.Scanner;
import java.util.Arrays;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        final int n = 1001;

        while (scanner.hasNextInt()) {
            int v = scanner.nextInt();
            int d = scanner.nextInt();

            int a = 1;
            int b = 1;
            int[] fib = new int[v];
            for (int i  = 0; i < v; i++) {
                fib[i] = (a + b) % n;
                b = a;
                a = fib[i];
            }
            Arrays.sort(fib);

            int counter = 0;
            int previous = fib[0];
            for (int i = 0; i < v; i++) {
                int current = fib[i];
                if (current - previous >= d) {
                    counter++;
                }
                previous = current;
            }

            System.out.println(counter + 1);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
import math
a,b,h,m=map(int,input().split())
c,d=(h*60+m)/1440*math.pi*4,m/60*math.pi*2
print(((a*math.sin(c)-b*math.sin(d))**2+(a*math.cos(c)-b*math.cos(d))**2)**0.5)

Measured memory_bytes: 9520
N, M = [int(i) for i in input().split()]
ans_list = [list(input().split()) for i in range(M)]
ref_list = [0]*N
pena_list = [0]*N
for i, j in ans_list:
    if ref_list[int(i)-1]==0:
        if j == "AC":
            ref_list[int(i)-1]=1
        else:
            pena_list[int(i)-1] = pena_list[int(i)-1]+1
ok_count = 0
pena_num = 0
for i in ref_list:
    if int(i) == 1:
        ok_count += 1
for i, j in zip(ref_list, pena_list):
    if i==1:
        pena_num += j
print(ok_count, pena_num)

Measured memory_bytes: 27464
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B)          for(int I=A; I<B; I++)
#define LL                  long long
#define PII                 pair<int,int>
#define MOD                 1000000007
#define MAX                 1000005
#define READ(A)             freopen(A,"r",stdin)

int main() {
    //READ("input.txt");
    stack<int>S;
    int N;

    while(scanf("%d",&N)!=EOF){
        if(N==0){
            printf("%d\n",S.top());
            S.pop();
        }else{
            S.push(N);
        }
    }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, start;
    cin >> len >> start;
    int ans;
    cin >> ans;
    ans = abs(ans - start);
    for(int i = 1; i < len; i++) {
        int a;
        cin >> a;
        a = abs(a - start);
        ans = __gcd(ans, a);
    }
    cout << ans;
}

Measured memory_bytes: 3656
#include<stdio.h>
  
int main(){
  int n, i, max, min;
  int a[200000];
 
  scanf("%d" ,&n);
   for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
   max = a[1] - a[0];
   min = a[0];
   for(i = 1; i < n; i++){
	scanf("%d", &a[i]);
         if(max < a[i] - min){
     max = a[i] - min;
   }
      if(min > a[i]){
     min = a[i];
   }
  }

    printf("%d\n" ,max);
 
 return 0;
}
 

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, t;
    cin >> n >> t;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    Int ma, mi;
    ma = mi = a[0];
    Int d = 0;
    for (Int i = 0; i < n; i++) {
        if (mi > a[i]) {
            ma = mi = a[i];
        }
        else if (ma < a[i]) {
            ma = a[i];
        }
        d = max(d, ma-mi);
    }
    // dump(d);
    ma = mi = a[0];
    Int res = 0;
    Int x, y;
    x = y = 0;
    vector<pair<Int, Int>> v;
    for (Int i = 1; i < n; i++) {
        if (mi > a[i]) {
            ma = mi = a[i];
        }
        else if (ma < a[i]) {
            ma = a[i];
            if (ma - mi == d) v.push_back(make_pair(mi, ma));
        }
    }
    ma = mi = a[0];
    Int j = 0;
    for (Int i = 0; i < n; i++) {
        if (mi > a[i]) {
            if (ma - mi == d) j++;
            ma = mi = a[i];
            res += min(x, y);
            x = y = 0;
        }
        else if (ma < a[i]) {
            ma = a[i];
        }
        if (v[j].first == a[i]) x++;
        if (ma - mi == d && v[j].second == a[i]) y++;
    }
    res += min(x, y);
    dump(res);
    return 0;  
}

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

int main(){
    long long N;
    cin>>N;
    long long  A[N];
    long long ans=1;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    
    for(int i=0;i<N;i++){
      long long temp=ans;
      
        ans*=A[i];
        if(ans>1000000000000000000){
            cout<<-1<<endl;
            return 0;
        }
      if(ans<temp){
        cout<<-1<<endl;
        return 0;
      }
    }

    cout<<setprecision(20)<<ans<<endl;
    
}



Measured memory_bytes: 4392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
 int a,b,c;
 cin >> a >> b >> c;
 if ((b-a)==(c-b))
 {
   cout << "YES" << endl;
 }else
 {
   cout << "NO" << endl;
 }
 
  

  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
program Project1;
         
{$APPTYPE CONSOLE}
     
uses
  SysUtils,math;
var
  g,l,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t:Integer;
  //l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);

    for i := n downto 1 do
      if power(trunc(sqrt(i)),2)=i then begin
        Writeln(i);
        break;
      end;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
import bisect
n = int(input())
a = sorted([int(i) for i in input().split()])
b = sorted([int(i) for i in input().split()])
c = sorted([int(i) for i in input().split()])
ans = 0
for i in b:
    ans += bisect.bisect_left(a, i) * (n - bisect.bisect(c, i))
print(ans)


Measured memory_bytes: 23244
#include <iostream>

using namespace std;

typedef long long ll;

int main() {

	ll n = 0, m = 0, sum = 0, input = 0;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> input;
		sum += input;
	}

	if (n - sum < 0) cout << -1;
	else {
		cout << n - sum;
	}

}

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

char A[1001][1001];
/* nearest distance to # */
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
bool arrived[1001][1001];
int H, W;
queue< pair <int,int> > Q;
int sharp_cnt = 0;

int bfs_visit(){
    int v, w;
    int ans = 0;

    
    while(!Q.empty() && sharp_cnt < H*W){
        ans++;
        queue< pair <int,int> > sub;
        
        while(!Q.empty()){
            v = Q.front().first;
            w = Q.front().second;
            Q.pop();
            for(int i = 0; i < 4; i++){
                int ny = v + dy[i];
                int nx = w + dx[i];
                if(ny < 0 || ny >= H || nx < 0 || nx >= W || arrived[ny][nx]){
                    continue;
                }
                arrived[ny][nx] = true;
                sub.push(make_pair(ny, nx));
                sharp_cnt++;
            }
        }
        Q = sub;
    }
    
    return ans;

}

int main(void){
    // Your code here!
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> A[i][j];
            if(A[i][j] == '#'){
                sharp_cnt++;
                Q.push(make_pair(i, j));
                arrived[i][j]=true;
            } else{
                arrived[i][j] = false;
            }
        }
    }
    
    if(sharp_cnt == H*W){
        cout << 0 << endl;
        return 0;
    }
    
    cout << bfs_visit() << endl;

}


Measured memory_bytes: 10496
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    ll N; cin >> N;
    vector < ll > a(N);
    REP(i,N) cin >> a[i];

    ll ans = 0;
    while (true) {
        sort(a.begin(), a.end());
        if (a.back() < N) break; 
        ll minus = a.back() / N * N;
        a.back() -= minus;
        ans += minus / N;
        REP(i,a.size() - 1) a[i] += minus / N;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, K  = map(int, input().split())
h = [int(x) for x in input().split()]

inf = float('inf')
dp = [inf] * N

dp[0] = 0

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

for i in range(1, N):
    for k in range(1, K+1):
        if i-k <0:
            break
        else:
            dp[i] = chmin(dp[i], dp[i-k] + abs(h[i] - h[i-k])) 

print(dp[N - 1])

Measured memory_bytes: 55264
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define inf 1e18;
#define PI acos(-1)
const int M = 1000000007;
const int N=1e5+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int k  , a , b;
    cin >> k >> a >> b;
    int r = b/k;
    int l = (a-1)/k;
    if(r - l > 0 ){
        cout << "OK\n";
    }
    else{
        cout <<"NG\n";
    }

}

signed main()
{
    FAST;
    //TODO:  check test cases are there or not?
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++)
    {
        solve();
    }
}

Measured memory_bytes: 3640
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut P = read![i64; N];
    P.sort();
    P[N - 1] /= 2;
    println!("{}", P.into_iter().sum::<i64>())
}


Measured memory_bytes: 4352
n,m = list(map(int,input().split()))
gate = list()
for i in range(0,m):
    gate.append(list(map(int,input().split())))

low = 1
high = n

for i in range(0,m):
    if gate[i][0] > high or gate[i][1] < low:
        print(0)
        break
    low = max(low,gate[i][0])
    high = min(high,gate[i][1])
else:
    print(high-low+1)


Measured memory_bytes: 27348
#include<stdio.h>
#include<ctype.h>

int main(void)
{
  char name[1000] = {0};
  int i=0;

  gets(name);
  while(name[i] != '\0'){
    name[i] = toupper(name[i]);
    printf("%c",name[i]);
    i++;
  }
  putchar('\n');
  
  return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  string A, B, C; cin >> A >> B >> C;
  if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]){
    cout << "YES" << endl;
  }else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    bool hai = false, tya = false, green = false, miz = false, ao = false, ki = false, dai = false, red = false;
    int free = 0;
    int count = 0;
    rep(i, n) {
        if (a[i] < 400) {
            if(!hai){
                count++;
                hai = true;
            }
        }
        else if (a[i] < 800) {
            if (!tya) {
                count++;
                tya = true;
            }
        } else if (a[i] < 1200) {
            if (!green) {
                count++;
                green = true;
            }
        } else if (a[i] < 1600) {
            if (!miz) {
                count++;
                miz = true;
            }
        } else if (a[i] < 2000) {
            if (!ao) {
                count++;
                ao = true;
            }
        } else if (a[i] < 2400) {
            if (!ki) {
                count++;
                ki = true;
            }
        } else if (a[i] < 2800) {
            if (!dai) {
                count++;
                dai = true;
            }
        } else if (a[i] < 3200){
            if(!red) {
                count++;
                red = true;
            }
        }
        else free++;
    }
    int max1 = count + free;
    int min1 = 0;
    if(count == 0) min1 = 1;
    else{
        min1 = count;
    }
    cout << min1 << " " << max1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string a,b; cin >>a >>b;
  string c=a+b;
  int temp=sqrt(stoi(c));
  if (temp*temp==stoi(c)) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
  return 0;
}


Measured memory_bytes: 256
A=list(input())
B=list(input())
lengthA=len(A)
lengthB=len(B)
maxi=[]
for i in range(lengthA-lengthB+1):
	counter=0
	C=A[i:lengthB+i]
	for j in range(lengthB):
		if C[j]==B[j]:
			counter+=1
	maxi.append(lengthB-counter)
print(min(maxi))

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

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

int main()
{
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int cost = inf;
    for(int i = -100; i <= 100; i++){
        int tmp = 0;
        rep(j,n){
            tmp += (a[j]-i) * (a[j]-i);
        }
        cost = min(cost,tmp);
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  bool include_zero = false;
  rep(i, N){
    if(A[i] == 0) include_zero = true;
  }

  ll ans = 0;
  if(include_zero){
    rep(i, N){
      ans += abs(A[i]);
    }
  }else{
    ll count_minus = 0;
    rep(i, N){
      if(A[i] < 0) count_minus++;
    }
    ll sum = 0;
    rep(i, N){
      A[i] = abs(A[i]);
    }
    rep(i, N){
      sum += A[i];
    }
    if(count_minus % 2 == 0){
      ans = sum;
    }else{
      ans = sum;
      ll mn = A[0];
      rep(i, N){
        mn = min(mn, A[i]);
      }
      ans -= mn * 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define MOD 1000000007

char maze[21][21];
ll h, w;

void init_maze()
{
  for (auto i = 0; i < 21; i++)
  {
    for (auto j = 0; j < 21; j++)
    {
      maze[i][j] = 'z';
    }
  }

  cin >> h >> w;
  char cell;
  for (auto i = 1; i <= h; i++)
  {
    for (auto j = 1; j <= w; j++)
    {
      cin >> cell;
      maze[i][j] = cell;
    }
  }
}

int calc(int i, int j)
{
  set<pair<int, int>> visited = {};
  queue<pair<int, int>> q = {};
  auto initial_p = make_pair(i, j);

  q.push(initial_p);
  visited.insert(initial_p);

  ll cycle = -1;
  while (!q.empty())
  {
    cycle++;
    auto size = q.size();

    for (auto i = 0; i < size; i++)
    {
      auto cur = q.front();
      q.pop();

      auto directions = vector<pair<int, int>>{
          make_pair(1, 0),
          make_pair(-1, 0),
          make_pair(0, 1),
          make_pair(0, -1),
      };

      for (auto d : directions)
      {
        auto x_diff = d.first;
        auto y_diff = d.second;

        auto next_x = cur.first + x_diff;
        auto next_y = cur.second + y_diff;

        // 範囲内でなければなにもしない
        if (!(next_x >= 1 && next_x <= h && next_y >= 1 && next_y <= w))
        {
          continue;
        }

        // もし道ならば
        if (maze[next_x][next_y] == '.')
        {
          auto p = make_pair(next_x, next_y);
          if (visited.count(p) == 0)
          {
            q.push(p);
            visited.insert(p);
          }
        }
        else
        {
        }
      }
    }
  }
  return cycle;
}

int main()
{
  init_maze();

  ll max = -1;
  for (auto i = 1; i <= h; i++)
  {
    for (auto j = 1; j <= w; j++)
    {
      if (maze[i][j] == '.')
      {
        auto res = calc(i, j);
        if (res > max)
        {
          max = res;
        }
      }
    }
  }

  cout << max << endl;
  return 0;
}


Measured memory_bytes: 888
n = gets.chomp.to_i
rates = readlines.map(&:chomp).map(&:to_i)
maxv = (-2) * 10 ** 9
min_r = rates[0]

(1..(n - 1)).each do |i|
  maxv = maxv > rates[i] - min_r ? maxv : rates[i] - min_r
  min_r = min_r < rates[i] ? min_r : rates[i]
end

puts maxv



Measured memory_bytes: 29516