akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//


int main() {

	fast_cin();

		ll x, y;
		
		cin>> x>> y;
		
		cout << (x * y) / __gcd(x, y) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, b=0;
  cin >>N;
  vector<long long> A(N,0), B(N,0);
  for(int i=0; i<N; i++){
    long long a;
    cin >>a;
    b+=a;
    A[i]=a;
    B[i]=b;
  }
  long long ans=1e15;
  for(int i=0; i<N-1; i++){
    ans=min(abs(B[N-1]-2*B[i]), ans);
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 3328
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            print('No')
            quit()
    else:
        if s[i] == 'R':
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n + 1);
    loop(i, n + 1) cin >> a[i];
    if (a[0] != 0)
    {
        if (n == 0)
        {
            if (a[0] == 1)
            {
                putout(1);
                return 0;
            }
        }
        putout(-1);
        return 0;
    }
    vec up(n + 1);
    ll maxx = Sum(a);
    loop(i, n + 1)
    {
        up[i] = maxx;
        maxx -= a[i];
    }
    vec b(n + 1);
    ll now = 1;
    b[0] = 1;
    Loop(i, 1, n + 1)
    {
        if (i == n && (b[i - 1] - a[i - 1]) * 2 < up[i])
        {
            putout(-1);
            return 0;
        }
        b[i] = min((b[i - 1] - a[i - 1]) * 2, up[i]);
        if (b[i] <= 0)
        {
            putout(-1);
            return 0;
        }
    }
    putout(Sum(b));
}


Measured memory_bytes: 5556
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var A = cin.ReadLongArray(N);
			Console.WriteLine(A.Where((x, i) => x%2!=0&&i%2==0).Count());
		}

	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
	
}


Measured memory_bytes: 28284
#include <stdio.h>
int main(void)
{
    int dice[7],q,i,fr,bt,ri;
    
    for(i=1;i<=6;i++)
    {
        scanf("%d",&dice[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
        scanf("%d %d",&bt,&fr);
        if(bt==dice[1])
        {
            if(fr==dice[2]) ri=dice[3];
            else if(fr==dice[3]) ri=dice[5];
            else if(fr==dice[4]) ri=dice[2];
            else if(fr==dice[5]) ri=dice[4];
            printf("%d\n",ri);
        }
        else if(bt==dice[2])
        {
            if(fr==dice[1]) ri=dice[4];
            else if(fr==dice[3]) ri=dice[1];
            else if(fr==dice[4]) ri=dice[6];
            else if(fr==dice[6]) ri=dice[3];
            printf("%d\n",ri);
        }
        else if(bt==dice[3])
        {
            if(fr==dice[1]) ri=dice[2];
            else if(fr==dice[2]) ri=dice[6];
            else if(fr==dice[5]) ri=dice[1];
            else if(fr==dice[6]) ri=dice[5];
            printf("%d\n",ri);
        }
        else if(bt==dice[4])
        {
            if(fr==dice[1]) ri=dice[5];
            else if(fr==dice[2]) ri=dice[1];
            else if(fr==dice[5]) ri=dice[6];
            else if(fr==dice[6]) ri=dice[2];
            printf("%d\n",ri);
        }
        else if(bt==dice[5])
        {
            if(fr==dice[1]) ri=dice[3];
            else if(fr==dice[3]) ri=dice[6];
            else if(fr==dice[4]) ri=dice[1];
            else if(fr==dice[6]) ri=dice[4];
            printf("%d\n",ri);
        }
        else if(bt==dice[6])
        {
            if(fr==dice[2]) ri=dice[4];
            else if(fr==dice[3]) ri=dice[2];
            else if(fr==dice[4]) ri=dice[5];
            else if(fr==dice[5]) ri=dice[3];
            printf("%d\n",ri);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C, D, N, M;
	string S, T;


	cin >> A;

	cout << (A + A % 2) / 2 << endl;




	return 0;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------

int n;
int p[5010];

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

	cin >> n;
	REP(i, n) cin >> p[i];

	int ans = INF;
	REP(l, p[0] + 1) {
		REP(r, p[n - 1] + 1) {
			int P[5010], cnt[5010] = {};
			REP(i, n) P[i] = p[i];
			P[0] -= l, P[n - 1] -= r;
			int sum = l + r;
			REP(i, n - 1) {
				if (cnt[i] < P[i]) {
					sum += 2 * (P[i] - cnt[i]);
					cnt[i + 1] += P[i] - cnt[i];
				}
			}
			if (cnt[n - 1] < P[n - 1]) sum += P[n - 1] - cnt[n - 1];
			ans = min(ans, sum);
			REP(i, n) cnt[i] = 0;
			sum = l + r;
			for (int i = n - 1; i > 0; i--) {
				if (cnt[i] < P[i]) {
					sum += 2 * (P[i] - cnt[i]);
					cnt[i - 1] += P[i] - cnt[i];
				}
			}
			if (cnt[0] < P[0]) sum += P[0] - cnt[0];
			ans = min(ans, sum);
		}
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3296
n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, (n-1)//2+1):
	res = 0
	l, r = i, n-1-i
	while r > i and l != r and l != r+i:
		res += s[l] + s[r]
		ans = max(ans, res)
		l += i
		r -= i
print(ans)

Measured memory_bytes: 14860
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    string s,t;cin >> s >> t;
    int ls = s.size();
    int lt = t.size();
    int ans = lt;
    REP(i,ls-lt+1){
        int tmp=0;
        REP(j,lt){
            if(s[i+j]==t[j])tmp++;
        }
        ans=min(ans,lt-tmp);
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc177/tasks/abc177_b

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

const int INF = 1001001001;

int main() {
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = INF;
    for (ll i = 1; i < h; i++) {
        ll a = i * w;
        if ((h - i) % 2 == 0 || w % 2 == 0) ans = min(ans, abs(a - (h - i) * w / 2));
        else {
            ll b = (h - i) * (w / 2), c = (h - i) * w - b;
            ll maxs = max({ a, b, c }), mins = min({ a, b, c });
            ans = min(ans, maxs - mins);
            b = ((h - i) / 2) * w, c = (h - i) * w - b;
            maxs = max({ a, b, c }), mins = min({ a, b, c });
            ans = min(ans, maxs - mins);
        }
    }
    for (ll i = 1; i < w; i++) {
        ll a = i * h;
        if (h % 2 == 0 || (w - i) % 2 == 0) ans = min(ans, abs(a - h * (w - i) / 2));
        else {
            ll b = (h / 2) * (w - i), c = h * (w - i) - b;
            ll maxs = max({ a, b, c }), mins = min({ a, b, c });
            ans = min(ans, maxs - mins);
            b = h * ((w - i) / 2), c = h * (w - i) - b;
            maxs = max({ a, b, c }), mins = min({ a, b, c });
            ans = min(ans, maxs - mins);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
start = time.time()

N = int(readline())
A = [[int(x) - 1 for x in row.split()] for row in readlines()]


ids = [[0 for j in range(1005)] for i in range(1005)]
V = 0
for i in range(N):
    for j in range(i, N):
        ids[i][j] = V
        V += 1

MAXV = 1005 * 1005 // 2

visited = [False for i in range(MAXV)]
calculated = [False for i in range(MAXV)]
dp = [0 for i in range(MAXV)]

def dfs(v):
    if visited[v]:
        if not calculated[v]:
            print(-1)
            exit()

        return dp[v]

    visited[v] = True
    dp[v] = 1
    for u in to[v]:
        dp[v] = max(dp[v], dfs(u) + 1)

    calculated[v] = True
    return dp[v]

to = [[] for i in range(MAXV)]
for i in range(N):
    for j in range(N - 1):
        a = i
        b = A[i][j]
        if a > b:
            a, b = b, a
        A[i][j] = ids[a][b]
    for j in range(N - 2):
        to[A[i][j + 1]].append(A[i][j])

ans = 0
for i in range(V):
    ans = max(ans, dfs(i))

print(ans)
elapsed_time = time.time() - start
# print(elapsed_time)

Measured memory_bytes: 173144
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

ll dp[1003][1003];
string ar[1003];
ll n,mm,x,y,a,b,ans=-1;
//vector<ll> ans;
/*
void fun(ll i,ll j,ll m)
{
	if(i>=n || i<0 || j>=mm || j<0 || ar[i][j]=='#') return ;
	//cout<<i+1<<" "<<j+1<<" "<<m<<"\n";
	//if(i+1==4 and j+1==1) cout<<m;
	if(i==a-1 and j==b-1) {
		ans.pb(m);
		return;
	}
	if(m>dp[i][j]) return;
	dp[i][j]=m;
	fun(i+1,j,m);
	fun(i-1,j,m);
	fun(i,j+1,m);
	fun(i,j-1,m);
    for(ll ii=i-2;ii<=i+2;ii++)
    for(ll jj=j-2;jj<=j+2;jj++)
    	fun(ii,jj,m+1);
}
*/
struct inc{
bool operator()(pair<ll,pi> a,pair<ll,pi>b)
   {
    return a.s.s>b.s.s;
   }
 };
bool valid(ll i, ll j)
{
	return (i<n and j<mm and i>-1 and j>-1);
}
void bfs(ll i,ll j,ll m)
{
 priority_queue<pair<ll,pi>, vector<pair<ll,pi>>,inc > q;
 pair<ll,pi> node,val;
 q.push(mp(i,mp(j,0ll)));
 //dp[i][j]=1;
 ll xx,yy;
 while(!q.empty())
 {
     node=q.top();
     q.pop();
     i=node.f;
     j=node.s.f;
     m=node.s.s;
   if(i==a-1 and j==b-1)
    {
      ans=m;
      break;
    	//ans.pb(m);
    	//continue;
    }
    if(dp[i][j]) continue;
    dp[i][j]=1;
    //cout<<i+1<<" "<<j+1<<" "<<m<<"\n";
    xx=i+1,yy=j;
    if(valid(xx,yy) and ar[xx][yy]=='.')
    {
    	//dp[xx][yy]=1;
    	q.push(mp(xx,mp(yy,m)));
    }
    xx=i-1,yy=j;
    if(valid(xx,yy) and ar[xx][yy]=='.')
    {
    	//dp[xx][yy]=1;
    	q.push(mp(xx,mp(yy,m)));
    }
    xx=i,yy=j+1;
    if(valid(xx,yy) and ar[xx][yy]=='.')
    {
    	//dp[xx][yy]=1;
    	q.push(mp(xx,mp(yy,m)));
    }
    xx=i,yy=j-1;
    if(valid(xx,yy) and ar[xx][yy]=='.')
    {
    	//dp[xx][yy]=1;
    	q.push(mp(xx,mp(yy,m)));
    }
    
    for(ll ii=i-2;ii<=i+2;ii++){
    for(ll jj=j-2;jj<=j+2;jj++)
    {
    xx=ii,yy=jj;
    if(valid(xx,yy) and ar[xx][yy]=='.')
    {
    	//dp[xx][yy]=1;
    	q.push(mp(xx,mp(yy,m+1)));
    }
    }
    }
    
 }
}
int main()
{

  //for(ll i=0;i<1000;i++)
  //for(ll j=0;j<1000;j++) dp[i][j]=10000000000000ll;
  fast;
  cin>>n>>mm>>x>>y>>a>>b;
  for(ll i=0;i<n;i++) cin>>ar[i];
  //fun(x-1,y-1,0);
  	bfs(x-1,y-1,0);
    cout<<ans;
  /*
   priority_queue<pair<ll,pi>, vector<pair<ll,pi>>,inc > qq;
   pair<ll,pi> aa;
   qq.push(mp(1,mp(2,0)));
  qq.push(mp(1,mp(3,1)));
  aa=qq.top();
  cout<<aa.f<<" "<<aa.s.f;
  */
}


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

// #include <atcoder/>

using namespace std;

class DisjointSet {
 private:
  class Node {
    friend DisjointSet;

    std::size_t parent;
    std::size_t size;

    Node(const std::size_t parent, const std::size_t size) : parent(parent), size(size) {}
  };

  std::vector<Node> nodes;

 public:
  explicit DisjointSet(const std::size_t n) : nodes(n, Node(n, 1)) {}

  std::size_t size() const { return nodes.size(); }

  std::size_t size(const std::size_t x) { return nodes[root(x)].size; }

  std::size_t root(const std::size_t x) {
    if (nodes[x].parent == size()) return x;
    return nodes[x].parent = root(nodes[x].parent);
  }

  bool is_same(const std::size_t x, const std::size_t y) { return root(x) == root(y); }

  bool unite(const std::size_t x, const std::size_t y) {
    std::size_t rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (nodes[rx].size < nodes[ry].size) std::swap(rx, ry);
    nodes[rx].size += nodes[ry].size;
    nodes[ry].parent = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  DisjointSet ds(N);
  {
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](int a, int b) { return X[a] < X[b]; });
    int pos = 0;
    for (int i = 0; i < N; i++) {
      int a = idx[pos], b = idx[i];
      if (Y[a] > Y[b]) pos = i;
      if (X[a] < X[b] && Y[a] < Y[b]) ds.unite(a, b);
    }
    reverse(idx.begin(), idx.end());
    pos = 0;
    for (int i = 0; i < N; i++) {
      int a = idx[pos], b = idx[i];
      if (Y[a] < Y[b]) pos = i;
      if (X[a] > X[b] && Y[a] > Y[b]) ds.unite(a, b);
    }
  }
  {
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](int a, int b) { return Y[a] < Y[b]; });
    int pos = 0;
    for (int i = 0; i < N; i++) {
      int a = idx[pos], b = idx[i];
      if (X[a] > X[b]) pos = i;
      if (X[a] < X[b] && Y[a] < Y[b]) ds.unite(a, b);
    }
    reverse(idx.begin(), idx.end());
    pos = 0;
    for (int i = 0; i < N; i++) {
      int a = idx[pos], b = idx[i];
      if (X[a] < X[b]) pos = i;
      if (X[a] > X[b] && Y[a] > Y[b]) ds.unite(a, b);
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ds.size(i) << '\n';
  }
  return 0;
}


Measured memory_bytes: 8892
import heapq as hq
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a_mi = [a[i]*(-1) for i in range(len(a))]
hq.heapify(a_mi)
for i in range(m):
    ai = hq.heappop(a_mi)
    hq.heappush(a_mi,((-1)*ai//2)*(-1))
ans = [hq.heappop(a_mi) for i in range(len(a_mi))]
print(sum(ans)*(-1))

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;

ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){ 
      a=b; 
      b=r; 
      r=a%b; 
    }
    return b;
}

int main(){
  ll n,x;cin>>n>>x;
  cout<<3*(n-gcd(n,x))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,ans=0;
  cin>>n;
  int a[n];
  rep(i,n){
    cin>>a[i];
  }
  map<int,int> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  for(auto p: mp){
    if(p.second%2!=0){
      ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <functional>
#include <sstream>

using namespace std;

int main()
{
    string s;
    string t;
    int check;
    int pip = 0;
    
    cin >> s;
    cin >> t;
    
    int ss = (int)s.size();
    int st = (int)t.size();
    
    string ans;
    
    for (int i = 0;i < ss;i++){
        ans += 'z';
    }
    
    for (int i = 0;i <= ss-st;i++){
        string res = s;
        check = 1;
        for (int j = 0;j < i;j++){
            if (res[j] == '?'){
                res[j] = 'a';
            }
        }
        for (int j = 0;j < st;j++){
            if (res[i+j] == '?'){
                res[i+j] = t[j];
            }
            else if (res[i+j] != t[j]){
                check = 0;
            }
        }
        for (int j = st+i;j < ss;j++){
            if (res[j] == '?'){
                res[j] = 'a';
            }
        }
        if (check && res.compare(ans) <= 0){
            ans = res;
            pip = 1;
        }
     }
    
    if (pip){
        cout << ans << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
using namespace std;
#define LL long long
#define mod 998244353
const int NN=1000000+117;
LL fact[NN]={};
LL rev[NN]={};
LL comp(int m,int n){
	return fact[n]*rev[m]%mod*rev[n-m]%mod;
}
LL ksm(LL a,LL b){
	LL ret=1;
	while(b){
		if(b&1){
			(ret*=a)%=mod;
		}
		(a*=a)%=mod;
		b>>=1;
	}
	return ret;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int top=n+m;
	fact[0]=1;
	for(int i=1;i<=top;++i)
		fact[i]=fact[i-1]*i%mod;
	rev[top]=ksm(fact[top],mod-2);
	for(int i=top;i>=1;--i)
		rev[i-1]=rev[i]*i%mod;
	if(n<m)m^=n^=m^=n;
	LL ans=0;
	for(int i=1;i<=m;++i){
		ans+=comp(i,2*i)*comp(m-i,n+m-2*i)%mod;
		ans%=mod;
	}
	ans=ans*rev[2]%mod*rev[m+n]%mod*fact[n]%mod*fact[m]%mod;
	ans+=n;
	ans%=mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli maeSum[200200];
lli ushiSum[200200];

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(3*n);
	REP(i,0,3*n)cin>>a[i];

	priority_queue<lli> ushi;
	priority_queue<lli,vector<lli>,greater<lli>> mae;

	lli msum=0;
	lli usum=0;
	REP(i,0,n){
		msum+=a[i];
		usum += a[3*n-1-i];
		maeSum[i]=msum;
		ushiSum[3*n-1-i]=usum;
		mae.push(a[i]);
		ushi.push(a[3*n-1-i]);
	}

	if(DEBUG)cout<<msum<<" "<<usum<<endl;

	for(lli i=n;i<2*n;i++){
		if(mae.top()<a[i]){
			msum += a[i];
			msum -= mae.top();
			mae.pop();
			mae.push(a[i]);
		}
		maeSum[i]=msum;
	}

	for(lli i=2*n-1;i>=n;i--){
		if(ushi.top()>a[i]){
			usum+=a[i];
			usum-=ushi.top();
			ushi.pop();
			ushi.push(a[i]);
		}
		ushiSum[i]=usum;
	}
	lli ans = -INF;

	REP(i,0,3*n+1){
		if(DEBUG)cout<<"i="<<i<<" maeSum[i]="<<maeSum[i]<<" ushiSum[i]="<<ushiSum[i+1]<<endl;
	}
	for(lli i=n-1;i<2*n;i++){
		if(DEBUG)cout<<"i="<<i<<" maeSum[i]="<<maeSum[i]<<" ushiSum[i]="<<ushiSum[i+1]<<endl;
		ans = max(ans,maeSum[i]-ushiSum[i+1]);
	}
	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 6764
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{

        //入力
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        boolean[] sign = new boolean[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
            sign[i] = false;
        }


        // 出力
        int ans = 0;
        int i = 0;
        while(true){
            if(sign[i]){
                System.out.println(-1);
                break;
            }
            else if(i == 1){
                System.out.println(ans);
                break;
            }
            sign[i] = true;
            i = a[i] - 1;
            ans++;
        }
    }
}

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

#define N 55555

int main(void){
    vector<bool> prime(N+1, true);
    prime.at(0) = false;
    prime.at(1) = false;
    
    for(int i=2; i<=N; i++){
        int k = 2*i;
        while(k <= N){
            prime.at(k) = false;
            k += i;
        }
        if(i*i > N){
            break;
        }
    }

    int n;
    cin >> n;

    vector<int>vec;
    int p = 11;
    while(p <= N && vec.size() < n){
        if(prime.at(p)){
            vec.push_back(p);
        }
        p += 5;
    }

    for(int i=0; i<vec.size(); i++){
        cout << vec.at(i) << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0)return 1;
    else if(n%2 == 1)return EX(x,n-1)*x%mod;
    else return EX(x*x%mod,n/2)%mod;
};

int main(){
    int x;
    cin >> x;
    int ans = 0;
    for(int i = 1; i*i <= x; i++){
        for(int j = 2; j < 10; j++){
            if(ans < EX(i,j) && EX(i,j) <= x) ans = EX(i,j);
            if(EX(i,j) > x) break;
        }
    }    
    cout << ans << endl;
}

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

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

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,c; cin >> a >> b >> c; bool flag = true;
  ll ans = 0;
  
  while(flag){
    if(a == b && b == c && c == a && a % 2 == 0 && b % 2 == 0 && 
      c % 2 == 0){
      ans = -1;
      flag = false;
      break;
    }
    else if(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
      ans++;
      ll ad,bd,cd; ad = a; bd = b; cd = c;
      a = (bd+cd)/2; b = (ad+cd)/2; c = (ad+bd)/2;
    }
    else flag = false;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char S[5];
  int c=0;
  char A[2][6]={"Good","Bad"};
  
  scanf("%s",S);
  for(int i=0;i<3;i++)
    if(S[i]==S[i+1]) c=1;
  
  printf("%s\n",A[c]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  
  ll n,m;
  ci(n>>m);
  vll A(m+1);
  FOR(i,0,m){
    ci(A[i])
  }
  vll dp(1001000);
  ll now=0;
  dp[0]=1;
  
  if(A[now]==1){
    dp[1]=0;
    now++;
  }
  else{
  dp[1]=1;
  }
  
  FOR(i,2,n+1){
    if(A[now]==i){
      now++;
      dp[i]=0;
    }
    else{
      dp[i]+=dp[i-1]+dp[i-2];
    }
    dp[i]%=1000000007;
  }
  co(dp[n])
}

Measured memory_bytes: 8832
using System;
using System.Collections.Generic;

class ABC_123_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int X = int.Parse(input[0]);
        int Y = int.Parse(input[1]);
        int Z = int.Parse(input[2]);
        int K = int.Parse(input[3]);

        long[] A = new long[X];
        long[] B = new long[Y];
        long[] C = new long[Z];

        string[] stringA = Console.ReadLine().Split(' ');
        for (int i = 0; i < X; i++)
        {
            A[i] = long.Parse(stringA[i]);
        }
        string[] stringB = Console.ReadLine().Split(' ');
        for (int i = 0; i < Y; i++)
        {
            B[i] = long.Parse(stringB[i]);
        }
        string[] stringC = Console.ReadLine().Split(' ');
        for (int i = 0; i < Z; i++)
        {
            C[i] = long.Parse(stringC[i]);
        }

        List<long> result = new List<long>();

        Array.Sort(A);
        Array.Reverse(A);
        Array.Sort(B);
        Array.Reverse(B);
        Array.Sort(C);
        Array.Reverse(C);

        for (int i = 0; i < X; i++)
        {
            for (int j = 0; j < Y; j++)
            {
                if (i * j > K) break;
                for (int k = 0; k < Z; k++)
                {
                    if (i * j * k> K) break;
                    result.Add(A[i] + B[j] + C[k]);
                }
            }
        }

        result.Sort();
        result.Reverse();

        for (int i = 0; i < K; i++)
        {
            Console.WriteLine(result[i]);
        }
    }
}


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

if n == 0 or n % 2 == 1:
    ans = 0
else:
    k = n//2
    for i in range(1, 10**100):
        if k//(5**i) == 0:
            break
        ans += k//(5**i)
print(ans)

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var x=new int[]{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};
          	var y=int.Parse(Console.ReadLine());
          
          	var z=x[y-1];
          	Console.WriteLine(z);
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>


int main(void)
{
	char s[1000+2];
	int w;

	while(scanf("%1000[a-z]%d\n", s, &w)==2)
	{
		for(int i=0;s[i];i++)
		{
			if(i%w==0) printf("%c", s[i]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 128
import sys
input=sys.stdin.readline
n,k = map(int, input().split())
a = list(map(int, input().split()))
soa = sorted(a)
import bisect
ans=0
for i in range(len(a)):
    cnt = bisect.bisect_left(soa,a[i])
    slf=0
    for j in range(i,len(a)):
        if a[i] > a[j]:
            slf+=1
    sm = k*(k-1)*cnt // 2 + slf*k
    ans+=sm
mod=10**9+7
print(ans%mod)

Measured memory_bytes: 42348
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    int a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    for(int i=0;i<=d;i+=a){
        for(int j=0;j<=d;j+=b){
            if((d-i-j)%c==0 && (d-i-j)>=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a < 9 && b < 9) System.out.println("Yay!");
      else System.out.println(":(");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n, m, c; cin >> n >> m >> c;
	vector<int> B;
	int res = 0;
	for (int i = 0; i < m; i++) {
		int b; cin >> b;
		B.push_back(b);
	}

	for (int i = 0; i < n; i++) {
		int tmp = 0;
		int a;
		for (int j = 0; j < m; j++) {
			cin >> a;
			tmp += B[j] * a;
		}
		tmp += c;
		if (tmp > 0) res++;
	}

	cout << res << endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            map.compute(a, (key, value) -> value == null ? 1 : value + 1);
        }

        int res = 0;
        List<Integer> list = new ArrayList<>(map.values());
        Collections.sort(list);
        for (int i = 0; i < list.size() - k; i++) {
            res += list.get(i);
        }
        System.out.println(res);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 101860
# HとWに整数型で行数、列数を代入
H, W = map(int, input().split())
# print(H, W)
c = []

# for分で列をリスト化して代入
for i in range(H):
    s = list(input())
    c.append(s)

# print(c)
# count変数を初期化
count = 0

# for文でcの各要素を調べて'#'の場合、上下左右に'#'があるかどうか調べる
for i in range(H):
    for j in range(W):
        # pythonではリストの範囲外を指定するとエラーが発生するので、try except で回避する
        try:
            if (c[i][j] == '#' and c[i][j-1] != '#' and c[i-1][j] != '#' and c[i][j+1] != '#' and c[i+1][j] != '#'):
                # 問題文にそぐわない並びをしていたら、countに足す
                count += 1
        except IndexError:
            if i == W - 1 and i == H - 1:
                if (c[i][j] == '#' and c[i][j-1] != '#' and c[i-1][j] != '#'):
                    count += 1

            elif i == W - 1:
                if (c[i][j] == '#' and c[i][j-1] != '#' and c[i-1][j] != '#' and c[i+1][j] != '#'):
                    count += 1

            elif i == H - 1:
                if (c[i][j] == '#' and c[i][j-1] != '#' and c[i-1][j] != '#' and c[i][j+1] != '#'):
                    count += 1

if count == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
using System;

namespace ABC096_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            if(a == b)
            {
                Console.WriteLine(a);
            }else if(a > b)
            {
                Console.WriteLine(a - 1);
            }else if(a <= b)
            {
                Console.WriteLine(a);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
#define int         long long 
#define ll          long long 
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        300005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
int power(int a,int n){
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a),n/2)));
    return power((a*a),n/2);
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
} 

void solve(){
    int n;
    cin >> n;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    int yen = 1000;
    FOR(i,1,n+1){
        if(v[i+1] >= v[i]){
            int stocks = yen/v[i];
            yen -= v[i]*stocks;
            while(i+1 <= n && v[i+1] >= v[i])++i;
            yen += stocks*v[i];
        }
    }
    cout << yen << "\n";
}       
 
signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll n; cin >> n;
    vector<ll> ans(n);
    rep(i, n) {
        ll a; cin >> a;
        ans[a-1] = i+1;
    }
    rep(i, n) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
tbl = set()
q = int(input())
for i in range(q):
	a = input().split()
	x = int(a[1])
	if a[0] == '0':
		tbl.add(x)
		print(len(tbl))
	elif a[0] == '1': print(1 if x in tbl else 0)
	else:
		if x in tbl: tbl.remove(x)



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

int main(){
    int i, j, k, l, n, b, f, r, v;
    int h[4][3][10] = {};

    cin >> n;
    for(i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        h[b-1][f-1][r-1] += v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                cout << " " << h[i][j][k];
            }
            cout << endl;
        }
        if(i!=3)cout << "####################" << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];
  int q; cin >> q;
  vector<int> t(q);
  int ans = 0;
  for(int i = 0; i < q; i++) cin >> t[i];
  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(s[j] == t[i]){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3148
a,b = map(int,input().split())

if b == 1:
  print(0)
  exit()
  
if a >= b:
  print(1)
  exit()

tmp = a
c = 1

for i in range(100):
  tmp += a-1
  c += 1
  if tmp >= b:
    break
    
print(c)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M, T;
	cin >> N >> M >> T;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	int ANS = 0;
	ANS += A[0] - M;
	ANS += max(0, T - M - A[N - 1]);
	for (int i = 0; i < N - 1; i++) {
		ANS += max(0, A[i + 1] - A[i] - M * 2);
	}
	cout << ANS << endl;
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

vector<ll> h;

ll N,A,B;

bool f(ll x) {
  ll count = 0;
  rep(i,N) {
    ll k = max(0LL,h[i] - x * B);
    count += ((k + A - B - 1) / (A-B));
  }
  if (count <= x) return true;
  else return false;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  cin >> N >> A >> B;
  h.resize(N);
  rep(i,N) cin >> h[i];
  
  ll left = 0;
  ll right = 1e9;
  while (left + 1 < right) {
    ll mid = left + (right - left) / 2;
    if (f(mid)) right = mid;
    else left = mid;
  }
  
  cout << right << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int i,j,l,res=0,maxi=0,f=0;
    cin>>a;
    l=a.size();
    for(i=0; i<l; i++)
    {
        if(a[i]=='A'&&f==0)
        {
            f=1;
            res++;
        }
        else if(f==1)
        {
            res++;

            if(a[i]=='Z')
            {
                maxi=max(maxi,res);

            }



        }
        else
            {
                res=0;
                f=0;
            }



    }

    cout<<maxi<<endl;


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int a, b;
	cin >> a >> b;
	if(a > b) swap(a, b);
	for(int i=0;i<b;i++) cout << a;
	cout << endl; 	
	
}





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

int main(){
    int N,D;
    cin >> N >> D;
    int A,B;
    int X[N][D]={};

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

    int count = 0;

    for(int i = 0;i<N;i++){
        for(int j = i+1;j<N;j++){
            int norm = 0;
            for(int k = 0;k<D;k++){
                norm += pow(abs(X[i][k]-X[j][k]),2);
            }
            bool flag = false;
            for(int k = 0;k<=norm;++k){
                if(k*k == norm){
                    flag = true;
                }
            }
            if(flag) count++;
        }
    }

cout << count << endl;






}

Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())
D = [[]for _ in range(N)]
for i in range(M):
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    D[l].append([r,d])
    D[r].append([l,-d])
# 負の重みを持つ辺があるので-1で初期化したdistでseen配列をかねようとするとダメ
INF = float('inf')
dist = [INF]*N
seen = [False]*N
q = deque([])
for s in range(N):
    if dist[s] != INF:
        continue
    q.append([s,0])
    while len(q) != 0:
        p = q.popleft()
        # print(p)
        # print(dist)
        #if dist[p[0]] != -1 and dist[p[0]] != p[1]: # 来たことがあって矛盾している場合
        if seen[p[0]] and dist[p[0]] != p[1]: # 来たことがあって矛盾している場合

            # print(p[0],dist[p[0]],p[1])
            print('No')
            exit()
        #if dist[p[0]] != -1 and dist[p[0]] == p[1]: # 来たことがあって矛盾していない場合
        if seen[p[0]] and dist[p[0]] == p[1]: # 来たことがあって矛盾していない場合
            continue
        dist[p[0]] = p[1]
        seen[p[0]] = True
        for np in D[p[0]]:
            q.append([np[0],p[1]+np[1]])
print('Yes')
#print(dist)

Measured memory_bytes: 139168
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,a,b;
string s;

int main(){
	cin>>n>>a>>b>>s;
	int num=0,bnum=0;
	for(auto i=s.begin();i!=s.end();i++){
		if(num<a+b&&(*i=='a'||(*i=='b'&&bnum++<b))){
			cout<<"Yes"<<endl;
			num++;
		}
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 896