akhauriyash/Code-Regression huggingface dataset:
n=gets.chop.to_i
p=gets.chomp.split.map(&:to_i)
min=[]
count=0
for i in 0...n-2 do
 for j in 0...3 do
  min.push(p[i+j])
 end
 min2=min
 min=min.sort
 if min2[1]==min[1]
  count=count+1
 end
 min=[]
end
puts count

Measured memory_bytes: 1788
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	if(n%100 <= 12 && n%100>=1){
		if(n/100 <= 12 && n/100>=1){
			cout << "AMBIGUOUS" << endl;
		}
		else{
			cout << "YYMM" << endl;
		}
	}
	else{
		if(n/100 <= 12 && n/100>=1){
			cout << "MMYY" << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//Binary search

#include<stdio.h>

int main()
{

  int n1 = 0;
  int n2 = 0;
  int i,j;
  int arr1[100000];
  int arr2[50000];
  int mid = 0;
  int count = 0;
  int left = 0;
  int right = 0;

  //input data
  scanf("%d",&n1);

  for(i = 0; i < n1; i++)
    {
      scanf("%d",&arr1[i]);
    }

  scanf("%d",&n2);

  for(j = 0; j < n2; j++)
    {
      scanf("%d",&arr2[j]);
    }

  //work time

  for(j = 0; j < n2 ;j++)
    {
      left = 0;
      right = n1;

      while(left < right)
	{
        
	  mid = (left + right) / 2;
     
	  if(arr1[mid] == arr2[j])
	    {
	      count++;
	      break;
	    }

	  else if(arr2[j] < arr1[mid]) right = mid;

	  else if(arr2[j] > arr1[mid]) left = mid + 1;

	}
    }

  //output data
  printf("%d\n",count);

  return 0;
}




Measured memory_bytes: 2364
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int H, N;
  cin >> H;
  cin >> N;
  int A[N+1];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    H -= A[i];
  }
  if (H <= 0) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main() {
	long long a, b, x, result;
	scanf("%lld%lld%lld", &a, &b, &x);
	if(a==b) {
		if(a%x == 0) result = 1;
		else result = 0;
	}
	else if(!a) {
		result = b/x+1;
	}
	else {
		result = (b/x) - (a-1)/x;
	}
	printf("%lld\n", result);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,x;
int a[125252];

int main(){
  scanf("%d%d",&n,&x);
  REP(i,n)scanf("%d",a+i);
  ll ans = 0;
  REP(i,n-1){
    if(a[i]+a[i+1]>x){
      int sm = a[i]+a[i+1];
      int sb = sm-x;
      ans += sb;
      int mn = min(a[i+1],sb);
      sb -= mn;
      a[i+1] -= mn;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

const int MAXN = 1e5 + 10;
vector<pair<int, int> > Mat[MAXN];
bool cl[MAXN];
int n;

void dfs(int v, int p, int s) {
	cl[v] = s % 2;
	for (int i = 0; i < Mat[v].size(); i++)
		if (Mat[v][i].first != p)
			dfs(Mat[v][i].first, v, s + Mat[v][i].second);
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b, w;
		cin >> a >> b >> w;
		Mat[a].push_back({b, w % 2});
		Mat[b].push_back({a, w % 2});
	}
	dfs(1, 1, 0);
	for (int i = 1; i <= n; i++)
		cout << cl[i] << '\n';
}

Measured memory_bytes: 8832
n = int(input())
s = [input() for i in range(n)]
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for string in s:
    ans[string] += 1
print("AC x", ans["AC"])
print("WA x", ans["WA"])
print("TLE x", ans["TLE"])
print("RE x", ans["RE"])

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

int main() {
  int N,ans=0;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      for (int k = j+1; k < N; k++) {
        if (L.at(i) + L.at(j) > L.at(k)) {
          ans++;
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, T;
    cin >> N >> T;

    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    int dp1[N + 1][T], dp2[N + 1][T];
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));

    FOR(i, 1, N + 1) {
        FOR(t, 1, T) {
            dp1[i][t] = max(dp1[i - 1][t], dp1[i][t-1]);

            if (t - A[i - 1] > -1) {
                dp1[i][t] = max(dp1[i][t], dp1[i - 1][t - A[i - 1]] + B[i - 1]);
            }
        }
    }

    FOR(i, 1, N + 1) {
        FOR(t, 1, T) {
            dp2[N - i][t] = max(dp2[N - i + 1][t], dp2[N - i][t-1]);

            if (t - A[N - i] > -1) {
                dp2[N - i][t] = max(dp2[N - i][t], dp2[N - i + 1][t - A[N - i]] + B[N - i]);
            }
        }
    }

    int ans = 0;
    REP(i, N) {
        REP(j, T) {
            int tmp = B[i];
            tmp += dp1[i][j];
            tmp += dp2[i + 1][T - j - 1];

            ans = max(ans, tmp);
        }
    }

    print(ans);

}


Measured memory_bytes: 73928
h,w,k = map(int,input().split())
in_list = [[0] * w for i in range(h)]
for i in range(h):
    in_list[i][:] = input()
#print(in_list)

result = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ih in range(h):
            for iw in range(w):
                if (i>>ih&1)==0 and (j>>iw&1)==0:
                    if in_list[ih][iw]=="#":
                        cnt+=1
        if cnt==k:
            result += 1
print(result)


Measured memory_bytes: 9168
def bb
    s = gets.chomp
    t = gets.chomp

    if s == t
        puts 'Yes'
        exit
    end

    u = s.split(//)
    for i in 1..(s.length-1)
        u = u.rotate(-1)
        if u.join == t
            puts 'Yes'
            exit
        end
    end

    puts 'No'
end

bb


Measured memory_bytes: 1916
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		try (Scanner scTmp = new Scanner(System.in);) {

			int numN = scTmp.nextInt();
			int sum = 0;
			for (int i = 1; i <= numN; i++) {
				sum = sum + i;
			}
			System.out.println(sum);
		}
	}

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,m,a[200000],b[200000];
int main()
{
    m=read();n=m*2-1;reg int i,j,l,r,mid,c,fl;
    for(i=1;i<=n;++i)a[i]=read(),b[i]=a[i];
    sort(b+1,b+1+n);
    l=0;r=n;
    while(l<r-1)
    {
        mid=(l+r)>>1;c=(a[m]>b[mid]);c^=1;fl=-1;
        for(i=m-1,j=m+1;i>=1,j<=n;--i,++j)
        {
            if((a[i]>b[mid])!=c){fl=(a[i]>b[mid]);break;}
            if((a[j]>b[mid])!=c){fl=(a[j]>b[mid]);break;}
            c^=1;
        }
        if(fl==-1)
        {
            if(m&1)fl=(a[m]>b[mid]);
            else fl=(a[m]<=b[mid]);
        }
        if(fl)l=mid;
        else r=mid;
    }
    cout<<b[r]<<"\n";
	return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair
#define vd vector<double>
#define vdd vector<vd>


int main() {
  int n;
  cin >> n;
  vi l(n);
  rep (i, n) {
    cin >> l[i];
  }
  sort(all(l));
  ll sum = 0;
  rep (i, n - 1) {
    sum += l[i];
  }
  if (sum > l.back()) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<string> A(N),B(N);
  for(string &S:A)cin>>S;
  string T;
  cin>>T;
  B=A;
  for(int i=0;i<N;i++){
    for(char &c:A[i])
      if(c=='?')c='z';
    for(char &c:B[i])
      if(c=='?')c='a';
  }
  int n=1,m=1;
  for(int i=0;i<N;i++){
    if(A[i]<T)n++;
    if(B[i]<=T)m++;
  }
  for(int i=n;i<=m;i++){
    cout<<i;
    if(i==m)cout<<endl;
    else cout<<' ';
  }
}

Measured memory_bytes: 3888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

Measured memory_bytes: 256
#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
#include <atomic>
#include <thread>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }



const int N = 200001, inf = 10000;


void solve() {
  ll a = 2, b = 1;
  int n;
  cin >> n;
  n--;
  while (n--) {
    ll c = a + b;
    a = b;
    b = c;
  }
  cout << b << ln;
}


void init() {
  
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }
  
  
  return 0;
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
vector<string> split_str(string s) {
	vector<string> ans;
	int pre = 0;
	for (int i = 0; i <= s.length(); ++i) {
		if (i == s.length() || s[i] == ' ') {
			if (i != pre) ans.push_back(s.substr(pre, i - pre));
			pre = i + 1;
		}
	}
	return ans;
}
int main() {
	int NA, NT, NG, NC, M;
	cin >> NA >> NT >> NG >> NC >> M;
	int L = NA + NT + NG + NC;
	vector<string> query(M);
	getline(cin, query[0]);
	for (int i = 0; i < M; ++i) {
		getline(cin, query[i]);
	}
	vector<string> nonterm(M);
	vector<vector<string> > nonseq(M);
	for (int i = 0; i < M; ++i) {
		vector<string> res = split_str(query[i]);
		nonterm[i] = res[0]; nonterm[i].pop_back();
		nonseq[i] = vector<string>(res.begin() + 1, res.end());
	}
	vector<vector<string> > seq(M);
	bool flag = true;
	for (int i = M - 1; i >= 0 && flag; --i) {
		for (int j = 0; j < nonseq[i].size(); ++j) {
			if (nonseq[i][j][0] == '[') {
				seq[i].push_back(nonseq[i][j]);
			}
			else {
				int ptr = find(nonterm.begin(), nonterm.end(), nonseq[i][j]) - nonterm.begin();
				seq[i].insert(seq[i].end(), seq[ptr].begin(), seq[ptr].end());
			}
			if (seq[i].size() > L) {
				flag = false; break;
			}
		}
	}
	if (seq[0].size() < L) flag = false;
	if (!flag) {
		cout << 0 << endl;
	}
	else {
		vector<vector<vector<vector<int> > > > dp(NA + 1, vector<vector<vector<int> > >(NT + 1, vector<vector<int> >(NG + 1, vector<int>(NC + 1))));
		dp[0][0][0][0] = 1;
		for (int i = 0; i <= NA; ++i) {
			for (int j = 0; j <= NT; ++j) {
				for (int k = 0; k <= NG; ++k) {
					for (int l = 0; l <= NC; ++l) {
						int ptr = i + j + k + l - 1;
						if (i >= 1 && seq[0][ptr].find('A') != string::npos) {
							dp[i][j][k][l] += dp[i - 1][j][k][l];
							if (dp[i][j][k][l] >= mod) dp[i][j][k][l] -= mod;
						}
						if (j >= 1 && seq[0][ptr].find('T') != string::npos) {
							dp[i][j][k][l] += dp[i][j - 1][k][l];
							if (dp[i][j][k][l] >= mod) dp[i][j][k][l] -= mod;
						}
						if (k >= 1 && seq[0][ptr].find('G') != string::npos) {
							dp[i][j][k][l] += dp[i][j][k - 1][l];
							if (dp[i][j][k][l] >= mod) dp[i][j][k][l] -= mod;
						}
						if (l >= 1 && seq[0][ptr].find('C') != string::npos) {
							dp[i][j][k][l] += dp[i][j][k][l - 1];
							if (dp[i][j][k][l] >= mod) dp[i][j][k][l] -= mod;
						}
					}
				}
			}
		}
		cout << dp[NA][NT][NG][NC] << endl;
	}
	return 0;
}


Measured memory_bytes: 31444
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<double> a(n);
	for( auto &k : a ) cin >> k;
	for( auto &k : a ) k = 1.0/k;
	double sum = 0;
	for( auto &k : a ){
		sum += k;
	}
	cout << fixed << setprecision(10) << 1.0/sum << endl;
	return 0;
}

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

int main()
{
    int N ; 
    cin >> N ;
    
    vector<int> a(N) ;
    for(int &x : a) cin >> x ;

    vector<int> dp(N, INT_MAX) ;
    dp[0] = 0 ;

    for(int i = 0 ; i < N ; ++i)
    {
        if(i-1 >= 0)
            dp[i] = min(dp[i], dp[i-1]+abs(a[i-1]-a[i])) ;
        if(i-2 >= 0)
            dp[i] = min(dp[i], dp[i-2]+abs(a[i-2]-a[i])) ;
    }
    cout << dp[N-1] << endl ;
    return 0 ;
}


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

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

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

signed main(){
	int n,a,b,c,ans=1000000000;
	cin>>n>>a>>b>>c;
	vector<int>l(n);
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	for(int i=0;i<pow(4,n);i++){
		int bit[n];
		for(int j=0;j<n;j++){
			int po=1;
			for(int k=0;k<j;k++){
				po*=4;
			}
			bit[j]=i/po%4;
		}
		int x=0,y=0,z=0,xc=-1,yc=-1,zc=-1;
		for(int j=0;j<n;j++){
			if(bit[j]==1){
				xc++;
				x+=l[j];
			}
			else if(bit[j]==2){
				yc++;
				y+=l[j];
			}
			else if(bit[j]==3){
				zc++;
				z+=l[j];
			}
		}
		if(xc==-1||yc==-1||zc==-1)continue;
		ans=min(ans,abs(x-a)+abs(y-b)+abs(z-c)+(xc+yc+zc)*10);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
tot = ((n+1)*n)/2
fiz = 3*(((n / 3)+1) * (n/3))/2
baz = 5*(((n / 5)+1) * (n/5))/2
fiba =15*(((n /15)+1) * (n/15))/2
puts tot-fiz-baz+fiba  


Measured memory_bytes: 14312
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,s;
	cin>>a>>b;
	if(a<b) swap(a,b);
	if(a==b) s=a*2;
	else s=a+a-1;
	cout<<s;
	return 0;
}

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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 510000;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long com2(long n, long r) {
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

long inv(long a) {
  long b = MOD, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD; 
  if (u < 0) u += MOD;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  init();
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    long tmp = com(N, K);
    tmp -= com(i + 1, K);
    tmp -= com(N - i - 1, K);
    tmp *= A.at(i + 1) - A.at(i);
    tmp %= MOD;
    while (tmp < 0) tmp += MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 12672
//v 1.0.0
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <math.h>

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1 == 0){
    cout << 1 << endl;
  }
  else if (x2 == 0){
    cout << 2 << endl;
  }
  else if (x3 == 0){
    cout << 3 << endl;
  }
  else if (x4 == 0){
    cout << 4 << endl;
  }
  else if (x5 == 0){
    cout << 5 << endl;
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x; 


int main(){
    cin >> a >> b >> x;

    long double tan = (2*(a*a*b - x)) / (a*a*a);
    long double thita = 0.0;

    if(a*a*b/2.0 <= x){
        thita = atan(tan);
    }else{
        thita = PI/2 - atan(2*x / (a*b*b));
    }
    thita = thita*360/(2*PI);
    cout << fixed << setprecision(10) <<  thita << endl;
    return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void printVector(vector<int> v) {
    for(int i=0;i<v.size();i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

int solve(vector<int> v) {
    if(v.size() == 0)
        return 0;
    vector<int> dst1,dst2;
    for(int i=0;i<v.size();i++){
        if(v[i] == 0){
            if(i == 0){
                dst1 = v;
                dst1.erase(dst1.begin());
                // printVector(dst1);
                return solve(dst1);
            }
            if(i == v.size()-1){
                dst1 = v;
                dst1.erase(dst1.end()-1);
                // printVector(dst1);
                return solve(dst1);
            }
            dst1 = v;
            dst1.erase(dst1.begin(), dst1.begin()+i+1); //後半
            dst2 = v;
            dst2.erase(dst2.begin()+i, dst2.end()); //前半
            return solve(dst1) + solve(dst2);
        }
    }
    for(int i=0;i<v.size();i++){
        v[i]--;
    }
    return solve(v) + 1;
}

int main(){
    int n;
    cin >> n;
    vector<int> h;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    cout<< solve(h) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <cctype>
#include <utility>
#include <climits>


using namespace std;
using ll = long long;
using P = pair<ll,ll>;


const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);


#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define pb push_back
#define fir first
#define scn second
#define ednl endl


#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
long long init[51];
long long niit[51];
long long DFS(long long lv,long long n){
  if(n <= 0)return 0;
  if(init[lv] <= n){
    return niit[lv];
  }
  if(lv==0){
    return 1;
  }
  long long ryo = 0;
  
  n--;
  if(n <= 0)return ryo;
  ryo += DFS(lv-1,n);n-=init[lv-1];
  if(n <= 0)return ryo;
  ryo += 1;n--;
  if(n <= 0)return ryo;
  ryo += DFS(lv-1,n);n-=init[lv-1];
  
  if(n <= 0)return ryo;
  n--;
  return ryo;
  
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  init[0] = 1;
  niit[0] = 1;
  for(int i = 1; 51 > i; i++){
    init[i]=init[i-1]*2+3;
    niit[i]=niit[i-1]*2+1;
  }
  long long n,x;cin>>n>>x;
  cout << DFS(n,x) << endl;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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;
}


int main() {
  string s; cin >> s;
  string ans="";
  if(s=="Sunny")ans ="Cloudy";
  if(s=="Cloudy")ans ="Rainy";
  if(s=="Rainy")ans ="Sunny";
  cout << ans;
}

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

int main()
{
    int n, a[11]={4,7,8,11,12,14,15,16,18,19,20};
    cin >> n;
    if (n>=21){
        cout << "Yes" << endl;
        return 0;
    }
    for (int i=0;i<11;++i){
        if (n==a[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main()
{
while(true) {
int n;
bool card[2][200] = {false};
int count[2];

scanf("%d",&n);
if(n == 0)
break;
count[0] = count[1] = n;
for(int i = 0; i < n; ++i) {
int t;
scanf("%d", &t);
card[0][t - 1] = true;
}
for(int i = 0; i < 2 * n; ++i)
card[1][i] = !card[0][i];
int cur = -1;
int turn = 0;
while(count[0] > 0 && count[1] > 0) {
int next = -1;
for(int i = cur + 1; i < n * 2; ++i) {
if(card[turn][i]) {
card[turn][i] = false;
count[turn] -= 1;
next = i;
break;
}
}
cur = next;
turn = (turn + 1) % 2;
}
printf("%d\n%d\n", count[1], count[0]);
}
return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>  
    #define PI acos(-1.0)  
    #define pb push_back  
    #define F first  
    #define S second  
    #define debug puts  
    #define setp cout << fixed << setprecision(15)  
    #define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);  
    using namespace std;  
    typedef long long ll;  
    const int N=3e5+5;  
    const int MOD=998244353;  
      
    int main(void){  
        FAST_IO;  
        int n;  
        cin >> n;  
        vector<int> l(n+1),r(n+1);  
    //    cout << a[0]<<endl;  
        for(int i=1;i<=n;i++){  
            int a,b;  
            cin >> a >>b;  
            l[i]=a,r[i]=b;  
        }  
        sort(l.rbegin(),l.rend());  
        sort(r.begin(),r.end());  
        ll ans=0;  
        for(int i=0;i<=n;i++){  
            if(l[i]>r[i]){  
                ans+=2*(l[i]-r[i]);  
            }  
        }  
        cout << ans << endl;  
      
        return 0;  
    }  

Measured memory_bytes: 1024
from pprint import pprint
import sys

K = int(sys.stdin.readline())
S = sys.stdin.readline().strip()

ls = len(S)


mod = 10**9 + 7
MAX = ls + K + 100
factorial = [1] * (MAX+1)
t = 1
for i in range(1, MAX+1):
    t = (t * i) % mod
    factorial[i] = t
def combination(n, x, mod=10**9+7):
    # nCx
    # 組み合わせ
    # ex) combination(5, 2) = 10
    # factorial = [1] * (n+1)
    # t = 1
    # for i in range(1, n+1):
    #     t = (t * i) % mod
    #     factorial[i] = t
    tmp = factorial[n]
    tmp = (tmp * pow(factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(factorial[n-x], mod-2, mod)) % mod
    return tmp



# Sの部分文字列を埋め込む場所のパターン
# S + K choose S

# Snを配置する場所ごとに全パターンを計算
ans = 0
for i in range(ls-1, ls + K):	
    tmp = pow(25, i-ls+1, mod) 
    tmp *= pow(26, ls + K - i - 1, mod) 
    comb = combination(i, ls-1)
    tmp *= comb
    tmp %= mod
    ans += tmp
    ans %= mod

print(ans)

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

class Bmondai {
    static void Main()
    {
        var count = Int32.Parse(Console.ReadLine());
        var A= Console.ReadLine();
        var B = Console.ReadLine();
        var C = Console.ReadLine();
        var ans = 0;
        for (int i=0;i<count;++i)
        {
            if (A[i] == B[i] && A[i] == C[i]) continue;
            else if (A[i] == B[i] || A[i] == C[i] || B[i] == C[i]) ans++;
            else ans += 2;
        }
        Console.WriteLine(ans);
    }
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)
/* cout << fixed << setprecision(12) << ans << endl;*/
#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN



int main()
{
 boost;
 ll n,W;
 cin >> n >> W;
 vector<ll> wt(n),val(n);
 ll i=0,w=0;
 
 forn(i,0,n)
 cin >> wt[i] >> val[i];
 
 vector<vector<ll> > K(n+1 , vector<ll> (W+1 , 0 ) );
 
 for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   }
   
   cout << K[n][W] ; 
 

}






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

using LLI = long long int;
LLI a, b, n;

int main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  printf("%lld\n", max(0LL, (b*(n-1))+a-(a*(n-1)+b)+1));
}


Measured memory_bytes: 256
a = int(input())
cnt = 0

ans = 'No'

for i in range(a):
    L = list(map(int,input().split()))
    if L[0] == L[1]:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        ans = 'Yes'
        break

print(ans)




Measured memory_bytes: 9104
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

// using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
// typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///
const long long maX=1e6+5;
ll divisor[maX];
int main(){
        ll n;
        sf(n);
        ll cc=0;
        for(ll i=1;i<n;i++){
            cc+=(n-1)/i;
        }
        pfn(cc);
return 0;
}

Measured memory_bytes: 3788
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (h, _) = scan!(usize, usize);
    let input = scan!(;;h);

    let mut g = Vec::new();
    for line in input.iter() {
        g.push(line.chars().collect::<Vec<_>>());
    }

    for i in 0..g.len() {
        for j in 0..g[i].len() {
            if g[i][j] == '#' {
                print!("#")
            } else {
                let mut num = 0;
                for dx in &[1i64, 0, -1] {
                    for dy in &[1, 0, -1] {
                        let x = i as i64 + dx;
                        let y = j as i64 + dy;
                        if 0 <= x && x < g.len() as i64 && 0 <= y && y < g[i].len() as i64 {
                            if g[x as usize][y as usize] == '#' {
                                num += 1
                            }
                        }
                    }
                }
                print!("{}", num)
            }
        }
        println!()
    }
}


Measured memory_bytes: 4352
# AOJ 0242: Input Candidates
# Python3 2018.6.25 bal4u

while 1:
	n = int(input())
	if n == 0: break
	idx, dict = {}, {}
	for i in range(n):
		for j in list(input().split()):
			if j in dict: dict[j] += 1
			else:
				dict[j] = 1
				if j[0] not in idx:	idx[j[0]] = []
				idx[j[0]].append(j)
	k = input()
	if k not in idx: print("NA")
	else:
		a, ans = [], []
		for j in idx[k]: a.append((j, dict[j]))
		a.sort(key=lambda x:(-x[1],x[0]))
		w = min(len(a), 5)
		for j in range(w): ans.append(a[j][0])
		print(*ans)



Measured memory_bytes: 5616
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


A, B = inpl()

print(lcm(max(A, B), min(A, B)))


Measured memory_bytes: 2940
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main()
{
        vector< int > vec;
        int n, tmp;

        cin >> n;
        array< int, 10001 > arr;

        for ( int i = 0 ; i < 10001 ; i++ )
        {
                arr[i] = 0;
        }

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

        /* Counting Sort */
        for ( int i = 0 ; i < 10001 ; i++ )
        {
                if ( arr[i] != 0 )
                {
                        tmp = i;
                        for ( int j = 0 ; j < arr[tmp] ; j++ )
                        {
                                vec.push_back( tmp );
                        }
                }
        }


        for ( int i = 0 ; i < n ; i++ )
        {
                if ( i != n - 1 )
                {
                        cout << vec[i] << " ";
                }
                else
                {
                        cout << vec[i] << endl;
                }

        }


        return 0;
}

Measured memory_bytes: 11212
def main():
  n = int(input())
  s =  str(input())
  num_r = 0
  for i in range(n):
    if s[i] == "R":
      num_r += 1
  ans = 0
  for i in range(num_r):
    if s[i] == "W":
      ans += 1
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 9452
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

int main(void)
{
	int n = 0, m = 0,flag = 0,check = 0;
	char N[60][60], M[60][60],dummy;
	scanf("%d%d",&n, &m);
	scanf("%c", &dummy);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			scanf("%c", &N[i][j]);
		}
		scanf("%c", &dummy);
	}
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%c", &M[i][j]);
		}
		scanf("%c", &dummy);
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i + m - 1 >= n || j + m - 1 >= n)
			{
				continue;
			}
			
			check = 0;

			for (int y = 0; y < m; y++)
			{
				for (int x = 0; x < m; x++)
				{
					if (N[i + y][j + x] != M[y][x])
					{
						check = 1;
					}
				}
			}
			if (check == 0) { flag = 1; }
		}
	}
	
	if (flag == 1) { printf("Yes"); }
	else { printf("No"); }

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int x;
	cin>>x;
	long long int ans = 2*(x/11);
	x%=11;
	if(x > 6)
		ans+=2;
	else if(x > 0)
		ans++;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top=0,a[100];

int pop() {

  top--;
  return a[top];

}

void push(int x) {

  a[top]=x;
  top++;

}

int main(){
  int x;
  char s[100];
  int A,B;

  while( scanf("%s", s) != EOF ){ // EOF=入力が終るまでループ
    
    if ( s[0] == '+' ){
      A = pop();
      B = pop();
      push(A + B);
    } else if ( s[0] == '-' ){
      A = pop();
      B = pop();
      push(B-A);
    } else if ( s[0] == '*' ){
      A = pop();
      B = pop();
      push(A*B);
    } else {
      x = atoi(s); //数字をint型に変換
      push(x);
    }
  }

  printf("%d\n",a[top-1]);

  return 0;


}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		//~ scanf("%d", &a[i]);
		cin >> a[i];
	}
	vector <int> h(n);
	for (int i = 0; i < n; i++) {
		if (i & 1) h[0] -= a[i];
		else h[0] += a[i];
	}
	for (int i = 1; i < n; i++) {
		h[i] = 2 * a[i - 1] - h[i - 1];
	}
	for (int i = 0; i < n; i++) {
		//~ printf("%d ", h[i]);
		cout << h[i] << " ";
	}
	return 0;
}


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

ll dp[1011][1011];

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

    ll n,m;

    cin>>n>>m;

    string s[n+11];
    for(ll i=0;i<n;i++){
      cin>>s[i];
    }

    ll ok = 1;

    for(ll i=0;i<m;i++){
      if(s[0][i] == '#'){
        ok = 0;
      }
      dp[0][i] = ok;
    }
    ok = 1;

    for(ll i=0;i<n;i++){
      if(s[i][0]=='#'){
        ok = 0;
      }
      dp[i][0] = ok;
    }

    for(ll i=1;i<n;i++){
      for(ll j = 1;j<m;j++){
        if(s[i][j]=='#'){
          dp[i][j] = 0;
        }else{
          dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
      }
    }

    cout<<dp[n-1][m-1];

    
    return 0;
}

Measured memory_bytes: 9216
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

string s;

int main()
{
	cin >> s;
	if (s.length() >= 4 && s.substr(0, 4) == "YAKI")
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
    int N,M,i,j,t,K,sum=0;
    cin>>N>>M;
    int a[M]={0};
    for(i=1;i<=N;i++){
        cin>>K;
        for(j=1;j<=K;j++){
            cin>>t;
            a[t-1]++;
        }
    }
    for(i=0;i<M;i++){
        if(a[i]==N){
            sum++;
        }
    }
    cout<<sum;
    return 0;

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int a,b;
	cin>>a>>b;
	int ans=1500;
	for(int i=0;i<1500;i++){
		if((i*8/100)==a && (i*10/100)==b)
			ans=min(ans,i);
	}
	if(ans>1100)
		cout<<"-1\n";
	else
		cout<<ans<<"\n";
}

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ,k;
    cin>>n>>k;
    ll ans=0;

    ll max = (n-1)*(n-2)/2;
    if(k>max){
        cout<<-1<<endl;
        return 0;
    }
    VV graph(n+3);
    REP(i,2,n+1){
        graph[1].pb(i);
    }
    ll cnt = max-k;
    REP(i,2,n){
        REP(j,i+1,n+1){
            if(cnt<1){
                break;
            }
            graph[i].pb(j);
            cnt--;
        }
    }

    cout<<n-1+max-k<<endl;
    REP(i,1,n+1){
        rep(j,graph[i].size()){
            cout<<i<<" "<<graph[i][j]<<endl;
        }
    }
    return  0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Output(vector< pair< char, int > >& B)
{
  int tal = B.size() - 2;
  for(int i = B.size() - 1; i > 0; i--) {
    tal = min(tal, i - 1);
    while(tal > 0 && B[tal].second == 0) --tal;
    if(B[i].first == B[tal].first) {
      B[tal].second += B[i].second;
      B[i].second = 0;
    }
  }
  for(int i = 0; i < B.size(); i++) {
    if(B[i].second > 0) {
      cout << B[i].first << " " << B[i].second << " ";
    }
  }
  cout << "$" << endl; 
  exit(0);
}


  
signed main()
{
  vector< pair< char, int > > A[3];
  vector< pair< char, int > > B;
  
  for(int i = 0; i < 3; i++) {
    char C;
    while(cin >> C, C != '$') {
      int D;
      cin >> D;
      A[i].emplace_back(C, D);
    }
  }
  
  if(A[1].size() == 1) {
    for(int i = 0; i < A[0].size(); i++) {
      if(A[0][i].first == A[1][0].first && A[0][i].second >= A[1][0].second) {
        for(int j = 0; j < i; j++) {
          B.emplace_back(A[0][j].first, A[0][j].second);
        }
        for(int j = 0; j < A[2].size(); j++) {
          B.emplace_back(A[2][j].first, A[2][j].second);
        }
        if(A[0][i].second != A[1][0].second) {
          B.emplace_back(A[0][i].first, A[0][i].second - A[1][0].second);
        }
        for(int j = i + 1; j < A[0].size(); j++) {
          B.emplace_back(A[0][j].first, A[0][j].second);
        }
        Output(B);
      }
    }
  } else {
    for(int i = 0; i <= (int)A[0].size() - (int)A[1].size(); i++) {
      if(A[0][i].first == A[1][0].first && A[0][i].second >= A[1][0].second && A[0][i + A[1].size() - 1].first == A[1].back().first && A[0][i + A[1].size() - 1].second >= A[1].back().second) {
        bool flag = true;
        for(int j = 1; j < A[1].size() - 1; j++) {
          flag &= A[0][i + j] == A[1][j];
        }
        if(!flag) continue;
        for(int j = 0; j < i; j++) {
          B.emplace_back(A[0][j].first, A[0][j].second);
        }
        if(A[0][i].second != A[1][0].second) {
          B.emplace_back(A[0][i].first, A[0][i].second - A[1][0].second);
        }
        for(int j = 0; j < A[2].size(); j++) {
          B.emplace_back(A[2][j].first, A[2][j].second);
        }
        if(A[0][i + A[1].size() - 1].second != A[1].back().second) {
          B.emplace_back(A[0][i + A[1].size() - 1].first, A[0][i + A[1].size() - 1].second - A[1].back().second);
        }
        for(int j = i + A[1].size(); j < A[0].size(); j++) {
          B.emplace_back(A[0][j].first, A[0][j].second);
        }
        Output(B);
      }
    }
  }
  for(int i = 0; i < A[0].size(); i++) {
    B.emplace_back(A[0][i].first, A[0][i].second);
  }
  Output(B);
}

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

const int MAXN = 200005;

char s[MAXN];
int n;

int main(){
	scanf("%s", s);
	
	int sum = 0;
	for(int i = 0; s[i]; i++){
		sum = (sum + s[i] - '0') % 9;
	}
	
	if(sum == 0)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}


Measured memory_bytes: 3820
#include<stdio.h>
int main(void){
	int p,q,H,W;
	while(1){
		scanf ("%d %d",&H,&W);
		if (H == 0 && W == 0) break;
		for (p = 0; p < H; p++){
			for (q = 0; q < W; q++){
				if ( (p%2 == 0 && q%2 == 0) || (p%2 != 0 && q%2 != 0) ){
					printf ("#");
				}
				else printf (".");
			}
			printf("\n");
		}
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256