akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int i,j,k,n,count;

  while(scanf("%d",&n)!=EOF){
    if(n>36){
      printf("0\n");
      continue;
    }
    for(count=0,i=0;i<10;i++){
      if((27+i)<n) continue;
      for(j=0;j<10;j++){
	if((18+j+i)<n) continue;
	for(k=0;k<10;k++){
	  if((n-(i+j+k)<10)
	     &&(n-(i+j+k)>-1)){
	    count++;
	  }
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <string> 
using namespace std;

int main(void) {
    string S;
    cin >> S;
    for (int i = 0; i < 19; i++) {
        if (S[i] == ',') {
            S[i] = ' ';
        }
    }
    cout << S<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 4e5 + 5;
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	cout<<(1000 - n%1000 - 1000*(n%1000 == 0));
}

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var Y = NextInt();

            for (int i = 0; i <= N; i++) {
                for (int j = 0; j <= N - i; j++) {
                    if(i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
                        Console.WriteLine($"{i} {j} {N - i - j}");
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    
    
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i>=1&&i<=9)
        sum++;
        else if(i>=100&&i<=999)
        sum++;
        else
        if(i>=10000&&i<100000)
        sum++;
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <cstdio>

const int MOD=1000000007;
const int MAXN=2100011;

int sr;
int sum(int a, int b){
	sr=a+b;
	if(sr>=MOD)	sr-=MOD;
	return sr;
}

int mul(int a, int b){
	return (int)((1LL*a*b)%(long long)(MOD));
}

int pow(int a, int k){
	int ret=1, t=a;
	while(k){
		if(k&1)	ret=mul(ret, t);
		t=mul(t, t);
		k>>=1;
	}
	return ret;
}

int N;
int Fac[MAXN], Inv[MAXN];
int X[6], Y[6];

int C(int n, int m){
	return mul(Fac[n], mul(Inv[m], Inv[n-m]));
}

int Way(int x, int y){
	return C(x+y, y);
}

int Way(int xl, int yl, int xr, int yr){
	return Way(xr-xl, yr-yl);
}

int Calc(int xl, int yl, int xr, int yr){
	
	int ret=0;
	for(int i=X[2], y;i<=X[3];++i){
		y=Y[2]-1;
		ret=sum(ret, MOD-mul(mul(Way(xl, yl, i, y), Way(i, y+1, xr, yr)), (i-xl)+(y-yl)));
		y=Y[3];
		ret=sum(ret, mul(mul(Way(xl, yl, i, y), Way(i, y+1, xr, yr)), (i-xl)+(y-yl)));
	}
	
	for(int i=Y[2], x;i<=Y[3];++i){
		x=X[2]-1;
		ret=sum(ret, MOD-mul(mul(Way(xl, yl, x, i), Way(x+1, i, xr, yr)), (x-xl)+(i-yl)));
		x=X[3];
		ret=sum(ret, mul(mul(Way(xl, yl, x, i), Way(x+1, i, xr, yr)), (x-xl)+(i-yl)));
	}
	
	return ret;
}

int main(){
	
	N=2100000;
	Fac[0]=1;
	for(int i=1;i<=N;++i)	Fac[i]=mul(Fac[i-1], i);
	Inv[N]=pow(Fac[N], MOD-2);
	for(int i=N;i>=1;--i)	Inv[i-1]=mul(Inv[i], i);
	
	for(int i=0;i<6;++i)	scanf("%d", &X[i]);
	for(int i=0;i<6;++i)	scanf("%d", &Y[i]);
	
	int Ans=0;
	
	Ans=sum(Ans, Calc(X[0]-1, Y[0]-1, X[5]+1, Y[5]+1));
	Ans=sum(Ans, Calc(X[1], Y[1], X[5]+1, Y[5]+1));
	Ans=sum(Ans, MOD-Calc(X[0]-1, Y[1], X[5]+1, Y[5]+1));
	Ans=sum(Ans, MOD-Calc(X[1], Y[0]-1, X[5]+1, Y[5]+1));
	Ans=sum(Ans, Calc(X[0]-1, Y[0]-1, X[4], Y[4]));
	Ans=sum(Ans, Calc(X[1], Y[1], X[4], Y[4]));
	Ans=sum(Ans, MOD-Calc(X[0]-1, Y[1], X[4], Y[4]));
	Ans=sum(Ans, MOD-Calc(X[1], Y[0]-1, X[4], Y[4]));
	Ans=sum(Ans, Calc(X[1], Y[0]-1, X[4], Y[5]+1));
	Ans=sum(Ans, Calc(X[0]-1, Y[1], X[4], Y[5]+1));
	Ans=sum(Ans, MOD-Calc(X[0]-1, Y[0]-1, X[4], Y[5]+1));
	Ans=sum(Ans, MOD-Calc(X[1], Y[1], X[4], Y[5]+1));
	Ans=sum(Ans, Calc(X[1], Y[0]-1, X[5]+1, Y[4]));
	Ans=sum(Ans, Calc(X[0]-1, Y[1], X[5]+1, Y[4]));
	Ans=sum(Ans, MOD-Calc(X[0]-1, Y[0]-1, X[5]+1, Y[4]));
	Ans=sum(Ans, MOD-Calc(X[1], Y[1], X[5]+1, Y[4]));
	
	printf("%d\n", Ans);
	
	return 0;
}

Measured memory_bytes: 16512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int a[3];
   cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
   
   return 0;
}


Measured memory_bytes: 256
#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>;

void Main()
{
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  for(int i = k; i < n; i++) {
    if (a[i-k] < a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() {
	boost;
	int n, m;
	cin >> n >> m;
	vector < int > a(n);
	set < int > s;	
	for(int &i : a) {
		cin >> i;
		i /= 2;
		int cur = i,cnt = 0;
		while(cur % 2 == 0) {
			cur /= 2;
			cnt++;
		}
		s.insert(cnt);
	}
	if(s.size() > 1) {
		cout << 0 << endl;
		return 0;
	}
	int lcm = a[0];
	for(int &i : a) {
		lcm = (i * lcm) / __gcd(lcm, i);
		if(lcm > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	int ans = m / lcm;
	ans = (ans + 1) / 2;
	cout << ans << endl;
}





Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define FAST_IO std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define Puase system("pause")
using namespace std;
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, int> pli;
typedef pair<int, int> pint;

int const maxn = 5e5 + 10;
ll const INF = 0x3F3F3F3F3F3F3F3F;
ll dis[maxn << 2];
std::map<pint, int> Node;
struct node
{
    int v, w, next;
}e[maxn << 5];
int cnt, head[maxn];
int vis[maxn];

void add(int u, int v, int w) {
    e[cnt].v = v;
    e[cnt].w = w;
    e[cnt].next = head[u];
    head[u] = cnt++;
}
int node_num = 0;
int getNodeNum(int u, int v) {
    auto x = make_pair(u, v);
    if (Node.find(x) == Node.end()) {
        Node[x] = ++node_num;
    }

    return Node[x];
}

void dijkstra() {
    memset(dis, 0x3f, sizeof(dis));
    priority_queue<pli> q;
    dis[1] = 0;
    q.push(make_pair(0, 1));
    int c = 0;
    while (!q.empty()) {
        int u = q.top().second;
        q.pop();
        if (vis[u]) continue;
        vis[u] = 1;
        for (int i = head[u]; ~i; i = e[i].next) {
            int v = e[i].v;
            int w = e[i].w;
            if (dis[v] > dis[u] + w) {
                dis[v] = dis[u] + w;
                q.push(make_pair(-dis[v], v));
            }
        }
    }
}

int main(void) {    
    FAST_IO;
    memset(head, -1, sizeof(head));
    int n, m;
    cin >> n >> m;
    node_num = n;
    for (int i = 0 ; i < m; i++) {
        int p, q, c;
        cin >> p >> q >> c;
        int u = getNodeNum(p, c);
        int v = getNodeNum(q, c);
        add(p, u, 1);
        add(u, p, 1);
        add(q, v, 1);
        add(v, q, 1);
        add(u, v, 0);
        add(v, u, 0);
    }
    dijkstra();

    cout << (dis[n] == INF ? -1 : dis[n] / 2) << endl;
    // Puase;
    return 0;
}

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

int N, M, Q;
int a[51], b[51], c[51], d[51];
int ans=0;

void rec(vector<int> vec, int p){
    vec.push_back(p);
    int i;
    int sum=0;
    if(vec.size()>=N){
        for(i=1; i<=Q; i++){
            if(vec[b[i]-1]-vec[a[i]-1]==c[i]){
                sum += d[i];
            }
        }
        ans = max(ans,sum);
    }else{
        for(i=vec[vec.size()-1]; i<=M; i++){
            rec(vec,i);
        }
    }
}

int main(){
    cin >> N >> M >> Q;
    int i;
    for(i=1; i<=Q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> vec;
    for(i=1; i<=M; i++){
        rec(vec,i);
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int64_t x;
  cin >> x;
  int64_t a, b = -120;
  for(int64_t a = -120; a < 120; a++) {
    for(int64_t b = -120; b < 120; b++) {
      if(pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}



Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 3005;
int n;
ll a[maxn], dp[maxn][maxn][2];

int main(){
	scanf("%d", &n);
	for(int i = 1; i<=n; i++) scanf("%lld", &a[i]), dp[i][i][0] = -(dp[i][i][1] = a[i]);
	for(int w = 1; w<n; w++){
		for(int i = 1; i+w <=n; i++){
			int r = i+w;
			dp[i][r][1] = max(dp[i+1][r][0]+a[i], dp[i][r-1][0]+a[r]);
			dp[i][r][0] = min(dp[i+1][r][1]-a[i], dp[i][r-1][1]-a[r]);
		}
	}
	printf("%lld\n", dp[1][n][1]);
	
	return 0;
}


Measured memory_bytes: 139648
#include<stdio.h>

int main(){
        int a,b,c;
        int x,y,z;

        scanf("%d %d %d",&a,&b,&c);

        x = b;
       y = a;
        x = c;
        z = b;

        printf("%d %d %d",x,y,z);   
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdint>

int const MAXN = 1e5;
int N;
int64_t M, A[MAXN], sum[MAXN+1];

int64_t count(int th) {
  int64_t c = 0;
  int j = N-1;
  for(int i = 0; i < N; ++i) {
    if(A[i]*2 < th) break;
    while(j > i && A[i]+A[j] < th) --j;
    ++j;
    c += (int64_t)(j-i)*2-1;
    j = std::min(j, N-1);
  }
  return c;
}

int64_t calc(int th) {
  int64_t res = 0;
  int j = N-1;
  for(int i = 0; i < N; ++i) {
    if(A[i]*2 < th) break;
    while(j > i && A[i]+A[j] < th) --j;
    ++j;
    res += (sum[j-1] - sum[i] + (j-i)*A[i])*2;
    j = std::min(j, N-1);
  }
  return res;
}

int main() {
  std::cin >> N >> M;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A, A+N, [](int l, int r){ return l > r; });
  // 
  int thH = A[0]*2, thL = A[N-1]*2;
  while(thH > thL + 3) {
    int thM = (thH+thL)/2;
    if(count(thM) >= M) thL = thM;
    else thH = thM-1;
  }
  while(count(thH) < M) --thH;
  sum[0] = A[0];
  for(int i = 1; i < N; ++i) sum[i] = sum[i-1]+A[i];
  int64_t ans =  calc(thH) - (count(thH) - M)*thH;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        long A = nextLong();
        long B = nextLong();

        long[] a = new long[N];

        for(int i = 0; i < N; ++i) a[i] = nextLong();

        long low = 1L;
        long high = 1_000_000_000_000_000_001L;

        long min = Long.MAX_VALUE;
        while(low <= high) {
            long mid = low + ( high - low ) / 2L;
            if(can(mid,a,A,B)) {
                min = Math.min(min, mid);
                high = mid - 1;
            } else low = mid + 1;
        }
        writer.println(min);

    }

    private boolean can(long hits, long[] a, long A, long B) {

        long left = hits;
        long C = A - B;
        for(int i = 0; i < a.length; ++i) {
            long atLeast = (a[i] / B);
            if(a[i] % B != 0) ++atLeast;
            if(atLeast <= hits) continue;
            long he = a[i];
            he -= (B * hits);
            if(he <= left * C) {
                long need = he / C;
                if(he % C != 0) ++need;
                left -= need;
            } else return false;
        }

        return true;
    }

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

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 37072
#include<cstdio>
#include<algorithm>
using namespace std;
long long n, x;
long long func(long long h, long long w) {
	if (h == 0 && w == 0) return 0;
	else if (h == 0) return -w;
	else if (w == 0) return -h;
	if (h > w) return h / w * w * 2 + func(h%w, w);
	else return w / h * h * 2 + func(h, w%h);
}
int main() {
	scanf("%lld%lld", &n, &x);
	long long ans = n;
	printf("%lld", ans+func(n-x, x));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,mx=0,tmp;
  string s;
  cin >> n >> s;
  for(int i=0;i<n-1;i++){
    tmp=0;
    map<char,int> mp1,mp2;
    for(int j=0;j<=i;j++){
      if(!mp1.count(s[j]))mp1[s[j]]=1;
    }
    for(int j=i+1;j<n;j++){
      if(!mp2.count(s[j])&&mp1.count(s[j])){
        tmp++;
        mp2[s[j]]=1;
      }
    }
    if(mx<tmp)mx=tmp;
  }
  cout << mx << endl;
}
    

Measured memory_bytes: 256
#include<stdio.h>
int n,m;
int t[200001];
 
int u[200001];
 
int main(){
  int i;
   
  scanf("%d %d",&n,&m);
   
  for(i=0;i<m;i++){
    scanf("%d",&t[i]);
  }
   
  for(i=m-1;i>=0;i--){
    int num=t[i];
    if( u[num] == 0 ){
      printf("%d\n",num);
      u[num]=1;
    }
  }
 
  for(i=1;i<=n;i++){
    if(u[i]==0){
      printf("%d\n",i);
      u[i]=1;
    }
  }
  return 0;
}

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

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

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

ll mod = 2019;
int main(){
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> dp(n+5,0);

  ll digit = 1;
  rep(i,n){
    dp[i+1] = dp[i]+ctoi(s[n-1-i])*digit;
    dp[i+1] %= mod;
    digit *= 10;
    digit %= mod;
  }
  map<ll,ll>  mp;
  rep(i,n+1){
    mp[dp[i]]++;
  }

  ll ans = 0;
  for(auto it : mp){
    ans += it.second*(it.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;

    long long ans = 0;
    if ((B - A) % 2 == 0 ) ans = (B - A) / 2;
    else  ans = min(A - 1, N - B) + 1 + (B - A - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,m,a[100][100],b[100],c;
  int i,j;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
	{
	  scanf("%d",&a[i][j]);
	}
    }
  for(i=0;i<m;i++) scanf("%d",&b[i]);

  for(i=0;i<n;i++)
    {
      c=0;
      for(j=0;j<m;j++) c+=a[i][j]*b[j];
      printf("%d\n",c);
    }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int a,b;
  cin >> a >> b;
  int i,ans = 0;
  for(int i = a; i <= b; i++){
    int t[5];
    int tmp = i;
    rep(j,5){
      t[j] = tmp%10;
      tmp /= 10;
    }
    if(t[0]==t[4] && t[1]==t[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define maxN 1000000000000000000
int n;
long long a[100020];

int main()
{
//    freopen("B.INP","r",stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  long long P=1;
  for (int i=1;i<=n;++i)
    {
        cin>>a[i];
        if (a[i]==0) P=0;
    }
    for (int i=1;i<=n;++i)
    {
        if (P==0) break;
        if (maxN/P<a[i])
        {
            cout<<"-1";
            exit(0);
        }
        P*=a[i];
    }
    cout<<P;
 return 0;
}


Measured memory_bytes: 4444
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())

if N*2 >= M:
    ans = M//2
else:
    ans = N
    M -= N*2
    ans += M//4

print(ans)

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=500;
int a[MAXN+5][MAXN+5],ans[MAXN*MAXN+5][4];
int n,m,cnt;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m-1;j++)
			if(a[i][j]%2!=0)
			{
				a[i][j]-=1;
				a[i][j+1]+=1;
				cnt++;
				ans[cnt][0]=i;
				ans[cnt][1]=j;
				ans[cnt][2]=i;
				ans[cnt][3]=j+1;
			}
	for(int i=1;i<=n-1;i++)
	{
		if(a[i][m]%2!=0)
		{
				a[i][m]-=1;
				a[i+1][m]+=1;
				cnt++;
				ans[cnt][0]=i;
				ans[cnt][1]=m;
				ans[cnt][2]=i+1;
				ans[cnt][3]=m;
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
	{
		for(int j=0;j<4;j++)
			if(j==0)
				printf("%d",ans[i][j]);
			else
				printf(" %d",ans[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main(){
    int M,N;
    scanf("%d%d",&M,&N);
	vector<tuple<int,int,int>> vec;
	for(int i=0;i<M;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		vec.emplace_back(x,l-x,r-x);
	}
	vector<int> Time(N);
	set<int> st;
	for(int i=0;i<N;i++){
		scanf("%d",&Time[i]);
		st.insert(Time[i]);
	}
	sort(vec.begin(),vec.end());
	map<int,int> ans;
	for(int i=0;i<M;i++){
		int cor=get<0>(vec[i]),l=get<1>(vec[i]),r=get<2>(vec[i]);
		auto it1=st.lower_bound(l);
		auto it2=st.lower_bound(r);
		vector<int> done;
		while(it1!=it2){
			ans[*it1]=cor;
			done.push_back(*it1);
			it1++;
		}
		for(int x : done) st.erase(x);
	}
	for(int i=0;i<N;i++){
		if(ans.count(Time[i])) cout<<ans[Time[i]]<<endl;
		else cout<<"-1"<<endl;
	}
}    


Measured memory_bytes: 22128
#include "string"
#include "iostream"
#include "vector"
#include "algorithm"
using namespace std; 

int main() {
	vector<string> ss; 
	int n, l; 
  	cin >> n >> l; 
  
  	for (int i = 0; i < n; ++i) {
    	string s; 
      	cin >> s; 
      
      	ss.push_back(s);
    }
  
  	sort(ss.begin(), ss.end()); 
  	for (string s: ss) cout << s;
  	cout << endl; 
}

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

void f(int start, int to, string plus, string minus)
{
    for (int i = 0; i < abs(to - start); i++)
    {
        if (start < to)
        {
            cout << plus;
        }
        else
        {
            cout << minus;
        }
    }
}

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    f(sx, tx, "R", "L");
    f(sy, ty, "U", "D");
    f(tx, sx, "R", "L");
    f(ty, sy, "U", "D");

    if (sx < tx)
    {
        f(sx, sx - 1, "R", "L");
    }
    else
    {
        f(sx, sx + 1, "R", "L");
    }

    if (sy < ty)
    {
        f(sy, ty + 1, "U", "D");
    }
    else
    {
        f(sy, ty - 1, "U", "D");
    }

    if (sx < tx)
    {
        f(sx - 1, tx, "R", "L");
    }
    else
    {
        f(sx + 1, tx, "R", "L");
    }

    if (sy < ty)
    {
        f(ty + 1, ty, "U", "D");
    }
    else
    {
        f(ty - 1, ty, "U", "D");
    }

    if (sx < tx)
    {
        f(tx, tx + 1, "R", "L");
    }
    else
    {
        f(tx, tx - 1, "R", "L");
    }

    if (sy < ty)
    {
        f(ty, sy - 1, "U", "D");
    }
    else
    {
        f(ty, sy + 1, "U", "D");
    }

    if (sx < tx)
    {
        f(tx + 1, sx, "R", "L");
    }
    else
    {
        f(tx - 1, sx, "R", "L");
    }

    if (sy < ty)
    {
        f(sy - 1, sy, "U", "D");
    }
    else
    {
        f(sy + 1, sy, "U", "D");
    }

    cout << endl;
}


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


int MOD=1000000007;

int main(void){
    int A,B,ma;
    cin >> A >> B;
    ma=A*B;
    ma=max(A+B,ma);
    ma=max(A-B,ma);
    cout << ma << endl;

}

Measured memory_bytes: 256
# coding: utf-8
from heapq import heappop, heappush
from itertools import permutations
N,M,R=map(int,input().split())
r_list=list(map(int,input().split()))

INF=10**11
G=[[INF for j in range(N+1)] for i in range(N+1)]
conection=[[] for i in range(N+1)]

RG=[[INF for j in range(N+1)] for i in range(N+1)]

for i in range(M):
    A,B,C=map(int,input().split())
    G[A][B]=C
    G[B][A]=C
    conection[A].append(B)
    conection[B].append(A)

for k in range(R):
    start=r_list[k]
    d=[INF for i in range(N+1)]
    d[start]=0
    
    used=[False for i in range(N+1)]
    
    heap=[]
    heappush(heap,(d[start],start))
    
    while heap:
        d_u, u = heappop(heap)
        used[u] = True

        if d[u] < d_u:
            continue
        
        for v in conection[u]:
            if not(used[v]) and d_u + G[u][v] < d[v]:
                d[v] = d_u + G[u][v]
                heappush(heap,(d[v],v))
    
    for i in range(R):
        r=r_list[i]
        RG[start][r]=d[r]
        RG[r][start]=d[r]
        
P=permutations(r_list,R)
ans=INF

for p in P:
    tmp=0
    for j in range(R-1):
        tmp+=RG[p[j]][p[j+1]]
    ans=min(ans,tmp)

print(ans)

Measured memory_bytes: 77780
import sys
N,M=map(int,input().split())
table=[set() for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    table[a].add(b)
for x in table[0]:
    if N-1 in table[x]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 79052
import sys
input = sys.stdin.readline

N,u,v=map(int,input().split())
E=[tuple(map(int,input().split())) for i in range(N-1)]

EDGE=[[] for i in range(N+1)]

for x,y in E:
    EDGE[x].append(y)
    EDGE[y].append(x)

from collections import deque
T=[-1]*(N+1)

Q=deque()
Q.append(u)
T[u]=0

while Q:
    x=Q.pop()
    for to in EDGE[x]:
        if T[to]==-1:
            T[to]=T[x]+1
            Q.append(to)

A=[-1]*(N+1)

Q=deque()
Q.append(v)
A[v]=0

while Q:
    x=Q.pop()
    for to in EDGE[x]:
        if A[to]==-1:
            A[to]=A[x]+1
            Q.append(to)


OK=[0]*(N+1)

for i in range(N+1):
    if T[i]<A[i]:
        OK[i]=1

ANS=0
for i in range(N+1):
    if OK[i]==1:
        ANS=max(ANS,A[i])

print(max(0,ANS-1))

Measured memory_bytes: 37284
from bisect import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()

ans = 0
for i in range(10**5+5):
    j = bisect(D, i)
    if j==N//2:
        ans += 1
    elif j>N//2:
        break
print(ans)

Measured memory_bytes: 14120
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tmp = 0
for i in range(0, len(b)):
    tmp += b[a[i]-1]
    if(i < n-1 and a[i]+1 == a[i+1]):
        tmp += c[a[i]-1]

print(tmp)

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

int main(){
	int N, A, B, i, P;
	int num[3] = {0, 0, 0};
	cin >> N >> A >> B;
	for(i = 0; i < N; i++){
		cin >> P;
		if(P <= A){
			num[0]++;
		}
		else if(P <= B){
			num[1]++;
		}
		else{
			num[2]++;
		}
	}
	cout << min(num[0], min(num[1], num[2])) << endl;
	return 0;
}

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

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    vector<ll> V(N), C(N);

    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];

    
    ll ans = 0;
    rep(i, 1 << N ){
        vector<ll> chose;
        ll c = 0 ;
        ll v = 0 ;
        rep(j, N){
            if(1 & (i >> j)) chose.pb(j);
        }
        
        rep(j, chose.size()){
            c += C[chose[j]];
            v += V[chose[j]];
        }
        ans = max(ans, v-c);
    }
    cout << ans << endl;
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ma = max(A, max(B, C));
    ll ans = A + B + C - ma;
    rep(i, K) {
        ma *= 2;
    }
    print(ans+ma);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,n,a) for(int i=n;i>=a;i++)
#define ll long long int
#define p(a,b) pair<a,b>
#define mp(a,b) make_pair(a,b)
#define hpq(a) priority_queue<a>
#define lpq(a) priority_queue<a, vector<a>, greater<a>>
#define nl endl
#define pb(x) push_back(x);
#define ft(x,a) for(auto &it : a)
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
/*

   *                          (                            (
 (  `          )   )          )\ )            )            )\ )        (      )    *   )              )                                                  (
 )\))(      ( /(( /(   (  (  (()/(  (      ( /(   (  (    (()/(        )\  ( /(  ` )  /((   (      ( /(                   (         )    (               )\ )  (
((_)()\  (  )\())\()) ))\ )(  /(_))))\  (  )\()) ))\ )(    /(_))  (   ((_) )\())  ( )(_))(  )\ )   )\())(     (  (  `  )  )\ )     (     )\ )    (  (   (()/( ))\
(_()((_) )\(_))((_)\ /((_|()\(_))_/((_) )\((_)\ /((_|()\  (_))_   )\  )\ )(_))/  (_(_()|()\(()/(  (_))/ )\    )\ )\ /(/( (()/(     )\  '(()/(    )\ )\   ((_))((_)
|  \/  |((_) |_| |(_|_))  ((_) |_(_))( ((_) |(_|_))  ((_)  |   \ ((_)_(_/(| |_   |_   _|((_))(_)) | |_ ((_)  ((_|(_|(_)_\ )(_))  _((_))  )(_))  ((_|(_)  _| (_))
| |\/| / _ \  _| ' \/ -_)| '_| __| || / _|| / // -_)| '_|  | |) / _ \ ' \))  _|    | | | '_| || | |  _/ _ \ / _/ _ \ '_ \) || | | '  \()| || | / _/ _ \/ _` / -_)
|_|  |_\___/\__|_||_\___||_| |_|  \_,_\__||_\_\\___||_|    |___/\___/_||_| \__|    |_| |_|  \_, |  \__\___/ \__\___/ .__/ \_, | |_|_|_|  \_, | \__\___/\__,_\___|
                                                                                            |__/                   |_|    |__/           |__/

*/
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
        cout<<"x";
    
}


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

using namespace std;

#define ll long long

const int INF = 1e9+5;

int dp[3005][3005];

int main(){
    //freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    // diagram from techiedelight
    string s, t;
    cin >> s >> t;

    for(int i = 1; i <= s.size(); ++i){
        for(int j = 1; j <= t.size(); ++j){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                //cout << i << " " << j << " " << dp[i][j] << endl;
            }
            else{
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
                //cout << i << " " << j << " " << dp[i][j] << endl;
            }
        }
    }
    // lcs size
    //cout << dp[s.size()][t.size()]  << endl; 

    int i = s.size(), j = t.size();
    string ans;
    // iterating in reverse
    while(i && j){ // i >= 0 && j >= 0
        if(s[i-1] == t[j-1]){
            ans = s[i-1]+ans; // concatinating previous element into last string
            --i;
            --j;
            continue;
        }
        if(dp[i-1][j] > dp[i][j-1])
            --i;
        else
            --j;
    }

    cout << ans << endl;
}



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

using namespace std;
using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    int a;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if ((i + 1) % 2 != 0 && a % 2 != 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,k; string s;
  cin >> n >> k >> s;

  vector<int> v;
  char c = '1'; int cnt = 0;
  rep(i,n){
    if(c!=s[i]){
      v.push_back(cnt);
      c = s[i];
      cnt = 0;
    }
    cnt++;
  } 
  v.push_back(cnt);
  if(c=='0') v.push_back(0);

  int ans = 0;
  if(v.size()/2<=k){
    ans = n;
  }else{
    vector<int> s(v.size()+1);
    rep(i,v.size()) s[i+1] = s[i] + v[i];
    for(int i = 0; i+2*k<v.size(); i+=2 ){
      ans = max(ans,s[i+2*k+1]-s[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1272
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[999999999999 for i in range(n+1)]
dp[1]=0
for i in range(1,n+1):
  for j in range(1,k+1):
    if i+j<=n:
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j-1]-h[i-1]))
print(dp[-1])

Measured memory_bytes: 56544
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        cnt++;
      }
    }
  }
  if (cnt == h + w - 1) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
  return 0;
}

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

int main(){
    int A, B;
    cin  >> A >> B;
    for(int i = 0; i < B; i++){
        A++;
        if(A == 24) A = 0;
    }
    cout << A << endl;
    return 0;
}


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

typedef long long ll;
const int maxn = 505, mod = 1e9 + 7;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int add(int x, int y) {return x + y < mod ? x + y : x + y - mod;}
inline int fpow(int x, int k)
{
	int res = 1;
	while (k) {
		if (k & 1) res = (ll)res * x % mod;
		k >>= 1; x = (ll)x * x % mod;
	}
	return res;
}

int n, x, C[maxn][maxn], cnt[maxn], f[maxn][maxn][maxn], pw[maxn][maxn], fac[maxn], ifac[maxn];

int main()
{
	n = gi(); x = gi();
	for (int i = 1; i <= n; i++) ++cnt[gi()];
	
	fac[0] = 1;
	for (int i = 1; i < maxn; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[maxn - 1] = fpow(fac[maxn - 1], mod - 2);
	for (int i = maxn - 1; i; i--) ifac[i - 1] = 1ll * ifac[i] * i % mod;
	
	for (int i = 0; i < maxn; i++) {
		C[i][0] = pw[i][0] = 1;
		for (int j = 1; j <= i; j++) C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
		for (int j = 1; j < maxn; j++) pw[i][j] = 1ll * pw[i][j - 1] * i % mod;
	}
	
	f[x + 1][0][0] = 1;
	for (int i = x; i; i--)
		for (int j = 0; j <= x / i; j++)
			for (int k = 0; k <= x; k++)
				for (int l = 0; l <= j && i * l <= k; l++)
					if (f[i + 1][j - l][k - i * l])
						f[i][j][k] = (f[i][j][k] + (ll)f[i + 1][j - l][k - i * l] * ifac[l] % mod * pw[k - (i - 1) * j][cnt[i]]) % mod;

	int ans = 0;
	for (int i = 0; i <= x; i++)
		for (int j = 0; j <= x; j++)
			ans = (ans + 1ll * ((x - j) & 1 ? mod - 1 : 1) * C[x - j + 1][i] % mod * fac[i] % mod * f[1][i][j]) % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 502016
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    string sa,si,su;cin>>sa>>si>>su;
    sa+="z";si+="z";su+="z";
    int a=1,b=0,c=0;
    char now=sa.at(0);
    while(1){
        if(now=='z'){
            if(sa.size()==a){
                cout<<"A"<<endl;
                return 0;
            }
            else if(si.size()==b){
                cout<<"B"<<endl;
                return 0;
            }
            else if(su.size()==c){
                cout<<"C"<<endl;
                return 0;
            }
        }
        else if(now=='a'){
            now=sa.at(a);
            a++;
        }
        else if(now=='b'){
            now=si.at(b);
            b++;
        }
        else if(now=='c'){
            now=su.at(c);
            c++;
        }
    }
}






Measured memory_bytes: 256
#include <cstdio>
 #include <vector>
 #include <queue>
 using namespace std;
 
 struct state
 {
   int city;
   double cost;
   unsigned ticket;
   state(int c, double d, unsigned t) : city(c), cost(d), ticket(t) {}
   bool operator<(const state& that) const
   {
     return cost > that.cost;
   }
 };
 
 int main()
 {
   int N, M, P, A, B;
   while (scanf("%d%d%d%d%d", &N, &M, &P, &A, &B) != EOF && N != 0) {
     --A;  --B;
     static int tickets[8];
     for (int i = 0; i < N; i++) {
       scanf("%d", &tickets[i]);
     }
     vector<pair<int,int> > g[30];
     for (int i = 0; i < P; i++) {
       int x, y, z;
       scanf("%d%d%d", &x, &y, &z);
       --x;  --y;
       g[x].push_back(make_pair(y, z));
       g[y].push_back(make_pair(x, z));
     }
 
     static double dists[30][1<<8];
     for (int i = 0; i < M; i++) {
       fill_n(dists[i], 1<<N, 1e10);
     }
     dists[A][(1<<N)-1] = 0;
     priority_queue<state> q;
     q.push(state(A, 0.0, (1<<N)-1));
     while (!q.empty()) {
       const int n = q.top().city;
       const double cost = q.top().cost;
       const unsigned ticket = q.top().ticket;
       q.pop();
       if (n == B) {
         printf("%.3f\n", cost);
         goto NEXT;
       }
 
       for (vector<pair<int,int> >::const_iterator it(g[n].begin()); it != g[n].end(); ++it) {
         const int to = it->first;
         const int d = it->second;
         for (int i = 0; i < N; i++) {
           if (ticket & (1<<i)) {
             const unsigned s = ticket & ~(1<<i);
             const double c = cost + static_cast<double>(d) / tickets[i];
             if (c < dists[to][s]) {
               dists[to][s] = c;
               q.push(state(to, c, s));
             }
           }
         }
       }
     }
     puts("Impossible");
 NEXT:
     ;
   }
   return 0;
 }


Measured memory_bytes: 4768
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a, b;
	int d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	//cout << d << " " << r << " " << f << endl;
	    printf("%d %d %lf\n", d, r, f);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n,k;
	string s;
	cin>>n>>s>>k;
	
	k--;
	
	REP(i,n){
		if(s[i]==s[k]) cout<<s[i];
		else cout<<'*';
	}
	cout<<endl;
}

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

int main (){

	char data[20];
	int i,yy,mm,dd;
	scanf("%s",data);

yy = atoi(data);
for(i=0;i<5;i++){
	data[i] = data[i+5];
}
mm = atoi(data);
for(i=0;i<2;i++){
	data[i] = data[i+3];
}
dd = atoi(data);
	if(mm <= 4){
	
	printf("Heisei\n");
}
else
	printf("TBD\n");

	return 0;
}

Measured memory_bytes: 128
#第一回日本最強プログラマー学生選手権-予選- a
m,d=map(int,input().split())
ans=0
for month in range(1,m+1):
    for day in range(1,d+1):
        d1=day%10
        d10=day//10
        if d1>=2 and d10>=2 and month==d1*d10:
            ans+=1
print(ans)

Measured memory_bytes: 9184
// Copyright 2020 Tsutomu ISHIKAWA
// Author: Tsutomu ISHIKAWA


#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i=0; i < y; i++) {
        res = res*x%mod;
    }
    return res;
}
int main() {
    ll n;
    cin >> n;
    ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

vector<pair<int,int>> ad[110];
bool b[11000];
//b[i]:頂点iを通る最短経路があるかどうか
int l[110][110];

int n=0;

void dij(int i, int j){

    int d[110];
    int prev[110];
    rep(k,110){
        d[k]=INF;
    }
    d[i]=0;
    rep(k,110){
        prev[k] = -1;
    }
    prev[i]=i;
    set<int> st;
    rep(i,n){
        st.insert(i);
    }

    //cout << "#" << endl;

    while(!st.empty()){
        int mi = INF;
        int u;
        //stの中でd[u]が最大のuを拾ってくる
        auto itr = st.begin();
        rep(t,st.size()){
            int tmp = *itr;
            if(mi>d[tmp]){
                mi = d[tmp];
                u = tmp;
            }
            itr++;
        }

        //cout << i << ", " << j << ", u:" << u << endl;

        

        //int u=q.top();
        st.erase(u);
        auto v=ad[u];
        rep(k,v.size()){
            auto p=v[k];
            int node = p.first;
            int dis = p.second;
            if(d[node]>d[u]+dis){
                d[node]=d[u]+dis;
                prev[node]=u;
            }
        }

    }

    /*
    rep(i,3){
        cout << d[i] << " " << prev[i] << endl;
    }
    */

    int edger = j;
    int edgel = prev[j];
    while(edger!=i){
        if(l[edgel][edger]!=-1){
            b[l[edgel][edger]] = true;
        }
        else{
            b[l[edger][edgel]] = true;
        }
        edgel = prev[edgel];
        edger = edgel;
    }



}




void solve(){

    int n_,m;
    cin >> n_ >> m;
    n=n_;
    vector<pair<int,int>> verlist;
    rep(i,110){
        rep(j,110){
            l[i][j]=-1;
        }
    }
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        ad[a].emplace_back(make_pair(b,c));
        ad[b].emplace_back(make_pair(a,c));
        verlist.emplace_back(make_pair(a,b));
        l[a][b]=verlist.size()-1;
        l[b][a]=verlist.size()-1;
    }

    for(int x=0; x<n-1; x++){
        for(int y=x+1; y<n; y++){
            dij(x,y);
            //cout << "end" << endl;
        }
    }

    //cout << "cal" << endl;

    int ans = 0;
    rep(i,m){
        if(!b[i]) ans++;
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 512
from sys import exit
N = int(input())
A = list(map(int, input().split()))
ans = 1
A.sort(reverse=True)
if A[-1] == 0:
  print(0)
  exit()
for a in A:
  ans *= a
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)


Measured memory_bytes: 21612
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n, q;
    cin >> n >> q;

    vector<int> c(n);
    for(int i = 0; i < n; i++)  cin >> c[i];
    sort(c.begin(), c.end());

    int x;
    while(q-- > 0){
        cin >> x;
        int ans = 0;
        for(int i = x; i <= (c[n-1]+x-1)/x*x; i+=x){
            auto it = lower_bound(c.begin(), c.end(), i);
            if(it != c.begin()) it--;
            ans = max(ans, (*it)%x);
            if(ans == x-1)  break;
        }
        cout << ans << endl;
    }

    return 0;
}


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

int main()
{
  int N, T, c[1000], t[1000], ans = 1001;
  cin >> N >> T;
  for(int i = 0; i < N; i++)
    cin >> c[i] >> t[i];

  for(int i = 0; i < N; i++){
    if(t[i] <= T && ans > c[i]){
      ans = c[i];
    }
  }

  if(ans == 1001)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	string s;
	rd(s);
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
	return 0;
}

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

int main(){
  int h, n;
  cin >> h >> n;
  int ans=0;
  for(int i=0; i<n; ++i){
    int x;
    cin >> x;
    ans += x;
  }
  if(ans >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

A = []

Q = int(sys.stdin.readline().rstrip())
for _ in range(Q):
    s = sys.stdin.readline().rstrip().split()
    if s[0] == "0":  # pushback
        A.append(s[1])
    elif s[0] == "1":  # randomAccess
        print(A[int(s[1])])
    else:
        A.pop()



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

vector<int> pf(101,0);

void primeFact(int n) {
    for(int i=2; i*i<=n; i++)
        while(n%i == 0) {
            pf.at(i)++;
            n /= i;
        }
    
    if(n != 1)
        pf.at(n)++;
}

int cntPFE(int x) {
    int c=0;
    rep(i,101)
        if(pf.at(i) > x-2)
            c++;
    return c;
}

int main() {
    int N,j,k,r=0,l;
    vector<int> pf2;
    cin >> N;

    rep(i,N)
        primeFact(i+1);
    
    cout << cntPFE(75)+cntPFE(25)*(cntPFE(3)-1)+cntPFE(15)*(cntPFE(5)-1)+cntPFE(5)*(cntPFE(5)-1)*(cntPFE(3)-2)/2 << endl;
}

Measured memory_bytes: 256