akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=1000;
int n,m,k,ans=1,tot=1,tail,cnt,Time;
int pre[maxn*2+8],now[maxn+8],son[maxn*2+8];
int fac[maxn*2+8],fact[maxn*2+8],st[maxn+8];
int dfn[maxn+8],low[maxn+8];
bool vis[maxn*2+8],color[maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void add(int u,int v)
{
    pre[++tot]=now[u];
    now[u]=tot;
    son[tot]=v;
}

int C(int n,int m){return 1ll*fac[n]*fact[m]%mod*fact[n-m]%mod;}
int power(int a,int k)
{
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
	if (k&1)
	    sum=1ll*sum*a%mod;
    return sum;
}
int gcd(int n,int m){return n?gcd(m%n,n):m;}

void tarjan(int x)
{
    dfn[x]=low[x]=++Time;
    for (int p=now[x];p;p=pre[p])
	{
	    int child=son[p];
	    //if (child==fa||dfn[child]>dfn[x]) continue;
	    if (color[p]) continue;
	    color[p]=color[p^1]=1;
	    st[++tail]=p;
	    if (!dfn[child])
		{
		    tarjan(child);
		    low[x]=min(low[x],low[child]);
		    if (low[child]>=dfn[x])
			{
			    //puts("Link Start");
			    bool flag=1;int cnt=0,tmp=0;
			    for (int i=tail;st[i+1]!=p;cnt++,i--)
				if (vis[son[st[i]]]) flag=0;
				else vis[son[st[i]]]=1;
			    if (flag)
				{
				    for (int i=1;i<=cnt;i++) tmp=(tmp+power(k,gcd(cnt,i)))%mod;
				    tmp=1ll*tmp*power(cnt,mod-2)%mod;
				}
			    else tmp=C(cnt+k-1,k-1);
			    ans=1ll*ans*tmp%mod;
			    while(st[tail+1]!=p) vis[son[st[tail]]]=0,tail--;
			    // puts("Over");
			}
		}
	    else low[x]=min(low[x],dfn[child]);
	}
}

int main()
{
    n=read(),m=read(),k=read();
    fac[0]=fact[0]=1;
    for (int i=1;i<=m+k;i++) fac[i]=1ll*fac[i-1]*i%mod;
    fact[m+k]=power(fac[m+k],mod-2);
    for (int i=m+k-1;i;i--) fact[i]=1ll*fact[i+1]*(i+1)%mod;
    for (int i=1;i<=m;i++)
	{
	    int u=read(),v=read();
	    add(u,v),add(v,u);
	}
    for (int i=1;i<=n;i++)
	if (!dfn[i]) tarjan(i);
    printf("%d\n",ans);
    return 0;
}
		
	    


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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

ll N, K;
vector<pair<ll, ll> > v;

signed main()
{
	cin >> N >> K;
	rep(i, N) {
		CIN(ll, a);
		CIN(ll, b);
		v.PB(MP(a, b));
	}
	sort(all(v));
	ll cnt = 0;
	int pos = -1;
	while (cnt < K) {
		pos++;
		cnt+=v[pos].second;
	}
	cout << v[pos].first << endl;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
/*
T M Hridoy KUET CSE 15
*/
#include<bits/stdc++.h>

using namespace std;

#define print printf("==================\n");
typedef    long long ll;
typedef pair<ll,ll   > payar;
typedef   unsigned long long ull;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define readf                freopen("in.txt", "r", stdin);
#define writef               freopen("out.txt", "w", stdout);

priority_queue<int, vector<int>,  greater<int> > pq; ///accending
vector< pair<int,payar  > > vpp;
vector< pair<int,  pair<int,payar  > > > own;
vector < payar >  vp;
#define pi acos(-1.0);
#define EPS 1e-9
#define  mod   1000000007
#define  mod2  998244353
#define all(x) x.begin(),x.end()
#define endl "\n"


const int N = 15;
const int M = 1005;

int n, m, k;
char a[N][M];
int cur[N], temp[N];

int32_t main()
{
    IOS;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    int ans = 1e9;
    for(int mask = 0; mask < (1 << (n - 1)); mask++)
    {
        int cuts = __builtin_popcount(mask);
        memset(cur, 0, sizeof(cur));
        int flag = 1;
        for(int j = 0; j < m && flag; j++)
        {
            int idx = 0;
            memset(temp, 0, sizeof(temp));
            for(int i = 0; i < n; i++)
            {
                temp[idx] += (a[i][j] - '0');
                if(mask >> i & 1)
                    idx++;
            }
            for(int j = 0; j < n; j++)
            {
                if(temp[j] > k)
                {
                    flag = 0;
                    break;
                }
            }
            bool mark = 0;
            for(int j = 0; j < n; j++)
            {
                if(cur[j] + temp[j] > k)
                    mark = 1;
            }
            cuts += mark;
            if(mark)
            {
                for(int j = 0; j < n; j++)
                    cur[j] = temp[j];
            }
            else
            {
                for(int j = 0; j < n; j++)
                    cur[j] += temp[j];
            }
        }
        if(flag)
            ans = min(ans, cuts);
    }
    cout << ans;
    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 m = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[m];
		for(int i = 0 ; i < n ; i++) a[i] = sc.next();
		for(int i = 0 ; i < m ; i++) b[i] = sc.next();
		for(int i = 0 ; i <= n - m ; i++) {
			for(int j = 0 ; j <= n - m ; j++) {
				boolean ok = true;
				for(int k = 0 ; k < m ; k++) {
					for(int l = 0 ; l < m ; l++) {
						int x = i + k;
						int y = j + l;
						if(a[x].charAt(y) != b[k].charAt(l)) {
							ok = false;
						}
					}
				}
				if(ok == true) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


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


typedef long long ll;



 
const int mx = 105;
const int mx1 = 1000001;
const ll mod = 1000000007;


void adds(int &a, int b){
    a+= b;
    if(a >= mod)
     a-=mod;
}

// void subs(int &a, int b){
//     a-= b;
//     if(a < 0)
//      a+=mod;
// }

int main(){
   int n, i, j;
   cin>>n;

   bool a[n][n];


   for(i = 0;i < n;i++){
       for(j =0 ;j < n;j++){
           cin>>a[i][j];
       }
   }
   
   vector<int> dp(1<<n);

   dp[0] = 1;

   for(i = 0;i < (1<<n)-1;i++){
       ll m = __builtin_popcount(i);

       for(j = 0;j < n;j++){
           if(a[m][j] && !(1<<j & i)){
               ll mask = 1<<j|i;
               adds(dp[mask], dp[i]);
           }
       }
   }
   cout<<dp[(1<<n)-1];
} 


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

int main(){
    string S; cin >> S;
    map<int, ll> count;
    rep(i, S.size()){
        int idx = (int)(S[i] - 'a');
        count[idx]++;
    }
    ll ans = 1;
    for(int i = 0;i < 25; i++) {
        for(int j = i+1;j < 26;j++) {
            ans += count[i] * count[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    cout<<n*n*n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;

int n;
int a[101];

int main(){
	cin >> n;
	int c = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 1; i < n; i++){
		if(a[i] == a[i-1]){
			if(i != n-1 && a[i] == a[i+1]){
				c++;
				i++;
			}
			else c++;
		}
	}
	cout << c << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import bisect as bs

def main():
	s = input()
	t = input()
	indx = [[] for _ in range(26)]
	count = [0 for _ in range(26)]
	loop = 0
	pre = -1
	lens = len(s)
	for i in range(lens):
		c = ord(s[i])-97
		indx[c] += [i]
		count[c] += 1
	for i in range(len(t)):
		c = ord(t[i])-97
		if indx[c] == []:
			print(-1)
			return
		ref = bs.bisect(indx[c],pre)
		if indx[c][ref%count[c]] <= pre:
			loop += 1
		pre = indx[c][ref%count[c]]
		# print(pre)
	print(loop*lens + pre + 1)

main()

Measured memory_bytes: 7628
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;



void main() {
    string input;

    while ((input = readln.chomp).length != 0) {
        double sum = 0;
        double[] data = new double[](10);

        data[0] = input.to!double;
        foreach (i; 1..10) {
            if ((i % 2) == 0) {
                /* 偶数項 */
                data[i] = data[i - 1] / 3;
            } else {
                /* 奇数項 */
                data[i] = data[i - 1] * 2;
            }
        }

        foreach (i; 0..10) {
            sum += data[i];
        }

        writefln("%.8f", sum);
    }
}

Measured memory_bytes: 1128
#include <cstdio>
#include <cmath>
#include <vector>
#include <utility>

using namespace std;

#define INF 2000000000

#define min_aplly(x, y) if (x > y) x = y;

int dp[81][150][10];

int main() {
    while (1) {
        int i, j, k, l;
        int n, m;
        vector<pair<int, int> > points[150];
        int min = INF;

        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) return 0;

        for (l=0;l<m+1;l++) {
            for (i=0;i<n;i++) {
                for (j=0;j<10;j++) {
                    dp[l][i][j] = INF;
                }
            }
        }

        for (i=0;i<n;i++) {
            scanf("%d", &k);
            for (j=0;j<k;j++) {
                int x, d;
                scanf("%d %d", &x, &d);
                points[i].push_back(make_pair(x, d));
            }
        }

        for (j=0;j<10;j++) {
            dp[0][0][j] = 0;
            dp[1][1][j] = 0;
        }

        for (l=0;l<m+1;l++) {
            for (i=1;i<n;i++) {
                int pos1 = 0;
                vector<pair<int, int> >::iterator it1 = points[i].begin();

                for (;it1 != points[i].end();it1++, pos1++) {
                    if (l > 0 && i > 1) {
                         int pos2 = 0;
                         vector<pair<int, int> >::iterator it2 = points[i-2].begin();

                         for (;it2 != points[i-2].end();it2++, pos2++) {
                             int danger;

                             if (dp[l-1][i-2][pos2] == INF) continue;
                             danger = dp[l-1][i-2][pos2] + (it1->second + it2->second) * abs(it1->first - it2->first);
                             min_aplly(dp[l][i][pos1], danger);
                         }
                    }

                    int pos2 = 0;
                    vector<pair<int, int> >::iterator it2 = points[i-1].begin();

                    for (;it2 != points[i-1].end();it2++, pos2++) {
                        int danger;

                        if (dp[l][i-1][pos2] == INF) continue;
                        danger = dp[l][i-1][pos2] + (it1->second + it2->second) * abs(it1->first - it2->first);
                        min_aplly(dp[l][i][pos1], danger);
                    }
                }
            }
        }

        for (l=0;l<m+1;l++) {
            for (j=0;j<10;j++) {
                if (l < m) {
                    min_aplly(min, dp[l][n-2][j]);
                }

                min_aplly(min, dp[l][n-1][j]);
            }
        }

        printf("%d\n", min);
    }
}

Measured memory_bytes: 1496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 10005;
array<ll, MAX_SIZE> fac, inv, finv;
void fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[0] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % MOD;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }

const ll AB = 2000;
ll dp[AB*2 + 5][AB*2 + 5];
int main() {
    init();
    fac_init();
    ll N;
    cin >> N;
    vl A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    rep(i, N) dp[AB - A[i]][AB - B[i]] += 1;

    rep(a,AB*2+1)rep(b,AB*2+1){
        dp[a][b] %= MOD;
        ll v = dp[a][b];
        dp[a + 1][b] += v;
        dp[a][b + 1] += v;
    }

    ll ans = 0;
    rep(i,N){
        ll a = A[i], b = B[i];
        ans += dp[AB + a][AB + b];
        ans -= comb(2 * (a + b), 2 * a);
        ans = (ans % MOD + MOD) % MOD;
    }

    ans *= inv[2];
    ans %= MOD;

    cout << ans << endl;

}

Measured memory_bytes: 128896
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
struct Puddle{
	int idx;
	double area;
};
double area(int s_ptr,int e_ptr,std::vector<int> &height){
	int dh=0;
	double area=0;
	for(int i=s_ptr;i<e_ptr;i++){
		if(height[i]>height[i+1]){
			area+=0.5+dh;
			dh+=1;
		}else if(height[i]<height[i+1]){
			dh-=1;
			area+=0.5+dh;
		}else{
			area+=dh;
		}
	}
	return area;
}

std::vector<Puddle> range_puddle(int s_ptr,int e_ptr,int &max,std::vector<int> &height){
	std::vector<int> ptrs;
	std::vector<Puddle> sp,qp,p;
	for(int i=s_ptr;i<=e_ptr;i++){
		if(height[i]>=max) ptrs.push_back(i);
	}
	
	int n=ptrs.size();
	if(n>1){
		Puddle pud;
		for(int i=0;i<n-1;i++){
			pud.area=area(ptrs[i],ptrs[i+1],height);
			if(pud.area!=0){
				pud.idx=ptrs[i];
				p.push_back(pud);
			}
		}
	}
	int h_max=--max;
	if(ptrs[0]!=s_ptr) sp=range_puddle(s_ptr,ptrs[0]-1,max,height);
	if(ptrs[n-1]!=e_ptr) qp=range_puddle(ptrs[n-1]+1,e_ptr,h_max,height);
	std::vector<Puddle> puddle;
	int sl=sp.size(),ql=qp.size(),l=p.size();
	for(int i=0;i<sl;i++){
		puddle.push_back(sp[i]);
	}
	for(int i=0;i<l;i++){
		puddle.push_back(p[i]);
	}
	for(int i=0;i<ql;i++){
		puddle.push_back(qp[i]);
	}
	return puddle;
}

int main(){
	std::string str;
	std::cin>>str;
	int len=str.size();
	std::vector<int> height;
	height.push_back(0);
	int hi=0,max=0;
	for(int i=0;i<len;i++){
		char ch=str[i];
		if(ch=='/'){
			hi++;
			if(max<hi) max=hi;
		}else if(str[i]=='\\'){
			hi--;
		}
		height.push_back(hi);
	}
	std::vector<Puddle> p;
	p=range_puddle(0,len,max,height);
	double A=0;
	int k=0,n=p.size();
	for(int i=0;i<n;i++){
		A+=p[i].area;
		k++;
	}
	std::cout<<(int)A<<'\n'<<k;
	for(int i=0;i<n;i++){
		std::cout<<' '<<(int)p[i].area;
	}
	std::cout<<'\n';
	return 0;
}


Measured memory_bytes: 8360
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n, p / 2);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	vector<map<char, ll>> dic(N);
	rep(i, 0, N) {
		string S;
		std::cin >> S;
		rep(j, 0, S.size()) {
			dic[i][S[j]]++;
		}
	}

	string ans = "";
	for (auto x : dic[0]) {

		for (auto y : dic) {
			x.second = min(x.second, y[x.first]);
		}
		ans += string(x.second, x.first);
	}
	std::cout << ans << endl;
	return 0;
}


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

int dp[50];

int fib(int n){
    if(n == 0 || n == 1) return dp[n] = 1;
    if(dp[n] != -1) return dp[n];
    return dp[n] = fib(n-1) + fib(n-2);
}

int main(){
    int n;
    for(int i = 0; i < 50; i++) dp[i] = -1;
    cin >> n;
    cout << fib(n) << endl;
}



Measured memory_bytes: 3108
H, W = map(int, input().split())

S = [list(input()) for _ in range(H)]

Board = [['.' for _ in range(W+2)] for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        Board[i+1][j+1] = '#' if S[i][j] == '#' else '.'

ans = "Yes"
for i in range(1, H+1):
    for j in range(1, W+1):
        if Board[i][j] == '.':
            continue
        is_paintable = False
        for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if Board[i+di][j+dj] == '#':
                is_paintable = True
                break
        if not is_paintable:
            ans = 'No'
            break

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;

 
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++)
    cin>>b[i];
    int count=0,sum=0;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<m;j++){
            int x;
            cin>>x;
            sum+=(x*b[j]);
        }
        if((sum+c)>0)
        count++;
    }
    cout<<count;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main(void){
    std::string str;
    int N;
    std::cin >> N;
    std::cin.ignore();
    for(int i = 0; i < N; ++i){
        getline(std::cin, str);
        int pos;
        while((pos = str.find("Hoshino")) != -1){
            str.replace(pos, 7, "Hoshina");
        }
        std::cout << str << std::endl;
    }
}

Measured memory_bytes: 3140
//agc004_b.cpp
//Sat Jul 27 19:05:51 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,x;
	cin >> n >> x;

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}

	ll ans = LLINF;
	ll b[n];
	fill(b,b+n,LLINF);
	for (int i=0;i<n;i++){
		ll temp = 0;
		for (int j=0;j<n;j++){
			int index;
			if (j-i>=0){
				index = j-i;
			}else{
				index = n-i+j;
			}
			b[j] = min(b[j],a[index]);
			temp += b[j];
		}
		ans = min(ans,temp+i*x);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;

int main(){

    int n,k;
    cin >> n >> k;

    ll ans = 0;

    if(k == 0){
        cout << (ll)n*(ll)n << endl;
        return 0;
    }

    for(int i=k+1; i<=n; i++){
        int temp = n/i;
        ans += temp * (i-k);

        if(temp*i + k <= n){
            ans += n- temp*i - k + 1;
        }
    }

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

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
inline double torad(int deg) { return deg/180.0*M_PI; }
int main() {
    int a, b, C;
    cin >> a >> b >> C;

    double S, L, h;
    h = b * sin(torad(C));
    S = a * h * 0.5;
    L = a + b + sqrt((a*a) + (b*b) - 2*a*b*cos(torad(C)));

    cout.precision(8);
    cout << fixed << S << "\n";
    cout << fixed << L << "\n";
    cout << fixed << h << "\n";

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const long double CHT_INF = 1e24;

class CHT{
	map<long double,long double> ab,ar,ra;
	
public:
	
	CHT(){
		ab[0.0] = CHT_INF;
		ar[0.0] = CHT_INF;
		ra[CHT_INF] = 0.0;
	}
	
	void add(long double a , long double b){
		auto it = ab.find(a);
		auto it_ar = ar.end();
		if(it == ab.end()){
			auto it_ar_next = ar.upper_bound(a);
			if(it_ar_next != ar.end() && it_ar_next->first * it_ar_next->second + ab[it_ar_next->first] <= a * it_ar_next->second + b) return;
			it = ab.insert({a,b}).first;
			it_ar = ar.insert({a,it_ar_next->second}).first;
		} else if(it->second > b){
			it->second = b;
			it_ar = ar.find(a);
			ra.erase(it_ar->second);
		} else {
			return;
		}
		long double c = it_ar->second;
		while(it != ab.begin()){
			auto it_prev = prev(it);
			auto it_ar_prev = prev(it_ar);
			c = (it_prev->second - b) / (a - it_prev->first);
			if(it_ar_prev->second > c) break;
			else {
				ab.erase(it_prev);
				ra.erase(it_ar_prev->second);
				ar.erase(it_ar_prev);
			}
		}
		it_ar->second = c;
		for(auto it_ar_next = next(it_ar) ; it_ar_next != ar.end() ; it_ar_next = next(it_ar)){
			auto it_next = next(it);
			auto it_ar_next_next = next(it_ar_next);
			c = (b - it_next->second) / (it_next->first - a);
			if(it_ar_next_next == ar.end() || it_ar_next_next->second < c){
				ra.erase(it_ar_next->second);
				ra.insert({c,it_next->first});
				it_ar_next->second = c;
				break;
			} else {
				ab.erase(it_next);
				ra.erase(it_ar_next->second);
				ar.erase(it_ar_next);
			}
		}
		ra.insert({it_ar->second,it_ar->first});
	}
	
	long double ans(long double x){
		auto it = ab.find(ra.upper_bound(x)->second);
		return it->first * x + it->second;
	}
} solve;

int main(){
	int N; LL C; cin >> N >> C;
	vector<LL> h(N);
	repp(i,0,N) cin >> h[i];
	solve.add(-2*h[N-1],(C+h[N-1]*h[N-1]));
	repm(i,N-2,0){
		solve.add(-2*h[i],(LL)(solve.ans(h[i]))+C+2*h[i]*h[i]);
	}
	cout << (LL)(solve.ans(h[0]))+h[0]*h[0] << endl;
	return 0;
}


Measured memory_bytes: 48640
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,m,d;
  cin>>n>>m>>d;
  if(d==0){
    cout<<setprecision(10)<<(m-1)*(double)1/n<<endl;
  }else {
    cout<<setprecision(10)<<(m-1)*(double)2*(n-d)/(n*n)<<endl;
  }
}

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

int main() {
  int k;
  cin >> k;
  int ev = 0, od = 0;
  for (int i = 1; i <= k; i++) {
    if (i & 1) {
      od++;
    }
    else {
      ev++;
    } 
  }
  cout << od * ev << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,k;
char f[305][305];
int ans[305][305];
int cnt[305];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	rep(i,n) scanf("%s",&f[i]);
	vector<int>vi;
	rep(i,n){
		rep(j,m) cnt[i] += f[i][j] == '#';
		if(cnt[i]) vi.pb(i);
	}
	vector<P>vec;
	int pre = -1;
	rep(i,vi.size()){
		if(i+1 <vi.size()){
			vec.pb(mp(pre+1,vi[i]));
			pre = vi[i];
		}
		else{
			vec.pb(mp(pre+1,n-1));
		}
	}
	int id = 1;
	rep(i,vec.size()){
		int a = vec[i].fi, b = vec[i].sc;
		vector<int>vi;
		rep(j,m){
			int C = 0;
			for(int c=a;c<=b;c++) C += f[c][j] == '#';
			if(C) vi.pb(j);
		}
		vector<P>vecc;
		int pre = -1;
		rep(i,vi.size()){
			if(i+1 < vi.size()){
				vecc.pb(mp(pre+1,vi[i]));
				pre = vi[i];
			}
			else{
				vecc.pb(mp(pre+1,m-1));
			}
		}
		rep(j,vecc.size()){
			int c = vecc[j].fi, d = vecc[j].sc;
			vector<int>vv;
			for(int i=a;i<=b;i++){
				int e = 0;
				for(int j=c;j<=d;j++){
					e += f[i][j] == '#';
				}
				if(e) vv.pb(i);
			}
			int pree = a-1;
			rep(k,vv.size()){
				if(k+1 < vv.size()){
					for(int i=pree+1;i<=vv[k];i++) for(int j=c;j<=d;j++) ans[i][j] = id;
					id++;
				}
				else{
					for(int i=pree+1;i<=b;i++) for(int j=c;j<=d;j++) ans[i][j] = id;
					id++;
				}
			}
		}
	}
	rep(i,n) {
		rep(j,m) printf("%d%c",ans[i][j],(j==m-1?'\n':' '));
	}
}

Measured memory_bytes: 1280
*abc, k = list(map(int, input().split()))
n = [0] * 3
ans = 0
for i, v in enumerate(abc):
    if k >= v:
        n[i] = v
        k -= v
    else:
        n[i] = k
        break

print(n[0] + n[1] * 0 + n[2] * -1)



Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <unordered_set>
using namespace std;

#define ll long long


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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int res = 0;
	for (int i = 1; i < n - 1; i++)
	{
		int cur = arr[i];
		vector<int> a;
		for (int j = i - 1; j <= i + 1; j++)
		{
			a.push_back(arr[j]);
		}
		sort(a.begin(), a.end());
		if (cur == a[1])
		{
			res++;
		}
	}

	cout << res << endl;
}

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

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<double> a(n);
    for (size_t i = 0; i < n; ++i)
        cin >> a[i];
    double v = 0.0;
    for (auto e : a)
        v += 1.0 / e;
    cout << 1.0 / v << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    ll count=n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a&1){count--;}
    }
    cout<<count<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>
#define max(a,b) (a)>(b)? (a):(b);

main(){
        int N,W;
        int v[1000],w[1000];
        int dp[2][1001]={{0,},};
        int i,j;
        int maxv,minw;
        int c=1;

        while(scanf("%d",&W)!=EOF){
                if(!W)break;
                for(i=0;i<=W;i++)dp[0][i]=0;
                scanf("%d",&N);

                for(i=0;i<N;i++)
                        scanf("%d,%d",&v[i],&w[i]);

                for(i=1;i<=N;i++){
                        for(j=0;j<=W;j++){
                                if(j-w[i-1]<0)
                                        dp[i%2][j]=dp[(i-1)%2][j];
                                else
                                        dp[i%2][j]=max(dp[(i-1)%2][j],dp[(i-1)%2][j
-w[i-1]]+v[i-1]);
                        }
                }
                maxv=-1;
                for(i=0;i<=W;i++){
                        if(maxv<dp[N%2][i]){
                                maxv=dp[N%2][i];
                                minw=i;
                        }
                }
                printf("Case %d:\n%d\n%d\n",c++,maxv,minw);
        }

        return 0;
}

Measured memory_bytes: 616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()

	fmt.Println(check(inputs[0], inputs[1], inputs[2]))
}

// example
func check(n, a, b int) int {
	if a%2 == b%2 {
		return (b - a) / 2
	}

	// check distance to edge from a or b
	if a-1 < n-b {
		if (b-a-1)/2+a > 0 {
			return (b-a-1)/2 + a
		}
		return b - 1
	}
	if (b-a-1)/2+n-b+1 > 0 {
		return (b-a-1)/2 + n - b + 1
	}
	return n - a

}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;
  rep(i, len(S)) {
    cout << 'x';
  }
  cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
 
const long long Inf = 2e18;
const long long mod = 998244353;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
map <string, int> M;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		M[s]++;
	}	
	cout << "AC x " << M["AC"] << '\n';
	cout << "WA x " << M["WA"] << '\n';
	cout << "TLE x " << M["TLE"] << '\n';
	cout << "RE x " << M["RE"] << '\n';
}

Measured memory_bytes: 3636
n = list(input())
dp = [n[0]]

for i in range(0, len(n)-1):
    tmp = []
    for j in dp:
        tmp.append(j + str(n[i+1]))
        tmp.append(j + '+' + n[i+1])
    else:
        dp = tmp

result = 0
for i in dp:
    result += sum([int(i) for i in i.split('+')])

print(result)
    
        


Measured memory_bytes: 67060
n = int(input())
M = {}
for _ in range(n):
    u, k, *line = map(int, input().split())
    tmp = []
    for i in range(k):
        v, w = line[2*i:2*i+2]
        tmp.append((v, w))
    M[u] = tmp

INF = 10**10
WHITE = 0
GREY = 1
BLACK = 2
d = [INF] * n
color = [WHITE] * n
p = [-1] * n


def dijkstra():
    d[0] = 0
    p[0] = -1

    while True:
        mincost = INF
        for i in range(0, n):
            if color[i] != BLACK and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == INF:
            break

        color[u] = BLACK

        for v, w in M[u]:
            if color[v] != BLACK:
                if d[u]+w < d[v]:
                    d[v] = d[u]+w
                    p[v] = u


dijkstra()
for i in range(n):
    print(i, d[i])



Measured memory_bytes: 6124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_IntegerProduct solver = new A_IntegerProduct();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_IntegerProduct {
        final int PRECISION = 9;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] a = new int[100][100];
            int maxP2 = 0;
            int maxP5 = 0;
            long ans = 0;
            for (int i = 0; i < n; i++) {
                long x = nextNumber(in);
                int p2 = 0;
                while (x % 2 == 0) {
                    x /= 2;
                    ++p2;
                }
                int p5 = 0;
                while (x % 5 == 0) {
                    x /= 5;
                    ++p5;
                }

                for (int u = 0; u <= maxP2; u++) {
                    for (int v = 0; v <= maxP5; v++) {
                        if (Math.min(u + p2, v + p5) >= 2 * PRECISION) {
                            ans += a[u][v];
                        }
                    }
                }
                ++a[p2][p5];
                maxP2 = Math.max(maxP2, p2);
                maxP5 = Math.max(maxP5, p5);
            }
            out.println(ans);
        }

        private long nextNumber(FastScanner in) {
            String s = in.next();
            int i = s.indexOf('.');
            if (i < 0) {
                s = s + ".";
                i = s.length() - 1;
            }
            while (i + PRECISION >= s.length()) {
                s = s + "0";
            }
            return Long.parseLong(s.replace(".", ""));
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 55800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll x,y,a,b,c,p[200001],q[200001],r[200001];
    cin>>x>>y>>a>>b>>c;
    priority_queue<P> Q;
    rep(i,a) cin>>p[i],Q.push(P(p[i],2));
    rep(i,b) cin>>q[i],Q.push(P(q[i],1));
    rep(i,c) cin>>r[i],Q.push(P(r[i],0));
    ll X[3][2]={0};
    rep(i,a+b+c){
        ll o=Q.top().first,s=Q.top().second;
        Q.pop();
        if(!s||(s==2&&X[s][0]<x)||(s==1&&X[s][0]<y)) X[s][0]++,X[s][1]+=o;
        if(X[0][0]+X[1][0]+X[2][0]==x+y) break;
    }
    cout<<X[0][1]+X[1][1]+X[2][1]<<"\n";
}

Measured memory_bytes: 14060
#include <stdio.h>

int main(){
	char a[10], b[10], c[10];
	int i, j;
	scanf("%s%s%s", a, b, c);
	for(i = 0; a[i]; i++);
	for(j = 0; b[j]; j++);
	if(a[i - 1] == b[0] && b[j - 1] == c[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


import itertools

def powerset(iterable, low=0, high=None):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    if high is None:
        high = len(s)+1
    return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(low, high))


def solve(h, w, k, a):
    ans = 0
    rows = [i for i in range(h)]
    cols = [j for j in range(w)]

    for rr in powerset(rows):
        for cc in powerset(cols):
            rrs = set(rr)
            ccs = set(cc)
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if i not in rrs and j not in ccs and a[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ans += 1

    return ans


def main():
    h, w, k = ria()
    a = []
    for _ in range(h):
        a.append(rs())
    wi(solve(h, w, k, a))


if __name__ == '__main__':
    main()


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

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

using namespace std;

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

    priority_queue<int> q;
    rep(i,n){
        int a;
        cin >> a;
        q.push(a);
    }

    rep(i, m){
        int discounted = (int)(q.top() / 2);
        q.pop();
        q.push(discounted);
    }
    long long  ans = 0;
    rep(i, n) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

int main(void)
{
	int i,n;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		if(i==n-1){
			printf("%d\n",a[n-1-i]);
		} else {
			printf("%d ",a[n-1-i]);
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define ll long long
typedef pair<int, int> ii;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;

int n, row, col;
ii t[N];
ll fact[N], facw[N], f[N];

ll pw(ll x, ll y)   {
    ll res = 1;
    while(y)    {
        if(y % 2) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}
ll ckn(ll k, ll n)  {
    if(k > n) return 0ll;
    return fact[n] * facw[n - k] % mod * facw[k] % mod;
}
void add(ll &x, ll y) { x = (x + y) % mod; }
void sub(ll &x, ll y) { x = (x - y + mod) % mod; }
signed main()
{
    //freopen("test.inp", "r", stdin);
    fact[0] = 1ll; FOR(i, 1, N - 1) fact[i] = fact[i - 1] * i % mod;
    FOR(i, 0, N - 1) facw[i] = pw(fact[i], mod - 2);
    scanf("%d%d%d", &row, &col, &n);
    FOR(i, 1, n) scanf("%d%d", &t[i].fi, &t[i].se);
    sort(t + 1, t + n + 1);
    ll sum = 0ll;
    for(int i = 1; i <= n; ++i) {
        f[i] = ckn(t[i].fi - 1, t[i].fi + t[i].se - 2);
        FOR(j, 1, i - 1) if(t[j].fi <= t[i].fi && t[j].se <= t[i].se)
            sub(f[i], f[j] * ckn(t[i].fi - t[j].fi, t[i].fi + t[i].se - t[j].fi - t[j].se) % mod);
        add(sum, f[i] * ckn(row - t[i].fi, row + col - t[i].fi - t[i].se) % mod);
        //cout << sum << '\n';
    }
    sum = (ckn(row - 1, row + col - 2) + mod - sum) % mod;
    printf("%lld", sum);
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

vi a;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z=1e18;
    cin>>n;
    in(a,n);
    sort(all(a));
    if(a[0]==0){
        cout<<0;
        return 0;
    }
    y = 1;
    for(int i=0;i<n;i++){
        if(y*a[i]<y){
            cout<<-1;
            return 0;
        }
        y=y*a[i];
    }
    if(y>z){
        cout<<-1;
        return 0;
    }
    cout<<y;
    

    return 0;
}

Measured memory_bytes: 4276