akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<string,int> P;
typedef map<string,int> M;
 
void pr(M a,string s=""){
  return;
  cout<<s<<endl;
  for(P p:a) cout<<p.first<<" "<<p.second<<endl;
  cout<<"end"<<endl;
}
 
M add(M a,M b,int f=1){
  for(P p2:b) a[p2.first] += f * p2.second;
  return a;
}
 
M mult(M a,M b){
  M res;
  for(P p1:a)
    for(P p2:b){
      string s = p1.first + p2.first; sort(s.begin(),s.end());
      int num = p1.second * p2.second;
      res[s] += num;
    }
  return res;
}
 
 
M bnf();
int pos;
string S;
void skipsp(){while(S[pos] == ' ') pos++;}
 
int getNum(){
  int res = 0;
  while((int)S.size()> pos && isdigit(S[pos])) res = res * 10 + S[pos++]-'0';
  return res;
}
 
int getNum2(const string &S,int &pos){
  int res = 0;
  while((int)S.size()>pos && isdigit(S[pos])) res = res * 10 + S[pos++]-'0';
  return res;
}
 
string getBlock(){
  string res;
  skipsp();
  while(isdigit(S[pos]) || isalpha(S[pos])) res += S[pos++];
  skipsp();
  if(S[pos] == '^') {
    pos++;
    skipsp();
    assert(isdigit(S[pos])&&"hut");
    int p = getNum();
    for(int i=0;i<p-1;i++) res += res.back();
  }
  return res;
}
 
M BtoM(string b){
  M res;
  int num = 1;
  string val;
  for(int i=0;i<(int)b.size();i++){
    char ch = b[i];
    if(isalpha(ch)) val += ch;
    else if(isdigit(ch)) num *= getNum2(b,i),i--;
    else if(ch != ' ') assert(!"BtoM");
  }
  res[val] = num;
  return res;
}
 
M calc(){
  M res; res[""] = 1;
  while(1){
    skipsp();
    char ch = S[pos];
    if(ch == '(') pos++,res = mult(res,bnf()),pos++;
    else if(isalpha(ch) || isdigit(ch)){
      string block = getBlock();
      res = mult(res,BtoM(block));
    }
    else if(ch == '^') assert(!"^");
    else break;
  }
  pr(res,"calc,res");
  return res;
}
 
M bnf(){
  M res = calc();
  pr(res,"start bnf");
  while(1){
    skipsp();
    char ch = S[pos];
    if(isalpha(ch) || isdigit(ch)) res = mult(res,calc());
    else if(ch == '+')pos++,res = add(res,calc());
    else if(ch == '-')pos++,res = add(res,calc(),-1);
    else if(ch == '(') pos++,res = mult(res,bnf()),pos++;
    else if(ch == '^') assert(!"^");
    else break;
  }
   
  for(auto it=res.begin();it!=res.end();it++) if(it->second==0) res.erase(it);
  pr(res,"return bnf");
  return res;
}
 
signed main(){
  while(1){
    getline(cin,S);
    //cin.ignore();
    if(S == ".") break;
    pos = 0;
    M ori = bnf();
    pr(ori,"ori");
    while(1){
      getline(cin,S);
      if(S == ".") break;
      pos = 0;
      M res = bnf();
      cout<<((ori == res)? "yes":"no")<<endl;
      pr(res,S);
    }
    cout<<"."<<endl;
  }
  return 0;
}

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

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



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main()
{
  vector<int> nums = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

  int x, y;
  cin >> x >> y;

  if (nums[x] == nums[y]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	ll t;
	cin >> n >> t;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	if(n==1){
		cout << 0 << endl;
		return 0;
	}

	ll minv=a[0], maxv=-1, cnt=0;
	for(int i=1; i<n; i++){
		if(a[i]-minv==maxv) cnt++;
		else if(a[i]-minv>maxv) cnt=1;
		maxv=max(maxv, a[i]-minv);
		minv=min(minv, a[i]);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    Q = int(input())

    head = ""
    tail = ""
    reverse = False

    for i in range(Q):
        t = input().strip().split()
        if t[0] == "1":
            # 反転
            reverse = not(reverse)
        else:
            # 文字追加
            if t[1] == "1":
                # 前に追加
                if reverse:
                    tail += t[2]
                else:
                    head += t[2]
            else:
                # 後に追加
                if reverse:
                    head += t[2]
                else:
                    tail += t[2]
    
    if reverse:
        print(tail[::-1] + s[::-1] + head)
    else:
        print(head[::-1] + s + tail)



if __name__ == "__main__":
    main()

Measured memory_bytes: 4468
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

double dp[3005][3005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;

    vector<double> p(N);
    REP(i, N) cin >> p[i];

    dp[0][0] = 1;
    REP(i, N) {
        REP(j, i + 1) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    double ans = 0;
    FOR(i, 1, N) {
        if (i > N / 2) ans += dp[N][i];
    }
    fcout << ans << endl;

    return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int n,x,t;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin>>n>>x>>t;
    int ans=(n/x)*t+(n%x>0?t:0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll n,m,s; cin>>n>>m>>s;
  struct Train {
    ll s, c, d;
    Train(ll s,ll c,ll d):s(s),c(c),d(d){}
    bool operator>(const Train& x) const {return d>x.d;}
  };
  vector<Train> graph[n];
  for (int i = 0; i < m; i++) {
    ll u,v,a,b; cin>>u>>v>>a>>b; u--; v--;
    graph[u].emplace_back(v,a,b);
    graph[v].emplace_back(u,a,b);
  }
  for (int i = 0; i < n; i++) {
    int c,d; cin>>c>>d;
    graph[i].emplace_back(i,-c,d);
  }
  constexpr ll MAX = 200;
  constexpr ll INF = 1e18;
  vector<array<ll, MAX+1>> dp(n);
  for (auto& arr:dp) arr.fill(INF);
  dp[0][min(s,MAX)] = 0;
  priority_queue<Train, vector<Train>, greater<>> qs;
  qs.emplace(0,s,0);
  while (not qs.empty()) {
    auto [s,c,d] = qs.top(); qs.pop();
    if (d > dp[s][min(c,MAX)]) continue;
    for (auto t:graph[s]) {
      if (c-t.c<0) continue;
      if (d+t.d >= dp[t.s][min(c-t.c,MAX)]) continue;
      dp[t.s][min(c-t.c,MAX)] = d+t.d;
      qs.emplace(t.s, c-t.c, d+t.d);
    }
  }
  for (int i = 1; i < n; i++) {
    cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3856
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =5e5+5;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }
	     

	 void solve() {	    
         int n;
         cin>>n;
         map<string,int> mp;
         rep(i,0,n) {
			     string s;
			     cin>>s;
			     mp[s]++;
			 }
			 
			 int maxi=0;
			 for(auto to:mp) {
				    maxi=max(maxi,to.se);
				 }
				 
			vector<string > ans;
			
			for(auto to:mp ) {
				    if(to.se==maxi)
				     ans.pb(to.fe);
				}
				
				for(auto to:ans)
				  cout<<to<<endl;
				  
				  
			 
         
		       
	 }
	
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	   solve();
	   
	   
	   return 0;	   
}


Measured memory_bytes: 25584
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}ll n, S,k; vector<ll> a; string s;
const ll mod = 998244353;
int main(void) {
	cin >> n >> k  >> s;
	int sum = 1; vector<int> a;;
	int bit = s[0] - '0';
	if (bit == 0) a.push_back(0);
	rep(i, n - 1) {
		if (s[i + 1] == s[i]) sum++;
		else {
			a.push_back(sum);
			sum = 1; 
		}
	}
	a.push_back(sum); int ans = 0;
	if (s[n - 1] == '0') a.push_back(0);
	bit = 1 - bit;
	rep(i, a.size()-1) a[i + 1] += a[i];
	for (int i = 2 * k; i < a.size(); i += 2) {
		if (i == 2 * k) ans = max(ans, a[i]);
		else ans = max(ans, a[i] - a[i - 2 * k - 1]);
	}if (2 * k >= a.size()) ans = a[a.size()-1];
	cout << ans << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll k,a,b;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++){
    if(i%k==0) {
        cout<<"OK"<<endl;
    return 0;
    }
    }
   cout<<"NG"<<endl;

}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 1848
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if ((x - r < 0) || (y - r < 0) || (x + r > W) || (y + r > H)) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 584
def solve(x):
    res = 0
    v = 100
    while True:
        v = int(v * 1.01)
        res += 1
        if v >= x:
            return res


def main():
    x = int(input())
    res = solve(x)
    print(res)


def test():
    assert solve(103) == 3
    assert solve(1000000000000000000) == 3760
    assert solve(1333333333) == 1706


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9188
#include<stdio.h>

int main(void){
int i,j,h,w;
while(1){
scanf("%d %d",&h,&w);
if(h==0&&w==0)break;
else for(i=0;i<h;i++){
for(j=0;j<w;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<unordered_set>
#include<stack>
#include<vector>

using namespace std;
typedef unordered_set<int> useti;

struct person{
  useti link;
  useti block;
  int group = -1;
};

useti CreateGroup(int start, int gindex, vector<person> &nodes){
  stack<int> stackIndex;
  useti ret;
  
  stackIndex.push(start);
  while(!stackIndex.empty()){
    int cur = stackIndex.top();
    ret.emplace(cur);
    nodes[cur].group = gindex;
    stackIndex.pop();
	for(const auto &next : nodes[cur].link){
      if(ret.find(next) != ret.end()) continue;
      stackIndex.push(next);
    }
  }
  return ret;
}

int main(){
  
  int N, M, K;
  cin >> N >> M >> K;
  
  vector<person> nodes(N+1);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    nodes[A].link.emplace(B);
    nodes[B].link.emplace(A);
  }
  
  for (int i = 0; i < K; i++){
    int C, D;
    cin >> C >> D;
    nodes[C].block.emplace(D);
    nodes[D].block.emplace(C);
  }

  vector<useti> groups;
  int gcount = 0;
  for (int i = 1; i <= N; i++){
    if (nodes[i].group != -1) continue;
    auto tempGroup = CreateGroup(i, gcount, nodes);
    if (tempGroup.empty()) continue;
      
	groups.emplace_back(tempGroup);    
    
    ++gcount;
  }
  
  for (int i = 1; i < N+1; i++){
    int curGroup = nodes[i].group;
    
    if (curGroup == -1){
      cout << "0 ";
      continue;
    }
    
    int blockNum = 0;
    for (const auto &blockIndex : nodes[i].block){
	  if (nodes[blockIndex].group == curGroup) ++blockNum;
    }
    
    int ret = groups[curGroup].size() - nodes[i].link.size() - blockNum - 1;
    cout << ret;
    if (i != N) cout << " "; 
  }
  
  return 0;
}

Measured memory_bytes: 41548
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long LL;


void print(int* arr, int len=5) {
    REP(i, len) cout << arr[i] << " ";
    cout << endl;
}

int main(){
    LL N;
    LL C;

    scanf("%lld", &N);
    scanf("%lld", &C);

    LL tmp;
    REP(i, 4) {
        scanf("%lld", &tmp);
        if (tmp < C) C = tmp;
    }

    LL t = 4 + N / C;

    if (N % C > 0) {
        ++t;
    }

    printf("%lld\n", t);
}


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

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

  sort(A.begin(), A.end());

  cout << abs(A.at(0)-A.at(1))+abs(A.at(1)-A.at(2)) << endl;

return 0;  
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::map<char, std::vector<int>> mp;

    rep(i, s.size())
    {
        mp[s[i]]
            .push_back(i);
    }

    int pos = -1, ans = 0;

    for (int i = 0; i < t.size();)
    {
        const auto &mmp = mp[t[i]];
        if (mmp.empty())
        {
            std::cout << -1 << std::endl;
            return 0;
        }
        auto it = std::upper_bound(std::begin(mmp), std::end(mmp), pos);
        if (it == mmp.end())
        {
            ++ans;
            pos = -1;
        }
        else
        {
            pos = *it;
            ++i;
        }
        //std::cerr << pos << std::endl;
    }

    std::cout << ans * s.size() + pos + 1 << std::endl;

    return 0;
}

Measured memory_bytes: 4168
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N; cin >> N;
  string but[10] = {
	"",
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz",
  };
  REP(t,N){
	string str; cin >> str;
	int cur = -1, p = -1;
	REP(i,SZ(str)){
	  if(str[i] == '0'){
		if(cur >= 0 && p > 0){
		  cout << but[p][cur%SZ(but[p])];
		  cur = p = -1;
		}
	  }
	  else{
		p = str[i] - '0';
		++cur;
	  }
	}
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(void) {  

char num[1001];    

int a, sum;    

while(1){      

scanf("%s" ,num);      

if(num[0]=='0')break;      

sum = 0;      

for(a = 0;num[a]!='\0';a++){        

sum+=num[a]-'0';       

}      

printf("%d\n" ,sum);     

}  

return 0;

}
     

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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
	#include "Debug.h"
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=1e5+3;

struct City{
	int p;
	int t;
	int no;
	bool operator <(City a) const{
		re t<a.t;
	}
}a[MAXN];

int n,cnt[MAXN];
string ID[MAXN];

string make(int a,int b){
	string s=string(12,'0');
	for (int i=5;i>=0;i--){
		s[i]=a%10+'0';
		a/=10;
	}
	for (int i=11;i>=6;i--){
		s[i]=b%10+'0';
		b/=10;
	}
	re s;
}

int main(){
	cin>>n>>n;
	rep(i,n){
		cin>>a[i].p>>a[i].t;
		a[i].no=i+1;
	}
	sort(a,a+n);
	rep(i,n){
		cnt[a[i].p]++;
		ID[a[i].no]=make(a[i].p,cnt[a[i].p]);
	}
	For(i,n){
		cout<<ID[i]<<endl;
	}
	re 0;
}

Measured memory_bytes: 8576
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

int tom(const int n) {
	return n % 100 + (n / 100) * 60;
}

int main() {
	while (1) {
		int n, p, q; cin >> n >> p >> q;
		int aa = n;
		if (!n)break;
		int start(tom(p)), goal(tom(q));
		vector<int>times(2000);
		while (n--) {
			int t; cin >> t;
			while (t--) {
				int a, b; cin >> a >> b;
				a = tom(a), b = tom(b);
				times[a]--;
				times[b]++;
			}
		}
		int ans = 0;
		int seq = 0;
		int num = aa;
		for (int t = start; t < goal; ++t) {
			num += times[t];
			if (num) {
				seq++;
				ans = max(ans, seq);
			}
			else {
				seq = 0;

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

Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;

int main(){
    long double b,x=1,y=0,d=0,n,h,w,k,max=-100,ans=0,count=0,sum=0;
    string s;
    cin >> n >> k;
    for(int i=1; i<=n;i++){
        b = 1.0/n;
        int m = i;
        while(m<k){
            m*=2;
            b/=2;
        }
        ans += b;
    }
    cout << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  int ans = (N - 2) * 180;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c, k = map( int, input().split() )

if k <= a:
    print( k )

elif k > a:
    if b == 0:
        nc = k - a
        print( a - nc )
    elif b != 0:
        nb = k - a
        if nb <= b:
            print( a )
        elif nb > b:
            nc = nb - b
            print( a - nc )


Measured memory_bytes: 9204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var str = IO.GetIntList().Select(s=>(double)s).ToList();
            Console.Write(str[0] * str[1] / 2 + " ");
            var ans = str[0] / str[2] == 2 && str[1] / str[3] == 2 ? 1 : 0;
            
            Console.Write(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
long int solve(long long int x,long long int y)
{
	if(x==0||y==0)
	return 0;
	
	if(x<y&&y%x==0)
	{
		return (y/x)*2*x-x;
	}
	if(y<x&&x%y==0)
	{
		return (x/y)*2*y-y;
	}
	if(x<y)
	{
		return solve(x,y-(y/x)*x)+(y/x)*2*x;
	}
	else
	{
		if(y<x)
		{
			return solve(x-(x/y)*y,y)+(x/y)*2*y;
		}
		else
		return x;
	}
}
int main()
{
	long long int n,x;
	cin>>n>>x;
	cout<<n+solve(x,n-x);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++){
			a[i]=s.nextInt();
		}
		int max=a[1]-a[0];
		int min=a[0];
		for(int j=2;j<n;j++){
			min=Math.min(min,a[j-1]);
			int sub;
			sub=a[j]-min;
			if(sub>max) max=sub;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 101384
# encoding: utf-8
ABC = sorted(list(map(int, input().split())))

diff0 = ABC[-1] - ABC[0]
diff1 = ABC[-1] - ABC[1]

# +2 only
if diff0 % 2 == diff1 % 2 == 0: ans = (diff0 + diff1) // 2
# +1 (ABC[0], ABC[1]) once and +2
elif diff0 % 2 == diff1 % 2 == 1: ans = (diff0 + diff1) // 2
# +1 (ABC[{0, 1}], ABC[2]) once and +2)
else: ans = 1 + (diff0 + diff1 + 2) // 2

print(ans)

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

vector<int> coin;

int bst = INT_MAX;
int ans = 0;


int main(){
  int n, m;
  int ans = 0;

  cin >> n >> m;
  int tmp;
  for (int i=0; i < m; i++){
    cin >> tmp;
    coin.push_back(tmp);
  }

  vector<int> dp(n+1, INT_MAX);
  dp[0] = 0;
  // コイン
  for(int i=0; i<=n; i++){
    for(int j=0; j<coin.size(); j++){
      if(i - coin[j] >= 0){
        dp[i] = min(dp[i - coin[j]] + 1,  dp[i]);
      }
    }
  }
  cout << dp[n] << endl;



  return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>

using namespace std;

int n,k;

int main()
{
	cin >> n >> k;
	cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;
	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k) {
        print(s);
    } else {
        string ans = s.substr(0, k);
        print(ans + "...");
    }

    return 0;
}


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

struct Node {
  Node* l = nullptr;
  Node* r = nullptr;
};

int n;
long k;
string s[100000];
Node nodes[400000];
Node* head = nodes;

Node* new_node() {
  static Node* node = nodes;
  return ++node;
}

void add(const string& str) {
  Node* curr = head;
  for (int i = 0; i < str.size(); ++i) {
    char c = str[i];
    if (c == '0') {
      if (curr->l == nullptr) {
        curr->l = new_node();
      }
      curr = curr->l;
    } else {
      if (curr->r == nullptr) {
        curr->r = new_node();
      }
      curr = curr->r;
    }
  }
}

void create() {
  for (int i = 0; i < n; ++i) {
    add(s[i]);
  }
}

const int L = 100005;
int a[L];
void rec(Node* node, int level) {
  if (node == nullptr) {
    ++a[level];
    return;
  }
  
  if (node->l == nullptr && node->r == nullptr) return;
  rec(node->l, level + 1);
  rec(node->r, level + 1);
}

const int M = 64;
int b[M];
bool ok() {
  for (int i = 0; i < min<long>(k + 1, L); ++i) {
    if (a[i] % 2 == 0) continue;
    long p = k - i + 1;
    int cnt = 0;
    while (p % 2 == 0) {
      p /= 2;
      ++cnt;
    }
    ++b[cnt];
  }
  
  for (int p = 0; p < M; ++p) {
    if (b[p] % 2 == 1) return false;
  }
  return true;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  create();
  rec(head, 0);
  
  if (ok()) {
    cout << "Bob" << endl;
  } else {
    cout << "Alice" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4736
import java.util.*
import kotlin.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }


fun main(args: Array<String>) {
    val X = readLong()

    var money = 100.0
    var year = 0
    while (money < X) {
        money *= 1.01
        money = Math.floor(money)
        year++
    }

    val ans = year
    println(ans)
}


Measured memory_bytes: 34536
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
c = collections.Counter(s)
count = 0
for i in c.values():
  if i >= 2:
    count += cmb(i, 2)
print(count)

Measured memory_bytes: 68452
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,m;
cin>>n>>m;
vector<long long int > arr(n);
long long int  sum=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
}
int count=0;
for(int i=0;i<arr.size();i++)
{
    
    if(arr[i] >= (float)sum/(4*m))count++;
}
if(count>=m)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
    
    
    
}

Measured memory_bytes: 256
C=input()
if C=="a":
  print("b")
elif C=="b":
  print("c")
elif C=="c":
  print("d")
elif C=="d":
  print("e")
elif C=="e":
  print("f")
elif C=="f":
  print("g")
elif C=="g":
  print("h")
elif C=="h":
  print("i")
elif C=="i":
  print("j")
elif C=="j":
  print("k")
elif C=="k":
  print("l")
elif C=="l":
  print("m")
elif C=="m":
  print("n")
elif C=="n":
  print("o")
elif C=="o":
  print("p")
elif C=="p":
  print("q")
elif C=="q":
  print("r")
elif C=="r":
  print("s")
elif C=="s":
  print("t")
elif C=="t":
  print("u")
elif C=="u":
  print("v")
elif C=="v":
  print("w")
elif C=="w":
  print("x")
elif C=="x":
  print("y")
else :
  print("z")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main(){
  int N,K,x,sum=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    if(K-x<x) sum+= 2*(K-x);
    else sum+= 2*x;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
   ll N,A,B;
   cin >> N >> A >> B;
   ll X[N];
   for(int i=0;i<N;i++)cin >> X[i];
   ll ans = 0;
   for(int i=0;i<N-1;i++){
       ans = ans + min(A*(X[i+1]-X[i]),B);
   }
   cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(int) Attempts(N + 1, 0);
    VEC(bool) AC(N + 1, false);

    FOR(i, 0, M) {
        int p;
        string res;
        cin >> p >> res;
        if (!AC[p]) {
            Attempts[p]++;
            AC[p] = (res == "AC");
        }
    }

    int solved = 0, penalties = 0;
    FOR(p, 1, N + 1)
        if (AC[p]) {
            solved++;
            penalties += Attempts[p] - 1;
        }

    cout << solved << " " << penalties << endl;
    return 0;
};

Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<iterator>
#include<algorithm>
#include<functional>

typedef long long ll;

struct solver_abc_a37_b {
	// const int coord_min = -1000000;
	// const int coord_max =  1000000;

	std::string run(int K, int X) {
		int exist_min = X - K + 1;
		int exist_max = X + K - 1;
		std::stringstream ss;

		ss << exist_min;
		for(int i = exist_min + 1; i <= exist_max; ++i) {
			ss << " " << i;
		}

		return ss.str();
	}
};

int main(void) {
	solver_abc_a37_b solver;
	int K, X;
	std::cin >> K >> X;
    std::cout << solver.run(K, X) << std::endl;

	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    vector<int64_t> tmp(n);
    int minus = 0;
    int absmin=1000000001;
    rep(i,n){
        cin>>a[i];
        if(abs(a[i])<absmin){
            absmin = abs(a[i]);
        }
        if(a[i]<0){
            minus++;
        }
    }
    if(minus%2==0){
        int64_t sum=0;
        rep(i,n){
            sum += abs(a[i]);
        }
        cout<<sum<<endl;
    }
    else{
        int64_t sum=0;
        rep(i,n){
            sum += abs(a[i]);
        }
        sum -= 2*absmin;
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    char c;
    std::cin >> c;

    char result;
    if (c == 'A') result = 'T';
    if (c == 'T') result = 'A';
    if (c == 'C') result = 'G';
    if (c == 'G') result = 'C';

    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [0]
M = list(range(1 , N + 1))
a = 1
for i in range(1 , N):
  for j in range(1 ,i + 1):
    a = a * j
  L.append(a)
  a = 1
list.sort(L,reverse = True)
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
con_P = 0
con_Q = 0
for k in range(0 , N - 1):
  if k != N - 2:
    con_P += L[k] * (M.index(P[k]))
    M.remove(P[k])
  else:
    con_P += L[k] * (M.index(P[k]) + 1)
    
M = list(range(1 , N + 1))

for l in range(0 , N - 1):
  if l != N - 2:
    con_Q += L[l] * (M.index(Q[l]))
    M.remove(Q[l])
  else:
    con_Q += L[l] * (M.index(Q[l]) + 1)
ans = con_P - con_Q
if ans < 0:
  print(-ans)
else:
  print(ans)



Measured memory_bytes: 9180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(ALL(d));
  int ans = d[(n-1)/2 + 1] - d[(n-1)/2];
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, k;
    string s;
    cin >> n >> k >> s;
    string press;
    s = 'z' + s; //調整
    loop(i, n)
    {
        if (s[i] != s[i + 1])
            press.push_back(s[i + 1]);
    }
    ll siz = press.size();
    ll unhappy = siz;
    unhappy -= k * 2;
    if (unhappy < 1)
        unhappy = 1;
    putout(n - unhappy);
    return 0;
}


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=a[i][j];
            bool flag=false;
            for(int k=0;k<n;k++){
                if(i==k||j==k)continue;
                if(a[i][k]+a[k][j]<a[i][j]){
                    cout<<-1<<endl;
                    return 0;
                }
                else if(a[i][k]+a[k][j]==a[i][j]){
                    if(!flag)ans-=a[i][j];
                    flag=true;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
//const long long MOD=1e9+7;
ll mod_pow(ll x,ll y,ll MOD){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  ll N,count=0;
  cin>>N;
  string X;
  cin>>X;
  for(ll i=0;i<N;i++){
    if(X.at(i)=='1'){count++;}
  }
  ll summ=0;
  ll ing=1;
  ll M=count+1;
  ll m=count-1;
  for(ll i=0;i<N;i++){
    if(m==0){break;}
    if(X.at(N-i-1)=='1'){
      summ+=ing;
      summ%=m;
      //cout<<i<<" "<<ing<<endl;
    }
    ing*=2;
    ing%=m;
  }
  
  ll sumM=0;
  ing=1;
  for(ll i=0;i<N;i++){
    if(X.at(N-i-1)=='1'){
      sumM+=ing;
      sumM%=M;
      //cout<<i<<" "<<ing<<endl;
    }
    ing*=2;
    ing%=M;
  }
  ll rock;
  //cout<<summ<<endl;
  //cout<<m<<" "<<summ<<"    "<<M<<" "<<sumM<<endl;
  //map<ll,ll> mp;
  //map<ll,ll> cal;
  for(ll i=0;i<N;i++){
    //m
    if(X.at(i)=='0'){
      rock=mod_pow(2,N-i-1,M);
      rock+=sumM;
      rock%=M;
      //cout<<i<<" "<<rock<<endl;
    }
    else{
      if(m==0){cout<<0<<endl;continue;}
      rock=-1*mod_pow(2,N-i-1,m);
      rock+=summ;
      //cout<<rock<<endl;
      rock%=m;
      rock+=m;
      rock%=m;
      //cout<<i<<" "<<rock<<endl;
    }
    //mp[i]=1
    //cal[i]=rock;
    //cout<<" "<<i<<endl;
    if(rock==0){cout<<1<<endl;}
    else{
      ll start=rock;
      ll ans=1;
      while(start>0){
      ll memo=start;
      ll div=2;
      ll c=0;
      while(start>0){
        if(start%div==0){
          start/=div;
        }
        else{
          c++;
          start-=(start%div);
          start/=div;
        }
      }
      ans++;
      if(c==0){break;}
      start=memo%c;
      }
      cout<<ans<<endl;
    }
  }
}

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

void fnInput(int& rnSpcNum, int& rnMinSum, int& rnMaxSum)
{
  cin >> rnSpcNum >> rnMinSum >> rnMaxSum;
}

int fnDigitsSum(int nNum)
{
  int nDigitsSum = 0;
  while ( nNum )
  {
    nDigitsSum += nNum % 10;
    nNum /= 10;
  }
  return nDigitsSum;
}

int fnSomeSums(int nSpcNum, int nMinSum, int nMaxSum)
{
  int nTotal = 0;
  for (int n = 1; n <= nSpcNum; n++)
  {  
    int nDigitsSum = 0;

    nDigitsSum += fnDigitsSum(n);
    if (nMinSum <= nDigitsSum && nDigitsSum <= nMaxSum)
      nTotal += n;
  }
  return nTotal;
}

int main()
{
  int nSpcNum, nMinSum, nMaxSum;
  fnInput(nSpcNum, nMinSum, nMaxSum);

  cout << fnSomeSums(nSpcNum, nMinSum, nMaxSum) << endl;
  return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main(){ 
    FAST
    int n;cin>>n;
    vector<int> v(n+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        if(i%2==1&&v[i]%2==1) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3612
#D

#デバッグ
debug=0
def pront(*n):
    if debug==1:
        print(n)
        
#10**9+7を底とした処理

base=10**9+7

def add(a,b):#a+b
    return (a+b)%base

def sub(a,b):#a-b
    return (a-b)%base

def multi(a,b):#a*b
    return (a*b)%base

def exp(a,b):#a**b
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):#a/b
    return(multi(a,exp(b,base-2)))

#入力
N,K=map(int,input().split())

#処理
    #その他演算
def fact(m,n):#m~nの積(m<n)
    x=1
    for i in range(m,n+1):
        x=multi(x,i)
    return x
def comb(n,r):
    return div(fact(n-r+1,n),fact(1,r))

def ssum(m,n):#m~nの和(m<=n)
    x=(n)*(n+1)//2
    y=(m-1)*(m)//2
    return x-y

x=0

for i in range(K,N+2):
    #pront(i,ssum(N-i+1,N),ssum(0,i-1))
    x+=ssum(N-i+1,N)-ssum(0,i-1)+1
print(x%base)

Measured memory_bytes: 9276
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int A,B; cin >> A >> B;
    cout << (A+B)%24 << endl;
    return 0;
}

Measured memory_bytes: 384
main () {
    int a, b, c;
    scanf("%d %d %d",&a, &b, &c);
    if (a <= b && b <= c) printf("%d %d %d\n", a, b, c);
    else if (a <= c && c <= b) printf("%d %d %d\n", a, c, b);
    else if (b <= a && a <= c) printf("%d %d %d\n", b, a, c);
    else if (b <= c && c <= a) printf("%d %d %d\n", b, c, a);
    else if (c <= a && a <= b) printf("%d %d %d\n", c, a, b);
    else if (c <= b && b <= a) printf("%d %d %d\n", c, b, a);
}


Measured memory_bytes: 2112
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func convertInt(str string) int {
	num, e := strconv.Atoi(str)
	if e != nil {
		panic(e)
	}
	return num
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextLine()
	fmt.Println(strings.Count(s, "1"))
}

Measured memory_bytes: 640
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

[<EntryPoint>]
let main _ =
    let a = reada int
    if Array.sum a >= 22 then "bust"
    else "win"
    |> printfn "%s"
    0 // return an integer exit code


Measured memory_bytes: 13916