akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector<int> rad[605];
long double bf[605],rl[605],tcnt[605];
int n,m;
long double gl(int now){
    if(rl[now]) return rl[now];
    long double trl = 0;
    for(int i=0;i<rad[now].size();++i){
        trl+=gl(rad[now][i])+1;
    }
    if(now==n) return 0;
    return rl[now] = trl/rad[now].size();
}
int main(){
    scanf("%d%d",&n,&m);
    int s,t;
    for(int i=0;i<m;++i){
        scanf("%d%d",&s,&t);
        rad[s].push_back(t);
    }
    gl(1);
    bf[1] = 1;
    for(int i=1;i<n;++i){
        long double tv = bf[i]/rad[i].size();
        for(int j=0;j<rad[i].size();++j)
            bf[rad[i][j]]+=tv;
    }
    long double ans = 0;
    for(int i=0;i<rad[1].size();++i){
        ans+=(1+rl[rad[1][i]]);
    }
    ans/=rad[1].size();
    long double df = 0;
    for(int i=1;i<=n;++i){
        if(rad[i].size()==1) continue;
        long double tsm = rl[i]*rad[i].size();
        for(int j=0;j<rad[i].size();++j){
            long double sdf = ((tsm-rl[rad[i][j]]-1)/(rad[i].size()-1)-tsm/rad[i].size())*bf[i];
            if(sdf<df) df = sdf;
        }
    }
    cout <<setprecision(25)<<fixed<<ans+df<<endl;
    return 0;
}


Measured memory_bytes: 5044
from collections import deque

S = input()
Q = int(input())

s = deque(S)

rev = False
for _ in range(Q):
    q = input().split()
    t = int(q[0])
    if t == 1:
        rev = not rev
    else:
        f, c = int(q[1]), q[2]
        if (f == 1 and not rev) or (f == 2 and rev):
            s.appendleft(c)
        else:
            s.append(c)

s = ''.join(s)
if rev:
    s = s[::-1]
print(s)

Measured memory_bytes: 76120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if (n < 1200){
			System.out.println("ABC");
		} else if (n < 2800){
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 22356
#include <stdio.h>
#include <string.h>
char a[60];
int ans,n;
int main()
{
  scanf("%d\n",&n);
  scanf("%s",a);
  int i,j,k;
  for(i=0;i<n-2;i++)
  {
    if(a[i]=='A')
    {
      if(a[i+1]=='B')
      {
        if(a[i+2]=='C')
          ans++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

const int maxn = 1e5+100;

int n,k,a[maxn],res;
vector<int> id;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    int id;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        if (a[i]==1) id = i;
    }
    cout<<(n+k-3)/(k-1)<<endl;
}


Measured memory_bytes: 640
// abc042_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if (v[0] == 5 && v[1] == 5 && v[2] == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  string S;
  cin >> S;
  int mod = 0, n = S.size();
  rep(i,n) {
    int s = S[i] -'0';
    mod = (mod+s)%9;
  }
  print(mod?"No":"Yes");
  return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <memory.h>
#include <string>

using namespace std;

typedef long long ll;

int a;
string s;
int main() {
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define _ sync_with_stdio(false)
typedef long long ll;
const int MAXN=100000+10;
const int INF=0x7fffffff;

int n,m;
string s[110];

int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<m+2;i++)
		cout<<"#";
	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<"#"<<s[i]<<"#"<<endl;
	}
	for(int i=0;i<m+2;i++)
			cout<<"#";
		cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;

void func(int W){
    for(int i = 0; i < W; i++)printf("#");
    printf("\n");
    return;
}

void Main(){
    int H, W;
    scanf("%d%d", &H, &W);
    func(W + 2);
    for(int i = 0; i < H; i++){
        string S;
        cin >> S;
        S = "#" + S + "#";
        cout << S << '\n';
    }
    func(W + 2);
    return;
}

int main(){
    cin.tie(0);
//  ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

vector<int> prime(int n)
{
    vector<bool> num;
    vector<int> p;

    for (int i = 0; i <= n + 10; i++)
        num.push_back(true);

    FOR(i, 2, n)
    {
        if (!num[i])
            continue;

        p.push_back(i);

        for (int j = i * 2; j <= n; j += i)
        {
            num[j] = false;
        }
    }

    return p;
}

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

    int x;

    cin >> x;

    V p = prime(1123456);

    for (int i : p)
    {
        if (x <= i)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, ii> pii;
const int MAX = 2e5+5;
char s[MAX];

int solve(int i, int j) {
	if(i >= j) return 0;
	if(s[i] == 'R') return solve(i+1, j);
	else if(s[j] == 'R') return solve(i+1, j-1)+1;
	return solve(i, j-1);
}

int main(int argc, char** argv) {
	int N; scanf("%d %s", &N, s);
	printf("%d\n", solve(0, N-1));
	return 0;
}


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

int l[201010], r[201010];

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    int cur = 1;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'o') {
            l[i] = cur++;
            i += C;
        }
        if (cur > K) break;
    }

    cur = K;
    for (int i = N - 1; i >= 0; --i) {
        if (S[i] == 'o') {
            r[i] = cur--;
            i -= C;
        }
        if (cur < 0) break;
    }

    for (int i = 0; i < N; ++i) {
        //cout << l[i] << ", " << r[i] << endl;
        if (l[i] > 0 and l[i] == r[i]) {
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3332
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);

        if (a > 9) return -1;
        if (b > 9) return -1;

        return a * b;
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans;
int a[100000+5];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        ans=ans+a[i]/2;
        a[i]=a[i]%2;
        if(i<n&&a[i]&&a[i+1])
        {
            ++ans;
            --a[i];
            --a[i+1];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	
	int cnt = 0;
	for (int i = d; i <= 100; i += d) {
		if (i >= l && i <= r)  cnt++;
	}
	
	cout << cnt << '\n';
	
	return 0;
}

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

typedef int integer;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define bs binary_search
#define up upper_bound
#define lw lower_bound
#define fs first 
#define sd second 
#define mp make_pair    

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())

#define infll 1e17
#define infi  2e9
#define int long long
#define endl '\n'
const ld pi = 2.14159265258979222846;
const ll mod = 1e9+7;


typedef pair<ll,ll> pr;

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

const int MAX_N = 500000;

int n,t;
int v[MAX_N],w[MAX_N];
int dp[101][100001];

int solve(int pos,int val){
	if(val<0)return infll;
	if(pos==n){
		if(val==0)return 0;
		else return infll; 
	}
	int &r = dp[pos][val];
	if(r!=-1)return r;
	r=0;
	r+=min(w[pos]+solve(pos+1,val-v[pos]),solve(pos+1,val));
	return r;
}


integer main(){FIN;
	cin>>n>>t;
	mm(dp,-1);
	fore(i,0,n)cin>>w[i]>>v[i];
	rfore(i,100001,0){int p = solve(0,i); if(p<=t){cout<<i;break;}}
	return 0;
}


Measured memory_bytes: 82176
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  int n,i;cin>>n;vint s(n);
  for(i=0;i<n;i++){cin>>s[i];}
  //caricurate
  ll ans=0;
  for(i=0;i<n;i++){
    ans+=s[i];
  }
  if(ans%10){cout<<ans<<endl;return 0;}
  int mi=-1;vsort(s);i=0;
  while(i<n){
   if(s[i]%10){mi=s[i];break;}
   i++;
  }
  if(mi==-1){cout<<0<<endl;return 0;}
  //output
  ans-=mi;cout<<ans<<endl;
}

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

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

    int n;
    cin>>n;

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

    int ans = 0;
    for (int i=1; i<=n; i++)
        if (a[a[i]] == i)
            ans++;

    cout<<ans/2<<endl;
}


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

int main()
{
  string s;
  
  cin >> s;
  
  if (s == "AAA" || s == "BBB")
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import copy
hwk = input('')
h = int(hwk.split(' ')[0])
w = int(hwk.split(' ')[1])
k = int(hwk.split(' ')[2])

clist = []
for i in range(h):
    clist.append(input())

cnt_all=0
for i in range(2**(h+w)):
    bag=[]
    clist2 = []
    for line in clist:
        clist2.append(line)
    for j in range(h+w):
        if ((i>>j)&1):
            if j < h:                
                # 行を選ぶ方
                bag.append("Y:{}".format(j))
                clist2[j] = 'R'*w
            else:
                # 列を選ぶ方
                bag.append("X:{}".format(j-h))
                for i2 in range(h):
                    line = list(clist2[i2])
                    line[j-h] ='R'
                    clist2[i2] = "".join(line)
    cnt = 0
    for c in clist2:
        cnt+=c.count('#')
    if cnt==k:
#        print(clist2)
        cnt_all+=1

print(cnt_all)

Measured memory_bytes: 9176
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  //ll A, B, C, D;
  //std::cin >> A >> B >> C >> D;
  //ll a, b, c, d;
  //std::cin >> a >> b >> c >> d;
  ll N, M, X;
  std::cin >> N >> M >> X;
  std::vector< ll > vc(N, 0LL);
  std::vector< std::vector<ll> > va(N, std::vector<ll>(M, 0LL) );
  for (ll i = 0; i < N; i++) {
    std::cin >> vc[i];
    for (ll j = 0; j < M; j++) {
      std::cin >> va[i][j];
    }
  }

  ll ans = INF;
  for (ll bit = 0; bit < (1 << N); bit++) {
    ll cost = 0LL;
    std::vector<ll> vx(M, 0LL);
    for (ll i = 0; i < N; i++) {
      if (((bit >> i) & 1) != 1) continue;

      cost += vc[i];
      for (ll j = 0; j < M; j++) {
        vx[j] += va[i][j];
      }
    }

    bool judge = true;
    for (ll j = 0; j < M; j++) {
      if (vx[j] < X) judge = false;
    }

    if (judge) ans = std::min(ans, cost);
  }

  print(ans == INF ? -1 : ans);
  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  solve();
  return 0;
}



Measured memory_bytes: 3672
from itertools import accumulate
n,m = map(int,input().split())
imos = [0]*(10**5+10)
for i in range(m):
    l,r = map(int,input().split())
    imos[l-1] += 1
    imos[r] -= 1
A = accumulate(imos)
cnt = 0
for a in A:
    if a == m:
        cnt += 1
print(cnt)


Measured memory_bytes: 4076
#include <cstdio>

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_e(i, x) for (int i = pos[x]; i; i = g[i].frt)

#define v g[i].y
#define NR 101000

struct Edge { int y, frt; } g[NR * 4];
int pos[NR], gsz, fa[NR], fb[NR], s[NR], w[NR], tp[NR];
int n, d[NR];
int vis[NR * 4];

void dfs(int x) {
	for (int &i = pos[x]; i; i = g[i].frt) if(vis[i >> 1] == 0) {		
		vis[i >> 1] = i;
	//	printf("%d->%d\n", x, v);
		dfs(v);
	}
}

void AE(int x, int y) { g[++gsz] = (Edge) { y, pos[x] }, pos[x] = gsz; }

int main() {
	scanf("%d", &n); gsz = 1;
	int root;
	iter(i, n) {
		scanf("%d", &fa[i]);
		if (fa[i] != -1)
			AE(i, fa[i]), AE(fa[i], i), ++d[fa[i]];
		else
			root = i;
	}

	int lim = gsz;

	iter(i, n) {
		scanf("%d", &fb[i]);
		if (fb[i] != -1)
			AE(i, fb[i]), AE(fb[i], i), ++d[fb[i]];
	}

	iter(i, n) if (d[i] % 2 != 0) { puts("IMPOSSIBLE"); return 0; }
	iter(i, n) tp[i] = pos[i];
	dfs(root);
	iter(i, n) pos[i] = tp[i];
	s[root] = -1;

	iter(x, n) {
		iter_e(i, x) if (i <= lim && v == fa[x]) s[x] = (vis[i >> 1] == i ? +1 : -1);//, printf("%d->%d %d\n", x, v, vis[i/2]);
	//	printf("%d ", s[x]);
	}
	
	

	puts("POSSIBLE");
	iter(x, n) {
		w[x] = s[x];
		iter_e(i, x) if (i <= lim && v != fa[x]) w[x] -= s[v];
		printf("%d ", w[x]);
	}
	puts("");

	//\sum X[p] = \sum X[q]

	return 0;
}

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

void solve(void){
  int P1, P2, N, tmp, ans; 
  int Pmax=0;
  int Pmin=0;
  
  cin >> N;
  
  int X[N];
  
  for (int i=0; i<N; i++){
    cin >> X[i];
    Pmax = max(Pmax, X[i]);
    Pmin = min(Pmin, X[i]);
  }
  P1 = Pmin - Pmax;
  P2 = Pmax + Pmin;
  
  ans = 100000000;
  
  for (int P = P1-1; P < P2+1; P++){
    tmp = 0;
    for (int j = 0; j < N; j++){
      tmp += (X[j]-P)*(X[j]-P);
    }
    ans = min(ans, tmp);
  }
  
  cout << ans << endl;
  
  return;
}

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

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

  solve();
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
    int  n,k;
    cin>>n;
    for(int i=1;i<=n;i++){
        if((i%3==0)||(i%10==3))cout<<" "<<i;
        else if(i/10!=0){
            k=i;
            for(;k>=1;){
            if((k/10)%10==3){
                cout<<" "<<i;
                break;
            }
            k=k/10;
            }
        }
    }
        
    cout<<endl;
}


Measured memory_bytes: 3072
n, m, k = map(int, input().split())
friendships = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  friendships[a-1].append(b-1)
  friendships[b-1].append(a-1)
blockships = [[] for _ in range(n)]
for _ in range(k):
  c, d = map(int, input().split())
  blockships[c-1].append(d-1)
  blockships[d-1].append(c-1)
# assign users (id) for connected component, according to friendships
# also increment a counter for size of each component
component_id = [-1]*n
component_size = dict()
stack_to_visit = [(node, node) for node in range(n)]
while stack_to_visit:
  node, parent_id = stack_to_visit.pop()
  if component_id[node] != -1:
    continue
  component_id[node] = parent_id
  component_size[parent_id] = component_size.get(parent_id, 0) + 1
  for other in friendships[node]:
    stack_to_visit.append((other, parent_id))
# calculate number of suggestions for each node
for node in range(n):
  suggestions = 0
  current_id = component_id[node]
  suggestions += component_size[current_id] - 1
  suggestions -= len(friendships[node])
  suggestions -= sum(int(component_id[other] == current_id) for other in blockships[node])
  print(suggestions, end=" ")

Measured memory_bytes: 138240
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	int bf=0,cnt=0,ans=0;
	FOR(i,0,n){
		int h;
		cin>>h;
		if(bf<h){
			ans=max(ans,cnt);
			cnt=0;
		}else{
			cnt++;
		}
		bf=h;
	}
	ans=max(ans,cnt);

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; ++i){
            p[i] = sc.nextInt();
        }
           
        int count = 0;   //カウント用の変数
        //条件を満たすものをカウント
        for (int i = 0; i < (n-2); ++i){ //要素数がn個の配列に対し、n-2回調べる
            if (p[i] < p[i+1] && p[i+1] < p[i+2] || p[i] > p[i+1] && p[i+1] > p[i+2]){
                ++count;
            }
        }
           
        //出力
        System.out.println(count);
        
    }
}


Measured memory_bytes: 35600
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		for(long i = -1000; i <= 1000; i++) {
			for(long j = -1000; j <= 1000; j++) {
				if(Math.pow(i, 5) - Math.pow(j, 5) == X) {
					System.out.println(i + " " + j);
					return;
				}
			}
		}
	}

}


Measured memory_bytes: 38956
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  input.shift();
  input.splice(N,input.length);
  var A = input.map(i => parseInt(i.split(" ")[0])).sort(function(a,b){return a-b;});
  var B = input.map(i => parseInt(i.split(" ")[1])).sort(function(a,b){return b-a;});
  if(N%2==0){
    var ans = ((B[N/2-1]+B[N/2])/2 - (A[N/2-1]+A[N/2])/2)/0.5+1;
  }else{
    var ans = (B[Math.floor(N/2)]-A[Math.floor(N/2)])+1;
  }


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 73260
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

const int MXV=100000;
vector<edge> G[MXV];
ll MX,MN;
int seen[MXV],plc[MXV];

void dfs(int v,int pa,int pl){
    chmax(MX,(ll)plc[v]);
    chmin(MN,(ll)plc[v]);
    seen[v]=1;
    rep(i,G[v].size()){
        if(seen[G[v][i].to]){
            if(G[v][i].cost+plc[v]!=plc[G[v][i].to]){
                cout << "No" << endl;
                exit (0);
            }
            else{
                continue;
            }
        }
        else{
            seen[G[v][i].to]=1;
            plc[G[v][i].to]=G[v][i].cost+plc[v];
            dfs(G[v][i].to,v,plc[G[v][i].to]);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    rep(i,N){
        seen[i]=0;
        plc[i]=0;
    }
    rep(i,M){
        int L,R,D;
        cin >> L >> R >> D;
        L--;R--;
        G[L].pb({R,D});
        G[R].pb({L,-D});
    }
    rep(i,N){
        if(!seen[i]){
            MX=-INF;MN=INF;
            dfs(i,-1,0);
            if(abs(MX-MN)>1000000000){
                cout << "No" << endl;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 20724
#include<bits/stdc++.h>
using namespace std;
#define lim 100000
int main(){
    int n,m,x,y;
    int num[lim+1];
    bool f[lim+1]={};
    fill(num,num+lim+1,1);
    f[1]=true;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        if(f[x])f[y]=true;
        num[x]--;num[y]++;
        if(num[x]==0)f[x]=false;
    }
    cout<<count(f,f+lim+1,true)<<endl;
}

Measured memory_bytes: 768
#include<stdio.h>

int fibonacci(int);

int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}
  
int fibonacci(int n){
  int F[45],i;

  F[0]=1;
  F[1]=1;

  for(i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];

  return F[n];
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main()
{
 int N,M;cin>>N>>M;
 int K[M][10];
 int detenai[N];
 for(int i = 0;i<N;i++) detenai[i] = -1;
 for(int i = 0;i<M;i++) for(int j=0;j<10;j++) K[i][j] = -1;
 
 for(int i = 0;i<M;i++){
   int kai;cin >> kai;
   for(int j = 0;j<kai;j++){
    int s; cin>>s;
    s = s-1;
    K[i][s] = 1;
    detenai[s]+= 1;
   }
 }
 int p[M];
 for(int i = 0;i<M;i++) cin>>p[i];
  
 int kotae=0;
 for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        int gg[M];
        for(int i = 0;i<M;i++) gg[i] = 0;
        for(int j= 0;j<M;j++){
          for (int i = 0; i < (int)S.size(); ++i) {
		    if(K[j][S[i]] == 1) gg[j]+= 1;
          }
        }
        int B[M];
        for(int i = 0;i<M;i++) B[i] = -1;
        for(int i = 0;i<M;i++){
          if(gg[i]%2 == p[i])B[i] = 1;
        }
        bool ike = true;
        for(int i = 0;i<M;i++){
          if(B[i] !=1) {
            ike = false;
            break;
          }
        }
      
        if(ike){
          kotae++;
        }
    }
   
   cout<<kotae;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;
    // スペース区切りの整数の入力
    int d,x;
    cin >> d >> x;
    int q = 0;
    for (int i = 0; i < n; i++) {
		int f;
                cin >>f;
         for (int j = 0; j < d; j = j+f ) {
                q =q+1 ;
	}    }
    // 出力
    cout << (q+x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

P p1[102],p2[102];
int n;

bool ok(int x,int y,int dx,int dy) {
    int ny=y+dy;
    int nx=x+dx;
    rep(i,n) {
        if(p1[i].fr==x&&p1[i].sc==y && p2[i].fr==nx&&p2[i].sc==ny) return false;
        if(p2[i].fr==x&&p2[i].sc==y && p1[i].fr==nx&&p1[i].sc==ny) return false;
    }

    return true;
}
void solve() {
    int gx,gy;
    cin>>gx>>gy;
    cin>>n;
    rep(i,n) {
        cin>>p1[i].fr>>p1[i].sc;
        cin>>p2[i].fr>>p2[i].sc;
    }
    int dp[20][20];
    rep(i,20) rep(j,20) dp[i][j]=0;
    dp[0][0]=1;
    rep(x,19) rep(y,19) {
        if(ok(x,y,1,0)) dp[x+1][y]+=dp[x][y];
        //else dp[x+1][y]=0;
        if(ok(x,y,0,1)) dp[x][y+1]+=dp[x][y];
        //else dp[x][y+1]=0;
    }
    int ans=dp[gx][gy];
    if(ans) cout<<ans<<endl;
    else cout<<"Miserable Hokusai!"<<endl;

}
int main() {
    int t;
    cin>>t;
    while(t-->0) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1160
N, L = list(map(int, input().split()))
aji = []
min_abs = 10000
min_i = -1
for i in range(N):
    ab = abs(L+i)
    if ab<min_abs:
        min_i = i
        min_abs = ab
    aji.append(L+i)
print(sum([a for i, a in enumerate(aji) if i!=min_i]))

Measured memory_bytes: 3060
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define int long long

#define pb push_back
#define ld long double

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int maxn=131072;

int n;

int a[maxn];

int s;

int32_t main()
{
  ios::sync_with_stdio(0);cin.tie(0);
  
  cin>>n;

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

  int m=a[0];

  a[n]=a[0];

  int d=((a[1]-a[0])%n+n)%n;
  int p=n*(n+1)/2;
  
  for(int i=0;i<n;i++)
    {
      s+=a[i];
      if(((a[i+1]-a[i])%n+n)%n!=d)
	{
	  cout<<"NO"<<endl;
	  return 0;
	}
      m=min(a[i],m);
    }

  if(s%p or m<(s/p) or (s/p)%n!=d)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;


  
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    char a[50];
    int N,i,s;
    while(scanf("%d%*c",&N)!=EOF)
    {
        s=0;
        for(i=0;i<N;i++)
            a[i]=getchar();
        for(i=0;i<N;i++)
        {
            if(a[i]=='A')
                if(a[i+1]=='B')
                    if(a[i+2]=='C')
                            s++,i+2;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
def even(d):
    return d // 2

def odd(A, B, N):
    if abs(A-1) > abs(B-N):
        dist2edge = abs(B-N)
        A += dist2edge
        B += dist2edge 

        return even(abs((A+1)- B)) + 1 + dist2edge

    else:
        dist2edge = abs(A - 1)
        A -= dist2edge
        B -= dist2edge
    
        return even(abs(A- (B-1))) + 1 + dist2edge


def main():
    N, A, B = map(int, input().split())
    diff = abs(A-B)

    if diff % 2 == 0:
        print(even(diff))
    else:
        print(odd(A, B, N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);
    int n = N;
    int sum=0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }

    if (N % sum == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import queue

q = queue.Queue()
N, M = map(int, input().split())

ans = [-1 for i in range(N+1)]
path = [[] for i in range(N+1)]

for i in range(M):
  A, B = map(int, input().split())
  path[A].append(B)
  path[B].append(A)
q.put(1)
COUNTER = 0
while not q.empty() :
  now = q.get()
  for p in path[now]:
    if ans[p]==-1:
      ans[p]=now
      q.put(p)
      #print(COUNTER, now,p)
      COUNTER+=1
      
print("Yes")
for i in ans[2:]:
  print(i)


Measured memory_bytes: 34868
import java.util.*;

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

        int[] times = new int[n];
        for(int i = 0; i < n; i++)
            times[i] = sc.nextInt();

        long total = 0;
        int start = 0;
        for(int i = 0; i < n; i++) {
          if(i == 0) {
              if(times[i] > t) {
                  total += t;
                  start = times[i];
              }
          } else {
              if(times[i] > times[i-1] + t) {
                total += times[i-1] - start + t;
                start = times[i];
              }
          }
          if(i == n - 1)
            total += times[i] - start + t;
        }

        System.out.println(total);
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int x, y, n;
    cin >> n;
    x = n * 800;
    y = (n / 15) * 200;
    cout << x - y << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
lint N;
struct  edge{lint to, cost;};
vector<vector<edge> > G;
vector<lint> color;

void dfs(lint now, lint ago, lint depth){
  if(depth % 2 == 0) color[now] = 1;
  else color[now] = 0;
  for(lint i = 0; i < G[now].size(); i++){
    edge e = G[now][i];
    if(e.to == ago) continue;
    dfs(e.to, now, depth + e.cost);
  }
}

signed main(){
	cin >> N;
	G.resize(N);
  color.resize(N);
	for(lint i = 1; i < N; i++){
		lint u, v, w; cin >> u >> v >> w;
		edge e = {v - 1, w}, e1 = {u - 1, w};
		G[u - 1].push_back(e); G[v - 1].push_back(e1);
	}
  dfs(0, -1, 0);
  for(lint i = 0; i < N; i++) cout << color[i] << endl;
}

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

int main(){
    int N,Y;

    cin >> N >> Y;

    for(int a=0;a <= N;++a){
        for(int b=0;a + b <= N;++b){
            int c = N - a - b;
            int total = 10000 * a + 5000 * b + 1000 * c;
            if(total == Y){
                printf("%d %d %d\n",a,b,c);
                return 0;
            }
        }
    }
        
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500+j*100+k*50:
                ans+=1
print(ans)

Measured memory_bytes: 3064
# import 周り
from fractions import gcd

# 定数関係
mod = 10 ** 9 + 7

# 補助関数
def inv(a):
    b, u, v = mod, 1, 0
    while b != 0:
        t = a // b
        a, b = b, a - t * b
        u, v = v, u - t * v
        if u < 0: u += mod
    return u

if __name__ == '__main__':
    #入力関係
    n = int(input())
    A = list(map(int, input().split()))

    V = 1
    U = 0
    for ele in A:
      V = V * ele // gcd(V, ele) # LCMを計算
      U += inv(ele)
    V %= mod
    print(U * V % mod)


Measured memory_bytes: 68696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
int N,C;
int D[55][55];
int c[555][555];
//cnt[i][c]: iにcが何個あるか
int cnt[10][55];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    cin>>N>>C;
    rep(i,C)rep(j,C){
        cin>>D[i][j];
    }
    rep(i,N)rep(j,N){
        cin>>c[i][j];
        cnt[(i+j+2) % 3][c[i][j]-1]++;
    }
    //色i,j,kに塗り直す
    ll ans = INFLL;
    rep(i,C)rep(j,C){
        if(i == j)continue;
        rep(k,C){
            if(i == k || j == k)continue;
            ll tmp = 0;
            rep(m, C){
                tmp += D[m][i] * cnt[0][m];
                tmp += D[m][j] * cnt[1][m];
                tmp += D[m][k] * cnt[2][m];
            }
            chmin(ans, tmp);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//map<int,int>mp;
vector<ll>v[N];
ll vis[N],ans;
set<ll>s;
void dfs(ll f)
{
    vis[f]=1;
    s.insert(f);
    for(ll x:v[f])
    {
        if(vis[x]==0)
        {
            dfs(x);
        }
    }
}
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>l>>r;
        v[l].pb(r);
        v[r].pb(l);
    }
    ans=0;
    for(i=1; i<=n; i++)
    {
        if(vis[i]==0)
        {
            s.clear();
            dfs(i);
            ans=max(ans,(ll)s.size());
        }
    }
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 34836
# ABC 98 B - cut and count
n = int(input())
s = input()

max_t = 0
for i in range(1, n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    t = len(s1.intersection(s2))
    max_t = max(max_t, t)
print(max_t)


Measured memory_bytes: 2940
arr = Array.new(10**5 + 1) { 1 }
arr[0] = arr[1] = 0

2.upto(316) do |i|
  next if arr[i] == 0

  (10**5 / i - 1).times { |j| arr[i * (j + 2)] = 0 }
end

arr2 = Array.new(10**5 + 1) { 0 }

(10**5 + 1).times do |i|
  arr2[i] = 1 if arr[i] == 1 && arr[(i + 1) / 2] == 1
end

cum = [0]
arr2.drop(1).each { |e| cum << e + cum[-1] }

q = gets.to_i

q.times do |i|
  l, r = gets.split.map(&:to_i)
  puts cum[r] - cum[l - 1]
end

Measured memory_bytes: 16924
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n = s.length();
    
    if(s[0]!='A'){
        cout<<"WA\n";
        return 0;
    }
    
    //cnt_C = 0;
    bool flag = false;
    for(int i=1;i<n;i++){
        if(i>=2 && i<=n-2){
            if(s[i]=='C'){
                if(!flag)   flag=true;
                else{
                    cout<<"WA\n";
                    return 0;
                }
            }
            else if(s[i]>=65 && s[i]<=90){
                cout<<"WA\n";
                return 0;
            }
        }

            else if(s[i]>=65 && s[i]<=90){
                cout<<"WA\n";
                return 0;
            }

    }
    if(!flag)   cout<<"WA\n";
    else        cout<<"AC\n";
    return 0;
}



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

int main() {
  int A,B,C;
  int goukei;
  int ans;
  cin >> A >> B >> C;
  goukei=B+C;
  if (A >= goukei) {
    std::cout << "0" << '\n';
  }else{
    ans = abs((B+C)-A);
    cout << ans << '\n';  
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

ll n, k;
vl values;

int dp[2][500001];

bool canWin(bool taro, ll missing) {
	if(dp[taro][missing] != -1) return dp[taro][missing];
	
	bool output;
	
	if(missing < values[0]) {
		output = false;
	} else {
		output = false;
		for(ll value : values) {
			if(missing - value < 0) continue;
			if(!canWin(!taro, missing - value)) {
				output = true;
				break;
			}
		}
	}
	
	dp[taro][missing] = output;
	return output;
}

int main(){
	cin.sync_with_stdio(0);
	cin >> n >> k;
	
	FOR(i, 0, 2) {
		FOR(j, 0, 500001) {
			dp[i][j] = -1;
		}
	}
	
	values = vl(n);
	FOR(i, 0, k) {
		cin >> values[i];
	}
	
	if(canWin(true, k)) cout << "First" << endl;
	else cout << "Second" << endl;
	
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
ll p[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	cin>>N>>A>>B;
	ll count1=0,count2=0,count3=0;
	rep(i,0,N){
		cin>>p[i];
		if(p[i]<=A)count1++;
		else if(p[i]>B)count3++;
		else count2++;
	}
	cout<<min(count1,min(count2,count3))<<endl;

	return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    int64_t count =0;
    cin >>n;
    
    map<string,int> s;
    for(int i=0;i<n;i++){
        string str;
        cin >>str;
        sort(str.begin(),str.end());
        count += s[str]++;
    }
    cout << count <<"\n";
}


Measured memory_bytes: 11264
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    string s; cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); i++) sum += s[i]-'0';
    cout << (sum%9 ? "No" : "Yes") << endl;
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


Measured memory_bytes: 3768
N,S=map(int,input().split())
A = list(map(int,input().split()))
mod=998244353
ans=[[0 for e in range(S+1)] for f in range(N+1)]
ans[0][0]=1
for i in range(N):
 for k in range(S+1):
  ans[i+1][k]=ans[i][k]*2
  ans[i+1][k]%=mod
 for j in range(A[i],S+1):
  ans[i+1][j]+=ans[i][j-A[i]]
  ans[i+1][j]%=mod
print(ans[N][S])

Measured memory_bytes: 147248
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define f first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
int isPrime(ll n)
{
    if(n<2)
    return 0;
    if(n==2)
    return 1;
    for(ll i=2;i*i<=n;i++)
    if(n%i==0)
    return 0;
    return 1;
}
void solve()
{
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    int c=1;
    for(ll i=1;i*i<=g;i++)
    {
        if(g%i==0)
        {
            if(isPrime(i)){
            c++;}
            if(isPrime((g/i))){
            c++;}
        }
    }
    //cout<<endl;
    cout<<c<<endl;
}
int main()
{
    solve();
}

Measured memory_bytes: 256