akhauriyash/Code-Regression huggingface dataset:
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[100005]={},c[3]={},ans=1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    ll cnt=0,x=-1;
    if(a[i]==c[0]) {
      cnt++,x=0;
    }
    if(a[i]==c[1]) {
      cnt++,x=1;
    }
    if(a[i]==c[2]) {
      cnt++,x=2;
    }
    if(x==-1) {
      cout << 0 << endl;
      return 0;
    }
    c[x]++;
    ans*=cnt;
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
// B - Hina Arare
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	map<char,int> S;
	for(int i=0; i<N; ++i){
		char s; cin>>s;
		S[s]++;
	}
	cout<< (S.size()==3? "Three":"Four") <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
	int dist,angle;
	int ang_go=90;
	
	// angle:clockwise/rerative
	// ang_go:counterclockwise/absolute
	
	double x,y;
	x=0.0;y=0.0;
	double px,py;

	
	while(scanf("%d,%d",&dist,&angle)!=EOF){
		if(dist==0 && angle ==0)break;
		
		px=(double)dist*cos( (((double)ang_go*M_PI)/180.0 ) );
		py=(double)dist*sin( (((double)ang_go*M_PI)/180.0 ) );

		x=x+px;
		y=y+py;
//printf("%d,%d\n",(int)x,(int)y);

		ang_go=ang_go-angle;

	}

	printf("%d\n%d\n",(int)x,(int)y);

	return 0;
}

Measured memory_bytes: 604
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

ll n, a[N], b[N], ans;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 0; i <= n; i++ ) {
        cin >> a[i];
    }
    for ( int i = 0; i < n; i++ ) {
        cin >> b[i];
        ans += min( b[i], a[i] + a[i + 1] );
        if ( b[i] >= a[i] + a[i + 1] ) {
            a[i] = a[i + 1] = 0;
        }
        else {
            if ( b[i] >= a[i] ) {
                b[i] -= a[i];
                a[i] = 0;
                if ( b[i] >= a[i + 1] ) {
                    a[i + 1] = 0;
                }
                else {
                    a[i + 1] -= b[i];
                }
            }
            else {
                a[i] -= b[i];
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())

dis = [ 0 for _ in range(n)]  # 距離
adj = [[] for _ in range(n)] # 隣接リスト

for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1;b-= 1
    adj[a].append([b, c])
    adj[b].append([a, c])

# v; 現在の頂点
# p; vの親
# d; 現在の距離
def dfs(v, p, d):
    dis[v] = d
    for i, c in adj[v]:
        if i == p:
            continue
        dfs(i, v, d+c)

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)

for _ in range(q):
    x, y = map(int, input().split())
    x -= 1;y -= 1
    print(dis[x] + dis[y])

Measured memory_bytes: 137984
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (_S == _T && (_T = (_S = _B) + fread(_B, 1, 1 << 15, stdin), _S == _T) ? EOF : *_S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char _B[1 << 15], *_S = _B, *_T = _B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}
#define maxn 1010
typedef long long ll;
ll a[maxn], b[maxn];
int main()
{
//	setfile();
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%lld%lld", &a[i], &b[i]);
	for (int i = 2; i <= n; ++i)
	{
		R ll aa = (a[i - 1] + a[i] - 1) / a[i], bb = (b[i - 1] + b[i] - 1) / b[i];
		R ll tmp = dmax(aa, bb);
		a[i] *= tmp; b[i] *= tmp;
	}
	printf("%lld\n", a[n] + b[n] );
	return 0;
}


Measured memory_bytes: 128
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


void solve()
{
    
    int n,m;
    cin>>n>>m;
    int cnt[n+1]={0};int cr=0,pe=0;string s;
    int p;int pee[n+1]={0};
    for(int i=0;i<m;i++)
    {
        cin>>p;
        cin>>s;
        if(s[0]=='A')
        {
            cnt[p]=1;
        }
        else
        {
            if(!cnt[p])
            { pe+=1;
                pee[p]+=1;
            }
                
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(cnt[i])
            cr++;
        else
            pe-=pee[i];
    }
    cout<<cr<<" "<<pe<<endl;
}
int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int i,n,a,b,c,d,e,f,g,h;
	while( cin >> n && n>0) {
	for (i=0;i<n;i++) {
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
		cout << a*e-b*f-c*g-d*h << ' ' << a*f+b*e+c*h-d*g << ' ' << a*g-b*h+c*e+d*f << ' ' << a*h+b*g-c*f+d*e << endl; 
	}
    } 
	return 0;
} 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll long  long
int main()
{
    ll n;
    cin>>n;
    ll i,a[n][3],j,z=0;
    for(i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    for(i=1;i<n;i++) {
        a[i][0] += max(a[i-1][1],a[i-1][2]);
        a[i][1] += max(a[i-1][0],a[i-1][2]);
        a[i][2] += max(a[i-1][1],a[i-1][0]);
    }
    cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>

int main(void){

int n, i;
double x[100], y[100], max=0, d1=0, d2=0, d3=0;
scanf("%d", &n);
for(i=0;i<n;i++) scanf("%lf", &x[i]);
for(i=0;i<n;i++) scanf("%lf", &y[i]);

for(i=0;i<n;i++)
{
d1+=fabs(x[i]-y[i]);
d2+=pow(fabs(x[i]-y[i]), 2);
d3+=pow(fabs(x[i]-y[i]), 3);
if(max<fabs(x[i]-y[i])) max=fabs(x[i]-y[i]);
}

printf("%f\n%f\n%f\n%f\n", d1, sqrt(d2), cbrt(d3), max);

return 0;

    
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int x, y, a, b, c;
  vector<LL> p, q, r;
  Solver2(LL x, LL y, LL a, LL b, LL c) : x(x), y(y), a(a), b(b), c(c), p(a), q(b), r(c){};

  void solve() {
    for (int i = 0; i < a; ++i) {
      cin >> p[i];
    }
    for (int i = 0; i < b; ++i) {
      cin >> q[i];
    }
    for (int i = 0; i < c; ++i) {
      cin >> r[i];
    }
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<LL> pq;
    for (int i = 0; i < x; ++i) {
      pq.push_back(p[i]);
    }
    for (int i = 0; i < y; ++i) {
      pq.push_back(q[i]);
    }
    for (int i = 0; i < c; ++i) {
      pq.push_back(r[i]);
    }
    sort(pq.rbegin(), pq.rend());
    LL ans = 0;
    for (int i = 0; i < x + y; ++i) {
      ans += pq[i];
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m, a, b, c;
  std::cin >> n >> m >> a >> b >> c;

  Problem::Solver2 sol(n, m, a, b, c);
  sol.solve();
  return 0;
}


Measured memory_bytes: 8816
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, W = map(int, raw_input().split())
DP = [0] * (W + 1)
for _ in range(N):
    w, v = map(int, raw_input().split())
    for i in range(w, W + 1)[::-1]:
        DP[i] = max(DP[i], DP[i - w] + v)

print DP[W]

Measured memory_bytes: 134124
def hyouji(a):
    print(a[0], end=' ')
    print(a[1], end=' ')
    print(a[2], end=' ')


def kingaku(a):
    return 10000*a[0]+5000*a[1]+1000*a[2]


n, y = map(int, input().split())

maisuu = [0,0,n]

for i in range(n+1):
    for j in range(n-i+1):
        maisuu = [i,j,n-i-j]
        if kingaku(maisuu) == y:
            hyouji(maisuu)
            exit()

print('-1 -1 -1')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

int v[2000001];
int head = 0, tail = 0;
int front(){return v[head];}
void pop(){head++;}
void push(int a){v[tail] = a, tail++;}
bool empty(){return head == tail;}
bool size(){return tail - head;}
void initQueue(){head = tail = 0;}

int H, W, N;
string mp[1001];
int dist[1001][1001];

int bfs(int sy, int sx, int gy, int gx){
  initQueue();
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++) dist[i][j] = 1e9;
  
  push(sy * W + sx);
  dist[sy][sx] = 0;

  while(!empty()){
    int num = front(); pop();
    int y = num / W;
    int x = num % W;
    int cost = dist[y][x];
    if(y == gy && x == gx) return cost;
    int dy[4] = {-1, 0, 1, 0};
    int dx[4] = {0, 1, 0, -1};
    for(int i=0;i<4;i++){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if(mp[ny][nx] == 'X' || dist[ny][nx] != 1e9) continue;
      push(ny * W + nx);
      dist[ny][nx] = cost + 1;
    }
  }
  assert(0);
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>H>>W>>N;
  for(int i=0;i<H;i++) cin>>mp[i];

  int sy[10], sx[10];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++){
      if(mp[i][j] == 'S') sy[0] = i, sx[0] = j;
      if('0' <= mp[i][j] && mp[i][j] <= '9') sy[mp[i][j] - '0'] = i, sx[mp[i][j] - '0'] = j;
    }

  int ans = 0;
  for(int i=0;i<N;i++){
    ans += bfs(sy[i], sx[i], sy[i+1], sx[i+1]);
  }

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/





vector<int> adj[100005];
int dist1[100005];
int dist2[100005];
void dfs(int node,int par,int dist1[]){
     for(int child:adj[node]){
          if(child==par)continue;
          dist1[child]=dist1[node]+1;
          dfs(child,node,dist1);
     }
}
int main(){
     ll n,d,a;
     cin>>n>>d>>a;
     vector<pi> vec(n);
     for(int i=0;i<n;i++)cin>>vec[i].fi>>vec[i].se;
     sort(vec.begin(),vec.end());
     ll r[n+3]={0};
     ll ans=0LL;
     for(int i=0;i<n;i++){
          vec[i].se-=r[i];
          if(vec[i].se>0){
               ll t=(vec[i].se+a-1)/a;
               ans+=t;
               r[i]+=t*a;
               int id1=upper_bound(vec.begin(),vec.end(),
               pi{vec[i].fi+2*d,1e9})-vec.begin();
               r[id1]-=t*a;

          }
          r[i+1]+=r[i];
          
     }
     cout<<ans;

}















































Measured memory_bytes: 10292
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
//		Scanner sc = new Scanner(System.in);
//		
//		int n = sc.nextInt();
//		sc.nextLine();
//		
//		Set<String> dic = new HashSet<>();
		
		Scanner sc=new Scanner(System.in);
		Set<String> dic=new HashSet<>();
		int n=sc.nextInt();
		String com,word;
		for(int i=0;i<n;i++){
			com=sc.next();
			word=sc.next();
			if(com.equals("insert")){
				dic.add(word);
			}
			else if(dic.contains(word)){
				System.out.println("yes");
			}
			else{
				System.out.println("no");
			}
		}
		
//		for(int i=0;i<n;i++)
//		{
//			String[] str = sc.nextLine().split(" ");
//			
//			if(str[0].equals("insert"))
//			{
//				dic.add(str[1]);
//			}
//			
//			if(str[0].equals("find"))
//			{
//				if(dic.contains(str[1]))
//					System.out.println("yes");
//				else
//					System.out.println("no");
//			}
//		}
		
	}
}



Measured memory_bytes: 251080
def resolve():
    n, k = map(int, input().split())
    mod = 998244353
    dp = [0] * (3*n)
    imos = [0] * (3*n)
    lr = []
    for i in range(k):
        l, r = map(int, input().split())
        lr.append((l, r+1))
    for l, r in lr:
        imos[l] += 1
        imos[r] += -1
    for i in range(1, n+1):
        dp[i] = (dp[i-1] + imos[i]) %mod
        for l, r in lr:
            imos[min(i+l, n+2)] += dp[i]
            imos[min(i+r, n+2)] += -1*dp[i]
    print(dp[n-1]%mod)

resolve()

Measured memory_bytes: 77372
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+1e3;
int h[N],dp[N];
int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++)cin >> h[i];
    dp[0] = -1e9;
    for(int i = 2; i <= n; i++){
        dp[i] = abs(h[i-1]-h[i]) + dp[i-1];
        if(i > 2)dp[i] = min(dp[i],abs(h[i-2]-h[i]) + dp[i-2]);
    }
    //for(int i = 1; i <= n; i++)cout << dp[i] << " ";
    cout << dp[n];
}


Measured memory_bytes: 4404
/*************************************************************************
    > File Name: c.cpp
# File Name: c.cpp
# Author : xiaobuxie
# QQ : 760427180
# Email:760427180@qq.com
# Created Time: 2019年09月01日 星期日 20时17分33秒
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define pq priority_queue<int,vector<int>,greater<int> >
ll gcd(ll a,ll b){
    if(a<b) return gcd(b,a);
    return b==0?a:gcd(b,a%b);
}
const int N=1e5+9;
int dp[N];
int a[N];
int main(){
    int n; scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",a+i);
    int ans=0;
    int now=0;
    for(int i=n-1;i>=1;--i){
        if(a[i]>=a[i+1]) ++now;
        else now=0;
        ans=max(ans,now);
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int N, M, A, B;
  cin >> N >> M >> A >> B;
  vector<int> D(N);
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }

  stack<int> gab;
  for(int i = 0; i < N; i++){
    if(D[i] >= A){
      gab.push(D[i]);
    }else{
      break;
    }
  }


  if(N - (int)gab.size() < M){
    while(1){
      if(gab.size() == 0) break;
      if(gab.top() <= B){
	gab.pop();
      }
      else{
	break;
      }
    }
  }

  cout << gab.size() << endl;

  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;

    string S; cin >> S;
    if (N%2 == 1){
        cout << "No" << endl;
        return 0;
    }    bool f=true;
    for(int i=0;i<N/2;i++){
        cerr << S[i] << " " << S[i+N/2] << endl;
        if (S[i] == S[i+N/2]){}
        else{ f=false; break;}
    }
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()


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

    vector<ll> div;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            ll m = i - 1;
            ll d = N / i;
            if(m > d) div.push_back(i);
            if(i * i != N) {
                ll m = N / i - 1;
                ll d = i;
                if(m > d) div.push_back(N / i);
            }
        }
    }
    sort(all(div));
    ll ans = 0;
    for(auto d : div) {
        ans += d - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%s" (fun s ->
    let n = String.length s in

    let rec loop i =
        if i = n then "YES" else
            if n - i >= 7 && String.sub s i 7 = "dreamer" then (
                if n - i = 7 then "YES" else
                    if s.[i + 7] = 'a' then loop (i + 5) else loop (i + 7)
            ) else
            if n - i >= 6 && String.sub s i 6 = "eraser"  then loop (i + 6) else
            if n - i >= 5 && String.sub s i 5 = "dream"   then loop (i + 5) else
            if n - i >= 5 && String.sub s i 5 = "erase"   then loop (i + 5) else
                "NO"
    in
    loop 0 |> print_endline
)

Measured memory_bytes: 4688
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(){
  string s;
  cin >> s;
  int min = 999, tmp_min;
  string subs;
  for(int i = 0; i < (s.length())-2; i++){
    subs = s.substr(i, 3);
    tmp_min = abs(753 - atoi(subs.c_str()));
    if(min > tmp_min) min = tmp_min;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def f(a,b,c):
  return math.gcd(math.gcd(a,b),c)

k = int(input())
ans = 0
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ans += f(i,j,k)
print(ans)


Measured memory_bytes: 68256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let map = {}
    while (hasNext()) {
        let first = next()[0]
        if (!map[first]) map[first] = 1
        else map[first]++
    }
    let ans = 0n
    let march = ['M', 'A', 'R', 'C', 'H']
    for (let i = 0; i < march.length - 2; i++) {
        for (let j = i + 1; j < march.length - 1; j++) {
            for (let k = j + 1; k < march.length; k++) {
                if(!map[march[i]] || !map[march[j]] || !map[march[k]]) continue
                ans += BigInt(map[march[i]]) * BigInt(map[march[j]]) * BigInt(map[march[k]])
            }
        }
    }
    console.log(Number(ans))
}
Main()


Measured memory_bytes: 37752
#include <iostream>
#include <limits.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(void){
    long long a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c - 1) cout << b + c << endl;
    else cout << 2 * b + a + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  map<int,int> mp;
  mp[A]++;
  mp[B]++;
  mp[C]++;
  for(auto x:mp){
    if(x.second==1) cout << x.first << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000000000000
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int a[n+1];
    ll int i,j,k,w;
    for(i=1;i<=n;i++)
    	cin>>a[i];
    ll int dp[n+1][n+1];
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=n;j++)
    		dp[i][j]=MOD;
    }
    ll int l[n+1];
    l[1]=a[1];
    for(i=2;i<=n;i++)
    	l[i]=l[i-1]+a[i];
    //dp[i][j]== min cost in which we can make (i,j) slimes convert to one slime.
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=(n-i+1);j++)
    	{
    		w=(j+i-1);
    		if(j==w)
    		{
    			dp[j][w]=a[j];
    			continue;
    		}
    		if(i==2)
    		{
    			dp[j][w]=a[j]+a[w];continue;
    		}
    		for(k=j;k<=w;k++)
    		{
    			if(k==j)
    				dp[j][w]=min(dp[j][w],dp[k+1][w]+l[w]-l[j]+a[j]);
    			else if(k==w)
    				dp[j][w]=min(dp[j][w],dp[j][w-1]+l[w]-l[j]+a[j]);
    			else 
    				dp[j][w]=min(dp[j][w],(dp[j][k]+dp[k+1][w])+l[w]-l[j]+a[j]);
    		}
    	}
    }
    cout<<dp[1][n]<<endl;
   

}

Measured memory_bytes: 4884
// inputに入力データ全体が入る
function Main(input) {
  var s, K, ref;
  ref = input.split("\n"), s = ref[0], K = parseInt(ref[1]);
  console.log(Array.from(s).map((v, i, arr)=> {
    var code = v.charCodeAt();
    if(i === arr.length - 1) {
      code += K%26;
      code -= code >122 ? 26 : 0;
      return String.fromCharCode(code);
    } else {
      if(v === "a") return v;
      return 123 - code <= K ? ((K -= 123 - code), "a") : v;
    }
  }).join(""));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11356
#include<bits/stdc++.h>
using namespace std;
int n, t, a, x, ans;
double MINN = 10000000;
int main(void)
{
	cin >> n >> t >> a;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (abs(t - x * 0.006 - a) < MINN)
		{
			MINN = abs(t - x * 0.006 - a);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, X;
    cin >> N >> X;
    
    vector<ll> A;
    
    ll now = 0;
    A.pb(now);
    
    rep(i, N){
        ll inp;
        cin >> inp;
        now += inp;
        A.pb(now);
    }
    
    rep(i, A.size()){
        if(A[i] > X){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << N+1 << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cmath>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int X;
    int N;
    cin >> X >> N;
    int p[N];
    int ans;
    int index = -1;
    int end = 0;
    rep(i,N) cin >> p[i];
    sort(p,p+N);
    for(int i=0;i<N;i++){
        if(p[i]==X){
            index = i;
        }
    }

    if(index == -1){
        ans = X;
    }else{
        int cnt = 1;
        while(end == 0){
            if(index+cnt < N){
                if(p[index+cnt] != X+cnt){
                    end=1;
                    ans=X+cnt;
                }
                if(index-cnt>=0){
                    if(p[index-cnt] != X-cnt){
                        end = 1;
                        ans = X-cnt;
                    }
                }else{
                    end = 1;
                    ans = X-cnt;
                }
            }else if(index-cnt >= 0){
                end = 1;
                ans = X+cnt;
                if(p[index-cnt] != X-cnt){
                    end=1;
                    ans=X-cnt;
                }
            }else{
                if(index+cnt >= N){
                    end = 1;
                    ans=X+cnt;
                }
                if(index-cnt < 0){
                    end = 1;
                    ans=X-cnt;
                }
            }
            cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numbers[] = new int [n];
        for(int i = 0; i < n; i++){
            numbers[i] = sc.nextInt();
        }
        StringBuilder sb = new StringBuilder();
        process(numbers, n, sb);
        
        for(int i = 1; i < n; i++){
            int v = numbers[i];
            int j = i - 1;
            while(j >= 0 && numbers[j] > v){
                numbers[j + 1] = numbers[j];
                j--;
                
            }
            numbers[j + 1] = v;
            process(numbers, n, sb);
        }
        System.out.print(new String(sb));
    }
    
    private static void process(int numbers[], int n, StringBuilder sb){
        for(int i = 0; i < n; i++){
            if(i != 0){
                sb.append(" ");
            }
            sb.append(numbers[i]);
        }
        sb.append("\n");
    }
}


Measured memory_bytes: 27476
N,K=map(int,input().split())
ins=[list(map(int,input().split())) for _ in range(N)]
#print(ins)
ins.sort(key=lambda x:x[0])
num=0
for i in range(N):
    num=num+ins[i][1]
    if num-ins[i][1]<K<=num:
        print(ins[i][0])
        break


Measured memory_bytes: 64472
N,M = map(int,input().split())
dic = {}
for i in range(1,N+1):
    dic[i] = 0
for i in range(M):
    a,b = map(int,input().split())
    dic[a] += 1
    dic[b] += 1
for key,value in dic.items():
    print(value)

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

using namespace std;
typedef long long ll;

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

  int sum;
  string r;
  for (int bit = 0; bit < (1 << 3); bit++) {
    sum = N[0] - '0';
    r = "";
    for (int i = 0; i < 3; i++) {
      if (bit & (1 << i)) {
        sum -= N[i+1] - '0';
        r += "-";
      } else {
        sum += N[i+1] - '0';
        r += "+";
      }
    }
    if (sum == 7) {
      break;
    }
  }
  cout << N[0] - '0';
  for (int i = 0; i < 3; i++) {
    cout << r[i] << N[i + 1] - '0';
  }
  cout << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((A+B) > (C+D)){
    cout << "Left" << endl;
  } else if((A+B) == (C+D)) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int p[200000];
	for(int i=0; i<n; i++){
		scanf("%d", &p[i]);
	}
	map<int, int> mp;
	int d[200000];
	d[0]=1;
	mp[p[0]]=1;
	for(int i=1; i<n; i++){
		auto itr=mp.find(p[i]-1);
		if(mp.find(p[i]-1)!=mp.end()){
			int d=itr->second;
			mp.erase(itr);
			mp[p[i]]=d+1;
		}else{
			mp[p[i]]=1;
		}
	}
	int ans=1;
	for(auto itr=mp.begin(); itr!=mp.end(); itr++){
		int d=itr->second;
		if(ans<d) ans=d;
	}
	printf("%d\n", n-ans);
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define ll long long
#define mp make_pair
using namespace std;
const int N=2e5+5;
ll ans;int n,T;vector<pii>L,R;
int l[N],r[N],k[N];pii p[N];
priority_queue<int,vector<int>,greater<int> >q;
ll cal(vector<pii>v)
{
	while(!q.empty())q.pop();
	ll res=0;
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		res+=v[i].S;
		q.push(v[i].S);
		while(q.size()>v[i].F)res-=q.top(),q.pop();
	}
	return res;
}
int main()
{
	cin>>T;
	while(T--)
	{
		while(!q.empty())q.pop();
		ans=0;L.clear();
		cin>>n;R.clear();
		for(int i=0;i<n;i++)
		{
			cin>>k[i]>>l[i]>>r[i];
			ans+=min(l[i],r[i]);
			if(l[i]>r[i])
				L.push_back(mp(k[i],l[i]-r[i]));
			if(r[i]>l[i])
				R.push_back(mp(n-k[i],r[i]-l[i]));
		}
		cout<<ans+cal(L)+cal(R)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 9580
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>

using namespace std;

const double Pi = acos(-1);
const int MAXN = 2333333;
const double EPS = 1e-8;
struct Point{
	double x, y;
	Point (double _x = 0.0, double _y = 0.0): x(_x), y(_y){}
}p[MAXN];
int f[MAXN];

Point operator - (Point u, const Point &v){
	u.x -= v.x;
	u.y -= v.y;
	return u;
}

double operator * (const Point &u, const Point &v){
	return u.x * v.y - u.y * v.x;
}

inline int Sign(double u){
	return u < -EPS? -1: u > EPS;
}

inline double Len(const Point &u){
	return sqrt(u.x * u.x + u.y * u.y);
}

bool Cross(const Point &a, const Point &b, const Point &c, const Point &d, Point &cro){
	if (Sign(((b - a) * (d - a)) * ((b - a) * (c - a))) >= 0 || Sign(((d - c) * (a - c)) * ((d - c) * (b - c))) >= 0) return 0;
	double u = (d - c) * (a - c), v = (b - c) * (d - c);
	cro.x = (b.x - a.x) * u / (u + v) + a.x;
	cro.y = (b.y - a.y) * u / (u + v) + a.y;
	return 1;
}

int Get(const Point &u){
	if (Sign(u.x) > 0 && Sign(u.y) >= 0) return 1;
	if (Sign(u.x) <= 0 && Sign(u.y) > 0) return 2;
	if (Sign(u.x) < 0 && Sign(u.y) <= 0) return 3;
	return 4;
}

bool cmp(const Point &a, const Point &b){
	if (Get(a) != Get(b)) return Get(a) < Get(b);
	else return Sign(a * b) > 0 || Sign(a * b) == 0 && Len(a) < Len(b) - EPS;
}

int find(int u){
	int v = u;
	while (v != f[v]) v = f[v];
	while (u != f[u]){
		int w = f[u];
		f[u] = v;
		u = w;
	}
	return u;
}

int main(){
	while (1){
		int n;
		scanf("%d", &n);
		if (n == 0) break;
		if (n % 3 == 0) n /= 3;
		if (n == 1){
			printf("%.9f\n", sqrt(3.0) / 4.0);
			continue;
		}
		double Theta = 360.0 / (double)(n * 3) / 180.0 * Pi;
		double Cos = cos(Theta), Sin = sin(Theta);
		double Cos6 = cos(Pi * 2.0 / 3.0), Sin6 = sin(Pi * 2.0 / 3.0);
		double x = 0.0, y = 1.0 / sqrt(3.0);
		double x2 = x * Cos - y * Sin, y2 = y * Cos + x * Sin;
		double x3 = x * Cos6 - y * Sin6, y3 = y * Cos6 + x * Sin6;
		double x4 = x2 * Cos6 + y2 * Sin6, y4 = y2 * Cos6 - x2 * Sin6;
		Point a(x, y), b(x3, y3), c(x2, y2), d(x4, y4);
		Point cro;
		Cross(a, b, c, d, cro);
//printf("%.9f %.9f %.9f %.9f\n", (b - a).x, (b - a).y, (d - a).x, (d - a).y);
//printf("%.9f %.9f\n", (b - a) * (c - a), (b - a) * (d - a));
//printf("%.9f %.9f\n%.9f %.9f\n%.9f %.9f\n%.9f %.9f\n%.9f %.9f\n", x, y, x3, y3, x2, y2, x4, y4, cro.x, cro.y);
		double S = y * y * Pi / (double)(n * 3) - (a * c) / 2.0 + ((cro - c) * (a - c)) / 2.0;
		double sum = y * y * Pi - S * (double)(n * 3);
		printf("%.9f\n", sum);
	}
	return 0;
}

Measured memory_bytes: 38616
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;
 
int main()
{
    int N;  cin >> N;
    int cnt = 0;
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        if(a%2 == 0)  cnt++;
    }
    if(cnt == N)  cout << "second";
    else    cout << "first";
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int height = sc.nextInt();
            int weight = sc.nextInt();
            
            if( height == 0 && weight == 0 ) break;
            for(int h = 0; h < height; h++){
                for(int w = 0; w < weight; w++){
                    if( h == 0 || h == height-1 || w == 0 || w == weight-1){
                        System.out.print("#");    
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 36364
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
 
string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}

int mod = 1e9 + 7;
ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}
 
int main() { 
	//1 2 3 4 5 6 7
	//2 3 4 5 6 7 1
	ll n;
	cin >> n;
	n--;
	cout << (n * (n + 1)) / 2;
}





	


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;

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

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

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


	ll N, M,L=1;
	ll two = 0;
	cin >> N >> M;
	FOR(i, 0, N) {
		ll cur; cin >> cur;

		ll copy = cur;
		ll cnt = 0;
		while (copy % 2 == 0) {
			copy /= 2;
			cnt++;
		}

		if (i == 0) {
			two = cnt;
		}
		else {
			if (two != cnt) {
				cout << 0 << endl;
				return 0;
			}
		}

		L = lcm(L, cur/2);
		if (L > 1e9) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << (M + L) / (2 * L) << endl;



}

Measured memory_bytes: 3660
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int mod = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (int i = 0 ; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    vector<vector<int>> dp(n, vector<int>(m, 0));
    if (a[0] == b[0]) dp[0][0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0];
        if (a[i] == b[0]) dp[i][0] += 1;
    }
    for (int i = 1; i < m; i++) {
        dp[0][i] = dp[0][i - 1];
        if (a[0] == b[i]) dp[0][i] += 1;
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < m; j++) {
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + mod + mod + mod) % mod;
            if (a[i] == b[j]) dp[i][j] += dp[i - 1][j - 1] + 1;
            dp[i][j] %= mod;
        }
    }
    cout << (dp[n - 1][m - 1] + 1) % mod;
}
/*

*/


Measured memory_bytes: 31616
let rec remove value lst =
	let rec remove_non_dec value lst =
		match lst with
		| []      -> []
		| x :: xs ->
			if x >= value then remove_non_dec x xs
			else x :: xs
	in
	let rec remove_non_inc value lst =
		match lst with
		| []      -> []
		| x :: xs ->
			if x <= value then remove_non_inc x xs
			else x :: xs
	in
	match lst with
	| []      -> []
	| x :: xs ->
		if x > value then remove_non_dec x xs
		else if x < value then remove_non_inc x xs
		else remove x xs

let rec solve count lst =
	match lst with
	| []      -> count
	| x :: xs -> solve (count + 1) (remove x xs)

let () =
	let n = read_int () in
	let a =
		read_line ()
		|> Str.split (Str.regexp " ")
		|> List.map int_of_string
	in
	solve 0 a
	|> print_int
	|> print_newline


Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,k;

int main(){
  int ans=0;
  int a,b;
  cin >> n >> a>>b;
  ans=min(a*n,b);

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

Measured memory_bytes: 256
a = [int(input()) for i in range(5)]

b = [(10 - (int(a[i]) % 10)) % 10 for i in range(5)]

cnt = b.count(max(b))
pass_cnt = 0
sum = 0
sum2 = 0
del_cnt = 0
for i in range(5):
    if max(b) == b[i]:
        pass_cnt += 1
        sum2 += a[i]+b[i]
        del_cnt = b[i]
    else:
        sum += a[i]+b[i]
#        print("sum:{}".format(sum))

print(sum+sum2-del_cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int k;
	vector<int> ary(5);
	for (int i = 0; i < 5; ++i) {
		cin >> ary[i];
	}
	cin >> k;

	for (int i = 0; i < 4; ++i) {
		for (int j = i + 1; j < 5; ++j) {
			if (ary[j] - ary[i] > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, d, r= 0;
	double f = 0;
	
	scanf("%d%d", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double) a / b;
	
	printf("%d %d %lf\n", d, r, f);
	
	return 0;
	
}




Measured memory_bytes: 2128
module mymodule
  implicit none
  public

  type store_type
    integer(8) :: price, storage
  end type store_type

  interface operator (>)
    procedure greater
  end interface

  contains

  pure function greater(fi, se)
    type(store_type), intent(in) :: fi, se
    logical :: greater
    greater = (fi % price > se % price)  ! Edit here
  end function greater

  recursive subroutine quicksort(a)
    type(store_type), intent(inout) :: a(:)
    type(store_type) :: pivot, tmp
    integer :: i, j, k, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (pivot > a(i))
        i = i + 1
      end do
      do while (a(j) > pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end module mymodule

program main
  use mymodule
  implicit none
  integer(8) :: n, m, i, cost
  type(store_type), allocatable :: stores(:)

  read (*, *) n, m
  allocate (stores(n))
  do i = 1, n
    read (*, *) stores(i) % price, stores(i) % storage
  end do

  call quicksort(stores)

  cost = 0
  do i = 1, n
    if (m <= stores(i) % storage) then
      cost = cost + m * stores(i) % price
      exit
    end if
    cost = cost + stores(i) % storage * stores(i) % price
    m = m - stores(i) % storage
  end do

  write (*, "(i0)") cost
end program main


Measured memory_bytes: 1792