akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const char keibutton[10][5]={{'\0','\0','\0','\0','\0'},
							 {'.',',','!','?',' '}, //1
						     {'a','b','c'},     //2
						     {'d','e','f'},     //3
						     {'g','h','i'},     //4
						     {'j','k','l'},     //5
						     {'m','n','o'},     //6
						     {'p','q','r','s'}, //7
						     {'t','u','v'},     //8
						     {'w','x','y','z'}};//9


int main(){
	int n,cnt,outcnt,inpcnt;
	char str[1025],outputStr[1025];
	
	cin>>n;
	
	for(int z=0;z<n;z++){
		
		fill(str,str+1025,'\0');
		fill(outputStr,outputStr+1025,'\0');
		cnt=-1;
		inpcnt=0;
		outcnt=0;
		
		cin>>str;
		
		while(true){
			if(str[inpcnt]=='\0'){
				break;
			}
			inpcnt++;
		}
		
		for(int i=0;i<inpcnt;i++){
			if(str[i]=='0'){
				if(i>0 && str[i-1]!='0'){
					outputStr[outcnt]=keibutton[str[i-1]-'0'][cnt];
					outcnt++;
				}
				cnt=-1;
			}
			else if(str[i]=='1'){
				if(cnt>=4){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else if(str[i]=='7' || str[i]=='9'){
				if(cnt>=3){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else{
				if(cnt>=2){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
		}
		cout<<outputStr<<endl;
	}
}

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

signed main() {
  int N;
  cin >> N;
  int h, n, w;
  bool finish = false;

  // 4/N = 1/h + 1/n + 1/w
  // 4 = N/h + N/n + N/w
  // 4hnw = Nnw + Nhw + Nhn
  // 4hnw - Nnw - Nhw = Nhn
  // 4 = N/h + N/n + N/h
  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      // h=i n=j
      int left = 4*i*j - N*j - N*i;
      int right = N*i*j;
      double leftw;
      if (right == 0) {
	leftw = 0;
      } else if (left == 0 || (left < 0 && right > 0) || (left > 0 && right < 0)){
	continue;
      } else {
	leftw = (double)right / left;
      }
      if (ceil(leftw) == floor(leftw) && leftw > 0) {
	h = i;
	n = j;
	w = leftw;
	finish = true;
	break;
      }
    }
    if(finish) break;
  }
  cout << h << " " << n << " " << w << endl;
  return 0;
}


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

int main() {
	int t;
	cin >> t;
	int ac=0, wa=0, tle=0, re=0;
	while(t--) {
	    string s;
	    cin >> s;
	    if(s == "AC") ac++;
	    else if(s == "WA") wa++;
	    else if(s == "TLE") tle++;
	    else re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
ll a[100000];

int main() {
	cin >> N;
	rep(i, N) cin >> a[i];

	ll sum, ct;
	int sign;
	ll ret ;

	sum = 0; sign = 1;ct = 0;
	rep(i, N){
		sum += a[i];
		if(sign == 1){
			if(sum <= 0) {ct += (1 - sum); sum = 1;}
		}
		else{
			if(sum >= 0) {ct += (1 + sum); sum = -1;}
		}
		sign *= -1;
	}
	ret = ct;
	fprintf(stderr, "%d\n", ct);

	sum = 0; sign = -1;ct = 0;
	rep(i, N){
		sum += a[i];
		if(sign == 1){
			if(sum <= 0) {ct += (1 - sum); sum = 1;}
		}
		else{
			if(sum >= 0) {ct += (1 + sum); sum = -1;}
		}
		sign *= -1;
	}
	ret = min(ret, ct);
	fprintf(stderr, "%d\n", ct);

	cout << ret << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define MOD 1000000007
long long mp[61];
long long ans[61];
int main(){
  int n;cin>>n;
  long long a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  long long mx = 0;
  for(int i = 0; n > i; i++){
    long long t = a[i];
    long long nw = 0;
    while(t!=0){
      if(t%2){
        mp[nw]++;
      }
      t/=2;
      nw++;
    }
    mx = max(nw,mx);
  }
  mx++;

  for(int i = 0; n > i; i++){
    long long t = a[i];
    int nw = 0;
    for(int j = 0; mx > j; j++){
      if(t%2){
        mp[nw]--;
        //0の個数を求める
        ans[nw] = (ans[nw]+(n-i-1)-mp[nw])%MOD;
      }else{
        ans[nw] = (ans[nw]+mp[nw])%MOD;
      }
      t/=2;
      nw++;
    }
  }
  long long ret = 0;
  int nw = 0;
  long long nwc = 1;
  for(int i = 0; mx > i; i++){

    ret = (ret+(ans[nw]*nwc))%MOD;
    nwc= (nwc*2)%MOD;
    nw++;
  }
  //cout << endl;
  cout << ret << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n,nn;
    cin >> n;
    nn=n;
    vector<int> a(0);
    while (true){
        a.push_back(n%3);
        n/=3;
        if (n==0) break;
    }
    nn=nn-a.at(0);
    int p=a.size()+1;
    vector<pair<pp,int>> f;
    rep(i,a.size()){
        int c=pow(3,i);
        rep(j,a.at(i)){
            f.push_back(mk(mk(i+1,p),nn+j*c));
        }
        
        if (i!=a.size()-1){
            nn-=a.at(i+1)*c*3;
            rep(j,3){
                f.push_back(mk(mk(i+1,i+2),j*c));
            }
        }
    }
    cout << p << " " << f.size() << endl;
    rep(i,f.size()){
        cout << f.at(i).first.first << " " << f.at(i).first.second << " " << f.at(i).second << endl;
    }
}


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

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

    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++) {
        int max = 0;
        int ind = 0;
        for (int j = 0; j < n; j++) {
            if (max < vec.at(j)) {
                max = vec.at(j);
                ind = j;
            }
        }
        
        if (i % 2 == 0) alice += max;
        else bob += max;

        vec.at(ind) = 0;
    }

    cout << (alice - bob) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = INF;
  for (ll i = 1; i <= sqrt(n); i++) {
    if (n%i == 0) {
      ans = min((i-1)+(n/i-1),ans);
    }
  }
  cout << ans << '\n';
}

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

signed main()
{
  int n; cin >> n;

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

  bool escape = false;

  for(int i = 0; escape == false ;++i) {
    for(int j = 0; j<n; ++j) {
      if(v[j]%2 == 1) {
        cout << i << endl;
        escape = true;
        break;
      }

      v[j] = v[j] / 2;
    }

  }

}

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

int A[2000];
int n;

int solve(int i, int m) {
  bool res;
  if ( m == 0 ) return true;
  if ( i >= n ) return false;
  res = solve( i + 1, m ) || solve( i + 1, m - A[i]);
  return res;
}

int main() {
  // input
  int q;
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> A[i];
  }
  cin >> q;
  int m[q];
  for ( int j = 0; j < q; j++ ) {
    cin >> m[j];
  }

  for ( int j = 0; j < q; j++ ) {
    if ( solve( 0, m[j] ) )cout << "yes" << endl;
    else cout << "no" << endl;
  }

}



Measured memory_bytes: 3112
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

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

const int N = 1000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, m, a[N], b[N], ps[N * N], ps2[N * N], invc[N * N], invr[N* N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		ps[a[i]] ++;
		invr[a[i]] = 1;
		if (ps[a[i]] == 2) return cout << 0 << endl, 0;
	}
	
	for (int i = 1; i <= m; i++){
		cin >> b[i];
		ps2[b[i]]++;
		invc[b[i]] = 1;
		if (ps2[b[i]] == 2) return cout << 0 << endl, 0;
	}
	for (int i = N * N - 2; i >= 1; i--){
		ps[i] += ps[i + 1];
		ps2[i] += ps2[i + 1];
	}
	int res = 1;
	for (int i = n * m; i >= 1; i--){
		if (invc[i] + invr[i] == 0){
			int ted = ps[i] * ps2[i];
			ted -= n * m - i;
			ted = max(0ll, ted);
			res = res * ted % MOD;
		}else if(invc[i] == 0){
			res = res * ps2[i] % MOD;
		}else if(invr[i] == 0){
			res = res * ps[i] % MOD;
		}
	}
	cout << res << endl;






	return 0;
}


Measured memory_bytes: 19840
#include<stdio.h>
int main()
{
  int n;
  scanf("%d",&n);
  if(n==22)
    printf("Christmas Eve Eve Eve");
  else if(n==23)
    printf("Christmas Eve Eve");
  else if(n==24)
    printf("Christmas Eve");
  else if(n==25)
    printf("Christmas");
  
  return 0;
  
}

Measured memory_bytes: 128
n=int(input())
A=[int(i) for i in input().split()]
B=[0]
for a in A:
  B.append(B[-1]+a)
m=B[-1]//2
import bisect
p=bisect.bisect_left(B,m)
l,r=B[p-1],B[p]
ans=min(abs(B[-1]-2*l),abs(B[-1]-2*r))
print(ans)



Measured memory_bytes: 26060
n = int(input())
s = input()

A = 1234567
MOD = 10000000000000007

def ok(length):
    rolling_hash = 0
    head = pow(A, length, MOD)
    occurence = {}
    for i in range(n):
        rolling_hash = (rolling_hash * A + ord(s[i])) % MOD
        if i - length >= 0:
            rolling_hash = (rolling_hash - head * ord(s[i-length])) % MOD
        if rolling_hash not in occurence:
            occurence[rolling_hash] = []
        occurence[rolling_hash].append(i)

    for key in occurence:
        if occurence[key][-1] - occurence[key][0] >= length:
            return True
    return False

bottom, top = 0, n

while top - bottom > 1:
    mid = (top + bottom) // 2
    if ok(mid):bottom = mid
    else: top = mid

print(bottom)

Measured memory_bytes: 4200
#C - Coloring Colorfully
S = list(input())
S_rev = list(reversed(S))
if len(S) == 1:
    count_min = 0
else:    
    count_front = 0
    for i in range(1,len(S)):
        if S[i] == S[i-1] == '1':
            S[i] = '0'
            count_front += 1
        elif S[i] == S[i-1] == '0':
            S[i] = '1'
            count_front += 1
    count_back = 0
    for j in range(1,len(S)):
        if S_rev[j] == S_rev[j-1] == '1':
            S_rev[j] = '0'
            count_back += 1
        elif S_rev[j] == S_rev[j-1] == '0':
            S_rev[j] = '1'
            count_back += 1
    count_min = min(count_front,count_back)
print(count_min)

Measured memory_bytes: 10352
#include<stdio.h>
int main()
{
	long long a[87],i,o;
	scanf("%lld",&o);
	for(a[0]=2,a[1]=1,i=2;i<=o;i++)
		a[i]=a[i-1]+a[i-2];
	printf("%lld\n",a[o]);
	return 0;
 } 

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n = 0, i = 0,base = 1;
	string ans;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	while (n != 0) {
		if (n%(base*2) == 0) {
			ans += '0';
		}
		else {
			ans += '1';
			n -= base;
		}
		i++;
		base *= -2;
	}
	for (ll i = ans.size()-1; i >= 0; i--) {
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A, B, C;
  tools::read(A, N);
  std::transform(A.begin(), A.end(), A.begin(), [](const i64& A_i) { return A_i - 1; });
  tools::read(B, N);
  tools::read(C, N - 1);

  i64 answer = 0;
  for (const i64& A_i : A) {
    answer += B[A_i];
  }
  for (auto it1 = A.begin(), it2 = ++A.begin(); it2 != A.end(); ++it1, ++it2) {
    if (*it1 + 1 == *it2) {
      answer += C[*it1];
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(x,y):
 x,y=r(x),r(y)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=c=0;b=[];k=(n+~m)*2
for v in a:d[r(i)]+=v,;i+=1
if k<1:print(0)
elif k>n:print('Impossible')
else:
 for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1
 print(c+sum(sorted(b)[:k]))

Measured memory_bytes: 35692
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// ??°?????????????¢??????????????????°??????
int main()
{
  ll N, Q, S, T; cin >> N >> Q >> S >> T;
  ll A[N+1]; FOR(i,0,N+1) cin >> A[i];
  ll temp[N+1]; temp[0] = A[0];
  FOR(i,1,N+1) temp[i] = temp[i-1] + ((A[i] - A[i-1]) >= 0 ? -S : T) * abs(A[i] - A[i-1]);
  ll d[N]; CLR(d); // ???????????????????????????(i??¨i+1???)i????????????????????????
  FOR(i,0,Q) {
    int l, r, x; cin >> l >> r >> x;
    ll prel = ((A[l] + d[l-1] - A[l-1]) >= 0 ? -S : T) * abs(A[l] + d[l-1] - A[l-1]);
    d[l-1] += x;
    ll aftl = ((A[l] + d[l-1] - A[l-1]) >= 0 ? -S : T) * abs(A[l] + d[l-1] - A[l-1]);
    ll dl = aftl - prel;
    ll dr = 0;
    if(r < N) {
      ll prer = ((A[r+1] + d[r] - A[r]) >= 0 ? -S : T) * abs(A[r+1] + d[r] - A[r]);
      d[r] -= x;
      ll aftr = ((A[r+1] + d[r] - A[r]) >= 0 ? -S : T) * abs(A[r+1] + d[r] - A[r]);
      dr = aftr - prer;
    }
    cout << temp[N] + dl + dr << endl;
    temp[N] = temp[N] + dl + dr;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;

    int cnt = 0;
    for(int i=0; i<s.size()-2; i++){
        if(s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C') cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char res[100];
	char *str;
	int j;
	
	str = (char *)malloc(sizeof(char) * 15);
	scanf("%s", str);
	j = 0;
	for(int i = 0; i <= strlen(str); i++){
		if(str[i] == '0')
			res[j] = '0';
		if(str[i] == '1')
			res[j] = '1';
		if(str[i] == 'B'){
			if(j == 0)
				continue;
			j--;
			continue;
		}

		j++;
	}
	
	res[j-1] = '\0';
	printf("%s", res);
	
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int A, B; cin >> A >> B;
  vector<bool> p(4);
  p.at(A) = true;
  p.at(B) = true;
  for (int i = 1; i <= 3; i++) {
    if (!p.at(i)) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<set<int>> st(26);
    for (int i = 0; i < n; i++) {
        st[s[i] - 'a'].insert(i);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int id;
            char c;
            cin >> id >> c;
            id--;
            st[s[id] - 'a'].erase(id);
            st[c - 'a'].insert(id);
            s[id] = c;
        }
        else {
            int l, r;
            cin >> l >> r;
            l--; r--;
            int res = 0;
            for (int j = 0; j < 26; j++) {
                auto it = st[j].lower_bound(l);
                if (it != st[j].end() && *it <= r) res++;
            }
            cout << res << '\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 24220
n,a,b = map(int,input().split())
s = 0
H = []
for _ in range(n):
    h = int(input())
    H.append(h)
from copy import deepcopy

from math import ceil
def count(x):
    Hc = deepcopy(H)
    cnt = 0
    for i in range(n):
        Hc[i] -= b*x
        if Hc[i]>0:
            cnt += (Hc[i]-1)//(a-b) + 1
    return cnt <= x

l,r = 0, max(H)//b + 1
while l < r:
    mid = (l+r)//2
    if count(mid):
        r = mid
    else:
        l = mid+1
print(r)

Measured memory_bytes: 122948
#include <stdio.h>
#include <stdlib.h>
int selctionSort(int *a, int n);
int main(int argc, char** argv) {
    int number;
    int readScan = scanf("%d", &number);
    int array[number];
    for(int i = 0; i< number; i++)
    {
        int reasScan = scanf("%d", &array[i]);
    }
    int count;
    count = selctionSort(array, number);
    for(int i= 0; i< number; i++)
    {    
        if(i<number-1)
        {
            printf("%d ", array[i]);
        }
        if(i==number-1)
        {
               printf("%d", array[i]);
        }
    }
    printf("\n");
   
    printf("%d\n", count);
    return (EXIT_SUCCESS);
}

int selctionSort(int *a, int n)
{
    int b;
    int count = 0;
    int min ;
    for (int i = 0; i < n-1; i++)
    {   
        min = i;
        for (int j = i+1; j < n; j++)
	{
            if (a[j] < a[min])
            { 
                min = j;
            }   
        }  
        b= a[i];
        a[i]=a[min];
        a[min]=b;
        if(min != i)
        {
            count++;
        }
    }
    return count;
}


Measured memory_bytes: 2140
for i in range(3):
    L  =list(map(int,input().split()))
    L0 = L[0] * 60 * 60 + L[1] * 60 + L[2]
    L1 = L[3] * 60 * 60 + L[4] * 60 + L[5]
    h = (L1 - L0) // (60 * 60)
    m = ((L1 - L0) % (60 * 60)) // 60
    s = ((L1 - L0) % (60 * 60)) % 60
    print(h,m,s)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define N 100000
using namespace std;
typedef long long LL;
int a[N+1];
int gap(int n, int k)
{
	if(n&1)
		return min(abs(n/2-k),abs(n/2+1-k));
	else
		return abs(n/2-k);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n; cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a,a+n);

	int ai = a[n-1];
	
	int aj = a[0];
	for(int j = 0; j < n; j++)
		if(gap(ai,a[j]) < gap(ai,aj))
			aj = a[j];

	cout<<ai<<" "<<aj<<endl;
	return 0;
}

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

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

            Console.ReadKey();
        }

        static void Solve()
        {
            var ans = Math.Pow(IO.GetInt(), 2);

            Console.WriteLine(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: 13140
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


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


signed main(){
  ll n,s; cin>>n>>s;
  if(n<s) return cout<<-1<<endl,0;
  if(n==s) return cout<<n+1<<endl,0;
  ll ans = -1;
  for(ll b=1;b<(ll)pow(n-s,0.5)+5;b++){
  //   // if(b==1) continue;
  //   // if(b>n) break;
    if(b!=1&&f(b,n)==s&&(ans==-1||ans>b)) ans=b;
    if((n-s)/b&&f((n-s)/b+1,n)==s&&(ans==-1||ans>b)) ans=(n-s)/b+1;
  }
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
vector<ll> memo(1000010,-1);

int main(){
    string s;cin>>s;
    int sz = s.length();
    ll sum = 0;
    rep(i,sz){
        sum = sum + (s[i]-'0');
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 11380
S = input()
T = input()
res = 'No'
if S == T:
  res='Yes'
count = len(S)
l = len(S)
while S != T and count > -1:
  count -= 1
  s = S[ l -1 ] + S[:(l-1)]
  S =s
 
  if S == T:
    res = 'Yes'
    break
print(res)
  

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int dp[2][2019] = {};
signed main(){
    fast_io();
    string s; cin >> s;
    constexpr int mod = 2019;
    vector<int>v; for(const auto& c : s)v.push_back(c - '0');
    int ans = 0;
    dp[1][v.front() * 10] = 1;
    dp[0][v.front()] = 1;
    for(int i = 1; i < v.size(); ++i){
        int crt = v[i];
        int inv = mod - v[i];
        ans += dp[i % 2][inv];
        for(int j = 0; j < 2019; ++j){
            dp[(i+1)%2][(j * 10 + crt * 10) % mod] = dp[i % 2][j];
        }
        dp[(i+1) % 2][crt * 10] += 1;
    }
    cout << ans << endl;;
}




Measured memory_bytes: 4380
//ue right > sita left OUT
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  vector<int> R(x);
  vector<int> L(x);
  for (int i = 0; i < x; i++) {
    string s;
    cin >> s;
    bool b = true;
    for (int j = 0; j < y; j++) {
      if (s[j] == '#') {
        R[i] = j;
        if (b) {
          b = !b;
          L[i] = j;
        }
      }
    }
    
    if (i > 0 && R[i-1] > L[i]) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const ll inf = 1e18+9;
int a[maxn];
int road[maxn];
int vis[maxn];

int main(){
	memset(vis,0,sizeof(vis));
	int n;
	ll k;
	scanf("%d %lld",&n,&k);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	int cnt = 1;
	int t = 1;
	vis[1] = 1;
	road[cnt++] = 1;
	int en = 0;
	while(1){
		int x = a[t];
		if(vis[x]){
			en = x;
			break;
		}else{
			vis[x] = 1;
			road[cnt++] = x;
			t = x;
		}
	}

	ll y = 0;
	for(ll i = 1;i < cnt;i++){
		if(road[i] == en){
			y = i;
			break;
		}
	}
	ll s = cnt - y;
	if(k <= y){
		printf("%d",a[road[k]]);
	}
	else{
		k -= y;
		k %= s;
		printf("%d",a[road[y+k]]);
	}
	return 0;
}


Measured memory_bytes: 6152
//package april2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
//	static long[] dp;
	static int n;
	static long MOD = (long)1e9+7;
	static long[] pre,dp;
//	static ArrayList<Integer>[] graph;
//	static HashSet<Integer> visited;
	static long[][] in;
//	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		FastReader scn = new FastReader();
		OutputStream out = new BufferedOutputStream ( System.out );
		n = scn.nextInt();
		in = new long[n][n];
		pre = new long[1<<n];
		for(int i =0;i<n;i++) {
			for(int j=0;j<n;j++) {
				in[i][j] = scn.nextLong();
			}
		}
		for(int mask = 0; mask < (1 << n); ++mask) {
//			System.out.println("Here "+mask);
	        for(int i = 0; i < n; ++i) {
//	        	System.out.println("    Here "+i);
	            if((mask & (1 << i))>0) {
//	            	System.out.println("Here "+mask+" "+i);
	                for(int j = i + 1; j < n; ++j) {
	                    if((mask & (1 << j))>0) {
	                        pre[mask] += in[i][j];
//	                        System.out.println("Here "+i+" "+j);
	                    }
	                }
	            }
	        }
	    }
		dp = new long[1<<n];
		Arrays.fill(dp, Long.MIN_VALUE);
		dp[0]=0;
		for(int mask=0;mask<(1<<n);mask++) {
			ArrayList<Integer> not_taken = new ArrayList<>();
			for(int i=0;i<n;i++) {
				if((mask&(1<<i))==0) {
					not_taken.add(i);
				}
			}
			rec(0,not_taken, dp[mask], mask,0);
		}
		out.write((dp[(1<<n)-1]+"\n").getBytes());
		out.close();
	}
	static void rec(int i, ArrayList<Integer> not_taken, long score_so_far, int mask, int group) {
		if(i==(int)not_taken.size()) {
			dp[mask] = Math.max(dp[mask], score_so_far+pre[group]);
			return;
		}
		
		rec(i+1, not_taken, score_so_far, mask, group);
		rec(i+1, not_taken, score_so_far, mask^(1<<not_taken.get(i)),group^(1<<not_taken.get(i)));
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 29108
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val map = mutableMapOf<String, Int>()
    for (i in 0 until n) {
        val s = readLine()!!
        if (!map.containsKey(s)) {
            map[s] = 0
        }
        map[s] = map[s]!! + 1
    }
    val max = map.values.max()!!
    val lst = map.keys.filter { map[it] == max }.toMutableList()
    lst.sort()
    for (s in lst) {
        println(s)
    }
}

Measured memory_bytes: 86604
/*ALDS1_2A*/

#include <iostream>
#define abs(a) (a<0?-(a):a)
#define square(x) ((x)*(x))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) ((a!=b)?(a+=b,b=a-b,a-=b):0)
#define This
#define True true
#define False false
#define null Null


using namespace std;

int bubbleSort(int[],int);
int main()
{
	int n;	
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	cout<<bubbleSort(num,n)<<endl;

	
}

int bubbleSort(int num[],int N){
	int count=0;
	bool flag=true;//逆の隣接要素が存在する
	while(flag){
		flag=false;
		for(int i=N-1;i>=1;i--){
			if(num[i-1]>num[i]){
				swap(num[i-1],num[i]);
				flag=true;
				count++;
			}
		}
	}
	for(int i=0;i<N-1;i++){
		cout<<num[i]<<" ";
	}
	cout<<num[N-1]<<endl;
	return count;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 998244353
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 200005

void solve()
{
	lli x;
	cin>>x;

	lli ans = x/500 ;
	x =x%500;

	ans = ans*1000;

	ans += (lli)(x/5)*5;

	cout<<ans;


}
 
int main()
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  
 	
	lli t;
	t=1;
 
	while(t--)
		solve();
 
}

Measured memory_bytes: 256
#include<stdio.h>

void Fibonacci(int);

int F[45];

int main(){
  int n;

  scanf("%d",&n);

  Fibonacci(n);

  printf("%d\n",F[n]);

  return 0;
}

void Fibonacci(int n){
  int i;
  F[0]=1;
  F[1]=1;

  for(i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];

}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b-1; i >= a; i--)
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

signed main(){
    int N; cin >> N;
    string S, T; cin >> S >> T;
    rep(i, 0, N){
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int Matrix[100][100];
    int i,j,k;
    while(1){
        scanf("%d",&k);
        if(k == 0){
            return 0;
        }
        for(i = 0;i < k;i++){
            for(j = 0;j < k;j++){
                scanf("%d",&Matrix[i][j]);
            }
        }
        for(i = 0;i < k;i++){
            for(j = 0;j < k;j++){
                Matrix[i][k] += Matrix[i][j];
                Matrix[k][k] += Matrix[i][j];
            }
        }
        for(j = 0;j < k;j++){
            for(i = 0;i < k;i++){
                Matrix[k][j] += Matrix[i][j];
            }
        }
        for(i = 0;i < k+1;i++){
            for(j = 0;j < k+1;j++){
                    printf("%5d",Matrix[i][j]);
            }
            printf("\n");
        }
        for(i = 0;i < 100;i++){
            for(j = 0;j < 100;j++){
                Matrix[i][j] = 0;  //行列のリセットのつもり//
            }
        }
    }
    return 0;
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N,A,B,C,D;
    string S;
    cin>>N>>A>>B>>C>>D>>S;
    if(C<D){
        for(int i=B;i<=D-3;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        for(int i=A;i<=C-3;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    else{
        bool jump=false;
        for(int i=B;i<=D-1;i++){
            if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.'){
                jump=true;
            }
        }
        if(S[B-2]=='.' && S[B]=='.') jump=true;
        if(!jump){
            cout<<"No"<<endl;
            return 0;
        }
        for(int i=A;i<=C-3;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int N;
  cin >> N;
  ll ans=0;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin >> A[i];
  sort(A.begin(),A.end());
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int k=j+1;
      while(k<N&&A[k]<A[i]+A[j]){
        k++;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	int n;
	cin>>n;
	cout<<n/2-(n%2==0)<<endl;
}


Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    answer();
   }
   static void answer()
     {
       Scanner sc = new Scanner(System.in);
       
       while(true)
       {
         int h = sc.nextInt();
         
         int w = sc.nextInt();
         
         if(h == 0 && w == 0)break;
         
         for(int i = 0; i < h; i ++)
         {
           for(int j = 0; j < w; j ++)
           {
             System.out.printf("#");
           }
           System.out.println();
         }
         System.out.println();
       }
     }
 }
    


Measured memory_bytes: 60128
#include<stdio.h>
int main(){
int x[3], i, j, tmp, c;
  scanf("%d %d %d",&x[0], &x[1], &x[2]);
  c = x[2];
  
  for (i=0; i<3; ++i){
    for(j=i+1; j<3; ++j){
     if(x[i] > x[j]){
       tmp = x[i];
       x[i] = x[j];
       x[j] = tmp;
     }
    }
  }
  
  if(x[1] == c){
   puts("Yes"); 
  }
  else {
   puts("No"); 
  }
  
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int A, B;
  int cnt=0;
  int enter=0;

  cin >> A;
  cin >> B;

  if(B==1){
    cout << cnt<< endl;
    return 0;
  }

  cnt++;
  enter+=A;//1つめのタップ
  while(enter<B){
    enter+=(A-1);
    cnt++;
  }
  cout << cnt<< endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a = 0, b = 0, c = 0;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'a') {
            a = 1;
        }
        else if (s[i] == 'b') {
            b = 1;
        }
        else if (s[i] == 'c') {
            c = 1;
        }
    }
    if (a == 1 && b == 1 && c == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
S = input()
Length = len(S)
count = 0

if Length % 2 == 0:
    for i in range(0, int(Length / 2)):
        if S[i] != S[Length - i - 1]:
            count += 1
else:
    for i in range(0, int((Length - 1) / 2)):
        if S[i] != S[Length - i - 1]:
            count += 1
            
print(count)


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

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> total(N, 0);
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') total[i] = total[i-1] + 1;
        else total[i] = total[i-1];
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << total[r-1] - total[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[4];
	scanf("%s",s);
	if((s[0]=='a' || s[1]=='a' || s[2]=='a')	&&
	(s[0]=='b' || s[1]=='b' || s[2]=='b')	&&
	(s[0]=='c' || s[1]=='c' || s[2]=='c'))	{
	printf("Yes\n");
	}
	else printf("No\n");
return 0;
}

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

using namespace std;

const int N = (int)1e6 + 5;

int main() {
  int a, b;
  cin >> a >> b;
  if (a != 1 && b != 1)
    cout << 1 << " ";
  if (a != 2 && b != 2)
    cout << 2;
  if (a != 3 && b != 3)
    cout << 3;
  return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = list(b)
d = 0
e = c.count(".")
f = 0
for i in range(len(c)+1): #左からi個を白にする　0<=i<=len(c)
    if i == 0:
        ans = e
    else:
        if c[i-1] == ".":
            d = d + 1 #dは左からi個のうちの白の個数を指す
        f = (i - d) + (e - d) #左側の(i-d)個の黒を白にし、右側(e-d)個の白を黒にする
        ans = min(ans, f)
print(ans)

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

int main() {
  int n;
  cin >> n;
  map<char, int> cnt;
  rep (i, 3) cin >> cnt['A'+i];
  vector<string> s(n);
  for (string &i : s) cin >> i;
  string ans;
  rep (i, n) {
    char t1 = s[i][0], t2 = s[i][1];
    if (cnt[t1] == 0 and cnt[t2] == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (cnt[t1] < cnt[t2]) swap(t1, t2);
    char t3 = 'A'+3-(t1-'A')-(t2-'A');
    //while (t3 == t1 or t3 == t2) t3++;
    if (cnt[t1] == 1 and cnt[t2] == 1 and cnt[t3] == 0) {
      if (i + 1 < n) {
        if (t1 == s[i+1][0] or t1 == s[i+1][1]) {
          swap(t1, t2);
        }
      }
    }
    ans += t2;
    cnt[t2]++;
    cnt[t1]--;
  }

  cout << "Yes" << endl;
  for (char i : ans) cout << i << endl;
  return 0;
}


Measured memory_bytes: 6680
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n; cin >> n;
  bool all_even = true;
  for (ll i = 0; i < n; i++) {
    ll a; cin >> a;
    if (a % 2 != 0) all_even = false;
  }
  cout << (all_even ? "second" : "first") << endl;

  return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}

	void solve(){
		int N,i,j,p,q;
		string word;
		cin>>word;
		N=word.size();
		for(i=0;i<N;i++){
			if(word[i]=='?')word[i]='D';
		}	
		cout<<word;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


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

int main(){
    ll n,m;
    cin >> n>> m;
    ll arr[n],i,sum=0;
    for(i=0;i<n;i++){
    cin >> arr[i];
    sum=sum+arr[i];
    }
    
    sort(arr,arr+n,greater<int>());
    if((float)arr[m-1]>=(float)sum/(4*m))
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
    
}

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

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

using namespace std;

int a[200005];

int main(){
  int n;
  cin >> n;
  REP(i, n){
    cin >> a[i];
    if(i==0 && a[i] != 0){ cout << -1 << endl; return 0; }
    if(i>0 && a[i] - a[i-1] > 1) { cout << -1 << endl; return 0; }
  }
  long long res=0;
  for(int i=n-1; i>=0; i--){
    if(a[i] == 0) continue;
    int val = a[i];
    res += val;
    for(int j=val; j>0; j--) if(a[i-val+j]-j==0) a[i-val+j] = 0; else break;
  }
  cout << res << endl;
}

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

int main() {
    ll n;
    cin >> n;
    if (n & 1) {
        puts("0");
        return 0;
    }
    ll cnt = n / 10;
    n /= 10;
    while (n) {
        n /= 5;
        cnt += n;
    }
    cout << cnt << endl;
}

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

const int N = 305;

int n, k, a[N];

using ll = long long;

const ll inf = 0x3f3f3f3f3f3f3f3f;

ll dp[N][N];

int main() {
	scanf("%d %d", &n, &k);
	if (n == k) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	int up = n-k;
	for (int i = 0; i <= n; i ++) for (int j = 0; j <= up; j ++) dp[i][j] = inf;
	dp[0][0] = 0;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= up; j ++) {
			ll &res = dp[i][j];
			for (int k = 0; k < i; k ++) if (dp[k][j-1] < inf) {
				res = min(res, dp[k][j-1] + (a[k] < a[i] ? a[i] - a[k] : 0));
			}
		}
	}
	ll ans = inf;
	for (int i = 1; i <= n; i ++) ans = min(ans, dp[i][up]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4492
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> A(N);
	rep(i,N){
		cin>>A[i];
		A[i] -= i+1;
	}
	sort(all(A));
	if(N%2 == 1){
		ll ans = 0;
		int medi = A[N/2];
		rep(i,N){
			ans += abs(A[i] - medi);
		}
		cout<<ans<<endl;
	}else{
		ll ans_a = 0, ans_b;
		int medi_a = A[N/2], medi_b = A[N/2-1];
		rep(i,N){
			ans_a += abs(A[i] - medi_a);
			ans_b += abs(A[i] - medi_b);
		}
		cout<<min(ans_a, ans_b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    A,B,C,K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if K<=A:
        print(K)
    elif A<K<=A+B:
        print(A)
    elif A+B<K:
        print(A-(K-A-B))




if __name__ == "__main__":
    main()

Measured memory_bytes: 68096