akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vi A(N), B;
    cin >> A;
    B = A;
    sort(ALL(B));

    A.pb(-1);
    int ans = INF;
    REP(i, N) {
        vi tmp;
        vi can;
        REP(j, N + 1) {
            if (A[j] < B[i]) {
                sort(ALL(tmp));
                REP(k, SZ(tmp) - K + 1) {
                    can.pb(tmp[k]);
                }
                tmp.clear();
            } else {
                tmp.pb(A[j]);
            }
        }
        sort(ALL(can));
        if (SZ(can) < Q) continue;
        chmin(ans, can[Q - 1] - can[0]);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
long Blue(long n,long a,long b){
  if(n>=a){
    return a;
  }
  else return n;
}
int main(void) {
  long n,a,b,blue=0,v;
  scanf("%ld %ld %ld",&n,&a,&b);
  if(n>a+b){
    v=n/(a+b);
    n=n%(a+b);
    blue=v*a+Blue(n,a,b);
  }
  else blue=Blue(n,a,b);
  printf("%ld",blue);
}

Measured memory_bytes: 128
import java.util.*;
        public class Main {
        	public static void main(String[] args){
        		Scanner sc = new Scanner(System.in);
        		int a = sc.nextInt();
        		int b = sc.nextInt();
        		int c = sc.nextInt();
        		System.out.print(c+" "+a+" "+b);

        	}
        }

Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    VVI y(h);
    REP(i,n){
        int a = in() - 1, b = in() - 1;
        y[a].push_back(b);
    }
    REP(i,h) sort(ALL(y[i]));

    int s = 1;
    REP(i,h-1){
        if (!y[i+1].empty() && y[i+1][0] < s){
            cout << i + 1 << endl;
            return 0;
        }else if (y[i+1].empty() || y[i+1][0] > s){
            s = min(s + 1, w);
        }
    }
    cout << h << endl;

    // vector<P> p(n);

    // vector<string> s(h, string(w, '.'));
    // REP(i,n){
    //     int x = in() - 1, y = in() - 1;
    //     p[i] = P(x, y);
    //     s[x][y] = '#';
    // }
    // REP(i,h) cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    for (ll h = 1; h <= 3500; h++) {
        for (ll w = 1; w <= 3500; w++) {
            ll bunshi = N * h * w;
            ll bunbo = 4ll * h * w - N * w - N * h;
            if (bunbo <= 0) continue;
            if (bunshi % bunbo == 0) {
                ll n = bunshi / bunbo;
                cout << h << ' ' << n << ' ' << w;
                ret();
            }
        }
    }

}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if(A<=B){
        ll x = A+T*V;
        ll y = B+T*W;
        if(x>=y){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        ll x = A-T*V;
        ll y = B-T*W;
        if(x<=y){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
# DPL_1_A: Combinatorial - Coin Changing Problem


def change(n, cs):
    ts = [[0] * (n+1) for _ in range(len(cs)+1)]
    for j in range(0, n+1):
        ts[0][j] = n+1

    for i, c in enumerate(cs):
        for j in range(1, n+1):
            if j >= c:
                ts[i+1][j] = min(ts[i][j], ts[i+1][j-c]+1)
            else:
                ts[i+1][j] = ts[i][j]

    return ts[-1][-1]


def run():
    n, m = [int(i) for i in input().split()]
    denoms = [int(i) for i in input().split()]

    print(change(n, denoms))


if __name__ == '__main__':
    run()



Measured memory_bytes: 45320
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(long long N, std::vector<long long> P, std::vector<long long> Q) {
  vector<long long> a(N);
  rep(i, N) a[i] = i + 1;
  int cnt = 0;
  lli aa = 0, bb = 0;
  do {
    if (a == P) {
      aa = cnt;
    }
    if (a == Q)
      bb = cnt;
    cnt++;
  } while (std::next_permutation(a.begin(), a.end()));
  cout << abs(aa - bb) << endl;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &P[i]);
  }
  std::vector<long long> Q(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &Q[i]);
  }
  solve(N, std::move(P), std::move(Q));
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, A, B;
    cin >> N >> A >> B;
    cout << ((B-A)%2 ? "Borys" : "Alice") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	n := nextInt()
	k := nextInt()
	sum := 0
	for i := 1; i <= n; i++ {
		sum += i
	}

	//選ぶ数を1つずつ減らしながら和の最大値と最小値を求める
	i := n + 1           //選ぶ個数
	max, min := sum, sum //N+1個選ぶ時の和の最大値と最小値
	maxCalc := 0         //和の最大値から引く数
	minCalc := n         //和の最小値から引く数
	ans := 0
	for i >= k {
		//N+1個選ぶ時を考慮した分岐
		if i < n+1 {
			max -= maxCalc
			min -= minCalc
			maxCalc++
			minCalc--
		}
		//fmt.Println("i:", i, "max:", max, "min:", min)
		ans += max - min + 1
		//ans %= 1000000007
		i--
	}
	fmt.Println(ans % 1000000007)
}


Measured memory_bytes: 1756
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000000000LL
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n;
int a[MN];
int b[MN];
priority_queue<pii, vpii> pq;

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

    int ok = 0;

    cin >> n;
    F0R(i, n){
        cin >> a[i];
    }
    F0R(i, n){
        cin >> b[i];
        if(a[i] == b[i]) ok++;
        else pq.push({b[i], i});
    }

    ll cnt = 0;

    while(ok < n){
        //++cnt;
        pii top = pq.top();
        pq.pop();
        /*b[top.s] = b[top.s] - b[(top.s+1)%n] - b[(top.s+n-1)%n];
        ++cnt;*/
        int scnd = max(max(b[(top.s+1)%n], b[(top.s+n-1)%n]), a[top.s]);
        int sm = b[(top.s+1)%n] + b[(top.s+n-1)%n];
        int dif = b[top.s]-scnd;
        int ch = (dif-1)/sm+1;
        cnt += (ll)ch;
        b[top.s] -= ch*sm;
        //cout << top.s << " " << scnd << " " << sm << " " << ch << " " << b[top.s] << "\n";

        if(b[top.s] < a[top.s] || ch <= 0){
            cout << "-1\n";
            return 0;
        } else if(b[top.s] == a[top.s]){
            ++ok;
        } else{
            pq.push({b[top.s], top.s});
        }
    }

    cout << cnt << "\n";
    
    return 0;
}


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

int main() {
  long long N;
  cin >> N;
  
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    B.at(i) = A.at(i);
  }
  sort(B.begin(), B.end());
  
  for (int i = 0; i < N; i++) {
    if(A.at(i) == B.at(N-1)){
      cout << B.at(N-2) << endl;
    }
    else {
      cout << B.at(N-1) << endl;
    }
  }
}
  
  
 

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
bool p;
string a;
int main()
{
    cin>>a;
    int i=-1;
    while (1)
    {
    	i++;
        if (i==a.size()) break;
        if (a[i]=='C' || p) p=1;
        if (p && a[i]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  int i, j, n, p, odd=0, even=0;
  long long ans=1;
  cin >> n >> p;
  int a[n];
  for(i=0; i<n; i++){
    cin >> a[i];
    if(a[i]%2==1) odd++;
    else even++;
  }
  if(p==0){
    if(odd==0) odd++;
    for(i=0; i<even+odd-1; i++)
      ans*=2;
  }
  else if(odd==0)
    ans=0;
  else
    for(i=0; i<even+odd-1; i++)
      ans*=2;
  cout << ans;
  return 0;
}

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

int main(void){
    char s[1000];
    scanf("%s", s);

    if(s[0] == 'S'){
        printf("Cloudy\n");
    }
    else if(s[0] == 'C'){
        printf("Rainy\n");
    }
    else{
        printf("Sunny\n");
    }
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
	char a[15],b[15],c[15];
	int n1,n2,n3;
	scanf("%s %s %s",a,b,c);
	n1=strlen(a);
	n2=strlen(b);
	n3=strlen(c);
	if(a[n1-1]==b[0] && b[n2-1]==c[0])
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  deque<int> deq;
  rep(i, n) {
    if(i%2)
      deq.push_front(a[i]);
    else
      deq.push_back(a[i]);
  }
  if(n%2) {
    for(auto it=deq.rbegin(); it!=deq.rend(); it++) {
      if(it != deq.rbegin())
        cout << ' ';
      cout << *it;
    }
  } else {
    for(auto it=deq.begin(); it!=deq.end(); it++) {
      if(it != deq.begin())
        cout << ' ';
      cout << *it;
    }
  }
  cout << endl;
  return 0;
}

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

int main() {
    int n; cin >> n; int arr[n]; for (int i = 0; i < n; i ++) cin >> arr[i];
    int num = arr[0]; for (int i = 1; i < n; i ++) num = num^arr[i];
    for (int i = 0; i < n; i ++) cout << (num^arr[i]) << " "; cout << endl;
}

Measured memory_bytes: 4300
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	string s;
	cin>>s;s[3] = '8';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<set>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

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

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
static const int N=114514;

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=1e9+7;
#define ll long long

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int ans=0;
  if(s[0]==t[0]){ans++;}
  if(s[1]==t[1]){ans++;}
  if(s[2]==t[2]){ans++;}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = Array.new(N + 1, 0)
X = Array.new(N + 1, 0)

gets.split.map(&:to_i).each_with_index{|a,i| A[i + 1] = a }

(1 .. N).reverse_each do |i|
  sum = (1 .. N / i).inject(0){|s, j| s + X[i * j] }
  X[i] = (sum % 2 == A[i] ? 0 : 1)
end
ans = (1 .. N).select{|i| X[i] > 0}

puts ans.size
puts ans * ' '

Measured memory_bytes: 25100
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int n,m,p,a,b;
void mainmain(){
	while(cin>>n>>m>>p>>a>>b,n){
		VV(pii) vv(m);
		vint v(n);
		a--; b--;
		rep(i,n) cin>>v[i];
		rep(i,p){
			int x,y,z;
			cin>>x>>y>>z;
			x--;
			y--;
			vv[x].PB(pii(y,z));
			vv[y].PB(pii(x,z));
		}
		VV(double) dp;
		initvv(dp,m,1<<n,-1.0);
		priority_queue<pair<double,pii>> pq;
		pq.push(mkp(0.0,pii(a,(1<<n)-1)));
		while(!pq.empty()){
			auto top=pq.top();
			pq.pop();
			if(dp[top.S.F][top.S.S]>=0) continue;
			dp[top.S.F][top.S.S]=-top.F;
			for(pii x:vv[top.S.F]){
				rep(i,n){
					if((1<<i)&top.S.S){
						auto tmp=top;
						tmp.S.F=x.F;
						tmp.S.S-=(1<<i);
						tmp.F-=(double)x.S/v[i];
						if(dp[tmp.S.F][tmp.S.S]>=0) continue;
						pq.push(tmp);
					}
				}
			}
		}
		double ans=1e200;
		rep(i,1<<n){
			if(dp[b][i]>=0) ans=min(ans,dp[b][i]);
		}
		if(ans==1e200){
			cout<<"Impossible"<<endl;
		}
		else{
			cout<<ans<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 15012
#include <stdio.h>
int main() 
{
    int h, w;
    char s[52][52] = {0};
	scanf("%d%d ", &h, &w);
	for (int i = 1; i <= h; i++) {
        scanf("%s", &s[i][1]);
    }
	for (int j = 1; j <= h; j++) {
        for (int i = 1; i <= w; i++) {
            if (s[j][i] == '#') {
                if (s[j - 1][i] == '#') continue;
                if (s[j + 1][i] == '#') continue;
                if (s[j][i - 1] == '#') continue;
                if (s[j][i + 1] == '#') continue;
                printf("No\n");
                return 0;
            }
        }
    }
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  ll N;
  cin >>N;
  ll M;
  cin >>M;
  ll a=fac(N)*fac(M);
  ll b=a%MOD;
  ll c=(2*b)%MOD;
  
  if(abs(N-M)>=2) {
cout<<0<<endl;
  }
  
  else if(abs(N-M)==1) {
cout<<b<<endl;
  }
  else if(N==M) {
cout<<c<<endl;
  }
}

  
    
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200000+5],b[200000+5][22],c[22];
long long n,ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		long long t,j=0;
		t=a[i];
		while(t>0)
		{
			b[i][j]=t%2;
			j++;
			t/=2;
		}
	}
	long long l=1,r=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	for(int i=0;i<=21;i++)
	{
		c[i]+=b[1][i];
	}
	while(l<=n)
	{
		int flag=1,flag1;
		while(1)
		{
			r++;
			if(r>n)break;
			for(int i=0;i<=21;i++)
			{
				c[i]+=b[r][i];
				if(c[i]>1)flag=0;
			}
			if(flag==0||r==n)break;
		}
		if(flag==1)
		{
		//	cout<<'x'<<' '<<l<<' '<<r<<endl;
			ans+=(r-l+1)*(r-l+2)/2;
			break;
		}
		else 
		{
		//	cout<<'y'<<' '<<l<<' '<<r<<endl;
			ans+=(r-l)*(r-l+1)/2;
		}
			
		l++;
		while(l<=n)
		{
			flag1=1;
			for(int i=0;i<=21;i++)
			{
				c[i]-=b[l-1][i];
				if(c[i]>1)flag1=0;
			}
			if(flag1==0)
			{
				l++;
				
				continue;
			}
			else break;
		}
		if(r==n)
		{
		//	cout<<'z'<<' '<<l<<' '<<r<<endl;
			ans-=(r-l)*(r-l+1)/2;
			ans+=(r-l+1)*(r-l+2)/2;
			break;
		}
		else 
		{
			//cout<<'k'<<' '<<l<<' '<<r<<endl;
			ans-=(r-l)*(r-l+1)/2;
		}
		
		//cout<<'z'<<' '<<l<<' '<<r;
	}
	cout<<ans;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;

	bool elf = false;

	sort(all(s));
	sort(all(t));
	reverse(all(t));

	if (s < t) puts("Yes");
	else puts("No");
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;
template <class T>
T gcd(T a, T b) {
    if (b > a) T tmp = a, a = b, b = tmp;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int main() {
    lint N, K;
    cin >> N >> K;
    lint ans = N % K;
    if (ans == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min(ans, K - ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }

    const int mod = 998244353;
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    ll pw(ll b, ll e)
    {
        ll ans = 1;
        while(e)
        {
            if(e & 1)
                ans = (ans * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return ans;
    }

    ll fact[200002], inv[200002];
    
    ll C(ll n, ll k)
    {
        return ((((fact[n] * inv[k]) % mod) * inv[n-k]) % mod);
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
    int vis[200005];
     
    int main()
    {
     
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            int n;
            cin>>n;

            int a[n];
            forn(i,n) cin>>a[i];

            int dp[n+1]={0};

            dp[1]=abs(a[1]-a[0]);
            fore(i,2,n)
            {
                dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]) );
            }

            cout<<dp[n-1];
        }
        return 0;
    }

Measured memory_bytes: 1024
S = gets.chomp

ans1 = 0
ans2 = 0
# 1010 ~~
S.length.times do |i|
    if i % 2 == 0
        if S[i] == "0"
            ans1 += 1
        end
    else
        if S[i] == "1"
            ans1 += 1
        end
    end
end

# 0101 ~~
S.length.times do |i|
    if i % 2 == 0
        if S[i] == "1"
            ans2 += 1
        end
    else
        if S[i] == "0"
            ans2 += 1
        end
    end
end

puts [ans1, ans2].min

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

int main(void)
{
  int n;
  int m = 100000;
  double tmp = 0.0;

  cin >> n;
  for(int i=0;i<n;i++)
    {
      tmp = 0.0;

      m = m * 1.05;
      if(m % 1000 == 0)
	{
	  continue;
	}
      else
	{
	  tmp = (double)m / 1000.0;
	  tmp = ceil(tmp);
	  tmp *= 1000.0;
	  m = tmp;
	}
    }

  cout << m << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int64_t Z=0,A=0;
  for(int i=N-1;i>0;i--){
    Z=max(Z,max(A,p[i-1]-p[i]));
    p[i-1]-=max(A,p[i-1]-p[i]);
  }
  if(Z<2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

int main()
{
	int n;
	vector<int> train;
	while (cin >> n) {
		if (n) {
			train.push_back(n);
		}
		else {
			cout << train.back() << endl;
			train.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define r_0 return 0;
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
vector<ll>V,B;
set<int>S;
ll n, a, c, l, r,ans,b,m;
string p,s;
ll arr[10000001];
int main()
{
    TIME;
    for (int i =1; i <101; i++ )
        for (int j =1; j <101; j ++ )
            for (int h =1; h<101; h ++  )
            {
                a = i*i + j*j + h*h;
                a += i*j + i*h + j*h;
                arr[a]++;
            }
    cin>>n;
    for (int i =1; i <=n; i ++ )
        cout<<arr[i]<<endl;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b, c;
	cin>>a>>b>>c;
	int ans=min(c, b/a);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define input_from_file  freopen("input.txt", "r", stdin);
int main()
{
    // input_from_file;
  // int t; cin>>t;
  // while(t--){
  ll n,sum;
  cin>>n>>sum;
  vector<vector<ll>> vec(n,vector<ll> (2,0));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<2;j++) cin>>vec[i][j];
  }  
  vector<vector<ll>> dp(n+1,vector<ll> (sum+1,0));
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=sum;j++){
      if(j<vec[i-1][0])  dp[i][j]=dp[i-1][j];
      else {
        dp[i][j]=max(dp[i-1][j],dp[i-1
        ][j-vec[i-1][0]]+vec[i-1][1]);
      }
    } 
  } 
  // for(ll i=0;i<=n;i++){
  //   for(ll j=0;j<=sum;j++)  cout<<dp[i][j]<<" ";cout<<endl;}
	cout<<dp[n][sum];
  return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>
int a[110];
int main(){
	int x,n;
	scanf("%d%d",&x,&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	
	for(int d=0;;d++)for(int e=-1;e<2;e+=2){
		int dd=d*e;
		int flag=0;
		for(int i=0;i<n;i++)flag|=a[i]==x+dd;
		if(!flag){
			printf("%d",x+dd);
			return 0;
		}
	}
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int r;
    cin >> r;
    cout << (r * r * 3) << endl;
    return 0;
}

Measured memory_bytes: 256
S=input()
flag=0
chara=S
def hantei(moji):
    global flag
    #print(moji)
    length=len(moji)
    #print(length)
    flag=0
    #print(moji[0:length//2])
    #print(moji[(length//2):])
    
    if moji[0:length//2]==moji[(length//2):]:
        flag=1
        #print("Yes")
        return 
    else:
        flag=0
        return 
    
while flag==0:
    #print(flag)
    chara=chara[:-1]
    hantei(chara)
    
print(len(chara))

Measured memory_bytes: 3060
import java.util.*;

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

		char[] S = sc.next().toCharArray();
		int c_count = 0;

		for (int i=0; i<S.length; i++){
			if (i == 0){
				if (S[i] != 'A'){
					System.out.println("WA");
					return;
				}
			}else if (i >= 2 && S.length-2 >= i){
				if (S[i] == 'C'){
					c_count += 1;
				}
				if (c_count > 1){
					System.out.println("WA");
					return;
				}
			}else if (Character.isUpperCase(S[i])){
				System.out.println("WA");
				return;
			}
		}
		if (c_count == 1){
			System.out.println("AC");
			return;
		}else {
			System.out.println("WA");
			return;
		}

	}
}


Measured memory_bytes: 22612
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    System.out.println(n * n * n);
  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int N = 2010;
vector<int> edge[N];
pair<int,int> e[N];
bool vis[N];
int cnt;
void dfs(int n,int k){
    vis[n]=1;cnt++;
    if(k==0) return ;
    for(int i=0;i<edge[n].size();i++){
        if(!vis[edge[n][i]]) dfs(edge[n][i],k-1);
    }
}
int main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n-1;i++){
        int a,b;cin>>a>>b;
        e[i].first=a;e[i].second=b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int ans=n;
    if(k&1){
        for(int i=1;i<=n-1;i++){
            cnt=0;
            memset(vis,0,sizeof vis);
            vis[e[i].second]=1;
            dfs(e[i].first,k/2);
            dfs(e[i].second,k/2);
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }else{
        for(int i=1;i<=n;i++){
            cnt=0;
            memset(vis,0,sizeof vis);
            dfs(i,k/2);
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int count = 0;
        for(int i = 0; i <= A; i++){
            for(int j = 0; j <= B; j++){
                for(int k = 0; k <= C; k++){
                    if(500*i+100*j+50*k == X)
                        count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int a[N];
    REP(i,N){
        cin>>a[i];
    }
    int now;now=1;
    int ans;ans=0;
    REP(i,N){
        if(a[i]==now){
            now++;
        }else{
            ans++;
        }
    }
    if(now==1){
        print("-1");
        return 0;
    }else{
        print(ans);
        return 0;
    }
}


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

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

	string a, b, c; cin >> a >> b >> c;
	if(a.back() == b.front() && b.back() == c.front()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;	
}





  

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <algorithm>

const float a=1.05;

using namespace std;



int main(void)
{
	int debt,week;
	scanf("%d",&week);
	debt=100000;
	for(int loop=1;loop<=week;loop++)
	{
		debt*=1.05;
		if(debt%1000!=0)
		{
			debt=debt-(debt%1000)+1000;
		}
	}
	printf("%d\n",debt);
	return 0; 
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

string S, T;

int main() {
    cin >> S >> T;

    string S2 = S+S;
    int next[S2.length()+1][26];
    for (int i = 0; i < 26; i++) {
        next[S2.length()][i] = S2.length();
    }
    for (int i = S2.length() - 1 ; i >= 0 ; i--) {
		for (int j = 0; j < 26; j++) {
            next[i][j] = next[i+1][j];
        }
		next[i][S2[i] - 'a'] = i+1;
	}
    /*
    for (int i = 0; i < 26; i++) {
        cout << (char)('a' + i) << ": ";
        for (int j = 0; j < S.length(); j++) {
            cout << next[j][i] << " ";
        }
        cout << endl;
    }*/

    bool f = true;
    ll x = 0;
    ll cnt = 0;
	for (int i = 0; i < T.length(); i++) {
        if (next[x][T[i] - 'a'] == S2.length()) {
            f = false;
            break;
        }
        else {
            x = next[x][T[i] - 'a'];
            if (x >= S.length()) {
                x %= S.length();
                cnt++;
            }
        }
	}

    if (f) {
        cout << cnt*S.length() + x << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 21120
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int dist;
  cin>>dist;
  Int n;
  cin>>n;
  vector<Int> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  Int m;
  cin>>m;
  vector<Int> d(m);
  for(Int i=0;i<m;i++) cin>>d[i];

  const Int INF = 1e17;
  Int t[10][10];
  Int ans=INF;
  auto check=
    [&]()->Int{
      struct edge{
	Int from,to,cost;
	edge(Int from,Int to,Int cost):from(from),to(to),cost(cost){}
      };
      vector<edge> es;
      
      for(Int i=1;i<n;i++){
	// p[i-1] + 1 <= p[i]
	// p[i-1] - p[i] <= -1
	es.emplace_back(i,i-1,-1);
      }
      for(Int i=0;i<n;i++){
	for(Int j=i+1;j<n;j++){
	  // j catch up i at t[i][j]
	  if(t[i][j]>m) continue;
	  if(t[i][j]==m){
	    // dist * s[i] + p[i] <= dist * s[j] + p[j]
	    // p[i] - p[j] <= dist * s[j] - dist * s[i]	    
	    es.emplace_back(j,i,dist*(s[j]-s[i]));
	    continue;
	  }
	  Int x=d[t[i][j]];
	  // x * s[i] + p[i] == x * s[j] + p[j]
	  
	  // x * s[i] + p[i] <= x * s[j] + p[j]	  
	  // p[i] - p[j] <= x * s[j] - x * s[i]
	  es.emplace_back(j,i,x*(s[j]-s[i]));
	  // x * s[i] + p[i] >= x * s[j] + p[j]
	  // p[j] - p[i] <= x * s[i] - x * s[j]
	  es.emplace_back(i,j,x*(s[i]-s[j]));
	}
      }
      
      vector<Int> p(n,INF);
      // minimize p[n-1] - p[0]
      // maximize p[0] - p[n-1]
      p[n-1] = 0;
      Int flg=1;
      for(Int t=0;t<n*3;t++){
	flg=0;
	for(auto e:es){
	  if(p[e.from]+e.cost<p[e.to]){
	    p[e.to]=p[e.from]+e.cost;
	    flg=1;	    
	  }
	}
      }
      if(flg) return -1;      
      vector<Int> z(n);
      for(Int i=0;i<n;i++) z[i]=p[i]-p[0];
      
      for(Int i=0;i<m;i++){
	map<Int, Int> cnt;
	for(Int j=0;j<n;j++)
	  cnt[d[i]*s[j]+z[j]]++;
	for(auto p:cnt) if(p.second>2) return -2;
      }
      
      Int res=0;
      for(Int i=0;i<n;i++) chmax(res,dist*s[i]+z[i]);
      return res;
    };

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<n;i++)
    for(Int j=i+1;j<n;j++)
      vp.emplace_back(i,j);
  
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      t[i][j]=m+1;
  
  function<void(Int)> dfs=
    [&](Int x){
      Int res=check();
      if(res==-1) return;
      if(x==(Int)vp.size()){
	if(res>=0) chmin(ans,res);
	return;
      }
      for(Int i=0;i<=m;i++){
	t[vp[x].first][vp[x].second]=i;
	dfs(x+1);
	t[vp[x].first][vp[x].second]=m+1;
      }
    };
  
  dfs(0);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

void solve()
{
    string s;
    cin >> s;

    int l = s.size();

    if(s[l-1] == 's') s += "es";
    else s += 's';
    
    cout << s << "\n";
}

int main()
{
    int tc = 1;
    //cin >> tc;

    while(tc--) solve();

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> perm(n),p(n),q(n);
    for(int i=0;i<n;++i) perm[i] = i+1;
    for(int i=0;i<n;++i) cin >> p[i];
    for(int i=0;i<n;++i) cin >> q[i];
    map<vector<int>,int> mp;
    int i=1;
    do{
        mp[perm] = i;
        i++;
    }while(next_permutation(perm.begin(),perm.end()));
    
    cout << abs(mp[p] - mp[q]) << endl;
    return 0;
}

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

using namespace std;

int main() {
    string S, T;
    bool fg = true;
    cin >> S;
    cin >> T;

    if (S.size() + 1 == T.size()) {
        for (int i = 0; i < S.size(); i++) {
            if (S.at(i) != T.at(i)) {
                cout << "No" << endl;
                fg = false;
                break;
            }
        }
    } else {
        cout << "No" << endl;
        fg = false;
    }

    if (fg)cout << "Yes" << endl;

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int x[50], y[50];

map<PII, int> ma;

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d%d", x + i, y + i);
    forn(i, n) forn(j, i) {
        ma[mp(x[i] - x[j], y[i] - y[j])] += 1;
        ma[mp(x[j] - x[i], y[j] - y[i])] += 1;
    }
    int mx = 0;
    for (auto p : ma) {
        mx = max(mx, p.second);
    }
    printf("%d\n", n - mx);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e6;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int tot[N];
int main()
{
	int n=gi(),m=gi(),i,ans=n;
	for (i=1;i<=n;i++) tot[gi()]++;
	sort(tot+1,tot+1+n,greater<int>());
	for (i=1;i<=m;i++) ans-=tot[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
H, W, K = gets.split.map &:to_i
i = 1
s = gets(p)
s << "\n" if s[-1] != "\n"
s.gsub!(/\.*#\.*/){
    ("#{i} " * $&.size).tap{ i += 1 }
}
# puts s
s.gsub!(/(\.+\n)*([0-9 ]+\n)(\.+\n)*/){
  $2 * $&.count("\n")
}
puts s


Measured memory_bytes: 4940
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<int> a(n),x(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(i==0)continue;
        if(i==n-1)continue;
        if(a[i] >= a[i-1] && a[i] >= a[i+1])x[i] = 1;
        if(a[i] <= a[i-1] && a[i] <= a[i+1])x[i] = -1;
        if(a[i] == a[i-1] && a[i] == a[i+1])x[i] = 0;
    }
    ll max_m = 1000;
    ll m = 1000, s = 0;
    if(a[0] < a[1]){
        s = m/a[0];
        m %= a[0];
    }

    rep(i,n){
        if(i==0)continue;
        if(x[i] == 1){
            m += a[i]*s;
            s = 0;
            max_m = max(max_m,m);
        }
        if(x[i] == -1){
            s += m/a[i];
            m %= a[i];
        }
        if(i == n-1){
            m += a[i]*s;
            s = 0;
            max_m = max(max_m,m);
        }
    }


    cout << max_m << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3640