akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int a[6][6];
int main(){
	int n;
	cin>>n;
	while(n--){
		memset(a,0,sizeof(a));
		for(int y=1;y<=5;y++){
			for(int x=1;x<=5;x++){
				cin>>a[y][x];
				a[y][x] += a[y-1][x]+a[y][x-1]-a[y-1][x-1];
			}
		}
		int ans=0;
		for(int y=1;y<=5;y++){
			for(int x=1;x<=5;x++){
				for(int s=y;s<=5;s++){
					for(int t=x;t<=5;t++){
						int b=a[s][t]-a[y-1][t]-a[s][x-1]+a[y-1][x-1];
						if(b==(s-y+1)*(t-x+1))ans = max(ans,b);
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#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> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  for(int i = 0;i < n;i++)cin >> b[i];
  for(int i = 0;i < n;i++)cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll res = 0;
  /*for(int i = 0;i < n;i++){
    //cout << res << endl;
    int bok = 0;
    bok = *lower_bound(b.begin(),b.end(),a[i] + 1);
    cout << a[i] + 1 << " " << bok << " " << i<< endl;
    for(int j = bok;j < n;i++){
      int citi = 0;
      citi = *lower_bound(c.begin(),c.end(),b[j] + 1);
      if(citi < n){
        res += n - citi + 1; 
      }
    }
  }*/
  vector<ll> cok(n);
  for(int i = n - 1;i >= 0;i--){
    //int now = 0;
    auto now = lower_bound(c.begin(),c.end(),b[i] + 1);
    if(i == n - 1)cok[i] = n - (now - c.begin());
    else cok[i] = cok[i + 1] + n - (now - c.begin());
    //cout << i << " " << cok[i] << endl;
  }
  for(int i = 0;i < n;i++){
    auto bok = lower_bound(b.begin(),b.end(),a[i] + 1);
    //cout << i << " " << bok - b.begin() << " " << cok[bok - b.begin()]<< endl;
    res += cok[bok - b.begin()];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{

    int n;
    cin >> n;
    pair<string, int> p[n];
    map<pair<string, int>, int> mp;
    rep(i, n)
    {

        cin >> p[i].first >> p[i].second;
        p[i].second *= -1;
        mp[p[i]] = i + 1;
    }
    sort(p, p + n);
    rep(i, n) cout << mp[p[i]] << endl;
    return 0;
}


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

using namespace std;

int main() {
    int N;

    cin >> N;

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

    bool flag = true;
    for (int i = N-1; i > 0; i--) {
        if (H[i-1]-1 == H[i]) {
            H[i-1] -= 1;
        } else if (H[i-1] > H[i]) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


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

int main()
{
    int n,x;
    while(cin>>n>>x){
        int ok=0;
        
        if(n==0 && x==0) break;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                for(int k=1;k<=n;k++){
                    if(i+j+k==x && i!=j && i!=j!=k && i<j && i<k && j<k)
                         ok++;
                }
            }
        }
        
        cout<<ok<<"\n";
    }
    
    return 0;
}


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

int main(void) {
	int X, A, B;

	cin >> X >> A >> B;

	if (A >= B)
		cout << "delicious\n";
	else if (B - A <= X)
		cout << "safe\n";
	else
		cout << "dangerous\n";

	return 0;
}


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

using namespace std;
using Int = long long;

signed main(){
    string s;
    cin >> s;
    string first_half = s.substr(0, 2);
    string latter_half = s.substr(2, 2);
    Int first = atoi(first_half.c_str());
    Int latter = atoi(latter_half.c_str());

    bool first_is_mm, latter_is_mm;
    if (first > 0 && first <= 12){
        first_is_mm = true;
    } else {
        first_is_mm = false;
    }
    if (latter > 0 && latter <= 12){
        latter_is_mm = true;
    } else {
        latter_is_mm = false;
    }

    if (first_is_mm && latter_is_mm){
        cout << "AMBIGUOUS" << endl;
    } else if (first_is_mm && !latter_is_mm){
        cout << "MMYY" << endl;
    } else if (!first_is_mm && latter_is_mm){
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin,(x).end()
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define SID set<int>::iterator
#define fastCin ios::sync_with_stdio(false)
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const db pi=acos(-1);
const int mod=1e9+7;
const int maxn=3e6+10;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll quickpow(ll x,ll k) //x^k
{
	ll ans=1;
	while (k)
	{
		if (k&1) ans=ans*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ans;
}
int n;
set<int> st;
bool vis[maxn],more[maxn];
int ans;
int main()
{
	fastCin;
	cin>>n;
	rep(i,1,n)
	{
		int x;cin>>x;
		if (st.count(x)) more[x]=true;
		st.insert(x);
	}
	SID it;
	for (it=st.begin();it!=st.end();it++)
	{
		int w=*it;
		if (vis[w]) continue;
		for (int j=w+w;j<maxn;j+=w) vis[j]=1;
		ans += !more[w] and !vis[w];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15952
//
//  main.cpp
//  zoj2853
//
//  Created by cfhaiteeh on 14/03/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define  LL long long

using namespace  std;
const int maxn=2*123456;
struct he{
    int l,r;
}edge[maxn];
int fa[maxn];

int ai[maxn];
int n;
void init(){
  
    for(int i=1;i<=n;i++)scanf("%d",&ai[i]);
  
   
}
LL ans;
void play(){
    if(ai[1]!=0){
        ans=-1;
        return;
    }
    ans=0;
    for(int i=2;i<=n;i++){
        if(ai[i]<=ai[i-1]){
            ans+=ai[i];
        }
        else{
            if(ai[i]-1==ai[i-1]){
                ans++;
            }
            else{
              //  cout<<i<<endl;
                ans=-1;
                return;
            }
        }
    }
}
void pri(){
    
    printf("%lld\n",ans);
}
int main() {
    // insert code here...
  //  LL t=1000000000000000000
    while(scanf("%d",&n)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan  = new Scanner(System.in);
      String  str   = scan.next();
      int     count = 0;

      for(int i = 0; i < 3; i++){
          for(int j = 0; j < 3; j++){
              char t = str.charAt(i);
              char u = str.charAt(j);
              if(t == u){
                 count++;
                 }
              }
          }
      if(count == 3){
         System.out.println("Yes");
         }
      else{
          System.out.println("No");
          }
   }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	int a[1010];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a, a + N);
	int distance = a[N - 1] - a[0];
	cout << distance << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 105

int n,m;
int ar[N][N],dis[N][N];
int fx[]={0,1};
int fy[]={1,0};

bool valid(int x,int y){
   return x>=1&&x<=n&&y>=1&&y<=m;
}

int bfs(int x,int y){
   for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++) dis[i][j]=INT_MAX;
   }
   deque<pi>q;
   q.push_back({x,y});
   dis[x][y]=ar[x][y];
   while(!q.empty()){
      pi u=q.front();q.pop_front();
      for(int i=0;i<2;i++){
         int nx=u.F+fx[i];
         int ny=u.S+fy[i];
         if(valid(nx,ny)){
            int c=(!ar[u.F][u.S]&&ar[nx][ny])?1:0;
            if(dis[nx][ny]>dis[u.F][u.S]+c){
               dis[nx][ny]=dis[u.F][u.S]+c;
               if(c) q.push_back({nx,ny});
               else q.push_front({nx,ny});
            }
         }
      }
   }
   return dis[n][m];
}


int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin>>n>>m;
   for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
         char c;cin>>c;
         ar[i][j]=(c=='#')?1:0;
      }
   }
   cout<<bfs(1,1)<<endl;
   return 0;
}



Measured memory_bytes: 3720
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#define REPP(i,j,n) for(LL i=j;i<n;++i)
#define REP(i,n) REPP(i,0,n)
#define F first
#define S second

using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;

auto scan = []{static LL a;scanf("%lld",&a);return a;};
#define MAXN 100000

LL A[MAXN];
int main(){
  LL N = scan(), K = scan(), G;
  REP(i, N) A[i] = scan();
  sort(A, A+N);
  G = A[0];
  REP(i, N) G = __gcd(G, A[i]);
  puts(A[0] <= K && K <= A[N - 1] && (K - A[0])% G ==0?"POSSIBLE":"IMPOSSIBLE");
}


Measured memory_bytes: 1024
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll p[51];
ll t[51];

int f(int outsideLevel, ll remains){
  int includedLevel = outsideLevel;
  while(1){
    if(t[includedLevel] + outsideLevel - includedLevel <= remains){
      return includedLevel;
    }
    includedLevel--;
    if(!includedLevel) return 0;
  }
}

int main(){
  int N;
  ll X;
  cin >> N >> X;
  p[0] = 1;
  t[0] = 1;
  rep(i, 50){
    p[i + 1] = 2 * p[i] + 1;
    t[i + 1] = 2 * t[i] + 3;
  }

  ll ans = 0;
  int outsideLevel = N;
  ll remains = X;
  while(remains){
    int includedLevel = f(outsideLevel, remains);
    if(includedLevel == 0){
      if(remains - outsideLevel > 0) ans += remains - outsideLevel;
      break;
    }
    remains -= t[includedLevel] + outsideLevel - includedLevel;
    ans += p[includedLevel];
    if(!remains) break;
    ans++;
    remains--;
    outsideLevel = includedLevel;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);

    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int k=lower_bound(a,a+n,a[i]+a[j])-a;
            //cout<<"k= "<<k<<endl;
            ans+=k-j-1;
        }
    }
    cout<<ans<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int dist[MAXN][MAXN];
char s[MAXN];
const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};
int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	queue<int> qi, qj;
	for(int i = 1; i <= h; i += 1){
		scanf("%s", s + 1);
		for(int j = 1; j <= w; j += 1){
			if(s[j] == '#'){
				dist[i][j] = 0;
				qi.push(i);
				qj.push(j);
			} else {
				dist[i][j] = -1;
			}
		}
	}
	while(!qi.empty()){
		int i = qi.front();
		qi.pop();
		int j = qj.front();
		qj.pop();
		for(int d = 0; d < 4; d += 1){
			int ni = i + di[d];
			int nj = j + dj[d];
			if(dist[ni][nj] == -1){
				dist[ni][nj] = 1 + dist[i][j];
				qi.push(ni);
				qj.push(nj);
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= h; i += 1){
		for(int j = 1; j <= w; j += 1){
			ans = max(ans, dist[i][j]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 12416
import           Control.Monad                  ( forM_ )

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Integer]
    let factorial 0 _ = 1
        factorial _ 0 = 1
        factorial i j = i * factorial (i - 1) (j - 1)
    let comb n m = factorial n l `div` factorial l l where l = min m (n - m)
    let solve n k i = b * r `mod` 1000000007
          where
            b = comb (k - 1) (i - 1)
            r = comb (n - k + 1) i

    forM_ ([1 .. k] :: [Integer])
        $ \i -> print $ if n - k + 1 < i then 0 else solve n k i




Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n, k; cin >> n >> k;
    ll ans = n%k;
    chmin(ans, k-ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int a[N],d,x,i,n,pp;
int gcd(int a,int b)
{
	if (!b) return a;
	return gcd(b,a%b);
}
int dfs()
{
	x=0;
	pp=0;
	fo(i,1,n) if (a[i]%2==0) x++;
	else 
	{
		if (a[i]==1) pp=1;
		a[i]--;
	}
	if (x%2) return 0;
	if (x==n-1&&!pp)
	{
		d=a[1];
		fo(i,2,n) d=gcd(d,a[i]);
		fo(i,1,n) a[i]/=d;
		return dfs()^1;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n) 
		scanf("%d",a+i);
	if (dfs()==0) printf("First");else
	printf("Second");
}

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

using namespace std;

struct data{
    int t,n;
};

data d[100005];
int n;

bool cmp(const data &p1, const data &p2){
    return p1.t<p2.t;
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>d[i].t;
        d[i].n=i;
    }
    stable_sort(d+1,d+n+1,cmp);
    for(int i=1;i<=n;i++){
        cout<<d[i].n<<' ';
    }
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int l = n - 1, r = 0;
  for (int i = 0; i < n - 1; i++) {
    if (abs(a[i] * 2 - a[l]) < abs(a[r] * 2 - a[l])) {
      r = i;
    }
  }
  cout << a[l] << " " << a[r] << endl;

  return 0;
} 

Measured memory_bytes: 1024
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int k,n;cin>>k>>n;
	int a[n];
	fo0(i,n){
		cin>>a[i];
	}
	if(n==1){
		cout<<0;
		return;
	}
	vi v;
	fo0(i,n-1){
		int diff=abs(a[i]-a[i+1]);
		v.push_back(diff);
	}
	v.push_back(k-a[n-1]+a[0]);
	sort(rall(v));
	// for(auto i: v){
	// 	cout<<i<<" ";
	// }
	cout<<k-v[0];
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MN 200005
using namespace std;
int mp[MN],a[MN],sm[MN];
int tot,n,m;

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

int main()
{
	register int i,j,x,y;
	n=read(); m=read();
	for (i=1;i<=n;++i) ++mp[a[i]=read()];
	for (i=1;i<=n;++i)
		for (j=0;j<i&&j<mp[i];++j)
			if (sm[i-j]++==0) ++tot;
	while (m--)
	{
		x=read(); y=read();
		--mp[a[x]];
		if (mp[a[x]]<a[x])
			if (--sm[a[x]-mp[a[x]]]==0) --tot;
		if (mp[y]<y)
			if (sm[y-mp[y]]++==0) ++tot;
		++mp[y]; a[x]=y;
		printf("%d\n",n-tot);
	}
}

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

/*
日本でよく使われる紙幣は、10000円札、5000円札、1000円札です。
以下、「お札」とはこれらのみを指します。
青橋くんが言うには、彼が祖父から受け取ったお年玉袋にはお札がN枚入っていて、合計でY円だったそうですが、嘘かもしれません。
このような状況がありうるか判定し、ありうる場合はお年玉袋の中身の候補を一つ見つけてください。
なお、彼の祖父は十分裕福であり、お年玉袋は十分大きかったものとします。
*/

// 10000x + 5000y + 1000z = Y;
// x + y + z = N;



int main() {
  int N, Y, count = 0;
  cin >> N >> Y;
  Y = Y / 1000;

  for(int x = 0; x <= N; x++) {
    for(int y = 0; y <= N; y++) {
      if(Y - (10 * x + 5 * y) < 0) { break; }
      if ((Y - (10 * x + 5 * y)) + x + y == N) {
        cout << x << ' ';
        cout << y << ' ';
        cout << Y - (10 * x + 5 * y) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.{ StdIn => in}

object Main extends App {
  val Array(sx, sy, tx, ty) = in.readLine.split(" ").map(_.toInt)

  val ans = {
    val c1x = tx - sx
    val c1y = ty - sy
    val c2x = c1x + 1
    val c2y = c1y + 1

    val res = StringBuilder.newBuilder

    (1 to c1x).foreach(_ => res.append('R'))
    (1 to c1y).foreach(_ => res.append('U'))
    (1 to c1x).foreach(_ => res.append('L'))
    (1 to c1y).foreach(_ => res.append('D'))
    res.append('D')
    (1 to c2x).foreach(_ => res.append('R'))
    (1 to c2y).foreach(_ => res.append('U'))
    res.append('L')
    res.append('U')
    (1 to c2x).foreach(_ => res.append('L'))
    (1 to c2y).foreach(_ => res.append('D'))
    res.append('R')
    res.toString
  }

  println(ans)
}

Measured memory_bytes: 27192
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
ans = [0] * (n+1)
for i in range(1,n+1):
    for j in range(1,n+1):
        if i*j > n: break
        ans[i*j] += 1
res = 0
for i in range(1,n+1):
    res += i*ans[i]
print(res)

Measured memory_bytes: 156800
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
using namespace std;
int main(){
  int n;
  cin >> n;
  cout << "ABC" << setprecision(3) << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    for(int i=0;i<3;i++) scanf("%d",&a[i]);
    sort(a,a+3);
    int ans=0;
    while(1)
    {
        if(a[0]==a[1]&&a[1]==a[2]) break;
        if(a[1]==a[2])
        {
            a[0]+=2;
        }
        else
        {
            a[0]++;
            a[1]++;
        }
        ans++;
        sort(a,a+3);
        if(a[0]==a[1]&&a[1]==a[2]) break;
    }
    printf("%d\n",ans);
    return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int A, B, C;
  cin >> A >> B >> C;

  set<TP> st;
  st.insert(TP(A, B, C));
  int cont = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    int a = (B + C) / 2;
    int b = (A + C) / 2;
    int c = (A + B) / 2;
    A = a;
    B = b;
    C = c;

    cont++;
    if (EXIST(st, TP(A, B, C))) {
      cout << -1 << endl;
      return 0;
    }
    st.insert(TP(A, B, C));
  }

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 256
A = input()
B = input()
C = input()

def solve(A, B, C):
    target = A[0]
    a_cnt = 1
    b_cnt = 0
    c_cnt = 0
    
    while True:
        if target == "a":
            if len(A) > a_cnt:
                target = A[a_cnt]
                a_cnt += 1
            else:
                return "A"

        elif target == "b":
            if len(B) > b_cnt:
                target = B[b_cnt]
                b_cnt += 1
            else:
                return "B"
        else:
            if len(C) > c_cnt:
                target = C[c_cnt]
                c_cnt += 1
            else:
                return "C"
print(solve(A, B, C))

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> line(H+2);
    for (int i=1; i<=H; i++){
        cin >> line[i];
        line[i] = "#" + line[i] + "#";
    }
    for (int i=0; i<W+2; i++){
        line[0] += "#";
        line[H+1] += "#";
    }
    for (int i=0; i<=H+1; i++){
        cout << line[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<tuple>
#include<string>
#include<algorithm>

int main(){
    
    size_t n;
    std::vector<std::tuple<std::string, int, size_t>> v;

    std::cin >> n;

    for(size_t i = 0; i < n; i++){
        std::string s;
        int p;
        std::cin >> s >> p;

        v.emplace_back(std::make_tuple(s, -p, i));
    }

    std::sort(v.begin(), v.end());

    for(const auto& e : v){
        std::cout << std::get<2>(e) + 1 << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  int result = 0;
  for(int a = 1;a < 10;a++){
    for(int b = 1;b < 10;b++){
      if(a*b==N)result = 1;
    }
  }
    if(result == 1)cout << "Yes" << endl;
  if(result == 0)cout << "No" << endl;
}

Measured memory_bytes: 256
(let* ((n (read))
       (ab (sort (loop :for i :from 1 :to n
                       :for a := (read)
                       :for b := (read)
                       :collect (cons a b))
                 (lambda (x y) (< (cdr x) (cdr y))))))
  (loop :named main 
        :with acc := 0
        :for x :in ab
        :for a := (car x)
        :for b := (cdr x)
        :do (incf acc a)
        :if (> acc b)
        :do (progn
              (format t "No~%")
              (return-from main))
        :finally (format t "Yes~%")))


Measured memory_bytes: 82224
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int query(int x) {
	cout << x << "\n";
	cout.flush();

	string s;
	cin >> s;
	if (s == "Male") return 1;
	if (s == "Female") return 2;
	return 0;
}

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

	int n, l, r, m, i, j, k;
	cin >> n;
	vector<int> a(n + 1, -1);

	a[0] = query(0);
	a[n] = a[0];

	if (a[0] == 0) return 0;

	l = 0; r = n;
	while (l != r) {
		m = (l + r + 1) / 2;
		a[m] = query(m);
		if (a[m] == 0) return 0;

		if (((m - l) % 2 == 0) && (a[l] != a[m]) && (r != m)) r = m;
		else if (((m - l) % 2 == 1) && (a[l] == a[m]) && (r != m)) r = m;
		else l = m;
	}
	   
	return 0;
}




Measured memory_bytes: 1236
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct UnionFind{
    vl par;
    vl rank;
    map<ll, ll> size;
    UnionFind(ll N) : par(N, 0), rank(N, 0){
        for(int i = 0; i < N; i++){
            par[i] = i; size[i] = 1;
        }
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]); // compression
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x); ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx, ry);
        if(rank[rx] == rank[ry]) ++rank[rx];
        par[ry] = rx;
        if(rx != ry) size[rx] = size[rx] + size[ry];
        else{
            size[rx] = max(size[rx], size[ry]);
        }
    }
    
    ll get_size(ll x){
        return size[root(x)];
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};


int main(){
    ll N; cin >> N;
    vs ws(N); REP(i, N) cin >> ws[i];
    
    REP(i, N){
        FOR(j,i+1,N){
            if(ws[i] == ws[j]){
                cout << "No" << endstr; return 0;
            }
        }
    }
    REP(i, N-1){
        if(ws[i].back() != ws[i+1][0]){
            cout << "No" << endstr; return 0;
        }
    }
    cout << "Yes" << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=0; i<n; i++)
//#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i] << " ";}
int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
 
//int cnt =0;
 
//void SieveOfEratosthenes(int n=20000000)
//{
//   // v.push_back(1);
//
//   bool prime[n+1];
//   memset(prime, true, sizeof(prime));
//
//    vector <bool>prime(n+1,true);
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          mp[p]++;
//}
 
 
//set <int>s;
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        s.insert(2);
//        n /= 2;
//    }
//
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            s.insert(i);
//            n /= i;
//        }
//
//    }
//
//    if(n>2){
//       s.insert(n);
//    }
//
//}
 

//int isprime(long long int N){
//    if(N<2 || (!(N&1) && N!=2))
//        return 0;
//    for(long long int i=3; i*i<=N; i+=2){
//        if(!(N%i))
//            return 0;
//    }
//    return 1;
//}

//int binary_ser(vector<int>&v,int target,int r,int l=0){
//
//    int mid;
//    mid = l+((r-l)/2);
//
//    if(l>r)return -1;
//
//    if(v[mid]==target)return mid;
//    else if(v[mid]>target){
//        r = mid-1;
//        return binary(v, target,r,l);
//    }
//    else{
//        l = mid+1;
//        return binary(v, target,r,l);
//    }
//
//    return -1;
//
//}

//int lcs(string s,string p){
//
//    vector<vector<int>>v(s.size()+1,vector<int>(p.size()+1));
//
//    for(int i=1; i<=s.size(); i++){
//        for(int j=1; j<=p.size(); j++){
//
//    if(s[i-1]==p[j-1]) v[i][j] = v[i-1][j-1]+1;
//
//    else v[i][j] = max(v[i-1][j], v[i][j-1]);
//
//  }
// }
//
//    return v[s.size()][p.size()];
//}


int main(){
   
    
    int a,b,c,n;
    cin >> a >> b;
    
    if(b==1)cout << 0 << endl;
    else{
        cout << a-b << endl;
    }
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  string o,e,a;
  int leno,lene;
  cin >> o >> e;
  for(int i=0;i<e.size();i++){
    cout << o[i];
    cout << e[i];
  }
  if((o.size() - e.size()) == 1){
    cout << o[o.size()-1];
  }
}


Measured memory_bytes: 256
/// Solution No.:

/// Approach:

/// Comment:

/// Verdict:

/// Report:


#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <string.h>
#include <climits>
#include <set>
#include <cassert>
#include <cfloat>
#include <stack>

///using namespace std;         /// Recommended not to use

#define p(x) std::cout<<#x<<" = "<<x<<"\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define absolute(x) (((x)<0)?(-(x)):(x))
/// #define _DEBUG

typedef long long int ll;
typedef unsigned long long llu;
typedef long double lld;

/// lld pi = 2 * acos(0.0);   /// precision error
lld pi = 2 * acosl(0.0);

int test_case_number, test_case=1;

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
/// Direction Array
/// int dx[]={0, 0, 1, -1, -1, 1, -1, 1};
/// int dy[]={-1, 1, 0, 0, 1, 1, -1, -1};

///place for problem specific functions


void function_name()
{
    int element_number,k;
    scanf("%d %d", &element_number, &k);
    std::vector<int>main_array(element_number), dp(element_number, INT_MAX);

    for(int &x:main_array)
    {
        scanf("%d",&x);
    }


    dp[0]=0;
    for(int i=0; i<element_number;i++)
    {
        for(int j = i+1;j<=i+k;j++)
        {
            if(j<element_number)
            {
                dp[j]=std::min(dp[j], dp[i]+absolute(main_array[i]-main_array[j]));
            }
        }
    }

    printf("%d\n", dp[element_number-1]);
}
void function_name(int v1, int v2, int v3)
{

}
void function_name(std::string line)
{

}
class initial_works
{
public:

    void with_test_case_number()
    {
        scanf("%d", &test_case_number);
        ///getchar();
        while(test_case <= test_case_number)
        {
            function_name();
            test_case++;
        }
    }

    void single_iteration()
    {
        function_name();
    }

    void without_test_case_number()
    {
        int v1, v2, v3;
        while(scanf("%d %d %d", &v1, &v2, &v3)==3 && v1!=0)
        {
            function_name(v1, v2, v3);
            test_case++;
        }
    }

    void eoof()
    {
        char dummy_char_array[100];
        while(scanf("%[^\n]", dummy_char_array)!=EOF)
        {
            ///it only takes the absence of one getchar to ruin your life. Don't understand remove the getchar below and then input the sample input
            getchar();
            ///if not given getchar. the dummu_char_array will not take new input as there is newline after the first input is taken. It will continue with the previous value.
            /// So, the function will run with same argument.
            std::string line = dummy_char_array;
            function_name(line);
            test_case++;
        }
    }
};


int main()
{
    //std::ios_base::sync_with_stdio(false);
    initial_works a;
    a.single_iteration();

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    int N, K;
    cin>>N>>K;
    // vector<int> A;
    int argmin;
    rep(i, N){
        int a;
        cin>>a;
        if(a==1){
            argmin = i;
        }
        // A.push_back(a);
    }
    int r = argmin/(K-1);
    r += (N-argmin-1)/(K-1);
    int t = (argmin%(K-1)+(N-argmin-1)%(K-1)+1);
    r += t==1 ? 0 : t<=K ? 1 :2;

    cout<<r<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[100000+100];
int n; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	long long s=1;
	int num=0;
	for(int i=n;i>=2;i--){
		if(a[i]==a[i-1]){
			s = s*a[i];
			num++;
			i--;
		}
		if(num==2){
			break;
		}
	}
	if(num==2){
		cout<<s<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) if (a[j] >> i & 1) x++;
    ll t = x * (n - x) % mod;
    rep(j, i) t *= 2, t %= mod;
    ans += t;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const maxn = 200000
const maxr = 1000000000

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := stdin(sc)
	if n < 2 || maxn < n {
		panic("n is invalid")
	}
	ary := make([]int, n)
	for i := 0; i < n; i++ {
		v := stdin(sc)
		if v < 1 || maxr < v {
			panic("v is invalid")
		}
		ary[i] = v
	}
	maxv := -math.MaxInt32
	minv := ary[0]
	for i := 1; i < n; i++ {
		maxv = max(maxv, ary[i]-minv)
		minv = min(minv, ary[i])
	}

	fmt.Println(maxv)
}

func stdin(sc *bufio.Scanner) int {
	var n int
	if sc.Scan() {
		num, err := strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
		n = num
	}
	return n
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}



Measured memory_bytes: 5404
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 1000100;
const int base = 1e9+7;

int n;
ll fac[maxn],ifac[maxn];

ll pw(int a,int n) {
    if (n==0) return 1ll;
    if (n==1) return a;
    ll tg = pw(a,n/2);
    tg = (tg*tg) % base;
    if (n%2) return (tg*a)%base;
    return tg;
}

ll C(int k,int n) {
    if (k > n) return 0;
    return (fac[n] * ifac[k] % base * ifac[n-k])%base;
}

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    fac[0] = 1, ifac[0] = 1;
    for (int i=1;i<maxn;i++) {
        fac[i] = (fac[i-1]*1ll*i)%base;
        ifac[i] = pw(fac[i],base-2);
    }
    //cout<<C(1,1)<<endl;
    cin>>n;
    ll res=0;
    ll pre=0;
    for (int i=(n+1)/2;i<n;i++) {
        ll now = C(n-i-1,i-1) * fac[i] %base * fac[n-i-1] % base;
        res = (res + 1ll*i*(now-pre)%base + base)%base;
        pre = now;
    }
    cout<<res;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    ll ans =0 ;
    cin >> n;
    for (int z=1;z<n;z++){
        if (n-z != z){
            ans++;
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[15],k;
int main(){
	scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k);
	sort(a,a+3);
	for (int i=0; i<k; i++)
	a[2]*=2;
	int ans=0;
	for (int i=0; i<3; i++)	ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
S = str(input())
N = 2 ** (len(S)-1)
l = [] # それぞれの和を格納
for i in range(N):
  m = [S] # 分けた数字を格納
  cnt = 0
  for j in range(len(S)-1):
    if (i >> j) & 1:
      m.append(m[-1][:cnt+1])
      m.append(m[-2][cnt+1:])
      del m[-3]
      cnt = 0
    else:
      cnt += 1
  m = [int(s) for s in m]
  l.append(sum(m))
print(sum(l))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,a) rep((i),0,(a))
using namespace std;
//global

struct Data{
	int x, y,r;
	int c;
};
Data data[24];
bool dp[1024 * 1024 * 16];
int min_num;
int N;
bool double_check(int i, int j){
	int dx, dy, dr;
	dx = data[j].x - data[i].x;
	dy = data[j].y - data[i].y;
	dr = data[j].r + data[i].r;
	//printf("[%d,%d]%d,%d,%d\n", i, j, dx, dy, dr);
	if ((dx*dx + dy*dy)<(dr*dr))return(true);
	else return(false);
}

void printbit(int x){
	REP(i, N){
		if ((x >> (N - i-1)) & 1)cout << 1;
		else cout<<0;
	}
	cout << endl;


}
void solve(int num, int rest){
	/*cout << "rest"<<endl;
	printbit(rest);*/
	if (min_num > num)min_num = num;
	if (num <= 1)return;
	if (dp[rest])return;
	dp[rest] = true;
	int color[4] = { 0 }, index[4] = { 0 };
	REP(i, N){
		int bit = (1 << i);
		if ((rest&bit) > 0){
			bool f = true;
			rep(j,0,i)if((rest&(1<<j))>0)
			if (double_check(i, j)){
				f = false; continue;
			}
			if (f){
				color[data[i].c] += bit;
				index[data[i].c]++;
			}
		}
	}
	//rep(i, 0, 4){printf("%d,",index[i]);printbit(color[i]);}
	/*rep(i, 0, 4)
	if (index[i]>=2)
	if (!(index[i] & 1)){
		solve(num - index[i], rest - color[i]);
	}
	else{
		int p = 1;
		rep(j, 0, index[j]){
			while (!(p & 1))p <<= 1;
			solve(num - index[i] + 1, rest - color[i] + p);

		}
*/
	rep(i, 0, 4)
	if (index[i] >= 2){
		int p = 1;
		rep(j, 0, index[i] - 1){
			while ((p&color[i]) ==0)p<<=1;
			int pt = p<<1;
			rep(k, j + 1, index[i])
			{
				while ((pt&color[i])==0)pt <<= 1;
				int sub = p + pt;
				/*cout << "sub" << endl;
				printbit(sub);*/
				solve(num - 2, rest - sub);
				pt <<= 1;
			}
			p <<=1;
		}
	}

	//cout << "return" << endl;
}



int main(void){
	while (true){
		cin >> N;
		if (N == 0)return(0);
		min_num = N;
		memset(dp, 0, sizeof(dp));
		REP(i, N){
			cin >> data[i].x >> data[i].y >> data[i].r>>data[i].c;
			data[i].c--;
		}
		solve(N, (1 << N) - 1);
		cout << N - min_num << endl;
	}}

Measured memory_bytes: 17552
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <fstream>
 
using namespace std;
 
const int N = 100005;
int n, k, a[N], dp[N];
 
int rec(int i)
{
	if (i == n - 1) return 0;
	if (i > n - 1) return 1e9;
 
	int& dp = ::dp[i];
 
	if (dp != -1) return dp;
 
	dp = 1e9;
	
	for(int j = 1 ; j <= k && i + j <= n; j++)
		dp = min(rec(i+j) + abs(a[i]-a[i+j]),dp);
	
	return dp;
}
 
int main()
{
 
	cin >> n >> k;
	
	memset(dp, -1, sizeof(dp));
 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
	}
 
	printf("%d", rec(0));
}

Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var now = 100L;
            var num = long.Parse(Console.ReadLine());
            var result = 0L;

            for (; now < num; result++)
            {

                now += now / 100L;

            }

            Console.WriteLine(result);

        }


    }
}


Measured memory_bytes: 27536
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

h = Array.new(41, 0)
a.each {|x| x.bit_length.times {|i| h[i] += x[i]} }

b = true
ans = 0
40.downto(0) do |i|
    x = h[i] > n/2 ? 0 : 1
    
    if b
        if k[i] == x
            ans |= x << i
        elsif k[i] < x
        else
            b = false
        end
    else
        ans |= x << i
    end
end
#p ans
p a.inject(0){|r, v| r + (v ^ ans)}

Measured memory_bytes: 10764
using System;
using System.Linq;
using System.Collections.Generic;

public class Program{
  public static void Main(){
    var hw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var a = new byte[hw[0],hw[1]];
    for(var i=0; i<hw[0]; i++){
      var l = Console.ReadLine();
      for(var j=0; j<hw[1]; j++) a[i,j] = (byte) ( l[j]=='#'?1:0);
    }
    var can = true;
    for(var i=0; i<hw[0]; i++){
      for(var j=0; j<hw[1]; j++){
        if(a[i,j]==1){
          var count = 0;
          count += i!=0?(a[i-1,j]==1?1:0):0;
          count += j!=0?(a[i,j-1]==1?1:0):0;
          count += (j!=hw[1]-1)?(a[i,j+1]==1?1:0):0;
          count += (i!=hw[0]-1)?(a[i+1,j]==1?1:0):0;
          if(count==0) can = false;
        }
      }
      if(!can) break;
    }
    Console.WriteLine(can?"Yes":"No");
  }
}


Measured memory_bytes: 11092
fn main() {
    let h: usize = readln();
    let n = 1 << h;
    let a: Vec<usize> = readln();
    let mut dp = vec![(0, 0); n];
    for s in 0..n {
        dp[s] = (a[s], usize::min_value());
    }
    for i in 0..h {
        for s in 0..n {
            if (s >> i & 1) == 0 {
                let ns = s | (1 << i);
                let mut v = vec![dp[s].0, dp[s].1, dp[ns].0, dp[ns].1];
                v.sort();
                dp[ns] = (v[2], v[3]);
            }
        }
    }
    let mut cur = 0;
    for s in 1..n {
        let a = dp[s].0;
        let b = dp[s].1;
        cur = max(cur, a + b);
        println!("{}", cur);
    }
}


#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 12276