akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define ketasitei setprecision(15) //15桁表示



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

	ll n, m;
	cin >> n >> m;

	if (n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	LL n; sci(n);
	int ans = 9999;
	string s = to_string(n);
	if (s.length() <= 2) {
		int a = n;
		printf("%d", abs(753 - a));
		return 0;
	}

	for (int i = 0; i < s.length() - 2;i++) {
		string tmp = s.substr(i, 3);
		int a = stoi(tmp);
		ans = min(ans,abs(753-a));
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int MAX_N=51;
int r[51],N,M,a,b;
int main(){
    cin>>N>>M;

    REP(i,M){

        cin>>a>>b;
        r[a]++;
        r[b]++;
    }

    FOR(i,1,N+1){
        cout<<r[i]<<endl;

    }




}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	v1 a(4, 0);
	rep(i, n){
		string s;
		cin >> s;
		if(s == "AC") a[0]++;
		if(s == "WA") a[1]++;
		if(s == "TLE") a[2]++;
		if(s == "RE") a[3]++;
	}
	cout << "AC x " << a[0] << endl;
	cout << "WA x " << a[1] << endl;
	cout << "TLE x " << a[2] << endl;
	cout << "RE x " << a[3] << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int x[100011],y[100011],t[100011],xa[100011],ya[100011],ta[100011];
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>t[i]>>x[i]>>y[i];
    ta[i]=t[i]-t[i-1];
    xa[i]=x[i]-x[i-1];
    ya[i]=y[i]-y[i-1];
    int m=xa[i]+ya[i];
    if(m<0)
      m=-m;
    m-=ta[i];
    if(m%2!=0||m>0){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d%d%d",&a,&b,&c);
  
  if(a<b && b<c){
    printf("%d %d %d\n",a,b,c);
  }
  else if(a<c && c<b){
    printf("%d %d %d\n",a,c,b);
  }
  else if(b<a && a<c){
    printf("%d %d %d\n",b,a,c);
  }
  else if(b<c && c<a){
    printf("%d %d %d\n",b,c,a);
  }
  else if(c<a &&a<b){
    printf("%d %d %d\n",c,a,b);
  }
  else if(c<b && b<a){
    printf("%d %d %d\n",c,b,a);
  }

  else if (a==b && b>c){
    printf("%d %d %d\n",c,a,b);
  }
  else if (a==c && b<c){
    printf("%d %d %d\n",b,a,c);
  }
  else if (a==c && b>c){
    printf("%d %d %d\n",a,c,b);
  }
  else if (c==b && b<a){
    printf("%d %d %d\n",c,b,a);
  }
  else{
    printf("%d %d %d\n",a,b,c);
  }
  return 0;
}

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

void fnOutput(const vector<int> &argviSort, int argiSortCnt)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
  cout << argiSortCnt << endl;
}

void fnBubbleSort(vector<int> &argviSort, int &argiSortCnt)
{
  int ixToBeSorted = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = argviSort.size() - 1; i > ixToBeSorted; i--)
    {
      if (argviSort[i] < argviSort[i - 1])
      {
        bSorting = true;
        swap(argviSort[i], argviSort[i - 1]);
        argiSortCnt++;
      }
    }
    ixToBeSorted++;
  }
}

int main()
{
  int iSortCnt = 0;
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnBubbleSort(viSort, iSortCnt);
  fnOutput(viSort, iSortCnt);

  return 0;
}

Measured memory_bytes: 1220
N, M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7

dp = [0 for _ in range(N+100)]
dp[0] = 1
a_set = set(a_list)

for i in range(N):
    if i in a_set:
        continue
    else:
        if 0 <= i <= N - 1:
            dp[i + 1] += dp[i]
            dp[i + 1] %= mod
        if 0 <= i <= N - 2:
            dp[i + 2] += dp[i]
            dp[i + 2] %= mod

print(dp[N] % mod)


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

int main()
{

    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    for(int i = 1; i <= 1000; i++)
    {
        if((b * i + c) % a == 0)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



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


Measured memory_bytes: 3628
from collections import deque
def bfs(n,e,fordfs):
    #点の数、スタートの点、有向グラフ
    W = [-1]*n
    W[e] = 0
    que = deque()
    que.append(e)
    len = [0]*n
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        for ne in fordfs[now]:
            if W[ne] == -1:
                W[ne] = nowv+1
                len[ne] = nowlen+1
                que.append(ne)
    return W
#############################################################

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, M = LI()
V = [[] for i in range(3*N)]
#print(V)
for i in range(M):
    u, v = LI()
    V[u-1].append(N+v-1)
    V[N+u-1].append(2*N+v-1)
    V[2*N+u-1].append(v-1)
cou = []
S, T = LI()
#print(V)

cou = bfs(3*N, S-1, V)
#print(cou)
ans = cou[T-1]//3
print(ans)


Measured memory_bytes: 80932
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e6 + 3;
const ll big = 1e9;
const ll p = 27;
 
ll dp[N];
ll ok[N];
int main() 
{
	data();
   	// freopen("substr3.in","r",stdin);
   	// freopen("substr3.out","w",stdout);
	int n, k;
	cin >> n >> k;
	dp[1] = 1;
	int l[k + 1], r[k + 1];
	for (int i = 1; i <= k; i++)
	{                      
		cin >> l[i] >> r[i];
	}
	for (int i = 1; i <= n; i++)
	{
		ok[i] += ok[i - 1];
		dp[i] += ok[i];
		dp[i] %= 998244353;
		if (dp[i] > 0)
		{
			for (int j = 1; j <= k; j++)
			{
				if (i + l[j] <= n)
				{
					ok[i + l[j]] += dp[i];
					ok[i + l[j]] %= 998244353; 
					if (i + r[j] + 1 <= n)
					{
						ok[min(n + 1, i + r[j] + 1)] -= dp[i];
					}
				}
			}	
		}
	}
	cout << dp[n];
}   	                                   



Measured memory_bytes: 6736
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll x;
  cin >> x;
  for(ll i=x;i>=1;i--){
    for(ll j=2;j*j<=i;j++){
      ll y=i;
      ll cnt=0;
      if(y%j!=0)continue;
      while(y%j==0){
        y/=j;
        cnt++;
      }
      if(y==1 && cnt>=2){
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << 1 << endl;  
  return 0;     
}


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

#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)

struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};

vector<bool> sieve(1000007,true);

void help(){
     sieve[0] = false;
     sieve[1] = false;

     for(int i=2;i*i<=1000000;++i){
        if(sieve[i]){
            for(int j=i*i;j<=1000000;j+=i)
                sieve[j] = false;

        }
     }


}

int main() {
   fastIO

   int n;
   cin>>n;

   int arr[n];

   fo(i,n)
     cin>>arr[i];

     fo(i,n)
     {
      if(i==0||arr[i-1]<=arr[i]-1) arr[i]--;

      if(i&&arr[i-1]>arr[i])
      {
        cout<<"No";
        return 0;
        }
     }
     cout<<"Yes";



   return 0 ;
      }


Measured memory_bytes: 768
N, M = map(int, input().split())

questions = {i:[False, 0] for i in range(1, N + 1)}
count_AC = 0
count_WA = 0

for _ in range(M):
    p, S = input().split()
    if not questions[int(p)][0]:
        if S == "WA":
            questions[int(p)][1] += 1
        elif S == "AC":
            questions[int(p)][0] = True

for v in questions.values():
    if v[0]:
        count_AC += 1
        count_WA += v[1]
        
print(count_AC, count_WA)

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

using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    for(int i=0;;i++){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            return 0;
        }

        A -= D;
        if(A<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int a,b;
    cin>>a>>b;
    if(a%3==0 ||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>
using namespace std;

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

int N;
vector<pi> A;
vector<vector<ll> > DP;

void input_init(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A[i] = make_pair(a, i);
	}
	sort(A.begin(), A.end(), greater<pi>());
}

void calcu(void) {
	DP.resize(N + 1, vector<ll>(N + 1, (ll)0));
	for (int i = 0; i < N; ++i) {
		for (int l = 0; l <= i; ++l) {
			int r = i - l;
			ll val_l = (ll)A[i].first * abs(l - A[i].second);
			DP[i + 1][l + 1] = max(DP[i][l] + val_l, DP[i + 1][l + 1]);
			ll val_r = (ll)A[i].first * abs(N - 1 - r - A[i].second);
			DP[i + 1][l] = max(DP[i][l] + val_r, DP[i + 1][l]);
		}
	}
}

ll solve(void) {
	ll max_val = (ll)0;
	for (int l = 0; l < N; ++l)
		max_val = max(DP[N][l], max_val);
	return max_val;
}

int main(void) {
	input_init();
	calcu();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 34684
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin>>n;
	int *a = new int[n];
	deque<int> numList;
	bool forward = true;
	rep(i,n){
		cin>>a[i];
		if(forward == true){
			numList.push_back(a[i]);
			forward = false;
		}else{
			numList.push_front(a[i]);
			forward = true;
		}
	}
	if( forward == true){
		for( auto iter = numList.begin(); iter != numList.end(); iter++){
			cout<<*iter<<" ";
		}
		cout<<endl;
	}else{
		for(auto iter = numList.end(); iter != numList.begin(); iter--){
			auto temp = iter - 1;
			cout<<*temp<<" ";
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse4")
// #pragma GCC optimize ("unroll-loops")
#define ll          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
ll A[100005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k,i;
	ll res=LLONG_MAX;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>A[i];
	for(i=0;i+k-1<n;i++){
		if(A[i+k-1]<0)
			res=min(res,-A[i]);
		else if(A[i]>0)
			res=min(res,A[i+k-1]);
		else
			res=min({res,-2*A[i]+A[i+k-1],2*A[i+k-1]-A[i]});
	}
	cout<<res;
	return 0;
}

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

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


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i * i != n) res.emplace_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int main() {

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

	lint a, b;
	cin >> a >> b;

	auto diva = divisor(a);
	
	vector<lint> divab;
	for (const auto &e : diva) if (b%e == 0) divab.emplace_back(e);
	DMP(divab);
	vector<lint> ans;
	for (const auto &e1 : divab) {
		if (e1 == 1) continue;
		bool add = true;
		for (const auto &e2 : ans) {
			if (e1 % e2 == 0) {
				add = false;
				break;
			}
		}
		if (add) ans.emplace_back(e1);
	}

	DMP(ans);
	cout << ans.size() + 1 << "\n";

	return 0;
}

Measured memory_bytes: 384
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
L2 = [0 for i in range(len(L))]
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
    s = 1
    while L[i] % 2**s == 0:
        s += 1
    L2[i] = s-1
Q = numpy.sum(L2)
print(Q)

Measured memory_bytes: 13200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;
ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
  int n;
  cin >> n;
  vector<P> ab(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    ab[i] = P(b, a);
  }
  sort(ab.begin(), ab.end());
  vector<ll> cumsum(n+1, 0);
  rep(i, n){
    cumsum[i+1] = cumsum[i] + ab[i].second;
  }

  rep(i, n){
    if(ab[i].first < cumsum[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

typedef long long int LLI;

int N;
LLI K;
int maxd;
LLI as[114514];
LLI bs[114514];

int main() {
  scanf("%d%lld", &N, &K);
  for (int i=31; i>=0; i--) {
    if (K >> i & 1) {
      maxd = i;
      break;
    }
  }

  LLI ans = 0;
  for (int i=0; i<N; i++) {
    scanf("%lld%lld", &as[i], &bs[i]);
    if (!(as[i] & (~K))) ans += bs[i];
  }

  for (int i=0; i<=maxd; i++) {
    LLI t = 0;
    if (!(K >> i & 1)) continue;
    LLI mask = ((K >> (i+1)) << (i+1)) + (1LL << i) - 1;
    for (int i=0; i<N; i++) {
      if (!(as[i] & (~mask))) t += bs[i];
    }
    ans = max(ans, t);
  }

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


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] card = new int[9];
		for(int i = 0; i < 9; i++) {
			card[i] = sc.nextInt();
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			int b = sc.nextInt();
			for(int j = 0; j < 9; j++) {
				if(b == card[j]) {
					card[j] = 0;
				}
			}
		}

		for(int i = 0; i < 3; i++) {
			if(card[i] == 0) {
				if(card[i + 3] == 0 && card[i + 6] == 0) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}

		for(int i = 0; i < 9; i+=3) {
			if(card[i] == 0) {
				if(card[i + 1] == 0 && card[i + 2] == 0) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}

		if(card[4] == 0) {
			if(card[0] == 0 && card[8] == 0) {
				System.out.println("Yes");
				System.exit(0);
			}else if(card[2] == 0 && card[6] == 0) {
				System.out.println("Yes");
				System.exit(0);
			}
		}

		System.out.println("No");
		sc.close();
	}
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n, w;
	cin>>n>>w;
    int wt[n];
    long long val[n];
    for (int i = 0; i < n; i++)
    {
        cin>>wt[i]>>val[i];
    }
   
    long long dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
          if(i==0 || j==0)
            dp[i][j]=0;
           else if(j>=wt[i-1])
            {
                dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]] ,dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
            
        }
    }
    cout<< dp[n][w]<<"\n";
    
}

Measured memory_bytes: 82436
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1000;
const int MOD = 1e9 + 7;
int dp[N + 6][N + 5];
string s[N + 5];

void hora(int tc) {
	int h,w;
	cin>>h>>w;
	for(int i = 0;i < h;i++) cin>>s[i];
	dp[0][0] = 1;
	for(int i = 0;i < h;i++) {
		for(int j = 0;j < w;j++) {
			if(i + j == 0) continue;
			if(s[i][j] == '#') continue;
			if(i != 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
			if(j != 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
		}
	}
	cout<<dp[h - 1][w - 1]<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



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

int main(){
    int N,M;
    cin>>N>>M;
    int AC[100100];
    int WA[100100];
    for(int i=1;i<=N;i++){
        AC[i]=0;
        WA[i]=0;
    }

    int ac=0,wa=0;
    int p;
    string S;
    for(int i=0;i<M;i++){
        cin>>p>>S;
        if(AC[p]==0){
            if(S=="AC"){
                AC[p]=1;
                ac++;
                wa+=WA[p];
            }else{
                WA[p]++;
            }
        }
    }

    cout<<ac<<' '<<wa<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = Integer.parseInt(sc.nextLine());
        if(R < 1200) {
            System.out.println("ABC");
        } else if(R < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - k; i++) {
    if(a[i] < a[i + k]) {
      cout << "Yes\n";
    } else cout << "No\n";
  }
  return 0;
}


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


int main(void){
	int a, b, c, x, y, z, n, t;
	string s;
	cin >> n;
	int nt=0, nx=0, ny=0;
	bool ans = true;
	while(n--){
		cin >> t >> x >> y;
		int dis = abs(x-nx) + abs(y-ny);
		if(dis > t - nt || ((t - nt) - dis) % 2 != 0){
			ans = false;
		}
		nt = t;	nx = x;	ny = y;
	}
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n / 100 == n % 10 && n)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		int S = scn.nextInt();
		int h = S/3600;
		int m = (S%3600)/60;
		int s = (S%3600)%60;
		System.out.println(h+":"+m+":"+s);
		scn.close();
	}

}

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

int n, k;
string str;

int main(){
	cin >> n >> k;
	cin >> str;
	if(str[k-1] == 'A')
		str[k-1] = 'a';
	if(str[k-1] == 'B')
		str[k-1] = 'b';
	if(str[k-1] == 'C')
		str[k-1] = 'c';
	cout << str << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans=INF, a[40][40],dp[40][40][5000];
string str, ss;
bool f;
char c;
int d[4][2] = { {1,0},{-1,0} ,{0,1},{0,-1} };
struct Edge { LL to,cost; };
LL vec[1000][1000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j];
	rep(i, h)rep(j, w) rep(h, 2000)dp[i][j][h] = INF;
	dp[0][0][0] = 0;
	rep(s, 5000-1) {
		rep(i, h)rep(j, w) {
			rep(k, 4) {
				int X = i + d[k][0], Y = j + d[k][1];
				if (X >= 0 && Y >= 0 && X < h&&Y < w&& dp[i][j][s]!=INF)
					dp[X][Y][s + 1] = min(dp[X][Y][s + 1], dp[i][j][s] + (s*2+1)*a[X][Y]);
			}

		}
	}
	rep(i, 2000)
		ans = min(ans, dp[h-1][w-1][i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 38436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    ll a=N/2,b=N%2;
    cout<<a*min({Q*8,H*4,S*2,D}) + b*min({Q*4,H*2,S})<<endl;
}

Measured memory_bytes: 256
# Rectangular Searching

from collections import deque

while True:
    h, w = map(int, raw_input().split())
    if (h, w) == (0, 0):
        break

    g = []
    for i in range(h):
        g.append([1 if c == '.' else 0 for c in raw_input()] + [0])

    for i in range(1, h):
        for j in range(w):
            if g[i][j] != 0:
                g[i][j] = g[i - 1][j] + 1

    stack = deque()
    area = 0
    for i in range(h):
        for j in range(w + 1):
            if len(stack) == 0:
                stack.append((j, g[i][j]))
            else:
                if stack[-1][1] < g[i][j]:
                    stack.append((j, g[i][j]))
                elif stack[-1][1] > g[i][j]:
                    idx = j
                    while len(stack) != 0 and stack[-1][1] >= g[i][j]:
                        prev = stack.pop()
                        idx = prev[0]
                        area = max(area, prev[1] * (j - idx))
                    stack.append((idx, g[i][j]))

    print area

Measured memory_bytes: 6544
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N =2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int n;

int main(){


    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);



	string s , t;
	cin >> n;
	cin >> s >> t;
	
	for(int i = 0 ; i < s.length() ; ++i)
			cout << s[i] << t[i];

	cout << "\n";

    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <queue>

using namespace std;
static const int MAX=100;
static const int WHITE=1;
static const int GRAY=2;
static const int BLACK=3;

int n,M[MAX+10][MAX+10];

int prim()
{
    int u,minv;
    int d[MAX],p[MAX],color[MAX];

    for(int i=0;i<n;i++)
    {
      d[i]=INT_MAX;
      p[i]=-1;
      color[i]=WHITE;
    }

    d[0]=0;

    while(1)
    {
        minv=INT_MAX;
        u=-1;
        for(int i=0;i<n;i++)
        {
            if(minv>d[i]&&color[i]!=BLACK)
            {
                u=i;
                minv=d[i];
            }
        }
      if(u==-1) break;
      color[u]=BLACK;
      for(int v=0;v<n;v++)
      {
        if(color[v]!=BLACK && M[u][v]!=INT_MAX)
        {
            if(d[v]>M[u][v])
            {
                d[v]=M[u][v];
                p[v]=u;
                color[v]=GRAY;
            }
         }
      }
     }

    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=-1) sum+=M[i][p[i]];
    }

    return sum;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
     for(int j=0;j<n;j++)
    {
        int e;
        cin>>e;
        M[i][j]=(e==-1)? INT_MAX:e;
    }

    cout<<prim()<<endl;
    return 0;
}



Measured memory_bytes: 3144
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let n=tn()
  let a=tnn(n)
  let ans=0
  for(let i=0;i<a.length-1;i++){
    for(let j=i;j<a.length;j++){
      ans=max(ans,abs(a[i]-a[j]))
    }
  }
  to(ans)
}
main()


Measured memory_bytes: 9420
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define INF 1000000000000
using namespace std;

typedef long long ll;

ll N,M,K,S,P,Q;
bool iszombie[100010],isdanger[100010];
ll totalmoney[100010];
vector<ll> paths[100010];

ll distzomb[100010];
void dfs(){
	queue<pair<ll,ll>> que;
	fill(distzomb,distzomb+100010,INF);
	for(ll i=1;i<=N;i++){
		if(iszombie[i]){
			que.push(make_pair(0,i));
		}
	}
	while(!que.empty()){
		ll dis=que.front().first;
		ll num=que.front().second;
		que.pop();
		if(distzomb[num]==INF){
			distzomb[num]=dis;
			for(auto it=paths[num].begin();it!=paths[num].end();it++){
				if(distzomb[*it]==INF){
					que.push(make_pair(dis+1,(*it)));
				}
			}
		}
	}
	for(ll i=1;i<=N;i++){
		if(distzomb[i]<=S) isdanger[i]=true;
		else isdanger[i]=false;
	}
}

int main(){
	cin>>N>>M>>K>>S>>P>>Q;
	for(ll i=1;i<=K;i++){
		ll tmp;
		cin>>tmp;
		iszombie[tmp]=true;
	}
	for(ll i=1;i<=M;i++){
		ll a,b;
		cin>>a>>b;
		paths[a].push_back(b);
		paths[b].push_back(a);
	}

	//??±?????????
	dfs();

	priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;

	fill(totalmoney,totalmoney+100010,INF);
	pq.push(make_pair(0,1));
	while(!pq.empty()){
		ll mon=pq.top().first;
		ll num=pq.top().second;
		pq.pop();
		if(totalmoney[num]==INF){
			totalmoney[num]=mon;
			for(auto it=paths[num].begin();it!=paths[num].end();it++){
				if(iszombie[*it]) continue;
				if(totalmoney[*it]==INF){
					if(isdanger[*it]){
						pq.push(make_pair(mon+Q,*it));
					}
					else{
						pq.push(make_pair(mon+P,*it));
					}
				}
			}
		}
	}
	ll res;
	if(isdanger[N]) res=totalmoney[N]-Q;
	else res=totalmoney[N]-P;

	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 13916
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int a,b;
cin >> a >>b;
if(a>=b){
    for(int i=0;i<a;i++){
        cout << b;
    }
    cout << endl;
    return 0;
}
for(int i=0;i<b;i++){
    cout << a;
}
cout << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;



int main(){
	int n,m;
	cin >> n >> m;
	vector<int> from(m,0),to(m,0);
	vector<int> ans(n,0);
	
	for(int i=0;i<m;i++){
		cin >> from[i] >> to[i];
	}
	
	for(int i=0;i<m;i++){
		ans[from[i]-1]++;
		ans[to[i]-1]++;
	}
	
	for(int i=0;i<n;i++){
		cout << ans[i] << endl;
	}
}


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

#define MAX_N 101000
#define SWAP( a, b ) do { int tmp; tmp = a; a = b; b = tmp; } while( 0 )

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void insertionSort( int *, int );
void quickSort( int *, int );
void quickSort_body( int *, int, int );
int median( int, int, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 253 );
	}

	return 0;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] > tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];

				j--;
			} while ( j && data[ j - 1 ] > tmp );

			data[ j ] = tmp;
		}
	}
}

void quickSort( int *data, int n ) {
	quickSort_body( data, 0, n - 1 );
}

void quickSort_body( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] );

		while ( 1 ) {
			while ( data[ i ] < pivot )
				i++;
			while ( pivot < data [ j ] )
				j--;
			if ( i >= j )
				break;

			SWAP( data[ i ], data[ j ] );

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort_body( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort_body( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

Measured memory_bytes: 988
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;
string s;
int sum,num;
int main(){
	cin>>s;
	int tmp=s.length();
	for (int i=0; i<tmp; i++){
		if (s[i]=='S') sum++;
		if (sum&&(s[i]=='T')){
			sum--;
			num+=2;
		}
	}
	printf("%d\n",tmp-num);
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const int INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1000*1000*1000+7;
lli bpow(lli a, lli b) {
	if(b == 0) return 1;
	if(b == 1) return a % MOD;
	lli r = bpow(a, b >> 1);
	r = (r * r) % MOD;
	return (r * (((b&1)?a:1) % MOD)) % MOD;
}
lli multInverse(lli a) {
	return bpow(a, MOD - 2);
}
lli modMult(lli a, lli b) {
	return (a * b) % MOD;
}
lli modSub(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli modAdd(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	int n = s.length();
	s = "#" + s;
	
	string ans = "";
	for(int i = 1; i <= n; i++) {
		if(s[i] == 'B')
			if(!ans.empty()) 
				ans.pop_back();
		if(s[i] != 'B')
			ans.push_back(s[i]);
	}	
	cout << ans << "\n";
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
  int64_t n, k, c;
  cin >> n >> k >> c;

  string s;
  cin >> s;

  if (c == 0) {
    int64_t k2 = count(s.begin(), s.end(), 'o');
    if (k == k2) {
      for (auto i : irange(0L, n)) {
        if (s[i] == 'o') {
          cout << i + 1 << "\n";
        }
      }
    }

    return 0;
  }

  vector<int64_t> l(n), r(n);
  int64_t m = 0;
  for (auto i : irange(0L, n)) {
    l[i] = (i > 0 ? l[i - 1] : 0L);
    if (s[i] == 'o' && i >= m) {
      ++l[i];
      m = i + c + 1;
    }
    // cerr << "l[" << i << "] = " << l[i] << endl;
  }
  m = n - 1;
  for (auto i : irange(0L, n) | reversed) {
    r[i] = (i + 1 < n ? r[i + 1] : 0L);
    if (s[i] == 'o' && i <= m) {
      ++r[i];
      m = i - c - 1;
    }
    // cerr << "r[" << i << "] = " << r[i] << endl;
  }

  vector<int64_t> ans;
  for (auto i : irange(0L, n)) {
    int64_t t = (i > 0 ? l[i - 1] : 0L) + (i + 1 < n ? r[i + 1] : 0L);
    if (t < k) {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3716
from collections import deque, defaultdict

inf = 10**15
h, w = map(int, input().split())
#隣接リスト
#G = defaultdict(lambda:[])
G = [[inf]*(h*w) for _ in range(h*w)]
#################################

def warshall_floyd(d):
    #d[i][j]:iからjに行く最短経路
    for k in range(h*w):
        for i in range(h*w):
            for j in range(h*w):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d
  
li = []
for j in range(h):
    g = list(input())
    temp = []
    for i in g:
      if i=='.':
        temp.append(0)
      else:
        temp.append(1)
    li.append(temp)
for i in range(h):
    for j in range(w-1):
        if li[i][j]==0 and li[i][j+1]==0:
            G[i*w+j][i*w+j+1] = 1
            G[i*w+j+1][i*w+j] = 1
            G[i*w+j][i*w+j] = 0
            G[i*w+j+1][i*w+j+1] = 0
for i in range(h-1):
    for j in range(w):
        if li[i][j] ==0 and li[i+1][j]==0:
            G[i*w+j][i*w+w+j] = 1
            G[i*w+j+w][i*w+j] = 1
            G[i*w+j+w][i*w+j+w] = 0
            G[i*w+j][i*w+j] = 0
    
#################################
d = warshall_floyd(G)
max_ = 0
for i in range(h*w):
  for j in range(h*w):
    if d[i][j] < inf:
      max_ = max(max_, d[i][j])
print(max_)

Measured memory_bytes: 42896
# ABC090C 3/18
import numpy as np
#import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat
class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, M = getIntList()
    d.dmp((N, M))
    n = abs(N-2)
    m = abs(M-2)
    d.dmp((n,m),'n,m')
    return n*m


ans = prob()
if ans is None:
    pass
elif type(ans) == list and ans[0] == 'col':
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 12424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string S;
    cin >> S;

    int res = 0;
    int tmp = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            ++tmp;
        }
        else {
            chmax(res, tmp);
            tmp = 0;
        }
    }
    chmax(res, tmp);

    cout << res << endl;


	return 0;
}


Measured memory_bytes: 256
N = int(input())
li = list(map(int, input().split()))

# N = 6
# li = [5, 2, 4, 6, 1, 3]

for i in range(1, N):
    print(*li)
    v = li[i]
    for j in reversed(range(0, i)):
        if li[j] > v:
            li[j + 1] = li[j]
            li[j] = v
        else:
            break

print(*li)



Measured memory_bytes: 5984
#include<stdio.h>
int main() {
	int a, b, c, d=0, x;
	scanf("%d %d %d", &a, &b, &c);
	for (x = a;x <= b;x++) {
		if (c%x == 0) {
			d = d + 1;
		}
	}
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 596