akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    sort(all(a));
    ll ans=0;
    vector<ll> s,b;
    if(n%2==0){
        rep(i,n/2) s.push_back(a[i]);
        rep(i,s.size()){
            if(i<s.size()-1) ans-=s[i]*2;
            else ans-=s[i];
        }
        rep(i,n/2) b.push_back(a[n-1-i]);
        rep(i,b.size()){
            if(i<b.size()-1) ans+=b[i]*2;
            else ans+=b[i];
        }
    }
    else{
        ll res1=0;
        rep(i,n/2) s.push_back(a[i]);
        rep(i,s.size()){
            res1-=s[i]*2;
        }
        rep(i,n/2+1) b.push_back(a[n-1-i]);
        rep(i,b.size()){
            if(i<b.size()-2) res1+=b[i]*2;
            else res1+=b[i];
        }
        s.clear();
        b.clear();
        ll res2=0;
        rep(i,n/2+1) s.push_back(a[i]);
        rep(i,s.size()){
            if(i<s.size()-2) res2-=s[i]*2;
            else res2-=s[i];
        }
        rep(i,n/2) b.push_back(a[n-1-i]);
        rep(i,b.size()){
            res2+=b[i]*2;
        }
        ans=max(res1,res2);
    }

    cout<<ans<<endl;
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

const int max_v=100;
vector<int> graph[max_v],topo_ord;
int state[max_v]; //0:まだ訪れていない、1:途中、2:探索済み

bool topo_dfs(int v){
    if(state[v]==1) return false;
    if(state[v]==2) return true;
    
    state[v]=1;
    for(auto u:graph[v]) if(!topo_dfs(u)) return false;
    state[v]=2;
    
    topo_ord.push_back(v);
    return true;
}

void solve(){
    int v,e;
    cin >> v >> e;
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
    }
    
    rep(i,0,v){
        if(!topo_dfs(i)){
            cout << 1 << endl;
            return;
        }
    }
    cout << 0 << endl;
}

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

Measured memory_bytes: 1228
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,x,ans=0;
    while(1){
        ans=0;
        scanf("%lld%lld",&n,&x);
        if(n==0&&x==0) break;
        // ll a[n];
        // rep(i,0,n){
        //     a[i]=i+1;
        // }
        rep(i,0,n-2){
            rep(j,i+1,n-1){
                if( x - ( (i+1)+(j+1) ) > j+1 && x - ( (i+1)+(j+1) ) <=  n ){
                    // printf("%lld %lld ",i+1,j+1);
                    ans++;
                }else if(x - ( (i+1)+(j+1) ) <= j+1){
                    break;
                }
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double
int main(){
  char c;
  cin >> c;

  c += 1;
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
a,b=gets.split.map(&:to_i)
amin=(a/0.08).ceil
bmin=(b/0.1).ceil
if amin<bmin
  if (bmin*0.08).floor==a
    puts bmin
  else
    puts -1
  end
else
  if (amin*0.1).floor==b
    puts amin
  else
    puts -1
  end
end


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

int main() {
  int n, m;
  cin >> n >> m;
  int result = 0;
  int total = 0;
  vector<int> vec(n);
  
  rep(i, n) {
    int a;
    cin >> a;
    vec[i] = a;
    total += a;
  }
  
  rep(i, n) {
    if(vec[i] >= (total + 4 * m - 1) / (4 * m)) ++result;
  }
  
  if(result >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int
#define fu(a,b) for(int i=a;i<b;i++)
#define fv(a,b) for(int j=a;j<b;j++)
const int nax=1e3+5;
const ll mudu=1e9+7;
using namespace std;

char s[nax][nax];
ll sc[nax][nax];
int main()
{
	sc[0][0]=1;
	int h,w;
	cin>>h>>w;
	fu(0,h)
	{
		cin>>s[i];
	}
	int mx[2]={0,1};
	int my[2]={1,0};
	fu(0,h)
	{
		fv(0,w)
		{
			for(int k=0;k<2;k++)
			{
				int x=i+mx[k];
				int y=j+my[k];
				if(x>=0 && y>=0 && x<h && y<w)
				if(s[x][y]=='.')
				{
					sc[x][y]+=sc[i][j];
					if(sc[x][y]>=mudu)
					sc[x][y]-=mudu;
				}
			}
			
		}
	}
	/*fu(0,h)
	{
		fv(0,w)
		{
			cout<<sc[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	int ans=sc[h-1][w-1]%mudu;
	cout<<ans;
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    
    int n = 100;
    
    while(K>0){
        if(A%n == 0 && B%n == 0){
            --K;
            
        }
        --n;
    }
    
    cout << n+1 << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int yon(int a){

  while(a){
    if(a%10==9) return 1;
     a=a/10;
  }
  return 0;
}

int main(void)
{
  int n,a;

  scanf("%d",&n);

  if(a=yon(n))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> W(N);
  vector<int> T(N+1);
  for(int i=0; i<N; i++){
    cin >> W.at(i);
    T.at(i+1)=T.at(i)+W.at(i);
  }
  int ans=10000000;
  for(int i=0; i<N+1; i++){
    ans=min(ans, abs((T.at(N)-T.at(i))-T.at(i)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App{
  import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(new BufferedOutputStream(System.out))
  val n=in.readLine().toInt
  var map=scala.collection.mutable.HashMap[String,Int]()
  var max=0
  for {i <- (0 until(n))}{
    val s=in.readLine()
    map(s) = if(map.contains(s)) map(s) + 1 else 1
    max=Math.max(map(s),max)
  }
  map.toSeq.collect{case r if r._2 == max => r._1}.sorted.foreach(out.println(_))
  out.flush()
}

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

using namespace std;

#define io freopen("test.txt", "r", stdin);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);


#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double

#define cout(x) cout<<x<<" "
#define coutn(x) cout<<x<<endl
#define newline cout<<endl

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define ar array

#define pii pair<int,int>
#define pll pair<lli,lli>
#define pps pair<pair<int,int>, string>

const int MOD=1000000007;
const lli INF=1e18;
const int MX=100001;
const int N=1000000;


void solve(){

    int n,k;
    cin>>n>>k;

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

    int a[N];

    a[0]=0;

    for(int i=1;i<n;i++){
        a[i]=INT_MAX;
        for(int j=1;j<=k;j++){
            int x=(i-j>=0)?a[i-j]+abs(v[i]-v[i-j]):INT_MAX;
            a[i]=min(a[i], x);
        }
    }

    cout<<a[n-1]<<"\n";

}


int main(){
    fast
    // #ifndef godzqa
    //     io
    // #endif

    lli t=1;
    // cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main() {
	int N, M, K, A;
	cin >> N >> M;
	int total = 0;
	vector<int> vec(M);
	for (int i = 0; i < N; i++) {
		cin >> K;
		for (int j = 0; j < K; j++) {
			cin >> A;
			vec.at(A - 1)++;
		}
	}
	for (int k = 0; k < M; k++) {
		if (vec.at(k) == N) {
			total++;
		}
	}
	cout << total << endl;
}


Measured memory_bytes: 3616
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
#define DB(x) #x<<" "<<x<<" "
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[110][4][2];
//pos,k,== or <

int32_t main() {
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b; cin>>a>>b;
	cout<<(a+b-1)/b<<"\n";
	return 0;
}


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

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top=0;
    char s[100];
    
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    
    printf("%d\n",pop());
    return 0;
}








Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ks ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef pair<int,int>pa;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e6+177;
const ll mod=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
template<class T>inline void read(T &res){
    char c;T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}


int main(){
    ll n;
    scanf("%lld",&n);
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll now=n/i;
        ans=ans+(now*(now+1)/2*i);
    }

    printf("%lld\n",ans);


}


Measured memory_bytes: 3876
local n=io.read("n")
local a={}
local asum=0
for i=1,n do
    a[i]=io.read("n")
    asum=asum+a[i]
end
local b={}
local bsum=0
local minusb={}
local plusa=0
local counter=0
local flag=true
for i=1,n do
    b[i]=io.read("n")
    bsum=bsum+b[i]
    if a[i]>b[i] then
        table.insert(minusb,a[i]-b[i])
        flag=false
    elseif a[i]<b[i] then
        plusa=plusa+b[i]-a[i]
        counter=counter+1
    end
end
table.sort(minusb)

if bsum>asum then
    print(-1)
else
    for i=#minusb,1,-1 do
        if plusa>0 then
            plusa=plusa-minusb[i]
            counter=counter+1
        else
            break
        end
    end
    print(flag and 0 or counter)
end

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

using namespace std;

signed main(){
    int n,m;
    cin>>n>>m;
    vi v(1001);
    rep(i,m){
        int c,d;
        cin>>c>>d;
        Rep(j,c,d){
            v[j]=2;
        }
    }
    int ans=n+1;
    rep(i,1001){
        ans+=v[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int main(){
    int n,a[4][13],b,i,j;
    char x;
    scanf("%d",&n);
	for(i=0;i<4;i++){
    	for(j=0;j<13;j++){
    		a[i][j]=0;
    	}
	}
    for(i=n;i>0;i--){
        scanf("%c", &x);
        scanf("%c %d",&x,&b);
        if(x=='S'){
            a[0][b-1]=1;
        }else if(x=='H'){
            a[1][b-1]=1;
        }else if(x=='C'){
            a[2][b-1]=1;
        }else{
            a[3][b-1]=1;
        }
    }
    for(i=0;i<4;i++){
    	for(j=0;j<13;j++){
    		if(a[i][j]==0){
            	if(i==0){
            		printf("S %d\n",j+1);
         		}else if(i==1){
          			printf("H %d\n",j+1);
       			}else if(i==2){
            		printf("C %d\n",j+1);
        		}else{
            		printf("D %d\n",j+1);
        		}
    		}
    	}
    }
    return 0;
}


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

using namespace std;

using pii = pair<int, int>;
using pll = pair<long long, long long>;

constexpr int INF = (int)1e9+7;
constexpr long long LLINF = (long long)1e18+7;

long long mult(long long a, long long b) {
    return ((a%INF) * (b % INF))%INF;
}

long long binpow(long long n, int pow) {
    if (pow == 0) {
        return 1LL;
    }
    if (pow % 2 == 1) {
        auto res = binpow(n, pow - 1);
        return mult(n, res);
    }
    else {
        auto res = binpow(n, pow / 2);
        return mult(res, res);
    }
}


long long cnt(int k, int x) {
//    cout << "counting k: " << k  << endl;
    long long res = 0;
    for (int i = x; i <= k; i++) {
        long long t1 =  mult((0 + (i - 1)), i);
        t1 = mult(t1, binpow(2, INF - 2));
        long long t2 = mult((k - i + k - 1), i);
        t2 = mult(t2, binpow(2, INF - 2));
//        cout << "t1: " << t1 << ' ' << "t2: " << t2 << endl;
        res += (t2 + INF - t1 + 1) % INF;
//        cout <<"res: " <<  res << endl;
    }
    return res % INF;
}


int main()
{
    int n, k;
    cin >> n >> k;
    cout << cnt(n + 1, k) << endl;
//    for (int i = 1; i <= 6; i++) {
//        cout << cnt(i, k) << endl;
//    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string s;
    cin >> s ;    
    deque<char> que;
    for(char c : s) que.pb(c);
    bool flg = false;
    int q;
    cin >> q;
    rep(i,q){
        int x;
        cin >> x;
        if(x == 1){
            flg = !flg;
        }
        else{
            int y; 
            char c;
            cin >> y >> c;
            if(flg) y = 3- y;
            if(y==1){
                que.push_front(c);
            } 
            else{
                que.push_back(c);
            }
        }
    }
    if(flg) reverse(all(que));
    string ans;
    for(auto c:que) ans += c;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1368
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
const double PI=acos(-1);
struct node{
	int x,y;
	friend bool operator <(node a,node b){
		return a.x==b.x?a.y<b.y:a.x<b.x;
	}
}p[200001];
int n,sx,sy,tx,ty,_x,_y,top=0,tot=0,s[200001];
double ans;
bool ok1=false,ok2=false;
int main(){
	scanf("%d%d%d%d%d",&sx,&sy,&tx,&ty,&n);
	if(sx>tx){
		sx=-sx;
		tx=-tx;
		ok1=true;
	}
	if(sy>ty){
		sy=-sy;
		ty=-ty;
		ok2=true;
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&_x,&_y);
		_x*=ok1?-1:1;
		_y*=ok2?-1:1;
		if(_x>=sx&&_x<=tx&&_y>=sy&&_y<=ty){
			p[++top].x=_x;
			p[top].y=_y;
		}
	}
	sort(p+1,p+top+1);
	for(int i=1;i<=top;i++){
		if(!tot||p[i].y>s[tot]){
			s[++tot]=p[i].y;
		}else{
			int nw=lower_bound(s+1,s+tot+1,p[i].y)-s;
			s[nw]=p[i].y;
		}
	}
	ans=(double)(tx-sx+ty-sy)*100.0-(double)tot*(20.0-PI*5.0)+((tot==min(tx-sx+1,ty-sy+1))?PI*5.0:0);
	printf("%.11lf",ans);
	return 0;
}

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

int N, A;
int main () {
  cin >> N >> A;
  cout << (N*N-A) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){

 Q[tail] = x;
 tail = (tail + 1) % LEN;
}
 

P dequeue(){
  
  P x = Q[head];
  
     head =(head +1) %LEN;
   return x;
}

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

  int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
 head = 1; tail =n +1;

 while(head != tail){
  u = dequeue();
  c = min(q,u.t);
  u.t -=c;
  elaps +=c;

  if(u.t>0) enqueue(u);
  else{
    printf("%s %d\n",u.name,elaps);
   }
  }
   

  return 0;


}




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

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		vector<pair<int, int> > a(n), b(m);
		for(int i=0; i< n; i++){int p; cin >> p; a[i] = make_pair(0, p);}
		for(int i=0; i< m; i++){int p; cin >> p; b[i] = make_pair(0, p);}

		for(int i=0; i< n; i++)for(int j=0; j < m; j++){
			if(__gcd(a[i].second, b[j].second) != 1){a[i].first++; b[j].first++;}
		}
		sort(a.begin(), a.end()); sort(b.begin(), b.end());

		bool ba[500] = {false}, bb[500] = {false};
		int ret = 0;
		for(int i=0; i< n; i++)for(int j=0; j< m; j++){
			if(!ba[i] && !bb[j] && __gcd(a[i].second, b[j].second) != 1){
				ret++;
				ba[i] = true; bb[j] = true;
				break;
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
//freopen("","r",stdin);
//freopen("","w",stdout);
int main(){
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0){
        n /= k;
        cnt++; 
    }
    cout << cnt << '\n';
    return 0;
}

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

int main (){
  int h, w;
  while (true) {
    std::cin >> h >> w;
    if (h == 0 && w == 0){
      return 0;
    }else{
      for (size_t i = 0; i < h; i++) {
        for (size_t j = 0; j < w; j++) {
          if (i == 0 || i == h - 1 || j == 0 || j == w - 1){
            std::cout << "#";
          }else{
            std::cout << ".";
          }
        }
        std::cout << std::endl;
      }
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3056
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Measured memory_bytes: 91852
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
const ll mod=998244353;
ll pow(ll x, ll y,ll m){
    if(y==0) return 1;
    if(y&1) return x*pow(x,y-1,m)%m;
    ll p=pow(x,y/2,m);
    return p*p%m;
}
ll com(ll x,ll y,ll m){
    ll ans=1;
    if(y==0) return 1;
    rp(i,y) {
        ans *= x-i;
        ans %= m;
    }
    rp(i,y){
        ans*=pow(i+1,m-2,m);
        ans %= m;
    }
    return ans;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans=pow(m,n-1,mod);
    ll sub=1;
    rp(i,n-1-k){
        ans -= sub;
        if(ans<0) ans+=mod;
        sub *= n-i-1;
        sub%=mod;
        sub *= pow(i+1,mod-2,mod);
        sub%=mod;
        sub*= m-1;
        sub%=mod;
    }
    ans *= m;
    ans%=mod;
    print(ans);
    return 0;
}

Measured memory_bytes: 3612
n = int(input())
w = [str(input()) for i in range(n)]
a =[]
#print(w[0][-1])
a.append(w[0])
for i in range(n-1):
    #print(w[i+1])
    if w[i][-1]==w[i+1][0]:
        a.append(w[i+1])
        #print(a)
        if i+2!=len(set(a)):
            print('No')
            exit()
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3060
sa = list(input())
sb = list(input())
sc = list(input())

s = {'a': sa, 'b': sb, 'c': sc}
turn = 'a'
while True:
    st = s[turn]
    if len(st) > 0:
        turn = st.pop(0)
    else:
        if turn == 'a':
            print('A')
            exit()
        elif turn == 'b':
            print('B')
            exit()
        elif turn == 'c':
            print('C')
            exit()


Measured memory_bytes: 3060
#include <iostream>
#include <stdint.h>
#include <memory>
#include <algorithm>
#include <vector>

using namespace std;
#define REP(I,SIZE) for(int64_t I = 0;I < (int64_t)SIZE;I++)
#define UP(A,TYPE,N) unique_ptr<TYPE[]> A(new TYPE[N])

using group = pair<int,int>;

struct Tree{
  static int count;
  int val;
  bool valid = true;
  Tree(int i):val(i){count++;}
  unique_ptr<Tree> left = nullptr;  // small
  unique_ptr<Tree> right = nullptr; // large

  static int add(int i,Tree& head){
    // traverse
    if(head.val == i){
      if(head.valid) {count--;head.valid = false;}
      else{count++;head.valid = true;}
      return count;
    }else if(head.val < i){
      if(head.left != nullptr)
	return add(i,*head.left);
      else{
	head.left = unique_ptr<Tree>(new Tree(i));
      }
    }else{
      if(head.right != nullptr)
	return add(i,*head.right);
      else{
	head.right = unique_ptr<Tree>(new Tree(i));
      }
    }
    return count;
  }
};

int Tree::count = 0;

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

  bool isfirst = true;
  unique_ptr<Tree> t = nullptr;


  REP(i,N){
    int tmp;
    cin >> tmp;
    if(isfirst){
      isfirst = false;
      t = unique_ptr<Tree>(new Tree(tmp));
    }else{
      Tree::add(tmp,*t);
    }
  }
  cout << Tree::count << "\n";


  // unique_ptr<group[]> g(new group[N]);
  // UP(a,int,N);
  // vector<int> a;

  // REP(i,N){
  //   int tmp;
  //   cin >> tmp;
  //   a.push_back(tmp);
  // }

  // sort(a.begin(),a.end());

  // int count = 0;
  // int tmpcount = 1;
  // for(int i = 1;i < N;i++){
  //   if(a[i - 1] == a[i]){
  //     tmpcount++;
  //   }else{
  //     if(tmpcount %2 == 1)
  // 	count++;
  //     tmpcount = 1;
  //   }
  // }
  // cout << count << "\n";

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}int n,S,x[MAXN],l,r;ll ans=0,p[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),S=read(),l=1,r=n;
	Rep(i,1,n)x[i]=read(),p[i]=read();
	for(int t=p[1]<p[n]?1:n;l<=r&&x[l]<=S&&S<=x[r];){
		if(p[l]>=p[r])p[l]+=p[r],ans+=(t==r?x[r]-x[l]:0),r--,t=l;
		else p[r]+=p[l],ans+=(t==l?x[r]-x[l]:0),l++,t=r;
	}if(S<=x[l])ans+=x[r]-S;else ans+=S-x[l];
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    LL n;cin >> n;
    vector<LL> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    LL ans = 0;
    sort(ALL(l));
    for (int i = 1; i < n-1; i++) {
        for (int j = 0; j < i; j++) {
            auto p = lower_bound(l.begin()+i+1,l.end(),l[j] + l[i]) - l.begin();
            ans += p - i - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b, c;
	
	scanf("%d", &a);
	scanf("%d", &b);	
	c = a+b;
	
	switch(c){
			case 3:
				printf("3");
				break;
				
			case 4:
				printf("2");
				break;
				
			case 5:
				printf("1");
				break;
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int a[4];
  int sum[2]={};
  int i;
  for(i=0;i<4;i++){
    cin >> a[i];
    sum[0]+=a[i];
  }
  for(i=0;i<4;i++){
    cin >> a[i];
    sum[1]+=a[i];
  }
  if(sum[0]>sum[1]) cout << sum[0] << endl;
  else cout << sum[1] << endl;
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
typedef long long ll;
int main()
{
    fastIO
    int a;
    cin>>a;

    cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int l;
    cin >> l;
    vector<tuple<int, int, int>> ans;
    int n = 20;
    for (int i = 1; i <= n-1; ++i) ans.eb(i, i+1, 0);
    int power = 1;
    for (int i = 1; i <= n-1; ++i) {
        if (power * 2 <= l) {
            ans.eb(i, i+1, power);
            power *= 2;
        } else break;
    }
    int bit = l - power;
    int length = power;
    for (int i = 1; i <= n-1; ++i) {
        if ((bit>>(i-1)) & 1) {
            ans.eb(i, n, length);
            length += pow(2, i-1);
        }
    }
    int m = sz(ans);
    cout << n << " " << m << endl;
    rep(i, m) {
        int a, b, c;
        tie(a, b, c) = ans[i];
        cout << a << " " << b << " " << c << endl;
    }
}

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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
const ll MAX=110000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll a[110000];
main(){
    ll n,k,ans=0;
    cin>>n>>k;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    COMinit();
    rep(i,0,n)ans+=(a[i]*COM(i,k-1)-a[i]*COM(n-i-1,k-1))%mod;
    cout<<ans%mod;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<vector<pair<int, bool>>> t(n);
	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			pair<int, bool> p;
			int x;
			bool y;
			cin >> x >> y;
			x--;
			p = make_pair(x, y);
			t[i].push_back(p);
		}
	}

	int m = 0;

	for (int bit = 0; bit < (1 << n); bit++) {
		int sum = 0;
		bool can = true;
		vector<bool> flag(n, false);
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				flag[i] = true;
			}
		}
		for (int i = 0; i < n; i++) {
			if (flag[i]) {
				int tn = t[i].size();
				//cout << tn << endl;
				for (int j = 0; j < tn; j++) {
					int x = t[i][j].first;
					bool y = t[i][j].second;
					//cout << x << y << endl;
					if (flag[x] != y) {
						can = false;
						break;
					}
				}
			}
			if (!can) break;
		}
		if (can) {
			for (int i = 0; i < n; i++) {
				if (flag[i]) sum++;
			}
			if (sum > m) m = sum;
		}

	}
	cout << m << endl;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
aji = [l+i-1 for i in range(1,n+1)]
reuslt = []
sum_aji = sum(aji)
for x in range(n):
    reuslt.append((abs(aji[x]),sum_aji-aji[x]))
reuslt = sorted(reuslt,key=lambda x:x[0])
print(reuslt[0][1])

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

int N;
string S;
vint lis[10];

signed main(){
    cin>>N>>S;
    rep(i,N){
        lis[S[i]-'0'].pb(i);
    }


    rep(i,10){
        lis[i].pb(N+114);
        lis[i].pb(N+114514);
        lis[i].pb(N+1145141);
    }

    int ans=0;
    rep(i,1000){
        int d=i;
        int pos=-1;
        rep(j,3){
            pos=*upper_bound(all(lis[d%10]),pos);
            d/=10;
        }
        if(pos<N)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,M;
ll n[100000];
bool flag[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,N) n[i]=1;
    flag[0]=1;
    rep(i,0,M){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        if(n[x]>1){
            if(flag[x]) flag[y]=1;
            n[y]++;
            n[x]--;
        }
        else{
            if(flag[x]) flag[y]=1;
            flag[x]=0;
            n[y]++;
            n[x]--;
        }
    }
    ll ans=0;
    rep(i,0,N) if(flag[i]) ans++;
    cout <<ans<<"\n";
}

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

const string YES = "Yes";
const string NO = "No";
int main(){
  long long A, B, C; cin >> A >> B >> C;
  long long D = C - A - B;
  if (D > 0 && 4 * A * B < D * D) cout << YES << endl;
  else cout << NO << endl;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


ll f(ll b, ll n) {
    if (n < b) return n;
    return f(b, n / b) + n % b;
}


int main() {

    ll n, s;
    cin >> n >> s;

    if (s == n) {
        cout << n + 1 << endl;
        return 0;
    }

    ll sq = sqrt(n) + 1;
    for (ll i = 2; i <= sq; i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    };

    for (ll p = sq; p >= 1; p--) {
        ll b = (n - s) / p + 1;
        if (b <= 1) continue;
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

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

int main(void)
{
    int n,d,a,b;
    cin >> n >> d;
    a = n/(d*2+1);
    b = n%(d*2+1);
    if (b==0){
        cout << a << endl;
    }else{
        cout << a+1 << endl;
    }


}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define sec second
#define fori(i, a, b) for(int i = int(a); i < int(b); i++)
#define cc(x)	cout << #x << " = " << x << endl
#define ok		cout << "ok" << endl

typedef pair<int,int> ii;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const long long N = 1e5 + 10; 
long long n, cost[N];
long long dp[N];

long long pog(long long at, long long n){
	if(at >= n) return 0;
	
  	long long &r = dp[at];
  	if(r != -1) return r;

	long long L = pog(at+1, n) + abs(cost[at+1]-cost[at]);
	long long R = pog(at+2, n) + abs(cost[at+2]-cost[at]);

	return r = min(L, R);
}

int main(){
	ios_base::sync_with_stdio(false);

	memset(dp, -1, sizeof dp);
	cin >>n;

	for(int i = 0; i < n; i++)
		cin >>cost[i];
	
	cost[n] = INF;
	cout <<pog(0, n-1) <<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}

	for (int i = N-1; i >= 0; i-=2)
	{
		cout << A.at(i)<<endl;
	}
	for (size_t i = (N%2); i < N; i+=2)
	{
		cout << A.at(i) << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }

vector<pair<long long, long long>> primeFactorize(long long n) {
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; p++) {
        if ( n % p != 0) continue;
        long long num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back({p, num});
    }

    if (n != 1) res.push_back({n, 1});
    return res;
}

const int MAX = 510000;
const int mod = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void combInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    ll n,m; cin>>n>>m;
    vector<pair<ll,ll>> prime=primeFactorize(m);
    ll res=1;
    combInit();
    for(pair<ll,ll> p : prime){
        res*=comb(p.second+n-1, n-1);
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll h,n;
	cin>>h>>n;
	ll s = 0;
	forl(i,n)
	{
		ll x;
		cin>>x;
		s += x;
	}
	if(h-s<=0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

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

const int N = 100500;

int A[N];

int main() {
    int n, L;
    scanf("%d %d", &n, &L);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int pos = -1;
    for (int i = 0; i < n - 1; i++) {
        if (A[i] + A[i + 1] >= L) {
            pos = i;
        }
    }
    if (pos == -1) {
        puts("Impossible");
    } else {
        puts("Possible");
        for (int i = 1; i <= pos; i++)
            printf("%d\n", i);
        for (int i = n - 1; i > pos; i--)
            printf("%d\n", i);
    }
}


Measured memory_bytes: 1152
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
   ANS : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   ANS := B+C-A;
   if ANS < 0 then
      ANS := 0;
   end if;
   Put_Line (Integer'Image (ANS));
end Solve;

Measured memory_bytes: 3676
#include <stdio.h>

int main(void)
{
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if((0 <= x - r) && (x + r <= w) && (0 <= y - r) && (y + r <= h)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int mod=998244353;const int maxn=1e6+5;
int fac[maxn],ifac[maxn],lim,n,m;
inline int qm(int x) {return x>=mod?x-mod:x;}
inline int ksm(int a,int b) {
	int S=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)S=1ll*S*a%mod;return S;
}
inline int C(int n,int m) {
	if(n<0||m<0)return 0;
	return m>n?0:1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
	scanf("%d%d",&n,&m);if(n>m)std::swap(n,m);lim=n+m;
	fac[0]=ifac[0]=1;
	for(re int i=1;i<=lim;++i)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[lim]=ksm(fac[lim],mod-2);
	for(re int i=lim-1;i;--i)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	int ans=1ll*C(n+m,n)*m%mod;int tot=0;
	for(re int i=1;i<=n;i++) 
		tot=qm(tot+1ll*C(i+i,i)*C(m+n-i-i,m-i)%mod);
	printf("%d\n",1ll*qm(ans+1ll*tot*((mod+1)>>1)%mod)*ksm(C(n+m,m),mod-2)%mod);
	return 0;
}


Measured memory_bytes: 8064
# 2 つの正整数 A,B が与えられるので、
# その大小を比較してください。

# 2つの正整数を取得
a = gets.chomp.to_i
b = gets.chomp.to_i

# 比較した結果を格納する変数を宣言
result = String.new

# 大小比較する
if a > b
  result = "GREATER"
elsif a == b
  result = "EQUAL"
else
  result = "LESS"
end

# 結果を出力
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,m;
	cin>>n>>m;
	ll sum = 0;
	while(m--){
		ll a;
		cin>>a;
		sum+=a;

	}
	if((n-sum)>=0)cout<<n-sum<<endl;
	else cout<<-1<<endl;
	
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, T; cin >> n >> T;
	vector<pair<int, int>> vp(n); for (int i = 0; i < n; i++) cin >> vp[i].first >> vp[i].second;
	sort(vp.begin(), vp.end());
	vector dp(2, vector<int>(T + 1));
	int cur = 0;
	int nxt = 1;
	for (int i = 0; i < n; i++) {
		fill(dp[nxt].begin(), dp[nxt].end(), 0);
		for (int j = 0; j <= T; j++) {
			int to = j + vp[i].first;
			chmin(to, T);
			if(j < T) chmax(dp[nxt][to], dp[cur][j] + vp[i].second);
			chmax(dp[nxt][j], dp[cur][j]);
		}
		swap(cur, nxt);
	}
	cout << *max_element(dp[cur].begin(), dp[cur].end()) << endl;
	return 0;
}

Measured memory_bytes: 3696