akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}
ll const MAX = 1000001;


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

    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll x=n;
            while(x%i==0)
                x=x/i;
            if((x-1)%i==0)
                ans++;
            ll j=n/i;
            if(j!=i)
            {
                x=n;
                while(x%j==0)
                    x=x/j;
                if((x-1)%j==0)
                    ans++;
            }
           // cout<<i<<" "<<j<<" "<<ans<<endl;
        }
    }
    ll y=n-1;
    for(ll i=1;i*i<=y;i++)
    {
        if(y%i==0)
        {
            ans++;
            ll j=y/i;
            if(j!=i)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> P(N);

    for (int i = 0; i < N; i++) cin >> P[i];

    sort(P.begin(), P.end(), greater<int>());

    int ans = P[0] / 2;
    for (int i = 1; i < N; i++) ans += P[i];
    
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Solve
{
    static void Main(string[] args)
    {
        new ABC_C();
    }
}
public class ABC_A
{
    public ABC_A()
    {
        var inn = Ex.ReadIntArray();
        int n = inn[0];
        int m = inn[1];
        Console.WriteLine(n * (n - 1) / 2 + m * (m - 1) / 2);
    }
}
public class ABC_B
{
    public ABC_B()
    {
        string s = Ex.Read;
        int n = s.Length;
        Console.WriteLine((c1(s, 1, n) && c1(s, 1, (n - 1) / 2) && c1(s, (n + 3) / 2, n)) ? "Yes" : "No");
    }

    bool c1(string s, int ss, int ee)
    {
        int i = 0;
        while ((ss + i - 1) <= (ee / 2))
        {
            if (s[ss + i - 1] != s[ee - i - 1]) return false;
            i++;
        }

        return true;
    }
}
public class ABC_C
{
    public ABC_C()
    {
        string s = Ex.Read;
        ulong l = ulong.Parse(s);
        var d = (l / 3.0);
        Console.WriteLine(d*d*d);
    }
}
public class ABC_D
{
    public ABC_D()
    {

    }
}
public class ABC_E
{
    public ABC_E()
    {

    }
}
public class ABC_F
{
    public ABC_F()
    {

    }
}
public static class Ex
{
    public static string Read { get { return Console.ReadLine().Trim(); } }
    public static int ReadInt { get { return int.Parse(Read); } }
    public static long ReadLong { get { return long.Parse(Read); } }
    public static double ReadDouble { get { return double.Parse(Read); } }
    public static string[] ReadArray() { return Read.Split(' '); }
    public static int[] ReadIntArray() { return Read.Split(' ').Select(s => int.Parse(s)).ToArray(); }
    public static long[] ReadLongArray() { return Read.Split(' ').Select(s => long.Parse(s)).ToArray(); }
    public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<int> H(n);
    REP(i, n) cin >> H[i];
    bool flag = true;
    FOR(i, 1, n){
        if(H[i - 1] != H[i]){
            H[i]--;
            if(H[i - 1] > H[i]){
                flag = false;
                break;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// Shortcut

#pragma optimize ("O3")
#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

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

int a, b, c, d, e;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> a >> b >> c >> d;
    e = c / __gcd(c, d) * d;
    int ans = b - a + 1;
    
    int l = a / c * c;
    if (l < a) l += c;
    int r = b / c * c;
    ans -= (r - l) / c + 1;
    
    l = a / d * d;
    if (l < a) l += d;
    r = b / d * d;
    ans -= (r - l) / d + 1;
    
    l = a / e * e;
    if (l < a) l += e;
    r = b / e * e;
    ans += (r - l) / e + 1;
    
    cout << ans << endl;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

ll n, k;

int main () {
	scanf("%lld %lld", &n, &k);

	ll res = 0;
	for (ll b = k+1; b <= n; b++) {
		ll loc = (n/b)*(b-k);
		if (n%b >= k) loc += (n%b) - k + 1;
		if (k == 0) loc--;
		res += loc;
	}

	printf("%lld\n", res);
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
E=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  E[a].append(b)
  E[b].append(a)
D=deque([0])
V=[0]*n
V[0]=1
A=[0]
P=[-1]*n
while len(D)>0:
  x=D[0]
  D.popleft()
  for c in E[x]:
    if V[c]==0:
      D.append(c)
      A.append(c)
      P[c]=x
      V[c]=1
A=A[::-1]
VV=[0]*n
f=0
for c in A:
  if VV[c]==0:
    if P[c]==-1 or VV[P[c]]==1:
      f=1
    else:
      VV[c]=1
      VV[P[c]]=1
if f==1:
  print("First")
else:
  print("Second")

Measured memory_bytes: 25328
//Bartek Kostka
//  You are not prepared!

#include "bits/stdc++.h"

using namespace std;

#define x first
#define y second
#define SZ(x) int(x.size())
#define ll long long
#define pii pair <int, int>
#define vi vector <int>
#define ALL(x) x.begin(), x.end()

#ifdef LOCAL
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(false) cout
#endif

int main() {
  int x, y, z, K;
  cin >> x >> y >> z >> K;
  vector <ll> A(x), B(y), C(z);
  for(int i=0; i<x; i++) cin >> A[i];
  for(int i=0; i<y; i++) cin >> B[i];
  for(int i=0; i<z; i++) cin >> C[i];
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  ll p = -1, k = 1e18;
  auto check = [&](ll m) {
    ll ile = 0;
    for(int i=0; i<x; i++) {
      for(int j=0; j<y; j++) {
        ll res = max(0LL, m - A[i] - B[j]);
        ile += distance(lower_bound(ALL(C), res), C.end());
      }
    }
    return ile <= K;
  };
  while(k-p > 1) {
    ll m = (p+k)/2;
    if(check(m)) k = m;
    else p = m;
  }
  vector <ll> ret;
  ll las = p;
  for(int i=0; i<x; i++) {
    for(int j=0; j<y; j++) {
      ll res = max(0LL, las - A[i] - B[j]);
      for(auto it = lower_bound(ALL(C), res); it != C.end(); it++) {
        ret.push_back(A[i] + B[j] + *it);
      }
    }
  }
  sort(ALL(ret));
  reverse(ALL(ret));
  ret.resize(K);
  for(auto r : ret) cout << r << "\n";
}


Measured memory_bytes: 133216
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int Main(int &a, int &b)
{
    return (a >=1 && a <= 9 && b >= 1 && b <= 9) ? a * b : -1;
}

int main(void){
    int A, B;
    cin >> A >> B;
    cout << Main(A, B) << endl;
    return 0;
}

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

const int MAX_V = 100000;
int par[MAX_V];
int depth[MAX_V];
int num[MAX_V];

void init(int n) {
    for(int i = 0; i < n; i++) {
        par[i] = i;
        depth[i] = 0;
        num[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    num[x] += num[y];
    num[y] = num[x];

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

bool same(int x, int y) {
    return root(x) == root(y);
}

int get_num(int x) {
    return num[root(x)];
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a.at(i) >> b.at(i);
        a.at(i)--;
        b.at(i)--;
    }

    init(n);


    vector<long long> ans(m);
    long long cnt = (long long)n * (n - 1) / 2;
    ans.at(m - 1) = cnt;
    for (int i = m - 1; i >= 1; i--) {
        if (!same(a.at(i), b.at(i))) {
            cnt -= (long long)get_num(a.at(i)) * get_num(b.at(i));
            unite(a.at(i), b.at(i));
        }
        ans.at(i - 1) = cnt;
    }

    for (int i = 0; i < m; i++) {
        cout << ans.at(i) << endl;
    }
}

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

int main()
{
  int64_t h, w;
  cin >> h >> w;
  int64_t ans = min(h % 3 == 0 ? 0 : w, w % 3 == 0 ? 0 : h);
  if (ans != 0) {
    int64_t w3 = w / 3;
    int64_t s1 = w3 * h;
    int64_t s2 = (w - w3) * (h / 2);
    int64_t s3 = (w - w3) * ((h + 1) / 2);
    auto p = minmax({s1, s2, s3});
    ans = min(ans, p.second - p.first);
    w3++;
    s1 = w3 * h;
    s2 = (w - w3) * (h / 2);
    s3 = (w - w3) * ((h + 1) / 2);
    p = minmax({s1, s2, s3});
    ans = min(ans, p.second - p.first);
    swap(h, w);
    w3 = w / 3;
    s1 = w3 * h;
    s2 = (w - w3) * (h / 2);
    s3 = (w - w3) * ((h + 1) / 2);
    p = minmax({s1, s2, s3});
    ans = min(ans, p.second - p.first);
    w3++;
    s1 = w3 * h;
    s2 = (w - w3) * (h / 2);
    s3 = (w - w3) * ((h + 1) / 2);
    p = minmax({s1, s2, s3});
    ans = min(ans, p.second - p.first);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
    int n;

    cin >> n;

    int t[4][14];
    string suit;
    int num;

    for(int i = 0; i < 4; i++)
    {
        for(int j = 1; j < 14; j++)
        {
            t[i][j] = 0;
        }
    }

    for(int k = 0; k < n; k++)
    {
        cin >> suit >> num;

        if(suit == "S")
            t[0][num] = 1;
        else if(suit == "H")
            t[1][num] = 1;
        else if(suit == "C")
            t[2][num] = 1;
        else if(suit == "D")
            t[3][num] = 1;
    }

    for(int l = 0; l < 4; l++)
    {
        for(int m = 1; m < 14; m++)
        {
            if(t[l][m] == 0)
            {
                if(l == 0)
                    cout << "S " << m << endl;
                else if(l == 1)
                    cout << "H " << m << endl;
                else if(l == 2)
                    cout << "C " << m << endl;
                else if(l == 3)
                    cout << "D " << m << endl;
            }
        }
    }

    return 0;
} 

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

int main(){
  srand((unsigned int)time(NULL)); 
  int D,M=365*500;
  int c[30];
  int s[370][30];
  int t[370];
  int last[30];
  int ans=0;
  int ans_max=0;
  int old_t,old_d;
  
  scanf("%d",&D);
  for(int i=1;i<=26;i++)
    scanf("%d",c+i);
  for(int i=1;i<=D;i++)
   for(int j=1;j<=26;j++)
     scanf("%d",&s[i][j]);
  
  for(int i=1;i<=D;i++)
    t[i]=rand()%26+1;
  
  for(int i=1;i<=M;i++){
    ans=0;
    old_d=rand()%D+1;
    old_t=t[old_d];
    t[old_d]=rand()%26+1;
    for(int k=1;k<=26;k++)
      last[k]=0;
    for(int d=1;d<=D;d++){
      ans+=s[d][t[d]];
      last[t[d]]=d;
      for(int j=1;j<=26;j++){
        ans-=c[j]*(d-last[j]);
      }
    }
    if(ans<ans_max){
      t[old_d]=old_t;
    }else{
      ans_max=ans;
    }
  }
  
  for(int i=1;i<=D;i++)
    printf("%d\n",t[i]);
  return 0;
}

Measured memory_bytes: 1780
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        List<Integer> x = new ArrayList<Integer>();
        int result = -1;

        for (int i = 0; i<N; i++) {
            x.add(sc.nextInt());
        }

        for (int i = 0; i<N-K+1; i++) {

                int distance = Math.abs(x.get(i)) + Math.abs(x.get(i) - x.get(i+K-1));
                if (result < 0 || result > distance) {
                    result = distance;
                }
                distance = Math.abs(x.get(i+K-1)) + Math.abs(x.get(i+K-1) - x.get(i));
                if (result < 0 || result > distance) {
                    result = distance;
                }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 63724
# ABC042 C Iroha's Obsession
N,K = map(int,input().split())
D = tuple(map(str,input().split()))

for i in range(N,1000000):
    S = str(i)
    is_iroha = True
    for s in S:
        if s in D:
            is_iroha = False
            break
    if is_iroha:
        print(S)
        exit()


Measured memory_bytes: 3060
#! /usr/bin/env python3

n, m = map(int, input().split())
a = [int(i) for i in input().split()]

acc = 0
res = 0

mods = {}

for i in range(n):
    acc = (acc + a[i]) % m

    if acc == 0:
         res += 1

    if acc in mods:
        res += mods[acc]
        mods[acc] += 1
    else:
        mods[acc] = 1

print(res)


Measured memory_bytes: 14224
n, k = map(int, input().split())
A_MAX = 10**5
bkt = [0 for _ in range(A_MAX+1)]
for _ in range(n):
    a, b = map(int, input().split())
    bkt[a] += b
sum_count = 0
for i, cnt in enumerate(bkt):
    sum_count += cnt
    if sum_count >= k:
        print(i)
        break

Measured memory_bytes: 11692
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if((s.compare(u))==0){
        a=a-1;
        cout<<a<<" "<<b<<endl;
    }
    else{
        b=b-1;
        cout<<a<<" "<<b<<endl;
    }

    return 0;
}


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#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, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll inf = (ll)1e18;
const ll N = (ll)2e5+77;
const ll mod = (ll)1e9+7;

ll n, m, k;

int main() {
    fast;
    cin >> n >> m >> k;
    if ((m - k) & 1) cout << "Borys\n";
    else cout << "Alice\n";
    return 0;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    x=1
    y=[]
    z=0
    if n==0:
        break
    for i in range(1,n+1):
        x*=i
    for j in str(x):
        y+=[j]
    y.reverse()
    for k in y:
        if k=='0':
            z+=1
        elif k!=0:
            break
    print(z)


Measured memory_bytes: 6488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    gcd(b,a%b);
}

int main()
{
    ll a,b;cin>>a>>b;
    ll g=gcd(a,b);
    ll c=0;
    ll en=sqrt(g)+2;
    for(int i=2;i<en;i++)
    {
        if(g%i==0)
        {
            c++;
            while(g%i==0)
                g/=i;
        }
    }
    if(g!=1)
        c++;
    cout<<c+1<<endl;
}


Measured memory_bytes: 256
def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int x;
  cin >> x;
  for(int a = 0; a < 200; a++){
    for(int b = -200; b < 200; b++){
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] a = new int[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int temp = 0;
            for (int j = 0; j <= i; j++) {
                temp += a[0][j];
            }
            for (int j = i; j < n; j++) {
                temp += a[1][j];
            }
            ans = Math.max(ans, temp);
        }
        System.out.println(ans);
    }
}

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

int main() {

  int N;
  int A[10000000];

  cin >> N;

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

  int MAX = 0;
  for (int i = 0 ; i < 1000000 ; i++) {
    int isBroken = 0;
    // cout << "[";
    for (int j = 0 ; j < N ; j++) {
      // cout << A[j] << " ";
      if (A[j] % 2 != 0) {
	// cout << A[j] << endl;
	isBroken = 1;
	break;
      }
      A[j] = A[j]/2;
    }
    // cout << "]" << endl;
    if (isBroken == 1) {
      break;
    }
    MAX++;
  }

  cout << MAX << endl;
 
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
long extgcd( long a, long b)
{
  long u, v, q, tmp; 
  long x = 1;
  long y = 0; u = 0; v = 1;
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = v; v = y - q * v; y = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }
  x %= (long int)1E9+7;
  while (x<0)
    x+=(long)1E9+7;
  return x;
}

int main(){
	int N, M;
	long int count=1L;
	cin >> N >> M;
	
	if(M==1 || N == 1) {
		cout << 1 <<endl;
		return 0;
	}
	
	int fac[10][2];
    fill(fac[0],fac[10], 0);
	int i=0;
	int tmp = M;
	while( (tmp &1) == 0){
		fac[0][0] = 2;
		fac[0][1]++;
		tmp >>= 1;
		i |=1;
	}
	
	int prime=3;
	while(tmp > 1) {
		if(tmp % prime == 0) {
			fac[i][0] = prime;
			fac[i][1]++;
			tmp /= prime;
		} else {
			if(fac[i][0] != 0 )
				i++;
			prime += 2;
		}
	}
	
  	for (int aaa =0; aaa <= i;aaa++) {
	  long int k = 1;
      
      for(int j = fac[aaa][1]+ N -1 ; j >= N; j--) {
		k *= (long)j;
        k %= (long)1E9+7;
        k *= extgcd((long)fac[aaa][1]--, (long)1E9+7);
        k %= (long)1E9+7; 
      }
      count *= k;
      count %= (long int)1E9+7;
    }
	cout << count << endl;
}



Measured memory_bytes: 256
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

ll gcd(ll a, ll b){
	if (a==0){
		return b;
	}else{
		return gcd(b%a, a);
	}
}


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll mi=1ll<<60, N, A[5];
	cin>>N;
	rep(i, 5)cin>>A[i];
	rep(i, 5)chmin(mi, A[i]);
	cout << 5 + (N-1)/mi << endl;


}








Measured memory_bytes: 256
n,m = map(int,input().split())
graph = {i:[] for i in range(n)}
ans = {i:-1 for i in range(n)}

for _ in range(m):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  graph[a].append(b)
  graph[b].append(a)
  
from collections import deque

queue = deque([(0,-1)])

while queue:
  node,parent = queue.popleft()
  for i in graph[node]:
    if i ==parent:
      continue
    elif ans[i] != -1:
      continue
    ans[i] = node
    queue.append((i,node))

for i in range(1,n):
  if ans[i] == -1:
    print('No')
    break
else:
  print('Yes')
  for i in range(1,n):
    print(ans[i]+1)

Measured memory_bytes: 56584
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int n;
	cin >> n;
	vector<double> arr(n,0);
	for(int i = 0;i < n;i++)
		cin >> arr[i];
	sort(arr.begin(),arr.end());
	double ans = (arr[0] + arr[1]) / 2;
	for(int i = 2;i < n;i++)
		ans = (ans + arr[i]) / 2;
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 256
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_B"
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> s(n);
    REP (i, n) {
        cin >> s[i];
    }
    int q; cin >> q;
    int cnt = 0;
    while (q --) {
        int t_i; cin >> t_i;
        cnt += binary_search(ALL(s), t_i);
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

long long int ps(long long int x , long long int n){
    if(n==0) return 1;
    if(n==1) return x ;
    if(n%2) return ((x* ps(x,n-1)));
    else {
        long long int z=ps(x,n/2);
        return (z*z) ;
    }
}

bool ssort(const pair<int,int> &a,
              const pair<int,int>  &b)
{
    return (a.first < b.first);
}
bool ssort3(const pair<int,int> &a,
              const pair<int,int>  &b)
{
    if(a.first == b.first) return (a.second < b.second);
    return (a.first < b.first);
}

long long int a,b,c,d,n,k,q;
string s,t;
#define mo 998244353

#define pair<int , int > pi

int main()
{
    IOS;
    cin >> n >> k >> q ;
    long long int t[n];
    memset(t,0,sizeof(t));
    for(int p=0;p<q;p++){
        cin >> a;
        t[a-1]+=1;
    }
    for(int p=0;p<n;p++) {
        if(t[p]+k-q>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }




}


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

int main()
{   int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int ans=0;
    for(int i=0;i<1000;i++){
        int first=i/100,sec=(i-i/100*100)/10,ff=0,fs=0,tert=i%10,ft=0;
        int mark=0;
    while(ft==0&&mark<n){
        if(ff==0&&s[mark]-'0'==first){
            ff=1;
        }else if(ff==1&&fs==0&&s[mark]-'0'==sec){
            fs=1;
        }else if(ff==1&&fs==1&&ft==0&&s[mark]-'0'==tert){
            ft=1;
        }
        mark++;
    }
    if(ft==1){
        ans++;
    }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;




void solve() {
    ll n ;
    cin >> n;
    ll dp[n][3];
    rep(i, 0, n) {
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
    }

    rep(i, 1, n) {
        dp[i][0] = dp[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = dp[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = dp[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }


    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;


}





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

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 5980
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    ll a,b;
    cin >> a >> b;

    cout << a*b/__gcd(a,b) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoder_practice1
{
    class _086D0
    {
        static void Main()
        {
            NewMethod();
        }

        private static void NewMethod()
        {
            int N, t_2, x_2, y_2, dt, dx, dy;
            int t_1 = 0;
            int x_1 = 0;
            int y_1 = 0;
            string str;
            string[] str_array;
            int count = 0;
            N = int.Parse(Console.ReadLine());


            while (N != count)
            {
                str = Console.ReadLine();
                str_array = str.Split(' ');
                t_2 = int.Parse(str_array[0]);
                x_2 = int.Parse(str_array[1]);
                y_2 = int.Parse(str_array[2]);

                dt = t_2 - t_1;
                dx = Math.Abs(x_2 - x_1);
                dy = Math.Abs(y_2 - y_1);

                if (((dx + dy) % 2 != dt % 2) || (dt < dx + dy))
                {
                    Console.Write("No");
                    return;
                }

                t_1 = t_2;
                x_1 = x_2;
                y_1 = y_2;

                count++;

            }
            Console.WriteLine("Yes");
            return;
        }
    }
}

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

int main() {
    int n, m;
     while (cin >> n >> m && (n || m)) {
         vector<pair<int, int>> dp;
         for (int i = 0; i < n; ++i) {
             int d, p; cin >> d >> p;
             dp.push_back(make_pair(p, d));
         }

         sort(dp.begin(), dp.end(), greater<pair<int, int>>());

         int s = 0;
         for (int i = 0; i < n; ++i) {
             s += dp[i].first*dp[i].second;
         }

         for (int i = 0; i < n; ++i) {
             int guarded = min(m, dp[i].second);
             s -= dp[i].first*guarded;
             m -= guarded;
          }

         cout << s << endl;
     }
}

Measured memory_bytes: 3132
import java.util.*;

class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int r,int s){
		r=root(r);
		s=root(s);
		if(r==s)
			return false;
		if(a[r]>a[s]){
			a[s]+=a[r];
			a[r]=s;
		}else{
			a[r]+=a[s];
			a[s]=r;
		}
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

public class Main{
	public static void main(String[] $){
		var s=new Scanner(System.in);

		var a=s.nextLine().split(" ");
		var n=Integer.parseInt(a[0]);
		var q=Integer.parseInt(a[1]);

		var uf=new UF(n);

		for(int i=0;i<q;++i){
			var b=s.nextLine().split(" ");
			var t=Integer.parseInt(b[0]);
			var u=Integer.parseInt(b[1]);
			var v=Integer.parseInt(b[2]);

			if(t==0)
				uf.connect(u,v);
			else
				System.out.println(uf.isConnected(u,v)?1:0);
		}
	}
}


Measured memory_bytes: 60888
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N, Y;
  cin >> N >> Y;
  bool flag = false;
  int res10000 = -1;
  int res5000 = -1;
  int res1000 = -1;
  for (int i = 0; i <= N; i++) {
  	for (int j = 0; j <= N; j++) {
      int k = N - i - j;
      if (i + j <= N && 10000 * i + 5000 * j + 1000 * k == Y) {
        flag = true;
        res10000 = i;
        res5000 = j;
        res1000 = k;
      }
      if (flag) break;
    }
    if (flag) break;
  }
  
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	if (K * 2 + N * 2 - 1 >= K + (N * 5 + 1) / 2) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int i;
	for (i = 0; i < (N + 1) / 2; i++) printf("%d %d %d\n", K + i * 2, K + N * 2 - 1 - i, K + N * 5 / 2 + i);
	for (i = 0; i < N / 2; i++) printf("%d %d %d\n", K + i * 2 + 1, K + N * 2 - (N + 1) / 2 - 1 - i, K + N * 2 + i);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2324
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String[] list = new String[N];
        output(0);
        list[0] = scan.next();
        if (is_finished(list[0])) {
            return;
        }
        output(N-1);
        list[N-1] = scan.next();
        if (is_finished(list[N-1])) {
            return;
        }
        int left = 0;
        int right = N - 1;
        while (left < right) {
            int mid = (left + right) / 2;
            output(mid);
            list[mid] = scan.next();
            if (is_finished(list[mid])) {
                break;
            }
            if (list[mid].equals(list[right]) &&  (right - mid) % 2 == 1) {
                left = mid;
                continue;
            }
            if (!list[mid].equals(list[right]) &&  (right - mid) % 2 == 0) {
                left = mid;
                continue;
            }
            right = mid;
        }
    }
    private void output(int x) {
        System.out.println(x);
        System.out.flush();
    }
    private boolean is_finished(String x) {
        return "Vacant".equals(x);
    }
}


Measured memory_bytes: 24384
#include <stdio.h>

int main(){

    char b, ans;

    scanf("%c", &b);


    if (b == 'A'){
        ans = 'T';
    }
    if (b == 'T'){
        ans = 'A';
    }
    if (b == 'C'){
        ans = 'G';
    }
    if (b == 'G'){
        ans = 'C';
    }

    printf("%c", ans);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( j = 1; j <= 9; ++j )
  {
    for ( i = 1; i <= 9; ++i )
    {
      printf ( "%dx%d=%d\n", j, i, j * i );
    }
  }


  return ( 0 );
}

Measured memory_bytes: 0
n=int(input())

xy=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        xx,yy=list(map(int,input().split()))
        xy[i].append([xx-1,yy])


ans=[0]
for ii in range(2**n): #1 is honest

    i=bin(ii)[2:].zfill(n)
    ok=True
    for nin in range(n):
        if int(i[-nin])==1:
            for x,y in xy[nin]:
                if y!=int(i[-x]):
                    ok=False
                    break
            if not ok:break
    if ok:
        ans.append(i.count('1'))
print(max(ans))

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

long long int N;

int main(void) {
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++) cin >> S[i];
  sort(S.begin(),S.end());
  long long int ans = 1;
  for (int i=1; i<N; i++){
    if (S[i].compare(S[i-1]) != 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9600
k=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
unchi=int(input())
print(k[unchi-1])

Measured memory_bytes: 3316
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, z, w;
	cin >> n >> z >> w;
	vi v(n);
	REP(i, n)cin >> v[i];
	int ans = abs(v[n - 1] - w);
	if (n != 1)ans = max(ans, abs(v[n - 1] - v[n - 2]));
	cout << ans << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    int num=0;
    int num_2=0;
    int pos=0;
    int ans=0;
    while(pos<N){
        num=pos;
        num_2=pos;
        while(A[num]<=A[num+1]){
            ++num;
        }
        
        while(A[num_2]>=A[num_2+1]){
            ++num_2;
        }
        pos=max(num,num_2)+1;
        ++ans;
    }
    cout << ans;
    }


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

const (
	MAX_V = 1000
)

type Thing struct {
	w, v int
}

func getMin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func getValue(i, v int) int {
	value1 := values[i-1][v]
	value2 := math.MaxInt64
	preValue := v - things[i].v
	if preValue >= 0 && values[i-1][preValue] != math.MaxInt64 {
		value2 = values[i-1][preValue] + things[i].w
	} else if preValue < 0 && v <= things[i].v {
		value2 = things[i].w
	}
	hoge := getMin(value1, value2)
	return hoge
}

var values [][]int
var N, W int
var things []Thing

func main() {
	fmt.Scan(&N, &W)
	things = make([]Thing, N)
	var w, v int
	for i := 0; i < N; i++ {
		fmt.Scan(&w, &v)
		things[i] = Thing{w: w, v: v}
	}
	max_v := N * MAX_V
	values = make([][]int, N)
	for i := 0; i < N; i++ {
		values[i] = make([]int, max_v+1)
	}
	values[0][0] = 0
	for v := 1; v <= max_v; v++ {
		if things[0].v >= v {
			values[0][v] = things[0].w
		} else {
			values[0][v] = math.MaxInt64
		}
	}

	for i := 1; i < N; i++ {
		for v := 0; v <= max_v; v++ {
			values[i][v] = getValue(i, v)
		}
	}

	max := 0
	for i := 0; i < N; i++ {
		for v := 0; v <= max_v; v++ {
			if values[i][v] <= W {
				if max < v {
					max = v
				}
			}
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 81536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(a+w<b||b+w<a)cout<<min(abs(b+w-a),abs(a+w-b))<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;

int main(int argc, char* argv[])
{
	LL A,B;
	cin>>A>>B;
	LL X=A+B;
	if (X%2==0){
		cout<<X/2<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char c;
  scanf("%c",&c);
  if(c=='C')
    printf("G\n");
  if(c=='G')
    printf("C\n");
  if(c=='A')
    printf("T\n");
  if(c=='T')
    printf("A\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1};
vector<int> y4 = {1, 0, -1, 0};
vector<int> x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


template<class T> struct edge { int from, to; T cost;};

int N,M; // 各々頂点数、辺数
const int MAX_N = 1000;
const int MAX_M = 2000;
const int INFC = 1000000000;
vector<int> d(MAX_N);   // 最短距離
vector<edge<int>> es(MAX_M); // 辺              // llにするときはここもllにしてくれ

// s番目の頂点から各頂点への最短距離を求める。但しtrueならアカン負の閉路が存在する
bool bellman_ford(int s){
  rep(i, N) d[i] = INFC;
  d[s] = 0;
  rep(vv, N-1){
    bool update = false;
    rep(i, M){
      auto e = es[i];
      if (d[e.from] != INFC && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
  rep(i, M){   // 離島、負の閉路について
    auto e = es[i];
    if (d[e.from] == INFC) continue;
    if (d[e.from] + e.cost < d[e.to]) return true;
  }
  return false;
}


int main() {
  cin >>N >>M;
  int s; cin >>s;
  rep(i, M){
    int a,b,d; cin >>a >>b >>d;
    es[i] = {a,b,d};
  }
  if (bellman_ford(s)) cout <<"NEGATIVE CYCLE" <<endl;
  else{
    rep(i, N){
      if (d[i] == INFC) cout <<"INF" <<endl;
      else cout <<d[i] <<endl;
    }
  }
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
int n,y;
int main()
{
	cin >> n >> y;
	int ok=0;
	if(y%1000)
	{
		cout << -1 << ' ' << -1 << ' ' << -1;
		return 0;
	}
	else y/=1000;
	for(int i=0; !ok&&i<=y/10; i++)
		for(int j=0; j<=y/5; j++)
			if((y-i*10-j*5)>=0 && (y-i*10-j*5)+i+j == n)
			{
				cout << i << ' ' << j << ' ' << (y-i*10-j*5);
				ok=1;
				break;
			}
	if(!ok) cout << -1 << ' ' << -1 << ' ' << -1;
	return 0;
}


Measured memory_bytes: 3608
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    x,n = mi()
    p = li()

    for i in range(100):
        if x-i not in p:
            print(x-i)
            exit()
        elif x+i not in p:
            print(x+i)
            exit()



main()




Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using R=double;


int main(void){
	ll N,K;
	cin >> N >> K;

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

    ll result = 0;

    for(int b = K; b <= N; b++){
        if(b == 0){
            continue;
        }
        result += (N/b)*(b-K);
        int amari = N%b;
        if(amari-K >= 0){
            result += amari+1-K;
        }
        //printf("b,res,amares : %d,%d,%d\n",b,(N/b)*(b-K),amari+1-K);
    }

    cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
			N = N % 100;
            N = N % 10;
          if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
          {
			Console.Write("hon");          
          }
          if(N == 0 || N == 1 || N == 6 || N == 8)
          {
			Console.Write("pon");          
          }
          if(N == 3)
          {
			Console.Write("bon");          
          }
        }
    }
}


Measured memory_bytes: 27540