akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, k;
    cin >> n >> k;
    std::vector<int> m(n);
    std::vector<int> dp(n, MOD);
    for (int i = 0; i < n; i++) {
        cin >> m[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j < n) {
                chmin(dp[i + j], dp[i] + abs(m[i + j] - m[i]));
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int used[200];
int main()
{
	int x,n;
	cin>>x>>n;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin>>a;
		used[a] = 1;
	}
	int min = INT_MAX,ans;
	for (int i = 0; i < 200 ; ++i)
	{
		if(used[i]==0)
		{
			if(abs(i-x)<min)
			{
				min = abs(i-x);
				ans = i;
			}
		}
	}
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int a,b,d,c;
    
    scanf("%d%d%d%d",&a,&b,&c,&d);
    
    
    

    
    if ((((a-b)*(a-b))<=d*d && ((c-b)*(c-b))<=d*d) || ((c-a)*(c-a))<=d*d) {
        printf("Yes\n");
    }else if (a==a) {
        printf("No\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int A,B,C,s=0,t=0;
    scanf("%d %d %d",&A,&B,&C);
    while(t<C){
        s++;
        t+=A;
        if(s%7==0){
            t+=B;
        }
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2148
#include<stdio.h>
int main()
{
	int a,cnt=0,i;
	scanf("%d",&a);
	while(1){
		for(i=1;i<=a;i++){
			if(a%i==0){
				cnt++;
			}
		}
		if(cnt==2){
			break;
		}
		cnt=0;
		a++;
	}
	printf("%d\n",a);
	return 0;
}

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

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

int n, m, q;
std::vector<int> a, b, c, d;
int ans;

void dfs(std::vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = std::max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  std::cin >> n >> m >> q;

  a = b = c = d = std::vector<int>(q);

  rep(i, q) { std::cin >> a[i] >> b[i] >> c[i] >> d[i]; }

  dfs(std::vector<int>(1, 1));

  std::cout << ans << '\n';
  return 0;
}


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

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

int a[100];
for(int i=0;i<n;i++) cin>>a[i];

for(int i=0;i < n-1-i;i++) swap(a[i], a[n-1-i]);

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

return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

const LLONG Num(const LLONG B, const LLONG A, const LLONG Q)
{
    LLONG BQ = B / Q, AQ = A / Q;
    if (A % Q == 0)
    {
        return BQ - AQ + 1;
    }
    else
    {
        return BQ - AQ;
    }
}

const LLONG GCM(const LLONG a, const LLONG b)
{
    if (b == 0)
    {
        return a;
    }
    return GCM(b, a % b);
}

int main()
{
    LLONG A, B, C, D;
    cin >> A >> B >> C >> D;
    LLONG total = B - A + 1;
    LLONG divC = Num(B, A, C);
    LLONG divD = Num(B, A, D);
    LLONG gcm = GCM(max(C, D), min(C, D));
    LLONG bcm = C * D / gcm;
    LLONG divCD = Num(B, A, bcm);
    cout << total - divC - divD + divCD << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def solve(N, v):
    v = list(sorted(v))
    a = v[0]
    for b in v[1:]:
        a = (a+b) / 2.0
    return a

if __name__ == '__main__':
    N = int(input())
    v = list(map(int, input().split()))

    ans = solve(N, v)

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define F first 
#define S second 
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ; 
#define pb push_back
#define pf push_front  
#define mp make_pair
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define Rep(i,a,b) for ( int i = a ; i < b ; i++)
#define range(i,s) for ( auto i : s) 
#define sor(v) sort ( v.begin() , v.end()) ;
#define rev(v) reverse(v.begin() , v.end()) ; 
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
typedef long long ll ;
typedef long double ld ; 
using namespace std ;
const int N = 1e5 + 100  ; 
const ll mod = 1e9 + 7  ;


string one , two ;
ll ans[3005][3005]  ;
ll path[3005][3005]  ; 
ll lcs( int n , int m ){
    if ( ans[n][m] != -1){
        return ans[n][m]; 
    }
    if ( n == 0 || m == 0 ){
        return ans[n][m]= 0  ; 
    }
    if ( one[n] == two[m] ){
        path[n][m] = 2 ;   
        return ans[n][m] = 1 + lcs(n-1,m-1) ; 
    }
    else {
        ll ans1 = lcs(n-1,m) , ans2 = lcs(n,m-1); 
        if ( ans1 >= ans2){
            path[n][m] = 1 ; 
        }
        else {
            path[n][m] = -1 ; 
        }
        return ans[n][m] = max ( ans1 , ans2 ) ; 
        
    }
}


void solve( int i , int j ){
    if ( path[i][j] == 2){
        solve(i-1,j-1) ; 
        cout << one[i] ;
    }
    else if ( path[i][j] == 1){
        solve(i-1 , j ) ; 
    }
    else if ( path[i][j] == -1){
        solve ( i , j - 1 ) ; 
    }
}

int _3102_ {
    Gamed    
    cin >> one >> two ;
    one.insert(0," ") ; 
    two.insert(0," ") ; 
    mem ( ans , -1) ; 
    lcs(one.size() - 1 , two.size()- 1  ) ; 
    solve(one.size() -1 ,two.size()- 1 ) ; 
    return 0 ;  

}


Measured memory_bytes: 141696
#include<bits/stdc++.h>
using namespace std;
#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=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    char c; cin >> c;
    if(c - 'a' >= 0) cout << "a" << endl;
    else cout << "A" << endl;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define N 14
using namespace std;
int n;
typedef pair<double,double> P;
typedef pair<P,P> PP;

double X[N],Y[N],X2[N],Y2[N];

double dis(double x,double y,double x2,double y2){
  return sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));
}

map<P,double> mem[1<<N];

double dfs(double x,double y,int bit){
  if(bit==(1<<n)-1) return 0; 
 
  P sta = P(x,y);
  if(mem[bit].count(sta)) return mem[bit][sta];
  
  double res=1e9;
  for(int i=0;i<n;i++){
    if(bit&(1<<i))continue;
    int nbit = bit|1<<i;
    double a = dis(x,y,X[i],Y[i]) + dfs(X2[i],Y2[i],nbit);
    double b = dis(x,y,X2[i],Y2[i]) + dfs(X[i],Y[i],nbit);
    res = min(res,min(a,b));
  }
  return mem[bit][sta]=res;
}


int main(){
  int Case=0;
  while(1){
  cin>>n;
  if(n==0) break;
  double sum =0;
  for(int i=0;i<n;i++) cin>>X[i]>>Y[i]>>X2[i]>>Y2[i],sum+=dis(X[i],Y[i],X2[i],Y2[i]);
  for(int i=0;i<(1<<N);i++) mem[i].clear();
  
  double ans = 1e9;
  for(int i=0;i<n;i++) 
    ans = min(ans, min(dfs(X2[i],Y2[i],1<<i),dfs(X[i],Y[i],1<<i)));
  printf("Case %d: %.10f\n",++Case,ans+sum);
  }  
  return 0;
}

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

constexpr int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> res(N, INF);
    res[0] = 0;
    for(int i=0; i<N; ++i) {
        cin >> p[i];
    }
    for(int i=0; i<N; ++i) {
        if(p[i] != 0) {
            if(p[i+p[i]] == -p[i]) {
                res[i+p[i]] = res[i] = -1;
            }
        }
    }

    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int now = que.front(); que.pop();
        for(int k=1; k<=6; ++k) {
            int tmp_now = now;
            if(tmp_now + k < N && res[tmp_now] + 1 < res[tmp_now + k]) {
                res[tmp_now+k] = res[tmp_now] + 1;
                tmp_now += k;
                if(p[tmp_now] == 0) {
                    que.push(tmp_now);
                } else {
                    int t = res[tmp_now];
                    while(true) {
                        tmp_now += p[tmp_now];
                        if(res[tmp_now] > t) {
                            res[tmp_now] = t;
                            if(p[tmp_now] == 0) {
                                que.push(tmp_now);
                                break;
                            }
                        } else {
                            break;
                        }
                    }
                }
            }
        }
    }
    cout << res[N-1] << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

typedef struct RMQandRAQ {
  i32 *add;
  i32 *min;
  i32 bit;
  i32 size;
} RMQandRAQ;

RMQandRAQ* new_RMQandRAQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) ++k;
  RMQandRAQ *s = (RMQandRAQ *) calloc (1, sizeof (RMQandRAQ));
  s->add = (i32 *) calloc (2 << k, sizeof (i32));
  s->min = (i32 *) calloc (2 << k, sizeof (i32));
  s->bit = k;
  s->size = 1 << k;
  return s;
}

static inline i32 min (i32 a, i32 b) {
  return a < b ? a : b;
}

static inline i32 eval (RMQandRAQ *s, i32 k) {
  return s->add[k] + s->min[k];
}

void propagate (RMQandRAQ *s, i32 x) {
  x += s->size;
  for (i32 bit = s->bit; bit > 0; bit--) {
    i32 k = x >> bit;
    s->add[2 * k] += s->add[k];
    s->add[2 * k + 1] += s->add[k];
    s->add[k] = 0;
    s->min[k] = min (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void save (RMQandRAQ *s, i32 x) {
  for (i32 k = (x + s->size) >> 1; k >= 1; k >>= 1) {
    s->min[k] = min (eval (s, 2 * k), eval (s, 2 * k + 1));
  }
}

void add (RMQandRAQ *s, i32 l, i32 r, i32 v) {
  propagate (s, l);
  propagate (s, r - 1);
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->add[x++] += v;
    if (y & 1) s->add[--y] += v;
  }
  save (s, l);
  save (s, r - 1);
}

i32 find (RMQandRAQ *s, i32 l, i32 r) {
  propagate (s, l);
  propagate (s, r - 1);
  i32 ans = 1000 * 100000 + 1;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = min (ans, eval (s, l++));
    if (r & 1) ans = min (ans, eval (s, --r));
  }
  return ans;
}

void run (void) {
  i32 n, q;
  scanf ("%" SCNi32 "%" SCNi32, &n, &q);
  RMQandRAQ *s = new_RMQandRAQ (n);
  while (q--) {
    i32 t, l, r;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &t, &l, &r);
    r++;
    if (t == 0) {
      i32 v;
      scanf ("%" SCNi32, &v);
      add (s, l, r, v);
    } else {
      printf ("%" PRIi32 "\n", find (s, l, r));
    }
  }
}

int main (void) {
  run ();
  return 0;
}



Measured memory_bytes: 3000
#include<stdio.h>

#define N 100

int main(){
int i,j,n,u,k,v,M[N][N];

scanf("%d",&n);

for(i=0;i<n;i++){
for(j=0;j<n;j++){
M[i][j]=0;
  }
}
 
for(i=0;i<n;i++){
scanf("%d%d",&u,&k);
u--;
for(j=0;j<k;j++){
scanf("%d",&v);
v--;
M[u][v]=1;
}
}

for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(j) printf(" ");
printf("%d",M[i][j]);
}
printf("\n");
}


return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }

int main(){
    ll h,w,k,ans = LINF;
    cin >> h >> w >> k;

    char s[h][w] = {};
    rep(i,0,h) rep(j,0,w) cin >> s[i][j];

    rep(bit,0,(ll)pow(2,h-1)){
        ll index = 0,tempcnt = 0;
        bool flag = false;
        vector<ll> vec;

        rep(i,0,h-1) if((bit >> i) & 1) vec.push_back(i);
        vec.push_back(LINF);
        
        ll whitecnt[sz(vec)][w] = {};
        
        rep(j,0,w){
            index = 0;
            rep(i,0,h){
                whitecnt[index][j] += (s[i][j] - '0');
                flag |= (whitecnt[index][j] > k);

                if(vec[index] <= i) index++;
            }
        }
        if(flag) continue;
        
        rep(j,1,w){
            rep(i,0,sz(vec)){
                if(whitecnt[i][j] + whitecnt[i][j-1] > k){
                    tempcnt++;
                    break;
                }
                else if(i+1 == sz(vec)){
                    rep(l,0,sz(vec)) whitecnt[l][j] += whitecnt[l][j-1];
                }
            }
        }

        ans = min(ans,tempcnt + sz(vec)-1);
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4196
module ABC137

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A (A, B)

    ! arguments for this <subroutine>
    integer(INT16), intent(in) :: A, B

    ! STEP.01
    ! calculate & output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') maxval( [A + B, A - B, A * B] )

    ! STEP.END
    return

  end subroutine task_A

end module ABC137


program main

  ! <module>s to import
  use, non_intrinsic :: ABC137

  ! require all variables to be explicitly declared
  implicit none

  ! variables for this <program>
  integer(INT16) :: A, B

  ! STEP.01
  ! read out the given data
  read(unit=INPUT_UNIT, fmt=*) A, B

  ! STEP.02
  ! calculate & output the answer of this task
  call task_A (A, B)

end program main

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

using namespace std;

int func(int **a, int h, int w, int s, int t)
{
	int c = 0;
	if(t == h || w == s || a[t][s] == -1){
		return 0;
	} else if(a[t][s] == 1){
		return 1;
	}

	return func(a, h, w, s+1, t) + func(a, h, w, s, t+1);
}

int main(int argc, char **argv)
{
	int h, w, **a, n, s, t;
	
	while(1){
		cin >> w >> h;
		if(w == 0){
			break;
		}
		a = (int **)calloc(h, sizeof(int));
		for(int i = 0; i < h; i++){
			a[i] = (int *)calloc(w, sizeof(int));
		}
		a[h-1][w-1] = 1;
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> s >> t;
			
			a[t-1][s-1] = -1;
		}
		
		cout << func(a, h, w, 0, 0) << endl;
		
		for(int i = 0; i < h; i++){
			free(a[i]);
		}
		free(a);
	}
	
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
const int M = (int) 1e2;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int n, k;
int h[N + 1],f[N + 1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n >> k;
    FOR(i, 1, n) cin >> h[i];
    int res = INF;
    FOR(i, 2, n)
    {
        f[i] = INF;
        FOR(j, 1, k)
            if(i - j >= 1)
                f[i] = min(f[i], f[i - j] + abs(h[i] - h[i - j]));
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;

ll get(ll x) {
    
    return x*x*x*x*x;
}
int main()
{
    fastRead;
    ll x;
    cin>>x;
    
    
    for(ll i = -8191; i <=8191; i++ ) {
        
        for(int j = -8191 ; j <= 8191 ; j++ ) {
            
            if(get(i) - get(j) ==x ) {
                cout<<i<<" "<<j<<'\n';
                return 0;
            }
        }
    }
    return 0;
    
}

Measured memory_bytes: 3640
program main;
var
    n, k, sum, mini, i, j, temp : integer;
    a : array[1..1000] of integer;

begin
    readln(n, k);

    for i := 1 to n do 
        read(a[i]);

    sum := 0;
    for i := 1 to k do begin
        mini := i;
        for j := i + 1 to n do 
            if (a[mini] > a[j]) then
                mini := j;
        
        sum := sum + a[mini];
        temp := a[mini];
        a[mini] := a[i];
        a[i] := temp;
    end;
    

    writeln(sum);
end.

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

int n, m;
vector<int> odds, evens;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    
    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        (a&1 ? odds : evens).push_back(a);
    }
    
    if(odds.size() > 2) {
        cout << "Impossible\n"; return 0;
    }
    
    if(odds.size() > 0) cout << odds[0] << " ";
    for(int e : evens) cout << e << " ";
    if(odds.size() > 1) cout << odds[1] << " ";
    cout << "\n";
    
    
    if(n&1) {
        if(m == 1) {
        
            if(n==1) cout << "1\n1";
            else cout << "2\n" << n-1 << " 1";
            
        } else {
        
            cout << m << "\n";
            cout << odds[0] + 1 << " ";
            for(int i = 0; i < m-1; i++) cout << evens[i] - (i == m-2) << " ";
            
        }
        
    } else if(odds.size() == 0){
    
        cout << m + 1 << "\n";
        cout << evens[0] - 1 << " ";
        for(int i = 1; i < m; i++) cout << evens[i] << " ";
        cout << 1 << " ";
        
    } else {
    
        cout << m - (odds[1] == 1) << "\n";
        cout << odds[0] + 1 << " ";
        for(int e: evens) cout << e << " ";
        if(odds[1] != 1) cout << odds[1] - 1 << " ";
    }
    
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int i,h,s,j,r;
  int A[N];
  int tmp,num;
  scanf("%d",&num);
  for(s=0;s<num;s++){
    scanf("%d",&A[s]);
  }
  for(i=1;i<num;i++){
    for(h=0;h<num-1;h++){
      printf("%d ",A[h]);
    }
    printf("%d\n",A[num-1]);
    tmp=A[i];
    j=i;
    while(0<j && tmp<A[j-1]){
      A[j]=A[j-1];
      j--;
    }
    A[j]=tmp;
  }
  for(r=0;r<num-1;r++){
    printf("%d ",A[r]);
  }
  printf("%d\n",A[num-1]);
  return 0;
}



Measured memory_bytes: 2064
def gcd(x,y):
    if x > y:
        x,y = y,x

    while x!= 0:
            y = y % x
            x, y = y, x
    return y

w,h,c = map(int,input().split())
n = w * h / gcd(w,h)**2
print(int(c * n))



Measured memory_bytes: 5604
import heapq
import bisect

n,m = map(int,input().split())
ab = [[0,0,0] for _ in range(n)]

for i in range(n):
    a,b = map(int,input().split())
    ab[i] = [-b,a,b]

ab = sorted(ab, key=lambda x:x[1])

# print(ab)

day = 1
# ans = []
ans = 0
pqueue = []

for i in range(n):
    if ab[i][1] > m:
        break

    if ab[i][1] <= day:
        heapq.heappush(pqueue, ab[i])
    else:
        for j in range(day, ab[i][1]):
            if len(pqueue) > 0:
                ans += heapq.heappop(pqueue)[2]
                # ans += [heapq.heappop(pqueue)[2]] // debug
                day = ab[i][1]
        heapq.heappush(pqueue, ab[i])
    # print(f"i:{i} day:{day} ans:{ans} queue:{pqueue}")

for k in range(day, m+1):
    if len(pqueue) > 0:
        ans += heapq.heappop(pqueue)[2]
        # ans += [heapq.heappop(pqueue)[2]] //debug
        # print(f"## i:{i} day:{k} ans:{ans} queue:{pqueue}")

print(ans)


Measured memory_bytes: 80364
h,w=map(int,input().split())
a=[input() for _ in range(h)]
visited=[[0]*w for _ in range(h)]
from collections import deque
q=deque([])
for i in range(h):
  for j in range(w):
    if a[i][j]=="#":
      q.append((i,j,0))
      visited[i][j]=1
ans=0
while q:
  i,j,count=q.popleft()
  ans=max(ans,count)
  for nxi,nxj in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
    if 0<=nxi<h and 0<=nxj<w and visited[nxi][nxj]==0:
      visited[nxi][nxj]=1
      q.append((nxi,nxj,count+1))
print(ans)


Measured memory_bytes: 186648
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = s[k - 1] - 'A' + 'a';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
static const int inf = 1ll<<60;
typedef pair<int,int> pii;

struct edge{
    int to,cost;
    edge(){}
    edge(int p1,int p2){
        to=p1;
        cost=p2;
    }
};


int N,M,K;
vector<edge> G[3005];
double d[3005];

void dijkstra(int s){
    priority_queue<pii,vector<pii>,greater<pii> > que;
    d[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p=que.top();
        que.pop();
        int v=p.se;
        if(p.fi>d[v])continue;
        for(int i=0;i<G[v].size();++i){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

double ans=0.0;

signed main(){
    cin>>N>>M>>K;
    for(int i=0;i<M;++i){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].PB(edge(b,c));
        G[b].PB(edge(a,c));
    }
    fill(d,d+3000,inf);
    for(int i=0;i<K;++i){
        int shop;
        cin>>shop;
        shop--;
        dijkstra(shop);
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<G[i].size();++j){
            edge e=G[i][j];
            int D=abs(d[i]-d[e.to]);
            ans=max(ans,d[i]+(e.cost-D)/2.0);
        }
    }
    cout<<round(ans)<<endl;
}

Measured memory_bytes: 7080
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
typedef struct{
  int parent;
  int left;
  int right;
}Node;
 
Node Tree[MAX];
int n, Depth[MAX];
 
int getDepth(int);
void print(int);
 
int child[MAX];
 
int main(){
  int i, j;
  int degree,number;
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &number, &degree);
    for ( j = 0; j < degree; j++ ){
      scanf("%d", &child[j]);
 
      Tree[child[j]].parent = number;
       
      if(j == 0)
    Tree[number].left = child[0];
       
      else
    Tree[child[j - 1]].right = child[j];
    }
  }
   
  for ( i = 0; i < n; i++ )
    Depth[i] = getDepth(i);
   
  for ( i = 0; i < n; i++ )
    print(i);
   
  return 0;
}
 
int getDepth(int u){
  int d = 0;
 
  while(Tree[u].parent >= 0){
    u = Tree[u].parent;
    d++;
  }
 
  return d;
}
 
void print(int u){
 
  int i, cnt = 0;
 
  printf("node %d: parent = %d, depth = %d, ",u,Tree[u].parent,Depth[u]);
 
  if(Tree[u].parent == NIL)
    printf("root, [");
 
  else if(Tree[u].left == NIL)
    printf("leaf, [");
 
  else
    printf("internal node, [");
 
  u = Tree[u].left;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 
 
    else
      printf(", %d",u);
   
    u = Tree[u].right;
    cnt++;
 
     
  
 }
 
 
    printf("]\n");
 
}

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

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto && (i) : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
// constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  auto pm = [&](int a, int b) {
    int now = 1;
    rep(i, 0, b) now *= a, now %= mod1;
    return now;
  };
  int ans = pm(10, n) - pm(9, n) - pm(9, n) + pm(8, n);
  ans %= mod1;
  ans = (ans + mod1) % mod1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3604
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int N = r.i();
        int[] V = r.ii(),
              C = r.ii();
        int[] value = new int[N];
        for(int i = 0; i < N; i++){
            value[i] = V[i] - C[i];
        }
        int max = 0;
        for(int v : value){
            if(v > 0){
                max += v;
            }
        }
        print(max);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static int max(int[] ii){
        int max = ii[0];
        for(int i : ii) if(max < i) max = i;
        return max;
    }
    static int min(int[] ii){
        int min = ii[0];
        for(int i : ii) if(i < min) min = i;
        return min;
    }
    static long max(long[] ll){
        long max = ll[0];
        for(long l : ll) if(max < l) max = l;     
        return max;
    }
    static long min(long[] ll){
        long min = ll[0];
        for(long l : ll) if(l < min) min = l;
        return min;
    }
    static double max(double[] dd){
        double max = dd[0];
        for(double d : dd) if(max < d) max = d;
        return max;
    }
    static double min(double[] dd){
        double min = dd[0];
        for(double d : dd) if(d < min) min = d;
        return min;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int j = 0; j < N; j++) ii[j] = i();
            return ii;
        }
        long l() throws IOException{
            return Long.parseLong(readLine());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int j = 0; j < N; j++) ll[j] = i();            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;



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

ll fact(int i) {       
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
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 keta(ll n) {       
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {   
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

#pragma endregion

signed main() {
    int n,m;cin >> n >> m;
    priority_queue<int> pri;
    rep(i, n) {
        int a;cin >> a;
        pri.push(a);
    }
    rep(i, m) {
        int p = pri.top();pri.pop();
        p/=2;
        pri.push(p);
    }
    int sum = 0;
    rep(i, n) {
        int p = pri.top();pri.pop();
        sum+=p;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

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

    vector<int> oks(N+1,true);
    for(int i=0;i<M;++i) {
        int a;
        cin >> a;
        oks[a] = false;
    }

    vector<long long int> dp(N+1);
    dp[0] = 1;
    for(int now=0;now<N;++now) {
        for(int next=now+1;next<=min(N,now+2);++next) {
            if(oks[next]) {
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1408
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, L, K, A, H;
int cold[110];

// position, resttime
int dist[110][110];

signed main() {
    while(cin >> N >> M >> L >> K >> A >> H, N) {
        memset(dist, 0, sizeof(dist));
        memset(cold, 0, sizeof(cold));
        vector<pii> G[110];
        rep(i,0,L) {
            int p; cin >> p;
            cold[p] = 1;
        }
        cold[A] = cold[H] = 1;

        rep(i,0,K) {
            int x, y, t; cin >> x >> y >> t;
            G[x].push_back(pii(y, t));
            G[y].push_back(pii(x, t));
        }

        rep(i,0,110) rep(j,0,110) dist[i][j] = INF;
        dist[A][M] = 0;

        // position, resttime
        queue<pii> q;
        q.push(pii(A, M));
        while(!q.empty()) {
            pii t = q.front(); q.pop();
            int cur = t.first, time = t.second;
            for(auto e : G[cur]) {
                int to = e.first, elapse = e.second;
                int rest = time - elapse;
                if(rest < 0) continue;
                for(int i=0; i<=M; i++) {
                    if(i > 0 && cold[to] == 0) break;
                    if(rest + i > M) break;
                    if(dist[to][rest + i] > dist[cur][time] + elapse + i) {
                        dist[to][rest + i] = dist[cur][time] + elapse + i;
                        q.push(pii(to, rest + i));
                    }
                }
            }
        }

        int mi = INF;
        repq(i,0,M) chmin(mi, dist[H][i]);
        if(mi == INF) cout << "Help!" << endl;
        else cout << mi << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstring>
#include <sstream>
#include <algorithm>

using namespace std;

int d[50][100],dp[50][100];

int main() {
	string str;
	int l=0;
	memset(d,-1,sizeof(d));
	memset(dp,-1,sizeof(d));
	while(cin>>str) {
		replace(str.begin(),str.end(),',',' ');
		stringstream sstr(str);
		int i=0;
		while(sstr>>d[i++][l]);
		l++;
	}
	dp[0][0]=d[0][0];
	for(int i=1;i<l;i++) {
		for(int j=0;j!=50&&d[j][i]!=-1;j++) {
			if((l/2)<i) {
				dp[j][i]=max(dp[j][i-1],j<49?dp[j+1][i-1]:-1);
			}else {
				dp[j][i]=max(dp[j][i-1],j>0?dp[j-1][i-1]:-1);
			}
			dp[j][i]+=d[j][i];
		}
	}
	cout<<dp[0][l-1]<<endl;
}

Measured memory_bytes: 1272
import java.util.Scanner;
public class Main {
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner stdIn=new Scanner (System.in);
		int a=stdIn.nextInt();
		int b =stdIn.nextInt();
		if(a+b>=10)
		System.out.println("error");
		else
			System.out.println(a+b);
			
	}

}


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



int main() {

  int n;
  cin>>n;

  bool flg=false;
  int cnt=0;
  int cnt_max=0;
  for(int i=0;i<n;i++){
    int d1,d2;
    cin>>d1>>d2;

    if(d1==d2){
      flg=true;
    }else{
      flg=false;
    }

    if(flg){
      cnt++;
    }else{
      cnt=0;
    }

    cnt_max=max(cnt,cnt_max);
  }

  if(cnt_max>=3)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3636
///Mn kotr el labawy mb2t4 nawy
#include<bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 1e5 + 5;
const int MOD =  998244353;
pair<int, int> t[N<<2];
string s;
int par[N];
int n, m;
void upd(int node, int s, int e, int idx, int v){
  if(s == e){
    t[node] = pair<int, int>(v, s);
    return;
  }
  int md = (s + e) >> 1;
  if(idx <= md)
  upd(node << 1, s, md,idx, v);
  else
  upd(node<<1|1,md+1,e,idx,v);
  t[node] = min(t[node<<1], t[node<<1|1]);
}
pair<int,int> qry(int node, int s, int e, int l, int r){
  if(r < s || e < l)
    return make_pair(1e9, n);
  if(l <= s && e <= r)
    return t[node];
  int md = (s + e) >> 1;
  return min(qry(node<<1,s,md,l,r), qry(node<<1|1,md+1,e,l,r));
}
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  return 0;
  cin >> n >> m;
  cin >> s;
  upd(1,0,n,n,0);

  for(int i = n - 1; i >= 0; --i){
    if(s[i] == '0'){
    auto x = qry(1,0,n,i+1,i+m);
    par[i] = x.second;
    upd(1, 0, n, i, x.first + 1);
    } else {
    upd(1, 0, n, i, 1e9);
    }
  }
  auto x = qry(1, 0, n, 0, 0);
  if(x.first > n){
    cout << -1 << endl;
    return 0;
  }
//  cout << x.first << endl;
  for(int cur = 0; cur != n; cur = par[cur])cout << par[cur] - cur << ' ';


}


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

int main()
{
	double n,k;
	cin>>n>>k;
	vector<double> p(n);
	for(size_t i = 0; i<n; i++)
	{
		cin>>p[i];
	}
	double max = 0;
	int a = 0;
	for(size_t i = 0; i<k; i++)
	{
		a += p[i];
	}
	max = a;
	for(size_t i = 0; i<n-k; i++)
	{
		a += p[i+k];
		a -= p[i];
		if(a>max)
		{
			max = a;
		}
	}
	cout<<fixed<<setprecision(10)<<(max+k)/2<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class I
{
	public static void Main()
	{
		int N = GetInt();
		double[] p = Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();

		double[,] dp = new double[N + 1, N + 1];
		dp[0, 0] = 1.0;
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < N; j++)
			{
				dp[i + 1, j + 1] += dp[i, j] * p[i];
				dp[i + 1, j] += dp[i, j] * (1.0 - p[i]);
			}
		}

		double ans = 0.0;
		for(int i = N / 2 + 1; i <= N; i++)
			ans += dp[N, i];
		Console.WriteLine($"{ans:F12}");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 83424
N, M = map(int, input().split())
pAc = [list(map(int, input().split())) for _ in range(N)]
pAc.sort()
count = 0
price = 0
for p,c in pAc:
    if count + c >= M:
        print(price+(M-count)*p)
        exit()
    count += c
    price += p*c




Measured memory_bytes: 90048
#include<cstdio>

int search(int S[],int n ,int key){
  int i = 0;
  S[n] = key;
  while(S[i] != key) i++;
  if(i == n) return 0;
  else return 1;
}


int main(){
  int S[10001];
  int num;
  int n,q;
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  int ans=0;
  for(int i=0;i<q;i++) {
    scanf("%d",&num);
    ans += search(S,n,num);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2720
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)
    prev = A[0]
    for i in range(1, N):
        if prev == A[i]:
            print("NO")
            return 0
        else:
            prev = A[i]
    print("YES")

    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 87764
#include<iostream>
using namespace std;
int main(){
  int N, M, C, B[20], A[20][20];
  cin >> N >> M >> C;
  for(int i=0; i<M; i++){
    cin >> B[i];
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cin >> A[i][j];
    }
  }
  int cnt = 0;
  for(int i=0; i<N; i++){
    int ans = 0;
    for(int j=0; j<M; j++){
      ans += A[i][j]*B[j];
    }
    if(ans+C > 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import permutations
import math

N = int(input())
V = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0
for indices in permutations(range(N)):
    for i in range(N - 1):
        j = indices[i]
        k = indices[i + 1]
        ans += math.sqrt((V[j][0] - V[k][0]) ** 2 + (V[j][1] - V[k][1]) ** 2)
ans /= math.factorial(N)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int n,d[100005],head[100005],nxt[200005],v[200005],tot=0;
int dp[100005],rot;
inline void add(int a,int b)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;d[a]++;}
void dfs(int pos,int f)
{int o=0,num=0;
for (int i=head[pos];i;i=nxt[i])
{if (v[i]==f) continue;
num++;dfs(v[i],pos);
if (dp[v[i]]) o++;
dp[pos]+=dp[v[i]];
}
if (o<num-1) dp[pos]+=num-1-o;
}
int main (){
	int i,a,b;
	n=read();
	for (i=1;i<n;i++)
	{a=read()+1;b=read()+1;
	add(a,b);add(b,a);
	}
	for (i=1;i<=n;i++)
	{if (d[i]>=3) {rot=i;break;}
	}
	if (!rot) {puts("1");return 0;}
	dfs(rot,0);
	printf ("%d\n",dp[rot]);
	return 0;
}
	
	

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

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

	for (int i = 0; i < n; i++) {
		int Y, M, D;
		cin >> Y >> M >> D;
		int resdays = 0;

		for (int y = Y; y < 1000; y++) {
			//cout << y << "??´" << endl;
			if (y % 3 == 0) {
				//cout << "3????????°" << endl;
				for (int m = M; m <= 10; m++) {
					for (int d = D; d <= 20; d++)resdays++;
					D = 1;
				}
			}
			else {
				for (int m = M; m <= 10; m++) {
					if (m % 2 == 0 && m!=1) {
						for (int d = D; d < 20; d++)resdays++;
						D = 1;
					}
					else {
						for (int d = D; d <= 20; d++)resdays++;
						D = 1;
					}
				}
			}

			M = 1; D = 1;
		}
		cout << resdays << endl;
	}
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#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 f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/
int lcm(int x,int y){
    return (x*y)/__gcd(x,y);
}

signed main()
{
    showoff;
    int n;
    cin >> n;
    vector<pii>v;
    FOR(i,1,n+1){
        int a,b;
        cin >> a >> b;
        v.pb({b,a});
    }
    sort(v.begin(),v.end());
    int ct = 0;
    FOR(i,0,n){
        if(ct+v[i].se <= v[i].f){
            ct += v[i].se;
            continue;
        }
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
long long a[100100],n;
long long dp[100100];
/*long long DP(long long ind,long long cnt){
    if(ind==0)return cnt;
    if(ind<0)return 1000000000;
    if(dp[ind]!=-1)return dp[ind];
    return dp[ind]=min(DP(ind-1,cnt+abs(a[ind]-a[ind-1])),DP(ind-2,cnt+abs(a[ind]-a[ind-2])));

}*/

int main(){

    cin>>n;
   // memset(dp,-1,sizeof dp);
    for (long long i=0;i<n;i++)cin>>a[i];
    //cout<<DP(n-1,0);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(long long i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));

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

/*
10
1 10 2 10 10 10 2 10 2 2
*/


Measured memory_bytes: 1792
import java.util.Scanner;
 
class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int[][] a=new int[3][3];
   for(int i=0;i<3;i++) {
	   for(int j=0;j<3;j++) {
		   a[i][j]=sc.nextInt();
	   }
   }
   int n=sc.nextInt();
   int[] b=new int[n];
   for(int k=0;k<n;k++){
     b[k]=sc.nextInt();
   for(int x=0;x<3;x++) {
	   for(int y=0;y<3;y++) {
		   if(b[k]==a[x][y]){
             a[x][y]=0;
           }
	   }
   }
   }
   if((a[0][0]==a[0][1]&&a[0][1]==a[0][2])||(a[1][0]==a[1][1]&&a[1][1]==a[1][2])||(a[2][0]==a[2][1]&&a[2][1]==a[2][2])||(a[0][0]==a[1][0]&&a[1][0]==a[2][0])||(a[0][1]==a[1][1]&&a[2][1]==a[1][1])||(a[0][2]==a[1][2]&&a[1][2]==a[2][2])||(a[0][0]==a[1][1]&&a[1][1]==a[2][2])||(a[0][2]==a[1][1]&&a[1][1]==a[2][0])){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
 }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    ll N,W;
    cin >> N >> W;
    ll DP[W+1] = {0};
    FOR(i,0,N){
        ll w,v;
        cin >> w >> v;
        REP(j,0,W){
            if(j == 0 || DP[j]){
                if(j+w <= W){
                    DP[j+w] = max(DP[j]+v,DP[j+w]);
                }
            }
        }
    }
    FOR(i,1,W+1)DP[i] = max(DP[i],DP[i-1]);
    cout << DP[W] << endl;
}

Measured memory_bytes: 1024