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

public class Main	 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int P[] = new int[N];
		int sum = 1;
		boolean flag = true;
		for(int i=0; i < N; i++) {
		P[i] = scan.nextInt();
		}
		int pre_min = P[0];

		for(int i=1; i<N; i++) {
			flag = true;
			if(P[i] < pre_min) {
				sum +=1;
				pre_min = P[i];
			}


			/*
			if(pre_min > P[i]) {
				pre_min = P[i];
			}else {
			sum += 1;
			}
			*/
		}
/*
		for(int i=1; i<N; i++) {
			loop: for(int j=1; j<i+1; j++) {
			flag = true;
			c
			/*
			if(P[i] > P[j-1]) {
				flag = false;
				break;
			}

			if(P[i] == 0) {
				flag = true;
				break;
			}

		}
			if(flag == true) {
				sum += 1;
				pre_min = P[i];
			}
		}
		System.out.print(sum);
*/

		System.out.print(sum);
	}
}


Measured memory_bytes: 86320
#include<stdio.h>
#include<stdlib.h>
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
int main(){
    int A , B , K ;
    scanf("%d%d%d",&A,&B,&K) ;
    int arr[100] ;
    int x = MIN(A,B) ;int i, k = 0;
    for( i = x ; i>=1 ; i--){
        if(A % i == 0 && B % i == 0){
            arr[k] = i ;
            k++ ;
        }
    }
    
    printf("%d",arr[K-1]);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>
//#include <chrono> //正確な時間計測のため
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
#define MOD 998244353
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 

//階乗
ll Kaijou(ll a) {
if (a < 2) return 1;
return a * Kaijou(a - 1)%MOD;
}

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(ll a, ll b, ll p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}


//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

ll CCC(ll all,ll a,ll b,ll c){
  all=Kaijou(all)%MOD;
  a=Kaijou(a);
  b=Kaijou(b);
  c=Kaijou(c);
  ll sita=((a*b)%MOD*c)%MOD;
  return all*calc(sita,MOD-2,MOD)%MOD;
}

 ll ans=INF;

 ll cc[501][501];
 ll D[31][31];
 
 ll pdmin[3];

//再帰なし累乗
ll iPOW(ll x, ll p){
  ll result;
	for(result=1;p!=0;p>>=1)
	{
    if(p&1) result*=x;
	  x*=x;
  }
  return result;
}


int main(){  
 int n;
 cin>>n;
 if(n%2) cout<<2*n<<endl;
 else cout<<n<<endl;

}

Measured memory_bytes: 256
T = input()
T = T.split(" ")
x = int(T[0])
k = int(T[1])
d = int(T[2])
val = (x+k*d)//(2*d)
if val>=0 and val<=k:
    print(min(abs(-2*d*val+x+k*d), abs(-2*d*(val+1)+x+k*d)))
elif val<0:
    print(abs(x+k*d))
else:
    print(abs(x-k*d))

Measured memory_bytes: 9200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a <= 8 && b <= 8) System.out.println("Yay!");
    else System.out.println(":(");
  }
}

Measured memory_bytes: 32688
from math import sqrt
N = int(input())
ans = 0
for i in range(7, N+1):
  if i%2==0:
    continue
  c = 0
  for j in range(1, int(sqrt(i))+1):
    if i%j==0:
      c+=2
  if c==8:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    int n;
    cin >> n;
    int ans = 0;
    int res = 1;
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        int x = i;
        while (x%2==0){
            x /= 2;
            cnt++;
        }
        if(cnt>ans){
            ans = cnt;
            res = i;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        set<ll> st;
        st.insert(l[i]);
        st.insert(l[j]);
        st.insert(l[k]);
        if((ll)st.size() == 3){
          ll a = l[i];
          ll b = l[j];
          ll c = l[k];
          if(a+b>c&&b+c>a&&a+c>b){
          ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vll a(n);
  ll sum = 0;
  rep(i,n) {
    cin >> a.at(i);
    sum += a[i];
  }
  ll cnt = 0;
  vll v(n-1);
  rep(i,n-1) {
    cnt += a[i];
    v[i] = abs(sum-2*cnt);
  }
  ll ans = LLONG_MAX;
  rep(i,n-1) ans = min(ans,v[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef long long ll;

int main() {
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (abs(a - b) <= t * (v - w)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define fr first
#define sc second
using namespace std;
ll ar[26] ;
int main()
{
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Murtazoev_2007
    speed ;
    ///Autor of the greatest code :: Ahmadjon Murtazoev
    string al = "abcdefghijklmnopqrstuvwxyz" ;
    string s ;
    cin >> s ;
    ll a = s.size() ;
    for (ll i = 0 ; i<26 ; i ++ )
    {
        for (ll j = 0 ; j<a ; j ++ )
        {
            if (s[j] == al[i])
            {
                ar[i] ++ ;
            }
        }
    }
    for (ll i = 0 ; i<26 ; i ++ )
    {
        if (ar[i]%2 != 0)
        {
            cout << "No" << endl ;
            return 0 ;
        }
    }
    cout << "Yes" << endl ;
    return 0 ;
}


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

using namespace std;

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

  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }

  int four = h / 2 * (w / 2);
  int two = (h * w - four * 4) / 2;
  int one = (h * w - four * 4) % 2;

  map<char, int> mp;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      mp[a[i][j]]++;
    }
  }

  for (auto &i : mp) {
    int k = min(four, i.second / 4);
    i.second -= k * 4;
    four -= k;
  }

  for (auto &i : mp) {
    int k = min(two, i.second / 2);
    i.second -= k * 2;
    two -= k;
  }

  for (auto &i : mp) {
    int k = min(one, i.second);
    i.second -= k;
    one -= k;
  }

  cout << (four == 0 && two == 0 && one == 0 ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
bool judge(char s[],int a,int b)
{
	int i;
	for(i=a-1;i<(a+b)/2;i++)
	{
		if(s[i]!=s[b-1-i])
		break;
	}
	if(i<(a+b)/2)
	return false;
	else return true;
}
int main()
{
	char s[100];
	int l,p,h;
	cin>>s;
	l=strlen(s);
	p=1;
	h=l;
	if(judge(s,p,h))
	{
		p=1;
		h=(l-1)/2;
		if(judge(s,p,h))
		{
			p=(l+3)/2;
			h=l;
			if(judge(s,p,h))
			cout<<"Yes";
			else cout<<"No";
		}
		else
		cout<<"No";
	}
	else
	cout<<"No";
}

Measured memory_bytes: 256
n = int(input())
num_list = [int(i) for i in input().split()]
count = 0

for i in range(1,n):
    if num_list[i] < num_list[i-1]:
        count += (num_list[i-1] - num_list[i])
        num_list[i] = num_list[i-1]

print(count)

Measured memory_bytes: 32128
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    long long ans = 0;
    long long tmp=N/10;
    ans+=tmp;
    while(tmp>0){
        tmp=tmp/5;
        ans+=tmp;
    }

    if(N%2==0){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int n;
vector<ll> a;
ll sum(ll b) {
	ll s = 0;
	for (int i = 0;i < n;i++) {
		s += abs(a[i] - b);
	}
	return s;
}

int main(){
	cin >> n;
	a.resize(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	cout << sum(a[(n - 1) / 2]) << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<math.h>
#include<functional>
#define tmax 50000
int n,dp[4][41];
int bpos[41],bt[41];
using namespace std;
int f(int a)
{
	if(a<0)
		return a*-1;
	else
		return a;
}
int main()
{
	int i,j,k,t,ng;	
	int v[]={1,2,3,4};
	while(scanf("%d",&n)==1)
	{
		if(n==0)
			break;
		memset(dp,0,sizeof(dp));
		for(i=1;i<=n;i++)
			scanf("%d%d",&bpos[i],&bt[i]);
		if(bpos[1]>bt[1])
			printf("NG 1\n");
		else
		{	
			ng=0;
			dp[1][1]=bpos[1];
		//霓ャ遘サ譌カ豌ク荳咲畑 min ??
			for(i=1;i<n;i++)	
			{
				if(ng>0)
					break;
				for(k=0;k<=3;k++)
				{
					if(ng>0)
						break;
					if(dp[k][i]>0)
					{
						if(k==3)
						{
							t=bpos[i]*v[3]+bpos[i+1]*v[0]+bt[i];
							if(t<=bt[i+1])
							{
							//	ng=i+1;	
							//	break;							
						int temp=bpos[i]+dp[k][i]+bpos[i+1];
							if(dp[1][i+1]==0)
								dp[1][i+1]=temp;
							else if(dp[1][i+1]>temp)
								dp[1][i+1]=temp;
							}	

						}
						else if(k==0)
						{
							int temp=bpos[i+1]+dp[k][i];	
							if(dp[1][i+1]==0)
								dp[1][i+1]=temp;
							else if(dp[1][i+1]>temp)
								dp[1][i+1]=temp;
						}
						else
						{
							int ok=1;//!!!!!!!!!!!!!!!
							//t=bpos[i]/v[3]+bpos[i+1]/v[0]+bt[i];
							t=bt[i]+f(bpos[i+1]-bpos[i])*v[k];
							if(t<=bt[i+1])
							{
								ok=1;
								int temp=dp[k][i]+f(bpos[i+1]-bpos[i]);	
								if(dp[k+1][i+1]==0)
									dp[k+1][i+1]=temp;
								else if(dp[k+1][i+1]>temp)
									dp[k+1][i+1]=temp;
							}
							t=bpos[i]*v[k]+bpos[i+1]*v[0]+bt[i];
							if(t<=bt[i+1])
							{
								ok=1;
								int temp=bpos[i]+dp[k][i]+bpos[i+1];
								if(dp[1][i+1]==0||dp[1][i+1]>temp)
									dp[1][i+1]=temp;
							}
							if(!ok)
							{
								ng=i+1;	
								break;	
							}	
						}
							
					}
						
				}	
			}
		
			int ans=0x7fffffff;	
			for(k=1;k<=3;k++)
				{
					if(dp[k][n]>0&&dp[k][n]<ans)
						ans=dp[k][n];
					
				}
		ng=0;
		if(ans==0x7fffffff)
		{	
			for(i=n;i>=1;i--)
			{
				for(k=1;k<=3;k++)
				{
					if(dp[k][i]>0)
					{
						ng=i+1;
						break;
					}
				}
				if(ng>0)
					break;
			}
			
			printf("NG %d\n",ng);
		
		}
		else
		{

			printf("OK %d\n",ans+bpos[n]);
		
		}	
		}
	}
	
	//system("pause");
	return 0;	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

// int A[10100];
int res = 0;

ll my_pow(int n){
    ll ans = 1;
    ll mul = 2;
    while(n > 0){
        if(n & 1 == 1) ans = ans * mul % MOD;
        mul = mul * mul % MOD;
        n >>= 1;
    }
    return ans;
}
int main(int argc, char *argv[]){
    int n; cin >> n;
    bool flag = true;
    v A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    if(n % 2 == 0){ // even
        int i = 0;
        int j = 1;
        while(i < n){
            if(A[i] != j && A[i + 1] != j) { flag = false; break; }
            i += 2;
            j += 2;
        }
        if(flag){
            res = my_pow(n/2);
        }
    }else{ // odd
        if(n == 1){
            cout << 1 << endl;
            return 0;
        }
        int i = 0;
        int j = 0;
        if(A[0] == 0 && A[1] == 0) { flag = false; goto end; }
        while(i < n){
            if(A[i] != j && A[i + 1] != j) { flag = false; break; }
            i += 2;
            j += 2;
        }
        if(flag){
            res = my_pow(n/2);
        }
    }
end:
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int a,b,c, count=3;
    scanf("%d%d%d", &a, &b, &c);
    if(a==b) count-=1;
    if(a==c) count-=1;
    if(b==c) count-=1;
    if(a==b&&a==c) count=1;
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 1676
let () = Scanf.scanf "%d %d %d" @@ fun k a b ->
  Printf.printf "%d\n" @@ max (1 + k) @@
  if b <= a || k <= a - 1 then min_int
  else a + (k - a + 1) / 2 * (b - a) + (k - a + 1) mod 2


Measured memory_bytes: 384
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
void solve(vector<ll>x){
    vector<ll>y=x;
   sort(y.begin(),y.end());
   int l=(n-1)/2;
   int r=n/2;
   rep(i,n){
       if(x[i]<=y[l])cout<<y[r]<<endl;
       else cout<<y[l]<<endl;
   }
    
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    vector<ll>x(n);
    rep(i,n)cin>>x[i];
    solve(x);
    return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...

    int W,H,x,y,r;

    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if((x-r) >=0 && (x+r)<= W && (y-r) >= 0 && (y+r) <= H )printf("Yes\n");
    else printf("No\n");
    
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    ll march[5] = {};
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'M') march[0]++;
        else if (s[0] == 'A') march[1]++;
        else if (s[0] == 'R') march[2]++;
        else if (s[0] == 'C') march[3]++;
        else if (s[0] == 'H') march[4]++;
    }
    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += march[i] * march[j] * march[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll n;
//0-indexed
vector<vector<pll> >G(100010);
vector<ll> d(100010);
void dijkstra(ll s,vector<vector<pll> >&G,vector<ll> &d){
    priority_queue<pll,vector<pll>,greater<pll> >pq;
    rep(i,n){
        d[i]=inf*inf;
    }
    d[s]=0;
    pq.push(mp(0,s));
    while(!pq.empty()){
        pll k=pq.top();pq.pop();
        ll v=k.second;
        if(d[v]<k.first)continue;
        for(auto e:G[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                pq.push(mp(d[e.first],e.first));
            }
        }
    }
}
int main(){
    ll m;cin>>n>>m;
    ll s,t;cin>>s>>t;
    s--;t--;
    vector<vector<pll> >G1(n);
    vector<vector<pll> >G2(n);
    rep(i,m){
        ll u,v,a,b;cin>>u>>v>>a>>b;
        u--;v--;
        G1[u].pb(mp(v,a));
        G1[v].pb(mp(u,a));
        G2[u].pb(mp(v,b));
        G2[v].pb(mp(u,b));
    }
    vector<ll>d1(n),d2(n);
    dijkstra(s,G1,d1);
    dijkstra(t,G2,d2);
    vector<ll>ans(0);
    ll mi=d1[n-1]+d2[n-1];
    for(int i=n-1;i>=0;i--){
        mi=min(d1[i]+d2[i],mi);
        ans.pb(mi);
    }
    reverse(all(ans));
    ll snuuk=1000000000000000;
    rep(i,n){
        cout<<snuuk-ans[i]<<endl;
    }
}

Measured memory_bytes: 23036
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val chars = listOfString()

    if (chars[0] == "H") {
        // AtCoder == honest
        if (chars[1] == "H") {
            println("H")
        } else {
            println("D")
        }
    } else {
        // AtCoder == dishonest
        if (chars[1] == "H") {
            println("D")
        } else {
            println("H")
        }
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36020
n = int(input())
ans = 10**10
for i in range(1,n):
    j = n-i
    l1 = len(str(i))
    l2 = len(str(j))
    l1_cnt,l2_cnt = 0,0
    for k in range(l1):
        l1_cnt +=int(str(i)[k])
    for l in range(l2):
        l2_cnt +=int(str(j)[l])
    ans = min(ans,l1_cnt+l2_cnt)
print(ans)

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            var A = AB[0];
            var B = AB[1];

            long sa = Saishou(A,B);

            Console.WriteLine(sa);

        }

        public static long Saishou(long a, long b)
        {
            return a * b / Gcd(a, b);
        }
        

        public static long Gcd(long a, long b)
        {
            if (a < b)

                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
    
}


Measured memory_bytes: 11220
#include <iostream>
#include <climits>
#include <algorithm>
#include <math.h>


using namespace std;

int N,A,B;
string S;


int main()
{

    cin >> S;
   
    int n = 0;
    int con = 0;

    n = S.size();

    for (int i = 0; i < n / 2; i++ ) {
        if (S[i] != S[n-1-i]) { con++ ;  break; };
    }

    for (int i = 0; i < (n-1)/4; i++) {
        if (S[i] != S[(n-1)/2-1-i]) { con++;  break; };
    }

    for (int i = 0; i < (n-(n+3)/2+1)/2; i++) {
 //       cout << S[n - i - 1] << endl;
 //       cout << S[(n + 3) / 2] << endl;

        if (S[n-i-1] != S[(n + 3) / 2-1+i]) { con++;  break; };
    }


    if (con == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;

    }
    
    return 0;
}


Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

ans = 0
for r in range(3010):
  red = r * R
  if N < red:
    break
  
  for g in range(3010):
    green = g * G
    blue = N - red - green
    if blue < 0:
      break
    if blue % B == 0:
      ans += 1
      
print(ans)


Measured memory_bytes: 40684
from bisect import bisect_left as bi
n = int(input())
x = [int(i) for i in input().split()]
x,ans = sorted(x),0
for i in range(2,n):
    for j in range(i-1,0,-1):
        b = bi(x,x[i]-x[j]+1)
        if b<j: ans+=j-b
        else: break
print(ans)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
  private static final int[] mnum = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] A = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    
    int[] dp = new int[N+1];
    Arrays.fill(dp, -1000);
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < M; j++) {
        if (i - mnum[A[j]] >= 0) {
          dp[i] = Math.max(dp[i], dp[i-mnum[A[j]]]+1);
        }
      }
    }
    
    String ans = "";
    int len = dp[N];
    int remain = N;
    for (int i = len; i > 0; i--) {
      for (int j = M-1; j >= 0; j--) {
        if (remain-mnum[A[j]] >= 0
            && dp[remain-mnum[A[j]]] == i-1) {
          ans = ans + Integer.toString(A[j]);
          remain -= mnum[A[j]];
          break;
        }
      }
    }
    System.out.println(ans);
  }
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x>k/2)ans+=(k-x)*2;
        else ans+=x*2;
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
def main():
    # map(int, input().split())
    # l = list(map(int, input().split()))
    X = int(input())
    rest = X
    flag = False
    for i in range(1000001):
        if rest == 0 or rest % 100 == 0:
            flag = True
            break
        elif rest < 100:
            flag = False
            break
        amari = rest % 100
        if amari >= 5:
            rest -= 105
        elif amari >= 4:
            rest -= 104
        elif amari >= 3:
            rest -= 103
        elif amari >= 2:
            rest -= 102
        elif amari >= 1:
            rest -= 101
    print(1 if flag else 0)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const long double pi = 3.14159265358979323846;



void solve() {
  string s, t; cin >> s >> t;
  ll n = s.length(), ans = 0;
  f0r(i, n) if (s[i] != t[i]) ++ans;
  cout << ans << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3900
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int n;
	cin >> n;
	map<int, int>even, odd;
	vector<int>v(n);
	rep(i, n) {
		cin >> v[i];
		if (i & 1)odd[v[i]]++;
		else even[v[i]]++;
	}
	vector<P>od, ev;
	for (auto i : odd) {
		P j = i;
		swap(j.first, j.second);
		od.push_back(j);
	}
	for (auto i : even) {
		P j = i;
		swap(j.first, j.second);
		ev.push_back(j);
	}
	P p = { 0,-1 };
	od.push_back(p);
	ev.push_back(p);
	sort(od.begin(), od.end());
	sort(ev.begin(), ev.end());
	int ans;
	if (od[od.size()-1].second != ev[ev.size()-1].second) {
		ans = n / 2 - od[od.size() - 1].first + n / 2 - ev[ev.size() - 1].first;
	}
	else {
		int ans1, ans2;
		ans1 = n / 2 - od[od.size() - 2].first + n / 2 - ev[ev.size() - 1].first;
		ans2 = n / 2 - od[od.size() - 1].first + n / 2 - ev[ev.size() - 2].first;
		ans = min(ans1, ans2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9592
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int a, b, c; cin >> a >> b >> c;

	cout << (((a + b) == c || (b + c) == a || (c + a) == b) ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;
vector<int> v[maxn];
queue<int> q;
int ans[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	rep(i,0,m)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	q.push(1);
	while(!q.empty())
	{
		int x=q.front();q.pop();
		rep(i,0,v[x].size())
		{
			if(ans[v[x][i]]) continue;
			ans[v[x][i]]=x;
			q.push(v[x][i]);
		}
	}
	rept(i,2,n)
	{
		if(!ans[i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	rept(i,2,n) cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 10544
import java.util.*;

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

        int sLen = S.length();
        int tLen = T.length();
        if (S.equals(T.substring(0, tLen-1)))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35568
s = gets.chomp
num = []
last = "0"
cnt = 0
s.chars { |c|
  if c != last
    num << cnt
    cnt = 1
    last = c
  else
    cnt += 1
  end
}
num << cnt

l = 0
ans = s.length
num.each_with_index { |n,i|
  #p i
  if i % 2 == 1
    r = l + n - 1
    k = [[r+1 ,s.length-l].min , l, s.length-r-1].max
    ans = k if k < ans
    #puts k
  end
  l += n
}
puts ans
#p num


Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

vector<ll> divisor(ll n){
	vector<ll> ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n)ret.push_back(n/i);
		}
	}
	sort(ret.begin(),ret.end());
	return(ret);
}
 
int main(){
	ll n,m; cin >> n >> m;
	vector<ll> v=divisor(m);
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		ll p=v[i];
		if(p*n<=m){
			cout << p << endl;
			return 0;
		}
	}
}

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

using i64 = int64_t;

double dp[3003][3003] = {0};

int main(){
    int n;
    cin >> n;
    vector<double> v;
    v.push_back(0);
    for(int i=0;i<n;++i){
        double p;
        cin >> p;
        v.push_back(p);
    }
    dp[1][0] = 1 - v[1];
    dp[1][1] = v[1];
    for(int i=2;i<=n;++i){
        for(int j=0;j<=i;++j){
            dp[i][j] = dp[i-1][j]*(1-v[i]) + dp[i-1][j-1]*v[i];
        }
    }

    double ans = 0;
    for(int i=n/2+1;i<=n;++i){
        ans += dp[n][i];
    }

    printf("%.10f\n",ans);

    return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
void zz(int n){
  int f=0;
  for(int i=3;i<=sqrt(n);i+=2){
    if(n%i==0) {
      f=1; i=sqrt(n)+1; continue;
    }
  }
  if(f==0){
    cout<<n<<endl;
    exit(0);
  }
}

int main() {
  int x; cin>>x;
  if(x<=3||x==5){
    cout<<x<<endl;
    exit(0);
  }else if(x==4){
    cout<<x+1<<endl;
    exit(0);
  }else if(x%2==0){
    x++;
  }
  while(true){
    zz(x);
    x+=2;
  }
}

Measured memory_bytes: 256
// 2011/05/04 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		int lng[1000];
		for(int i=0; i<n; i++)
			lng[i] = i+1;
/*
		for(int i=0; i<n; i++)
			cout << lng[i] << ' ';
		cout << endl;
*/
		int k = 0;
		while(n>1){
			k = (k-1+m)%n;
			for(int i=k; i<n-1; i++)
				lng[i] = lng[i+1];
			n--;
/*
		for(int i=0; i<n; i++)
			cout << lng[i] << ' ';
		cout << endl;
*/
		}

		cout << lng[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#8方向走査
#下、右、上、左、右下、右上、左上、左下
dy=[1,0,-1,0,1,-1,-1,1]
dx=[0,1,0,-1,1,1,-1,-1]

H,W=map(int,input().split())

#文字列→作成後変更不可
#文字列をリスト化し変更可にする
field=[]
for _ in range(H):
  field.append(list(input()))

for y in range(H):
  for x in range(W):
    if field[y][x]=="#":
      continue
    count=0
    for k in range(8):
      tmp_y=y+dy[k]
      tmp_x=x+dx[k]

      if tmp_y<0 or tmp_y>=H or tmp_x<0 or tmp_x>=W:
        continue
      if field[tmp_y][tmp_x]=="#":
        count+=1
    field[y][x]=str(count)

#"".join(list)→listの各要素を区切り文字なしで結合して出力
#" ".join(list)→listの各要素を半角スペースで結合して出力
for y in range(H):
  print("".join(field[y]))

Measured memory_bytes: 3188
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	ll a,b,n;cin>>a>>b>>n;
	 
	if(b==1){
		cout<<"0"<<endl;
	}
	else{
		if(n>=b)cout<<(a*(b-1))/b<<endl;
		else cout<<(a*n)/b<<endl;
	}
	
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

void test_case(){
    
}

int main() {
    fastio
    int k, x;
    cin >> k >> x;
    if(k*500 >= x)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}






Measured memory_bytes: 256
N,P=map(int, input().split())
A=list(map(int, input().split()))
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


odds=0
evens=0
for a in A:
    if a%2==0:
        evens+=1
    else:
        odds+=1
ans=0
a=0
b=0
if P==0:
    #偶数と奇数を偶数個
    for i in range(evens+1):
        a+=cmb(evens, i)
    for j in range(0,odds+1, 2):
        b+=cmb(odds, j)
    #print(a,b)
    ans+=a*b
if P==1:
    #偶数と奇数を奇数個
    for i in range(evens+1):
        a+=cmb(evens, i)
    for j in range(1,odds+1, 2):
        b+=cmb(odds, j)
    ans+=a*b
print(ans)


Measured memory_bytes: 3684
n = gets.chomp.to_i
g = Array.new(n).map{Array.new(n,-1)}

n.times do |i|
  a = gets.to_i
  a.times do 
    x,y = gets.chomp.split.map(&:to_i)
    g[i][x-1] = y
  end
end

ans = 0
(2**n).times do |s|
  ok = true
  n.times do |i|
    if (s>>i&1) == 1
      n.times do |j|
        if ((g[i][j] != -1) && (s>>j&1 != g[i][j]))
           ok = false
        end
      end
    end
  end
  
  if ok
    ans = [ans, s.to_s(2).count('1')].max
  end
end
puts ans


Measured memory_bytes: 1788
N = int(input())
A = list(map(int,input().split()))

M = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
    total = 0
    n = 2
    while (i+1) * n <= N:
        total += M[(i+1)*n-1]
        n += 1

    if total % 2 == A[i]:
        M[i] = 0
    else:
        M[i] = 1


print(sum(M))

kugiri = False
for i in range(len(M)):
    if M[i] == 1:
        if kugiri:
            print(" ", end="")
        print(i+1, end="")
        kugiri = True
print()


Measured memory_bytes: 7408
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = INT_MAX;
    for(int k=0; k<2; ++k){
        int cnt = 0;
        for(int i=0; i<n; ++i){
            if(s[i] != '0' + (i + k) % 2)
                ++ cnt;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> deg(n);
    forn (i, 1, n) {
        int p;
        cin >> p, --p;
        deg[p]++;
    }
    forn (i, 0, n)
        cout << deg[i] << "\n";
    return 0;
}

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

int main() {
  	long long target;
  	cin >> target;
  	long long start = 100;
  	long long years = 0;
  	while (start < target) {
     	long long interest = start / 100;
      	start += interest;
      	++years;
    }
  	cout << years << endl;
 	return 0; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */

int main(){
	int n=gi(),l=gi();
	static int a[200000];
	rep(i,1,n)a[i]=gi();	
	int p=0,mx=0;
	rep(i,1,n-1)if(a[i]+a[i+1]>mx)mx=a[i]+a[i+1],p=i;
	if(mx<l)puts("Impossible");
	else{
		puts("Possible");
		rep(i,1,p-1)write(i);
		repd(i,n-1,p+1)write(i);
		write(p);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    int l=0,r=n+1;
    rep(i,m){
        l=max(l,in());
        r=min(r,in());
    }
    cout<<max(0,r-l+1)<<endl;
}


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

// ABC092 at 2018/**/**

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

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.nextLine());
        int B = Integer.parseInt(sc.nextLine());
        int C = Integer.parseInt(sc.nextLine());
        int D = Integer.parseInt(sc.nextLine());
        int result = 0;

        if (A < B) {
            result += A;
        } else {
            result += B;
        }
        if (C < D) {
            result += C;
        } else {
            result += D;
        }

        System.out.println(result);
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int D = sc.nextInt();
        int X = sc.nextInt();
        sc.nextLine();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(Integer.parseInt(sc.nextLine()));
        }
        int result = 0;
        for (Integer num : list) {
            int numa = num.intValue();
            int cnt = 1;
            for (int i = 1; i <= D; i++) {
                if (cnt == i) {
                    result++;
                    cnt += numa;
                }
            }
        }
        System.out.println(result + X);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int m,d;
    cin>>m>>d;
    int c=0;
    for (int i=1; i<=m; i++) {
        for (int j=10; j<=d; j++) {
            int l=j/10;
            int n=j%10;
            if (i==l*n && l>=2 && n>=2) c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
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();
        
        double s = 0.5*a*b*Math.sin(Math.toRadians(c));
        double l = a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(c)));
        double h = 2 * s / a;
        
        System.out.println(s);
        System.out.println(l);
        System.out.println(h);
    }
}


Measured memory_bytes: 26352
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<long long>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define vs vector<string>
#define mx INT_MAX
#define mn INT_MIN
#define all(z) z.begin(),z.end()
#define mcc 1000000007
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
using namespace std;

//ll maxl(ll a,ll b) {return (a>b)? a:b;}
//ll minl(ll a,ll b) {return (a<b)? a:b;}
//ll gcdl(ll a,ll b) {return b ? gcdl(b,a%b):a;}


void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b;
}


#if 1
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
#endif

//------------------------Google-------------------
#if 0
int main()
{
    #ifdef __WIN32
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,ct=0;
    cin>>t;
    while(t--)
    {
        cout<<"Case #"<<++ct<<": ";
        solve();
    }
    return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#define nmax 3001

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

int dist[nmax][nmax];

int main()
{
    char s[nmax],t[nmax];
    cin>>s>>t;
    int n=strlen(s),m=strlen(t);

    for(int i=0; i<=n; i++)
        for(int j=0; j<=m; j++)
            if(i==0 || j==0) dist[i][j]=0;
            else
                if(s[i-1]==t[j-1])
                    dist[i][j]=1+dist[i-1][j-1];
                else
                    dist[i][j]=max(dist[i-1][j],dist[i][j-1]);

    /*for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
                fout<<dist[i][j]<<" ";
            fout<<endl;
        }*/

    char sol[nmax];
    int ct=0;

    int i=n,j=m;
    while(i>0 && j>0)
        {
            if(s[i-1]==t[j-1]) {sol[ct++]=s[i-1]; i--; j--;}
            else if(dist[i-1][j]>dist[i][j-1])  i--;
                 else j--;
        }

    sol[ct]=NULL;
    for(int i=ct-1; i>=0; i--)
        cout<<sol[i];

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin >> N >> M;
    int X[M];
    rep(i,M) cin >> X[i];

    int ans=0;
    if(N>=M) ans=0;
    else{
        sort(X,X+M);
        int x[M-1];
        rep(i,M-1){
            x[i]=X[i+1]-X[i];
        }
        ans=X[M-1]-X[0];
        sort(x,x+M-1);
        reverse(x,x+M-1);
        rep(i,N-1){
            ans-=x[i];
        }
    }
    cout << ans << endl;
    



}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<ii> v;
    int n,m;
    cin>>n>>m;
    while(m--){
        int x,y;
        cin>>x>>y;
        v.pb({y-1,x});
    }
    int ans=0;
    int cur=-1;
    sort(all(v));
    f(sz(v)){
        if(v[i].ss>cur){
            ++ans;
            cur=v[i].ff;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1400