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

#define ll long long

ll arr[10004];

ll min(ll a, ll b) {
    return a < b ? a : b;
}

ll max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ll n,m;
    cin >> n >> m;
    ll res ;
    ll a = n%m;
    if (a < 0) a += m;
    cout << min(a, m-a) << "\n";
}


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

struct pair{
  int num,data,ans;
};

int compdata(const void *p1,const void *p2){
  int n1=((const struct pair *)p1)->data;
  int n2=((const struct pair *)p2)->data;
  return n1-n2;
}

int compnum(const void *p1,const void *p2){
  int n1=((const struct pair *)p1)->num;
  int n2=((const struct pair *)p2)->num;
  return n1-n2;
}


int main(void){
  int N;
  struct pair array[200000];
  int i,j,k;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&array[i].data);
    array[i].num=i;
  }
  qsort(array,N,sizeof(struct pair),compdata);
  for(i=0;i<N/2;i++) array[i].ans=array[N/2].data;
  for(i=N/2;i<N;i++) array[i].ans=array[N/2-1].data;
  qsort(array,N,sizeof(struct pair),compnum);
  for(i=0;i<N;i++) printf("%d\n",array[i].ans);
  return 0;
}



Measured memory_bytes: 6772
#include<stdio.h>
 
#define N 100
#define MAX 500000
 
int main(){
 
  int i, j, l, k, n;
  int p[N+1], m[N+1][N+1];
 
  scanf("%d",&n);
 
  for( i=1; i<=n; i++ ) {
    scanf("%d %d",&p[i-1], &p[i]);
  }
 
  for( i=1; i<=n; i++ ) {
    m[i][i]=0;
  }
 
  for( l=2; l<=n; l++ ) {
    for( i=1; i<=n-l+1; i++ ) {
      j = i+l-1;
      m[i][j] = MAX;
      for( k=i; k<=j-1; k++ ) {
	if( m[i][j] > m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j] ) {
	  m[i][j] = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	}
      }
    }
  }
 
  printf("%d\n",m[1][n]);
 
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	char s1[5],s2[5]; 
	scanf("%s%s",s1,s2);
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
	printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> m(n);
  map<ll,ll> count;
  for(int i = 0;i < n;i++){
    cin >> m[i];
    if(i != 0)m[i] += m[i - 1];
    count[m[i]]++;
  }
  ll res = 0;
  vector<ll> fac(100000);
  for(auto i:count){
    res += i.second * (i.second - 1) / 2;
  }
  res += count[0];
  cout << res << endl;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005
int main()
{
    int i,n,j,k;
    string str;
    cin >> str;
    n=str.size();
    int ans=0;
    i=0;
    while(i<n)
    {
        j=i;
        while(j<n && str[j]==str[i])
            j++;
        k=(j-i);
        if(k&1)
        {
            ans+=(k/2);
            i=j;
        }
        else
        {
            ans+=(k/2);
            k=str[j-1]-'0';
            k^=1;
            str[j-1]='0'+k;
            i=j-1;
        }
    }
    out(ans);
}





Measured memory_bytes: 512
#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(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  double n, m, d;
  cin >> n >> m >> d;
  double ans;
  if(d == 0){
    ans = 1/n;
  }else{
    ans = 2*(n-d)/(n*n);
  }
  ans *= (m-1);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    typedef long long lol;
    #define next NEXT
    template<typename T>
    inline void gg(T &res){
        res=0;T fh=1;char ch=getchar();
        while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
        if(ch=='-')fh=-1,ch=getchar();
        while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
        res*=fh;
    }
    inline int gi(){int x;gg(x);return x;}
    inline lol gl(){lol x;gg(x);return x;}
    const int MAXN=200010;
    const int K=2001;
    const int N=4002;
    const int INF=1e9;
    const int MOD=1e9+7;
    int qpow(int x,int y){
        int res=1;
        while(y){
            if(y&1)res=1ll*res*x%MOD;
            x=1ll*x*x%MOD;
            y>>=1;
        }
        return res;
    }
    int jc[N<<1],nj[N<<1],f[N][N];
    inline int C(int n,int m){return 1ll*jc[n]*nj[m]%MOD*nj[n-m]%MOD;}
    int a[MAXN],b[MAXN];
    int main(){
        jc[0]=1;for(int i=1;i<=8000;i++)jc[i]=1ll*jc[i-1]*i%MOD;
        nj[8000]=qpow(jc[8000],MOD-2);for(int i=8000;i;i--)nj[i-1]=1ll*nj[i]*i%MOD;
        int n=gi(),ans=0;
        for(int i=1;i<=n;i++){
            a[i]=gi(),b[i]=gi();
            f[K-a[i]][K-b[i]]++;
            ans=(ans-C(a[i]+b[i]<<1,a[i]<<1)+MOD)%MOD;
        }
        for(int i=1;i<N;i++)
            for(int j=1;j<N;j++)f[i][j]=(0ll+f[i][j]+f[i-1][j]+f[i][j-1])%MOD;
        for(int i=1;i<=n;i++)ans=(ans+f[a[i]+K][b[i]+K])%MOD;
        printf("%d",1ll*ans*qpow(2,MOD-2)%MOD);
        return 0;
    }

Measured memory_bytes: 64384
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Forr(i, j, k) for(int i = j; i >= k; --i)
#define Travel(i, u) for(int i = beg[u], v = to[i]; i; i = nex[i], v = to[i])
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') p = -1;
	for(; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= p;
}

inline void File() {
#ifndef ONLINE_JUDGE
	freopen("AGC005F.in", "r", stdin);
	freopen("AGC005F.out", "w", stdout);
#endif
}

const int N = 2e5 + 10, maxn = N << 2, mod = 924844033;
int a[maxn], b[maxn], e = 1, beg[N], nex[N << 1], to[N << 1]; 
int rev[maxn], bit, len, siz, invg[maxn], powg[maxn]; 
int fac[N], inv[N], cnt[N], sz[N], u, v, n;

inline int qpow(int a, int b) {
	int res = 1;
	for (; b; a = 1ll * a * a % mod, b >>= 1) 
		if (b & 1) res = 1ll * res * a % mod;
	return res;
}

inline void Init(int n) {
	fac[0] = inv[0] = 1;
	For(i, 1, n) fac[i] = 1ll * i * fac[i - 1] % mod;
	inv[n] = qpow(fac[n], mod - 2);
	Forr(i, n - 1, 0) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}

inline void add(int x, int y) {
	to[++ e] = y, nex[e] = beg[x], beg[x] = e;
	to[++ e] = x, nex[e] = beg[y], beg[y] = e;
}

inline void dfs(int u, int f) {
	sz[u] = 1;
	Travel(i, u) if (v != f) dfs(v, u), sz[u] += sz[v];
	-- cnt[sz[u]], -- cnt[n - sz[u]];
}

inline void NTT(int *a, int flag) {
	For(i, 0, siz - 1) if (rev[i] > i) swap(a[rev[i]], a[i]);
	for (int i = 2; i <= siz; i <<= 1) {
		int wn = flag ? powg[i] : invg[i];
		for (int j = 0; j < siz; j += i) {
			int w = 1;
			for (int k = 0; k < (i >> 1); ++ k, w = 1ll * w * wn % mod) {
				int x = a[j + k], y = 1ll * w * a[j + k + (i >> 1)] % mod;
				a[j + k] = (x + y) % mod, a[j + k + (i >> 1)] = (x - y) % mod; 
			}
		}
	}
	if (!flag) {
		int g = qpow(siz, mod - 2);
		For(i, 0, siz - 1) a[i] = 1ll * g * a[i] % mod;
	}
}

int main() {
	Init(N - 5);
	n = read();
	For(i, 2, n) u = read(), v = read(), add(u, v);
	dfs(1, 0), cnt[n] = n;

	for (siz = 1; siz <= (n << 1); siz <<= 1) ++ bit;
	For(i, 0, siz - 1) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1));

	int g = qpow(5, mod - 2);
	for(int i = 1; i <= siz; i <<= 1) {
		invg[i] = qpow(g, (mod - 1) / i),
		powg[i] = qpow(5, (mod - 1) / i);
	}

	For(i, 0, n) {
		a[i] = 1ll * cnt[i] * fac[i] % mod;
		b[i] = inv[n - i];
	}

	NTT(a, 1), NTT(b, 1);
	For(i, 0, siz) a[i] = 1ll * a[i] * b[i] % mod;
	NTT(a, 0);

	For(i, 1, n) {
		int ans = 1ll * a[n + i] * inv[i] % mod;
		ans = (ans + mod) % mod;
		printf("%d\n", ans);
	}
	return 0;
}


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

//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4"

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)2e5+100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int n, dp[maxn],a[maxn],b[maxn], t[maxn];
vi g[maxn];
void upd(int pos,int val){
  for(;pos<maxn;pos=(pos|(pos+1)))
    t[pos]=max(t[pos],val);
}
int get(int r){
  int res=0;
  for(;r>=0;r=(r&(r+1))-1)
    res=max(res,t[r]);
  return res;
}
main () {
  cin>>n;
  forn(i,1,n) cin>>a[i];
  forn(i,1,n) cin>>b[i];
  forn(i,1,n){
    dp[i]=get(a[i]-1)+b[i];
    upd(a[i],dp[i]);
  }
  cout<<*max_element(dp+1,dp+n+1);
}

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

using namespace std;


long long n, K, val, rest, ans[5555], i, a, b, c;

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

    cin >> K;
    n = 50;
    if(K%n == 0)
    {
        cout << n << '\n';
        for(i=1; i<=50; ++i) cout << (K/n + (n-1)) << ' ';
        return 0;
    }

    val = K / n;
    for(i=1; i<=n; ++i) ans[i] = val + (n-1);

    rest = K % n;
    for(i=1; i<=n-3; ++i) ans[i] -= rest;

    a = rest / 3;
    b = rest / 3;
    c = rest / 3 + rest % 3;
    ans[n-2] += a * n - b - c;
    ans[n-1] += b * n - a - c;
    ans[n] += c * n - a - b;

    cout << n << '\n';
    for(i=1; i<=n; ++i) cout << ans[i] << ' ';

    return 0;
}


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

int main()
{
	int n, m, t = 3000;
	char s[51];
	int w[50], b[50], r[50];

	memset(w, 0, sizeof(w));
	memset(b, 0, sizeof(b));
	memset(r, 0, sizeof(r));

	cin >> n >> m;

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

		for (int j = 0; j < m; j++) {
			if (s[j] == 'W')
				w[i]++;
			else if (s[j] == 'B')
				b[i]++;
			else
				r[i]++;
		}
	}

	for (int i = 1; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int tc = n * m;

			for (int k = 0; k < n; k++) {
				if (k < i)
					tc -= w[k];
				else if (k >= i && k < j)
					tc -= b[k];
				else
					tc -= r[k];
			}

			if (t > tc)
				t = tc;
		}
	}

	cout << t << endl;

	return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;

const int MSIZE  = 100100;

long long dp[MSIZE][3];



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, 0x3f, sizeof dp);
    int n;
    cin >> n;
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int i = 1; i <= n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

Measured memory_bytes: 2560
using System;

class AGC019B
{
	static public void Main(string[] args)
	{
		string A = Console.ReadLine();
		long ans = 1;
		int[] count = new int[26];
		count[A[0]-'a']++;
		for(int i=1; i < A.Length; i++)
		{
			char c = A[i];
			int canReverse = 0;
			for(int j=0; j < 26; j++)
			{
				if(c-'a' != j)
				{
					canReverse+=count[j];
				}
			}
			ans += canReverse;
			count[c-'a']++;
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11616
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int a,ans=1000000000;
    cin>>a;
    vector<int> data(a);
    for(int i=0;i<a;i++) cin>>data[i];
    sort(data.begin(),data.end());
    for(int i=data[0];i<=data[a-1];i++)
    {
        int sum=0;
        for(int k=0;k<a;k++)
        {
            sum+=(data[k]-i)*(data[k]-i);
        }
        ans=min(ans,sum);
    }
    cout<<ans;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int a, b;
    char c;
    while(cin >> a >> c >> b) {
        if (c == '?') break;
        if (c == '+') cout << a + b << endl;
        else if (c == '-') cout << a - b << endl;
        else if (c == '*') cout << a * b << endl;
        else cout << a / b << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
#define pb push_back
#define mp make_pair



const int maxn = 2e5+1;
const int mod = 1e9+7;
ll sum[maxn];

int main()
{
  int n; scanf("%d", &n);
  ll ans = 1;
  int last = -1;
  for (int i = 1; i <= n; ++i)
    {
      int color; scanf("%d", &color);
      if (color == last) continue;
      last = color;
      (ans += sum[color]) %= mod;
      sum[color] = ans;
    }
  printf("%lld\n", ans);
}
	 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int x=s.size();
	int y=t.size();
	int dp[x+1][y+1];
	for(int i=0;i<=x;i++){
		for(int j=0;j<=y;j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	char lcs[dp[x][y]+1];
	lcs[dp[x][y]]='\0';
	int i=x,j=y;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			lcs[dp[x][y]-1]=s[i-1];
			i--,j--,dp[x][y]--;
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}
	cout<<lcs<<endl;
	return 0;
}


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

int main(){
    int n;
    int a[4][13];
    int i,j;
    string t="";
    int t1,t2;
    
    for (i = 0; i < 4; i++){
        for (j = 0; j < 13; j++){
            a[i][j]=0;
        }
    }

    cin >> n;
    for (i = 0; i < n;i++){
        cin >> t >> t2;
        if (t =="S"){
            t1=0;
        }else if(t=="H"){
            t1=1;
        }else if(t=="C"){
            t1=2;
        }else if(t=="D"){
            t1=3;
        }
        a[t1][t2-1]=1;
    }
    
    t="";
    for (i = 0; i < 4; i++){
        for (j = 0; j < 13; j++){
            if (a[i][j]==0){
                if (i ==0){
                    t="S";
                }else if(i==1){
                    t="H";
                }else if(i==2){
                    t="C";
                }else if(i==3){
                    t="D";
                }
                cout << t << " " << j+1 << endl;
                t ="";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include<queue>
using namespace std;
using namespace std;
int total=0;
char ch[1000][1000];
int d[1000][1000];
const int INF=100000000;
int sum=0;
int sx,sy,ex,ey,n,h,w;
int bfs();
int main()
{
    cin>>h>>w>>n;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        cin>>ch[i][j];
        for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
       if(ch[i][j]=='S')
       {
       sx=i;
       sy=j;
       }
       char k='1';
    for(int c=0;c<n;c++)
      for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(ch[i][j]==k)
            {
                k++;
                ex=i;
                ey=j;
                sum=sum+bfs();
                sx=ex;
                sy=ey;
            }


    cout<<sum<<endl;
    return 0;
}
int bfs()
{
    typedef pair<int,int> p;
    queue<p> que;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        d[i][j]=INF;
        int nx,ny, x[4]={-1,0,1,0},y[4]={0,1,0,-1},sum=0;
       que.push(p(sx,sy));
       d[sx][sy]=0;
       while(que.size())
       {
           p q=que.front();
           que.pop();
           if(q.first==ex&&q.second==ey)
                break;
           for(int i=0;i<4;i++)
           {
               nx=q.first+x[i];
               ny=q.second+y[i];
           if(nx>=0&&nx<h&&ny>=0&&ny<w&&ch[nx][ny]!='X'&&d[nx][ny]==INF)
           {
              d[nx][ny]=d[q.first][q.second]+1;
               que.push(p(nx,ny));
           }
           }

       }
       return d[ex][ey];
}



Measured memory_bytes: 7928
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(true){
			double q=sc.nextDouble();
			if(q==-1)break;
			double x=Math.abs(q/2);
			while(Math.abs(x*x*x-q)>=0.000001*q){
				x=x-(x*x*x-q)/(3*x*x);
			}
			ln(String.format("%.6f",x));
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

typedef long long ll;

int dp[3005][3005];

int main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int,int>> p(N);
    for (int i=0;i<N;i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    dp[0][0] = 0;
    int ans = 0;
    for (int i=0;i<N;i++){
        for (int j=0;j<T;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            int nj = j+p[i].first;
            if (nj < T) dp[i+1][nj] = max(dp[i+1][nj], dp[i][j] + p[i].second);
        }
        int now = dp[i][T-1] + p[i].second;
        ans = max(ans, now);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 1; i <= K; i++) {
    ans += l[N - i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

// 1-indexed
template<typename T>
struct BIT{
    int n;
    vector<T> bit;
    BIT(int n_=0):n(n_),bit(n+1){}
    T sum(int i){
        T res=0;
        for(;i>0;i-=(i&-i))res+=bit[i];
        return res;
    }
    void add(int i,T a){
        if(i==0)return;
        for(;i<=n;i+=(i&-i)){bit[i]+=a;}
    }
    int lower_bound(T k){ // k<=sum(res)
        if(k<=0)return 0;
        int res=0,i=1;
        while((i<<1)<=n)i<<=1;
        for(;i;i>>=1){
            if(res+i<=n&&bit[res+i]<k)k-=bit[res+=i];
        }
        return res+1;
    }
};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<pair<int,int>,int>> vv;
    for(int i=0;i<n;i++){
        string s; cin >> s;
        ll p=0;
        int cnt=0;
        bool flag=0;
        for(char c:s){
            if(c=='.'){
                flag=1;
            }
            else{
                if(flag)cnt++;
                p=p*10+(c-'0');
            }
        }
        int t=0,fi=0;
        while(p%2==0){t++;p/=2;}
        while(p%5==0){fi++;p/=5;}
        vv.push_back(make_pair(make_pair(t,fi),cnt));
    }
    // for(int i=0;i<n;i++){
    //     cout << v[i].first.first << " " << v[i].first.second << " " << v[i].second << endl;
    // }
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        v.push_back(make_pair(vv[i].first.first-vv[i].second,vv[i].first.second-vv[i].second));
    }
    sort(v.begin(), v.end());
    ll res=0;
    BIT<int> bit(200);
    int r=n-1;
    int cnt=0;
    for(int i=0;i<n;i++){
        while(r>=0&&v[i].first+v[r].first>=0){
            bit.add(v[r].second+100,1);
            cnt++;
            r--;
        }
        res+=cnt-bit.sum(-v[i].second+99);
    }
    for(int i=0;i<n;i++){
        if(v[i].first>=0&&v[i].second>=0)res--;
    }
    cout << res/2 << endl;
}

Measured memory_bytes: 9296
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	int n;
	int ans1, ans2;
	int diff, diff_min = 1000000000;

	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ans1 = *(a.end() - 1);
	rep(i, n) {
		diff = abs(min(a[i], ans1 - a[i]) - ans1 / 2);
		if (diff < diff_min) {
			diff_min = diff;
			ans2 = a[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a-x) < abs(b-x)) cout << 'A' << endl;
  else cout << 'B' << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int x[32], y[32], r[32], c[32];
char dp[1<<24];

int C(int u, int v){
  return (SQ(x[u]-x[v])+SQ(y[u]-y[v])) >= SQ(r[u]+r[v]);
}

char dfs(int bit){
  char &res = dp[bit];
  if(res >= 0) return res;
  res = 0;
  vector<int>v;
  for(int i=0;i<N;i++){
    if(!((bit>>i)&1)) continue;
    int f = 1;
    for(int j=0;j<i;j++) if((bit>>j)&1) f &= C(i, j);
    if(f) v.push_back(i);
  }

  rep(i, v.size()) for(int j=i+1;j<v.size();j++){
    if(c[v[i]] == c[v[j]]) res = max(res, (char)(dfs(bit ^ (1<<v[i]) ^ (1<<v[j]))+2));
  }
  return res;
}

int main(){
  while(scanf("%d", &N) && N){
    memset(dp, -1, sizeof(dp));
    rep(i,N) scanf("%d%d%d%d", x+i, y+i,r+i,c+i);
    printf("%d\n", dfs((1<<N)-1));
  }
  return 0;
}

Measured memory_bytes: 17596
// abc.64.C - Together

#include <bits/stdc++.h>
using namespace std;

int main( void ) {
    int n;
    cin >> n;
    vector<int> num( n ),val(100005,0);
    for( int i = 0; i < n; i++ ) {
        int num;
        cin >> num;
        if(num!=0){
        val.at( num - 1 )++;
        val.at( num  )++;
        val.at( num + 1 )++;
        }
        else{
            val.at( num )++;
            val.at( num + 1 )++;
        }
    }
    int ans = -5;
    for( int i = 0; i < val.size(); i++ ) {
        ans = max( ans, val.at( i ) );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  int Scnt=0;
  int Tcnt=0;
  int ans=n;
  rep(i,n){
    if(s[i]=='S') Scnt++;
    else if(Scnt>0&&s[i]=='T') Tcnt++;
    if(Tcnt>Scnt){
      ans-=Scnt*2;
      Scnt=0; Tcnt=0;
    }
    if(i==n-1){
      ans-=min(Scnt,Tcnt)*2;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;

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

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

const ll INF = 1LL<<60;
int H, W;
vector<string> fi;

ll solve() {
    vector<vector<ll>> dp(H, vector<ll>(W, INF));
    if (fi[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int dir = 0; dir < 2; dir++) {
                int ni = i + dx[dir], nj = j + dy[dir];
                if (ni >= H || nj >= W) continue;
                int add = 0;
                if (fi[ni][nj] == '#' && fi[i][j] == '.') add = 1;
                chmin(dp[ni][nj], dp[i][j]+add);
            }
        }
    }
    return dp[H-1][W-1];
}

int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; i++) {
        cin >> fi[i];
    }
    cout << solve() << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;
#define INF 0x3f3f3f3f

int main() {
	long long n, k;
	scanf("%lld%lld", &n, &k);
	if (k == 0) {
		printf("%lld\n", n * n);
	}
	else {
		long long sum = (n - k) * (n - k + 1) >> 1;
		for (int b = k + 1; b <= n; ++b) {
			for (int p = k; p <= b - 1; ++p) {//枚举余数
				int t = (n - p) / b;
				if (t == 0) {
					break;
				}
				int li = n - t * b;
				li = min(li, b - 1);
				sum = sum + t * (li - p + 1);
				p = li;
			}
		}
		printf("%lld\n", sum);
		
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,ans=0;
    cin>>n;
    ll a[n],b[n],c[n-1];
    for(i=0;i<n;i++){
    	cin>>a[i];
	}
	for(i=0;i<n;i++){
		cin>>b[i];
	}
	for(i=0;i<n-1;i++){
		cin>>c[i];
	}
	for(i=0;i<n;i++){
		ans+=b[i];
	}
	for(i=0;i<n-1;i++){
		if(a[i]+1==a[i+1]){
			ans+=c[a[i]-1];
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n, k;
  cin >> n >> k;
  
  long long a = n / k;
  
  long long ans = min((n - (a * k)), (((a+1) * k) - n));
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int a,b,c;

cin >> a >> b >> c;

if(a+b >= c) cout << "Yes" << endl;
else            cout << "No" << endl;

return 0;
}

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

int main(){
	long long D, N;
	cin >> D >> N;
	if (N == 100)
		N++;
	if (D == 0){
		cout << N << endl;
	} else {
		cout << (int)(pow(100, D)*N) << endl;
	}
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

long long modpow(long long x,long long n) {
    long long result = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            result = (result * x) % mod;
        }
        x = (x * x) % mod;
        n >>= 1;
    }
 
    return result;
}

#define N 200000
long long x[N+1],y[N+1];

void make_fact_table(){
    int i;
    x[0]=y[0]=1;
    for(i=1;i<=N;i++){
        x[i]=(long long)(x[i-1]*i)%mod;
        y[i]=modpow(x[i],mod-2);
    }
}

long long mod_nCr(int n, int r){
    return x[n]*y[n-r]%mod*y[r]%mod;
}

int p[N+1];

void eratosthenes(){
    int i,j;
    for(i=2;i<N;i++)
        p[i]=1;
    for(i=2;i*i<N;i++){
        if(p[i]){
            for(j=2*i;j<=N;j=j+i){
                p[j]=0;
            }
        }
    }
}

void run(){
    int n,m;
    cin>>n>>m;
    int q;
    eratosthenes();
    make_fact_table();
    vi a;
    int t=m;
    for(int i=2;i<N;i++){
        if(!p[i])continue;
        int x=0;
        while(t&&t%i==0){
            x++;
            t/=i;
        }
        a.pb(x);
    }
    if(t!=1)a.pb(1);
    int ans=1;
    for(int x:a){
        ans=ans*mod_nCr(n+x-1,x)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
 ll res=0;
 for(int d=60;d>=-1;d--){
     if(d!=-1&&!(k&(1ll<<d)))continue;
     ll tmp=0;
     for(int e=60;e>=0;e--){
         ll mask=(1ll<<e);
         ll num=0;
         for(int i=0;i<n;i++)if(a.at(i)&mask)num++;
             if(e>d){
                 if(k&mask)tmp+=mask*(n-num);
                 else tmp+=mask*num;
             }
             else if(e==d)tmp+=mask*num;
             else tmp+=mask*max(num,n-num);
     }
     res=max(res,tmp);
 }
cout<<res<<endl;
}

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


int main(){
    
    int S;
    cin >> S;
    
    int a = S / 3600 ;
    int b = S % 3600 / 60;
    int c = S - a *3600 - b *60;
    
    cout << a << ":" << b << ":" << c <<endl;
    
     return 0;
}





Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=405,M=998244353;
int n,ans,a[N],b[N][N],p[N][N],cnt,fa[N*N/2],size[N*N/2],size2[N*N/2],sum[N*N/2],C[N][N],dp[N*N/2][N],g[N*N/2][N],f[N],fac[N];
signed main(){
	scanf("%lld",&n);
	fac[0]=1;
	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*2%M;
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		for (int j=1;j<=a[i];j++)b[j][i]=1;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (b[i][j]){
				if (!b[i][j-1]){
					p[i][j]=++cnt;
					fa[cnt]=p[i-1][j];
				}
				else p[i][j]=p[i][j-1];
				size[p[i][j]]++;size2[fa[p[i][j]]]++;
			}
	for (int i=1;i<=cnt;i++){
		sum[i]=size[i]-size2[i];
		dp[i][0]=g[i][0]=1;
	}
	for (int i=0;i<=n;i++){
		C[i][0]=1;
		for (int j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%M;
	}
	for (int v=cnt;v;--v){
		memset(f,0,sizeof f);
		for (int i=0;i<=size[v];i++){
			(f[i]+=g[v][i]*(fac[size[v]-i]-1))%=M;
			for (int j=1;j<=i;j++)(f[i-j]+=g[v][i]*C[i][j]%M*fac[size[v]-i])%=M;
		}
		memcpy(g[v],f,sizeof g[v]);
		memset(f,0,sizeof f);
		for (int i=0;i<=size[v];i++){
			(g[v][size[v]-i]+=dp[v][i])%=M;
			for (int j=0;j<=size[v]-i;j++)
				(f[i+j]+=dp[v][i]*C[size[v]-i][j]%M*fac[i])%=M;
		}
		memcpy(dp[v],f,sizeof dp[v]);
		memset(f,0,sizeof f);
		int u=fa[v];
		for (int i=0;i<=sum[u];i++)
			for (int j=0;j<=size[v];j++)(f[i+j]+=dp[u][i]*dp[v][j])%=M;
		sum[u]+=size[v];
		memcpy(dp[u],f,sizeof dp[u]);
		memset(f,0,sizeof f);
		for (int i=0;i<=sum[u];i++)
			for (int j=0;j<=size[v];j++)(f[i+j]+=g[u][i]*g[v][j])%=M;
		memcpy(g[u],f,sizeof g[u]);
	}
	printf("%lld\n",g[1][0]);
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> homework(M);
  int days = 0;
  
  for (int i = 0; i < M; i++) {
    cin >> homework.at(i);
    days += homework.at(i);
  }
  
  if(days > N){
    cout << -1 <<endl;
  }
  else{
    cout << N - days <<endl;
  }
}

Measured memory_bytes: 3652
#include<cstdio>

int main(){
	int w,n,a,b;
	scanf("%d", &w);
	int c[w + 1];
	for(int i = 0; i <= w; i++){
		c[i] = i;
	}
	scanf("%d", &n);
	while(n){
		n--;
		scanf("%d,%d", &a, &b);
		c[0] = c[a];
		c[a] = c[b];
		c[b] = c[0];
	}
	for(int i = 1; i <= w; i++){
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
L=input()
if int(L[0])+int(L[1])+int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])+int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])-int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])+int(L[1])-int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("+",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])+int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])+int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("+",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])-int(L[2])+int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("+",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)
elif int(L[0])-int(L[1])-int(L[2])-int(L[3])==7:
	print(L[0],end="")
	print("-",end="")
	print(L[1],end="")
	print("-",end="")
	print(L[2],end="")
	print("-",end="")
	print(L[3],end="")
	print("=",end="")
	print(7)

Measured memory_bytes: 3320
#include<iostream>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
//string a,b,c;
bool cmp(int a,int b)
{
    return a>b;
}
int gcd(int a,int b)
{
    if(!b)
        return a;
    return gcd(b,a%b);    
}
char a1[5271720];
long long int g;
long double q,t,sum1,sum2;
long long int n,i,j,dp[811][811],a[71720],b[71720],c[71720],d[71720],e[71720],f[71720],sum,sumend,lsbl,m;
int main()
{
    cin>>sum>>n>>m;
    if(sum>1&&n<=m||sum==1&&n==m)
    {
        cout<<(sum-2)*(m-n)+1<<endl;
        return 0;
    }
    cout<<0<<endl; 
    return 0;
}

Measured memory_bytes: 2304
import Data.Bool
main = do
  [n, m] <- map read . words <$> getLine
  a <- map read . words <$> getLine
  putStrLn $ bool "No" "Yes" $
    (>= m) $ length $
    filter (>= sum a `divCeil` (4*m)) a

divCeil a b = div (a+b-1) b

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N, K;
	vector<llong> P;

	cin >> N >> K;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i];

	set<llong> s;
	llong incr = 0, before = -1;
	llong sorted = 0;
	llong ans = N - K + 1;
	for (int i = 0; i < N; ++i) {
		incr = P[i] > before ? incr+1 : 1;
		if (incr == K) ++sorted;
		before = P[i];

		s.insert(P[i]);
		if (incr > K || (i >= K && *(--s.end()) == P[i] && *s.begin() == P[i-K])) {
			--ans;
		}

		if (i >= K) s.erase(P[i-K]);
	}

	cout << ans - max(llong(0), sorted - 1) << endl;

	return 0;
}

Measured memory_bytes: 11136
N,M=map(int,input().split(" "))
class _const:
    def __init__(self):
        self.__INT_MAX = 0x7fffffff

    @property
    def INT_MAX(self):
        return self.__INT_MAX

const=_const()

dp=[ const.INT_MAX for i in range((1<<N)) ]
dp[0]=0
for i in range(M):
    val,T=map(int,input().split(" "))
    r=list( map(int,input().split(" ")) )
    
    now = 0
    for it in r:
        now |= (1<<(it-1))
    for bits in range((1<<N)):
        dp[bits | now] = min(dp[ bits | now ],dp[bits]+val)


if dp[-1]==const.INT_MAX:
    print("-1")
else:
    print(dp[-1])




Measured memory_bytes: 3188
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, readline().split()))
    a = [list(str(readline().rstrip().decode('utf-8'))) for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                a[i][j] = -1
            else:
                a[i][j] = 0
    a[0][0] = 1
    ql = [[0, 0, 0]]
    ql = collections.deque(ql)
    while True:
        if len(ql) != 0:
            cost, x, y = ql.popleft()
            for xv, yv in [[x + 1, y], [x, y + 1]]:
                if 0 <= xv < h and 0 <= yv < w:
                    if a[xv][yv] == 0:
                        ql.append([cost + 1, xv, yv])
                        a[xv][yv] += a[x][y]
                    else:
                        if a[xv][yv] != -1:
                            a[xv][yv] += a[x][y]
                            a[xv][yv] %= mod
        else:
            break
    print(a[h-1][w-1] % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 117468
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    N,M = isRaw()
    Hs = isRaw()
    isGood = [1]*N
    for m in range(M):
        A,B = isRaw()
        if Hs[A-1] >= Hs[B-1]:
            isGood[B-1]=0
        if Hs[A-1]<=Hs[B-1]:
            isGood[A-1]=0
    return sum(isGood)
    
if __name__ == "__main__":
    print(main())


Measured memory_bytes: 82960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try( BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      br.lines()
        .filter(s -> !s.equals("0") && !s.isEmpty())
        .mapToInt(s -> IntStream.range(0,s.length())
          .map(i -> Character.getNumericValue(s.charAt(i)))
          .sum() )
        .forEach(System.out::println);
    }
  }
}


Measured memory_bytes: 30820
#include <iostream>
 
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a;
    cin >> b;
    c=a*b;
    c = c %2;
    if(c == 0)
    cout << "No" << endl;
    else 
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;


void Work(){
    int lens = s.size();
    int lent = t.size();
    string ans("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
               "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"), k = ans;
    for(int i = 0; i < lens; i++){
        if(s[i] == '?' || s[i] == t[0]){
            string tmp = s;
            for(int j = 0; j < i; j++) if(tmp[j] == '?') tmp[j] ='a';
            bool can = false;
            for(int j = 0; j < lent; j++){
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j]) break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can){
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';
                ans = min(ans, tmp);
            }
        }
    }
    if(ans == k) cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
}
int main(){
    cin >> s >> t;
    Work();
}


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

int main(){
    ll a,b,c;
    cin >> a>>b>>c;
    cout << c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};


string X;
int A[4];

int a[]={1,-1};


string hoge(int a){
	if(a==0) return "+";
	else return "-";
}

int main() {
	cin>>X;
	Rep(i,4){
		A[i] = X[i]-'0';
	}
	Rep(i,2){
		Rep(j,2){
			Rep(k,2){
				int num=A[0]+a[i]*A[1]+a[j]*A[2]+a[k]*A[3];
				if(num==7){
					
					cout<<X[0]+hoge(i)+X[1]+hoge(j)+X[2]+hoge(k)+X[3]+"=7"<<endl;
                  return 0;
				}
				
			}
		}
	}
	
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N,X,D;
  cin>>N>>X>>D;
  if(D==0){
    if(X==0){
      cout<<1<<endl;
    }else{
      cout<<N+1<<endl;
    }
    return 0;
  }
  map<ll,vector<P>> vs;
  ll mn=0,mx=0;
  rep(k,N+1){
    ll r=(k*X)%(ll)abs(D);
    if(r<0)r+=D;
    if(D>0){
      vs[r].push_back(P(mn,+1));
      vs[r].push_back(P(mx+D,-1));
    }else{
      vs[r].push_back(P(mx,+1));
      vs[r].push_back(P(mn-D,-1));
    }
    mn+=X+k*D;
    mx+=X+(N-1-k)*D;
  }
  ll res=0;
  for(auto it : vs){
    vector<P> ps=it.se;
    sort(all(ps));
    ll crt=0,pre=-1;
    for(P p : ps){
      //dbg(p.fi); dbg(p.se);
      if(crt>0){
        // dbg(crt); dbg(p.fi); dbg(pre);
        res+=(p.fi-pre)/(ll)abs(D);
      }
      crt+=p.se;
      pre=p.fi;
    }
  }
  cout<<res<<endl;

  return 0;
}


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

using namespace std;

int main(){
	long long a,b,d,r;
	double af,bf,f;
	
	cin>>a>>b;
	
	d=a/b;
	r=a%b;
	af=a;
	bf=b;
	f=af/bf;
	
	cout<<d<<" "<<r<<" ";
	printf("%.5lf",f);
	cout<<endl;
}


Measured memory_bytes: 3240
import java.util.Scanner;

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    System.out.println(c + " " + a + " " + b);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

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

  vector<int> A(N);

  rep(i,N) cin >> A[i];

  ll s=0;

  rep(i,N) s+=A[i];//総投票

  sort(all(A));

  reverse(all(A));

  if(A.at(M-1)*4*M>=s) cout << "Yes" << endl;

  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256