akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 0001
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rer(i, a, b) for(ll i=a-1; i>=b; i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
// vector< vector<int> > dp;

bool accessible(int x, vector<int> v){
    bitset<32001> dp;
    // int m = dp[0].size()/2, n=v.size();
    int m = 16000, n=v.size();
    // rep(i, 0, dp.size())rep(j, 0, dp[0].size()) dp[i][j] = 0;
    // dp[0][m] = 1;
    dp[m] = true;

    // rep(i, 0, n){
    //     rep(j, -m, m){
    //         if(j+m-v[i] < 0 && j+m+v[i] < dp[0].size()) dp[i+1][j+m] = dp[i][j+m+v[i]];
    //         else if(j+m-v[i] > 0 && j+m+v[i] > dp[0].size()) dp[i+1][j+m] = dp[i][j+m-v[i]];
    //         else dp[i+1][j+m] = dp[i][j+m-v[i]] || dp[i][j+m+v[i]];
    //     }
    // }
    rep(i, 0, n){
        // rep(j, -m, m){
            // dp[j+m] = dp[j+m-v[i]] || dp[j+m+v[i]];
            dp = (dp<<v[i]) | (dp>>v[i]);
        // }
    }
    // if(dp[n][x+m]==1) return true;
    // else return false;
    return dp[16000+x];
}

signed main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    vector<int> fx(1, 0), fy(0, 0);
    int n = s.size();
    int cnt = 0;
    rep(i, 0, n){
        if(s[i] == 'F'){
            if(cnt%2==0) fx[cnt/2]++;
            else fy[cnt/2]++;
        }else if(s[i] == 'T'){
            cnt++;
            if(cnt%2==0) fx.pb(0);
            else fy.pb(0);
        }
    }
    if(cnt==s.size() && (x != 0 || y != 0)){
        cout << "No" << endl;
        return 0;
    }
    // rep(i, 0, fx.size()) cout << fx[i] << endl;
    // rep(i, 0, fy.size()) cout << fy[i] << endl;
    // dp = vector< vector<int> >(max(fx.size(), fy.size())+1, vector<int>(16001, 0));
    x -= fx[0];
    fx.erase(fx.begin());

    if(accessible(x, fx))
        if(accessible(y, fy)){
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
x1, y1, x2, y2 = map(int,input().split())

x3 = x2 + y1 - y2
y3 = y2 + x2 - x1

x4 = x1 + y1 - y2
y4 = y1 + x2 - x1

print(x3, y3, x4, y4)

Measured memory_bytes: 9060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

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

bool table[1000][1000];
bool k[1000][1000];

int t, n;

void solve(int sy, int sx) {
	queue<pair<P, int>> que;
	table[sy][sx] = 1;
	que.push({ {sy,sx},0 });
	while (que.size()) {
		pair<P, int> p = que.front();
		que.pop();
		if (p.second == t)continue;
		rep(i, 6) {
			int ny = p.first.first + dy[i], nx = p.first.second + dx[i];
			if (!k[ny][nx] && !table[ny][nx]) {
				que.push({ { ny,nx }, p.second + 1 });
				table[ny][nx] = 1;
			}
		}
	}
}

int main() {
	while (cin >> t >> n&&t + n) {
		rep(i, 1000)rep(j, 1000) {
			table[i][j] = 0;
			k[i][j] = 0;
		}
		rep(i, n) {
			int y, x;
			cin >> x >> y;
			k[500 + y][500 + x] = 1;
		}
		int sy, sx;
		cin >> sx >> sy;
		solve(sy + 500, sx + 500);
		int ans = 0;
		rep(i, 1000)rep(j, 1000)ans += (table[i][j] && !k[i][j]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5076
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 998244353LL
#define MOD2 996491788296388609LL
#define MODL 7971934306371108872LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    inline constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<300000, ll, MOD> fact;

int main() {
    fastio();
    ll N, A, B, K, ans = 0;
	cin >> N >> A >> B >> K;
    ll g = gcd(A, B);
    if(K%g==0) {
        ll ca=B/g, cb=A/g;
        ll oa=min(N, K/A), ob=min(N, K/B);
        int i=0, j=ob;
        while(i<=oa) {
            while (i*A+j*B>K) j--;
            if (i*A+j*B==K) break;
            i++;
        }
        while(i<=oa && j>=0) {
            ans += fact.comb(N,i)*fact.comb(N,j);
            if(ans >= MODL) ans -= MODL;
            i += ca; j -= cb;
        }
    }
    cout << ans%MOD << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int g,s,b;
	g=n%10;
	s=n/10%10;
	b=n/100;
	if (b==g)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

ll gcd(ll a, ll b){
    ll temp;
	while (a % b != 0){
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;

    rep(i,S.size()){
        cout << char((int(S[i])-int('A')+N)%26+int('A'));
    }
    cout << "" <<endl;
    return 0;
}


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

int main()
{
    int l=0;
    char n[1000];
    scanf("%s", n);
    l=strlen(n);
    if(n[l-1]=='2' ||n[l-1]=='4' ||n[l-1]=='5' ||n[l-1]=='7' ||n[l-1]=='9')
        printf("hon\n");
    else if(n[l-1]=='0' ||n[l-1]=='1' ||n[l-1]=='6' ||n[l-1]=='8')
        printf("pon\n");
    else if(n[l-1]=='3')
        printf("bon\n");
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define itr(itr, map) for (auto itr = map.begin(); itr != map.end(); ++itr)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, w ,c;
    vector<int> v;
    cin >> N;
    rep(i, N) {
        cin >> w;
        v.push_back(w);
    }
    sort(v.rbegin(), v.rend());
    c = 0;
    rep(i, N) {
        w = v.at(i);
        if(i % 2 == 0) {
            c += w;
        } else {
            c -= w;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;

  int n=s.size();
  int alp[26]={};
  for(int i=0;i<n;i++){
    alp[s[i]-'A']++;
  }

  int two=0;
  for(int i=0;i<26;i++){
    if(alp[i]==2) two++;
  }

  if(two==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}

		int[] dp = new int[N];
		for (int i = 0; i < N; i++) dp[i] = (int)Double.POSITIVE_INFINITY;
		dp[0] = 0;

		for(int i = 1; i < N; i++) {
			dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			if (i > 1)  dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
		}

		System.out.println(dp[N - 1]);
	}

}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

const int MAXN = 100000;
const ll MOD = 998244353;
const ll PO = 1000000000000000000LL%MOD;
const int SQ = 450;

int n;
vector<int> lis[3][100100];
ll an1[100100];
ll anv[SQ+10];
int an2[100100];
ll anv2[SQ+10];
int an3[100100];
int ma[SQ+10][SQ+10];
ll po[300100];

int chk[100100];
int chk2[100100][SQ+10];
int main(){
	scanf("%d",&n);
	int m;
	for (int t=0;t<3;t++) {
		scanf("%d", &m);
		for (int i = 0; i < m; i++) {
			int a, b;
			scanf("%d%d", &a, &b); a--; b--;
			if (a>b) swap(a,b);
			lis[t][a].push_back(b);
		}
	}
	po[0] = 1;
	for (int i=1;i<=3*n;i++) po[i] = po[i-1]*PO%MOD;
	for (int i=n-1;i>=0;i--) {
		for (int &j : lis[0][i]) chk[an1[j]] = 1;
		int t;
		for (t=0;chk[t];t++);
		an1[i] = t;
		anv[t] = (anv[t]+po[i])%MOD;
		for (int &j : lis[0][i]) chk[an1[j]] = 0;
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int &k : lis[1][i]) chk2[i][an2[k]]=1;
		int t;
		for (t = 0; chk2[i][t]; t++);
		an2[i] = t;
		//anv2[0] = (anv2[0] + anv[t]*po[i]) % MOD;
		for (int &k : lis[1][i]) chk2[i][an2[k]]=0;
	}
	for (int j=0;j<SQ;j++) {
		for (int i=0;i<SQ;i++) {
			for (int k=0;k<i;k++) chk[ma[j][k]]=1;
			for (int k=0;k<j;k++) chk[ma[k][i]]=1;
			int t;
			for (t=0;t<SQ&&chk[t];t++);
			ma[j][i] = t;
			for (int k=0;k<i;k++) chk[ma[j][k]]=0;
			for (int k=0;k<j;k++) chk[ma[k][i]]=0;
		}
		for (int i=0;i<n;i++) {
			anv2[j] = (anv2[j]+anv[ma[j][an2[i]]]*po[i])%MOD;
		}
	}
	ll ans = 0;
	for (int i=n-1;i>=0;i--) {
		for (int &j : lis[2][i]) chk[an3[j]] = 1;
		int t;
		for (t=0;chk[t];t++);
		an3[i] = t;
		ans = (ans+anv2[t]*po[i])%MOD;
		for (int &j : lis[2][i]) chk[an3[j]] = 0;
	}
	printf("%lld\n",ans*po[3]%MOD);

	return 0;
}


Measured memory_bytes: 197632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int d[301][301];

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        rep(j, n){
            cin >> d[i][j];
            if(i < j) ans += d[i][j];
        } 
    }

    rep(i, n){
        rep(j, n){
            rep(k, n){
                if(i == j || i == k || j == k) continue;
                if(d[i][j] > d[i][k] + d[k][j]){
                    cout << -1 << endl;
                    return 0;
                }
                if(i < j && d[i][j] == d[i][k] + d[k][j]){
                    ans -= d[i][j];
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

Combi=[[] for i in range(N+1)]
Combi[0]=[1,0]

for i in range(1,N+1):
    Combi[i].append(1)
    for j in range(i):
        Combi[i].append((Combi[i-1][j]+Combi[i-1][j+1])%mod)
    Combi[i].append(0)

DP=[0]*(N+1)
DP[0]=1

for k in range(K):
    use=A[k]

    NDP=[0]*(N+1)

    for i in range(N+1):
        ANS=0
        for j in range(i+1):
            if use-(i-j)>=0:
                ANS=(ANS+DP[j]*Combi[N-j][i-j]*Combi[N-(i-j)][use-(i-j)])%mod

        NDP[i]=ANS

    #print(DP)

    DP=NDP

print(DP[N])

Measured memory_bytes: 52716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int d[] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
int main(void) {
	int x, y; cin >> x >> y;
	if(d[x] == d[y]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin >> s >> t;
  string s1,t1;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t){
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No" <<endl;
  return 0;
}

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

int main(){
  int x;
  cin >> x;
  int a = x / 1000;
  int b = x / 100 - a * 10;
  int d = x % 10;
  int c = ( x % 100 - d ) / 10;
  if ( (a == b && b == c) || (b == c && c == d) ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

bool check(std::vector<char> v,int n){
  int k,count = 0;

  if(v[0]!='A')//先頭はAか?
    return false;

  for (int i = 2; i < (n-1); i++)
    {
      if((v[i]) == 'C')
      {
        count += 1;
        k = i;
      }
  }
  if (count != 1)//Cの数は1個か?
    return false;

  v.erase(v.begin()+k);v.erase(v.begin());

  //AとC以外は小文字か?
  for (int i = 0; i < v.size();i++){
    if ('a' > v[i] || 'z' < v[i])
      return false;
  }

  return true;
}

int main(){
  std::string s;
  std::cin >> s;
  std::vector<char> v;
  int n = s.size();

  for (int i = 0; i < n;i++)
    v.push_back(s[i]);

  if(check(v,n)){
    std::cout << "AC" << std::endl;
  } else {
    std::cout << "WA" << std::endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char moji[100];
    int mojisize, count;
    scanf("%s", moji);
    for(count = 0; moji[count] != '\0'; count++);
    printf("%c%d%c", moji[0], count - 2, moji[count - 1]);
    return 0;
}

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

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int count = 0;
	while(a >= b){
		b *= 2;
		count++;
	}
	while(b >= c){
		c *= 2;
		count++;
	}
	if(count <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
Y_DIR=[-1,0,1]
X_DIR=[-1,0,1]
def count_bomb(y,x):
  cnt=0
  for yd in Y_DIR:
    yy=y+yd
    if not (0<=yy<h):
      continue
    for xd in X_DIR:
      xx=x+xd
      if not (0<=xx<w):
        continue
      if s[yy][xx]=="#":
        cnt+=1
  return cnt

h,w=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
  
ans=["" for _ in range(h)]
for y in range(h):
  for x in range(w):
    if s[y][x] == ".":
      c=count_bomb(y,x)
      ans[y]+=str(c)
    else:
      ans[y]+=s[y][x]

print("\n".join(ans)) 
      


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int a,b,c;
   cin>>a>>b>>c;

   int ans=0;
   int ta,tb,tc;
   while(a%2==0 && b%2==0 && c%2==0){
       if(a==b && b==c){
           cout<<-1<<endl;
           return 0;
       }
       ta=(b+c)/2;
       tb=(c+a)/2;
       tc=(a+b)/2;
       ans++;
       a=ta;b=tb;c=tc;
   }
   cout<<ans<<endl;
}

   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
typedef pair<int,int> P;

int N,M;
P t[MAX];

vector<int> G[MAX];

int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    t[i]=P(l,r);
    G[l].push_back(i);
  }

  vector<int> z;
  for(int id:G[0])z.push_back(id);
  
  priority_queue< P, vector<P> , greater<P> > Q;
  int cnt=0;
  for(int i=1;i<=M+1;i++){
    
    for(int id:G[i]){
      int r=t[id].second;

      
      if( min(i,M)-cnt>0){
        cnt++;
        Q.push( P(r,id) );

      }else{

        Q.push( P(r,id) );
        P p=Q.top();
        Q.pop();
        z.push_back( p.second );
      }

    }
  }
  for(int i=0;i<MAX;i++)G[i].clear();


  for(int id:z){
    //    cout<<id<<' '<<t[id].second<<endl;
    G[ t[id].second ].push_back(id);
  }
  
  int cc=0;
  for(int i=M;i>=1;i--){
    for(int id:G[i]){
      if(min(M-i+1,M-cnt)-cc>0){
        cc++;
      }
    }
  }

  //  cout<<cc<<' '<<cnt<<endl;
  
  cout<< N-M+(M-cc-cnt) <<endl;
  return 0;
}


Measured memory_bytes: 13940
#include<stdio.h>
int main(){
    int a,b;
    int ans;
    scanf("%d %d",&a,&b);
    if(a<=5) ans=0;
    else if (6<=a && a<=12) ans = b/2;
    else{
        ans=b;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
const int MAXN = 101010;
int N , E , T;
int x[MAXN];
ll f[MAXN];
int head = 1 , tail = 0;
ll minn = 1000000000000ll;
int q[MAXN];
ll t[MAXN];
void push(int p , ll now){
	while(head <= tail && now <= t[tail])
		tail --;
	q[++ tail] = p;
	t[tail] = now;
}
int main(){
	ios::sync_with_stdio(0);
	cin >> N >> E >> T;
	for(int i = 1 ; i <= N ; ++ i)
		cin >> x[i];
	f[N + 1] = 0;
	x[N + 1] = E;
	for(int i = N ; i >= 1 ; -- i){
		while(head <= tail && 2 * (x[q[head]] - x[i]) >= T){
			minn = min(minn , f[q[head] + 1] + 2ll * x[q[head]] + x[q[head] + 1]);
			head ++;
		}
		push(i , f[i + 1] + x[i + 1]);
		f[i] = minn - 3ll * x[i];
		if(head <= tail) f[i] = min(f[i] , t[head] + T - x[i]);
	}
	cout << f[1] + x[1] << endl;
	return 0;
}

Measured memory_bytes: 2688
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    vector<int> cost;
    int tmp;

    cin >> tmp;
    cost.push_back(tmp);
    cin >> tmp;
    cost.push_back(tmp);
    cin >> tmp;
    cost.push_back(tmp);

    sort(cost.begin(),cost.end());
    cout << cost[2]-cost[0];

    

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
//constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[3007][3007],x[3007][3007],y[3007][3007];

int main(){
  ll A,C,B,D,ANS=0;
  cin >> A >>  B >>  C >> D;
  ll X=C-A,Y=D-B;
  rep(i,3002){
    rep(j,3002){
      dp[i][j]=0;
    }
  }
  dp[A][B]=1;
  Rep(i,A,C+1){
    Rep(j,B,D+1){
      dp[i+1][j]+=dp[i][j]*j;
      dp[i+1][j]%=MOD;
      dp[i][j+1]+=dp[i][j]*i;
      dp[i][j+1]%=MOD;
      dp[i+1][j+1]+=MOD-dp[i][j]*i*j;
      dp[i+1][j+1]%=MOD;
    }
  }
  cout << dp[C][D] << endl;
}

Measured memory_bytes: 74160
# -*- coding: utf-8 -*-
#D - Grid Components
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B = map(int,readline().split())
grid = []
for _ in range(50):
    grid.append(['.']*100)
for _ in range(50):
    grid.append(['#']*100)   
A -= 1
B -= 1

cnt = 0
f = 0
for i in range(1,50,2):
    for j in range(1,99,2):
        if cnt == B:
            f = 1
            break
        cnt += 1
        grid[i][j] = '#'
    if f == 1:
        break
cnt = 0
f = 0
for i in range(51,100,2):
    for j in range(1,99,2):
        if cnt == A:
            f = 1
            break
        cnt += 1
        grid[i][j] = '.'
    if f == 1:
        break
print(100,100)
for row in grid:
    print(''.join(a for a in row)) 

Measured memory_bytes: 9384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

list<int> Prime(int num) {
	list<int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

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

	cin >> M >> N >> L >> R;
	while (M) {
		vector<pair<pair<int, int>, int>>score(N + 1);
		for (int i = 1; i <= N; i++) {
			score[i].second = i;
		}
		vector<vector<int>>WA(N + 1, vector<int>(M + 1));
		for (int i = 0; i < R; i++) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			if (d) {
				WA[b][c]++;
			}
			else {
				score[b].first.first++;
				score[b].first.second -= a;
				score[b].first.second -= WA[b][c] * 20;
			}
		}
		sort(score.begin(), score.end());
		reverse(score.begin(), score.end());
		pair<int,int> box = { -1,0 };
		for (auto i : score) {
			if (i.second==0) {
				continue;
			}
			if (box.first == -1) {
				cout << i.second;
				box = { i.first.first,i.first.second };
			}
			else {
				if (box == make_pair(i.first.first, i.first.second)) {
					cout << "=" << i.second;
				}
				else {
					cout << "," << i.second;
					box = { i.first.first,i.first.second };
				}
			}
		}
		cout << endl;
		cin >> M >> N >> L >> R;
	}
	return 0;
}

Measured memory_bytes: 3200
N = int(input())
d_list = list(map(int,input().split()))

#print(N)
#print(d_list)


total_cmb = int(N * (N-1) / 2)

total = 0
add_cnt = 0
for n1 in range(N):
    for n2 in range(N):
        if n1 < n2:
            total = total + d_list[n1] * d_list[n2]
            add_cnt = add_cnt + 1

#print(add_cnt, "/", total_cmb)
print(total)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    s=" "+s;
    n++;
    ll f1=1,f2=1;
    for(ll i=b+1;i<d;i++)
    {
        if(s[i]=='#'&&s[i-1]=='#')
            f1=0;
    }
    for(ll i=a+1;i<c;i++)
    {
        if(s[i]=='#'&&s[i-1]=='#')
            f1=0;
    }
    if(c>d)
    {
        f2=0;
        for(ll i=b-1;i<=(d-1);i++)
        {
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
                f2=1;
        }
    }
    if(f1&&f2)
        cout<<"Yes";
    else
        cout<<"No";
}

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

long long n, k, arr[200001], ans;

int main(){
	cin>>n>>k;
	
	for(long long i=1; i<=n; i++) cin>>arr[i];
	sort(arr+1, arr+n+1);
	
	for(long long i=1; i<=n-k; i++){
		ans+=arr[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int N,i,j,min,temp,swap=0;
  int A[100];

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

  for(i=0;i<N;i++){
    min=i;
    for(j=i+1;j<N;j++){

      if(A[j]<A[min]) {
	min=j;
      }
    }
    if(i!=min){    
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    swap++;
    }

  }
    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n%d\n",A[N-1],swap);
  
} 



Measured memory_bytes: 2072
n=int(input())
s=[input() for i in range(n)]

dict={"M":0, "A":0, "R":0, "C":0, "H":0}
dickey=list(dict.keys())
for i in range(n):
    if s[i][0] in dict:
        dict[s[i][0]]+=1

# print(dict)
# print(dickey)
ans=0
for i in range(0, 3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans+=dict[dickey[i]]*dict[dickey[j]]*dict[dickey[k]]

print(ans)


Measured memory_bytes: 54616
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;n--;
    ll num = 1;
    ll cnt = 1;
    while(n>=26*num){
        n-=num*26;
        num*=26;
        cnt++;
    }
    string ans = "";
    for(int i=0; i<cnt; i++){
        ans += 'a'+n%26;
        n/=26;
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

m = 0
for i in range(1, K+1):
    if i <= N:
        for j in range(1,i+1):
            VV = deque(copy.deepcopy(V))
            a = []
            heapq.heapify(a)
            for k in range(j):
                v = VV.popleft()
                heapq.heappush(a,v)
            for k in range(i-j):
                v = VV.pop()
                heapq.heappush(a, v)
            ans = sum(a)
            for k in range(K-i):
                if len(a) > 0:
                    v = heapq.heappop(a)
                    if v < 0:
                        ans -= v
            m = max(m,ans)
    else:
        ans = sum(V)
        a = copy.deepcopy(V)
        heapq.heapify(a)
        for k in range(K-N):
            if len(a) > 0:
                v = heapq.heappop(a)
                if v < 0:
                    ans -= v
        m = max(m, ans)
        break

print(m)






Measured memory_bytes: 75472
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100100]={0};
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=abs(a[i]-a[i-1]);
	}
	sum+=abs(a[n]);
	for(int i=1;i<=n;i++){
		int ans=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
		cout<<ans<<endl;
	}
}

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

int main(int argc, char *argv[])
{
    char a[6];
    for (int i = 0; i < 6; i++) {
        std::cin >> a[i];
    }
    if ((a[0] == a[5]) && (a[1] == a[4]) && (a[2] == a[3])) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

i64 memo[41][2];
i64 a, b, c, x;

i64 rec(const i64 i, const bool j) {
    if (i < 0) return 0;
    if (memo[i][j] != -2) return memo[i][j];
    const i64 mask = 1ll << i;
    const i64 p = mask & a, q = mask & x, r = mask & c;
    i64 ret;
    if (!q) {
        if (!r) {
            ret = rec(i - 1, j || p);
        } else {
            if (!p && !j) ret = -1;
            else ret = mask | rec(i - 1, j);
        }
    } else {
        if (!r) {
            const i64 z = rec(i - 1, j || p),
                o = !p && !j ? -1 : (rec(i - 1, j) | mask);
            ret = std::max(z, o);
        } else {
            ret = -1;
        }
    }

    return memo[i][j] = ret;
}

int main() {
    for (auto &v : memo) v[0] = v[1] = -2;
    int n;
    std::cin >> n >> a >> b;
    for (int i = 2; i < n; i++) {
        i64 in;
        std::cin >> in;
        x ^= in;
    }

    const i64 t = a + b - x;
    if (t < 0 || t % 2) {
        std::cout << -1 << std::endl;
        return 0;
    }

    c = t / 2;

    const i64 ret = rec(40, false);
    std::cout << (ret <= 0 ? -1 : a - ret) << std::endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        rep(i,h){
            rep(j,w){
                if(i == 0 || i == h-1 || j == 0 || j == w-1){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<stack>
#include<sstream>
#include<vector>
using namespace std;
int main(){
  stringstream ss;
  int n;
  string line;
  for(cin>>n;n>0;n--){
    ss.str("");
    ss.clear(stringstream::goodbit);
    cin>>line;
    vector<int> form,f_nums;
    vector<char> f_signs;
    if(line[0]=='-')line = "0"+line;
    ss<<line;
    stack<char> sg;
    int num;
    char sign;
    for(int i=0;i<line.size();i++){
      if('0'<=ss.str()[i]&&ss.str()[i]<='9'){
	ss>>num;
	for(int d=10;d<=num;i++)d*=10;
	f_nums.push_back(num);
	form.push_back(f_nums.size()-1);
      }
      else{
	ss>>sign;
	if(sign=='=')break;
	if(sign==')'){
	  while(sg.top()!='('){
	    f_signs.push_back(sg.top());
	    form.push_back(-f_signs.size());
	    sg.pop();
	  }
	  sg.pop();
	}
	else{
	  if(sign!='('){
	    while(!sg.empty()&&sg.top()!='('&&((sign=='+'||sign=='-')||(sg.top()=='*'||sg.top()=='/'))){
	      f_signs.push_back(sg.top());
	      form.push_back(-f_signs.size());
	      sg.pop();
	    }
	  }
	  sg.push(sign);
	}
      }
    }
    while(!sg.empty()){
      f_signs.push_back(sg.top());
      form.push_back(-f_signs.size());
      sg.pop();
    }
    stack<int> calc;
    for(int i=0;i<form.size();i++){
      if(form[i]>=0){
	calc.push(f_nums[form[i]]);
      }
      else{
	double a,b,c;
	b = calc.top();
	calc.pop();
	a = calc.top();
	calc.pop();
	if(f_signs[-form[i]-1]=='+')c = a+b;
	if(f_signs[-form[i]-1]=='-')c = a-b;
	if(f_signs[-form[i]-1]=='*')c = a*b;
	if(f_signs[-form[i]-1]=='/')c = a/b;
	calc.push(c);
      }
    }
    cout<<calc.top()<<endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll dp[100][100001];
ll n,m,k;
int main(){
    while(1) {
        cin >> n >> m >> k;

        if(n == 0) 
            break;

        REP(i,n + 1) {
            REP(j,n * m + 1) {
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;

        REP(i,n) {
            REP(j,n * m + 1) {
                REP(k,m) {
                    dp[i + 1][j + k + 1] += dp[i][j];
                }
            }
        }
        double ans = 0;
        double d = 1;

        REP(i,n) {
            d *= (1.0 / m);
        }

        REP(i,n * m + 1) {
            ans += ((max(1ll,i - k) * dp[n][i] * 1.0) * d);
        }

        printf("%0.10f\n",ans);
    }
}




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

int main() {
    int n;  cin >> n;
    if (n >= 64)  cout << 64 << endl;
    else if (n >= 32)  cout << 32 << endl;
    else if (n >= 16)  cout << 16 << endl;
    else if (n >= 8)  cout << 8 << endl;
    else if (n >= 4)  cout << 4 << endl;
    else if (n >= 2)  cout << 2 << endl;
    else  cout << 1 << endl;
}

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

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

const ll MOD = 1e9+7;

inline void in() {}
template<class T, class... Ts>
inline void in(T& x, Ts&... xs) {
	int c, s=0; x=0;
	while (c=getchar(), c!='-'&&(c<'0'||c>'9'));
	if (c=='-') s=1, c=getchar();
	do x=x*10+(c-'0'); while (c=getchar(), c>='0'&&c<='9');
	if (s) x=-x;
	in(xs...);
}
inline void ins(char *s) {
    char c; while(c=getchar(), c<33); do *s++=c; while(c=getchar(), c>32); *s=0;
}

char d[500][500];
int a[500][500],b[500][500];

int main() {
	int h,w;
	in(h,w);
	rep(i,0,h) {
		rep(j,0,w) d[i][j]=getchar();
		getchar();
	}
	rep(j,0,w)a[0][j]=b[h-1][j]=1;
	rep(i,1,h-1) {
		rep(j,0,w) {
			a[i][j]=j%2==0||d[i][j]=='#';
			b[i][j]=j%2==1||d[i][j]=='#';
		}
	}
	rep(i,0,h) {
		rep(j,0,w) {
			putchar(a[i][j]?'#':'.');
		}
		putchar('\n');
	}
	putchar('\n');
	rep(i,0,h) {
		rep(j,0,w) {
			putchar(b[i][j]?'#':'.');
		}
		putchar('\n');
	}
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

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

int main() {
    int v[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int64_t k;
    cin >> k;

    cout << v[k - 1] << endl;
}

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

int main() 
{ 
    string s,t; 
    cin>>s>>t; 

    bool flg=true;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            flg=false;
            break;
        }
    }

    if(flg&&s.size()+1==t.size())
        cout<<"Yes"<<endl; 
    else
        cout<<"No"<<endl;

return 0; 
} 


Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;
string s1,s2;
int main()
{
	cin>>s1>>s2;
	bool prime = true;
	int s1len = s1.length();
	int s2len = s2.length();
	for(int i=0,j=s2len-1;i<s1len&&j>=0;i++,j--){
		if(s1[i]!=s2[j])
		{
			prime = false;
			break;
		}
	}
	if(prime)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		if(s.length()<=2) {
			System.out.println(s);
		}else {
			System.out.println(s.charAt(2)+""+s.charAt(1)+""+s.charAt(0));
		}

	}
	public static int floor(int n) {
		return (int)Math.floor((n*n + 4.0)/8.0);
	}

}


Measured memory_bytes: 21844
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}

int main()
{
	string s,t="";
	cin >> s;
	FOR(i, 0, s.size()) {
		if ((i+1) % 2 == 1) t += s[i];
	}
	cout << t << endl;
}


Measured memory_bytes: 512
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 1e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 

int dp[105][LIM];

int32_t main()
{
	IOS;
    int w,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++){
        int v;
        cin>>w>>v;
        // dp[i]=dp[i-1];
        forn(j,W+1) dp[i][j]=dp[i-1][j];
        for(int j=0;j<=W;j++){
            if(j+w<=W){
                dp[i][j+w]=max(dp[i-1][j]+v,dp[i][j+w]);
            }
        }
    }
    int ans=0;
    forn(j,W+1) ans=max(ans,dp[n][j]);
    cout<<ans<<ln;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int h,w,c4,c2,c1;
string s;
map<char,int> m;

signed main() {
    cin >> h >> w;
    rep(i,h) {
        cin >> s;
        for(auto j : s) m[j]++;
    }
    for(auto& i : m) c4 += i.se/4, i.se %= 4;
    for(auto& i : m) c2 += i.se/2, i.se %= 2;
    for(auto i : m) c1 += i.se;
    if (h%2 + w%2 == 2) {
        int a4,a2,a1=1;
        a4 = (h-1)*(w-1)/4;
        a2 = (h+w-2)/2;
        int tmp = max(0LL, c4-a4);
        c2 += tmp*2;
        c4 -= tmp;
        if (a4 == c4 && a2 == c2 && a1 == c1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if (h%2) {
        int a4,a2=w/2,a1=0;
        a4 = (h-1)*w/4;
        int tmp = max(0LL, c4-a4);
        c2 += tmp*2;
        c4 -= tmp;
        if (a4 == c4 && a2 == c2 && a1 == c1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if (w%2) {
        int a4,a2=h/2,a1=0;
        a4 = (w-1)*h/4;
        int tmp = max(0LL, c4-a4);
        c2 += tmp*2;
        c4 -= tmp;
        if (a4 == c4 && a2 == c2 && a1 == c1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        int a4,a2=0,a1=0;
        a4 = w*h/4;
        int tmp = max(0LL, c4-a4);
        c2 += tmp*2;
        c4 -= tmp;
        if (a4 == c4 && a2 == c2 && a1 == c1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,a,b;
    int train;
    
    scanf("%d %d %d",&n,&a,&b);
    
    train = a * n;
    
    if(train > b)
    {
        printf("%d\n",b);
    }
    else
    {
        printf("%d\n",train);
    }
    
    return 0;
}


Measured memory_bytes: 128
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll n,m,ans;
    cin>>n>>m;

    if (n>m){
        ll t=n;
        n=m;
        m=t;
    }

    if (n==1){
        if (m==1) ans=1;
        else if (m==2) ans=0;
        else ans=m-2;
    } else if (n==2){
        ans=0;
    } else {
        ans=(n-2)*(m-2);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <vector>

using namespace std;
typedef long long int ll;

int main(){
    int n, q, c, t, x;
    vector<stack<int>> v;

    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++){
        v.push_back(stack<int>());
    }
    for (int i = 0; i < q; i++){
        scanf("%d %d", &c, &t);
        if(c==0){
            scanf("%d", &x);
            v.at(t).push(x);
        }else if(c==1){
            if(!v.at(t).empty()){
                printf("%d\n", v.at(t).top());
            }
        }else{
            if(!v.at(t).empty()){
                v.at(t).pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,k; cin >> n >> k;
	int ans = 0;
	while(n){
		n /= k;
		ans++;
	}
	cout << ans << endl;
}




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

typedef struct{
  double x;
  double y;
} Point;

void koch(int n, Point p1, Point p2){
  
  if (n == 0) return;
  
  Point s,t,u;
  
  s.x = ((2*p1.x)+(1*p2.x))/3;
  s.y = ((2*p1.y)+(1*p2.y))/3;
  t.x = ((1*p1.x)+(2*p2.x))/3;
  t.y = ((1*p1.y)+(2*p2.y))/3;
  u.x = (t.x - s.x)*cos(M_PI/3)-(t.y - s.y)*sin(M_PI/3)+s.x;
  u.y = (t.x - s.x)*sin(M_PI/3)+(t.y - s.y)*cos(M_PI/3)+s.y;
  
  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);

  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  
  koch(n-1,t,p2);
}

int main(){
  int n;
  Point p1 = {0,0};
  Point p2 = {100,0};

  scanf("%d",&n);
  
  printf("%.8f %.8f\n",p1.x,p1.y);
 
  koch(n,p1,p2);
  
  printf("%.8f %.8f\n",p2.x,p2.y);
 
  return 0;

}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<pair<int, int>> a(n);
    for (auto i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());
    int64_t ans = 0; int i = 0;
    while (m > 0) {
        ans += (int64_t)a[i].first * min(a[i].second, m);
        m -= a[i].second;
        i++;
    }

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

Measured memory_bytes: 1024