akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> a;
int n = 0, k = 0;
bool check(int x) {
  int res = 0;
  for(auto& cur : a)
    res += (cur + x - 1) / x - 1;
  return (res <= k);
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  cin >> n >> k;

  a.resize(n);

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

  int l = 1, r = 1e9 + 42;

  while(l < r) {
    int mid = (l + r) / 2;
    if(check(mid)) r = mid;
    else l = mid + 1;
  }

  cout << (check(l) ? l : r);

  return 0;
}
/*

*/


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

int main(){
  int n, m;
  string s, a;
  cin >> n >> s;
  
if(n%2==0){
  m = (int)(0.5*s.size());
  a = "Yes";
 
  for(int i=0,j=m ; j<s.size(); i++,j++){
    if(s.at(i)!=s.at(j)){
      a = "No";
      break;
    }
  }
}
else{
  a = "No";
}  
  
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

input()
t = defaultdict(lambda: 0)
for e in [int(i) for i in input().split()]:
  t[e] += 1
ans = []
for k, v in t.items():
  if v >= 2:
    if v >= 4:
      ans.extend([k, k])
    else:
      ans.append(k)
ans.sort()
if len(ans) < 2:
  print(0)
else:
  print(ans[-1]*ans[-2])


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

int main(){
  string s;
  cin >> s;
  int flag=1;
  if(s[0]==s[1]&&s[1]==s[2]) flag = 0;
  cout << (flag?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0, w = 0 ;
	char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

ll n, ans ;

void dfs(ll now, int a3, int a5, int a7) {
	if (now > n) return ;
	if (a3 && a5 && a7) ans++ ;
	dfs(now * 10 + 7, a3, a5, 1) ;
	dfs(now * 10 + 5, a3, 1, a7) ;
	dfs(now * 10 + 3, 1, a5, a7) ;
}

signed main(){
	scanf("%lld", &n) ;
 	dfs(0, 0, 0, 0) ;
	printf("%d\n", ans) ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


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


int main() {

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin>>n;

    map<int, int> m;
    int arr[n];
    for (int i=0; i<n; i++){
        int curr;
        cin>>curr;
        arr[i] = curr;
        m[curr]++;
    }

    long long int total = 0;
    for (int i=1; i<=n; i++){
        long long int n = m[i];
        total += 1LL*n*(n-1)/2;
    }
    for (int i=1; i<=n; i++){
        long long int n = m[arr[i-1]];
        long long int ans = total - 1LL*n*(n-1)/2 + 1LL*((n-1)*(n-2))/2;
        cout<<ans<<endl;    
    }

}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
vector<string> S;
ll H, W;
bool used[400][400];
ll dh[] = {1, 0, -1, 0};
ll dw[] = {0, 1, 0, -1};
P dfs(ll h, ll w){
    used[h][w] = 1;
    P ret = P(S[h][w] == '.', S[h][w] == '#');
    for(ll i = 0; i < 4; i++){
        ll nh = h + dh[i];
        ll nw = w + dw[i];
        if(!(0 <= nh && nh < H &&
             0 <= nw && nw < W)) continue;
        if(S[nh][nw] == S[h][w]) continue;
        if(used[nh][nw]) continue;
        P tmp = dfs(nh, nw);
        ret.first += tmp.first;
        ret.second += tmp.second;
    }
    return ret;
}

int main(){
    cin >> H >> W;
    S.resize(H);
    for(auto &s : S) cin >> s;
    ll ans = 0;
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++){
        if(used[i][j]) continue;
        auto tmp = dfs(i, j);
        ans += tmp.first * tmp.second;
    }
    cout << ans << endl;
    return 0;
}


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

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

    int a[4][3][10];
    for (size_t i = 0; i < 4; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            for (size_t k = 0; k < 10; k++)
            {
                a[i][j][k] = 0;
            }
        }
    }

    for (size_t i = 0; i < n; i++)
    {
        ll b, f, r, v;
        cin >> b >> f >> r >> v;
        a[b - 1][f - 1][r - 1] += v;
    }

    for (size_t i = 0; i < 4; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            for (size_t k = 0; k < 10; k++)
            {
                cout << " ";
                cout << a[i][j][k];
            }
            cout << endl;
        }
        if (i != 4 - 1)
        {
            cout << "####################" << endl;
        }
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
  int L, N;
  cin >> L >> N;
  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    int x, w;
    cin >> x >> w;
    sum += x*w;
  }

  if ( sum == 0 ) cout << 0 << endl;
  else {
    cout << 1 << endl;
    if ( sum > 0 ) cout << -1 << " " << sum << endl;
    else cout << 1 << " " << -1*sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

double N,K;

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

    double ans=0;
    repn(i,N){
        double x=max(ceil(log2(K/i)),0.0);
        ans+=1/pow(2,x);
    }
    ans/=N;

    cout<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#define INFL (1LL << 60)

using namespace std;
typedef long long ll;

struct game {
    ll p1, p2, ans;
    game *g1, *g2;
    bool flag;
    game() {
        p1 = 0, p2 = 0, ans = -1, g1 = this, g2 = this, flag = false;
    }
};

struct roundRobin {
    vector< vector<game> > m;
    roundRobin() {};
    roundRobin(ll n) {
        m = vector< vector<game> >(n + 1, vector<game>(n + 1));
        for (ll i = 1; i <= n; ++i) for (ll j = 1; j <= n; ++j) {
            m.at(i).at(j).p1 = i, m.at(i).at(j).p2 = j, m.at(i).at(j).g1 = &m.at(i).at(j), m.at(i).at(j).g2 = &m.at(i).at(j);
        }
    }
    void resize(ll n) {
        *this = roundRobin(n);
    }
    void previousGame(ll np1, ll np2, ll pp1, ll pp2) {
        if (pp1 > pp2) swap(pp1, pp2);
        if (np1 < np2) m.at(np1).at(np2).g1 = &m.at(pp1).at(pp2);
        else m.at(np2).at(np1).g2 = &m.at(pp1).at(pp2);
    }
    ll solve(ll p1, ll p2) {
        if (p1 > p2) swap(p1, p2);
        if (m.at(p1).at(p2).ans >= 0) return m.at(p1).at(p2).ans;
        else if (m.at(p1).at(p2).flag) return INFL;
        m.at(p1).at(p2).flag = true;
        ll a = 0;
        if (m.at(p1).at(p2).g1 != &m.at(p1).at(p2)) a = max(a, solve(m.at(p1).at(p2).g1->p1, m.at(p1).at(p2).g1->p2));
        if (m.at(p1).at(p2).g2 != &m.at(p1).at(p2)) a = max(a, solve(m.at(p1).at(p2).g2->p1, m.at(p1).at(p2).g2->p2));
        return m.at(p1).at(p2).ans = a + 1;
    }
};

int main() {
    ll n, a, p, ans = 0;
    scanf("%lld", &n);
    roundRobin t(n);
    for (ll i = 1; i <= n; ++i) {
        scanf("%lld", &p);
        for (ll j = 2; j < n; ++j) {
            scanf("%lld", &a);
            t.previousGame(i, a, i, p);
            p = a;
        }
    }
    for (ll i = 1; i <= n; ++i) for (ll j = 1; j <= n; ++j) ans = max(ans, t.solve(i, j));
    printf("%lld\n", ans >= INFL ? -1 : ans);
    return 0;
}


Measured memory_bytes: 47488
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

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

    bool flag=false, ans=false;
    REP(i,s.size()){
        if(s[i]=='C')   flag=true;
        if(s[i]=='F' and flag)  ans=true;
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

bool f(int x, int y, vector<int> v)
{
  swap(v[x], v[y]);
  bool res = true;
  for (int i = 1; i < v.size(); ++i) if (v[i] - v[i-1] < 0) res = false;

  return res;
}

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

  int n;
  cin >> n;

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

  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (f(i, j, a)) {
        cout << "YES\n";
        return (0);
      }
    }
  }

  cout << "NO\n";

  return (0);
}


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

using namespace std;

int a[100005];

int main() {
	a[0] = 0;
	for (int i = 1; i < 100005; ++i) {
		a[i] = i + a[i - 1];
	}
	int x;
	scanf("%d", &x);
	for (int i = 0; i < 100005; ++i)
	{
		if (x <= a[i]) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 1000000
#define MOD 1000000007

int main(){
  int N;
  cin>>N;
  vector<int> a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a.at(i);
  }

  vector<int> b(N+1);
  int M=0;
  for(int i=N;i>0;i--){
    int counter=0;
    for(int j=2;i*j<=N;j++){
      if(b.at(i*j)==1){
        counter++;
      }
    }
    b.at(i)=(counter+a.at(i))%2;
    if(b.at(i)==1){
      M++;
    }
  }

  cout<<M<<endl;
  for(int i=1;i<=N;i++){
    if(b.at(i)==1){
      cout<<i<<" ";
    }
  }
  cout<<endl;
}


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

using namespace std;

int main()
{
    ll n,k,i,j,a,b,ans=0;
    cin>>n>>k;
    vector<pair<ll, ll > >v;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        v.push_back({a,b});

    }
    sort(v.begin(), v.end());
    j=v.size();
    for(i=0;i<j;i++)
    {
        ans+=v[i].second;
        if(ans>=k)
        {
            cout<<v[i].first<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
from typing import List


def answer(n: int, a: List[int]) -> int:
    next_value = 1
    count = 0
    for _ in range(n):
        next_value = a[next_value - 1]
        count += 1
        if next_value == 2:
            return count

    return -1


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(answer(n, a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14088
#include <stdio.h>
#include <math.h>

int main(void)

{
  int x,y,z;

  double S,L;

  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&z);

  S=x*y*sin(z*M_PI/180)/2;

  L=sqrt(pow(x,2)+pow(y,2)-2*x*y*cos(z*M_PI/180))+x+y;

  printf("%lf\n",S);
  printf("%lf\n",L);
  printf("%lf\n",2*S/x);

  return 0;
}



Measured memory_bytes: 2080
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
  cin>>n;
  int a[100000];
  set<int> st;
  map<int, int> mp;
  for(int i=0; i<n; i++){
    cin>>a[i];
    st.insert(a[i]);
  }
  int i0=0;
  for(auto x:st){
    mp[x]=i0;
    i0++;
  }
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<ll> rnd1(2, MOD-2);
  set<int> ans;
  for(int i=1; i<=n; i++) ans.insert(i);
  for(int t=0; t<10; t++){
    ll b=rnd1(mt);
    ll bp[100000];
    bp[0]=1;
    for(int i=1; i<i0; i++) bp[i]=bp[i-1]*b%MOD;
    ll h=0, hr=0;
    for(int i=1; i<=n; i++){
      h+=bp[mp[a[i-1]]];
      hr+=bp[mp[a[n-i]]];
      h%=MOD; hr%=MOD;
      if(h!=hr) ans.erase(i);
    }
  }
  int j=0;
  for(auto x:ans){
    if(j==ans.size()-1) cout<<x<<endl;
    else cout<<x<<" ";
    j++;
  }
	return 0;
}


Measured memory_bytes: 13376
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f(int x, int n, int mod = (int)1e9 + 7) {
    int ret = 1;
    while (n > 0) {
        if ((n & 1)) {
            ret = ret * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

void run(){
    int n;
    cin>>n;
    vi d(n);
    rep(i,n)cin>>d[i];
    if(d[0]){
        cout<<0<<endl;
        return;
    }
    Rep(i,1,n){
        if(d[i]==0){
            cout<<0<<endl;
            return;
        }
    }
    int m=998244353;
    int ans=1;
    SORT(d);
    vi x;
    int c=1;
    Rep(i,1,n){
        if(d[i-1]==d[i])c++;
        else if(d[i-1]+1==d[i]){
            if(!d[i-1])continue;
            x.pb(c);
            c=1;
        }
        else{
            cout<<0<<endl;
            return;
        }
    }
    x.pb(c);
    rep(i,x.size()-1){
        ans=ans*f(x[i],x[i+1],m)%m;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2168
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	ll a = 0, b = 0, c = 0, d = 0;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	ll bd = b*d;
	ll ac = a*c;
	ll ad = a*d;
	ll bc = b*c;
	ll ans = MAX(bc, MAX(ad, MAX(bd, ac)));
	printf("%lld\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll h, w;
	cin >> h >> w;
	if (h == 1 | w == 1)
		cout << 1 << endl;
	else
		cout << h * w / 2 + (h * w) % 2 << endl;
	return 0;
}

Measured memory_bytes: 3636
n, k = gets.chomp.split.map(&:to_i)
cnt = Array.new(k, 0)
res = Array.new(k, 0)

k.times do |i|
  cnt[i] = (n + i) / k
end

k.times do |i|
  j = (- i) % k
  if i == j
    res[i] = cnt[i] ** 3
  elsif (2 * i) % k == 0
    res[i] = ((cnt[i] + 1) * cnt[i] / 2) * cnt[j]
  else
    res[i] = 0
  end
end
puts res.inject(:+)

Measured memory_bytes: 17356
import java.util.Scanner;

public class Main {
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int sum = 0;
			int bottom = 1;
			int count = 0;
			int i=1;
			while(i < n){
				if(sum <= n){
					sum += i++;
					if(sum == n){
						count++;
					}
				}
				else if(n < sum){
					for(int j=bottom;;j++){
						if(sum == n){
							count++;
							bottom = j;
							break;
						}
						else if(sum < n){
							bottom = j;
							break;
						}
						else sum -= j;
					}
				}
			}//end for
			System.out.println(count);
		}
	}
	public static void main(String[] args) {
		//new AOJ2197().run();
		new Main().run();
	}
}

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

int main() {
  int n,min = 200000;
  string s;
  cin >> n >> s;
  vector<int>w(n+1,0);
  vector<int>b(n+1,0);
  for(int i = 1;i <= n;i++){
    if(s[i-1] == '#') b[i]++;
    if(i != n) b[i+1] = b[i];
  }
  for(int i = n-1;i >= 0;i--){
    if(s[i] == '.') w[i]++;
    if(i != 0) w[i-1] = w[i];
  }
  for(int i = 0;i < n+1;i++){
    if(min > w[i]+b[i]) min = w[i]+b[i];
  }
  cout << min << endl;
}


Measured memory_bytes: 2180
n ,y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }

    let mut min = std::isize::MAX;
    for i in -100..101 {
        let mut sum = 0;
        for na in &a {
            sum += (na - i) * (na - i);
        }
        if sum < min {
            min = sum;
        }
    }

    println!("{}", min);
}


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

int main(){
  long long h, w;
  cin >> h >> w;
  if(h == 1 && w == 1) cout << 1 << endl;
  else if(h == 1 || w == 1) cout << h*w-2 << endl;
  else cout << (h-2)*(w-2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200001];
int main() {
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", a+i);
        a[i] -= i;
    }
    sort(a, a+n);
    int m = a[n/2];
    long long ans = 0;
    for(int i=0; i<n; i++) {
        ans += abs(a[i] - m);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int N,A;
    cin >>N>>A;
    bool exist=0;
    for (int a = 0; a <=N ; a++) {
      int total=a*2+(N-a)*4;
      if(A==total){
        exist=1;
        break;
      }
    }
    if(exist){
      std::cout << "Yes" << '\n';
    }else{
      std::cout << "No" << '\n';
    }
}


Measured memory_bytes: 3612
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
int main(){
	int n ;
	cin>>n;
	ll cnt=0;
	ll a[n+2];
	ll b[n+2];
	memset(a , 0 , sizeof(a));
	memset(b, 0 , sizeof(b));
	for(int i=1;i<=n+1;i++)
		cin>>a[i];
	for(int j=1;j<=n;j++)
		cin>>b[j];
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=b[i]){
			sum=sum+a[i];
			b[i]=b[i]-a[i];
			//cout<<-9;
			a[i]=0;
			//cout<<b[i]<<" ";
		}
		else{
			sum=sum+b[i];
			b[i]=0;
		}
	//	cout<<b[i]<<"\n";
		if(b[i]>0){
			if(a[i+1]<=b[i]){
			sum=sum+a[i+1];
			
			b[i]=b[i]-a[i+1];
			a[i+1]=0;
		}
		else{
			sum=sum+b[i];
			a[i+1]=a[i+1]-b[i];
		}
	//	cout<<sum<<"\n";

	}
	//cout<<sum;


}
cout<<sum;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int N = 200010;
int n,d,A;
ll fw[N];
int nx[N];
ii a[N];
void up(int x, ll v){
    while (x <= N){
        fw[x] += v;
        x += x&(-x);
    }
}
ll sum(int x){
    ll res = 0;
    while (x){
        res += fw[x];
        x -= x&(-x);

    }
    return res;
}
main(){
    scanf("%lld%lld%lld",&n,&d,&A);
    for (int i = 1; i <= n; i++){
        scanf("%lld%lld",&a[i].first,&a[i].second);
    }
    sort(a+1,a+n+1);
    ll ans = 0;
    int j = 1;
    for (int i = 1; i <= n; i++){
        up(i,a[i].second);
        up(i+1,-a[i].second);
    }
    for (int i = 1; i <= n; i++){
        while (j <= n && a[j].first-a[i].first <= 2*d) j++;
        nx[i] = j;
        ll curhp = sum(i);
        if (curhp <= 0) continue;
        //printf("%d %lld %lld\n",i,curhp,nx[i]);
        ll num = (curhp-1)/A+1;
        ans += num;
        ll hprem = num*A;
        up(i,-hprem);
        up(nx[i],hprem);
    }
    printf("%lld",ans);

}


Measured memory_bytes: 6528
#include<cstdio>
using namespace std;
int n;
inline int rd()
{
	char tmp=getchar();
	int ddd=0;
	while('0'>tmp&&tmp<'9')
	{
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd;
}
int main()
{
	n=rd();
	printf("%d",3*n*n);
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'a')continue;
		int x = 'z' - s.at(i) + 1;
		if (x <= k) {
			s.at(i) = 'a';
			k -= x;
		}
	}
	if (k == 0) {
		cout << s << endl;
		return 0;
	}
	if (k >= 26)k %= 26;
	s.at(s.length() - 1) = s.at(s.length() - 1) + k;
	cout << s << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a + b + c;
	if (sum <= 21) {
		cout << "win";
	}
	else {
		cout << "bust";
	}
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := []int{}
	for i := 0; i < N; i++ {
		num := sc.nextInt()
		if num%2 == 0 {
			A = append(A, num)
		}
	}
	ans := 0
	for _, num := range A {
		for num%2 == 0 {
			num /= 2
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll left[n],use[n];
    rep(i,n){
        left[i] = 3;
        use[i] = 0;
    }
    ll ans = 1;
    rep(i,n){
        if(a[i] == 0){
            ans *= left[a[i]];
            left[0]--;
        }else{
            ans *= min(left[a[i]],left[a[i]] - left[a[i]-1]);
            left[a[i]]--;
        }
        
        ans %= mod;
    }
    cout << ans % mod << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define double long double
#define stp setprecision
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inp(a) for(auto&i:a) cin>>i;
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bi back_inserter
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define mpii map<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
#define matrix vector<vector<int>>
#define mxe *max_element
#define mne *min_element
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+7;
int binexp(int a,int b){
	if(!b)
		return 1;
	int p=binexp(a,b>>1);
	p=p*p%mod;
	if(b&1)
		p=p*a%mod;
	return p;
}
void a_b_l(){
    int n;
    cin>>n;
    if(n==3){
        cn(1);
        return;
    }
    int ans=0;
    for(int r=0;r<=n;r++){
        if(r-1<0)
            continue;
        int p=n-2*r-1;
        if(p<=0)
            continue;
        int ncr[p+1];
        ncr[0]=1;
        forp(i,1,p){
            int k=ncr[i-1];
            k*=p-i+1;
            k%=mod;
            k*=binexp(i,mod-2);
            k%=mod;
            ncr[i]=k;
        }
        if(r-1>p)
            continue;
        ans+=ncr[r-1];
        ans%=mod;
    }
    cn(ans);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    while(t--)
    	a_b_l();
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int NUM;
    int COUNT;
};

int main() {
    int n; cin >> n;
    map<int, int> odd;
    map<int, int> even;
    int evencount=0,oddcount=0;
    rep(i,n){
        int num; cin >> num;
        if(i%2==0) {
            evencount++;
            even[num]++;
        }
        else {
            oddcount++;
            odd[num]++;
        }
    }
    int ans;
    vector<P> E;
    for(auto e: even) {
        E.push_back({e.first,e.second});
    }
    vector<P> O;
    for(auto o: odd) {
        O.push_back({o.first,o.second});
    }

    sort(E.begin(),E.end(),[](P a, P b){return(a.COUNT>b.COUNT);});
    sort(O.begin(),O.end(),[](P a, P b){return(a.COUNT>b.COUNT);});
    if(E[0].NUM==O[0].NUM){
        ans = min(evencount-E[0].COUNT+oddcount-O[1].COUNT,evencount-E[1].COUNT+oddcount-O[0].COUNT);
    }else {
        ans = evencount-E[0].COUNT+oddcount-O[0].COUNT;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6136
#include<iostream>
#include<vector>
int main(){
  int X,N,up,under;
  std::cin>>X>>N;
  std::vector<int>a(N);
  for(int i=0;i<N;i++){
    std::cin>>a[i];
  }
  up=X;
  under=X;
  int b=N,c=N;
  while(true){
    b=N;
    c=N;
    for(int i=0;i<N;i++){
      if(under==a[i]&&up==a[i]){
        b--;
        c--;
        continue;
      }
      if(up==a[i]){
        b--;
        continue;
      }
       if(under==a[i]){
         c--;
         continue;
       }
    }
    //std::cout<<b<<" "<<c<<std::endl;
    //std::cout<<up<<" "<<under<<std::endl;
    if(c==N){
      std::cout<<under<<std::endl;
      return 0;
    }
    if(b==N){
      std::cout<<up<<std::endl;
      return 0;
    }
    up++;
    under--;
  }
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> AA(N,0);
    for(ll i=0;i<N;++i)cin>>AA[i];
    map<ll,ll> M;
    for(auto p: AA)M[p]++;
    if(M.size()>2){
        prt("No");
        return 0;
    }
    if(M.size()==1){
        if(M[AA[0]]==N&&(AA[0]==N-1||(AA[0]<=N/2&&AA[0]>=1))){
            prt("Yes");
        }
        else prt("No");
        return 0;
    }
    P A, B;
    bool check=0;
    for(auto p: M){
        if(!check){
            check=1;
            A=p;
        }
        else {
            B=p;
        }
    }
    if(B.first-A.first!=1){
        prt("No");
        return 0;
    }
    ll i=N-B.first;
    if(i+1<=B.second&&2*i>=B.second){
        prt("Yes");return 0;
    }
    prt("No");

    return 0;
}



Measured memory_bytes: 10124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  while(cin >> n && n) {
    int a[6]={1,2,3,6,5,4};
    string s;
    while(n--) {
      cin >> s;
      if(s[0]=='n') {
        swap(a[0],a[4]);
        swap(a[3],a[4]);
        swap(a[1],a[3]);
      } else if(s[0]=='e') {
        swap(a[0],a[2]);
        swap(a[2],a[3]);
        swap(a[3],a[5]);
      } else if(s[0]=='s') {
        swap(a[0],a[1]);
        swap(a[1],a[3]);
        swap(a[3],a[4]);
      } else {
        swap(a[0],a[5]);
        swap(a[3],a[5]);
        swap(a[2],a[3]);
      }
    }
    cout << a[0] << endl;
  }
  return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	long long a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	long long ans=0;

	if(2*c<=a+b){
		ans+=2*c*min(x,y);
		long long left=max(x,y)-min(x,y);

		if(max(x,y)==x){
			if(2*c<=a) ans+=2*c*left;
			else ans+=a*left;
		}else{
			if(2*c<=b) ans+=2*c*left;
			else ans+=b*left;
		}
	}else{
		ans+=x*a+y*b;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3612
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a[200000+2];
int query(int A,int B){
	return a[A] xor a[B];
}

int main(){
	fastio;
	cin>>n;
	rb(i,1,n) cin>>a[i];
	if(n==2){
		cout<<a[2]<<" "<<a[1]<<endl;
	}
	else{
		int res=0;
		rb(i,1,n)
			res ^=a[i];
		rb(i,1,n){
			cout<<(res^a[i])<<" ";
		}
	}
	return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
 
typedef long long lglg;

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], lglg n) {
    string result = "{";
    for (lglg i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

lglg check(string t) {
    lglg a=0,b;
    for (char c : t) if (c=='<') ++a;
    b = t.size()-a;
    if (b < a) swap(a,b);
    return (a-1)*a/2+b*(b+1)/2;
}

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

    string s; cin >> s;
    lglg n = s.size();
    
    string t; t += s[0];
    lglg result = 0;
    for (lglg i=1; i<n; ++i) {
        if (s[i-1] == '>' && s[i] == '<') {
            result += check(t);
            t.clear();
        }
        t += s[i];
    }
    result += check(t);
    cout << result;
}

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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
int test;
void slove()
{
	int n; cin >> n;
	vector<int> a(n + 1);
	for(int i = 1;i <= n ;i ++)cin>> a[i];
	sort(a.begin() + 1,a.begin() + n + 1);
	ll ans = 0;
	for(int i = 1;i <= n - 1;i ++)
	{
		ans += a[n - i / 2];
	}	
	cout << ans << endl;
} 
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

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

int A[128],N;
int main() {
	A[0] = 1;
	cin >> N;
	while(N != 0) {
		for(int i=0; i<N+1; ++i) {
			if(A[i] ==0) {
				A[i] = A[i-1];
				if(i>1) A[i] += A[i-2];
				if(i>2) A[i] += A[i-3];
			}
		}
		cout << ((A[N]+9)/10 + 364)/365 << endl;
		cin >> N;
	}
}

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

int main() {
  string S, T;
  cin >> S >> T;

  int count = 0;

  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]){
      count = count + 1;
    }
  }
  cout << count << endl;
}

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

int n, t;

int min_cost(vector<pair<int, int>> &r) {
    sort(r.begin(), r.end());
    for (auto p : r) {
        if (p.second <= t) {
            return p.first;
        }
    }

    return -1;
}

int main() {
    cin >> n >> t;
    vector<pair<int, int>> r(n);
    for (int i = 0; i < n; i++) {
        int cost, time; cin >> cost >> time;
        r[i] = make_pair(cost, time);
    }
    
    int ans = min_cost(r);
    if (ans == -1) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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


int main(){
    int n,c=0;
    string s;
    cin>>n>>s;
    rep(i,n-2){
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a = 1,b = n;
    for(int i = sqrt(n);i>=1;i--){
        if(n%i == 0){
            a = i;
            b = n/i;
            break;
        }
    }
    cout<<a+b-2;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a;cin>>a;cout<<(1000-(a%1000))%1000<<endl;
}


Measured memory_bytes: 3616
main :: IO ()
main=getLine>>=print.solve.map read.words

solve :: [Integer] -> Integer
solve [n,x]
  | 2 * x < n = go (n+2*x) x (n - 2 * x)
  | 2 * x == n = 3 * x
  | otherwise = go n x (n-x)
  where
    go acc x y
      | x > y = go acc y x
      | x == y = x
      | otherwise = case divMod y x of
          (q, 0) -> acc + 2 * q * x - x
          (q, r) -> go (acc + 2 * q * x) x r

Measured memory_bytes: 508
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
ans=[]
cand=[xy[i][0]+xy[i][1] for i in range(n)]
#print(cand)
ans.append(max(cand)-min(cand))
cand=[-xy[i][0]+xy[i][1]for i in range(n)]
ans.append(max(cand)-min(cand))
cand=[-xy[i][0]-xy[i][1] for i in range(n)]
ans.append(max(cand)-min(cand))
cand=[xy[i][0]-xy[i][1] for i in range(n)]
ans.append(max(cand)-min(cand))
print(max(ans))

Measured memory_bytes: 156596
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;
int main() {
	long long int ans = 9999999999,a=0;
	char S[11];
	cin >> S;
	for (int i = 0; i < strlen(S)-2; i++)
	{
		a = 100 * ((int)S[i] - 48)+ 10 * ((int)S[i+1] - 48)+((int)S[i+2] - 48);
		ans = min(ans, abs(a - 753));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {

    int a,b,c;
    
    scanf("%d %d %d", &a, &b, &c);

    if (a<b) {
	if(b<c)	
	printf("Yes\n");
        else
        printf("No\n");
    } else {
        printf("No\n");
    } 
     
    return 0;
} 

Measured memory_bytes: 580
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def div2_n(x):
    n = 0
    while x % 2 == 0:
      if x % 2 == 0:
          n += 1
          x >>= 1
    return n
  
n, m = map(int, input().split())
a = list(map(int, input().split()))

a2 = [i//2 for i in a]
n0 = div2_n(a2[0])
for i in range(1,n):
    if div2_n(a2[i]) != n0:
        print(0)
        exit()

a2_l = lcm(*a2)
print(m//a2_l - m//(a2_l*2))


Measured memory_bytes: 20820
# 貪欲法 の解法
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
k = I()
ans = 1
for _ in range(n):
    ans = min(ans * 2, ans + k)

print(ans)


Measured memory_bytes: 9064
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
int cnt[2][105];
int h, w;
bool flag[110][110];

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  vector<Int> d(n);
  using P = pair<Int, Int>;
  vector<P> vp;
  vp.emplace_back(1,0);
  for(Int i=0;i<n;i++){
    Int t=s[i]-'0';
    if(vp.empty()||vp.back().first!=t) vp.emplace_back(t,0);
    vp.back().second++;
  }
  if(!vp.back().first) vp.emplace_back(1,0);
  
  Int m=vp.size();
  vector<Int> v(m+1,0);
  for(Int i=0;i<m;i++) v[i+1]=v[i]+vp[i].second;
  Int ans=0;
  if(k*2+1>m) ans=n;
  
  for(Int i=0;i+k*2+1<=m;i+=2)    
    chmax(ans,v[i+k*2+1]-v[i]);

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


Measured memory_bytes: 3568
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s, w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe"<<endl;
    }
    else
    {
        cout<<"safe"<<endl;
    }



    return 0;
}


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

double dp[16][9];
int k, x, y, z;
int b[9][4]={
	{1,3,-1,-1},
	{ 0,2,4,-1 },
	{ 1,5,-1,-1 },
	{ 0,4,6,-1 },
	{ 1,3,5,7 },
	{ 2,4,8,-1 },
	{ 3,7,-1,-1 },
	{ 4,6,8,-1 },
	{ 5,7,-1,-1 }
};
int main() {
	while (cin >> k, k) {
		memset(dp, 0, sizeof(dp));
		char a, b, c; cin >> a >> b >> c;
		dp[0][a - 'A'] = 1;
	    y = b - 'A'; z = c - 'A';
		double S = 0;
		for (int i = 0; i < k; i++) {
			for (int j = 0; j < 9; j++) {
				for (int l = 0; l < 4; l++) {
					if (::b[j][l] == -1 || ::b[j][l] == z) {
						dp[i + 1][j] += dp[i][j] * 0.25;
					}
					else {
						dp[i + 1][::b[j][l]] += dp[i][j] * 0.25;
					}
				}
			}
		}
		printf("%.10lf\n", dp[k][y]);
	}
}

Measured memory_bytes: 2996
#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll s;
	cin >> s;
	ll x = ceil(sqrtl(s));
	ll y = (s + x - 1) / x;
	ll rem = x * y - s;
	if (rem == 0)
		cout << 0 << " " << 0 << " " << x << " " << 0 << " " << 0 << " " << y
		     << endl;
	else
		cout << 0 << " " << 0 << " " << x << " " << 1 << " " << rem << " " << y
		     << endl;
}

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

int main() {
  int N;
  cin >> N;
  bool B = true;
  
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    
    if(s == "Y"){
      B = false;
    }
  
  }
  
  if(B){
    cout << "Three" << endl;
  }
  
  else{
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256