akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	string s; cin >> s;
	string ans = "";
	for (int i = 1; i <= 5; i++) {
		ans += "hi";
		if (ans == s) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}









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

int main() {
    string s;

    cin >> s;

    int cnt = 0;
    for (int i = 0; i < 3; i ++) {
        if (s[i] == '1') {
            cnt += 1;
        }
    }

    cout << cnt << endl;
}

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

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: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,K;
    string S;
    cin>>N>>K;
    cin>>S;
    rep(i,N){
        if(i==K-1){
            if(S[i]=='A') cout<<"a";
            else if(S[i]=='B') cout<<"b";
            else cout<<"c";
        }else cout<<S[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

ll get_distance(ll s, ll t)
{
  std::queue< ll > que;
  std::map< ll, ll > m_dist;

  m_dist[s] = 0;
  que.push(s);
  while (!que.empty()) {
    const ll pos = que.front(); que.pop();

    ll npos = -pos;
    if (m_dist.count(npos) == 0) m_dist[npos] = INF;
    if (m_dist[npos] > m_dist[pos] + 1) {
      m_dist[npos] = m_dist[pos] + 1;
      if (npos != t) que.push(npos);
      //print("1B", pos, npos, m_dist[pos], m_dist[npos]);
    }

    npos = t;
    if (m_dist.count(npos) == 0) m_dist[npos] = INF;
    if (npos > pos) {
      if (m_dist[npos] > m_dist[pos] + npos - pos) {
	//print("2A", pos, npos, m_dist[pos], m_dist[npos]);
	m_dist[npos] = m_dist[pos] + npos - pos;
	if (npos != t) que.push(npos);
	//print("2B", pos, npos, m_dist[pos], m_dist[npos]);
      }
    }

    npos = -t;
    if (m_dist.count(npos) == 0) m_dist[npos] = INF;
    if (npos > pos) {
      if (m_dist[npos] > m_dist[pos] + npos - pos) {
	//print("2A", pos, npos, m_dist[pos], m_dist[npos]);
	m_dist[npos] = m_dist[pos] + npos - pos;
	if (npos != t) que.push(npos);
	//print("2B", pos, npos, m_dist[pos], m_dist[npos]);
      }
    }

  }

  return m_dist[t];
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll s, t;
  std::cin >> s >> t;

  print(get_distance(s, t));
  return 0;
}


Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-06 16:52:04(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
import itertools
# import statistics
# import functools
# import operator

# def nCr(n, r):
#     r = min(r, n - r)
#     return functools.reduce(operator.mul, range(n, n-r, -1), 1) // math.factorial(r)

def main():
    n = int(sys.stdin.readline().rstrip())
    march = {l: 0 for l in 'MARCH'}

    for i in range(n):
        initial = sys.stdin.readline()[0]
        if initial in march:
            march[initial] += 1


    march = {k: v for k, v in march.items() if v != 0}
    
    if len(march) < 2:
        print(0)
        exit()
    
    total_cmb = 0
    for cmb in itertools.combinations(march.values(), 3):
        total_cmb += cmb[0] * cmb[1] * cmb[2]
    
    print(total_cmb)
        
if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 123456;
const ll mod = 1e9 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;

int n;
ll a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    
    cin >> n;

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

    int len = INT_MIN;
    int cur = a[1];
    int temp = 0;
    rep(i , 2 , n) {

    	if(a[i] <= cur) {
    		temp++;
    		cur = a[i];
    	}	
    	else {
    		cur = a[i];
    		len = max(len , temp);
    		temp = 0;
    	}
    }

    len = max(len , temp);
	
	cout << len << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<complex>
#include<utility>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef complex<double> point;

point rot[4]={point(1,0),point(0,1),point(-1,0),point(0,-1)};

int main(){
	int n;
	while(cin>>n,n){
		int m,x,y,ans=0;
		vector<vector<pii> > in(n+1);
		vector<vector<point> > vec(n+1);
		rep(i,n+1){
			cin>>m;
			rep(j,m){
				cin>>x>>y;
				in[i].pb(pii(x,y));
			}
		}
		rep(i,n+1){
			rep(j,in[i].size()-1){
				vec[i].pb(point(in[i][j+1].first-in[i][j].first,in[i][j+1].second-in[i][j].second));
			}
		}
		rep(j,n+1){
			if(j==0 || vec[0].size()!=vec[j].size())continue;
			bool boo[8]={1,1,1,1,1,1,1,1};
			rep(k,4){
				bool temp=true;
				rep(l,vec[0].size()){
					point alt=vec[0][l];
					alt*=rot[k];
					if(alt!=vec[j][l]){
						temp=false;
						break;
					}
				}
				if(!temp)boo[k]=false;
				temp=true;
				for(int l=vec[0].size()-1;l>=0;l--){
					point alt=vec[0][vec[0].size()-l-1];
					alt*=rot[k];
					if(alt!=vec[j][l]){
						temp=false;
						break;
					}	
				}
				if(!temp)boo[k+4]=false;
			}
			if(boo[0]||boo[1]||boo[2]||boo[3]||boo[4]||boo[5]||boo[6]||boo[7]){
				cout<<j<<endl;
			}
		}
		cout<<"+++++"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int M;
vector<int> es[114514];
vector<int> res[114514];
int cnt[114514];
int maxd[114514];

int main() {
  scanf("%d%d", &N, &M);
  rep(i, N-1+M) {
    int a, b;

    scanf("%d%d", &a, &b);
    --a;
    --b;
    es[a].eb(b);
    res[b].eb(a);
  }

  fill(maxd, maxd+N, -1);
  queue<int> que;
  rep(v, N) {
    if (res[v].empty()) {
      maxd[v] = 0;
      que.push(v);
    }
  }
  assert(que.size() == 1);

  while (!que.empty()) {
    int v = que.front(); que.pop();

    for (int w : res[v]) {
      MX(maxd[v], maxd[w]+1);
    }

    for (int u : es[v]) {
      cnt[u]++;
      //printf("u: %d, res[u].size(): %d, cnt[u]: %d\n", u, (int)res[u].size(), cnt[u]);
      if (res[u].size() == cnt[u]) {
        que.push(u);
      }
    }
  }

  rep(v, N) {
    //printf("maxd[%d]: %d\n", v, maxd[v]);
    if (res[v].empty()) {
      puts("0");
      continue;
    }

    bool found = false;
    for (int w : res[v]) {
      if (maxd[w]+1 == maxd[v]) {
        printf("%d\n", w+1);
        assert(!found);
        found = true;
      }
    }
    assert(found);
  }
}


Measured memory_bytes: 13184
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int W[10];
  int K[10];
  int Wpon, Kpon;
  int i;

  for (i = 0;i < 10;i++){
    scanf("%d", &W[i]);
  }

  for (i = 0;i < 10;i++){
    scanf("%d", &K[i]);
  }

  sort(W, W+10);
  sort(K, K+10);

  Wpon = W[9] + W[8] + W[7];
  Kpon = K[9] + K[8] + K[7];

  printf("%d %d\n", Wpon, Kpon);

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n,m,x;
    cin >> n >> m >> x;
    vector<ll> C(n);
    vector<vector<ll>> A(n, vector<ll>(m,0));
    for (ll i = 0; i < n; ++i) {
        cin >> C[i];
        for (ll j = 0; j < m; ++j) {
            cin >> A[i][j];
        }
    }

    ll res = -1;
    ll top = 1LL<<n;
    for (ll i = 0LL; i < top; ++i) {
        vector<ll> T(m,0);
        ll sum = 0;
        //cerr << i << ": ";
        for (ll j = 0; j < n; ++j) {
            if (((1LL<<j) & i) != 0) {
                //cerr << j << ",";
                sum += C[j];
                for (ll k = 0; k < m; ++k) {
                    T[k] += A[j][k];
                }
            }
        }
        //cerr << endl;
        bool ok = true;
        //cerr << i << ": ";
        for (ll k = 0; k < m; ++k) {
            //cerr << T[k] << ",";
            if (T[k] < x) {
                ok = false;
                break;
            }
        }
        //cerr << endl;
        if (ok) {
            if (res < 0) {
                res = sum;
            } else {
                res = min(res, sum);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define p5(i) i*i*i*i*i
using namespace std;
int n,k,a[100005];
map<int,long long > m;
int main()
{
    cin>>n;
    long long r=0;
    for(int i=1;i<=n;++i)
    {
        int x;
        cin>>x;
        r=r+m[i-x];
        m[x+i]++;
    }
    cout<<r;

}


Measured memory_bytes: 26320
#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=998244353;
const int INF=1e9;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vvl G;


void dfs(int v,vector<bool> &seen,int  &res){
  bool end=true;
  rep(i,seen.size())if(!seen[i] &&i!=v)end=false;
  if(end){
    res++;
    return;
  }
  seen[v]=true;
  for(auto nv:G[v]){
    if(seen[nv])continue;
    dfs(nv,seen,res);
  }
  seen[v]=false;
}
         
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,m;
  cin >> n >> m;
  bool G[n][n];
  rep(i,n)rep(j,n)G[i][j]=false;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a][b]=true;
    G[b][a]=true;
  }
  vector<int>p(n);
  rep(i,n)p[i]=i;
  
  int ans=0;
  do{
    if(p[0]!=0)break;
    bool ok=true;
    for(int i=1;i<n;i++){
      if(!G[p[i-1]][p[i]])ok=false;
    }
    if(ok)ans++;
  }while(next_permutation(all(p)));
       
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 3604
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s, t;
	scans(s);
	scans(t);
	vector<string> ans;
	rep(i, s.length() - t.length() + 1) {
		if (s[i] == t[0] || s[i] == '?') {
			bool flag = true;
			rep(j, t.length()) {
				if (s[i + j] != t[j] && s[i + j] != '?')flag = false;
			}
			if (flag) {
				string tmp;
				rep(j, s.length()) {
					if (j == i) {
						rep(k, t.length()) {
							tmp += t[k];
							++j;
						}
						--j;
					}
					else{
						if (s[j] == '?')tmp += 'a';
						else tmp += s[j];
					}
				}
				ans.pb(tmp);
			}
		}
	}
	sort(all(ans));
	if (ans.size() == 0)printf("UNRESTORABLE\n");
	else prints(ans[0]);
	

	Please AC;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A = sorted(A,reverse=True)
ans = A[0]
if N==2:
    print(ans)
else:
    A = A[1:]
    for i in range(N-2):
        idx = i//2
        ans += A[idx]
    print(ans)

Measured memory_bytes: 31332
#include <stdio.h>
#include <math.h>
int main(void)
{
  int a = 0;
  scanf("%d", &a);
 
  int b = 0;
  scanf("%d", &b);
    
  int ans = 0;
 
  if(a<=b){
    for(int i = 0;i < b; i++){
    ans = ans + a*pow(10,i);
    }
    printf("%d", ans);
  }else{
    for(int i = 0;i < a; i++){
      ans = ans + b*pow(10,i);
    }    
    printf("%d", ans);
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  long long sum = 0;
  long long minus = 0;
  rep(i, N) {
    long long tmp = i + 1;
    sum += tmp;
    if((tmp%3) == 0 && (tmp%5) != 0) minus += tmp;
    else if((tmp%5) == 0 && (tmp%3) != 0) minus += tmp;
    else if((tmp%3) == 0 && (tmp%5) == 0) minus += tmp;
  
  }
  cout << (sum - minus) << endl;
}

Measured memory_bytes: 3608
/*
* AUTHOR : Haoyang(Max) Chen
* INSTITUTION : Australian National Unversity
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <random>
#include <map>
using namespace std;

#define ll long long

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

	int l, v, ans = 0;

	cin >> l;

	map<int, int> fm;
	map<int, int>::iterator it;

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

	for(it = fm.begin(); it != fm.end(); ++it){
		if (it -> first != it -> second){
			if (it -> first < it -> second){
				ans += (it -> second - it -> first);
			}
			else if(it -> first > it -> second){
				ans += it -> second;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int x,a;
  cin >> x >>a;
  if(x<a)cout << 0 << endl;
  else cout << 10 << endl;
  }


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ll mod;
struct Matrix {
	vector<vector<long long> > val;
	Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
	void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); }
	size_t size() const { return val.size(); }
	inline vector<long long>& operator [] (int i) { return val[i]; }
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix R(A.size(), B[0].size());
	for (int i = 0; i < A.size(); ++i)
		for (int j = 0; j < B[0].size(); ++j)
			for (int k = 0; k < B.size(); ++k)
				R[i][j] = (R[i][j] + A[i][k] * B[k][j] % mod) % mod;
	return R;
}

Matrix modpow(Matrix A, long long n) {
	Matrix R(A.size(), A.size());
	for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
	while (n > 0) {
		if (n & 1) R = R * A;
		A = A * A;
		n >>= 1;
	}
	return R;
}

ll power(ll x, ll n, ll p = 1000000007) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return power(x * x % p, n / 2, p) % p;
	}
	else {
		return x * power(x, n - 1, p) % p;
	}
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		ll N, M, A, B, C, T; scanf("%lld %lld %lld %lld %lld %lld", &N, &M, &A, &B, &C, &T); if (N == 0) break;
		mod = M;
		vector<ll> s(N); for (int i = 0; i < N; i++) scanf("%lld", &s[i]);
		if (N == 1) {
			cout << s[0] * power(B, T, M) % M << "\n";
			continue;
		}
		Matrix ini(N, 1); for (int i = 0; i < N; i++) ini[i][0] = s[i];
		Matrix mat(N, N);
		mat[0][0] = B;
		mat[0][1] = C;
		for (int i = 1; i < N - 1; i++) mat[i][i - 1] = A, mat[i][i] = B, mat[i][i + 1] = C;
		mat[N - 1][N - 1] = B;
		mat[N - 1][N - 2] = A;
		Matrix res = modpow(mat, T) * ini;
		for (int i = 0; i < N; i++) {
			cout << res[i][0];
			if (i == N - 1) cout << "\n";
			else cout << " ";
		}
	}
	return 0;

}


Measured memory_bytes: 3284
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int cc[500][4];

struct abcd {
  int a, b, c, d;
  abcd() {}
  abcd(int _a, int _b, int _c, int _d) { a = _a; b = _b; c = _c; d = _d; }
  bool operator < (const abcd & another) const {
    if (a != another.a) return a < another.a;
    if (b != another.b) return b < another.b;
    if (c != another.c) return c < another.c;
    return d < another.d;
  };
};

int same(int a0, int a1, int a2, int a3, int b0, int b1, int b2, int b3) {
  int cc = 0;
  if (a0 == b0 && a1 == b1 && a2 == b2 && a3 == b3) cc ++;
  if (a0 == b1 && a1 == b2 && a2 == b3 && a3 == b0) cc ++;
  if (a0 == b2 && a1 == b3 && a2 == b0 && a3 == b1) cc ++;
  if (a0 == b3 && a1 == b0 && a2 == b1 && a3 == b2) cc ++;
  return cc;
}

int main()
{
  int n;
  cin >> n;
  map<abcd, int> cnt;
  for (int i=0; i<n; i++) {
    cin >> cc[i][0] >> cc[i][1] >> cc[i][2] >> cc[i][3];
    cnt[abcd(cc[i][0], cc[i][1], cc[i][2], cc[i][3])] ++;
    cnt[abcd(cc[i][1], cc[i][2], cc[i][3], cc[i][0])] ++;
    cnt[abcd(cc[i][2], cc[i][3], cc[i][0], cc[i][1])] ++;
    cnt[abcd(cc[i][3], cc[i][0], cc[i][1], cc[i][2])] ++;
  }

  long long res = 0;
  for (int i=0; i<n; i++)
    for (int j=i+1; j<n; j++) {
      int a0 = cc[i][0], a1 = cc[i][1], a2 = cc[i][2], a3 = cc[i][3];
      int b0 = cc[j][3], b1 = cc[j][2], b2 = cc[j][1], b3 = cc[j][0];
      for (int ord=0; ord<4; ord++) {
        int ll_cnt = cnt[abcd(a0, a3, b0, b1)];
        int rr_cnt = cnt[abcd(a2, a1, b2, b3)];
        int uu_cnt = cnt[abcd(a1, a0, b1, b2)];
        int dd_cnt = cnt[abcd(a3, a2, b3, b0)];
        ll_cnt -= same(a0, a1, a2, a3, a0, a3, b0, b1);
        ll_cnt -= same(b3, b2, b1, b0, a0, a3, b0, b1);
        rr_cnt -= same(a0, a1, a2, a3, a2, a1, b2, b3);
        rr_cnt -= same(b3, b2, b1, b0, a2, a1, b2, b3);
        uu_cnt -= same(a0, a1, a2, a3, a1, a0, b1, b2);
        uu_cnt -= same(b3, b2, b1, b0, a1, a0, b1, b2);
        dd_cnt -= same(a0, a1, a2, a3, a3, a2, b3, b0);
        dd_cnt -= same(b3, b2, b1, b0, a3, a2, b3, b0);

        rr_cnt -= same(a0, a3, b0, b1, a2, a1, b2, b3);
        uu_cnt -= same(a0, a3, b0, b1, a1, a0, b1, b2);
        uu_cnt -= same(a2, a1, b2, b3, a1, a0, b1, b2);
        dd_cnt -= same(a0, a3, b0, b1, a3, a2, b3, b0);
        dd_cnt -= same(a2, a1, b2, b3, a3, a2, b3, b0);
        dd_cnt -= same(a1, a0, b1, b2, a3, a2, b3, b0);
        res += 1LL * ll_cnt * rr_cnt * uu_cnt * dd_cnt;
//        printf("%d %d %d : %d %d %d %d\n", i,j,ord, ll_cnt, rr_cnt, uu_cnt, dd_cnt);
        int b4 = b0;
        b0 = b1;
        b1 = b2;
        b2 = b3;
        b3 = b4;
      }
    }
  cout << res / 3 << endl;
}


Measured memory_bytes: 80128
package main

import "fmt"

func main() {
	var n, t int
	fmt.Scan(&n, &t)

	ans := 0
	pre := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		ans += min(tmp-pre, t)
		pre = tmp
	}
	ans += t
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main()
{
  string S;
  cin>>S;
  int ans=0;
  for(int i=0;i<S.size()-1;i++){
    if(S[i]!=S[i+1]) ans++;
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 512
n = int(input())
ans = 0
list_N = [["3", "5", "7"]]

for i in range(2, 10):
    d = []
    for a in list_N[-1]:
        for b in ["3", "5", "7"]:
            k = b + a
            if n >= int(k) and "3" in k and "5" in k and "7" in k:
                ans += 1
            d.append(k)
    list_N.append(d)

print(ans)

Measured memory_bytes: 11180
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), T = getint();

	int kotae = T;
	int mae = getint();
	rep(i, N - 1) {
		int t = getint();
		kotae += min(t - mae, T);
		mae = t;
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const ll INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

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

  ll c = 0;
  ll mi = 0;
  priority_queue<ll> ql;
  priority_queue<ll, vector<ll>, greater<ll>> qr;
  ql.push(-INF);
  qr.push(INF);
  REP(i, Q) {
    int com;
    cin >> com;
    if (com == 1) {
      ll a, b;
      cin >> a >> b;
      c += b;

      if ((ql.size() + qr.size()) % 2 == 0) {
        if (!(ql.top() <= a && a <= qr.top())) {
          mi += min(abs(a - ql.top()), abs(a - qr.top()));
        }
      } else {
        mi += abs(a - ql.top());
      }

      if (ql.top() > a) {
        ql.push(a);
      } else {
        qr.push(a);
      }

      while (ql.size() > qr.size() + 1) {
        qr.push(ql.top());
        ql.pop();
      }

      while (qr.size() > ql.size()) {
        ql.push(qr.top());
        qr.pop();
      }

    } else {
      cout << ql.top() << " " << mi + c << endl;
    }
  }
}


Measured memory_bytes: 3828
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A+B==3) {
			System.out.println(3);
		}else if(A+B==4) {
			System.out.println(2);
		}else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 23124
def wall(grid,x,y,d):
    if d==0:
        return x<4 and grid[y*2][x]=='1'
    if d==1:
        return y<4 and grid[y*2+1][x]=='1'
    if d==2:
        return x>0 and grid[y*2][x-1]=='1'
    if d==3:
        return y>0 and grid[y*2-1][x]=='1'

def move(x,y,d):
    if d==0:
        return x+1,y,'R'
    if d==1:
        return x,y+1,'D'
    if d==2:
        return x-1,y,'L'
    if d==3:
        return x,y-1,'U'

ans=''
x=y=d=0
grid=[raw_input() for i in range(9)]
while x or y or d < 2:
    d=(d+3)%4
    while not wall(grid,x,y,d):
        d=(d+1)%4
    x,y,c=move(x,y,d)
    ans=ans+c
print ans

Measured memory_bytes: 6368
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/

int main(){
   int h, w; cin >> h >> w;
   map<char,int> mp;
   rep(i, h){
     string s; cin >> s;
     rep(j, w) mp[s[j]]++;
   }
   bool flag = true;
   if(h % 2 == 1 and w % 2 == 1){
     map<int,int> c;
     for(auto it : mp) c[it.second % 4]++;
     if(c[3]) flag = false;
     if(c[1] != 1) flag = false;
     if(c[2] > (h - 1) / 2 + (w - 1) / 2) flag = false;
   }else if(h % 2 == 0 and w % 2 == 0){
     for(auto it : mp) if(it.second % 4 != 0) flag = false;
   }else{
     map<int,int> c;
     for(auto it : mp) c[it.second % 4]++;
     if(c[1] or c[3]) flag = false;
     if(c[2] > (w % 2 ? h / 2 : w / 2)) flag = false;
   }
   if(flag) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    ll n; cin >> n;
    vector<int> ans(n + 1, 0);
    _rep(i, 1, 100)_rep(j, 1, 100)_rep(k, 1, 100){
        if(i * i + j * j + k * k + i * j + j * k + k * i > n) continue;
        else ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
    }
    _rep(i, 1, n + 1) cout << ans[i] << endl; 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  // int n;
  // int m;
  // cin >> n;
  // cin >> m;
  
  string s;
  cin >> s;
  int ans = 0;
  for(char c: s)
    if(c == '1')
      ans++;

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



Measured memory_bytes: 256
a, b, c = map(int, input().split())
vec = sorted([a, b, c])

ans = vec[2]-vec[1]
vec[0] += ans
vec[1] += ans

if (vec[1]-vec[0])%2==0:
    ans += (vec[1]-vec[0])//2
else:
    ans += (vec[1]-vec[0])//2+2

print(ans)

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

int main() {
	string str;
	cin >> str;
	int ss = (str[0] == 'S' ? 1 : 0), tt, l = str.length();
	for (int i = 1; i < str.length(); i++) {
		if (str[i] == 'S') {
			if (str[i-1] == 'S') {
				ss++;
			}
			else {
				if (tt == 1) {
					ss++;
				}
				else {
					ss = 1;
				}
			}
		}
		else {
			if (ss > 0) {
				l -= 2;
				ss--;
				tt = 1;
			}
			else {
				tt = 0;
			}
		}
	}
	cout << l << endl;
	return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int n,x,i,a[100010];
  ll ans=0;
  cin >> n >> x;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n-1;i++){
    if (a[i]+a[i+1]>x){
      if (a[i]>x){
        ans+=a[i]+a[i+1]-x;
        a[i]=x;
        a[i+1]=0;
      }else{
        ans+=a[i]+a[i+1]-x;
        a[i+1]=x-a[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();

		if ( R - L > 2019 ) {
			System.out.println(0);
		} else {
			long ans = 2019;
			for ( long i = L ; i < R ; i++ ) {
				for ( long j = i + 1 ; j <= R ; j++ ) {
					long mod = (i * j) % 2019;
					if ( ans > mod ) {
						ans = mod;
					}
				}
			}
			System.out.println(ans);
		}
	}
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b; cin >> a >> b;
  a--; b--;
  int n = 100;
  vector<string> v(n);
  REP(i, n/2) {
    v[i].assign(n, '#');
  }
  FOR(i, n/2, n) {
    v[i].assign(n, '.');
  }

  int cnta = 0;
  for(int i=0;i<n/2-1;i += 2) {
    if(cnta == a) break;
    for(int j=0;j<n;j+=2) {
      if(cnta == a) break;
      v[i][j] = '.';
      cnta++;
    }
  }

  int cntb = 0;
  for(int i=n/2+1;i<n;i+=2){
    if(cntb == b) break;
    for(int j=0;j<n;j += 2) {
      if(cntb == b) break;
      v[i][j] = '#';
      cntb++;
    }
  }

  cout << n << " " << n << endl;
  REP(i, n) {
    cout << v[i] << endl;
  }

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int n;
	scanf("%d",&n);
	
	long long int sum = 0;
	
	for ( int i = 1 ; i <= n ; i++){
		if ( i%3 == 0  && i%5 == 0){
		}
		else if ( i%3 == 0){
		}
		else if ( i%5 == 0){
		}
		else {
			sum = sum + i ; 
		}
	}
		printf("%lld",sum);
	
	
	return 0;
}

Measured memory_bytes: 2148
n = int(input())
h = list(map(int, input().split()))

global count
count = 0


def f(l, r, arr):
    # l以上r未満の範囲で探索
    global count
    while len(arr[l:r]) > 0 and all(arr[l:r]) and l < r:
        # l からrまですべて1以上のときはデクリメントし続ける
        arr = [a-1 if l <= idx and idx < r else a for idx, a in enumerate(arr)]
        count += 1
    # ずべてが0だったら終了
    if sum(arr) == 0:
        return
    # l以上r未満のどっかに0が含まれるので、含まれない範囲を抽出
    if arr[0] > 0:
        # 左端がl、以後0が見つかったらr, なかったら右端
        r = arr.index(0) if 0 in arr else len(arr)
        f(0, r, arr)
    elif arr[0] == 0:
        # 左から数えて最初に1以上のインデックスがl、その次の0もしくは右端がr
        a, b = -1, len(arr)
        for idx, x in enumerate(arr):
            if x == 0 and a > 0:
                b = idx
                break
            if x > 0 and a < 0:
                a = idx
        f(a, b, arr)


f(0, n, h)
print(count)


Measured memory_bytes: 3188
s=str(input())
y=int(s[0:4])
m=int(s[5:7])
d=int(s[8:])

if y <=2018:
    print("Heisei")
elif y >=2020:
    print("TBD")
elif m<=3:
    print("Heisei")
elif m>=5:
    print("TBD")
else:
    if d<=30:
        print("Heisei")
    else:
        print("TBD")


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int min_num = 1e8;
    int min_idx = -1;
    rep(i, n) {
        cin >> a[i];
        if ( min_num > a[i] ) {
            min_num = a[i];
            min_idx = i;
        }
    }
//    if ( k == n ) {
//        cout << 1 << endl;
//        return 0;
//    }
    int left_num = min_idx;
    int right_num = n - 1 - min_idx;
    int ans = ( left_num + right_num + k - 2 ) / ( k - 1 );
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll a;
  cin >> a;
  cout << 48-a << endl;

}

Measured memory_bytes: 3588
x = int(input())
Primes = [2]
cand = 2
max_prime = 2
while max_prime < x:
  cand = cand + 1
  for prime in Primes:
    if cand % prime == 0:
      break
  else:
    max_prime = cand
    Primes.append(cand)
print(max_prime)

Measured memory_bytes: 40684
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    // 各Xごとに最大設定可能な個数をカウントし，最大値を探す:O(N)
    map<int, int> X2NumMap;
    for (int i = 0; i < N; ++i)
    {
        int ai; cin >> ai;
        for (int j = -1; j <= 1; ++j)
        {
            ++X2NumMap[ai + j];
        }
    }
    cout << max_element(X2NumMap.begin(), X2NumMap.end(),
        [](const pair<int, int> &kvp1, const pair<int, int> &kvp2)
    { return kvp1.second < kvp2.second; })->second << '\n';
}


Measured memory_bytes: 4736
#include <stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK -1

int adj[MAX][MAX];
int d[MAX], f[MAX], color[MAX];

void visit(int u, int n){
  int i, j;
  static int time = 0;

  color[u] = GRAY;
  d[u] = ++time;

  for( j = 1; j <= n; j++){
    if( adj[u][j] == 1 ){
      if( color[j] == WHITE ) visit(j, n);
    }
  }

  color[u] = BLACK;
  f[u] = ++time;

}


void depthFirstSearch(int n){
  int i;

  for( i = 0; i < n; i++){
    color[i] = WHITE;
  }

  for( i = 1; i <= n; i++){
    if( color[i] == WHITE ) visit(i, n);
  }

}


main(){
  int i, j, n, k, u, v;

  scanf("%d", &n);

  for( i = 1; i <= n; i++){
    scanf("%d%d", &u, &k);
    for( j = 1; j <= k; j++){
      scanf("%d", &v);
      adj[i][v] = 1;
    }
  }

  depthFirstSearch(n);

  for( i = 1; i <= n; i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }

  return 0;

}

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

int main() {
  string s;
  cin >> s;
  int price = 700;
  if (s.at(0) == 'o') price += 100;
  if (s.at(1) == 'o') price += 100;
  if (s.at(2) == 'o') price += 100;  
  cout << price << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, A, Q, B, C;
  long long sum{};
  cin >> N;
  vector<int> v(100001,0);
  for (int i = 0; i != N; ++i) {
    cin >> A;
    ++v[A];
    sum += A;
  }
  cin >> Q;
  while(cin >> B >> C) {
    sum += (C-B)*v[B];
    v[C] += v[B];
    v[B] = 0;
    cout << sum << endl;
  }
}


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

// Common file
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}

/*****************************************************/

const int N = 2e5 + 3;
ll a[N] , af[N] , b[N] , bf[N] , n , m , k , ans = 0;
ll rem_book = 0;

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

    rep(i , n)
        cin >> a[i];
    rep(i , n)
        af[i + 1] = af[i] + a[i];

    rep(i , m)
        cin >> b[i];
    rep(i , m)
        bf[i + 1] = bf[i] + b[i];

    rep(i , n + 1) {
        rem_book= k - af[i];
        if(rem_book < 0)
            continue;
        ll remToK = lower_bound(bf , bf + m , rem_book) - bf;

        if(remToK > m || bf[remToK] > rem_book)
            --remToK;

        ans = max(ans , i + remToK);
        //cout << "ans: " << ans << " i: "
        //<< i << " rem_book: " << rem_book << " remToK: " << remToK << "\n";
    }

    cout << ans << "\n";

    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  int N = SZ(S);
  int ans = 0;
  for(int b=0,e=N-1;b<e;){
	if(S[b] == S[e]){
	  ++b;
	  --e;
	}
	else if(S[b] == 'x'){
	  ++ans;
	  ++b;
	}
	else if(S[e] == 'x'){
	  ++ans;
	  --e;
	}
	else{
	  ans = -1;
	  break;
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
data = []
while True:
    try:
        data.append(input())
    except EOFError:
        break

d = {}
for i in range(len(data)):
    i,n = data[i].split()
    if i in d:
        d[i].append(n)
    else:
        d[i] = [n]
d = sorted(d.items(), key = lambda x:x[0])
for i in range(len(d)):
    i,n = d[i]
    n = map(int,n)
    print(i)
    n = sorted(n)
    for i in range(len(n)-1):
        print(n[i], end = ' ')
    print(n[-1])

Measured memory_bytes: 7668
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 18:39:26 2020

@author: Kanaru Sato
"""

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(0,n):
    givenindex = n-1-i
    given = givenindex+1
    givenl = []
    
    for j in range(1,n+1):
        if given*j <= n:
            givenl.append(given*j)
        else:
            break
        
    sum = 0
    for j in givenl:
        sum += ans[j-1]
        
    if sum%2 == a[givenindex]:
        ans[givenindex] = 0
    else:
        ans[givenindex] = 1

sum = 0
for i in range(n):
    sum = sum + ans[i]
print(sum)

filledbox = []
for i in range(n):
    if ans[i] == 1:
        filledbox.append(i+1)
tmp = " ".join(map(str,filledbox))
print(tmp)

Measured memory_bytes: 27700
#include <iostream>

using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool flg=false;
    int ab,bc,ac;
    ab=b-a;
    if(ab<0)ab*=-1;
    bc=c-b;
    if(bc<0)bc*=-1;
    ac=c-a;
    if(ac<0)ac*=-1;

    if(ac<=d || (ab<=d && bc<=d ))flg=true;

    if(flg)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

struct Unionfind{
	vector<int> p;
	Unionfind(int n ):p(n, -1) {}
	int find(int x) {
		if (p[x] < 0) return x;
		return p[x] = find(p[x]);
	}

	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		return true;
	}

	bool same(int x, int y) { return(find(x) == find(y)); }
};

int main() {

	int n, q;;
	cin >> n >> q;
	int c, x, y;
	Unionfind uf(n);
	for (int i = 0; i < q; i++) {
		cin >> c >> x >> y;
		if (c == 0) uf.unite(x, y);
		else {
			cout << uf.same(x, y) << endl;
		}
	}
	return 0;
}


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

int main() {
	ll s[3];
	rep(i,0,3) cin>>s[i];
	sort(s,s+3);
	if (s[0]%2==0||s[1]%2==0||s[2]%2==0) cout<<0<<endl;
	else cout<<s[0]*s[1]<<endl;
}

Measured memory_bytes: 256