akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000007LL
#define ll long long
using namespace std;
struct edge{ int to,cap,rev; };
vector<edge> G[210];
int level[210];
int iter[210];
void add_edge(int from, int to, int cap){
	G[from].pb((edge){to,cap,(ll)G[to].size()});
	G[to].pb((edge){from,0,(ll)G[from].size()-1});
}

void bfs(int s){
	memset(level, -1, sizeof(level) );
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if( e.cap > 0 && level[e.to] < 0 ){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int  f){
	if( v == t ) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if( e.cap > 0 && level[v] < level[e.to] ){
			int d = dfs(e.to, t, min(f, e.cap));
			if( d > 0 ){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,LINF))>0){
			flow += f;
		}
	}
}
signed main(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if( a[i] <= 0 ){
			add_edge(0,i,-a[i]);
		}
		else{
			add_edge(i,101,a[i]);
			ans += a[i];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=2*i;j<=n;j+=i){
			add_edge(i,j,LINF);
		}
	}
	cout<<ans-max_flow(0,101)<<endl;
	return 0;
}

Measured memory_bytes: 256
// C - Monsters Battle Royale
#include <bits/stdc++.h>
using namespace std;

int in(){int x;cin>>x;return x;}

int gcd(int a, int b){return b? gcd(b, a%b): a;}

int main(){
	int N; cin>>N;
	int g = in();
	for(int i=0; i<N; ++i) g = gcd(g, in());
	cout<< g <<endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll d, t, s; cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3636
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n;
map<string,int>ma;
string s;
vector<string>v;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(ma[s]==0) v.pb(s);
        ma[s]++;
    }
    int maxi=0;
    for(auto isi:v){
        maxi=max(maxi,ma[isi]);
    }
    sort(v.begin(),v.end());
    for(auto isi:v){
        if(ma[isi]==maxi){
            cout<<isi<<endl;
        }
    }
}

Measured memory_bytes: 25968
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int LOG = 20;
const int N = (1 << LOG) + 10;
char str[N];

int ar[LOG + 1];
int arsz;

int dp[LOG + 1][1 << (LOG + 1)];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i <= n; i++)
    {
        scanf("%s", str);
        for (int j = 0; j < (1 << i); j++)
        {
            if (str[j] == '0') continue;
            dp[0][j | (1 << i)]++;
        }
    }
    for (int t = 0; t < LOG; t++)
    {
        eprintf("--- t = %d\n", t);
        int pos = 0;
        for (int i = 0; i < (1 << (LOG + 1)); i++)
        {
            int cur = dp[t][i];
            if (cur == 0) continue;
            while ((1 << (pos + 1)) <= i) pos++;
            int bnd = pos - t - 1;
            if (bnd < 0) continue;
            eprintf("i = %d, val = %d\n", i, cur);

            int x = (1 << (bnd + 1));
            int gen = (i >> (bnd + 1));
            int msk = (i & (x - 1));
            int b = (msk >> bnd) & 1;
            while (bnd >= 0 && ((msk >> bnd) & 1) == b)
                bnd--;
            
            dp[t][gen] += cur;
            dp[t + 1][i] += cur;
            eprintf("-> %d ", i);
            if (bnd >= 0)
            {
                int oth = ( ( (gen << 1) ^ 1 ^ b) << bnd) | (msk & ((1 << bnd) - 1));
                dp[t + 1][oth] += cur;
                eprintf("%d", oth);
            }
            eprintf("\n");
        }
    }
    for (int t = LOG; t >= 0; t--)
        for (int i = 0; i < (1 << (LOG + 1)); i++)
            if (dp[t][i] >= k)
            {
                for (int j = t - 1; j >= 0; j--)
                    printf("%d", (i >> j) & 1);
                printf("\n");
                return 0;
            }




	return 0;
}



Measured memory_bytes: 171392
import math

n, m = map(int, input().split())
if n <= 1:
    ans = 0
else:
    ans = math.factorial(n) / math.factorial(n - 2) / 2
if m <= 1:
        ans += 0
else:
    ans += math.factorial(m) / math.factorial(m - 2) / 2
print(int(ans))

Measured memory_bytes: 3060
N = int(input())
A = [0 for k in range(int(N**0.5)+1)]

#N=1の処理
if N == 1:
  print(0)
  exit()
ans = 0


prime = [2]
for k in range(3, len(A), 2):
  if A[k] == 0:
    prime.append(k)
    for j in range(k, len(A), k):
      A[j] = 1
for p in prime:
  if N%p == 0:
    break
else: 
  print(1)
  exit()

use = []
for p in prime:
  if p > N:
    break
  if N%p == 0:
    ans += 1
    use.append(p)
    N = N // p
  np = p * p
  while N % np == 0:
    ans += 1
    N = N // np
    np = np * p
    
for u in use:
  while N % u == 0:
    N = N // u
if N > 1:
  ans += 1
print(ans) 

Measured memory_bytes: 142360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N + 1);
  vector<int> deg(N + 1);
  rep(i, 0, N + M - 1) {
    int A, B;
    cin >> A >> B;
    G[A].push_back(B);
    deg[B]++;
  }
  queue<int> Q;
  rep(i, 1, N + 1) if(!deg[i]) Q.push(i);
  vector<int> par(N + 1);
  while(!Q.empty()) {
    int cur = Q.front(); Q.pop();
    for(auto p : G[cur]) {
      deg[p]--;
      par[p] = cur;
      if(!deg[p]) Q.push(p);
    }
  }
  rep(i, 1, N + 1) cout << par[i] << "\n";
  return 0;
}


Measured memory_bytes: 7040
// AtCoder_146A. Can't Wait for Holiday
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

ll q, t, a, b, c, d, m, n, k;
ll cnt, Mn, Mx, sum, sum1, sum2, ck;
ll arr1[1000], arr2[1000];

map <ll, ll> mp1, mp2;
set <ll> st1, st2;
vector <ll> vec1, vec2;
string str1, str2, str3;

int main()
{
    FIO;
    t = 1;
    string s, s1[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    while(t--)
    {
        cin >> s ;
        int pos;
        for(int i=0; i<7; i++){
            if(s == s1[i]){
                pos = i;
            }
        }
        cout << 7-pos << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<int> can;
	int l = sqrt(m);
	rep(i, 1, l)
	{
		if (m%i == 0)
		{
			can.push_back(i);
			can.push_back(m / i);
		}
	}
	int ans = 1;
	for (int x : can)
	{
		if (m / x >= n)ans = max(ans, x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

#include <queue>
#include <cstdio>

#include <list>
#include <set>


#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DIV_NUM (1000000007)

using namespace std;


bool seen[501][501];

int N,K;
int X, Y, Z;
int con;
//    string S;


char field[501][501];
int  dist[501][501];

typedef pair<int, int> P;
queue<P> que;


//typedef vector<vector<int>> v;
vector<double> v1;
vector<double> v2;


set<int> s1;


int main(){
  
  
    // input data
    int d = 0;


    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> d;
        s1.insert(d);
    }

    set<int>::iterator ite;;

    ite = s1.end();
 
    
    std::cout << *ite << "\n";

        return 0;

}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 111;
     
using namespace std;

ll n, q, k;

struct matrix{
	ll a[200][200];
	matrix() {}
	void read(){
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				cin >> a[i][j];
	}
	void ans(){
		ll h = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++){
				h += a[i][j];
				h %= mod;
			}
		cout << h;
	}
	void write(){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++)
				cout << a[i][j] << " ";
			cout << endl;
		}
	}
	void ff(){
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				a[i][j] = 0;
		for (int i = 1; i <= n; i++)
			a[i][i] = 1;
	}
	void operator *= (matrix &y){
		ll g[200][200];
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				ll h = 0;
				for (int q = 1; q <= n; q++){
					h += a[i][q] * y.a[q][j];
					h %= mod;
				}
				g[i][j] = h;
			}
		}
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				a[i][j] = g[i][j];
	}

};

matrix madpow(matrix x, ll b){
	matrix res;
	res.ff();
	while (b){
		if (b & 1)
			res *= x;
		x *= x;
		b >>= 1;
	}
	return res;
}

void solve(){                   
	cin >> n >> k;
	matrix x;
	x.read();
	matrix l = madpow(x, k);
	l.ans();
}

main(){
    boost;
	                 	
	q = 1;

	while (q--){
		solve();
	}
}


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

int main(){
    vector<string> divide={"dream", "dreamer", "erase" , "eraser"};
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
    string S;
    cin >> S;
    bool can = true;
    reverse(S.begin(),S.end());
    for (int i=0; i<S.size();){
        bool can2 = false;
        for (string str:divide){
            if (S.substr(i,str.size())==str){
                can2 = true;
                i += str.size();
            }
        }
        if (!can2){
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

struct node
{
	int num,fa,ls,rs;
	node(int _num,int _fa)
	{
		num=_num;
		fa=_fa;
		ls=rs=-1;
	}
};

typedef vector<node> Tree;

Tree T;

void insert(int t,int n)
{
	if(T[0].num==INT_MAX) 
		T[0].num=n;
	else if(T[t].num>n)
		if(T[t].ls==-1)
		{
			T[t].ls=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].ls,n);
	else
		if(T[t].rs==-1)
		{
			T[t].rs=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].rs,n);
}

void find(int t,int x)
{
	if(T.size()==0||t==-1)
		printf("no\n");
	else if(T[t].num==x)
		printf("yes\n");
	else if(x<T[t].num)
		find(T[t].ls,x);
	else find(T[t].rs,x);
}

void lc(int fa,int son)
{
	T[fa].ls=son;
	if(son!=-1) T[son].fa=fa; 
}

void rc(int fa,int son)
{
	T[fa].rs=son;
	if(son!=-1) T[son].fa=fa;
}

void del(int t,int x)
{
	if(T[t].num==x)
	{
		if(T[t].ls==-1)
			if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
					T[T[t].fa].ls=-1;
				else T[T[t].fa].rs=-1;
			else
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
		else if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].ls;
					T[T[t].rs].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].ls;
					T[T[t].rs].fa=T[t].fa;
				}
			else
			{
				int mir=T[t].rs;
				while(T[mir].ls!=-1) mir=T[mir].ls;
				del(t,T[mir].num);
				T[t].num=T[mir].num;
			}
	}
	else if(x<T[t].num)
		del(T[t].ls,x);
	else del(T[t].rs,x);
}

void Preorder(int t)
{
	if(t==-1) return;
	printf(" %d",T[t].num);
	Preorder(T[t].ls);
	Preorder(T[t].rs);
}

void Inorder(int t)
{
	if(t==-1) return;
	Inorder(T[t].ls);
	printf(" %d",T[t].num);
	Inorder(T[t].rs);
}

void print()
{
	Inorder(T[1].ls);
	printf("\n");
	Preorder(T[1].ls);
	printf("\n");
}

int main()
{
	T.clear();
	T.push_back(node(INT_MAX,1));
	T.push_back(node(-1,-1));
	T[1].ls=0;
	int n;
	scanf("%d",&n);
	while(n--)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int t;
			scanf("%d",&t);
			insert(T[1].ls,t);
		}
		else if(s[0]=='f')
		{
			int t;
			scanf("%d",&t);
			find(T[1].ls,t);
		}
		else if(s[0]=='d')
		{
			int t;
			scanf("%d",&t);
			del(T[1].ls,t);
		}
		else print();
	}
	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(3*N);
  for (int i = 0; i < 3*N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  ll sum = 0;
  for (int i = N; i < 3*N; i += 2) sum += A.at(i);
  cout << sum << endl;
  
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>a(N);
    vector<int>s(N+1);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        s[i+1] = s[i]+a[i];
    }
    vector<int>res;
    for(int i = 0; i <= N; i++) {
        for(int j = i; j <= N; j++) {
            res.push_back(s[j]-s[i]);
        }
    }
    vector<vector<int>>cnt(res.size(),vector<int>(50));
    for(int i = 0; i < res.size(); i++) {
        int X = res[i];
        int time = 0;
        while (time < 50) {
            cnt[i][time++] = X%2;
            X >>= 1;
        }
    }
    int ans = 0;
    set<int>st;
    for(int i = 0; i < res.size(); i++) {
        st.insert(i);
    }
    for(int i = 49; i >= 0; i--) {
        int sum = 0;
        for(int x:st) {
            if(cnt[x][i]) {
                sum++;
            }
        }
        if(sum >= K) {
            ans += pow(2,i);
            auto it = st.begin();
            while (it != st.end()) {
                if(cnt[*it][i] == 0) {
                    st.erase(it++);
                }
                else {
                    it++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 246676
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define len 100001
ll n, buf, a[len];

int main() {
	cin >> n;
	ll c = 0;
	for(ll i = 1; i <= len-1; i++){a[i] = 0;}
	for(ll i = 0; i < n; i++){cin >> buf; a[buf]++;}
	
	ll itemin = 0;
	ll itemax = len-1;
	
	ll omit = 0;
	ll even = 0;
	for(ll i = 1; i <= len-1; i++){
		if(a[i] >= 2 && a[i]%2 == 0){
			omit += a[i]-2;
			even++;
		}
		if(a[i] >= 2 && a[i]%2 == 1){
			omit += a[i]-1;
		}
	}
	omit += (even%2 == 0)? even : even+1;
	
	cout << n-omit << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
main()
{
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)printf(i==x-k+1?"%d":" %d",i);
    puts("");
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int[] B = new int[M];
        int sum = 0;
        int count = 0;

        for (int i = 0; i < M; i++) {
            B[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                sum += Integer.parseInt(sc.next()) * B[j];
            }
            if (sum + C > 0) {
                count++;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);
        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 36040
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		System.out.println((a-(a-a%60)/60%60-a%60)/3600+":"+(a-a%60)/60%60+":"+a%60);
	}
}

Measured memory_bytes: 26220
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N, vector<int>());
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;

    vector<vector<int>> dist;
    dist.assign(N, vector<int>(3, -1));
    dist[s][0] = 0;
    queue<P> queue;
    queue.push({s, 0});
    while (!queue.empty()) {
        P p = queue.front();
        queue.pop();
        int target = p.first;
        int cost = p.second;
        for (auto v : G[target]) {
            int tmp = (cost + 1) % 3;
            if (dist[v][tmp] == -1) {
                dist[v][tmp] = dist[target][cost] + 1;
                queue.push({v, tmp});
            }
        }
    }
    if (dist[t][0] == -1) {
        cout << -1 << endl;
    } else {
        cout << dist[t][0] / 3 << endl;
    }

}



Measured memory_bytes: 11136
# -*- coding: utf-8 -*-
from collections import deque

import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, C, D, S):
    C = (C[0]-1, C[1]-1)
    D = (D[0]-1, D[1]-1)
    q = deque()
    q.append((0, C))
    memo = {}
    T = 10**6
    while q:
        c, (x, y) = q.popleft()
        v = x*T + y
        if v in memo:
            continue
        memo[v] = c

        for nx in range(x-2, x+3):
            for ny in range(y-2, y+3):
                if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                    if abs(nx-x) + abs(ny-y) == 1:
                        q.appendleft((c, (nx, ny)))
                    else:
                        q.append((c+1, (nx, ny)))
    g = D[0]*T + D[1]
    return -1 if g not in memo else memo[g]


def main():
    H, W = read_int_n()
    C = read_int_n()
    D = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, C, D, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 247372
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    ll N;

    cin >> N;
    cout << (N%2 == 0 ? N : 2*N) << 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;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int n = 6;
    cout << n - a - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
const int N = 1E5 + 50;
int a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    int ans = 0, cur = a[n], temp = 0;
    for (int i = n - 1; i >= 1; i--)
    {
        if (a[i] >= cur)
            temp++;
        else
            ans = max(ans, temp), temp = 0;
        cur = a[i];
    }
    ans = max(ans, temp);
    printf("%d\n", ans);
    //system("pause");
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		long N = keyboard.nextLong();
		long P = keyboard.nextLong();
		
		HashMap<Long, Integer> prime = new HashMap<Long, Integer>();
		for (int i=2;1L*i*i<=P;i++) {
			while (P % i == 0) {
				int count = prime.containsKey((long)i) ? prime.get((long)i) : 0;
				prime.put((long)i, count + 1);
				P /= i;
			}
		}
		if (P != 1) prime.put(P, 1);
		
		long ans = 1;
        for (Map.Entry<Long, Integer> entry : prime.entrySet()) {
            for (int i=0; i < entry.getValue() / N; i++) {
        		ans *= entry.getKey();
        	} 
        }
		
		System.out.println(ans);
		keyboard.close();
	}
	
}


Measured memory_bytes: 35948
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = [LS() for _ in range(n)]
        s = S()
        k = S()
        l = len(k)
        if s == k:
            rr.append(0)
            continue
        u = set([s])
        c = set([s])
        t = 0
        r = -1
        while c:
            t += 1
            ns = set()
            for cs in c:
                for d,e in a:
                    nt = cs.replace(d,e)
                    if len(nt) > l:
                        continue
                    ns.add(nt)
            if k in ns:
                r = t
                break
            c = ns - u
            u |= ns
        rr.append(r)

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 9200
import sys
input = sys.stdin.readline
from operator import itemgetter

c = []

def main():
	global c
	n, m, q = map(int, input().strip().split())
	xy = [[0] * (n+1) for _ in range(n+1)]
	for i in range(m):
		l, r = map(int, input().strip().split())
		xy[l][r] += 1
	c = [[0] * (n+2) for _ in range(n+1)]
	for i in range(n+1):
		for j in range(n+1):
			c[i][j+1] = xy[i][j] + c[i][j]

	# print(c)
	for i in range(q):
		ans = 0
		p, q = map(int, input().strip().split())
		for k in range(p, q+1):
			ans += c[k][q+1] - c[k][p]
		print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 56156
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll pow(int x) {
	ll X = x;
	return X * X * X * X * X;
}

int main() {
	ll X; cin >> X;
	for (int A = 0; A <= 1000; ++A) {
		for (int B = -1000; B <= 1000; ++B) {
			if (pow(A) - pow(B) == X) {
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

int main() {
    ll n,k;cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        a[i]--;
    }
    int b[n]{};
    fill(b,b+n,-1);
    int start;
    int one;
    for (int i=0,c=0;;i++) {
        if (i==k) {
            cout<<c+1<<endl;
            return 0;
        }
        if (b[c]!=-1) {
            start=c;
            k-=b[c];
            one=i-b[c];
            break;
        }
        b[c]=i;
        c=a[c];
    }
    k%=one;
    for (int i=0;i<k;i++)
        start=a[start];
    cout<<start+1<<endl;
    return 0;
}

Measured memory_bytes: 5196
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,c,x,y;
    int a[200000],b[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(a,a+n);
    x=a[n/2-1];
    y=a[n/2];
    
    for(int i=0;i<n;i++){
        if(b[i]<=x)printf("%d\n",y);
        else printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
#define ll long long

/*string mycmp(string a,string b)
{
    string p=a,q=b;
    string x=p.append(q),y=b.append(a);
    //cout<<p<<"p "<<x<<"x "<<q<<"q "<<y<<endl;
    if(x.compare(y)>0)
        return x;
    else
        return y;
}

string largestNumber(const vector<int> &A) {
    vector<int>v;
    if(A.size()==0)
        return "";
    int t=-1;
    for(int i=0;i<A.size();i++){
        t+=A[i];
        v.push_back(to_string(A[i]));
    }
    t+=1;
    if(t==0)
        return "0";
    sort(v.begin(),v.end());
}

*/
int main() {
	/*ios::sync_with_stdio(false);
	cin.tie(0);*/
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=0,cm=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]>cm)
            cm=a[i];
        if(a[i]<cm)
        {
            ans+=(cm-a[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5180
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<ctime>
#include<cstring>
#include<cstdio>
#define IOS ios::sync_with_stdio(false); cin.tie(0); 
using namespace std;
typedef pair<int,int> PII;
const int N=25;
const int INF=0x3f3f3f3f;
int n,m;
int main(){
	IOS;
	//clock_t starttime,endtime;	
	//starttime=clock();
	cin>>n>>m;
	int ans=0;
	ans=(n*(n-1))/2+(m*(m-1))/2;
	cout<<ans<<endl;
	//endtime=clock();
	//cout<<(double)(endtime - starttime) / CLOCKS_PER_SEC<<"s"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int ans = 0;
    if( X <=599 )
    {
        ans = 8;
    }
    else if(X <=799)
    {
        ans = 7;
    }
    else if(X <=999)
    {
        ans =6;
    }
    else if(X <=1199)
    {
        ans = 5;
    }
    else if(X <=1399)
    {
        ans = 4;
    }
    else if(X <= 1599)
    {
        ans = 3;
    }
    else if(X <= 1799)
    {
        ans = 2;
    }
    else
    {
        ans = 1;
    }

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

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

vector<vector<int>> tree;
vector<int> cnt;
void dep(int c,int p){
    for(int a:tree[c]) if(a!=p){cnt[a]+=cnt[c];dep(a,c);}
    return;
}
int main(){
    int n,q;
    cin>>n>>q;
    tree.assign(n,vector<int>(0));
    cnt.assign(n,0);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        cnt[p-1]+=x;
    }
    dep(0,-1);
    rep(i,n)cout<<cnt[i]<<' ';
    return 0;
}

Measured memory_bytes: 23424
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

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

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int flag = 0;
    while (true) {
        if (flag == 0) {
            if (a + 1 == b) {
                if (a == 1) {
                    cout << "Borys" << endl; return 0;
                } else {
                    a = a - 1;
                }
            } else {
                a = a + 1;
            }
        } else {
            if (b - 1 == a) {
                if (b == n) {
                    cout << "Alice" << endl; return 0;
                } else {
                    b = b + 1;
                }
            } else {
                b = b - 1;
            }
        }
        flag ^= 1;
    }
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define Graph vector<vector<int>>

int main() {
  
  int H,W;
  cin >> H >> W;

  Graph A( H , vector<int> (W,0) );
  Graph count( H , vector<int> (W,0) );
  queue< pair<int,int> > que;

  rep(y,H){
    rep(x,W){

      char a;
      cin >> a;
      if( a == '#' ){
       A[y][x]=1;
       count[y][x]=0;
       que.push( make_pair(x,y) );
      }
      if( a == '.' ) A[y][x]=0; //白の時0 
   
    }
  }

  vector<int> dx = { 0, 1, 0, -1 };
  vector<int> dy = { 1, 0, -1, 0 };
  int res = 0;
  
  while( !que.empty() ){

        pair<int,int> v = que.front();
        que.pop();

        int x = v.first;
        int y = v.second;

        rep(i,4) {

            int nv_x = x + dx[i];
            int nv_y = y + dy[i];

            //通れるか？
            if ( nv_x < 0 || nv_x >= W ) continue;
            if ( nv_y < 0 || nv_y >= H ) continue;
            if ( A[nv_y][nv_x] == 1 ) continue;
            
            A[nv_y][nv_x] = 1;
            count[nv_y][nv_x] = count[y][x] +1;
            res = count[nv_y][nv_x];
            que.push( make_pair(nv_x,nv_y) );

        }
    }
   
  printf("%d\n", res );
  return 0;

}

Measured memory_bytes: 16272
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = arr[0];
    int m = arr[1];
    var a = new string[n];
    var b = new string[m];
    for (int i = 0; i < n; i++) {
      a[i] = Console.ReadLine();
    }
    for (int i = 0; i < m; i++) {
      b[i] = Console.ReadLine();
    }
    bool incld = false;
    for (int i = 0; i <= n - m; i++) {
      bool f = false;
      for (int j = 0; j <= n - m; j++) {
        var t = a[i].Substring(j, m);
        if (t == b[0]) {
          f = true;
          for (int k = 1; k < m; k++) {
            if (a[i + k].Substring(j, m) != b[k]) {
              f = false;
              break;
            }
          }
        }
      }
      if (f) {
        incld = true;
        break;
      }
    }
    Console.WriteLine(incld ? "Yes" : "No");
  }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

V<int> power(V<int> s, int k) {
   int n = s.size();
   V<int> res(n);
   for (int i = 0; i < n; i++) res[i] = i;

   while (k > 0) {
      if (k & 1) {
         V<int> tmp(res);
         for (int i = 0; i < n; i++) {
            res[i] = tmp[s[i]];
         }
      }
      k >>= 1;
      V<int> tmp(s);
      for (int i = 0; i < n; i++) {
         s[i] = tmp[tmp[i]];
      }
   }

   return res;
}

signed main()
{
   int n; cin >> n;
   V<int> x(n);
   for (int i = 0; i < n; i++) {
      cin >> x[i];
   }
   int m, k; cin >> m >> k;
   V<int> a(m);
   for (int i = 0; i < m; i++) {
      cin >> a[i];
      a[i]--;
   }

   V<int> s(n-1);
   for (int i = 0; i < n-1; i++) {
      s[i] = i;
   }
   for (int i = 0; i < m; i++) {
      swap(s[a[i]-1], s[a[i]]);
   }

   s = power(s, k);

   V<int> d(n-1);
   for (int i = 0; i < n-1; i++) {
      d[i] = x[i+1] - x[i];
   }

   int sum = 0;
   for (int i = 0; i < n; i++) {
      cout << x[0] + sum << endl;
      if (i != n-1) sum += d[s[i]];
   }

   return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>

int main(){
	char op;
	int a,b;

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

	if (op == '-') {
		printf("%d\n", a-b);
	}else{
		printf("%d\n", a+b);
	}
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll l = c / gcd(c, d) * d;

    ll cnt = (b/c - (a-1)/c) + (b/d - (a-1)/d) - (b/l - (a-1)/l);
    
    cout << b-a+1-cnt << endl;
}


Measured memory_bytes: 256
import re

# ?があるとエラーが起きるので
# "."は、メタ文字（特別な意味を持つ文字）
# https://qiita.com/hiroyuki_mrp/items/29e87bf5fe46de62983c
s = input().replace('?', '.')
t = input()
#print("s,t:", s, t)

for i in range(len(s) - len(t), -1, -1):
    # re.match : 文字列の先頭がマッチするかチェック、抽出
    if re.match(s[i:i + len(t)], t):
        #print(s[i:i + len(t)], t)
        s = s.replace('.', 'a')
        print(s[:i] + t + s[i + len(t):])
        exit()

print('UNRESTORABLE')


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int n, k;
std::vector<int> buf = { 1 };

void separate(int cursum=1, int comb=0) {
    comb += (cursum - buf.back())*buf.back();
    if (comb == k) {
        throw 1;
    }
    for (int i = buf.back(); i + cursum <= n - 1; i++) {
        buf.push_back(i);
        separate(cursum + i, comb);
        buf.pop_back();
    }
}


int main() {
    std::cin >> n >> k;
    if (k > (n - 1)*(n - 2) / 2) {
        std::cout << -1 << std::endl;
        return 0;
    }
    bool found = false;
    try {
        separate();
    } catch(int) {
        found = true;
    }
    if (!found) {
        std::cout << -1 << std::endl;
        return 0;
    }
    int sum = std::accumulate(buf.begin(), buf.end(), 0);
    std::vector<std::pair<int, int>> ans;
    int pos = 0;
    for (int t : buf) {
        for (int i = pos; i < pos + t; i++) {
            for (int j = i + 1; j < pos + t; j++) {
                ans.emplace_back(i + 1, j + 1);
            }
            for (int j = sum; j < n; j++) {
                ans.emplace_back(i + 1, j + 1);
            }
        }
        pos += t;
    }
    for (int i = sum; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans.emplace_back(i + 1, j + 1);
        }
    }
    std::cout << ans.size() << std::endl;
    for (const auto &e : ans) {
        std::cout << e.first << " " << e.second << std::endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
   int n,h,w;
   cin >> n >> h >> w;
    int ans = 0;
   
   rep(i,n) {
       int a,b;
       cin >> a >> b;
       if(h<=a && w<=b) {
           ans++;
       }
   }
   cout << ans << endl;

}



Measured memory_bytes: 3536
#include <stdio.h>
#define maxn 100010
#define LL long long
LL rd[maxn]={1,2,3,4,5,6,7,8,9};
int main(){
	int i,id,k;
	scanf("%d",&k);
	i=9,id=0;
	while(i<k){
		if(rd[id]%10==0){
			rd[i]=rd[id]*10;
			rd[i+1]=rd[id]*10+1;
			i+=2;
		}else if(rd[id]%10==9){
			rd[i]=rd[id]*10+8;
			rd[i+1]=rd[id]*10+9;
			i+=2;
		}else{
			rd[i]=rd[id]*10+rd[id]%10-1;
			rd[i+1]=rd[id]*10+rd[id]%10;
			rd[i+2]=rd[id]*10+rd[id]%10+1;
			i+=3;
		}
		id++;
	}
	printf("%lld",rd[k-1]);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

int main() {
  //ios_base::sync_with_stdio(false);
  //cin.tie(0);
  int N;
  long long count = 0,t1,t2;
  cin >> N;
  vector<long long> temp(N);
  map<long long, long long>times;
  for(auto&i:temp){
    cin >> i;
    ++times[i];
  }
  for(auto&i:times){
    count += i.second*(i.second - 1) / 2;
  }
  for(auto&i:temp){
    t1 = times.at(i);
    t1 = t1*(t1-1)/2;
    t2 = times.at(i)-1;
    t2 = t2*(t2-1)/2;
    cout << count-t1+t2 << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int mi=10000;
    for ( int i=0; i<n; i++ ) {
        int a;
        cin >> a;
        int c=0;
        while ( a%2==0 ) {
            c++;
            a/=2;
        }
        mi=min(mi,c);
    }
    cout << mi << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];  //Aという配列を作成。N＋1個の配列がある。

//	いずれかのAに0が含まれる場合
		for(int i=0 ; i<N ; i++) {
			A[i]=sc.nextLong();  //入力された配列の読み込み
			if(A[i] == 0) {
				System.out.println(0);
				return;
			}
		}

//	Aへの入力の時点で結果が「-1」になる場合
		long total = 1;  //計算結果を表す変数
		for(int i=0 ; i<N ; i++) {
			if(A[i] > 1000000000000000000L / total) {
				System.out.println(-1);
				return;
			}
			else {
				total *= A[i];
			}
		}

//	計算してみないと「-1」になるかわからない場合
		if(total <= 1000000000000000000L) {
			System.out.print(total);
		}
		else {
			System.out.print(-1);
		}
	}
}

Measured memory_bytes: 61124
#include<cstdio>
//dp'[i][j][k]=({0,1,2,3}個の寿司が置いてある皿が{n-i-j-k,i,j,k}個から始めたときの操作回数の期待値)
//            =(dp'[i-1][j][k]+1)*(i/n)+(dp'[i+1][j-1][k]+1)*(j/n)+(dp'[i][j+1][k-1]+1)*(k/n)+(dp'[i][j][k]+1)*((n-i-j-k)/n)
//整理すると、(i+j+k)*dp'[i][j][k]=i*dp'[i-1][j][k]+j*dp'[i+1][j-1][k]+k*dp'[i][j+1][k-1]+n
//dp'[i][j][k]=dp[i+j+k][j+k][k]と書き直すと、
//(i+j+k)*dp[i+j+k][j+k][k]=i*dp[i-1+j+k][j+k][k]+j*dp'[i+1+j-1+k][j-1+k][k]+k*dp'[i+j+1+k-1][j+1+k-1][k-1]+n
//m=i+j+k, l=j+kと書き直すと、
//m*dp[m][l][k]=(m-l)*dp[m-1][l][k]+(l-k)*dp[m][l-1][k]+k*dp[m][l][k-1]+n
double dp[301][301][301];
int main(){
    int n,cnt[4]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        cnt[a]++;
    }
    dp[0][0][0]=0;
    for(int m=1;m<=n;m++){
        for(int l=0;l<=m;l++){
            for(int k=0;k<=l;k++){
                dp[m][l][k]=((m-l)*dp[m-1][l][k]+(l-k)*dp[m][l-1][k]+k*dp[m][l][k-1]+n)/m;
            }
        }
    }
    printf("%1.14lf",dp[cnt[1]+cnt[2]+cnt[3]][cnt[2]+cnt[3]][cnt[3]]);
    return 0;
}

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

using namespace std;
const int INF = 1234567890;
const int MAXN = 100005;
struct edge {
  int to, cost;
};
vector<edge> G[MAXN];
int d[MAXN];
bool is_valid = true;

void dfs(int cur, int prev) {
  for (auto e: G[cur]) {
    if (e.to == prev) continue;
    if (d[e.to] == INF) {
      d[e.to] = d[cur] + e.cost;
      dfs(e.to, cur);
    }

    if (d[e.to] != INF && d[cur] + e.cost != d[e.to]) is_valid = false;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    --l; --r;
    G[l].emplace_back(edge{r, d});
    G[r].emplace_back(edge{l, -d});
  }

  for (int i = 0; i < n; ++i) d[i] = INF;
  for (int i = 0; i < n; ++i) {
    if (d[i] != INF) continue;
    d[i] = 0;
    dfs(i, -1);
  }
  if (!is_valid) {
    printf("No\n");
  } else { 
    printf("Yes\n");
  }
  return 0;
}



Measured memory_bytes: 13824