akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#define fora(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T> void UNIQUE(vector<T> &a){ SORT(a);a.erase(unique(ALL(a)),a.end());}
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,K;
    cin>>N>>K;
    v<ll> A(N,1);
    rep(i,K){
        ll ko; cin>>ko;
        rep(j,ko){
            ll x; cin>>x; --x;
            A[x]=0;
        }
    }
    cout<< sumer(A) <<"\n";
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    // ifstream in("input.txt"); cin.rdbuf(in.rdbuf());
    // ofstream out("output.txt"); cout.rdbuf(out.rdbuf());
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; rep(QQ,Qkai) Main();
    Main();
}
//-----------------------------------------

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

#define ll long long

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

    ll s,step,dis;
    cin>>s>>step>>dis;
    ll a=abs(s)/dis;
    ll ans=0;
    if(a+1<=step)
    {
        ll A,B;
        if(s<0) A=s+a*dis,B=A+dis;
        else A=s-a*dis,B=A-dis;
        if((step-a)&1) ans=abs(B);
        else ans=abs(A);
    }
    else
    {
        if(s<0) ans=abs(s+step*dis);
        else ans=abs(s-step*dis);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 998244353; //1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e4+2;
int dd[2]={1,-1};
int val[21][21];
int d[404][404];
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int h,w;
      cin>>h>>w;
      string s[h];
      for(int i=0;i<h;i++) cin>>s[i];
      int cnt=0;
      for(int i=0;i<20;i++)
      {
      	for(int j=0;j<20;j++)
      	{
      		val[i][j]=cnt++;
      	}	
      }
      // cout<<s[0][1];
      for(int i=0;i<402;i++) for(int j=0;j<402;j++) d[i][j]=1e17;
      for(int i=0;i<402;i++) d[i][i]=0;
      for(int i=0;i<h;i++)
      {
      	for(int j=0;j<w;j++)
      	{
      		if(s[i][j]=='#') continue;
      		if(i+1<h&&s[i+1][j]=='.')
      		{
      			// cout<<i+1<<" "<<j<<"\n";
      			d[val[i][j]][val[i+1][j]]=1;
      		}
      		if(j+1<w&&s[i][j+1]=='.')
      		{
      			// cout<<"*";
      			// cout<<i<<" "<<j+1<<"\n";

      			d[val[i][j]][val[i][j+1]]=1;
      		}
      		if(i-1>=0&&s[i-1][j]=='.')
      		{
      			// cout<<"*";
      			// cout<<i<<" "<<j<<"\n";

      			d[val[i][j]][val[i-1][j]]=1;
      		}
      		if(j-1>=0&&s[i][j-1]=='.')
      		{
      			// cout<<"*";
      			// cout<<i<<" "<<j<<"\n";

      			d[val[i][j]][val[i][j-1]]=1;
      		}
      	}
      }
      for(int k=0;k<402;k++)
      {
      	for(int i=0;i<402;i++)
      	{
      		for(int j=0;j<402;j++)
      		{
      			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      		}
      	}
      }	
      int ans=0;
      for(int i=0;i<402;i++) for(int j=0;j<402;j++) {
      	// if(i==j) continue;
      	if(d[i][j]==1e17) continue;
      	// cout<<d[i][j]<<" ";
      	ans=max(ans,d[i][j]);
      }      
      // if(ans==-1)
      cout<<ans;
} 
// I never lose. I either win or I learn

Measured memory_bytes: 1536
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,M,P;
	scanf("%d %d %d",&N,&M,&P);

	int tmp;
	bool start_FLG = false;
	priority_queue<int> Q;

	for(int loop = 0; loop < M; loop++){
		scanf("%d",&tmp);

		if(tmp < P){
			tmp = N + (tmp-P);
		}else if(tmp == P){
			start_FLG = true;
			tmp = 0;
		}else{
			tmp -= P;
		}
		Q.push(tmp);
	}

	int index,max_index;
	int* table;

	if(start_FLG == false){
		Q.push(0);
		table = new int[M+1];
		max_index = M+1;
		index = M;
	}else{
		table = new int[M];
		max_index = M;
		index = M-1;
	}

	while(!Q.empty()){
		table[index--] = Q.top();
		Q.pop();
	}

	int minimum = 0;

	minimum = min(table[max_index-1],N-table[1]);

	for(int base = 1; base <= max_index-2;base++){
		if(table[base]> N-table[base+1]){
			tmp = 2*(N-table[base+1])+table[base];
		}else{
			tmp = 2*table[base] + (N-table[base+1]);
		}
		minimum = min(minimum,tmp);
	}

	printf("%d\n",minimum*100);

    return 0;
}

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


int main() {
    string s;
    cin >> s;
    ll n = s.length();
    rep1(i, n/2){
        if (s[i] != s[n/2+1+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner; // scannerの方が速い(?)

class Main {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        Scanner scan = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = scan.nextInt(); // Integer.parseInt(br.readLine());

        // String[] input = br.readLine().split(" ");

        int[] from = new int[n];
        int[] to = new int[n];

        int max = 0;

        for (int i = 0; i < n; i++) {
            from[i] = scan.nextInt(); // Integer.parseInt(input[i]);
            max = Math.max(max, from[i]);
        }

        CountingSort(from, to, max);

        StringBuilder sb = new StringBuilder();
        sb.append(to[0]);

        for (int i = 1; i < n; i++)
                sb.append(" " + to[i]);

        System.out.println(sb);
    }

    static void CountingSort(int[] A, int[] B, int k) {
        int[] C = new int[k + 1];
        int length = A.length;

        /*
        for (int i = 0; i < k + 1; i++) 
            C[i] = 0;
        */
        int i; // to avoid TLE

        for (i = 0; i < length; i++) 
            C[A[i]]++;

        for (i = 1; i < k + 1; i++) 
            C[i] += C[i - 1];
        
        for (i = length - 1; i >= 0; i--)
            B[--C[A[i]]] = A[i];
        
    }

}


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

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

 int a,b,k;
 cin >> k >> a >> b;
 bool ok = false;
 for(int i=a; i<=b; i++){
 	if(i%k == 0){
 		ok = true;
 		break;
 	}
 }
 cout << (ok ? "OK\n" : "NG\n");

}


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

const int N=100005;
const long long INF=0x3f3f3f3f3f3f3f3f;
int n,k;
long long a[3005],dp[3005][3005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) dp[i][i]=a[i];
	for(int len=2;len<=n;len++)
	{
		for(int i=1;i<=n-len+1;i++)
		{
			int j=i+len-1;
			dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	}
	printf("%lld\n",dp[1][n]);
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5+10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

ll dp[N];
vector<int> v;

ll findans(int n)
{
	if(n <= 0) return LONG_MAX-1;
	if(dp[n] != 0) return dp[n];
	dp[n] = LONG_MAX;
	for(auto x: v)
	{
		dp[n] = min(findans(n-x) + 1, dp[n]);
	}
	//cout<<n<<" "<<dp[n]<<endl;
	return dp[n];
}

int main()
{
	int n;
	cin>>n;
	ll x = 6;
	v.pb(1);
	while(n >= x)
	{
		v.pb(x);
		x = x*6;
	}
	x = 9;
	while(n >= x)
	{
		v.pb(x);
		x = x*9;
	}
	memset(dp, 0, sizeof(dp));
	for(auto i: v){
		dp[i] = 1;
	}
	cout<<findans(n)<<endl;
}


Measured memory_bytes: 5760
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> ls(N);
  F0R(i, N) {
    cin >> ls[i];
  }
  sort(rng(ls));

  int result = 0;
  F0R(i, N) {

    FOR(j, i + 1, N) {
      int cmax = ls[i] + ls[j];
      int cmin = ls[j] - ls[i];

      int l = upper_bound(ls.begin() + j + 1, ls.end(), cmin) - ls.begin();
      int r = lower_bound(ls.begin() + j + 1, ls.end(), cmax) - ls.begin();
      if (r > l) result += r - l;

    }
  }
  cout << result;
}
#endif


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),K=in();
	int V = (N-1)*(N-2)/2;
	if(K>V){
		cout << -1 << endl;
		return 0;
	}
	vector<pair<int,int>> p;
	auto comp = [](const pair<int,int>& lhs,const pair<int,int>& rhs){return lhs.first==rhs.first ? lhs.second<rhs.second : lhs.first<rhs.first;};
	set<pair<int,int>,decltype(comp)> memo(comp);
	REP(i,N-1){
		p.emplace_back(1,i+2);
		memo.emplace(1,i+2);
	}
	int c = V-K;
	for(int i=2;c>0 && i<=N;i++){
		for(int n=i+1;c>0 && n<=N;n++){
			auto res = memo.emplace(min(i,n),max(i,n));
			if(res.second){
				p.emplace_back(i,n);
				c--;
			}
		}
	}

	cout << p.size() << endl;
	for(auto& x:p){
		cout << x.first << ' ' << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define el "\n" ;
vector<ll> dp(100000  + 2 , -1 ) ;
vector<long> v(100000 + 1) ;
ll f(ll n ){
    if(n <= 1){
        return 0 ;
    }
    if(dp[n] >= 0 ){
        return dp[n] ;
    }
    else
    {
        dp[n] = min(f(n-1) + abs(v[n] - v[n-1]) ,f(n-2) + abs(v[n] - v[n-2]) ) ;

    }
    return dp[n] ;
    
}
int main(){
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    ll  n ; 
    cin >> n  ; 
    
    for( ll i = 1 ; i <= n ; i++){
        cin >> v[i] ;
    }
    v[0] = v[1] ;
    cout << f( n ) << el ;
    return 0 ;
}


/*#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map> 
#include<bits/stdc++.h> 
typedef long long ll ; 
#define el '\n' 
#define fr(n) for(ll i =0 ; i<n ; i++) 
using namespace std ;
ll a[100005] ; ll dp[100005] ;
ll k  ; 
ll solve(ll n){
    if (n < 1 ) return 0 ; 
    if (dp[n] != -1 )
    {
        return dp[n] ; 
    }

    ll left , right ;
    left = solve(n-1) + abs(a[n] - a[n-1])  ;
    right = INT64_MAX ;
    if(n - 2 >= 0 ){
        right = solve(n-2) + abs(a[n]  - a[n-2]) ; 
    }
    return dp[n] =  min(right , left ) ; 
    
}
int main() 
{ 
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    cin >> k ;
    dp[0] = - 1  ;
    fr(k){
        cin >> a[i+1] ;
        dp[i + 1 ] = - 1 ; 
    }
    a[0] = a[1] ;
    cout << solve(k) << el ;
    return 0; 
} */

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int solve() {
    int cnt = 0;
    string s, t; cin >> s >> t;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) cnt++;
    }

    return cnt;
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
const int N=1e5+9;
using namespace std;
int a[N],num,n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    int pos;
	for(int i=1;i<n;)
    {
	   if(a[i]!=i) i++;
	   else 
	   {
	   	  swap(a[i],a[i+1]);
	   	  i++;num++;
	   }
    }
    if(a[n]==n) num++;
    printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split())) + [10000]
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if a[i+1] - a[i] == 1:
    ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAX 1000
using namespace std;
map<int,int> l,c;
map<pair<int,int>,bool> visited;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,k;
	cin>>n>>m>>k;
	int mx = 0,my = 0;
	while(k--)
	{
		int x,y;
		cin>>x>>y;
		mx = max(mx,++l[x]);
		my = max(my,++c[y]);
		visited[{x,y}] = true;
	}
	vector<int> tx,ty;
	for(pair<int,int> p:l)
		if(p.second==mx)
			tx.push_back(p.first);
	for(pair<int,int> p:c)
		if(p.second==my)
			ty.push_back(p.first);
	for(int x:tx)
	{
		for(int y:ty)
		{
			if(!visited[{x,y}])
			{
				cout<<mx+my<<endl;
				return 0;
			}	
		}
	}				
	cout<<mx+my-1<<endl;
	return 0;
}

Measured memory_bytes: 54288
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll n, k;
    cin >> n >> k;
    vector<ll> ar(100000, 0);

    ll a, b;
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &a, &b);
        ar[a] += b;
    }

    ll cnt = 0, ans;
    for (ans = 0; ans < 100000; ans++) {
        cnt += ar[ans];
        if (cnt >= k) break;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

vector<int> bfs(const vector<vector<int>> &G, int s, int t = -1) {
    vector<int> ret(G.size(),-1);
    ret[s] = 0;
    if (t != -1) ret[t] = 0;
    queue<int> que;
    que.emplace(s);
    if (t != -1) {
        ret[t] = 0;
        que.emplace(t);
    }
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (ret[nv] != -1) continue;
            ret[nv] = ret[v] + 1;
            que.emplace(nv);
        }
    }

    return ret;
}

const int MAX = 100;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    auto f=[&](int v) {
        auto dist = bfs(G,v);
        int color = *max_element(all(dist));
        color++;
        vector<int> L(MAX);
        rep(i,N) {
            if (i==v) chmax(L[dist[i]],(int)G[i].size());
            else chmax(L[dist[i]],(int)G[i].size()-1);
        }
        ll ret = 1;
        rep(i,MAX) {
            if (L[i]) ret *= L[i];
        }
        return pll(color,ret);
    };
    auto g=[&](int u, int v) {
        auto dist = bfs(G,u,v);
        int color = *max_element(all(dist));
        color++;
        vector<int> L(MAX);
        rep(i,N) {
            chmax(L[dist[i]],(int)G[i].size()-1);
        }
        ll ret = 2;
        rep(i,MAX) {
            if (L[i]) ret *= L[i];
        }
        return pll(color,ret);
    };

    ll color = 1e18, ans = 1e18;
    rep(i,N) {
        ll c,a;
        tie(c,a) = f(i);
        if (color > c) {
            color = c;
            ans = a;
        } else if (color == c) {
            chmin(ans,a);
        }
    }
    rep(v,N) {
        for (auto nv : G[v]) {
            ll c,a;
            tie(c,a) = g(v,nv);
            if (color > c) {
                color = c;
                ans = a;
            } else if (color == c) {
                chmin(ans,a);
            }    
        }
    }

    cout << color << " " << ans << ln;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;
ll s(ll a) {ll res=0; while(a>0) res+=a%10, a/=10; return res;}
bool val_ok(ll a,ll b) {return a*s(b)<=b*s(a);}
bool check(ll a) {
  ll ke=0, a2=a;
  while(a2>0) ke++, a2/=10LL; a2=a;
  bool able=true;
  for(ll i=0,j=1;i<ke;i++,j*=10LL) {
    while(a2%(j*10LL)/j != 9LL) {
      a2+=j;
      if (val_ok(a,a2)) continue;
      else {able=false; break;}
    }
    if (!able) break;
  }
  if (able) return true;
  else return false;
}
int main() {
  ll k; cin>>k;
  ll j=1,j2=10000;
  for(ll i=1, all=0; all<k;i+=j) {
    if ((i+1)%j2 == 0) j*=10,j2*=10;
    if (check(i)) {cout<<i<<endl; all++;}
    //cout<<i<<endl; all++;
    if (i>1e15) break;
  }
}

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

struct comp {
	bool operator()(const pair<int, int> l, const pair<int, int>& r) {
		return (l.first == r.first ? l.second < r.second : l.first > r.first);
	}
};

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

	for(int n, m; cin >> n >> m, n | m;) {
		vector<int> cnt(m, 0);
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				int in;
				cin >> in;
				cnt[j] += in;
			}
		}

		vector<pair<int, int> > v;
		for(int i = 0; i < m; ++i)
			v.push_back(make_pair(cnt[i], i + 1));

		sort(v.begin(), v.end(), comp());
		for(int i = 0; i < m; ++i)
			cout << v[i].second << (i + 1 == m ? "\n" : " ");
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  int N;
  cin>>N;
  string inp;
  int AC=0,WA=0,TLE=0,RE=0;
  for(int i=0;i<N;i++)
  {
    cin>>inp;
    if(inp.compare("AC")==0)
       {
      	AC++;
       }  
    if(inp.compare("WA")==0)
       {
       WA++;
       } 
    if(inp.compare("TLE")==0){
      TLE++;}
    if(inp.compare("RE")==0){
      RE++;}
  }
  
  cout<<"AC x "<<AC<<endl;
  cout<<"WA x "<<WA<<endl;
  cout<<"TLE x "<<TLE<<endl;
  cout<<"RE x "<<RE<<endl;
    
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

const string goal = "1112131415161700212223242526270031323334353637004142434445464700";
const int INF = 100000000;

map<string, int> data;

int solve(string str){
  int res = INF;
  if(str == goal) return 0;
  if(data.find(str) != data.end()) return data[str];
  for(int i=2;i<str.size();i+=2){
    if(str[i] == '0' && str[i+1] == '0'){
      if(str[i-1] == '0' || str[i-1] == '7') continue;
      for(int j=2;j<str.size();j+=2){
        if(str[j] == str[i-2] && (char)(str[j+1]-1) == str[i-1]){
          char a = str[j], b = str[j+1];
          str[j] = str[j+1] = '0';
          str[i] = a;
          str[i+1] = b;
          res = min(res, solve(str)+1);
          str[i] = str[i+1] = '0';
          str[j] = a;
          str[j+1] = b;
        }
      }
    }
  }
  data[str] = res;
  return res;
}

main(){
  int T;
  cin >> T;
  while(T--){
    data.clear();
    string input;
    for(int i=0;i<4;i++){
      string tmp = "11";
      tmp[0] += i;
      input += tmp;
      for(int j=0;j<7;j++){
        string in;
        cin >> in;
        if(in[1] == '1') input += "00";
        else input += in;
      }
    }
    int ans = solve(input);
    if(ans == INF) ans = -1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 8624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    int a = scan.nextInt();
	    
	    
	        System.out.println(48-a);


	}
}


Measured memory_bytes: 23764
input()
A=[0]+input().split()
H=len(A)
for i in range(1,H):
 print(f'node {i}: key = {A[i]}, {f"parent key = {A[i//2]}, "if i>1 else""}{f"left key = {A[2*i]}, "if 2*i<H else""}{f"right key = {A[2*i+1]}, "if 2*i+1<H else""}')


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


int main()
{
      long long int n ,k,m;
      cin>>n>>m>>k;
   
      vector<long long int> s1(n+1),s2(m+1);
      s1[0]=0;
      s2[0]=0;
      
      for( int i=1;i<=n;i++)
      {
         
          cin>>s1[i];
          s1[i]=s1[i]+s1[i-1];
    
      }
          
        for( int j=1;j<=m;j++)
      {
         
          cin>>s2[j];
        s2[j]=s2[j]+s2[j-1];
        
      }
      int max_book=0;
      for(int i=0;i<=n;i++)
      {
          if(k-s1[i]<0)
          continue;
           int l=lower_bound(s2.begin(),s2.end(),k-s1[i])-s2.begin();
          if(l>m||s2[l]>k-s1[i])
          l--;
          max_book=max(max_book,i+l);
          
          
      }
      cout<<max_book<<endl;
      
       return 0;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
#define LL long long
#define pr pair<LL, LL>
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    map <LL, int> mp;
    map <LL, int> :: iterator it;
    LL N, num;
    cin >> N;
    while(N--){
        cin >> num;
        mp[num]++;
    }
    LL cnt = 0;
    for(it = mp.begin(); it != mp.end(); it++){
        cnt += (it->second % 2);
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 6528
import java.io.*;
import java.util.*;

public class Main{

    public static final int M=1046527;
    public static final int L=14;
    
    static String H[]=new String[M];
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	Arrays.fill(H,"");
	
	int n=Integer.parseInt(br.readLine());

	for(int i=0;i<n;i++){
	    String str[]=br.readLine().split(" ");

	    if(str[0].equals("insert")){
		insert(str[1]);
	    }else{
		if(find(str[1]))
		    System.out.println("yes");
		else
		    System.out.println("no");
	    }
	}
    }

    static int getChar(char ch){
	if ( ch == 'A') return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else  if(ch=='T')return 4;
	else return -1;
    }

    static int getKey(String s){
	int sum = 0, p = 1;
	char str[]=s.toCharArray();
	
	for (int i = 0; i < str.length; i++ ){
	    sum += p*(getChar(str[i]));
	    p *= 5;
	}
	return sum;
    }

    static int h1(int key){
	return (key%M);
    }
    static int h2(int key){
	return 1+key%(M-1);
    }
    
    static boolean find(String s){
        int a=getKey(s);

	for(int i=0;;i++){
	    int j=(h1(a)+i*h2(a))%M;
	    if(H[j].equals(s)){
		return true;
	    }else if(H[j].length()==0){
		return false;
	    }
	}
	
    }
    
    static boolean insert(String s){
	int a=getKey(s);
        for (int i=0;;i++){
	    int j = (h1(a)+i*h2(a))%M;
	    if (H[j].equals(s)){
	        return true;
	    }else if(H[j].length()==0){
		H[j]=s;
		return false;
	    }
	}
    }
}



Measured memory_bytes: 184744
import java.util.Scanner;

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

		if (D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		} else if (D == 23) {
			System.out.println("Christmas Eve Eve");
		} else if (D == 24) {
			System.out.println("Christmas Eve");
		} else {
			System.out.println("Christmas");
		}
	}

}


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

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  bool all_even = true;
  rep(i, n) if (a[i] % 2 != 0) all_even = false;

  cout << (all_even ? "second" : "first") << endl;
  return 0;
}


Measured memory_bytes: 3788
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

N = SORO_INT()
A = list([int(input()) for i in range(N)])
t = sorted(A)[-2]

B = max(A)
B_in = A.index(B)


for i in range(N):
    A[i] = B
A[B_in] = t
for i in range(N):
    print(A[i])


Measured memory_bytes: 13200
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, h, w);
  Cins(string, h, a);

  int x = 0, y = 0;
  vector<vector<bool>> checked(h, vector<bool>(w, false));
  while (true) {
    if (a[y][x] != '#') {
      puts("Impossible");
      return;
    }
    checked[y][x] = true;
    if (x == w - 1 && y == h - 1) break;
    if (x < w - 1 && y < h - 1) {
      if (a[y + 1][x] == '#' && a[y][x + 1] == '#') {
        puts("Impossible");
        return;
      }
    }
    if (x < w - 1)
      if (a[y][x + 1] == '#') {
        x++;
        continue;
      }
    if (y < h - 1)
      if (a[y + 1][x] == '#') {
        y++;
        continue;
      }
    puts("Impossible");
    return;
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#' && !checked[i][j]) {
        puts("Impossible");
        return;
      }
    }
  }
  puts("Possible");
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int main(){
  int a , b;
  cin >> a >> b;
  if ( (a * b) % 2 == 0 ){
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}
  


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

int main()
{
    int n, m;
    cin >> n >> m;
    if(n<10){
        cout << m +(100*(10 - n))<< endl;
        return 0;
    }
    cout << m << endl;
    return 0;
}

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

int n;
int f[100][10]={};
long long p[100][11]={};
long long INF=9999999999999;

long long dfs(int time,long long con){
    long long ans=0;
    long long t=con;
    if(time==9 && con==0) return -INF;
    if(time==9){
        for(int i=0;i<n;i++){
            int cnt=0;
            con=t;
            for(int j=0;j<10;j++){
                if(con%10==1 && f[i][9-j]==1){
                    cnt++;
                }
                con/=10;
            }
            ans+=p[i][cnt];
        }
        return ans;
    }

    ans=(long long)max(dfs(time+1,10*con),dfs(time+1,10*con+1));

    return ans;

}

int main(){
    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }

    long long ans=0;

    ans=(long long)max(dfs(0,0),dfs(0,1));

    cout<<ans;

}


Measured memory_bytes: 256
S = input()
N = int(len(S)/2)

if len(S)%2 != 0:
  N = N + 1
  
count = 0
#print(N)
for i in range(N):
  if S[i] != S[len(S) - 1 - i]:
    #print(S[i])
    #print(S[len(S) - 1 - i])
    count += 1

print(count)

Measured memory_bytes: 2940
N, A, B = map(int, input().split())
S = input()

capacity = A+B
rank = 1
for i in range(N):
    if 'a' == S[i] and 0 < capacity:
        print('Yes')
        capacity -= 1
    elif 'b' == S[i] and 0 < capacity and rank <= B:
        print('Yes')
        capacity -= 1
        rank += 1
    else:
        print('No')


Measured memory_bytes: 9176
#include <iostream>

using namespace std;

int main() {
    int bit[26];
    for(int i = 0;i < 26;i++) bit[i] = 0;
    string str;
    cin >> str;
    long long ans = 1;
    for(int i = 0;i < str.length();i++){
        int c = str[i] - 'a';
        for(int j = 0;j < 26;j++){
            if(c != j) ans += bit[j];
        }
        bit[c]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){

    int a,b,c,n;
    cin >> n;
    vector<int> f(10001);
    rep(i,100){
        rep(j,100){
            rep(k,100){
                a=i+1; b=j+1; c=k+1;
                int tmp=a*a+b*b+c*c+a*b+a*c+b*c;
                if(tmp<=10000){
                    f[tmp]++;
                }
            }
        }
    }
    rep(i,n){
        cout << f[i+1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3532
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string  s; int k,sum=0,ans;
    cin >> s >> k ; 
    for (int i=0;i<sz(s);i++){
        if (s[i]=='1') {
            if (sum==k-1) {
                ans = 1;
                break;
            }
            else sum++;
        }
        else {
            ans=s[i]-'0'; 
            break;
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
int main() {
    std::vector <int> A;
    int N,k=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> k;
        A.push_back(k);
    }
    for(int j=0;j<N;j++) cout << A[j] << ((j<N-1) ? ' ' : '\n');
    for(int i=1;i<N;i++){
        k = A[i];
        int j=i-1;
        for(;j >= 0&& A[j]>k;){
            A.erase(A.begin()+j+1);
            A.insert(A.begin() + j+1, A[j]);
            j--;
        }
        A.erase(A.begin() + j+1);
        A.insert(A.begin() + j+1, k);
        for(int j = 0; j<N;j++){
            cout << A[j] << ((j==N-1)?'\n' : ' ');
        }
    }
   return 0;
}



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

bool exist[5001][5001];

inline bool check(int x, int y){
  if(x<0 || y<0 || x>5000 || y>5000)return false;
  return exist[x][y];
}

int main(){
  int n;
  while(cin >> n, n){
    memset(exist,0,sizeof(exist));
    vector<int> x(n), y(n);

    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i];
      exist[x[i]][y[i]] = 1;
    }

    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	int dx = x[i]-x[j], dy = y[i]-y[j];

	if( check(x[i]+dy,  y[i]-dx) && check(x[j]+dy,  y[j]-dx) ){
	  ans = max(ans, dx*dx + dy*dy);
	}
	if( check(x[i]-dy,  y[i]+dx) && check(x[j]-dy,  y[j]+dx) ){
	  ans = max(ans, dx*dx + dy*dy);
	}
      }
    }
    cout << ans << endl;
  }
}

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

int main()
{
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end());

  cout << a[2]-a[1] + a[1]-a[0] << endl;

  return 0;

}


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

int main(){
    int a,b;
    
    cin >> a >> b;
    
    if(a<b){
     
        cout << "a < b" << endl;
    
        
    }else if(a>b){
        
        cout << "a > b" << endl;
    
        
    }else if(a==b){
        
        cout << "a == b" << endl;
        
}

return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;


int main()
{
    int k;
    cin >> k;
    if(k < 10){
        cout << k << '\n';
        return 0;
    }
    queue<int64_t> lln;
    for(int64_t i = 1; i < 10; ++i){
        lln.push(i);
    }
    while(k > 1){
        const auto lk = lln.front();
        //cout << lk << ',';
        lln.pop();
        const int lsd = lk % 10;
        const auto llshift = lk * 10;
        if(lsd > 0) lln.push(llshift + lsd - 1);
        lln.push(llshift + lsd);
        if(lsd < 9) lln.push(llshift + lsd + 1);
        --k;
    }
    cout << lln.front() << '\n';
    return 0;
}


Measured memory_bytes: 1792
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
char s[100111];
int cnt[26];
int main()
{
  	int n;
  	scanf("%d", &n);
	scanf("%s", s);
	for (int i=0; i<n; i++) cnt[s[i]-'a']++;
	ll ans = 1;
	for (int i=0; i<26; i++)
	{
		ans = ans*(cnt[i]+1)%mod;
	}
	cout<<(ans-1+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S; cin >> S;

    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int w[1000000+10],h[1000000+10];
set<int> adj[1000000+10];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int H,W,M;
    cin >> H >> W >> M;
    int maxH=-1,maxW=-1;
    for (int i = 0; i < M; i++) {
        int a,b; cin >> a >> b;
        adj[a].insert(b);
        w[b]++;
        h[a]++;
    }
    for (int i = 0; i <= W; i++) {
        maxW = max(maxW, w[i]);
    }
    for (int i = 0; i <= H; i++) {
        maxH = max(maxH, h[i]);
    }
    vector<int> hs,ws;
    for (int i = 0; i <= W; i++) {
        if (w[i]==maxW) ws.push_back(i);
    }
    for (int i = 0; i <= H; i++) {
        if (h[i]==maxH) hs.push_back(i);
    }
    if (hs.size()*ws.size()>M) {
        cout << maxH+maxW << endl;
    }
    else {
        for (int i = 0; i < (int)hs.size(); i++) {
            for (int j = 0; j < (int)ws.size(); j++) {
                int x=hs[i],y=ws[j];
                if (adj[x].find(y) == adj[x].end()) {
                    cout << maxH+maxW << endl;
                    goto done;
                }
            }
        }
        cout << maxH+maxW-1 << endl;
    }

    done: return 0;
}

Measured memory_bytes: 70668
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long;
using lli = long long int;


void ABC076C()
{
	string S1, T;
	cin >> S1 >> T;

	int nS = S1.size();
	int nT = T.size();
	priority_queue<string, vector<string>, greater<string>> candidates;
	for (int i = 0; i <= nS - nT; ++i)
	{
		string cand(S1);
		for(int k = 0; k < i; ++k)
			cand[k] = S1[k] == '?' ? 'a' : S1[k];

		int j = 0;
		for (; j < nT; ++j)
		{
			char a = S1[i + j];
			char b = T[j];
			if (a != '?' && a != b)
				break;
			cand[i + j] = T[j];
		}
		if (j == nT)
		{
			for(int k = i+ nT; k < nS; ++k)
				cand[k] = S1[k] == '?' ? 'a' : S1[k];
			candidates.push(cand);
		}
	}
	string ret = candidates.empty() ? "UNRESTORABLE" : candidates.top();
	cout << ret << endl;
}

int main()
{
	ABC076C();
	return 0;
}


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

int main () {
    int N;
    cin >> N;
    vector<string> S(N), T(N);
    for (int i = 0; i < N; i++)
        cin >> S[i] >> T[i];

    for (int i = 0; i < N; i++) {
        int dp[1001][1001] = {};
        string s = S[i], t = T[i];
        int n = s.size(), m = t.size();
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < m; k++) {
                if (s[j] == t[k]) {
                    dp[j + 1][k + 1] = dp[j][k] + 1;
                } else {
                    dp[j + 1][k + 1] = max(dp[j + 1][k], dp[j][k + 1]);
                }
            }
        }
        cout << dp[n][m] << endl;
    }
    return 0;
}



Measured memory_bytes: 7120
import heapq

N, K = map(int, input().split())

V = list(map(int, input().split()))

ans = 0
for i in range(1, K+1):
    if i > N:
        continue
    for j in range(i+1):
        tmp = 0
        q = V[:j] + V[N-i+j:]
        heapq.heapify(q)
        for _ in range(min(i, K-i)):
            tmp_min = heapq.heappop(q)
            ans = max(ans, sum(q))
            if tmp_min > 0:
                ans = max(ans, sum(q)+tmp_min)
                break
        ans = max(ans, sum(q))

print(ans)

Measured memory_bytes: 3064
use std::io;
 
fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut it = line.split_whitespace();
    let a = it.next().unwrap().parse::<usize>().unwrap();
    let b = it.next().unwrap().parse::<usize>().unwrap();
 
    if (a * b) % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}

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

int main(){
    string c1, c2;
    int res=0;

    cin >> c1;
    cin >> c2;
    for(int i=0; i<3; ++i){
        if(c1[i] == c2[2-i]){
            res ++;
        }
    }
    if(res == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

//int main(){
//    int res;
//    string s[6];
//    for(int i=0; i<3; ++i){
//        cin >> s[i];
//    }
//    for(int i=3; i<6; ++i){
//        cin >> s[i];
//    }
//    cout << s << endl;
//    for(int i=0; i<3; ++i){
//        if(s[i] == s[2-i]){
//            res ++;
//        }
//    }
//    if(res==3) cout<<"YES"<< endl;
//    else cout << "NO" << endl;
//}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 998244353;
const int N=5009;
int main()
{
    FASTINOUT;
    long double x,ans;
    cin>>x;
    ans=x/3.0*x/3.0*x/3.0;
    cout<<fixed<<setprecision(6)<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    int x;
    int n;
    set<int> s;
    cin >> x >> n;
    for(int i=0;i<n;i++) {
        int e;
        cin >> e;
        s.insert(e);
    }
    for(int i=0;;i++) {
        int n1 = x-i;
        int n2 = x+i;
        if(s.find(n1)==s.end()) {
            cout << n1 << endl;
            return;
            break;
        }
        else if(s.find(n2)==s.end()) {
            cout << n2 << endl;
            return;
            break;
        }
    }
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <set>
#include <functional>
#include <algorithm>
#include <cmath>
#define REP(i,N) for(int i=0;i<N;i++)
using namespace std;
using vi=vector<int>;
using ll = long long int;
int main() {
	ll K, A, B,KA;
	cin >> K >> A >> B;
	
	if (A+1 >= B) {
		cout << 1 + K;
		return 0;
	}
	if (K <= A - 1) {
		cout << 1 + K;
		return 0;
	}
	if ((K-A) % 2 == 1) {
		cout << A + (B - A)*(K - A + 1) / 2;
		return 0;
	}
	else {
		cout << 1 + A + (B - A)*(K - A) / 2;
		return 0;
	}
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
X = [int(input()) for _ in range(N)]


def dfs(idx, a, b, c, cnt):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30
        else:
            return 10 ** 9

    res = 10 ** 9
    res = min(res, dfs(idx + 1, a, b, c, cnt))
    res = min(res, dfs(idx + 1, a + X[idx], b, c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b + X[idx], c, cnt + 10))
    res = min(res, dfs(idx + 1, a, b, c + X[idx], cnt + 10))
    return res


print(dfs(0, 0, 0, 0, 0))


Measured memory_bytes: 74188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int N;
  cin >> N;
  int happy[N][3];
  for(int i = 0 ; i <N; i++){
     for(int j = 0 ; j < 3; j++) cin >> happy[i][j];
  }
  int dp[N][3];
  memset(dp,0,sizeof(dp));
  for(int j = 0 ; j <3 ; j++)  dp[0][j] = happy[0][j];
  for(int i = 1; i < N; i++){
     for(int j=0; j <3; j++){
        for(int k =0; k < 3; k++){
           if(j==k) continue;
           dp[i][j] = max(dp[i][j], dp[i-1][k]+happy[i][j]);
        }
     }
  }
  int ans = 0;
  for(int j=0; j <3; j++) ans = max(ans, dp[N-1][j]);

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


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

int main(){
    string s,t;
    cin >> s >> t;
    vector<long long int> v[26];
    for(int i=0;i<(int)s.length();i++)v[(int)(s[i]-'a')].push_back(i);
    long long int ans=0;
    long long int tmp=0;
    int start=0;
    if(s[0]==t[0])start=1;
    for(int i=start;i<(int)t.length();i++){
        if(v[(int)(t[i]-'a')].size()==0){
            cout << -1;
            return 0;
        }
        int u = upper_bound(v[(int)(t[i]-'a')].begin(),v[(int)(t[i]-'a')].end(),tmp)-v[(int)(t[i]-'a')].begin();
        if(u<(int)v[(int)(t[i]-'a')].size()){
            ans+=v[(int)(t[i]-'a')].at(u)-tmp;
            tmp=v[(int)(t[i]-'a')].at(u);
        }
        else{
            ans+=(long long int)s.length()-tmp+v[(int)(t[i]-'a')].at(0);
            tmp=v[(int)(t[i]-'a')].at(0);
        }
    }
    cout << ans+1;
}

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

const int N = 1e5 + 5;

#define int long long

int n, A[N], T;

map < int, int > Map;

main() {
	cin >> n >> T;
	for(int i = 1; i <= n; ++ i) scanf("%lld", &A[i]);
	int Mi = 1e9, ans = 0;
	for(int i = 1; i <= n; ++ i) {
		Mi = min(Mi, A[i]);
		ans = max(ans, A[i] - Mi);
	}
	
	Mi = 1e9;
	int cnt1 = 0, cnt2 = 0;
	for(int i = 1; i <= n; ++ i) {
		++ Map[A[i]];
		Mi = min(Mi, A[i]);
		if(A[i] - Mi == ans) {
			cnt1 += Map[Mi];
			++ cnt2;
			Map[Mi] = 0;
		}
	}
	cout << min(min(cnt1, cnt2), 10000000000LL);
}

Measured memory_bytes: 10720