akhauriyash/Code-Regression huggingface dataset:
program step
	implicit none
    integer(8):: N
    integer(8):: step_size(200000), height(200000)
    integer(8):: i, h1, h2

	read(*,*) N    
    read(*,*) (height(i),i=1,N)
    step_size(1:N)=0

	do i = 1, N-1
    	h1 = height(i)+step_size(i)
        h2 = height(i+1)+step_size(i+1)
    	if (h1>h2) then
        	step_size(i+1)=step_size(i+1)+h1-h2
        end if
    end do
    write(*,'(i0)') sum(step_size(1:N))
end program


Measured memory_bytes: 6216
def resolve():
	n=int(input())
	a=list(map(int,input().split()))
	m=10**9
	for i in a:
		c=0
		n=i
		while n%2==0 and c<m:
			c+=1
			n//=2
		m=min(c,m)
	print(m)
resolve()

Measured memory_bytes: 38640
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String Sd = sc.next();
        String T = sc.next();
        char[] sd = Sd.toCharArray();
        char[] t = T.toCharArray();
        int tlen = t.length;
        String tmp = "";
        int tleft = 9999;
        for (int i = Sd.length() - 1;;) {
            int left = i - tlen + 1;
            if (left < 0) {
                break;
            }

            if (check(left, i, sd, t)) {
                tmp = new String(t);
                tleft = left;
                break;
            }
            i--;
        }

        if (tleft == 9999) {
            System.out.println("UNRESTORABLE");
        } else {
            // System.out.println(Sd.substring(0, tleft).replaceAll("\\?", "a")
            // + tmp);
            StringBuilder sb = new StringBuilder();
            sb.append(Sd);
            sb.replace(tleft, tleft + tlen, tmp);
            System.out.println(sb.toString().replaceAll("\\?", "a"));
        }
    }

    boolean check(int s, int g, char[] sd, char[] t) {
        int ti = 0;
        for (int i = s; i <= g; i++) {
            if (sd[i] != '?' && sd[i] != t[ti]) {
                return false;
            }
            ti++;
        }
        return true;
    }
}


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

using namespace std;

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

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

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

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

    int n, s[(1 << 18) + 10];

    cin >> n;
    REP(i, 1 << n)
    cin >> s[i];

    sort(s, s + (1 << n));

    int i = (1 << n) - 1;

    priority_queue<int> q;

    q.push((1 << (n + 1)) - 1);

    while (i >= 0)
    {
        int cnt = 1;

        while (i >= 0 && s[i] == s[i - 1])
        {
            cnt++;
            i--;
        }

        if (cnt > q.size())
        {
            cout << "No" << endl;
            return 0;
        }

        V v;

        REP(j, cnt)
        {
            v.push_back(q.top());
            q.pop();
        }

        REP(j, cnt)
        {
            int p = v[j];

            int k = 2;
            while (true)
            {
                if (p / k < 1)
                    break;

                q.push(p / k);

                k *= 2;
            }
        }

        i--;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2552
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef unsigned long long ll;
typedef vector<string> vs;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int main()
{
	string t; int n;
	while(getline(cin,t)){
		string s;
		fr(i,t)if(isalpha(*i))s.pb(toupper(*i));
		n=s.size();
		set<string> S;
		rep(i,n-2){
			ll h=0,H=0,b=1;
			int j=i;
			rep(k,2){
				h*=29; h+=s[j]-'A';
				H+=b*(s[j]-'A'); b*=29; j++;
			}
			for(;j<n;j++){
				h*=29; h+=s[j]-'A';
				H+=b*(s[j]-'A'); b*=29;
				if(h==H)S.insert(s.substr(i,j-i+1));
			}
		}
		vs v; fr(i,S)v.pb(*i);
		int m=v.size(); bool f=1;
		vector<int> len; rep(i,m)len.pb(v[i].size());
		rep(i,m){
			rep(j,m)if(i!=j){
				if(len[i]<len[j]&&v[i]==v[j].substr((len[j]-len[i])/2,len[i]))goto FAIL;
			}
			if(!f)cout<<" "; else f=0;
			cout<<v[i]; FAIL:;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = gets.chomp.to_i
p = gets.chomp.split.map(&:to_i)
count = 0
0.upto(n-3) do |i|
  if (p[i] < p[i+1]) && (p[i+1] < p[i+2]) then
    count += 1
  elsif (p[i] > p[i+1]) && (p[i+1] > p[i+2]) then
    count += 1
  end
end
puts count

Measured memory_bytes: 3836
n = int(input())
v = [int(i) for i in input().split()]
m = n//2

a = [v[2*i] for i in range(0,m)]
b = [v[2*i+1] for i in range(0,m)]

def mode(arr):
        r = [0] * (max(arr) + 1)
        for a in arr:
            r[a] += 1
        return r.index(max(r))

A = mode(a)
B = mode(b)

v.remove(A)

if v == []:
    print(m)
    exit()
if A == B:
    if a.count(A) < b.count(B):
        a.remove(A)
        C = mode(a)
        print(n - a.count(C) - b.count(B))
    else:
        if b.count(B) == m:
            print(n - m)
        else:
            if a.count(A) == b.count(B):
                t = a.count(A)
                a.remove(A)
                b.remove(B)
                D = mode(a)
                E = mode(b)
                if a.count(D) > b.count(E):
                    print(n - t - a.count(D))
                else:
                    print(n - t - b.count(E))
            else:
                b.remove(B)
                C = mode(b)
                print(n - a.count(A) - b.count(C))
else:
    print(n - a.count(A) - b.count(B))

Measured memory_bytes: 56216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  int Q;cin >> Q;
  vector<int> k(Q);
  rep(i,Q)cin >> k[i];
  map<int,ll> mp;
  rep(q,Q){
    if(mp.count(k[q])){
      cout << mp[k[q]] << endl;
      continue;
    }
    ll ans = 0;
    ll n_D = 0;
    ll n_M = 0;
    ll add = 0;
    rep(i,N){
      if(s[i] == 'D') ++n_D;
      if(s[i] == 'M'){
        ++n_M;
        add += n_D;
      }
      if(i<2)continue;
      if(i>=k[q]){
        if(s[i-k[q]] == 'D'){
          add -= n_M;
          --n_D;
        }
        if(s[i-k[q]] == 'M') --n_M;
      }
      if(s[i] == 'C')ans += add;
    }
    cout << ans << endl;
    mp[k[q]] = ans;
  }
  return 0;
}


Measured memory_bytes: 1948
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

const LL MOD = 1000000007;
static const size_t MAX_N = 400000;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

LL range_sum(LL a, LL b) {
	return (b * (b + 1)) / 2 - ((a - 1) * a) / 2;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, k = -1;
		cin >> n >> k;
		if (n < 0) return 0;
		modll ans = 0;
		for (int i = k; i <= n + 1; ++i) {
			LL lower = range_sum(0, i - 1);
			LL upper = range_sum(n + 1 - i, n);
			ans += (upper - lower + 1) % MOD;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int Q;

ll solve(ll a, ll b) {
  ll l = 0, r = 1LL<<31;
  while(r - l > 1) {
    ll m = (l + r) / 2;

    ll res = 0;
    for(ll i = max(m/2-10,1LL); i <= min(m/2+10, m); i++) {
      ll j = i;
      if(a <= i) j++;
      ll k = m + 1 - i;
      if(b <=  m + 1 - i) k++;
      res = max(res, j*k);
    }
    if(res < a*b) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}

int main () {
  cin >> Q;

  rep(i,Q) {
    ll A, B;
    cin >> A >> B;

    cout << solve(A, B) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
a = l()

for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")
    else:
        print("No")


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

int main() {
  int N;
  cin >> N;
  
  cout << (N+1)/2 << endl;
  return 0;
}




Measured memory_bytes: 3612
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i
  character(20) :: s(50, 2) = ''
  integer(8) :: c(50) = 0, m(50, 21, 2) = 0, x = inf
  logical :: u(50, 21, 2) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 1), c(i)
    s(i, 2) = reverse(s(i, 1)(1:len_trim(s(i, 1))))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 1) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    do t = 1, n
      l = j
      r = 1
      do while (l <= len_trim(s(i, k)) .and. r <= len_trim(s(t, 3 - k)))
        if (s(i, k)(l:l) /= s(t, 3 - k)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == len_trim(s(i, k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, 3 - k) + c(t))
      end if
      if (r == len_trim(s(t, 3 - k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

Measured memory_bytes: 2896
nim, mike, kite = map(int, input().split())

INF = 10 ** 11 + 1
S = [-INF] + [int(input()) for _ in range(nim)] + [INF]
T = [-INF] + [int(input()) for _ in range(mike)] + [INF]
X = [int(input()) for _ in range(kite)]

def bsr(a, v):
	lo, hi = 0, len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x < a[mid]: hi = mid
		else: lo = mid + 1
	return lo

for x in X:
	sr = bsr(S, x)
	sl = sr - 1
	tr = bsr(T, x)
	tl = tr - 1
	cost = []
	for m in [S[sr], S[sl]]:
		for n in [T[tr], T[tl]]:
			cost += [abs(x - m) + abs(m - n), abs(x - n) + abs(m - n)]
	print(min(cost))


Measured memory_bytes: 16128
"use strict";
function Main(input) {
  input = input.split("\n");
  const persons = input[1].split(" ");
  const boxes = [];
  let freeColorCount = 0;
  const rates = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200];
  
  for(let i=0; i < rates.length; i++){
      boxes[i] = false;
  }
    
  for(let personCount=0; personCount < persons.length; personCount++){
      const inputValue = parseInt(persons[personCount], 10);
      const rateIndex = rates.findIndex(rate => rate > inputValue);    
      boxes[rateIndex] = true;
      if(rateIndex === -1){
          freeColorCount ++;
      }
  }
  let  color = 0;
  for(let colorCount=0; colorCount < boxes.length; colorCount++){
      color += boxes[colorCount];
  }
  
  const max = color + freeColorCount;
  let min = color;
  
  if(color === 0 && freeColorCount > 0){
      min = 1;
  }
  console.log(min,max);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
struct union_find {
	ll par[MAX_N];
	ll Size[MAX_N];
	union_find(ll n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			Size[i] = 1;
		}
	}
	ll root(ll x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	bool same(ll x, ll y) {
		return root(x) == root(y);
	}
	void unite(ll x, ll y) {
		if (same(x, y))return;
		Size[root(x)] += Size[root(y)];
		par[root(y)] = root(x);
	}
};

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m,0),b(m,0);
    for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
	}
    vector<ll> ans(m);
    struct union_find U(n);
    for(int i=m-1;i>=0;i--){
		if(!U.same(a[i],b[i])){
			ans[i]=U.Size[U.root(a[i])]*U.Size[U.root(b[i])];
		}
		//cout<<"a.size="<<U.Size[a[i]]<<" , b.size="<<U.Size[b[i]]<<endl;
		U.unite(a[i],b[i]);
    }
    for(int i=0;i<m;i++){
		cout<<ans[i]<<endl;
		if(i<m-1) ans[i+1]+=ans[i];
	}
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
#define REP1(i,n1,n2) for (int i=n1; i<n2; i++)
vi primes;

int get_primes(int m){
    int n = (m+1)/2, root = (int)(pow(n, 0.5));
    vector <bool> N(n, true);
    N[0]=false;

    if (m>1) primes.push_back(2);
    REP1(i,1,root){
        int tmp = i*2+1;
        if (N[i]){
            primes.push_back(tmp);
            for (int j=i+tmp; j<n+1; j+=tmp)
				N[j]=false;
        }
    }
    REP1(i,root,n+1)
        if(N[i]) primes.push_back(2*i+1);
    return 0;
}

int main(){
	get_primes(50100);
	while (true){
		int n,a,b;
		cin>>n;
		if (cin.eof()) break;
		REP1(i,0,(int)primes.size()){
			a=primes[i];
			if (a<n) b=a;
			else if (a>n) break;
		}
		cout<<b<<" "<<a<<endl;
	}
}

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

int	main()
{
	string	S;
	cin >> S;
	int		size = S.size();
	
	if (size < 2 || size % 2) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < size; ++i) {
		if (i % 2 == 0 && S.at(i) != 'h') {
			cout << "No" << endl;	
			return 0;
		}
		if (i % 2 == 1 && S.at(i) != 'i') {
			cout << "No" << endl;	
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int D,E,F;
    D=abs(A-B);
    E=abs(B-C);
    F=abs(C-A);
    cout<<D+E+F-max(max(D,E),F)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
const integer p = 1000000007;

int main(){
	string S;
	getline(cin,S);
	int len = S.length();

	static integer dp[100002][5] = {};

	for(int i = len; 0 <= i; i--){
		for(int j = 3 ; 0 <= j; j--){
			if ((i==len) and (j==3)){
				dp[i][j] = 1;
			}else if(i == len){
				dp[i][j] = 0;
			}else if(j==3){
				if(S[i] == '?'){
					dp[i][j] = (3 * dp[i+1][j])%p;
				}else{
					dp[i][j] = dp[i+1][j];
				}
			}else{
				integer m1,m2;
				if (S[i] == '?') m1=3;
				else m1 = 1;

				m2 = 0;

				if((S[i]=='?') or ((j==0) and (S[i] == 'A'))) m2 = 1;
				if((S[i]=='?') or ((j==1) and (S[i] == 'B'))) m2 = 1;
				if((S[i]=='?') or ((j==2) and (S[i] == 'C'))) m2 = 1;
				
				dp[i][j] = (m1*dp[i+1][j] + m2*dp[i+1][j+1]) % p;
			}
		}
	}

	PRINTLLD(dp[0][0] % p);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
  // Your code here!
  long double a, b, c;
  cin >> a >> b >> c;

  long double a2 = sqrtl(a);
  long double b2 = sqrtl(b);
  long double c2 = sqrtl(c);
  long double tmp = sqrtl(a*b);
  if (2*tmp < c-a-b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

void op(const int& a){
	if(a==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
}


int main()
{
	int n,k;
	int a[100];
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[100001];
	dp[0]=-1;
	for(int i=1;i<=k;i++)
	{
		int val=0;
		for(int j=0;j<n;j++)
		{
			if(a[j]>i)
				break;
			if(dp[i-a[j]]==-1)
				val=1;
		}
		if(val)
			dp[i]=1;
		else
			dp[i]=-1;
	}
	op(dp[k]);
}
	

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a, b, c, d, e = [int(x) for x in stdin.readline().rstrip().split()]
    start = a*60 + b
    end = c*60 + d
    print(end - start - e)

main()

Measured memory_bytes: 9936
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        k: usize,
        mut s: chars,
    }
    match s[k - 1] {
        'A' => s[k - 1] = 'a',
        'B' => s[k - 1] = 'b',
        'C' => s[k - 1] = 'c',
        _ => {}
    }
    println!("{}", s.into_iter().collect::<String>());
}


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

int main() {
    int N; cin >> N;
    vector<string> verdict(N);
    for (int i = 0; i < N; i++) cin >> verdict[i];
    string values[4] =  {"AC", "WA", "TLE", "RE"};
    int frq1 = count(verdict.begin(), verdict.end(), values[0]);
    int frq2 = count(verdict.begin(), verdict.end(), values[1]);
    int frq3 = count(verdict.begin(), verdict.end(), values[2]);
    int frq4 = count(verdict.begin(), verdict.end(), values[3]);

    cout << "AC " << "x " << frq1 << "\n";
    cout << "WA " << "x " << frq2 << "\n";
    cout << "TLE " << "x " << frq3 << "\n";
    cout << "RE " << "x " << frq4 << "\n";
    return 0;
}

Measured memory_bytes: 6428
#include <cstdint>
#include <cstdio>

const int64_t MOD = 998244353;
const int N = 1e7 + 10;
int n;
int64_t fac[N], inv[N], pow2[N];

int64_t pow(int64_t a, int exp) {
    int64_t ret = 1;
    while (exp) {
        if (exp & 1) (ret *= a) %= MOD;
        (a *= a) %= MOD;
        exp >>= 1;
    }
    return ret;
}

int main() {
    scanf("%d", &n);
    int64_t a = pow(3, n), b = 0;
    fac[0] = inv[0] = inv[1] = pow2[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % MOD;
    for (int i = 2; i < N; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    for (int i = 2; i < N; i++) (inv[i] *= inv[i - 1]) %= MOD;
    for (int i = 1; i < N; i++) pow2[i] = (pow2[i - 1] << 1) % MOD;
    for (int i = n / 2 + 1; i <= n; i++) (b += fac[n] * inv[i] % MOD * inv[n - i] % MOD * pow2[n - i]) %= MOD;
    int64_t ans = ((a - 2 * b) % MOD + MOD) % MOD;
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 234496
N, M = map(int, input().split())

if N==1 or M==1:
    if N==1 and M==1:
        print(1)
    else:
        if N < M:
            N, M = M, N
        print(N-2)

else:
    print((N*M) - N*2 - M*2 + 4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {


    string a;
    cin>>a;
    int n=a.length();

    int ans[n+1]={0};
    int cnt1=0,cnt2=0;
    int ind;
    for (int i = 0; i < n; ++i) {
        cnt1=0,cnt2=0;

        if(a[i]=='R')
        {
            while (a[i]=='R')
            {
                cnt1++;
                i++;
            }

            ind=i-1;

            while (a[i]=='L')
            {
                i++;
                cnt2++;
                if(i==n)
                    break;
            }
            i--;
            if((cnt1+cnt2)%2==0)
            {
                ans[ind]=(cnt1+cnt2)/2;
                ans[ind+1]=(cnt1+cnt2)/2;
            }
            else
            {
                if(cnt1%2==1)
                {
                    ans[ind]=(cnt1+cnt2+1)/2;
                    ans[ind+1]=(cnt1+cnt2)/2;
                }
                else
                {
                    ans[ind]=(cnt1+cnt2)/2;
                    ans[ind+1]=(cnt1+cnt2+1)/2;
                }
            }
        }


    }


    for (int i = 0; i < n; ++i) {
        cout<<ans[i]<<" ";
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int a,b;
char op;

int main(){
    while(true){
        cin>>a>>op>>b;
        if(op=='?')return 0;
        else if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
l = input().split(' ')

y = int(l[3]) - int(l[1])
x = int(l[2]) - int(l[0])

def my_print(i,str):
    for j in range(i):
        print(str,end='')
"""
for i in range(x):
    print('U',end='')

for i in range(y):
    print('R',end='')

for i in range(x):
    print('D',end='')

for i in range(y+1):
    print('L',end='')

for i in range"
"""
my_print(y,'U')
my_print(x,'R')
my_print(y,'D')
my_print(x+1,'L')
my_print(y+1,'U')
my_print(x+1,'R')
my_print(1,'D')
my_print(1,'R')
my_print(y+1,'D')
my_print(x+1,'L')
my_print(1,'U')


print()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
typedef long long ll;
#define MAXNUM 111111
vector<pii> v[2];
int dset[MAXNUM],ssize[MAXNUM];
int fa(int a)
{
    if(dset[a]!=a)return dset[a]=fa(dset[a]);
    return a;
}
int main()
{
    ll m;
    int n,q,a,b,c;scanf("%d%lld%d",&n,&m,&q);
    rep(i,1,n+1)dset[i]=i;
    rep(i,1,q+1)scanf("%d%d%d",&a,&b,&c),a++,b++,v[c].emplace_back(a,b);
    ll up=n*1ll*(n-1)/2,down=n-1;
    int flag=1;
    for(pii p:v[0])
        dset[fa(p.first)]=fa(p.second);
    int dnum=0;
    rep(i,1,n+1)ssize[fa(i)]++,dnum+=i==fa(i);
    for(pii p:v[1])
    {
        if(fa(p.first)==fa(p.second))flag=0;
    }
    if(!v[1].empty())down++;
    if(!v[1].empty()&&dnum<=2)flag=0;
    up=dnum*1ll*(dnum-1)/2;
    rep(i,1,n+1)if(fa(i)==i)
        up+=ssize[i]-1;
    if(m>up||m<down)flag=0;
    if(flag)printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 2036
q=input()
for i in [1]*q:
	c,a,n=map(int,raw_input().split())
	s=0
	while c>0 and a>0 and n>0:
		s+=1
		c,a,n=c-1,a-1,n-1
	while c>0 and a>0:
		s+=1
		c,a=c-2,a-1
	print s+c/3

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int MAX_N = 1e5 + 5;

int a[MAX_N];

int main() {
	int n;
	scanf(" %d", &n);
	
	for(int i = 0; i < n; i++) {
		scanf(" %d", &a[i]);
	}
	
	sort(a, a + n);
	
	vector< int > possibleSides;
	
	for(int i = 1; i < n; i++) {
		if(a[i] == a[i - 1]) {
			possibleSides.pb(a[i]);
			i++;
		}
	}
	
	if(possibleSides.size() < 2) {
		printf("0\n");
	}
	else {
		printf("%lld\n", 1ll * possibleSides[possibleSides.size() - 2] * possibleSides[possibleSides.size() - 1]);
	}
	
	return 0;
}


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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int a[100010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, 0, n){
        // cout << "i = " << i << endl;
        // cout << a[i] << endl;
        // cout << a[a[i]-1]-1 << endl;
        // cout << "---" << endl;
        if(i == a[a[i]-1]-1) ans++;
    }
    
    cout << ans/2 << endl;
    
}

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

typedef long long ll;
typedef unsigned long long ull;

vector<int> Zalgorithm(vector<int> S) {
    vector<int> A(S.size());
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }
    return A;
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), S(3 * N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    rep(i, N) {
        S[i] = b[i] ^ b[(i + 1) % N];
        S[N + i] = a[i] ^ a[(i + 1) % N];
        S[N + N + i] = a[i] ^ a[(i + 1) % N];
    }
    auto A = Zalgorithm(S);
    rep(i, N) {
        if (A[N + i] >= N) {
            cout << i << " " << (a[i] ^ b[0]) << "\n";
        }
    }
}

Measured memory_bytes: 9688
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
    int T,H,S,t3,h3,s3,sum,sum3,t,h,s;
    for(;;){
        cin>>T>>H>>S;
        if(T==-1&&H==-1&&S==-1)break;
        sum=7200-(T*3600+H*60+S);
        t=sum/3600;
        s=sum%60;
        h=(sum-(t*3600)-s)/60;
        sum3=sum*3;
        t3=sum3/3600;
        s3=sum3%60;
        h3=(sum3-(t3*3600)-s3)/60;
        printf("%02d:%02d:%02d",t,h,s);
        cout<<endl;
        printf("%02d:%02d:%02d",t3,h3,s3);
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>

int main()
{
  int N, i;
  int W[100];
  int S1, S2;
  int T;
  int sub[100] = {0};
  int ans;

  scanf("%d", &N);
  for ( i = 0; i < N; i++)
  {
    scanf("%d", &W[i]);
  }

  for ( T = 1; T < N; T++)
  {S1=0;
  S2=0;

    for ( i = 0; i < T; i++)
    {
    S1 = S1 + W[i];
    }

    for ( i = T; i < N; i++)
    {
    S2 = S2 + W[i];
    }
    //printf(" %d %d\n", S1, S2);
    sub[T] = (S1>S2 ? S1-S2 : S2-S1);
    ans = sub[T]<sub[T-1] ? sub[T]:ans;
  }

  
  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(int argc, char const* argv[])
{
    string w;
    map<char, int> mp;
    cin >> w;
    for (int i = 0; i < w.size(); i++) {
        mp[w[i]]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

k, s = map(int, input().split(' '))

counter = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            # print(i, j , s - i - j)
            counter += 1

print(counter)



Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//And Then. How Many Are There?
public class Main{

	int n;
	int[][] c;
	int[] col;

	boolean f(int i, int j, int x){
		if(col[i]!=col[j])return false;
		for(int k=0;k<i;k++){
			if((x&(1<<k))==0)continue;
			if(Math.hypot(c[i][0]-c[k][0], c[i][1]-c[k][1]) < c[i][2]+c[k][2])return false;
		}
		for(int k=0;k<j;k++){
			if((x&(1<<k))==0)continue;
			if(Math.hypot(c[j][0]-c[k][0], c[j][1]-c[k][1]) < c[j][2]+c[k][2])return false;
		}
		return true;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			c = new int[n][3];
			col = new int[n];
			for(int i=0;i<n;i++){
				for(int j=0;j<3;j++){
					c[i][j]=sc.nextInt();
				}
				col[i] = sc.nextInt();
			}
			List<Integer> l = new ArrayList<Integer>();
			l.add((1<<n)-1);
			boolean[] u = new boolean[1<<n];
			u[(1<<n)-1] = true;
			int step = 0;
			while(!l.isEmpty()){
				List<Integer> next = new ArrayList<Integer>();
				for(int s:l){
					int i = 0;
					while(i<n){
						if((s&(1<<i))>0){
							int j = i+1;
							while(j<n){
								if((s&(1<<j))>0){
									int x = s - (1<<i) - (1<<j);
									if(!u[x] && f(i, j, s)){
										next.add(x);
										u[x] = true;
									}
								}
								j++;
							}
						}
						i++;
					}
				}
				l = next;
				step++;
			}
			System.out.println((step-1)*2);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 51000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415936535//ここ

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

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000;

//input
string S;

//processing


//dpTable
int dp[100050];

int main(){
    cin >> S;
    for (int i = 0; i < S.size(); i++){
        if (S.at(i) == '?'){
            S.at(i) = 'D';
        }
    }
    cout << S << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int h[100001];

bool can_banish(ll times, int N, int A, int B) {
    ll rest = times;
    for(int i = 0; i < N; i++) {
        if(h[i] - B * times <= 0) continue;
        rest -= (h[i] - B * times + (A - B) - 1) / (A - B);
        if(rest < 0) return false;
    }

    return true;
}

int main(void) {
    int i, N, A, B;
    ll l = -1, r = 0;
    scanf("%d%d%d", &N, &A, &B);
    for(i=0; i<N; i++) {
        scanf("%d", h+i);
        r = max(r, 1LL * (h[i] + B - 1) / B);
    }

    ll mid = (r + l) / 2;
    while(r - l > 1) {
        if(can_banish(mid, N, A, B)) {
            r = mid;
            mid = (r + l) / 2;
        }
        else {
            l = mid;
            mid = (r + l) / 2;
        }
    }

    return !printf("%lld\n", r);
}

Measured memory_bytes: 640
args = str(input())
args = args.split(" ")
a = int(args[0])
b = int(args[1])
k = int(args[2])

turn = 0
for i in range(k):
    if (turn==0):
        if (a>0):
            if (a % 2 == 1):
                a = a - 1
        if (a>0):
            g = a/2
            a = a - g
            b = b + g
        turn=1
    elif (turn==1):
        if (b>0):
            if (b % 2 == 1):
                b = b -1
        if (b>0):
            g = b/2
            b = b - g
            a = a + g
        turn=0

print(int(a),int(b))


Measured memory_bytes: 3064
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
    n = ni()
    s = ns()

    res = s[0]
    pre = s[0]
    for i, ss in enumerate(s[1:]):
        if ss == pre:
            pass
        else:
            res += pre
            pre = ss
    if not res:
        print(1)
        return
    print(len(res))
main()

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

int	calc_score(int H, int grid[10][5], int score_grid[10][5])
{
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < 5; ++j)
			score_grid[i][j] = 0;
	}
	for (int i = 0; i < H; ++i) {
		int	max_cnt = 0, cnt = 0;
		int	head = 0, argmax = 0;
		for (int j = 0; j < 5; ++j) {
			if (grid[i][j] == grid[i][head]) {
				++cnt;
			} else {
				head = j;	
				cnt = 1;
			}
			if (max_cnt < cnt) {
				max_cnt = cnt;
				argmax = head;
			}
		}
		if (max_cnt < 3) continue;
		for (int j = argmax; j < argmax + max_cnt; ++j)
			score_grid[i][j] = grid[i][j];
	}
	int	score = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < 5; ++j)
			score += score_grid[i][j];
	}
	return score;
}

void	update(int H, int grid[10][5], int score_grid[10][5])
{
	for (int j = 0; j < 5; ++j) {
		int top = H - 1;
		for (int i = H - 1; i >= 0; --i) {
			if (grid[i][j] == score_grid[i][j]) continue;
			grid[top][j] = grid[i][j];
			--top;
		}
		for (int i = top; i >= 0; --i)
			grid[i][j] = 0;
	}
}

int	main()
{
	int	H;
	int	grid[10][5] = {};
	int	score_grid[10][5] = {};
	while (cin >> H) {
		if (H == 0) break;
		int	score = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < 5; ++j)
				cin >> grid[i][j];
		}
		int tmp;
		while ((tmp = calc_score(H, grid, score_grid)) > 0) {
			score += tmp;
			update(H, grid, score_grid);
		}
		cout << score << endl;
	}
}





Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n;
    cin >> n;
    cout << n*n*n;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Kaeru Jump
public class Main{

	int h, w, n;
	char[][] m;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	char[] str = {'U','R','D','L'};
	char[] res;

	int[][] near(int i, int j){
		int[][] r = new int[4][2];
		for(int[]a:r)Arrays.fill(a, -1);
		for(int k=0;k<4;k++){
			int pi = i+d[k][0], pj = j+d[k][1];
			while(0<=pi&&pi<h&&0<=pj&&pj<w){
				if(m[pi][pj]=='o'){
					r[k][0] = pi; r[k][1] = pj; break;
				}
				pi += d[k][0]; pj += d[k][1];
			}
		}
		return r;
	}

	boolean dfs(int i, int j, int D, int c){
		if(c==n-1)return true;
		int[][] e = near(i, j);
		for(int k=0;k<4;k++){
			if(e[k][0]==-1||D==(k+2)%4)continue;
			res[c] = str[k];
			m[i][j] = '.';
			if(dfs(e[k][0], e[k][1], k, c+1))return true;
			m[i][j] = 'o';
		}
		return false;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt(); w = sc.nextInt();
		n = 0;
		m = new char[h][];
		int si = -1, sj = -1, sd = -1;
		for(int i=0;i<h;i++){
			m[i] = sc.next().toCharArray();
			for(int j=0;j<w;j++){
				if(m[i][j]=='.')continue;
				n++;
				if(m[i][j]=='o')continue;
				si = i; sj = j;
				sd = m[i][j]=='U'?0:m[i][j]=='R'?1:m[i][j]=='D'?2:3;
				m[i][j] = 'o';
			}
		}
		res = new char[n-1];
		dfs(si, sj, sd, 0);
		System.out.println(new String(res));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int X;
  cin >> X;
  
  int M = X/500;
  int MT=M*1000;
 // cout<<M<<endl;高橋君の500円玉の数
 // cout<<MT<<endl;500円玉から得た嬉しさ
  
  int S = X%500;
  int ST= S/5*5;
 // cout<<S<<endl;高橋君の500円玉以外のお金
  //cout<<ST<<endl;500円玉以外のお金からいくつ5円玉があるか
  
  cout<<MT+ST<<endl;
  
}

Measured memory_bytes: 256
# ABC082C - Good Sequence (ARC087C)
import sys

input = sys.stdin.readline

from collections import Counter


def main():
    n = int(input())
    cnt = Counter(list(map(int, input().rstrip().split())))
    ans = 0
    for i, j in cnt.items():
        if i > j:
            ans += j
        elif i < j:
            ans += j - i
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

int main()
{
    int D; cin >> D;
    int c[26]; REP(i,26) cin >> c[i];
    int s[D][26]; REP(i,D) REP(j,26) cin >> s[i][j];
    int t[D]; REP(i,D) cin >> t[i];

    ll satis = 0;
    int lastday[26]; REP(i,26) lastday[i] = 0;

    int j;
    REP(i,D){
        j = t[i] - 1;
        lastday[j] = i + 1;
        REP(k,26){
            satis -= (i + 1 - lastday[k]) * c[k];
        }
        satis += s[i][j];
        cout << satis << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans = k * pow(k - 1, n - 1);
    cout << ans << endl;
	return 0;
}



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

int main()
{
    int n;

    cin >> n;

    if(n % 2 == 0){
        cout <<setprecision(10) << fixed << (double) (n / 2) / n << "\n";
    }
    else{
        cout <<setprecision(10) << fixed << (double) (n / 2 + 1) / n << "\n";
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; 
  }
  return u;
}

int main(){
	int u, v;
	cin >> u >> v;
	cout << gcd(u,v) << endl;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
 
const int MAX = 100005;
 
LL a[MAX];
LL b[MAX];
 
LL s[MAX];
int main()
{
 //  freopen("in.txt", "r", stdin);
  //  ios::sync_with_stdio(false); cin.tie(0);
 
    int n;
    cin>>n;
    FOR(i,0,n)
    {
    	cin>>a[i]>>b[i];
    }
 
    FOR(i,0,n)
    {
    	s[i] = (b[i] - a[i]%b[i])%b[i];
    }
 
    LL ans = s[n-1];
 
    RFOR(i,n-1,0)
    {
    	a[i] += ans;
    	ans += (b[i]-a[i]%b[i])%b[i];
    }
 
    cout<<ans;
	return 0;
}

Measured memory_bytes: 2688
import itertools
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsが使える
# permutations（関数）にlistを渡すと、順列を生成！
l = [i for i in range(1, N+1)]
permutations_l = list(itertools.permutations(l))

a, b = 0, 0
for i, R in enumerate(permutations_l):
  if R == P: a = i
for i, R in enumerate(permutations_l):
  if R == Q: b = i

print(abs(a-b))

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

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

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

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

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	int g[505][505]={};
	FORQ(i,1,n){
		FORQ(j,i+1,n){
			FOR(k,0,10){
				int ii=(i>>k)&1;
				int jj=(j>>k)&1;
				if(ii!=jj){
					g[i][j]=k+1;
					break;
				}
			}
		}
	}
	FORQ(i,1,n){
		FORQ(j,i+1,n){
			cout<<g[i][j]<<" ";
		}
		cout<<endl;
	}

	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    
    string t;
    cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256