akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int X, t;
  cin >> X >> t;
  cout << max(X - t, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq
N,M=[int(s) for s in input().split()]
ls=input().split()
h = []
for e in ls:
  heapq.heappush(h, -int(e))
for i in range(M):
  x=heapq.heappop(h)
  y=(-x)//2
  heapq.heappush(h,-y)
print(-sum(h))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
// #include "../utils.h"

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    // read in integers
    ll n, k;
    cin >> n >> k;
    vector<long double> p(n, 0);
    REP(i, n) cin >> p[i];

    vector<long double> cs(n, 0);
    cs[0] = (long double)(1.0+p[0])/2.0;

    FOR(i, 1, n){
        cs[i] += cs[i-1] + (long double)(1.0+p[i])/2.0;
    }

    long double max = cs[k-1];
    FOR(i, k, n){
        if (cs[i]-cs[i-k] > max) max = cs[i]-cs[i-k];
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(12);
    cout << max << endl;

}

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;
const double eps = 1e-9;

int a, b, c;
LL d, e, f, g;

int main() {
scanf("%d %d %d", &a, &b, &c);
d = c * 1LL - a - b;
e = 4LL * a * b;
f = LL(sqrt(e));
for (g = f + 10;g>=f-10;g--) if (g * g == e) break;
if (d < 0) printf("No\n"); else if (g * g == e) {
	if (g < d) printf("Yes\n"); else printf("No\n");
} else {
	if (e < d * d) printf("Yes\n"); else printf("No\n");
}
return 0;
}

Measured memory_bytes: 256
//+option:-ansi -Wall -Wextra
//+task:hdu 1216
//press <F7> to update the source to mark file.
//press <S-F7> to open the page
#include "vector"
#include "iostream"
#include "algorithm"
#include "numeric"
#include "cmath"
#include "cstdio"
#include "cstdlib"
#include "cstring"
#include "iterator"
using namespace std;
#define inc(over, ...)\
        do\
        {\
                static int over = 0;\
                (over)++;\
                __VA_ARGS__;\
        }while(0)
#define rangedo(i, s, t)\
        i=s; i!=t; i++
#define range(a, b, ...)\
	__typeof(a) _ = a; (_ != (b)) && (bool(__VA_ARGS__)); _++
#define each(a, b, ...)\
	for(range(a, b, true)) __VA_ARGS__
#define exist(a, b, pred)\
	({\
	        bool ok=false;\
		for(range(a,b,!ok))\
			if((pred)) ok = true;\
		ok;\
	})
#define countdown(a, ...)\
	for(int _ = a; _--; ) __VA_ARGS__
/* Good Day */

#define _t(a...) __typeof(a)
#define _s(a...) sizeof(a)

#define x_lambda(args, index, va...)({\
		static _t(args) _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;\
		(void)_1,(void)_2,(void)_3,(void)_4,(void)_5,(void)_6,(void)_7,(void)_8,(void)_9,(void)_10;\
		typedef _t(({va;})) rett;\
		struct __class{\
		static rett __func1 (const _t(args) &_1){return (_t(({va;})))(({va;}));}\
		static rett __func2 (const _t(args) &_1, const _t(args) &_2) {return (_t(({va;})))(({va;}));}\
		__typeof(__func##index)* lambda() const {return __func##index;};\
		}var;\
		var;})
#define $lb (
#define $1(type)  x_lambda $lb type, 1 
#define $2(type)  x_lambda $lb type, 2 
#define $lambda(...) __VA_ARGS__)
#define $cin(type)   istream_iterator<type>(cin)
#define $cin_end(type) istream_iterator<type>()
#define $cout(type) ostream_iterator<type>(cout)
#define $cout_end(type) ostream_iterator<type>()
#define closure static
/* Good Day */
/* Good Day */
long long beven[250+1000];
long long bodd[250*250+10000];
int N;
int M;
long long out[1000];





int main()
{	
	while (scanf("%d",&N), N)
	{
		M = N*(N+1)/2;
		int odd=0, even=0;
		for (int i=0; i<M; i++){
			long long u;
			scanf("%lld", &u);
			if (u & 1LL)  bodd[odd++] = u;
			else beven[even++]=u;
		}
		//a0 * 3, a0 * 5
		//3 * 5
		sort(bodd, bodd+odd);
		sort(beven, beven+even);
		long long k = beven[0];
		long long d = bodd[0];
		long long gcd = __gcd(k, d);
		k/=gcd; d/=gcd;
		long long l = beven[1];
		gcd = __gcd(l, d);
		l/=gcd; d/=gcd;
		long long a0 = (long long)sqrt(k*l/d+1e-6);
		printf("%lld\n", a0);
		for (int i=0; i<even; i++)
		{
			if (i) putchar(' ');
			printf("%lld", beven[i] / a0);
		}
		printf("\n");
		
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int a,b;
  cin>>a>>b;
  if(1<=a&&a<=9&&1<=b&&b<=9){
    cout<<a*b<<endl;
  }else{
    cout<<-1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
#include<stack>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
typedef long  long LL;

const int N = 200005;
const int M = 30;
const int inf = 1<<28;
const double eps = 1e-8;
using namespace std;
typedef pair<int,int> PII;
int n,a[N];
double dp[22][N];

void input(){
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
}

double DP(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=N-5;j++) dp[i][j]=-1.0;
    }
    for(int i=1;i<=N-5;i++){
        dp[1][i]=1.0*abs(a[1]-i)/a[1];
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<=N-5;j++){
            if(dp[i][j]<0) continue;
//            if(i==n){
//                printf("dp[%d][%d]=%.6f\n",i,j,dp[i][j]);
//                continue;
//            }
            for(int k=j;k<=N-5;k+=j){
                double tmp=max(1.0*abs(a[i+1]-k)/a[i+1],dp[i][j]);
//                cout<<i+1<<" "<<k<<" "<<tmp<<endl;
                if(dp[i+1][k]<0) dp[i+1][k]=tmp;
                else dp[i+1][k]=min(dp[i+1][k],tmp);
            }
        }
    }
    double res=1e50;
    for(int i=1;i<=N-5;i++){
        if(dp[n][i]<0) continue;
        res=min(res,dp[n][i]);
    }
    return res;
}

int main(){
    //freopen("in","r",stdin);
    while(scanf("%d",&n)>0){
        input();
        printf("%.10f\n",DP());
    }
    return 0;
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt = 0, f = 1;
    vector<int> ans(n, 0);
    rep(i, s.size()) {
        if(s[i] == 'c')
            continue;
        else if(s[i] == 'a' && cnt < a + b) {
            cnt++;
            ans[i] = 1;

        } else if(s[i] == 'b' && f <= b && cnt < a + b) {
            cnt++;
            f++;
            ans[i] = 1;
        }
    }
    rep(i, n) {
        if(ans[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (h <= a && w <= b) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25428
import java.io.PrintWriter
import java.util.ArrayDeque

data class State(val pos: Int, val cost: Int)

fun main(args: Array<String>) {
    val pw = PrintWriter(System.out)

    val (n, x, y) = readInputLine().split(" ").map { it.toInt() }

    val cost = Array(n) { IntArray(n) { Int.MAX_VALUE } }

    repeat(n) {
        cost[it][it] = 0
    }

    for (i in 0 until n) {
        val queue = ArrayDeque<State>()

        queue.add(State(i, 0))

        while (queue.isNotEmpty()) {
            val state = queue.poll()!!

            if (state.pos > 0 && cost[i][state.pos - 1] > state.cost + 1) {
                cost[i][state.pos - 1] = state.cost + 1
                queue.add(State(state.pos - 1, state.cost + 1))
            }
            if (state.pos < n - 1 && cost[i][state.pos + 1] > state.cost + 1) {
                cost[i][state.pos + 1] = state.cost + 1
                queue.add(State(state.pos + 1, state.cost + 1))
            }
            if (x - 1 == state.pos && cost[i][y - 1] > state.cost + 1) {
                cost[i][y - 1] = state.cost + 1
                queue.add(State(y - 1, state.cost + 1))
            }
            if (y - 1 == state.pos && cost[i][x - 1] > state.cost + 1) {
                cost[i][x - 1] = state.cost + 1
                queue.add(State(x - 1, state.cost + 1))
            }
        }
    }

    val cnt = IntArray(n)

    for (i in 0 until n) {
        for (j in i + 1 until n) {
            cnt[cost[i][j]]++
        }
    }

    for (i in 1 until n) {
        pw.println(cnt[i])
    }

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 94616
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int r,c,R,C;
    cin >> R >> C >> r >> c; 
    int ans=R*C;
    ans -= r*C; ans -= c*(R-r);
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const ld PI = 3.14159265358979;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ld> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    const int LOOP_NUM = 1000000;
    ld ans = 0;
    for (int i = 0; i < LOOP_NUM; i++) {
        bool f = true;
        ld xs = 0, ys = 0;
        ld rad = (2 * PI * i / LOOP_NUM);
        ld xx = cos(rad), yy = sin(rad);

        for (int j = 0; j < n; j++) {
            ld na = xx * x[j] + yy * y[j];
            if (na > 0) {
                xs += x[j];
                ys += y[j];
            }
        }

        if (f) {
            ans = max(ans, xs * xs + ys * ys);
        }
    }
    ans = sqrt(ans);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define inf 1e18
#define ll long long int
using namespace std;
int main(void){
  int n,i,j;
  cin>>n;
  int a[n],b[n],c[n];
  for(i=0;i<n;i++)
  cin>>a[i]>>b[i]>>c[i];
  int dp[n+1][3];
  dp[1][0]=a[0];
  dp[1][1]=b[0];
  dp[1][2]=c[0];
  for(i=2;i<=n;i++){
	  dp[i][0]=a[i-1]+max(dp[i-1][1],dp[i-1][2]);
	  dp[i][1]=b[i-1]+max(dp[i-1][0],dp[i-1][2]);
	  dp[i][2]=c[i-1]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,i,j,k;
    bool flag;
    flag=false;
    cin >> N>>i;

    
    if (N%i==0){
        cout << N/i <<endl;
        
    }
    else{
        cout << N/i+1 <<endl;
    }
    return 0;
    
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i]
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int x,y;cin>>x>>y;
    int f=(y-(2*x))/2;
    int c=(x-f);
    if(c>=0 and f>=0 and f*2==(y-(2*x))){
        cout<<"Yes";
    }else cout<<"No";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sortv(X) sort(X.begin() , X.end()) ; 
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
#define ashar(x , y , z) cout<<setprecision(x)<<fixed<<y ; if (z==1) cout<<"\n" ;
#define ppi pair <pair <int, int > , int > 
#define ordered_set tree<pair <long long  ,long long >, null_type,less<pair <long long ,long long > >, rb_tree_tag,tree_order_statistics_node_update> 
  
long long const inf = 3e18, linf = 2e9, mod = 1e9+7 , inf2 = 1e12;
int const mxn = 5e5 + 10 ;
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int n , m ,  mark[mxn] , now , ans  ; 
vector <int > adj[mxn] ; 
void  dfs(int v){
	now++ ; 
	mark[v] = 1 ; 
	for (auto u : adj[v]){
		if (!mark[u])
			dfs(u) ; 
	}
}
int main(){
	cin>>n>>m;
	for (int i = 1 ; i <= m ; i++){
		int a , b ; 
		cin>>a>>b ; 
		adj[a].push_back(b) ; 
		adj[b].push_back(a) ; 
	} 
	for (int i = 1 ; i <= n ; i++){
		if (!mark[i]){
			now = 0 ; 
			dfs(i) ; 
			ans= max(ans , now) ; 
		}
	}
	cout<<ans ; 
}


Measured memory_bytes: 28596
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(a,b) for(int i=a;i<b;i++)
#define incl(a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define pii pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

int max(int a,int b)
{
    if(a>b)
        return a;
    return b;
}

signed main()
{
    fatafat;
    int n;
    cin>>n;
    int a[n],b[n];
    vector<pii> diff;
    int totala=0,totalb=0;
    excl(0,n)
    {
        cin>>a[i]>>b[i];
        diff.push_back(mp(a[i]+b[i],i));
    }
    sort(diff.begin(),diff.end());
    int i=(int)diff.size()-1;
    while(i>=0)
    {
        totala+=a[diff[i].ss];
        //cout<<totala<<" ";
        i--;
        if(i==-1)
            break;
        totalb+=b[diff[i].ss];
        //cout<<b[diff[i].ss]<<" ";
        i--;
    }
    cout<<totala-totalb;
}

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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int T; cin>>T; for(int i=1; i<=T; ++i)
#define in(a,n)         for(int i=0; i<(n); ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;
    
signed main()
{
    thegamebegins

    const double pi=3.14159265358979323846;
    int i;  cin>>i;
    cout<<fixed<<setprecision(20)<<pi*2*i;
    r0;
}


Measured memory_bytes: 3804
n = int(input())
t = list(map(int, input().split()))
m = int(input())

for _ in range(m):
    p, x = input().split()

    ans = 0
    for i in range(n):
        if i == int(p) - 1:
            ans += int(x)
        else:
            ans += t[i]

    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,p,x;
  int a[100];
  int sum;
  while(1){
    cin>>n>>m>>p;
    if(n==0 && m==0 && p==0) break;
    sum=0;
    for(int i=0;i<100;i++){
      a[i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>x;
      a[i]=x;
      sum+=x;
    }
    if(a[m-1]!=0){
      sum=sum*(100-p);
      cout<<sum/a[m-1]<<endl;
    }
    else cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t n;
    cin>>n;
    string s;
    int t=0;
    if(n==0){
        cout <<0<<endl;
        return 0;
    }
    while(n!=0){
       // cout << n%(-2)<<endl;
       if(n==1){
           s[t]='1';
           t++;
           break;
       }
        if(n%(-2)==-1){
            s[t]='1';
            n = -n/2+1;
        }
        else{
        s[t] = '0'+n%(-2);
        
        n = -n/2;
        }
        //cout<<"s["<<t<<"]="<<s[t]<<endl;
        //cout<<"n="<<n<<endl;
        t++;
    }
    for(int i=t-1;i>=0;i--){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111



int main(void) {
  ll k;
  set<string> ss;
  cin >> s;
  cin >> k;

  FOR(i, 1, 6) {
	FOR(j, 0, s.length() - i + 1) {
	  ss.insert(s.substr(j, i));
	}
  }
  for (auto it : ss) {
	cnt++;
	if (k == cnt) {
	  cout << it << endl;
	  break;
	}
  }

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

    for (int i = a; i < a + k; ++i) {
        if (i <= b)
            cout << i << '\n';
    }
    for (int i = b - k + 1; i <= b; ++i) {
        if (i > 0 && i >= (a + k))
            cout << i << '\n';
    }
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(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 WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 2010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;
II a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        int x;
        cin >> x;
        a[i] = II(x, i);
    }
    sort(a+1, a+n+1);
    FOR(i,1,n) cout << a[i].SE << ' ';
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(snip_i, n) cin >> h.at(snip_i);
	sort(h.begin(), h.end());
	int ans = 1001001001;
	rep(i, n-k+1){
		int mn = h.at(i), mx = h.at(i+k-1);
		ans = min(ans, mx - mn);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<vector<int>> obs(n, vector<int>());
    for (int i = 0; i < m; ++i) {
        int v, u;
        cin >> v >> u;
        obs[v - 1].push_back(u - 1);
        obs[u - 1].push_back(v - 1);
    }
    int cnt = 0;
    for (int v = 0; v < n; ++v) {
        bool good = true;
        for (auto u : obs[v]) {
            if (h[v] <= h[u]) { good = false; };
        }
        if (good) {
            ++cnt;
        }
    }
    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 8712
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

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

  ll ans = 0;
  for(int b=k;b<n;b++){
    int cn = (n+1)/(b+1);
    int mn = (n+1)%(b+1);
    ans += cn*(b-k+1);
    if(mn>=k)
    ans += mn-k;
  }
  if(k==0) ans-=n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = 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;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int Q(int n) {
    if(1 <= n and n <= 6) return n + 1;
    else return n - 5;
}

bool check(vector<int> P) {
    int sum = 0;
    for(int i=1; i<=11; i++) {
        sum += P[i] * Q(i);
    }
    sum %= 11;

    int target = -1;
    if(sum <= 1) target = 0;
    else target = 11 - sum;

    return target == P.front();
}

int main() {
    string s; cin >> s;
    reverse(s.begin(), s.end());
    int idx = find(s.begin(), s.end(), '?') - s.begin();

    vector<int> v(12, -1);
    for(int i=0; i<12; i++) {
        if(s[i] == '?') continue;
        v[i] = s[i] - '0';
    }

    int ans = -1, cnt = 0;
    for(int i=0; i<10; i++) {
        v[idx] = i;
        if(check(v)) {
            // fprintf(stderr, "ok: %d\n", i);
            ans = i, cnt++;
        }
    }
    
    if(cnt == 1) cout << ans << endl;
    else if(cnt > 1) cout << "MULTIPLE" << endl;
    else assert(false);
    return 0;
}



Measured memory_bytes: 3212
<?php
$n=trim(fgets(STDIN));
$i=0;
while($i<$n){
list($a,$b,$c,$d)=explode(" ",trim(fgets(STDIN)));
if($a<$b){
echo "No\n";
}elseif($a%$b>$c){
echo "No\n";
}elseif($d<$b){
echo "No\n";
}elseif($c+1>=$b){
echo "Yes\n";
}else{
if(gcd($d,$b)>=$b-$c){
echo "Yes\n";
}else{
echo "No\n";
}
}
++$i;
}

function gcd($a,$b) {
    return ($a % $b) ? gcd($b,$a % $b) : $b;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x, n;
    cin >> x >> n;
    set<int> st;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;
        st.insert(p);
    }

    int d = 0;
    while (true) {
        if (!st.count(x - d)) {
            cout << x - d << "\n";
            return 0;
        }
        if (!st.count(x + d)) {
            cout << x + d << "\n";
            return 0;
        }
        d++;
    }

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    int N,H[110],Hm,ans;
    cin >> N;

    for(int i=1;i<=N;i++){
        cin >> H[i];
    }

    ans = 0;
    Hm = 0;

    for(int i=1;i<=N;i++){
        if(Hm<=H[i]){
            ans+=1;
        }
        if(H[i]>Hm){
            Hm=H[i];
        }
    }

    cout << ans;

    return 0;

}

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


int main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n,m,sum=0;
	cin>>n>>m;

	vector<int> v(n);

	for(int i=0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}

	int count=0;

	for(int i=0;i<n;i++){

		if(v[i]>=sum/(4*(double)m))
			count++;

	}

	if(count>=m)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
	}


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

int main()
{
    int x, y, z, out;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

import sys

def solve(aOne, aTwo, aThree):
    (x, y, z) = sorted([aOne, aTwo, aThree])
    print((z - y) + (y - x))

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    aOne = int(ws[0])
    aTwo = int(ws[1])
    aThree = int(ws[2])
    return (aOne, aTwo, aThree,)

def main():
    solve(*readQuestion())

main()


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

ll a[200005], b[200005];
void solve(){
    ll n, m, t, cnt = 0;
    cin >> n >> m >> t;
    for(ll i = 1; i <= n; i++) cin >> a[i], a[i] += a[i-1];
    for(ll i = 1; i <= m; i++) cin >> b[i], b[i] += b[i-1];
    ll j = m;
    for(ll i = 0; i <= n; i++){
        ll f = 0;
        while(b[j] + a[i] > t){
            --j;
            if(j < 0) {f = 10; break;}
        }
        if(f) break;
        cnt = max(cnt, i + j);
    }
    cout << cnt << endl;
}


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


Measured memory_bytes: 6788
N,M = [int(i) for i in input().rstrip().split()]
n = 1 if N > 1 else 0
C = [list(range(n,10))] + [list(range(10)) for i in range(N-1)]

for m in range(M):
    s,c = [int(i) for i in input().rstrip().split()]
    s -= 1
    if c in C[s]:
        C[s] = [c]
    else:
        print(-1)
        exit()
    #print(C)
C = [str(min(c)) for c in C]
print("".join(C))


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B)
    cout << C << endl;
  else if (B == C)
    cout << A << endl;
  else
    cout << B << endl;
}


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

public class Main {

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        ArrayList<Integer> numbers = new ArrayList<>();
        int w = input.nextInt();
        int h = input.nextInt();
        int x = input.nextInt();
        int y = input.nextInt();
        int r = input.nextInt();
        String result = "Yes";

        if(x - r < 0 || x+r > w){
            result = "No";
        }
        if(y - r < 0 || y+r > h){
            result = "No";
        }

        System.out.println(result);

    }}


Measured memory_bytes: 26340
use std::io::*;
//use std::cmp::*;


struct UnionFind {
    forest: Vec<usize>
}


impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind { forest: (0..n).collect() }
    }


    fn group(&mut self, mut i: usize) -> usize {
        let mut path = vec![];
        while self.forest[i] != i {
            path.push(i);
            i = self.forest[i]
        }
        for p in path { self.forest[p] = i }
        i
    }


    fn merge(&mut self, edges: Vec<(usize, usize)>) {
        for (l, r) in edges {
            let gl = self.group(l);
            let gr = self.group(r);
            if gl != gr {
                self.forest[gl] = gr
            }
        }
    }


    fn count(&mut self) -> usize {
        let mut cnt = 0;
        for i in 0..self.forest.len() {
            if self.forest[i] == i {
                cnt += 1
            }
        }
        cnt
    }
}



fn solve(buf: String) -> usize {
    let it: Vec<&str> = buf.split_whitespace().collect();
    let it: Vec<usize> = it.iter().map(|x| x.parse::<usize>().unwrap()).collect();
    let n = it[0];
    let m = it[1];
    let it = &it[2..];
    let mut edges = vec![];
    for i in 0..m {
        edges.push((it[3*i]-1, it[3*i+1]-1))
    }
    let mut uf = UnionFind::new(n);
    uf.merge(edges);
    uf.count()
}


fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    println!("{}", solve(buf));
}

Measured memory_bytes: 19696
import java.util.Scanner;
public class Main {
    public static void main(String[] defargs) {
        Scanner scanner = new Scanner(System.in);
        int x,y;
        while(true){
            x = scanner.nextInt();
            y = scanner.nextInt();
            if ( x == 0 && y == 0 ) break;  
            if(x > y){
                System.out.println(y + " " + x);
            }else{
                System.out.println(x + " " + y);
            }
        }
    }
}



Measured memory_bytes: 36180
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	k--;
	for(int i = 0; i < n; i++){
		if(i == k) cout << (char)tolower(s[i]);
		else cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
    int N,hoge;
  	scanf("%d",&N);
  	hoge = 1000 - N%1000;
  	if(hoge == 1000){
      printf("0");
    }else{
      printf("%d",hoge);
    }
}

Measured memory_bytes: 3828
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long m = cin.Long();
			long v = cin.Long();
			long p = cin.Long();
			long[] a = cin.ArrayLong(n);

			Array.Sort(a);

			long[] rui = new long[n];
			rui[0] = a[0];
			for (int i = 1; i < n; i++) {
				rui[i] = a[i] + rui[i - 1];
			}

			int pp = n - (int)p;
			long ans = p - 1;
			for (int i = 0; i <= pp; i++) {
				long self = a[i] + m;
				if (self < a[pp]) {
					continue;
				}

				long pre = i * m;
				long post = ((pp - i) * self) - (rui[pp] - rui[i]);
				
				long all = (long)m * v;
				long remain = all - (p * m);
				if (remain <= pre + post) {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int main(void){
    ll n, k, s;
    cin >> n >> k >> s;
    vector<ll> res(k,s);
    rep(i,n-k) {
        res.push_back(n < s ? 1 : 1e9);
    }
    rep(i,n){
        cout << res[i] << (i < n-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 2232
#include<iostream>
#include<cstdio>
#include<string.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define max_n 1000
#define max_w 1000
using namespace std;

int N,W;
long long dp[max_n+1][max_w+1];
long long dw[max_n+1][max_w+1];
int w[max_n],v[max_n];

long long rec(int i,int j){
	int res;
	if(dp[i][j]!=-1)return dp[i][j];
	if(i==N){
		res=0;
		dw[i][j]=0;
	}else if(j<w[i]){
		res=rec(i+1,j);
		dw[i][j]=dw[i+1][j];
	}else{
		long long r1=rec(i+1,j);
		long long r2=rec(i+1,j-w[i])+v[i];
		if(r1>r2){
			res=r1;
			dw[i][j]=dw[i+1][j];
		}else if(r2>r1){
			res=r2;
			dw[i][j]=dw[i+1][j-w[i]]+w[i];
		}else{
			if(dw[i+1][j]>(dw[i+1][j-w[i]]+w[i])){
				res=r2;
				dw[i][j]=dw[i+1][j-w[i]]+w[i];
			}else{
				res=r1;
				dw[i][j]=dw[i+1][j];
			}
		}
	}
	return dp[i][j]=res;
}

int main(){
	int p=1;
	while(cin>>W,W){
		cin>>N;
		rep(i,N){
			scanf("%d,%d",&v[i],&w[i]);
		}
		memset(dp,-1,sizeof(dp));
		memset(dw,-1,sizeof(dw));
		cout<<"Case "<<p<<":"<<endl;
		cout<<rec(0,W)<<endl;
		cout<<dw[0][W]<<endl;
		p++;
		/*cout<<"value="<<rec(0,W)<<" cost="<<dw[0][W]<<endl;//????????§??????????????????
		cout<<"cost="<<dw[0][W]<<endl;*/
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
    int a, b, c, x, y;
    ll ans = 0;
    cin >> a >> b >> c >> x >> y;
    if(a + b > 2*c) {
        if(x <= y) {
            ans += x * 2 * c;
            if(b <= 2 * c) ans += (y - x) * b;
            else ans += (y - x) * 2 * c;
        }
        else {
            ans += y * 2 * c;
            if(a <= 2 * c) ans += (x - y) * a;
            else ans += (x - y) * 2 * c;
        }
    }
    else {
        ans += a * x + b * y;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>

using namespace std;

int main(void) {

    int n;
    unsigned long long  sum = 0;
    
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0) {
            continue;
        }

        if (i % 5 == 0) {
            continue;
        }
        sum += i;
    }
    cout << sum;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int n; cin >> n;
    if(n == 1) cout << 1 << endl;
    else if(n < 4) cout << 2 << endl;
    else if(n < 8) cout << 4 << endl;
    else if(n < 16) cout << 8 << endl;
    else if(n < 32) cout << 16 << endl;
    else if(n < 64) cout << 32 << endl;
    else if(n < 101) cout << 64 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,a[110];
cin >> n;
for (int i = 0;i < n;i++){
  cin >> a[i];
}
int max = 0;
for (int i = 0;i < n;i++){
  for (int j = 0;j < n;j++){
    if (max < abs(a[i]-a[j]))
      max = abs(a[i]-a[j]);
  }
}
cout << max << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int a, L;
	while(cin >> a >> L, a|L){
		map<int, int> hash;
		int turn = 0;

		hash.insert({a, turn++});
		while(1){
			vi aa;
			while(a > 0){
				aa.push_back(a % 10);
				a /= 10;
			}

			while(aa.size() < L)
				aa.push_back(0);

			RSORT(aa);

			int na = 0, nb = 0;
			for(auto n = aa.begin(); n!= aa.end(); n++){
				na *= 10;
				na += *n;
			}
			for(auto n = aa.rbegin(); n!= aa.rend(); n++){
				nb *= 10;
				nb += *n;
			}
			auto p = hash.insert({na-nb, turn});
//			LOG("na:%d nb:%d\n",na, nb);
//			LOG("tn:%d nn:%d\n",turn, na-nb);
			if(!p.second){
				printf("%d %d %d\n", p.first->second, na-nb, turn - p.first->second);
				break;
			}
			a = na-nb;
			turn ++;
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  set<int> st;

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    if (st.count(n) > 0)
      cnt++;
    else
      st.insert(n);
  }

  int ans = st.size();
  if (cnt % 2 == 1) --ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
static const int N=100;

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

cin >> n;

for(int i=0;i<n;i++){
for(int j=0;j<n;j++)M[i][j]=0;
}

for(int i=0;i<n;i++){
cin >> u >> k;
u--;
for(int j=0;j<k;j++){
cin >> v;
v--;
M[u][v]=1;
}
}

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

return 0;
}

Measured memory_bytes: 3060
#include<stdio.h>
#define MMM 9
int sonyu(int*,int,int);
int cnt=0;
int main() {
  int i, j, N, A[1000000], key, k,cnt2=0;
  scanf("%d", &N);
  for(i = 0; i < N; i++)
    scanf("%d", &A[i]);
  int g[9]={1507,203,110,9,7,5,3,2,1};
  for(i=0;i<MMM;i++){
    if(g[i]<=N){
      sonyu(A,N,g[i]);
      cnt2++;
    }
    
  }
  printf("%d\n",cnt2);
  for(i=MMM-cnt2;i<MMM;i++){
    printf("%d",g[i]);
    if(i == cnt2-1)
      printf("\n");
    else
      printf(" ");
  }
  printf("%d\n",cnt);
  for(i = 0; i < N; i++)
    printf("%d\n", A[i]);




}
int sonyu(int *A,int n, int g){
  int i,j,key;
  for(i=g;i<n;i++){
    j=i-g;
    key=A[i];
    //    printf("i = %d\n",i);
    while(j >= 0 && A[j] > key) {
      A[j + g] = A[j];
      j-=g;
      cnt++;
    }
  A[j + g] = key;
  // for(j = 0; j < n; j++)
  //printf("%d\n", A[j]);

  }
  return 0;
}



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

/*
g++ code.cpp
./a.out
*/

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;cin >> N >> M;
    int A[M],B[M];
    vector<int> V[N];
    REP(i,M){
        cin >> A[i] >> B[i];--A[i];--B[i];
        V[A[i]].pb(B[i]);V[B[i]].pb(A[i]);
    }
    vector<int> num(N);
    iota(num.begin(),num.end(),0);
    int ans = 0;
    do{
        int C = 1;
        while(C <= N-1){
            REP(i,V[num[C-1]].size()){
                if(V[num[C-1]][i] == num[C]){
                    C++;
                    break;
                }
                else if(i == V[num[C-1]].size()-1){C = INF;break;}
            }
        }
        if(C != INF) ans++;
    }while(next_permutation(num.begin() + 1,num.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256