akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

const int MOD = (int) 1e9 + 7;
const int A = 0, C = 1, G = 2, T = 3;

int dp[110][4][4][4];

void Add(int &a, int b) {
    a += b;
    if (a >= MOD)a -= MOD;
}

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

    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                if (k == A and j == G and i == C)dp[3][i][j][k] = 0;
                else if (k == G and j == A and i == C)dp[3][i][j][k] = 0;
                else if (k == A and j == C and i == G)dp[3][i][j][k] = 0;
                else dp[3][i][j][k] = 1;
            }
        }
    }

    for (int i = 3; i < N; i++) {
        for (int p = 0; p < 4; ++p) {
            for (int _p1 = 0; _p1 < 4; ++_p1) {
                for (int _p2 = 0; _p2 < 4; ++_p2) {
                    for (int _p3 = 0; _p3 < 4; ++_p3) {
                        if (p == C and _p2 == A and _p1 == G)continue;
                        if (p == C and _p2 == G and _p1 == A)continue;
                        if (p == G and _p2 == A and _p1 == C)continue;
                        if (p == C and _p3 == A and _p2 == G)continue;
                        if (p == C and _p3 == A and _p1 == G)continue;
                        Add(dp[i + 1][p][_p1][_p2], dp[i][_p1][_p2][_p3]);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                Add(ans, dp[N][i][j][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[100000];
  int i,count;
  scanf("%s",s);
  
    if(s[0]=='1'){
      for(i=1;i<100000;i++){
        if(i%2==0&&s[i]=='0'){
          count++;
        }
        if(i%2==1&&s[i]=='1'){
          count++;
        }
        if(s[i]=='\0')break;
      }  
    }
       if(s[0]=='0'){
      for(i=1;i<100000;i++){
        if(i%2==0&&s[i]=='1'){
          count++;
        }
       if(i%2==1&&s[i]=='0'){
          count++;
       }
        if(s[i]=='\0')break;
      }
       }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 256
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = 10 ** 18
for i in range(2**n):
  algo = [0] * m
  cost = 0
  for j in range(n):
    if (i >> j) & 1:
      book = ca[j]
      cost += book[0]
      for k,v in enumerate(book[1:]):
        algo[k] += v
  if all([j >= x for j in algo]):
    ans = min(ans,cost)
if ans == 10 ** 18:
  print(-1)
else:
  print(ans)

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

int main()
{
  long long a,v,b,w,t;
  long long sp,de;
  cin >> a >> v >> b >> w >> t;

  sp=v-w;
  de=b-a;

  if(de<0)de*=-1;

  if(de<=sp*t) cout << "YES\n";
  else cout << "NO\n";

  return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

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

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

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt");
    if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    string S, T; cin >> S >> T;
    string ans;
    rep(i, N){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

bool ac[1000005];
int wa[1000005];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) ac[i] = false, wa[i] = 0;
	int acs = 0, was = 0;
	while (m--)
	{
		int x; scanf("%d", &x);
		char c = '\0' ; while (c != 'A' && c != 'W') c = getchar();
		getchar();
		if (c == 'A' && !ac[x]) ac[x] = true, acs++, was += wa[x];
		if (c == 'W') wa[x]++;
	}
	printf("%d %d\n", acs, was);
}


Measured memory_bytes: 2560
# coding: utf-8
l, r = map(int, input().split())
tmp = 2019
if (l%2019 > r%2019) or r - l >= 2019:
    print(0)
else:
    for i in range(l%2019, r%2019):
        for j in range(i + 1, r%2019 + 1):
            if (i * j) % 2019 < tmp:
                tmp = (i * j) % 2019
    print(tmp)


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

int main()
{
    vector<int> bags(3);
    for (int &b : bags)
    {
        cin >> b;
    }

    sort(bags.begin(), bags.end());
    if (bags[2] == bags[1] + bags[0])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

int main(){
    ll n;
    cin >> n;
    bool honest[15] = {true};
    int shougen[15][15][15];
    int a[15];
    for (int i = 0; i < n;i++)
    {
        cin >> a[i];
        for (int j = 0; j < a[i];j++)
        {
            int temp1,temp2;
            cin >> temp1 >> temp2;
            shougen[i][j][0] = temp1;
            shougen[i][j][1] = temp2;
        }
    }
    int ans = 0;
    int d[15] = {};
    for(int i=0;i<pow(2,n);i++){
        //cout << i << endl;
        int dec = i;
        int j = 0;
        int count = 0;
        for (j = 0; dec > 0;j++)
        {
            d[j] = dec % 2;
            dec = dec / 2;
            if(d[j] == 1)
                count++;
        }
        for (j; j < n;j++)
            d[j] = 0;
            //for (int foo = 0; foo < j; foo++)
            {
                //cout << d[foo] << ",";
            }
        //cout << endl;
        bool flag = false;
        for (int k = 0; k < n;k++)
        {
            
            if(d[k] == 1)
            {
                //cout << "a[k] ="  <<a[k]<<", k = "<<k<<endl;
                for (int l = 0; l < a[k]; l++)
                {
                    //cout << "d[" << k << "]=1 , " << d[shougen[k][l +1][0]] << " , " << shougen[k][l +1][0] << " , " << shougen[k][l +1][1] << endl;
                    if(d[shougen[k][l][0] - 1] == 0 && shougen[k][l][1] == 1)
                    {
                        //cout << "TypeA";
                        flag = true;
                        break;
                    }
                    else if (d[shougen[k][l][0] - 1] == 1 && shougen[k][l ][1] == 0)
                    {
                        //cout << "TypeB";
                        flag = true;
                        break;
                    }
                        if (flag)
                            break;
                }
            if(flag)
                break;
            }
        if(flag)
            break;
        }
        if(ans<count && !flag)
            ans = count;
        if(flag)
            ;
            //cout << "mujyun" << endl;

    }
    cout << ans;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D ;
  int L = A + B;
  int R = C + D;
    
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L < R ){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  long long N, M;
  std::cin >> N >> M;
  if (N > 1 && M > 1) {
    std::cout << N * M - (N - 1) * 2 - (M - 1) * 2 << std::endl;
  } else {
    if (N == 1 && M == 1) {
      std::cout << 1 << std::endl;
    } else if (N == 1) {
      std::cout << M - 2 << std::endl;
    } else {
      std::cout << N - 2 << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007

int n;
int a[200000];
int b[200000];

int ad[200000];
int bd[200000];


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

	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];

	rep(i, n) {
		ad[i] = a[i] ^ a[(i - 1 + n) % n];
		bd[i] = b[i] ^ b[(i - 1 + n) % n];
	}

	long long p17n = 1;
	rep(i, n - 1) p17n = p17n * 17 % MOD;

	long long rh1 = 0, rh2 = 0;
	rep(i, n) {
		rh1 *= 17;
		rh1 += ad[i];
		rh1 %= MOD;

		rh2 *= 17;
		rh2 += bd[i];
		rh2 %= MOD;
	}

	rep(i,n) {
		if (rh1 == rh2) {
			cout << i << ' ' << (a[i] ^ b[0]) << endl;
		}
		rh1 -= ad[i] * p17n;
		rh1 = (rh1 % MOD + MOD) % MOD;
		rh1 *= 17;
		rh1 += ad[i];
		rh1 = (rh1) % MOD;
	}


	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>

int main (int argc, char *argv[])
{
	int x = 0;
	std::string S;

	std::cin >> S;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+')
			x++;
		else 
			x--;
	}
	std::cout << x << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
//*******************************************************************************
//       DoublyLinkedList                 
//*******************************************************************************
//     < ???????????? >
//       DoublyLinkedList ??? struct ????????¨??????????£??????? STL ??? list ????????¨?????????
//*******************************************************************************
#include <iostream>
using namespace  std;

struct StList
{
  int  m_nKey;
  StList* m_poPrev;
  StList* m_poNext;
  
  StList() :
    m_nKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int nNum, StList& roHead) :
    m_nKey(nNum), m_poPrev(&roHead), m_poNext(roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList& roHead, StList& roTrail)
{
  char acCmd[80];
  int nMaxCmd, nNum;

  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> acCmd;
    if (acCmd[0] == 'i')
    {
      cin >> nNum;
      StList* poList = new StList(nNum, roHead);
      roHead.m_poNext->m_poPrev = poList;
      roHead.m_poNext = poList;
    }
    else if (acCmd[6] == 'F')
    {
      StList* poList = roHead.m_poNext;
      if (poList != &roTrail)
      {
        poList->m_poNext->m_poPrev = poList->m_poPrev;
        roHead.m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[6] == 'L')
    {
      StList* poList = roTrail.m_poPrev;
      if (poList != &roHead)
      {
        roTrail.m_poPrev = poList->m_poPrev;
        poList->m_poPrev->m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[0] == 'd')
    {
      cin >> nNum;
      StList* poList = roHead.m_poNext;
      while (poList != &roTrail)
      {
        if (poList->m_nKey == nNum)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList& roHead, StList& roTrail)
{
  StList* poList = roHead.m_poNext;
  while (poList != &roTrail)
  {
    if (poList != roHead.m_poNext) cout << " ";
    cout << poList->m_nKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

 ll n, count=0, ans=0;
 ll a,p;
 string s;
 
 cin >> a;
 cin >> p ;
 count = a*3 + p;
 ans=count/2;
 


 cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	queue<int> halo;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		halo.push(x);
	}
	
	int count=1,mini=halo.front(),maxi=halo.front();
	halo.pop();
	
	while(!halo.empty())
	{
		int now= halo.front();
		if(now<=mini and now<=maxi)
		{
			count++;
		}
		
		if(now>maxi)
		{
			maxi=now;
		}
		
		if(now<mini)
		{
			mini=now;
		}
		
		halo.pop();
	}
	
	cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char s[1001];
int mark[1001];
signed main()
{
	int n,k;
	scanf("%s",s+1);
	scanf("%d",&k);
	n=strlen(s+1);
	int mark=0;
	for(int i=1;i<=n;i++)
	{
		if(i!=1&&s[i]!=s[i-1])
			mark=1;
		s[i+n]=s[i];
	}
	if(!mark)
	{
		printf("%lld",1ll*n*k/2);
		return 0;
	}
	if(s[1]!=s[n])
	{
		long long ans=0;
		for(int i=1;i<=n;i++)
		{
			int tot=1;
			while(i<n&&s[i+1]==s[i])
				i++,tot++;
			ans+=tot/2;
		}
		printf("%lld",1ll*ans*k);
		return 0;
	}
	long long ans=0;
	for(int i=1;i<=2*n;i++)
	{
		int tot=1;
		while(s[i+1]==s[i])
			i++,tot++;
		if(i>n&&i!=2*n)
			ans+=tot/2;
	}
	ans=1ll*ans*(k-1);
	for(int i=1;i<=n;i++)
	{
		int tot=1;
		while(i<n&&s[i+1]==s[i])
			i++,tot++;
		ans+=tot/2;
	}
	printf("%lld",ans);
	return 0;
}
/*
aqsqqsqqwww
10
*/

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]
t = [(0, 1), (0, -1), (1, 0), (-1, 0)]
ans = True
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            for h1, w1 in t:
                h2 = h1 + h
                w2 = w1 + w
                if H <= h2 or W <= w2 or h2 < 0 or w2 < 0:
                    continue
                if S[h2][w2] == '#':
                    break
            else:
                ans = False
print('Yes' if ans else 'No')



Measured memory_bytes: 9152
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ll long long
#define il inline
const ll inf = 1e9;

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 2000100

int n = read();
char s[N];
map<char,int>mp;
int main() {
	scanf("%s",s+1);
	for(int i = 1; i <= n; ++i) mp[s[i]]++;
	if(mp['R']>mp['B']) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
from collections import Counter

s = input()
s_len = len(s)
c = Counter(s)
ans = float('inf')
for k in c.keys():
    tmp = list(s)
    cnt = 0
    while True:
        if len(set(tmp)) == 1:
            break
        for i in range(len(tmp)-1):
            if tmp[i] == k:
                tmp[i] = k
            elif tmp[i+1] == k:
                tmp[i] = k
            else:
                continue
        else:
            tmp = tmp[:-1]
            cnt += 1
    ans = min(ans,cnt)
print(ans)

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






int main() {
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<2*a<<endl;
    return 0;
  }
  else{
    cout<<max(a,b)*2-1<<endl;
    return 0;
  }
}


Measured memory_bytes: 384
#!/usr/bin/env python3
#ABC110 B

n,m,x,y = list(map(int,input().split()))
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
mx = max(X)
my = min(Y)
if my - mx > 0 and x < my <= y and x < mx <= y:
    print('No War')
else:
    print('War')


Measured memory_bytes: 38384
#include <iostream>
#include <string>
typedef long long LL;
using namespace std;
int cnt[26];
int main () {
//    freopen("test.txt", "r", stdin);
    string s;
    cin >> s;
    LL ret = 1;
    for (char c : s) {
        for (int i = 0; i < 26; i++) {
            if (i == c-'a') continue;
            ret += cnt[i];
        }
        cnt[c-'a']++;
    }
    cout << ret << endl;

}

Measured memory_bytes: 640
import scala.io.StdIn

object Main extends App {
  val Array(a, b, c) =  StdIn.readLine().split(" ").map(_.toInt)

  def solve(a: Int, b: Int, c: Int): Int = {
    List(a, b, c).combinations(2).map(_.sum).min
  }

  println(solve(a, b, c))
}
  



Measured memory_bytes: 25528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (ll)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n,a[222222];

int I_Love_Hashimoto_Kanna() {
  fastio;
  cin>>n;
  FOR(i,0,n){
  	cin>>a[i];
  	a[i]-=(i+1);
	}
	sort(a,a+n);
	int b=a[n/2];
  ll ans=0;
  FOR(i,0,n)ans+=abs(a[i]-b);
  Tone(ans);
  
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	int N;
	std::cin >> N;

	for (int i = 1; i <= 9; ++i)
	{
		for (int j = 1; j <= 9; ++j)
		{
			if (N == i * j)
			{
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "No" << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char s[110];
bool flag;
int main()
{
	cin>>s+1;
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='C') flag=1;
		if(s[i]=='F'&&flag==1) {cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    A, B = (int(i) for i in input().split())

    def f(C):
        if C <= 0:
            return [0]*40
        arr = []
        for digit in range(1, 41):
            cur = (C+1)//(2**digit)
            cur *= 2**(digit-1)
            y = (C+1) % (2**digit)
            y -= 2**(digit-1)
            if y > 0:
                cur += y
            arr.append(cur)
            # digit桁目の1の個数
        return arr

    ans = 0
    i = 0
    fA = f(A-1)
    fB = f(B)
    for a, b in zip(fA, fB):
        ans += ((b-a) % 2)*(2**i)
        i += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38320
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int frt(int n){
  int tmp = n;
  while(n != 0){
    tmp = n % 10;
    n /= 10;
  }
  return tmp;
}

int bck(int n){
  return n % 10;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<vector<int> > cnt(10, vector<int>(10, 0));
  for(int i = 1; i <= N; i++){
    cnt[frt(i)][bck(i)]++;
  }
  int ans = 0;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,sum=1;
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if(b>=0) cout<<"Zero"<<endl;
	else if((abs(b)-abs(a))%2!=0) cout<<"Positive"<<endl;
	else cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); i++)
#define RFOR(i, a, b)  for(int i = (a); i > (b); i--)
#define rep(i, n)	   for(int i = 0; i < (n); i++)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define foritr(itr, c) for(auto itr = begin(c); itr != end(c); itr++)
#define SZ(a)		   ((ll) a.size())

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll a, ll b, ll c) {
	if((b - a) == (c - b)) printf("YES");
	else printf("NO");
}

int main() {
	ll c;
	ll a;
	ll b;
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	solve(a, b, c);
	return 0;
}


Measured memory_bytes: 256
str1 = input() #標準入力
str1 = str1.replace("apple","kari") #"apple"を"kari"に変換する
str1 = str1.replace("peach","apple") #"peach"を"apple"に変換する
str1 = str1.replace("kari","peach") #"kari"を"peach"に変換する
print(str1) #出力


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

#pragma GCC optimize ("O3")

using namespace std;

int n, k, q;
int ans[100005];
int main() {
  cin >> n >> k >> q;
  for(int i = 0; i < q; i++) {
    int wadiya;
    cin >> wadiya;
    wadiya--;
    ans[wadiya]++;
  }
  for(int i = 0; i < n; i++) {
    cout << ((q-ans[i] < k) ? "Yes" : "No") << endl;
  }
}


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var result = false;

            s += s;

            for (var i = 0; i < t.Length; i++)
            {
                var r = s.Substring(i, t.Length);
                if (r == t)
                {
                    result = true;
                }
            }

            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 25816
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int R,C,N;
struct point{
  int x,y,num;
  void read(){
    scanf("%d%d",&x,&y);
  }
  bool onedge(){
    if(x==0||y==0||x==R||y==C)return true;
    else return false;
  }
  int typ()const{
    if(x==0)return 1;
    else if(y==0)return 2;
    else if(x==R)return 3;
    else return 4;
  }
  bool operator <(const point &B)const{
    int t1=typ(),t2=B.typ();
    if(t1!=t2)return t1<t2;
    else if(t1==1)return y>B.y;
    else if(t1==2)return x<B.x;
    else if(t1==3)return y<B.y;
    else return x>B.x;
  }
}P[maxn][2];
point P2[maxn*2];int tot=0;
int stk[maxn*2],top=0;
int main(){
  scanf("%d%d%d",&R,&C,&N);
  for(int i=1;i<=N;++i){
    P[i][0].read();P[i][1].read();P[i][0].num=P[i][1].num=i;
    if((P[i][0].onedge())&&(P[i][1].onedge())){
      P2[++tot]=P[i][0];P2[++tot]=P[i][1];
    }
  }
  sort(P2+1,P2+tot+1);
  //  for(int i=1;i<=tot;++i)printf("%d ",P2[i].num);
  for(int i=1;i<=tot;++i){
    if(top&&stk[top-1]==P2[i].num)--top;
    else stk[top++]=P2[i].num;
  }
  if(top)printf("NO\n");
  else printf("YES\n");
  return 0;
}


Measured memory_bytes: 5248
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n)]
dp[0]=l[0]
for i in  range(1,n):
    dp[i][0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])

print(max(dp[-1]))


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

int main(){
	int H, W;

	while(1){
		cin >> H >> W;

		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;

}


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

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll; 

int n, k, h[200500];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }

    sort(h + 1, h + n + 1);
    reverse(h + 1, h + n + 1);
    
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (k > 0) {
            k--;
        }
        else {
            ans += h[i];
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int s = 1;
    rep(i, N){
        if(i!=0){
            s *= K-1;
        }else{
            s *= K;
        }
    }
    printf("%d\n", s);
    return 0;
}

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

using namespace std;
#define int long long 
#define N 666666
int arr[N],a[N],b[N];
#define pi 6.28318530717958623200
signed main(){
	int n;
	cin>>n;
	printf("%.20f",pi*n);
	return 0;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    int K,A,B;
    cin >> K;
    cin >> A >> B;

    bool a = false;
    for (int i = A; i <= B; ++i) {
        if(i%K == 0){
            a = true;
            break;
        }
    }

    if (a){
        cout << "OK" << endl;
    } else{
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.readline())
A = list(sys.stdin.readline().rstrip())
B = list(sys.stdin.readline().rstrip())
C = list(sys.stdin.readline().rstrip())

A = np.array(A, dtype='U1')
B = np.array(B, dtype='U1')
C = np.array(C, dtype='U1')


def count(a, b, c):
    if a == b == c:
        return 0
    if a == b or b == c or c == a:
        return 1
    return 2


ans = 0
for a, b, c in zip(A, B, C):
    ans += count(a, b, c)
print(ans)


Measured memory_bytes: 14672
#include<stdio.h>

int main(void){

	double a,b,c,d,e,f;
        double x,y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){

		if(b!=0){
		    x=((e*c/b)-f)/((e*a/b)-d);
		}
		else{
                x=c/a;
		}

		if(a!=0){
		y=((d*c/a)-f)/((d*b/a)-e);
		}
		else{
			y=c/b;
		}

		x=x*1000,y=y*1000;
		if(x>0){
			x=(double)(int)(x+0.5);
		}
		else{
			x=(double)(int)(x-0.5);
		}
		if(y>0){
			y=(double)(int)(y+0.5);
		}
		else{
			y=(double)(int)(y-0.5);
		}
		x=x/1000;y=y/1000;
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}



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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;cin>>r;
    cout<<r*r<<endl;
    return 0;
}


Measured memory_bytes: 3584
n= int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

satisfaction = 0

copy = A[0]
for a in A:
  satisfaction += B[a-1]

  if a-copy == 1:
    satisfaction += C[a-2]
  
  copy = a

print(satisfaction)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> adj[100001];
bool vis[100001];
void dfs(ll ind, stack<ll>& st){
	vis[ind] = true;
	for(ll i=0;i<adj[ind].size();i++){
		if(!vis[adj[ind][i]])
			dfs(adj[ind][i], st);
	}
	st.push(ind);
}
int main(){
	ll n, m;
	cin>>n>>m;
	ll i;
	ll x, y;
	for(i=0;i<=n;i++){
		adj[i].clear();
		vis[i] = false;
	}
	for(i=0;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}
	stack<ll> st;
	for(ll i=1;i<=n;i++){
		if(vis[i]==false)
			dfs(i, st);
	}
	vector<ll> dist(n+1, -1e15);
	dist[st.top()] = 0;
	while(!st.empty()){
		ll ind = st.top();
		st.pop();
		if(dist[ind]!=-1e15){
			for(ll i=0;i<adj[ind].size();i++){
				if(dist[adj[ind][i]]<1+dist[ind])
					dist[adj[ind][i]] = 1+dist[ind];
			}
		}
		else{
			dist[ind] = 0;
			for(ll i=0;i<adj[ind].size();i++){
				if(dist[adj[ind][i]]<1+dist[ind])
					dist[adj[ind][i]] = 1+dist[ind];
			}	
		}
	}
	cout<<*max_element(dist.begin(), dist.end())<<"\n";
	return 0;
}

Measured memory_bytes: 13140
fun main(args: Array<String>){
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }

    val S = Array(M){ readLine()!!.split(" ").map { it.toInt() }.drop(1) }
    val P = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0
    fun bitSearch(bit: String){
        if(bit.length == N+1){
            S.indices.map { i ->
                S[i].map { bit[it] }.count { it == '1' }.let { it % 2 == P[i] }
            }.all { it }.let { if(it) ans++ }
        }else{
            bitSearch(bit+"0")
            bitSearch(bit+"1")
        }
    }
    bitSearch("0")
    println(ans)
}

Measured memory_bytes: 42452
#include<iostream>
#include<math.h>
#include<cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include <vector>
#include<iomanip>
#include<queue>
#include<string>
#include<bitset>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;

const int N = 200;
const ll INF = (1LL << 62) - 1;
ll dist[N][N];
vector <int> rr;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i< n; i++)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int X[] = new int[N];
    int Y[] = new int[N];
    for (int i = 0; i < N; i++) {
        X[i] = sc.nextInt();
        Y[i] = sc.nextInt();
    }
    int ans=0;
    for (int i = 0; i < N-2; i++) {
    	if(X[i]==Y[i]&&X[i+1]==Y[i+1]&&X[i+2]==Y[i+2]) {
    		ans++;
    	}
    }
    if(ans>0) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 36080
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n;
		cin >> n;
		cout << (n + 1)/2 << '\n';
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f(int x)
{
    int c=0;
    while(x){
        x/=10;
        c++;
    }
    return c;
}
int main ()
{

    int n;
    cin >> n;vector<int>V(n),A(n);
    for(int i=1;i<=n;i++){
        cin >> V[i-1];
    }
    A = V;
    sort(V.begin(),V.end());
    if(A==V){
        cout<<"Yes\n";
    }
    else{
        A[0]--;
        int pr = A[0];
        for(int i=1;i<n;i++){
            if(pr<A[i]){
                    A[i]--;
            }
            else if(pr>A[i]){
                cout<<"No";
                return 0;
            }
            pr=A[i];
        }
        cout<<"Yes";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
#define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end())
template<typename A,typename B> inline bool chmax(A &a,const B &b){if(a<b){a=b;return 1;}return 0;}
template<typename A,typename B> inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;}

signed main() {

    int N;
    cin >> N;

    map<string, ll> mp;

    REP(i, N) {
        string S;
        cin >> S;
        SORT(S);
        mp[S]++;
    }

    ll res = 0;
    EACH(e, mp) {
        ll a = e.second;
        res += a * (a - 1) / 2;
    }

    cout << res << endl;

}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define N 200011
typedef struct{
	int to,nxt;
}edge;
edge e[N<<2];
int head[N<<2],sg[N],n,a,b,cnt;
void add(int a,int b){
	cnt++;
	e[cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int fa){
	sg[u]=0;
	for(int i=head[u];i!=-1;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u);
		sg[u]^=(sg[v]+1);
	}
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&a,&b);
		add(a,b);add(b,a);
	}
	dfs(1,0);
	if(sg[1]==0) printf("Bob\n");else printf("Alice\n");
}

Measured memory_bytes: 10624
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define pf psuh_front
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define eb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 2 * 1e3 + 7;
const ld pi = 3.14159265359;
const int INF = 1e20 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

string s;

deque < char > ans;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> s;

  for(int i = 0; i < s.size(); i++){

    char x = s[i];

    if(x == '0'){
      ans.pb('0');
    }
    else if(x == '1'){
      ans.pb('1');
    }
    else{
      if(ans.size() != 0){
        ans.pop_back();
      }
    }
  }

  for(auto i : ans){
    cout << i;
  }
}


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

int n;

int main(){
    scanf("%d",&n);int ans=0;
    for (int i=1;i<=n;i++){
        int x,k;scanf("%d%d",&x,&k);
        while (x%k>0) 
            x-=((x%k-1)/(x/k+1)+1)*(x/k+1);
        ans^=x/k;
    }
    if (ans) 
        puts("Takahashi");else 
        puts("Aoki");
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,a,b;
    scanf("%d",&N);
    if(10<=N&&N<=99)
    {
    a=N/10;
    b=N%10;
    if(a==9||b==9)
        {printf("Yes");}
    else
    {printf("No");}
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<string.h>
#include <vector>

using namespace std;

int main() {
	int k, n,aa;
	cin >> k >> n;
	vector<int> a;
	int b = 0,c;
	for (int i = 0; i < n; i++) {
		cin >> aa;
		a.push_back(aa);
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] - a[i] > b) {
			b = a[i + 1] - a[i];
			//c = i;
		}
	}
	if (k - a[n-1] + a[0] > b) {
		b = k - a[n-1] + a[0];
		//c = i;
	}
	cout << k - b << endl;

	return 0;
}

Measured memory_bytes: 1528
x, n = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
i = 0
while 1:
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x+i)
        break
    else:
        i += 1

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

using namespace std;

typedef long long ll;

struct Devide{ll n, sum;};

bool operator < (const Devide &e, const Devide &f){
    return e.n*f.sum < f.n*e.sum;
}

ll keta(ll n){
    ll tmp=n,res=0;
    while(tmp){
        res++;
        tmp /= 10;
    }
    return res;
}

ll S(ll n){
    ll tmp=n,res=0;
    while(tmp){
        res += tmp%10;
        tmp/=10;
    }
    return res;
}

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

    ll k;cin>>k;
    if(k<=9){
        for(int i=1;i<=k;i++) cout<<i<<endl;
        return 0;
    }
    ll res=9;
    for(int i=1;i<=9;i++) cout<<i<<endl;
    k -= 9;
    for(int i=0;i<k;i++){
        vector<Devide> cand;
        res++;
        ll ket=keta(res);
        if(ket<4){
            for(ll j=res;j<=999;j++){
                cand.push_back(Devide{j,S(j)});
            }
            sort(cand.begin(),cand.end());
            res = cand[0].n;
            cout<<res<<endl;
            continue;
        }
        ll dec=1;
        for(int j=0;j<ket-3;j++){
            dec *= 10;
        }
        for(ll j=1;j<=999;j++){
            ll val = j*dec+dec-1;
            if(val<res) continue;
            cand.push_back(Devide{val,S(val)});
        }
        sort(cand.begin(),cand.end());
        res = cand[0].n;
        cout<<res<<endl;
    }
    return 0;
}


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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd<<11)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

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

const int MAXN = 200'005;

const int MOD = 1000000007;

map<int,int> H;

int n;
int A[MAXN];

int main(){
    n=read();
    for(int i=1;i<=n;++i)A[i]=read();

    for(int i=1;i<=n;++i)++H[A[i]];

    LL ans=0;
    for(auto it:H)ans+=1ll*it.sd*(it.sd-1)/2;

    for(int i=1;i<=n;++i){
        int t=H[A[i]];
        ans-=1ll*t*(t-1)/2;
        ans+=1ll*(t-1)*(t-2)/2;
        cout<<ans<<endl;
        ans+=1ll*t*(t-1)/2;
        ans-=1ll*(t-1)*(t-2)/2;
    }

    return 0;
}


Measured memory_bytes: 8320
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SevenFiveFive solver = new SevenFiveFive();
        solver.solve(1, in, out);
        out.close();
    }

    static class SevenFiveFive {
        long n;
        long result = 0;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextLong();
            dfs("7", "");
            dfs("5", "");
            dfs("3", "");

            out.print(result);

        }

        public void dfs(String digit, String str) {

            String s = str.concat(digit);
            long v = Long.parseLong(s);
            if (n < v) {
                return;
            }
            if (s.contains("7") && s.contains("5") && s.contains("3")) {
                result++;
            }
            dfs("7", Long.toString(v));
            dfs("5", Long.toString(v));
            dfs("3", Long.toString(v));
        }

    }
}



Measured memory_bytes: 49828
#include<bits/stdc++.h>
using namespace std;
long long x[10000010],y[10000010],z[10000010];
#define int long long
signed main(){

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

    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>x[i];
        y[i]=x[i];
    }
    for(int i=1; i<=n; i++){
        z[x[y[i]]]=x[i];
    }
    for(int i=1; i<=n; i++) cout<<z[i]<<' ';
    cout<<'\n';
}

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

int main(){
    int ans=0;
    int n;
    cin >> n;
    int data[n];

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << 48-n << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll K, X; cin >> K >> X;

    for (ll s = X-(K-1); s<X+K; ++s)
        cout << s << ' ';
    cout << '\n';

    return 0;
}



Measured memory_bytes: 256
n = int(input())

keta = len(str(n))
ans = 0
#fugo =[0]*pow(2,keta-1)
for i in range(pow(2,keta-1)):
  shiki = str(n)[0]
  temp = [0]*(keta-1)
  for j in range(keta-1):
    if (i>>j)&1 == 1:
      temp[j] = "+"
    else:
      temp[j] = ""
    shiki += temp[j]+str(n)[j+1]
  ans += eval(shiki)


#for i in range(pow(2,keta-1)):
#  shiki = str(n)[0]
#  for j in range(keta-1):
#    shiki += fugo[i][j]+str(n)[j+1]
#  ans += eval(shiki)
print(ans)
                

Measured memory_bytes: 39408