akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int L = in.nextInt();
            int[] A = new int[L];
            for (int i = 0; i < L; i++) {
                A[i] = in.nextInt();
//                A[i] = A[i] % 2 == 0 ? (A[i] == 0 ? 0 : 2) : 1;
            }

            long[][] dp = new long[L + 1][5];
            for (int i = 0; i <= L; i++) {
                if (i == 0) {
                    dp[i][0] = A[i];
                    dp[i][1] = (A[i] == 0 ? 0 : (A[i] % 2 == 0 ? 0 : 1));
                    dp[i][2] = (A[i] == 0 ? 0 : (A[i] % 2 == 0 ? 1 : 0));
                    dp[i][3] = (A[i] == 0 ? 0 : (A[i] % 2 == 0 ? 0 : 1));
                    dp[i][4] = A[i];
//                    Utils.debug("dp[" + i + "]", dp[i]);
                    continue;
                }
                for (int j = 0; j < 5; j++) {
                    if (j == 0) {
                        dp[i][j] = (i < L ? A[i] : 0) + dp[i - 1][j];
                    } else if (j == 1) {
                        dp[i][j] = (i < L ? (A[i] == 0 ? 2 : (A[i] % 2 == 0 ? 0 : 1)) : 0) + Math.min(dp[i - 1][j], dp[i - 1][0]);
                    } else if (j == 2) {
                        dp[i][j] = (i < L ? (A[i] == 0 ? 1 : (A[i] % 2 == 0 ? 1 : 0)) : 0) + Math.min(dp[i - 1][j], Math.min(dp[i - 1][1], dp[i - 1][0]));
                    } else if (j == 3) {
                        dp[i][j] = (i < L ? (A[i] == 0 ? 2 : (A[i] % 2 == 0 ? 0 : 1)) : 0) + Math.min(Math.min(dp[i - 1][3], dp[i - 1][2]), Math.min(dp[i - 1][1], dp[i - 1][0]));
                    } else if (j == 4) {
                        dp[i][j] = (i < L ? A[i] : 0) + Math.min(dp[i - 1][4], Math.min(Math.min(dp[i - 1][3], dp[i - 1][2]), Math.min(dp[i - 1][1], dp[i - 1][0])));
                    }
                }
//                Utils.debug("dp[" + i + "]", dp[i]);
            }

            System.out.println(dp[L][4]);
        }
    }
}


Measured memory_bytes: 98916
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define int                 long long
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define vvi				    vector< vi > 
#define vpii                vector< pair<int,int> > 
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define loop(i,a,b)		    for(int i=a;i<b;i++)
#define LOOP(i,a,b)		    for(int i=a;i<=b;i++)
#define looprev(i,a,b)		for(int i=a;i>=b;i--)
#define rloop(it,c)         for(auto& it : c)
#define sz(a)			    a.size()
#define all(c) 			    c.begin(),c.end()
#define tr(c,i) 		    for(auto i = c.begin(); i != c.end(); i++)
#define present(c,x) 	    (c.find(x) != c.end())
#define cpresent(c,x) 	    (find(all(c),x) != c.end())
#define spresent(s,x)       (s.find(x) != s.npos)           //use 'x' while passing to parameters  ||  we can also use cpresent(c,x)
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define SETINT(a,x)         memset(a, x, sizeof(a))
#define SETCHAR(str,x)      memset(str, x, sizeof(str)      //use 'x' while passing to parameters  
#define mod                 1000000007
#define inf                 1e18
#define ps(x,y)             fixed<<setprecision(y)<<x
#define w(x)                int x; cin>>x; while(x--)
mt19937                     rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

 
int raise(int a,int n,int m = mod)
{
    if(n == 0)return 1;
    if(n == 1)return a;
    int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}
 
int floor1(int n,int k)
{
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}
 
int ceil1(int n,int k)
{
    return floor1(n+k-1,k);
}
 
 
void Gur27()
{
    ios::sync_with_stdio(0); cin.tie(0); 

}

int dp[100005];

int frog1rec(int h[],int N,int n)
{
    
    if(N==2)
        return abs(h[1]-h[0]);
    if(dp[N]!=-1)
        return dp[N];
    else 
    
    return dp[N]=min(abs(h[n-1]-h[n-2])+frog1rec(h,N-1,n-1),abs(h[n-1]-h[n-3])+frog1rec(h,N-2,n-2));
      
 
    
}
 
int32_t main()
{
    Gur27();
    int n;
    cin>>n;
    int a[n];
    SETINT(dp,-1);
    dp[0]=0;
    dp[1]=0;
    loop(i,0,n)
        cin>>a[i];
    
    cout<<frog1rec(a,n,n);
    
    return 0;
}

Measured memory_bytes: 5760
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    count = collections.Counter(s)
    lst = list(count.values())
    while len(lst)<3:
        lst.append(0)
    m = min(lst)
    lst = list(map(lambda x: x-m, lst))
    if max(lst)<=1:
        print("YES")
    else:
        print("NO")
main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int k;
  cin >> k;
  
  int r = 7;
  r %= k;
  map<int,int> pos;
  vi rs;
  while(pos[r] == 0){
    rs.push_back(r);
    pos[r] = rs.size();
    r *= 10;
    r %= k;
  }

  int fst = pos[r]-1;
  int sum = 0;
  int roop = 0;
  for(int i = fst;i < rs.size();i++){
    sum += rs[i];
    sum %= k;
    roop++;
  }

  map<int, int> roops;
  r = 0;
  rep(i,k){
    r += sum;
    r %= k;
    if(roops[r] != 0)break;
    roops[r] = i+1;
  }

  int ret = -1;
  r = 0;
  rep(i,rs.size()){
    r += rs[i];
    r %= k;

    if(r == 0){
      if(ret == -1 || ret > i+1) ret = i+1;
    }else if(roops[k-r] != 0 && i >= fst){
      int tmp = roops[k-r] * roop + i+1;
      if(ret == -1 || ret > tmp) ret = tmp;
    }
  }

  cout << ret << endl;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum_vote = 0;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum_vote +=A.at(i);
  }
  sort(A.begin(), A.end(), greater<int>());
  int flag = 0;
  for(int i = 0; i < M; i++){
    if((double)A.at(i) < (double)sum_vote/(4*M)){
      flag = 1;
    }
  }
  if(flag == 0){
    cout << "Yes" << endl;
  }else if(flag ==1){
    cout << "No" << endl;
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using node=struct{int to;};
using G=vector<vector<node>>;

tuple<vector<int>,G> scc(const G &graph){
	int n=graph.size(),k=0;
	vector<int> ord(n,-1),low(n),comp(n,-1),par(n);
	stack<int>s;

	function<void(int,int,int&)> dfs=[&](int v,int p,int &k){
		ord[v]=k++,low[v]=ord[v],par[v]=p;
		s.push(v);

		for(auto &e:graph[v]){
			if(ord[e.to]==-1){
				dfs(e.to,v,k);
				low[v]=min(low[v],low[e.to]);
			}else if(comp[e.to]==-1){
				low[v]=min(low[v],ord[e.to]);
			}
		}

		if(ord[v]==low[v]){
			while(1){
				int u=s.top();s.pop();
				comp[u]=v;
				if(u==v) break;
			}
		}
	};

	rep(v,n) if(ord[v]==-1) dfs(v,-1,k);
	G dag(k);
	rep(v,n) for(auto &e:graph[v]) if(comp[v]!=comp[e.to]) dag[comp[v]].push_back(e);
	return make_tuple(comp,dag);
}

int main(void){
	int v,e;
	cin >> v >> e;

	G graph(v);
	rep(loop,e){
		int a,b;
		cin >> a >> b;
		graph[a].push_back({b});
	}

	vector<int> comp;
	tie(comp,ignore)=scc(graph);

	int q;
	cin >> q;
	rep(loop,q){
		int a,b;
		cin >> a >> b;
		cout << (comp[a]==comp[b]) << endl;
	}
	return 0;
}

Measured memory_bytes: 5196
#include<stdio.h>
int A[101][101], n;

int main()
{
  int n, i, j, k, l, m;
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      for(j = 1; j <= n; j++)
	{
	  A[i][j] = 0;
	}
    }
  for(i = 1; i <= n; i++)
    {
      scanf("%d %d", &k, &l);
      if(l > 0)
	{
	  for(j = 1; j <= l; j++)
	    {
	      scanf("%d", &m);
	      A[k][m] = 1;
	    }
	}
    }
  for(i = 1; i <= n; i++)
    {
      for(j = 1; j <= n; j++)
	{
	  if(j != 1) printf(" ");
	  printf("%d", A[i][j]);
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    int n,a,b; cin >> n >> a >> b;
    cout << min(a*n,b) << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq

a,b,c,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr1=sorted(arr1,reverse=True)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
arr3=list(map(int,input().split()))
arr3=sorted(arr3,reverse=True)
heap=[]
heapq.heappush(heap,(-(arr1[0]+arr2[0]+arr3[0]),0,0,0))
s={(0,0,0)}
for _ in range(k):
  v,i,j,k=heapq.heappop(heap)
  if i+1<a and (i+1,j,k) not in s:
    s.add((i+1,j,k))
    heapq.heappush(heap,(-(arr1[i+1]+arr2[j]+arr3[k]),i+1,j,k))
  if j+1<b and (i,j+1,k) not in s:
    s.add((i,j+1,k))
    heapq.heappush(heap,(-(arr1[i]+arr2[j+1]+arr3[k]),i,j+1,k))
  if k+1<c and (i,j,k+1) not in s:
    s.add((i,j,k+1))
    heapq.heappush(heap,(-(arr1[i]+arr2[j]+arr3[k+1]),i,j,k+1))
  print(-v)

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll H,W,D;
    cin >> H >> W >> D;
    vector<P> A(H*W);
    REP(i,H){
        REP(l,W){
            ll tmp;
            cin >> tmp;
            tmp--;
            A[tmp] = mp(i,l);
        }
    }
    vector<ll> rui(H*W);
    REP(i,D){
        ll fa = i;
        rui[fa] = 0;
        fa += D;
        while(fa < H*W){
            rui[fa] = rui[fa - D] + abs(A[fa].F-A[fa-D].F) + abs(A[fa].S-A[fa-D].S);
            fa += D;
        }
    }
    ll Q;
    cin >> Q;
    REP(i,Q){
        ll L,R;
        cin >> L >> R;
        L--;
        R--;
        cout << rui[R] - rui[L] << "\n";
    }
}

Measured memory_bytes: 5260
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a=s.nextInt(),b=s.nextInt(),c=s.nextInt();
        System.out.println((a+b)*c/2);




    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=max(0,a-2*b);
    cout<<ans<<'\n';


}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N, X;
	scanf("%d", &N);
	scanf("%d", &X);

	if (X == 1 || X == N * 2 - 1) {
		printf("No");
	}
	else {
		*di++ = 'Y';
		*di++ = 'e';
		*di++ = 's';
		*di++ = '\n';
		if (N == 2) {
			putint(1);
			putint(2);
			putint(3);
		}
		else if (X != 2) {
			int k = 2;
			rep(i, N - 2) {
				if (k == X - 1) k += 3;
				putint(k++);
			}
			putint(X - 1);
			putint(X);
			putint(X + 1);
			putint(1);
			rep(i, N - 3) {
				if (k == X - 1) k += 3;
				putint(k++);
			}
		}
		else {
			int k = 4;
			rep(i, N - 2) {
				putint(k++);
			}
			putint(3);
			putint(2);
			putint(1);
			putint(2 * N - 1);
			rep(i, N - 3) {
				putint(k++);
			}
		}
		fwrite(dn, 1, di - dn, stdout);
	}


	Would you please return 0;
}

Measured memory_bytes: 2688
from collections import deque
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

S = input()
N = len(S)-1

for i in range(2**(N)):
    cou = int(0)
    lower = 0
    que = deque()
    for l in range(N+1):
        que.append(int(S[l]))
    for j in range(N):
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
#            print(i,j)
            for k in range(lower,j+1):
                cou += que.popleft()*(10**(j-k))
            lower = j+1
#            print(cou)
    k = int(0)
    while que:
        cou += que.pop()*(10**k)
        k +=1
    ans.append(cou)

print(sum(ans))

Measured memory_bytes: 40560
N = int(input())
A = {}
cnt = 0
for i in range(N):
    x = sorted(list(input()))
    if str(x) in A.keys():
        A[str(x)] += 1
    else:
        A[str(x)] = 1
for i in A.values():
    cnt += sum(list(range(i)))
print(cnt)

Measured memory_bytes: 22088
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

from collections import deque

def solve():
    dist = [inf] * len(to)
    q = deque()
    q.append((0, 0))
    dist[0] = 0
    while q:
        d, i = q.popleft()
        if d > dist[i]: continue
        if i < n:
            for j in to[i]:
                if dist[j] <= d + 1: continue
                dist[j] = d + 1
                q.append((d + 1, j))
        else:
            for j in to[i]:
                if j == n - 1:
                    print(dist[i])
                    exit()
                if dist[j] <= d: continue
                dist[j] = d
                q.appendleft((d, j))
    print(-1)

inf=10**9
n,m=MI()
to=[]
uctoi={}

for u in range(n):
    to.append([])
    uctoi[u,0]=u

for _ in range(m):
    u,v,c=MI()
    u,v=u-1,v-1
    if (u,c) not in uctoi:
        i=uctoi[u,c]=len(to)
        to.append([])
        to[i].append(u)
        to[u].append(i)
    else:i=uctoi[u,c]
    if (v,c) not in uctoi:
        j=uctoi[v,c]=len(to)
        to.append([])
        to[j].append(v)
        to[v].append(j)
    else:j=uctoi[v,c]
    to[i].append(j)
    to[j].append(i)
#print(to)
#print(fin)

solve()


Measured memory_bytes: 252744
import java.util.Scanner;

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

        String s = sc.next();
        char[] ans = new char[s.length()];

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'B') {
                if (index > 0)
                    index--;
            } else {
                ans[index++] = s.charAt(i);
            }
        }

        for (int i = 0; i < index; i++) {
            System.out.print(ans[i]);
        }
    }
}


Measured memory_bytes: 21972
N, M = map(int, input().split())
result = [0 for i in range(N)]
right = 0
penalty = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if result[p - 1] != -1:
    if s == "WA":
      result[p - 1] += 1
    else:
      right += 1
      penalty += result[p - 1]
      result[p - 1] = -1
print("{} {}".format(str(right), str(penalty)))

Measured memory_bytes: 3888
#include<stdio.h>
#include <string.h>


int main(){
  int i=0,j=0;
  int searchbool,readrange,slen,plen;
  char s[101],p[101];
  char s2[202]={};

  memset(s,'\0',202);
  memset(p,'\0',101);
  scanf("%s\n",s);
  scanf("%s\n",p);
  slen = strlen(s);
  plen = strlen(p);
  searchbool = 0;

  strcpy(s2, s);
  strcat(s2,s);
  readrange = 2 * slen - plen + 1;
  for(i=0;i<readrange;i++){
    for(j=0;j<plen;j++){
      if (s2[i+j]==p[j]){
        searchbool = 1;
      }
      else{
        searchbool = 0;
        break;
      }
    }
    if (searchbool==1){
      break;
    }
  }

  if(searchbool){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}



Measured memory_bytes: 2044
func main() {
    let N = Int(readLine()!)!
    
    let A = Array(readLine()!).map { $0 == "R" ? 0 : 1 }
    let S = A.sorted(by: <)
    
    var c = 0
    for i in 0..<N {
        if A[i] != S[i] { c += 1 }
    }
    
    print(c/2)
}

main()



Measured memory_bytes: 11700
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int n,m;
int shu;
long long ans;
priority_queue<int>p;
int main()
{
    scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){scanf("%d",&shu);p.push(shu);}
    for(int i=1;i<=m;i++)
     {
         shu=p.top()/2;
         p.pop();p.push(shu);
     }
    while(p.size())
    {
        ans=ans+p.top();
        p.pop();
    }
     printf("%lld",ans);
     return 0;
}
 

Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AB = ReadSplitInt();
            if (AB[0] == 1) AB[0] = 14;
            if (AB[1] == 1) AB[1] = 14;

            if (AB[0] == AB[1]) Println("Draw");
            else if (AB[0] < AB[1]) Println("Bob");
            else Println("Alice");
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<queue>
#include<string>
using namespace std;
int main()
{
	queue<pair<string,int>> Q;
	int elaps=0;
	string name;int t;
	int n,q;cin>>n>>q;
	for(int i=0;i<n;i++)
	{
		cin>>name>>t;
		Q.push(make_pair(name,t));
	}
	
	pair<string,int> u;
	for(;!Q.empty();)
	{
		u=Q.front();Q.pop();
		if(u.second<=q)
		{
			elaps+=u.second;
			cout<<u.first<<" "<<elaps<<endl;
		}
		else
		{
			elaps+=q;
			u.second-=q;
			Q.push(u);
		}
	}
	return 0;
}

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

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

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

    int ans = 0;
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            for (int k = 1; k <= K; k++)
            {
                int tmp = gcd(i, j);
                ans += gcd(tmp, k);
            }
            
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

#define TRUE 1
#define FALSE 0
#define MAX_NUM 100002
typedef struct pp{
  char c;
  int h;
  int w;
}P;

int top = 0;
P *Stack = NULL;
P *tmp = NULL;


void initialize(){
  Stack = (P *)calloc(MAX_NUM, sizeof(P));
  top = 0;
}

void finalize(){
  if(Stack != NULL){
    free(Stack);
    Stack = NULL;
  }
}

int isEmpty(){
  if(top <= 0){
    return TRUE;
  }else{
    return FALSE;
  }
}

int isFull(){
  if(top > MAX_NUM - 1){
    return TRUE;
  }else{
    return FALSE;
  }
}

int push(P x){
  fprintf(stderr, "pushするのは%c (h, w) = (%d, %d)\n", x.c, x.h, x.w);
  //printf("push x = %d\n",x);
  if(isFull() != FALSE){
    //    fprintf(stderr, "pushしたのは%d top = %d\n", Stack[top], top);
    printf("Error! Overfllow\n");
    return 0;
  }else{
    top++;
    if(Stack != NULL){
      Stack[top] = x;
    }
    return 0;
  }
}

P pop(){
  if(isEmpty() != FALSE){
    printf("Error! Underfllow\n");
    return *tmp;
  }else{
    top--;
    // return では取りだす値を返す
    //    fprintf(stderr, "popしたのは%d top = %d\n", Stack[top + 1], top);
    return Stack[top+1];
  }
}

// min
int main(void){
  int r = 0;
  int ans = 0;

  scanf("%d", &r);

  printf("%d\n", r*r);
  
  return 0;

}


Measured memory_bytes: 128
#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 vector<pii> VP;
typedef vector<string> VS;
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
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int N; cin >> N;
	int ans = 1;
	eFOR(i, 1, N) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;

ll dp[2010]={};

int main() {
  int n;
  cin >> n;
  dp[0]=1;
  rep(i,n+1){
    for(int j=i+3;j<=n;j++){
      dp[j]+=dp[i];
      dp[j]%=mod;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 3620
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    c = 1
    while a[0] % (2 * c) == 0:
        c *= 2
    for _a in a:
        if _a % c or not _a // c % 2:
            return "0"
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17172
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 55;
cs int INF = 1e9 + 7;
int n, Ans; 
vector<int> E[N], G[N], tG[N];
void rebuild(int u, int v){
	for(int i=1; i<=n; i++)if(i!=u){
		G[i].clear();
		for(int e=0; e<(int)tG[i].size(); e++) 
		if(tG[i][e]!=u) G[i].pb(tG[i][e]);
	} if(u) G[u].clear(), G[u].pb(v), G[v].pb(u);
}
vector<int> T[N];
int A[N], B[N];
void fir_dfs(int u, int f){
	A[u]=f;
	for(int e=0,v;e<(int)E[u].size();e++) 
	if((v=E[u][e])!=f) fir_dfs(v,u);
} void sec_dfs(int u, int f){
	B[u]=f;
	for(int e=0,v;e<(int)G[u].size();e++)
	if((v=G[u][e])!=f) sec_dfs(v,u);
} bool nt[N]; int dg[N];
int topsort(){
	static int q[N]; int hd=1, tl=0;
	for(int i=1; i<=n; i++) 
	if(nt[i]&&!dg[i]) q[++tl]=i;
	while(hd<=tl){
		int x=q[hd++]; 
		for(int e=0,v; e<(int)T[x].size(); e++){
			v=T[x][e]; if(--dg[v]==0) q[++tl]=v;
		}
	} return tl;
}
int cope(int u){
	for(int i=1; i<=n; i++) T[i].clear(), dg[i]=0;
	fir_dfs(u,0); sec_dfs(u,0); int ct=0;
	for(int i=1; i<=n; i++) ct+=(nt[i]=(A[i]!=B[i]));
	if(!ct) return 0;
	for(int i=1; i<=n; i++){
		if(!nt[i]){ if(nt[A[i]]) return INF; continue; }
		if(nt[A[i]]) T[A[i]].pb(i),++dg[i];
		if(nt[B[i]]) T[i].pb(B[i]),++dg[B[i]];
	} if(topsort()!=ct) return INF; return ct;
}
void Main(){
	scanf("%d",&n); Ans=INF;
	for(int i=1; i<=n; i++)
	E[i].clear(), tG[i].clear();
	for(int i=1,u,v; i<n; i++)
	scanf("%d%d",&u,&v), E[u].pb(v), E[v].pb(u);
	for(int i=1,u,v; i<n; i++)
	scanf("%d%d",&u,&v), tG[u].pb(v), tG[v].pb(u);
	for(int u=1; u<=n; u++) 
	rebuild(0,0), Ans=min(Ans,cope(u));
	for(int u=1; u<=n; u++) 
	if(tG[u].size()==1){
		for(int v=1; v<=n; v++)
		rebuild(u,v), Ans=min(Ans,1+cope(u));
	} cout<<((Ans>=INF)?-1:Ans)<<'\n';
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	int T; scanf("%d",&T); 
	while(T--) Main(); return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int q;
ll cal(ll a,ll b){
	if(a==b)return 2*a-2;
	if(a+1==b)return 2*a-2;
	ll c=sqrt(a*b);
	if(c*c==a*b)c--;
	if(c*(c+1)>=a*b)return 2*c-2;
	else return 2*c-1;
}
int main(){
	cin>>q;
	REP(i,q){
		ll a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		cout<<cal(a,b)<<endl;
	}
	return 0;

	}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0) Pr(1);
    a -= d;
    if(a <= 0) Pr(0);
  }
}


Measured memory_bytes: 3652
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string a, b;
int la, lb;

int main() {
	cin >> a >> b;
	la = (int)a.length(), lb = (int)b.length();
	if (la>lb) cout << "GREATER" << ln;
	else if (la<lb) cout << "LESS" << ln;
	else {
		rep(i,la) {
			if (a[i]-'0' > b[i]-'0') {
				cout << "GREATER" << ln;
				return 0;
			} else if (a[i]-'0' < b[i]-'0') {
				cout << "LESS" << ln;
				return 0;
			}
		}
		cout << "EQUAL" << ln;
	}
}

Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

s = input()

first = int(s[:2])
second = int(s[2:])

fmonth = 1<=first<=12
smonth = 1<=second<=12

if fmonth and smonth:
    print 'AMBIGUOUS'
elif fmonth:
    print 'MMYY'
elif smonth:
    print 'YYMM'
else:
    print 'NA'


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

int main()
{

  string a,b,c;
  cin >> a>>b>>c;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int const N=1e5;
int prime[N];
int ans[N];
int main() {
    //memset(prime,1, sizeof(prime));
    for(int i=2;i<=N;i++)
        prime[i]=1;
    prime[0]=0;prime[1]=0;
for(long long  i=2;i<=N;i++)
{
    if(prime[i]==1)
    {
        //cout<<i;
        for(long long  j=i*i;j<=N;j+=i)
        {

            //cout<<j;
         prime[j]=0;
        }
    }
}

for(int i=3;i<=N;i+=2)
{
   int  x=(i+1)/2;
    if(prime[i]&&prime[x])
    {
       // prime[i]=1;
       ans[i]=1;
   // cout<<"yes";
    }
    else
        ans[i]=0;
   // cout<<i;
}

for(int i=1;i<N;i++)
{
    ans[i]+=ans[i-1];
}

int q;
cin>>q;
while(q--)
{
    int l,r;
    cin>>l>>r;

    cout<<ans[r]-ans[l-1]<<endl;
}
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    ll res;cin>>res;
    rep1(i,n){
        ll p; cin >> p;
        res = res/__gcd(res,p)*p;
    }
    out(res);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[250];
    int count = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;

    while(true){
        bool exist_odd = false;
        for(int i = 0; i < n; i++){
            if(a[i]%2 != 0) exist_odd = true;
        }

        if(exist_odd == true) break;

        for(int i = 0; i < n; i++){
            a[i] = a[i]/2;
        }

        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    string s;
    cin >> s;
    s[1] = (s[1] == 'B')? 'R' : 'B';
    cout << s << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	string str;	
	vector<string> screen(H);

	for(int h=0;h<H;h++){
			cin >> str;
			str = "#" + str + "#";
			screen[h] = str;
	}

	string updown = "";
	for(int w=0;w<W+2;w++)  updown+="#";

	cout << updown << endl;
	for(int h=0;h<H;h++){
		cout << screen[h] << endl;
	}
	cout << updown << endl;

	return 0;
}


Measured memory_bytes: 888
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m, k = MAP()
for i in range(n+1):
    for j in range(m+1):
        if k == i*(m-j) + (n-i)*j:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 10076
N, K = map(int, input().split())
R, S, P = map(int, input().split())


dic = {'r':P, 's':R, 'p':S}
flag = [0]*N
rlt = 0

T = input()

for i in range(N):
  if i < K or T[i] != T[i-K] or flag[i-K] == 1:
    rlt += dic[T[i]]
  else:
    flag[i] = 1
    
print(rlt)

Measured memory_bytes: 74132
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
bool check(string s)
{
    ll n= s.size();
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[n-i-1]) return false;
    }
    return true;
}
int main()
{
    string s;
    cin>>s;
    ll n=s.size();
    string str,strr;
    for(int i=1;i<=(n-1)/2;i++) str.push_back(s[i-1]);
    for(int i=(n+3)/2;i<=n;i++) strr.push_back(s[i-1]);
    if(check(s)&& check(str)&& check(strr)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	ll ans = 0;
	ans = ceil((double)(n - 1) / (k - 1));
	printf("%lld\n", ans);

	Please AC;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

vector<int> z_algorithm(const string& s, int n = -1) {
  if (n < 0) n = s.size();
  vector<int> prefix(n);
  for (int i = 1, j = 0; i < n; i++) {
    if (i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while (i + k < n && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = n;
  return prefix;
}

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    auto p = z_algorithm(s.substr(i));
    // dump(i, p);
    for (int j = i + 1; j < n; j++) {
      int len = min(p[j - i], j - i);
      ans = max(ans, len);
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<long long int> f(N + 1,0);
  vector<int> a(M + 1,0);

  for(int i = 0;i < M;i++){
    cin >> a[i];
    //a[i] -= 1;
  }
  
  long long int temp1,temp2;

  f[0] = 1;
  //f[1] = 2;
  
  int j = 0;

  //1,2段目が抜けていた場合
  /*if(a[0] == 0){
    f[0] = 0;
    f[1] = 1;
    j++;
  } 
  if(a[0] == 1 || a[1] == 1){
    f[1] = 0;
    j++;
  }
  */
  temp1 = f[0];
  temp2 = 0;

  //cout << f[0] << " " << f[1] << " ";

  for(int i = 1;i < N + 1;i++){
    //f[i] がaと一致しない場合は行う
    if(i != a[j]){
      f[i] = temp1 + temp2;
    }else{
      j++;
    }
    temp2 = f[i - 1];
    temp1 = f[i];
    f[i] %= 1000000007;
  }

  cout << f[N] << endl;
}


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

namespace algorithm
{
	class Program
	{

		public static void Main()
		{
			int n = int.Parse(Console.ReadLine());
			Queue<string> num = new Queue<string>();
			List<long> List = new List<long>();
			while (num.Count > 0)
			{
			}

			num.Enqueue("3");
			num.Enqueue("5");
			num.Enqueue("7");
			while (num.Count >0)
			{
				string tmp = num.Dequeue();
				if(tmp.Contains("3"))
					if (tmp.Contains("5"))
						if (tmp.Contains("7"))
							List.Add(long.Parse(tmp));
				if (tmp.Length < 11)
				{
					num.Enqueue(tmp + "3");
					num.Enqueue(tmp + "5");
					num.Enqueue(tmp + "7");
				}
			}

			Console.WriteLine(List.Count(x=>x<=n && x >=357));
		}
		
	}

}




Measured memory_bytes: 37332