akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList list1 = new ArrayList<Integer>();
        ArrayList list2 = new ArrayList<Integer>();

        int K = sc.nextInt();
        for (int i = 0; i < K; i++) {
            list1.add(sc.nextInt());
        }

        for (int i = 0; i < N-1; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (list1.contains(A)) {
                    list2.add(A);
                }
            }
            list1.clear();
            for (int j = 0; j < list2.size(); j++) {
                list1.add(list2.get(j));
            }
            list2.clear();
        }

        System.out.println(list1.size());
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N,M;
    cin>>N>>M;
    vector<vector<int>> g(N);
    vi a(M),b(M);
    REP(i,M) {
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    int x=a[0],y=b[0];
    vector<bool> contain(N,false);
    deque<int> path;
    path.push_back(x);
    path.push_back(y);
    contain[x]=contain[y]=true;
    while(1) {
        bool ok=true;
        FORE(i,g[x]) {
            if(!contain[i]) {
                ok=false;
                x=i;
                path.push_front(x);
                contain[x]=true;
                break;
            }
        }
        if(ok) {
            break;
        }
    }
    while(1) {
        bool ok=true;
        FORE(i,g[y]) {
            if(!contain[i]) {
                ok=false;
                y=i;
                path.push_back(y);
                contain[y]=true;
                break;
            }
        }
        if(ok) {
            break;
        }
    }
    cout<<SZ(path)<<endl;
    REP(i,SZ(path)) {
        cout<<path[i]+1;
        if(i!=SZ(path)-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

bool x=1 , y=1 , a=0 , b=0 , c=0 , d = 0;

string s;

int main()
{
	cin >> s;
	
	for (int i = 0 ; i < (int)s.size() ; i++){
		if(s[i] == 'N'){
			a=1;
		}
		else if(s[i] == 'S'){
			b=1;
		}
		else if(s[i] == 'W'){
			c=1;
		}
		else if(s[i] == 'E'){
			d=1;
		}
		if((a==0 && b==1)||(a==1 && b==0)){
			x=0;
		}
		else if((a==1 && b==1)||(a==0 && b==0)){
			x=1;
		}
		if((c==0 && d==1)||(c==1 && d==0)){
			y=0;
		}
		else if((c==1 && d==1)||(c==0 && d==0)){
			y=1;
		}
	}
	if(x==1 && y==1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15);}} ioset;

int n;
long double dp[301][301][301];
bool flag[301][301][301];

long double rec(int i, int j, int k) {
    if (flag[i][j][k]) return dp[i][j][k];
    if (i + j + k == 0) return 0.0;
    double x = 0;
    if (i) x += rec(i - 1, j, k) * i / (i + j + k);
    if (j) x += rec(i + 1, j - 1, k) * j / (i + j + k);
    if (k) x += rec(i, j + 1, k - 1) * k / (i + j + k);
    flag[i][j][k] = true;
    return dp[i][j][k] = x + (double)n / (i + j + k);
}

int main() {
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> cnt(3, 0);
    rep(i, n) ++cnt[a[i] - 1];
    cout << rec(cnt[0], cnt[1], cnt[2]) << "\n";
    return 0;
}


Measured memory_bytes: 227284
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        immutable N = 8;
        auto c = s.split().map!(to!int).array();
        auto a = [4,1,4,1,2,1,2,1].cycle().take(N*2).array();
        int v=int.min;
        int p;
        int n;
        foreach(i;0..N)
        {
            auto b = a[i..i+N];
            auto u = zip(c,b).map!(t=>min(t[0],t[1])).reduce!"a+b"();
            if(v<=u)
            {
                auto m = b.map!(to!string).join().to!int();
                if(v<u || n>m)
                    v=u,p=i,n=m;
            }
        }
        a[p..p+N].map!(to!string).join(" ").writeln();
    }
}

Measured memory_bytes: 1512
n = int(input())
sn = [ input() for i in range(n)]

m, a, r, c, h = 0, 0, 0, 0, 0

for s in sn:
    if s[0] == "M":
        m += 1
    elif s[0] == "A":
        a += 1
    elif s[0] == "R":
        r += 1
    elif s[0] == "C":
        c += 1
    elif s[0] == "H":
        h += 1

print(
    m * a * r
    + m * a * c
    + m * a * h
    + m * r * c
    + m * r * h
    + m * c * h
    + a * r * c
    + a * r * h
    + a * c * h
    + r * c * h)

Measured memory_bytes: 9772
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<set>
#include<string>


using namespace std ;


string s[ 10 ] ;

set< string > ans ;


int main( void )
{
	int n ,k ;
	while( 1 )
	{
		scanf( "%d %d" ,&n ,&k ) ;

		if( n | k )
		{
			for( int i = 0 ; i < n ; ++i )
			{
				cin >> s[ i ] ;
			}

			sort( s ,s + n ) ;

			do
			{
				string in = "" ;

				for( int i = 0 ; i < k ; ++i )
					in += s[ i ] ;

				ans.insert( in ) ;

			}while( next_permutation( s ,s + n ) ) ;


			cout << ans.size() << endl ;

			ans.clear() ;
		}

		else
		{
			return 0 ;
		}
	}
}

Measured memory_bytes: 3380
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;

    int n = sz(s);
    int ans = 0;
    rep(i, n) ans += s[i] - '0';
    int temp = s[0] - '0' - 1;
    temp += 9 * (n - 1);
    cout<<max(ans, temp)<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MAX_N = 1e5+10;

ll n, a[MAX_N];

template <class T> struct FenwickTree {
  vector<T> node;
  FenwickTree (int N) : node(N, 0) {}

  void add(int idx, T val){
    for (int i = idx; i < node.size(); i |= i + 1) {
      node[i] += val;
    }
  }

  void update(int idx, T val){
    add(idx, -sum(idx, idx+1));
    add(idx, val);
  }

  T sum(int idx){
    T ret = 0;
    for (int i = idx-1; i >= 0; i = (i & (i+1))-1){
      ret += node[i];
    }
    return ret;
  }

  T sum(int l, int r){
    return sum(r)-sum(l);
  }
};

ll InversionNumber(vector<int> &arr){
  ll ret = 0;
  FenwickTree<ll> inst(MAX_N);
  for (int i = 0; i < arr.size(); ++i){
    ret += inst.sum(arr[i]+1);
    inst.add(arr[i], 1);
  }
  return ret;
}


bool check(ll x){
  vector<int> S(n+1,0);
  for (int i = 0; i < n; ++i){
    S[i+1] = (a[i]>=x) ? 1 : -1;
  }
  for (int i = 0; i < n; ++i) S[i+1] += S[i];
  int minV = S[0];
  for (int i = 0; i < n+1; ++i) minV = min(minV, S[i]);
  for (int i = 0; i < n+1; ++i) S[i] -= minV;
  for (int i = 0; i < n+1; ++i) S[i]++;

  ll inv = InversionNumber(S);
  ll num = n*(n+1)/2 + 1;
  return (num/2 <= inv) ? true : false;
}


int main(int argc, char const *argv[]) {
  cin >> n;
  vector<ll> b(MAX_N);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    b[i] = a[i];
  }

  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());

  int l = 0, r = b.size();
  while (r-l>1){
    int mid = (l+r)/2;
    if (check(b[mid])) l = mid;
    else r = mid;
  }

  cout << b[l] << endl;
  
  return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
ll n,w,W[N],v[N];
ll dp[105][N];
ll solve(ll idx,ll capacity)
{
    if(idx==n)
       return 0;
  if(dp[idx][capacity]!=-1)
    return dp[idx][capacity];
  if(capacity+W[idx]<=w)        // take                                          //leave
    dp[idx][capacity]=max(solve(idx+1,capacity+W[idx])+v[idx],solve(idx+1,capacity));
  else                          // leave
     dp[idx][capacity]=solve(idx+1,capacity);
   return dp[idx][capacity];
}
int main()
{
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        cin>>W[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
    return 0;
}


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

using namespace std;

int N;
int DpCount[100000];

int main() {
	string s, t;

	cin >> N >> s >> t;
	DpCount[s[0] - 'a'] = 1;
	--N;
	for (int i = 1; i < N; ++i) {
		DpCount[s[i] - 'a'] = (DpCount[s[i] - 'a'] + DpCount[t[i] - 'a']) % 1000000007;
	}
	cout << DpCount[t[N] - 'a'] << endl;

	return 0;
}


Measured memory_bytes: 3348
n = int(input())
s1 = str(input())
s2 = str(input())

mod = 10**9+7
ans = 1
flag = False
for i in range(n):
    if s1[i] == s2[i]:
        if i == 0:
            ans *= 3
        else:
            if flag:
                ans *= 2
            else:
                ans *= 1
        flag = True
    else:
        if i == n-1:
            continue
        else:
            if s1[i] == s1[i+1] and s2[i] == s2[i+1]:
                if i == 0:
                    ans *= 6
                else:
                    if flag:
                        ans *= 2
                    else:
                        ans *= 3
            else:
                continue
        flag = False
    ans %= mod
print(ans)


Measured memory_bytes: 38384
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int INF = 0x3f3f3f3f;
char ar[55][55];
int cr[55][55];
int h,w;
int fr[] = {0,-1,0,1};
int se[] = {-1,0,1,0};

void bfs(int x,int y)
{
    int tx,ty;
    for(int i=0;i<4;i++){
        tx=fr[i]+x;
        ty=se[i]+y;
        if(tx>=1&&tx<=h&&ty>=1&&ty<=w&&ar[tx][ty] == '.'){
            if(cr[tx][ty] > cr[x][y]+1){
                cr[tx][ty] = cr[x][y] + 1;
                bfs(tx,ty);
            }
        }
    }
}

int main()
{
    while(~scanf("%d%d",&h,&w)){
        int cnt = 0;
        memset(cr,INF,sizeof(cr));
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                scanf(" %c",&ar[i][j]);
                if(ar[i][j] == '#')
                    cnt++;
            }
        }
        cr[1][1] = 0;
        bfs(1,1);
        int ans;
        if(cr[h][w] == INF){
            ans = -1;
        }
        else{
            ans = h*w - cnt - cr[h][w] - 1;

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


Measured memory_bytes: 256
import numpy as np
import sys

S = input()
T = input()

counter = 0
max_counter = 0

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        if S[j+i] == T[j]:
            counter = counter + 1
    if counter > max_counter:
        max_counter = counter
    # print(counter)
    # print('max = ' + str(max_counter))
    counter = 0

print(int(len(T)) - int(max_counter))

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const int mxn = 1e7+7;

ll a[mxn], sum = 0;

int main(){
	setIO();
	int n; cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j*i <= n; j++){
			a[i*j]++;
		}
	}
	for (int i = 1; i <= n; i++){
		sum += (i*a[i]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 81768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		int one = in.nextInt() ; 
		int two = in.nextInt() ;
		int three = in.nextInt() ;
		
		int temp ;
		if(one>two) {
			temp = one ;
			one = two ;
			two = temp ;
		}
		
		if(three>one && three<two)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 23124
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  typedef pair<int, int> P;
  int N, A, B; cin >> N;
  vector<P> vec(N);
  REP(i, N) {
    cin >> A >> B;
    vec[i] = P(B, A);
  }
  sort(ALL(vec));
  int sum = 0;
  REP(i, N){
    sum += vec[i].second;
    if(sum > vec[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var abc = new int[n][];
            var dp = new int[n][];
            for (int i = 0; i < n; i++)
            {
                abc[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
                dp[i] = new int[3] { 0, 0, 0 };
            }

            dp[0] = abc[0];

            for (int i = 1; i < n; i++)
            {
                for (int j=0;j<3;j++)
                {
                    int cmax = 0;
                    for(int k=0;k<3;k++)
                    {
                        if(j!=k)
                        {
                            cmax = Max(cmax, dp[i-1][k] + abc[i][j]);
                        }
                    }
                    dp[i][j] = cmax;
                }
            }

            Console.WriteLine(dp.Last().Max());
        }
    }
}


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

int main() {

    int N, A, B;
    cin >> N >> A >> B;
    
    if (N * A > B) {
        cout << B << endl;
    }
    
    if (N * A < B) {
        cout << N * A << endl;
    }
    
    if (N * A == B) {
        cout << N * A << endl;
    }
            
 }

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

int n;
ll s[100010], ss[100010], b, ans, cur;

ll f(){
	ll ans = 0;
	for(int i = 2; i <= n; i++){
		if(b + s[i] == 0){
			if(s[i - 1] < 0) b++;
			else b--;
			ans++;
		}
		else if(b + s[i] > 0 && s[i - 1] > 0){
			ans += abs(s[i] + b + 1);
			b -= s[i] + b + 1;
		}
		else if(b + s[i] < 0 && s[i - 1] < 0){
			ans += abs(s[i] + b - 1);
			b -= s[i] + b - 1;
		}
		s[i] += b;
	}
	return ans;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){ scanf("%lld", s + i); s[i] += s[i - 1]; ss[i] = s[i]; }
	if(s[1] <= 0){ cur = b = 1 - s[1]; s[1] = 1; }
	ans = f() + cur;
	cur = 0; b = 0;
	for(int i = 1; i <= n; i++) s[i] = ss[i];
	if(s[1] >= 0){ cur = s[1] + 1; b = -s[1] - 1; s[1] = -1; }
	ans = min(ans, f() + cur);
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  cout << "Christmas";
  if ( D < 25 ) {
    cout << " Eve";
      if ( D < 24 ) {
        cout << " Eve";
        if ( D < 23 ) {
          cout << " Eve";
        }
      }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f[15];
int main()
{
	memset(f,true,sizeof(f));
	int n,k;
	int pos;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int m;
		cin>>m;
		f[m]=false;
	}
	for(int i=n; ;i++)
	{
		int cnt=0;
		int ans=0;
		pos=i;
		int p=i;
		while(p!=0)
		{
			int q=p%10;
			if(f[q])
				ans++;
			cnt++;
			p/=10;
		}
		//cout<<ans<<" "<<cnt<<endl;
		if(ans==cnt)
			break;
		else continue;
	}
	cout<<pos<<endl;
}

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

int main() {
    int N, count = 0;
    cin >> N;
    int A[101][2];
    for (int i = 0; i < N; i++) {
        cin >> A[i][0] >> A[i][1];
    }
    for (int i = 0; i < N; i++) {
        if (A[i][0] == A[i][1]) count++;
        else count = 0;
        if (count >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int n, s;
int ans;
bool used[10];

void dfs (int curr, int curr_s, int pre )
{
	if (curr >= n ){
		if (curr_s == s ) ans++;
		return;
	} // end if

	for (int i = pre+1; i < 10; i++ ){
		if (!used[i] ){
			used[i] = true;
			dfs (curr+1, curr_s + i, i );
			used[i] = false;
		} // end if
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Sum_of_Integers", "r", stdin );
	while (scanf ("%d %d", &n, &s ) ){
		if (n == 0 && s == 0 ) break;
		memset (used, false, sizeof (false ) );
		ans = 0;
		dfs (0, 0, -1 );
		printf ("%d\n", ans );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,t,time,count;
  cin >> a >> b >> t;
  count = 0;
  time = 0;
  while(1){
    time += a;
    if(time > t) break;
    count += b;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  rep(i,k){
    ans += vec[i];
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

int main()
{
	lint N,K;

	cin >> N >> K;

	lint comb[2010][2010]={};
	for(int i=0;i<=N;i++)
		comb[i][0]=1;
	for(int n=1;n<=N;n++)
	{
		for(int r=1;r<=n;r++)
		{
			comb[n][r]=comb[n-1][r]+comb[n-1][r-1];
			comb[n][r]%=mod;
		}
	}

	for(lint i=1;i<=K;i++)
		cout << (comb[N-K+1][i]*comb[K-1][i-1])%mod << endl;
	
	return 0;
}



Measured memory_bytes: 31872
import sys

sys.setrecursionlimit(10000)

n, m, p = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(m)]
al = [[] for _ in range(n)]

for i in range(m):
    abc[i][0] -= 1
    abc[i][1] -= 1
    abc[i][2] = -(abc[i][2] - p)

for a, b, c in abc:
    al[a].append(b)

d = [1e9] * n
d[0] = 0

for _ in range(n - 1):
    for u, v, c in abc:
        if d[v] > d[u] + c:
            d[v] = d[u] + c

res = -d[-1]

for _ in range(n - 1):
    for u, v, c in abc:
        if d[v] > d[u] + c:
            d[v] = d[u] + c
    

if res != -d[-1]:
    print(-1)
else:
    print(max(res, 0))


Measured memory_bytes: 54872
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=1e4+10;
typedef long long ll;
int x,y,z; 
int f[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int ans = 0;
        for (int x = 1; x * x < i; x++) {
            for (int y = 1; y * y + x * x + x * y < i; y++) {
                int j = x + y, m = i - x * x - y * y - x * y;
                int z = (sqrt(1.0 * j * j + 4.0 * m) - j) / 2;
                if (x * x + y * y + z * z + x * y + x * z + y * z == i)
                    ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print('Yes' if 'AC' in s else 'No')


Measured memory_bytes: 38384
H, W = map(int, input().split())
A = [input() for _ in range(H)]
cnt = 0
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            cnt += 1
if cnt == H + W -1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c) cout<<1<<endl;
    else if(a!=b&&b!=c&&c!=a) cout<<3<<endl;
    else cout<<2<<endl;
}



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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

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

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;


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

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

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;

        map<int,int> x, y;
        x[0] = y[0] = 0;
        FOR(i, 1, n) {
            int j, d; cin >> j >> d;
            x[i] = x[j] + dx[d];
            y[i] = y[j] + dy[d];
        }

        int l = 0, r = 0, t = 0, b = 0;
        REP(i, n) {
            chmin(l, x[i]);
            chmax(r, x[i]);
            chmin(b, y[i]);
            chmax(t, y[i]);
        }

        cout << r - l + 1 << " " << t - b + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  string s; cin >> s;
  bool flag = true;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) flag = false;
  cout << (flag ? "Good" : "Bad") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;


struct poi
{
 int64 xx;
 int64 yy;
 
 bool operator < (const poi &right) const
 {
  return xx == right.xx ? yy < right.yy : xx < right.xx;
 }
};

int main()
{
 int64 nn, xx, yy, rp, bp, ma, tmp, ans = 0;
 cin >> nn;
 bool flag, botti[nn];
 vector<poi> rr(nn), bb(nn);
 for(int64 ii = 0;ii < nn;ii++)
 {
  cin >> xx >> yy;
  rr[ii].xx = xx;
  rr[ii].yy = yy;
  botti[ii] = true;
 }
 for(int64 ii = 0;ii < nn;ii++)
 {
  cin >> xx >> yy;
  bb[ii].xx = xx;
  bb[ii].yy = yy;
 }
 sort(rr.begin(), rr.end());
 sort(bb.begin(), bb.end());
  
 for(bp = 0;bp < nn;bp++)
 {
  ma = -1;
  for(int64 ii = 0;ii < nn;ii++)
  { 
   if(botti[ii] && ma <= rr[ii].yy && rr[ii].yy < bb[bp].yy && rr[ii].xx < bb[bp].xx)
   {
    tmp = ii;
    ma = rr[ii].yy;
   }
  }
  if(ma != -1)
  {
   ans++;
   botti[tmp] = false;
  }
 }
 cout << ans << endl;
 return 0;
}

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

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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> grid(h, vector<int>(w));
    rep (i, h) {
        string s;
        cin >> s;
        rep (j, w) {
            if (s[j] == '.') {
                grid[i][j] = 1;
            } else {
                grid[i][j] = 0;
            }
        }
    }
    vector<vector<int>> yoko(h, vector<int>(w, 0)), tate(h, vector<int>(w, 0));
    rep (i, h) {
        int ctr = 0;
        int lastidx = 0;
        rep (j, w) {
            if (grid[i][j]) {
                ctr++;
            } else {
                rep (k, lastidx, j) {
                    yoko[i][k] = ctr;
                }
                ctr = 0;
                yoko[i][j] = -1;
                lastidx = j + 1;
            }
            if (j == w - 1 && grid[i][j]) {
                rep (k, lastidx, w) {
                    yoko[i][k] = ctr;
                }
            }
        }
    }
    rep (i, w) {
        int ctr = 0;
        int lastidx = 0;
        rep (j, h) {
            if (grid[j][i]) {
                ctr++;
            } else {
                rep (k, lastidx, j) {
                    tate[k][i] = ctr;
                }
                ctr = 0;
                tate[j][i] = -1;
                lastidx = j + 1;
            }
            if (j == h - 1 && grid[j][i]) {
                rep (k, lastidx, h) {
                    tate[k][i] = ctr;
                }
            }
        }
    }
    int ans = 0;
    rep (i, h) {
        rep (j, w) {
            chmax(ans, yoko[i][j] + tate[i][j]);
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 47360
# あなたは、joisinoお姉ちゃんと以下のようなゲームをしています。
# 最初、何も書いていない紙がある。
# joisinoお姉ちゃんが一つの数字を言うので、
# その数字が紙に書いてあれば紙からその数字を消し、
# 書いていなければその数字を紙に書く。これを N 回繰り返す。
# その後、紙に書かれている数字がいくつあるかを答える。
# joisinoお姉ちゃんが言った数字が、言った順番に A1,...,AN として与えられるので、
# ゲーム終了後に紙に書かれている数字がいくつあるか答えてください。

# 何も書いていない紙を定義
paper = Array.new

# 操作を繰り返す回数を取得
n = gets.chomp.to_i

# お姉ちゃんが言う数字をn回取得
n.times do
  a = gets.to_i
  paper << a
end

paper.sort!

i = 1
count = 1
length = paper.length
num = paper[0]
while i < n
  if num == paper[i]
    count += 1
  else
    if count != 1
      length -= count
      length += 1 if count.odd?
      count = 1
    end
    num = paper[i]
  end
  i += 1
end

if count != 1
  length -= count
  length += 1 if count.odd?
end

# 結果を出力
puts length

Measured memory_bytes: 4016
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur;
  cur =nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur;
  cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t;
  t= nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t;
  t= nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

int main() {
int n,k,x,sum;
  cin >>n>>k;
  for(int i=0;i<n; i++){
    cin>>x;
  if(x<k-x)sum+=2*x;
    else sum+=2*(k-x);
    }
  cout<<sum<<endl;
 }



Measured memory_bytes: 256
/* Problem Description:

*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define REP(i,a,b) for (int i = (a); i < (b); i++)
#define RREP(i,a,b) for (int i = (a); i > (b); i--)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define TRvi(it, c) for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define inf 0x3f3f3f3f
#define EPS 1e-10
#define PI acos(-1.0)
#define scan(x) scanf("%d",x)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define LSOne(x) x&(-x)
#define debug(x) cout << #x << " " << x << endl;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
   //  freopen("in" , "r" , stdin);
   //  freopen("out" , "w" , stdout);
    #endif
    int n, w;
    cin >> n >> w;
    int weight[n+1]; long value[n+1];

    for (int i = 1; i <= n; i++){
      cin >> weight[i] >> value[i];
    }

    vector< vector<long> > dp(w+1, vector<long>(n+1, 0));

    for (int i = 1; i <= w; i++){
      for (int j = 1; j <= n; j++){
        if (i-weight[j] >= 0){
          dp[i][j] = max(dp[i][j-1], value[j] + dp[i-weight[j]][j-1]);
        }
        else
        dp[i][j] = dp[i][j-1];
      }
    }

    cout << dp[w][n] << endl;

    return 0;
 }


Measured memory_bytes: 82304
use std::cmp::min;
//use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>();
    let s1: Vec<char> = s.chars().collect();

    let answer = solve(n, &s1);
    println!("{}", answer);
}

fn solve(n: usize, s: &[char]) -> usize {
    let mut v_max = 0;
    for i in 0..n {
        let sub = &s[i..n];
        let z = z_algo(sub.len(), sub);
        //println!("z: {:?}", z);
        let tmp = get_max(z.len(), &z);
        //println!("tmp: {}", tmp);
        if tmp > v_max {
            v_max = tmp;
        }
        if v_max > (n - i - 1) / 2 {
            break;
        }
    }
    return v_max;
}

fn z_algo(n: usize, s: &[char]) -> Vec<usize> {
    //println!("*** {}, {:?}", n, s);
    let mut z: Vec<usize> = vec![0; n];
    let mut l: usize = 0;
    let mut r: usize = 0;
    for i in 1..n {
        //println!("{}", i);
        if i >= r {
            //println!("   A");
            l = i;
            r = i;
            while r < n && s[r] == s[r - l] {
                r += 1;
            }
            z[i] = r - l;
        //r -= 1;
        } else {
            let k = i - l;
            if z[k] < r - i {
                //println!("   B1");
                z[i] = z[k];
            } else {
                //println!("   B2");
                l = i;
                while r < n && s[r] == s[r - l] {
                    r += 1;
                }
                z[i] = r - l;
            }
        }
    }
    // println!("{:?}", z);
    return z;
}

/**
 * l1 + len <= l2
 *  --> z[i] <= l1
 */
fn get_max(n: usize, z: &[usize]) -> usize {
    let mut v_max: usize = 0;
    for i in 1..n {
        let tmp = min(z[i], i);
        if tmp > v_max {
            v_max = tmp;
        }
    }
    return v_max;
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f,k,l,i;
    while(cin>>a>>b>>c>>d)
    {
        while(c>=1 && a>=1)
        {
            c=c-b;
            a=a-d;
        }
        if(c<=0)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;

    }
    return 0;
}


Measured memory_bytes: 3600
/* ITP1_9_B: Shuffle */
/* 20181124 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#define N 201
#include <stdio.h>
#include <string.h>

int main(void) {
	char str1[N], str2[N];
	int m, h, i, j, len_str1;

	i = 0;
	while(1) {
		scanf("%s", str1);
		if(str1[0] == '-') break;
		len_str1 = strlen(str1);
		scanf("%d", &m);
		for(i = 0; i < m; i++) {
			scanf("%d", &h);
			for(j = h; str1[j]; j++) {
				str2[j - h] = str1[j];
			}
			str2[len_str1 - h] = '\0';
			strncat(str2, str1, h);
			strcpy(str1, str2);
			//str2[len_str1] = '\0';
		}

		printf("%s\n", str1);
	}

	return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>
#include<string.h>
#define MAX 2000200
#define MIN -2000000300
typedef long ll;
 
int pindex;
ll Array[MAX];
 
int getParent(int i){
  return i/2;
}
 
int getLeft(int i){
  return 2*i;
}
 
int getRight(int i){
    return 2*i+1;
}
 
 
int heapIncreaseKey(int i,ll key){
  ll h;
  if(key < Array[i])return -1;
  Array[i] = key;
  while(i > 1 && Array[getParent(i)] < Array[i]){
    h = Array[i];
    Array[i] = Array[getParent(i)];
    Array[getParent(i)] = h;
    i = getParent(i);
  }
}
 
void maxHeapify(int i){
  ll l = getLeft(i);
  ll r = getRight(i);
  ll largest;
  ll h;
  if(l <= pindex && Array[l] > Array[i])largest=l;
  else largest=i;
  if(r<=pindex && Array[r] > Array[largest])largest = r;
  if(largest != i){
    h = Array[i];
    Array[i] = Array[largest];
    Array[largest] = h;
    maxHeapify(largest);
  } 
}
 
 
void Insert(ll key){ //maxHeapInsert
  ++pindex;
  Array[pindex] = MIN;
  heapIncreaseKey(pindex,key);
}
 
ll heapExtractMax(){
  ll max;
  if(pindex < 1)return -1;
  max = Array[1];
  Array[1] = Array[pindex];
  pindex--;
  maxHeapify(1);
  return max;
}
 
 
 
 
int main(){
  char op[1000];
  ll val;
 
  while(1){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%ld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }
 
  return 0;
}

Measured memory_bytes: 8784
//ABC171

#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <random>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <string>

using namespace std;

int main(){
    long int n, tmp;
    cin >> n;
    vector<int> v;
    while(true){
        if(n <= 26){
            v.push_back(n);
            break;
        }else{
            if(n % 26 == 0){
                v.push_back(26);
                n = n/26 - 1;
            }else{
                v.push_back(n%26);
                n /= 26;
            }
        }
    }
    reverse(v.begin(), v.end());
    for(auto itr = v.begin(); itr != v.end(); itr++){
        char c = 'a' + *itr - 1;
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3572
S = input()
S = S[:-1]

def stringcounter(M):
    if len(M)%2 ==0 and M[:len(M)//2]==M[len(M)//2:]:
        return True
    else:
        return False
while True:
    if stringcounter(S)==True:
        print(len(S))
        break
    else:
        S = S[:-1]

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;
#define MAX (int)1e9+7

int main(){
	int n;
	scanf("%d",&n);
	vector<pii > dx,dy;
	vector<pii > p;
	vector<pii > edge[100010];
	rep(i,n){
		int x,y;
		scanf("%d%d",&x,&y);
		dx.push_back(make_pair(x,i));
		dy.push_back(make_pair(y,i));
		p.push_back(make_pair(x,y));
	}
	sort(dx.begin(),dx.end());
	sort(dy.begin(),dy.end());
	rep(i,n-1){
		int tx=dx[i+1].first-dx[i].first;
		int ty=dy[i+1].first-dy[i].first;
		edge[dx[i].second].push_back(make_pair(tx,dx[i+1].second));
		edge[dx[i+1].second].push_back(make_pair(tx,dx[i].second));
		edge[dy[i].second].push_back(make_pair(ty,dy[i+1].second));
		edge[dy[i+1].second].push_back(make_pair(ty,dy[i].second));
	}
	bool visit[100010];
	int d[100010];
	rep(i,n){
		visit[i]=false;
		d[i]=MAX;
	}
	d[0]=0;
	priority_queue<pii ,vector<pii >,greater<pii> > q;
	q.push(make_pair(0,0));
	while(!q.empty()){
		int u=q.top().second;
		q.pop();
		if(visit[u])continue;
		visit[u]=true;
		rep(i,edge[u].size()){
			int v=edge[u][i].second;
			int dd=edge[u][i].first;
			if(!visit[v]&&dd<d[v]){
				d[v]=dd;
				q.push(make_pair(d[v],v));
			}
		}
	}
	ll sum=0;
	rep(i,n)sum+=d[i];
	printf("%lld\n",sum);
	return 0;
}



Measured memory_bytes: 12256
#include<iostream>

using std::begin;
using std::end;

int gcd(int n, int m) {
  if(n < m) return gcd(m, n);
  if(m == 0) return n;

  return gcd(m, n % m);
}

int main() {
  int x, y;
  std::cin >> x >> y;
  std::cout << gcd(x, y) << std::endl;

  return 0;
}



Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	enum State{
		START, MOUTH, EYE_A, EYE_B, BODY_A1, BODY_A2, BODY_B1, BODY_B2, MID_A, TAIL_A, TAIL_B1, TAIL_B2, NA;
	}
	
	String snake(String s){
		State state=State.START;
		int length=0;
		
		LOOP:
		for(int i=0;i<s.length();++i){
			char next=s.charAt(i);
			
			switch(state){
			case START:
				if(next=='>') state=State.MOUTH;
				else state=State.NA;
				break;
			case MOUTH:
				if(next=='\'') state=State.EYE_A;
				else if(next=='^') state=State.EYE_B;
				else state=State.NA;
				break;
			case EYE_A:
				if(next=='='){
					state=State.BODY_A1;
					length=0;
				}
				else state=State.NA;
				break;
			case BODY_A1:
				++length;
				if(next=='=') state=State.BODY_A1;
				else if(next=='#') state=State.MID_A;
				else state=State.NA;
				break;
			case MID_A:
				if(next=='=') state=State.BODY_A2;
				else state=State.NA;
				break;
			case BODY_A2:
				--length;
				if(next=='=') state=State.BODY_A2;
				else if(next=='~'&&length==0) state=State.TAIL_A;
				else state=State.NA;
				break;
			case EYE_B:
				if(next=='Q') state=State.BODY_B1;
				else state=State.NA;
				break;
			case BODY_B1:
				if(next=='=') state=State.BODY_B2;
				else state=State.NA;
				break;
			case BODY_B2:
				if(next=='Q') state=State.BODY_B1;
				else if(next=='~') state=State.TAIL_B1;
				else state=State.NA;
				break;
			case TAIL_B1:
				if(next=='~') state=State.TAIL_B2;
				else state=State.NA;
				break;
			default:
				break LOOP;
			}
		}
		
		switch(state){
		case TAIL_A:
			return "A";
		case TAIL_B2:
			return "B";
		default:
			return "NA";
		}

	}
	
	BufferedReader input;
	
	int ni() throws NumberFormatException, IOException{
		return Integer.parseInt(input.readLine());
	}
	
	String ns() throws IOException{
		return input.readLine();
	}
	
	void io(){
		input=new BufferedReader(new InputStreamReader(System.in));
		
		try {
			int n=ni();
			for(int i=0;i<n;++i){
				System.out.println(snake(ns()));
			}
			input.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

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

int main() {
  
  int a, b, c, k, sum = 0;
  
  cin >> a >> b >> c >> k;
  
  for(int i = 0; i < k; i++){
    if(a != 0) {
      sum++;
      a--;
    }
    else if(a==0 && b!=0) {
      b--;
    }
    else if(a==0 && b==0) {
      sum--;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll x[3];
int main() {
	string s; cin >> s;
	if (s.size() == 1 || (s.size() == 2 && s[0] != s[1])) {
		cout << "YES" << endl;
		return 0;
	}

	rep(i, 0, s.size()) {
		if (s[i] == 'a')x[0]++;
		else if (s[i] == 'b')x[1]++;
		else if (s[i] == 'c')x[2]++;
	}

	sort(x, x + 3);

	if (x[0] == 0) {
		cout << "NO" << endl;
	}
	else {
		x[1] -= x[0];
		x[2] -= x[0];
		if (x[1] == 0 && x[2] == 0 ||
			x[1] == 0 && x[2] == 1 ||
			x[1] == 1 && x[2] == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 512