akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.functional;
import std.string;
import std.traits;

pure
X genericPower(alias mul, X, Y) (X x, Y y, X one = 1.to!X)
  if (isUnsigned!Y) {
  X a = one, b = x;
  while (y > 0) {
    if (y & 1) {
      a = binaryFun!mul (a, b);
    }
    b = binaryFun!mul (b, b);
    y >>>= 1;
  }
  return a;
}

struct IntM(int q = 1_000_000_007) {
  alias N = IntM!q;
  private:
  int v;
  invariant () { assert (v >= 0 && v < q); }
  pure nothrow @nogc
  void fromInt (int m) {
    v = m % q;
    if (v < 0) {
      v += q;
    }
  }
  public:
  pure nothrow @nogc
  this (int m) {
    fromInt (m);
  }
  pure nothrow @nogc
  N opAssign (int m) {
    fromInt (m);
    return this;
  }
  pure nothrow @nogc
  N opUnary (string op : "-")() const {
    return N (-v);
  }
  pure nothrow @nogc
  ref N opUnary (string op : "++")() {
    if (++v >= q) {
      v -= q;
    }
    return this;
  }
  pure nothrow @nogc
  ref N opUnary (string op : "--")() {
    if (--v < 0) {
      v += q;
    }
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "+")(in N rhs) {
    v = (v + rhs.v) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "-")(in N rhs) {
    v = (v - rhs.v + q) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "*")(in N rhs) {
    v = (v.to!(long) * rhs.v) % q;
    return this;
  }
  pure nothrow @nogc
  ref N opOpAssign (string op : "/")(in N rhs) {
    return this *= rhs.inversion ();
  }
  pure nothrow @nogc
  ref N opOpAssign (string op)(in int rhs) if (op == "+" || op == "-" || op == "*" || op == "/") {
    mixin ("return this " ~ op ~ "= N(rhs);");
  }
  pure nothrow @nogc
  N opBinary (string op)(in N rhs) const if (op == "+" || op == "-" || op == "*" || op == "/") {
    N t = this;
    mixin ("t " ~ op ~ "= rhs;");
    return t;
  }
  pure nothrow @nogc
  N opBinary (string op)(in int rhs) const if (op == "+" || op == "-" || op == "*" || op == "/") {
    mixin ("return this " ~ op ~ " N(rhs);");
  }
  pure nothrow @nogc
  N opBinaryRight (string op)(in int rhs) const if (op == "+" || op == "*") {
    mixin ("return this " ~ op ~ " N(rhs);");
  }
  pure nothrow @nogc
  N opBinary (string op : "^^")(in ulong rhs) const {
    return genericPower! ("a * b", N, ulong) (this, rhs);
  }
  pure nothrow @nogc
  int opCast(T : int)() const { return v; }
}


alias N = IntM!998244353;

int test () {
  int n;
  readf (" %d", &n);
  auto d = new int[n];
  foreach (i; 0 .. n) {
    readf (" %d", &d[i]);
  }
  if (d[0] != 0) {
    return 0;
  }
  auto c = new int[n];
  foreach (i; 0 .. n) {
    ++c[d[i]];
  }
  debug stderr.writeln (c);
  if (c[0] != 1) {
    return 0;
  }
  int m;
  foreach (i; 0 .. n) {
    if (c[i]) {
      m = i;
    }
  }
  if (c[0 .. m].any!"a == 0") {
    return 0;
  }
  N res = 1;
  foreach (i; 1 .. n) {
    if (c[i-1] > 0) {
      res *= N (c[i-1]) ^^ c[i];
    }
  }
  return res.to!int;
}

void main() {
  writeln (test ());
}



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

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

int main()
{
	vector<int> l(5);
	rep(i,5) cin >> l[i];

	int k;
	cin >> k;

	bool ans = true;
	rep(i,5)
	{
		rep(j,5)
		{
			if(abs(l[i] - l[j]) > k) ans = false;
		}
	}

	if(ans) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}


Measured memory_bytes: 256
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p=p[:X]
q=q[:Y]

z=p+q+r

z.sort(reverse=True)

tot=sum(z[:X+Y])

print(tot)




Measured memory_bytes: 23328
// ABC 153-B
// 2020.1.26 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int H, N;
	
	H = in(), N = in();
	while (N--) H -= in();
	puts(H <= 0? "Yes": "No");
	return 0;
}


Measured memory_bytes: 128
class UnionFind():
    def __init__(self,num):
        self.n = num         #class内変数nに、外部から入力した値numを代入
        self.parents = [-1 for i in range(self.n)]
          #parentsは要素の親(1こ上のやつ)番号0~n-1を格納、自分が最親なら-(要素数)を格納(初期値は-1)

    #xの最親は誰？
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x]) #再帰して1番上までいってる
                #調べながらparentsの値を更新してる！（経路圧縮）
            return self.parents[x]

    #結合せよ
    #xの親とyの親をくっつける
    def union(self,x,y):
        xx=self.find(x)  #xxはxの最親
        yy=self.find(y)  #yyはyの最親
        if xx==yy:
            return     #同じ屋根の下にあった場合は何もしない
        else:
            size_xx=abs(self.parents[xx]) #xが含まれる木のサイズ
            size_yy=abs(self.parents[yy]) #yが含まれる木のサイズ
            if size_xx>size_yy:
                xx,yy=yy,xx  #yyの方が大きい木、ってことにする

            self.parents[yy]+=self.parents[xx] #大きい木のサイズ更新
            self.parents[xx]=yy   #サイズが小さい木を大きい木に接ぐ

    #xの属する木の大きさ（まあunionでも使ったけど）
    def size(self,x):
        xx=self.find(x)
        return abs(self.parents[xx])

    #xとyはこの空の続く場所にいますか　いつものように笑顔でいてくれますか　今はただそれを願い続ける
    def same(self,x,y):
        return True if self.find(x)==self.find(y) else False

    #xと　同じ木にいる　メンバーは？
    def members(self,x):
        xx=self.find(x)
        return [i for i in range(self.n) if self.find(i)==xx]
             #ifの条件式に漏れたら無視

    #最親だけを並べあげる
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]
        #いやこれは天才すぎる、basisのenumerate.py参照

    #すべての最親について、メンバーを辞書で
    def all_group_members(self):
        return {r:self.members(r) for r in self.roots()}

    #グループ分けどうなりましたか、２重リストで
    def state_grouping(self):
        return list(self.all_group_members().values())

    #出力用
    def __str__(self):
        return "\n".join("{}: {}".format(r,self.members(r)) for r in self.roots())
        #"\n"はただの改行コード
        #str(辞書)を改行しながら表示する
        #print(インスタンス)で__str__に飛ぶ
        #出力過程で、membersで全要素にfindをしてる→逐一経路圧縮されてる！


n,m,k=map(int,input().split())


uf=UnionFind(n)


G=[]
B=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    G.append([a,b])
    uf.union(a,b)
for i in range(k):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    B.append([a,b])

ans=[uf.size(i)-1 for i in range(n)] #自分を除く
for a,b in G:
    ans[a]-=1 ; ans[b]-=1
for a,b in B:
    if uf.same(a,b):
        ans[a]-=1 ; ans[b]-=1

print(*ans)




Measured memory_bytes: 43376
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if (X < 100) {
            System.out.println(0);
            return;
        }

        int sumOfProduct = X / 100;
        int mod = X % 100;

        for (int i5 = 0; i5 <= sumOfProduct; i5++) {
            for (int i4 = 0; i4 <= sumOfProduct - i5; i4++) {
                for (int i3 = 0; i3 <= sumOfProduct - i5 - i4; i3++) {
                    for (int i2 = 0; i2 <= sumOfProduct - i5 - i4 - i3; i2++) {
                        for (int i1 = 0; i1 <= sumOfProduct - i5 - i4 - i3 - i2; i1++) {
                            if (i5 * 5 + i4 * 4 + i3 * 3 + i2 * 2 + i1 == mod) {
                                System.out.println(1);
                                return;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(0);

    }
}

Measured memory_bytes: 21972
#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(){
    int n;
    cin >> n;
    int f = 0;
    while(n != 0){
        if(n%10 == 7) f = 1;
        n /= 10;
    }
    if(f == 1){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define inf (1e9 + 7)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;

int n, num[105], num2[205], nn = 0, ji = 0, ou = 0, lk[205], ans = 0, num3[205];
bool vis[205];
vector<int> eg[205];

bool dfs(int u)
{
    int lim = eg[u].size();
    for(int i = 0;i < lim;i++)
    {
        int v = eg[u][i];
        if(!vis[v])
        {
            num3[++num3[0]] = v;
            vis[v] = 1;
            if(lk[v] == -1||dfs(lk[v]))
            {
                lk[v] = u;
                return true;
            }
        }
    }
    return false;
}

bool jg(int a)
{
    if(a <= 2)
        return false;
    for(int i = 2;i * i <= a;i++)
    {
        if(a % i == 0)
            return false;
    }
    return true;
}

int main()
{
    mem(lk, -1);
    mem(vis, 0);
    scanf("%d", &n);
    for(int i = 1;i <= n;i++)
        scanf("%d", &num[i]);
    sort(num + 1, num + 1 + n);
    num2[++nn] = num[1];
    for(int i = 2;i <= n;i++)
    {
        if(num[i] - 1 != num[i - 1])
        {
            num2[++nn] = num[i - 1] + 1;
            num2[++nn] = num[i];
        }
    }
    num2[++nn] = num[n] + 1;
    for(int i = 1;i <= nn;i++)
    {
        if(num2[i] % 2 == 0)
        {
            ou++;
            for(int j = i + 1;j <= nn;j++)
            {
                if(jg(num2[j] - num2[i]))
                    eg[j].push_back(i);
            }
        }
        else
        {
            ji++;
            for(int j = i + 1;j <= nn;j++)
            {
                if(jg(num2[j] - num2[i]))
                    eg[i].push_back(j);
            }
        }
    }
    int res = 0;
    for(int i = 1;i <= nn;i++)
    {
        if(num2[i] % 2 == 0)
            continue;
        num3[0] = 0;
        if(dfs(i))
            res++;
        for(int j = 1;j <= num3[0];j++)
            vis[num3[j]] = 0;
    }
    ans += res;
    ji -= res;
    ou -= res;
    ans += ji / 2 * 2;
    ji %= 2;
    ans += ou / 2 * 2;
    ou %= 2;
    if(ji||ou)
        ans += 3;
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n,m;
	cin >> n >> m;
	if(n+m == 3)cout << 3;
	else if(n+m == 4)cout << 2;
	else if(n+m == 5)cout << 1;

	

	
   
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc148.contest.atcoder.jp/tasks/abc148_b

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string N; cin >> N;
  cout << (count(range(N), '7') ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

const long long MOD = 1e9+7;

long long f(long long k){
    long long res = 1;
    for(long long i = 1; i <= k; i++){
        res *= (i % MOD);
        res %= MOD;
    }

    return res;
}

int main(){
    long long N, M;
    cin >> N >> M;

    if(N > M){
        swap(N, M);
    }

    long long ans = 0;
    if(N+1 < M){
        ans = 0;
    }else if(N+1 == M){
        ans = (f(N) * f(M)) % MOD;
    }else if(N == M){
        ans = (2 * f(N) * f(M)) % MOD;
    }
    
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q,p;
ll w, ans;
ll k;
ll x[500005], y[500005];
ll dp[1005][1005];
ll table[500005];
char s[500005];

void solve(){
    cin >> s;
    n = strlen(s);
    bool good = true;
    for(ll i=0;i<n;i++){
        if(i % 2 == 0 && s[i] == 'L')good = false;
        if(i % 2 == 1 && s[i] == 'R')good = false;
    }
    Yes(good);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        solve();
    }
    return 0;

}


















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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long H, W;
vector<long long> v;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W ;
	long long S, s, ans, w, h, a, b ,c;

	if((H % 3) == 0 || (W % 3) == 0){
		ans = 0;
		printf("%lld\n", ans);
		return 0;
	}
	
	w = W / 3;
	h = H / 2;
	for(int i = -2; i <= 2; i++){
		if(w+i<1 || w+i>=W) continue;
		for(long long j = -2; j <= 2; j++){
			if(h+j<1 || h+j>=H) continue;
			a = H * (w+i);
			b = (h+j)*(W-(w+i));
			c = (H-(h+j))*(W-(w+i));
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			v.push_back(S - s);
		}
	}
	
	h = H / 3;
	w = W / 2;
	for(int i = -2; i <= 2; i++){
		if(h+i<1 || h+i>=H) continue;
		for(long long j = -2; j <= 2; j++){
			if(w+j<1 || w+j>=W) continue;
			a = (h+i) * W;
			b = (H-(h+i))*(w+j);
			c = (H-(h+i))*(W-(w+j));
			S = max( a, max( b, c ) );
			s = min( a, min( b, c ) );
			v.push_back(S - s);
		}
	}

	h = H / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			a = (h + i) * W;
			b = (h + j) * W;
			c = (H - (h+i) - (h+j)) * W;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			v.push_back(S - s);
		}
	}

	w = W / 3;
	for(int i = -2; i <= 2; i++){
		for(int j= -2; j <= 2; j++){
			a = (w + i) * H;
			b = (w + j) * H;
			c = (W - (w+i) - (w+j)) * H;
			S = max(a, max(b, c));
			s = min(a, min(b, c));
			v.push_back(S - s);
		}
	}

	sort(v.begin(), v.end());
	ans = v[0];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
map<ll,ll> mp;
const ll mod=1000000007;
int main(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
if(k%2==0)cout<<a-b<<endl;
else cout<<b-a<<endl;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n-1,-1,-1):
    if not sum(b[i::i+1]) % 2 == a[i]:
        b[i]=1
print(sum(b))
print(*[i+1 for i in range(n) if b[i]==1])

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

int main(){
    int A,B,C,X,sum,P;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>X;
    P=0;

    for(int l=0;l<=A;l++){
        for(int m=0;m<=B;m++){
            for(int n=0;n<=C;n++){
                sum=l*500+m*100+n*50;
                if(X==sum){
                   P=P+1;
                }
            }
        }
    }

    cout<<P<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
const int num = 16, ud[] = { -1, 1, 0, 0 }, lr[] = { 0, 0, -1, 1 }, nd = 4;
int md[num][num];
struct puzzle {
	int sp, p[num], mdp, cost;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
struct state {
	puzzle pu;
	int es;
	bool operator < (const state &s) const {
		//return pu.mdp + pu.cost > s.pu.mdp + s.pu.cost;
		return es > s.es;
	}
};
int astar(puzzle pz) {
	priority_queue<state> pq;
	int sum = 0;
	for (int i = 0; i < num; i++) {
		if (pz.p[i] == num) continue;
		sum += md[i][pz.p[i] - 1];
	}
	pz.mdp = sum;
	pz.cost = 0;
	map<puzzle, bool> m;
	puzzle u, v;
	state initial;
	initial.pu = pz;
	initial.es = pz.mdp;
	pq.push(initial);
	while (!pq.empty()) {
		state st = pq.top(); pq.pop();
		u = st.pu;
		if (!u.mdp) return u.cost;
		m[u] = true;
		int sx = u.sp / nd;
		int sy = u.sp % nd;
		for (int r = 0; r < nd; r++) {
			int tx = sx + ud[r];
			int ty = sy + lr[r];
			if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
			v = u;
			//v.mdp = p.mdp - md[tx * nd + ty][tmp.p[tx * nd + ty] - 1] + md[sx*nd + sy][tmp.p[tx * nd + ty] - 1];
			v.mdp -= md[tx * nd + ty][v.p[tx * nd + ty] - 1];
			v.mdp += md[sx*nd + sy][v.p[tx * nd + ty] - 1];
			swap(v.p[sx * nd + sy], v.p[tx * nd + ty]);
			v.sp = tx * nd + ty;
			if (!m[v]) {
				v.cost++;
				state news;
				news.pu = v;
				news.es = v.cost + v.mdp;
				pq.push(news);
			}
		}
	}
	return -1;
}

int main() {
	puzzle in;
	for (int i = 0; i < num; i++)
		for (int j = 0; j < num; j++)
			md[i][j] = abs(i / nd - j / nd) + abs(i%nd - j%nd);
	for (int i = 0; i < num; i++) {
		cin >> in.p[i];
		if (!in.p[i]) { in.sp = i;  in.p[i] = num; }
	}
	cout << astar(in) << endl;
	return 0;
}

Measured memory_bytes: 252960
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.size()<6)
    cout<<"No";
  else{
    if(s[2]==s[3] && s[4]==s[5])
      cout<<"Yes";
    else
      cout<<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
 
LL N, X;
 
LL f(LL a, LL b){
    if (a <= 0 || b <= 0) return 0;
    if (a%b == 0) return ((a+b)/b-1)*2*b;
    LL c = (a+b)%b;
    return (a+b)/b*b*2 + (b-1)/c*c + f(c - (b%c), b%c);
}
 
int main(){
    scanf("%lld %lld", &N, &X);
    if (X > N-X) printf("%lld", X+f(X, N-X));
    else printf("%lld\n", N+X+f(N-2*X, X));
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <class T>struct STm{
    vector<vector<T>> st;
    STm(vector<T>& v){
        st.clear();
        st.emplace_back(v);
        int n=1,k=1;
        while((n<<1)<=v.size()) n<<=1,++k;
        st.resize(k);
        n=1;
        for(size_t i=1;i<k;++i){
            st[i].resize(v.size()-n);
            for(size_t j=0;j<v.size()-n;++j) st[i][j]=min(st[i-1][j],st[i-1][j+n]);
            n<<=1;
        }
    }
    T gt(uint_fast32_t s,uint_fast32_t t){
        size_t l=31-__builtin_clz(t-s);
        return min(st[l][s],st[l][t-(1<<l)]);
    }
};

template <class T>struct STM{
    vector<vector<T>> st;
    STM(vector<T>& v){
        st.clear();
        st.emplace_back(v);
        int n=1,k=1;
        while((n<<1)<=v.size()) n<<=1,++k;
        st.resize(k);
        n=1;
        for(size_t i=1;i<k;++i){
            st[i].resize(v.size()-n);
            for(size_t j=0;j<v.size()-n;++j) st[i][j]=max(st[i-1][j],st[i-1][j+n]);
            n<<=1;
        }
    }
    T gt(uint_fast32_t s,uint_fast32_t t){
        size_t l=31-__builtin_clz(t-s);
        return max(st[l][s],st[l][t-(1<<l)]);
    }
};

struct UF{
    vector<int > par,sz;

    UF(int n){
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i]=i;
            sz[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }

    bool unit(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return false;
        if(sz[x]>sz[y]){
            par[y]=x;
            sz[x]+=sz[y];
        }
        else{
            par[x]=y;
            sz[y]+=sz[x];
        }
        return true;
    }

    bool same(int x, int y){return find(x)==find(y);}
};

class BSortingASegment {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k;
        in>>n>>k;
        vector<int> p(n);
        for(auto&i:p) in>>i;
        STm<int> m(p);
        STM<int> M(p);
        int c=0,ans=n-k+2;
        UF uf(n-k+2);
        fr(i,n-1){
            if(p[i]<p[i+1]) ++c;
            else c=0;
            if(c>=k-1) ans-=uf.unit(i-k+2,n-k+1);
        }
        fr(i,n-k){
            if(p[i]<m.gt(i+1,i+k)&&M.gt(i+1,i+k)<p[i+k]) ans-=uf.unit(i,i+1);
        }
        if(uf.sz[uf.find(n-k+1)]==1) --ans;
        out<<ans<<endl;
    }
};

int main() {
    BSortingASegment solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 29824
#include <cstdio>
#include <cstring>

const int maxn = 100 + 3;
int n, m, arr[maxn];

int main() {
  //freopen("input.txt", "r", stdin);
  while (~scanf("%d%d", &n, &m)) {
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
      sum += arr[i];
    }
    double bd = double(sum) / (4.0 * double(m));
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      if (double(arr[i]) >= bd) ++cnt;
    (cnt >= m) ? puts("Yes") : puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
using namespace std;
 
using i64 = long long int;
template <typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template <typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl;
  err(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& os, const pair<T1, T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")";
}
template<typename T>
inline ostream &operator << (ostream & os,const vector<T>& v) {
  bool first = true;
  os << "[";
  for (const auto &e: v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "]";
}
template<typename T>
inline ostream &operator << (ostream & os, multiset<T>& v) {
  bool first = true;
  os << "{";
  for (auto ii = v.begin(); ii != v.end(); ++ii) {
    if(!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template<typename T>
inline ostream &operator << (ostream & os,const unordered_set<T>& v) {
  bool first = true;
  os << "{";
  for (const auto &x : v) {
    if(!first) os << ", ";
    os << x;
    first = false;
  }
  return os << "}";
}
template<typename T1, typename T2>
inline ostream &operator << (ostream & os,const map<T1, T2>& v) {
  bool first = true;
  os << "{";
  for (const auto &e : v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "}";
}
template<typename T>
ostream &operator << (ostream & os,const vector<vector<T>>& v) {
  for (auto &u: v) os << '\n' << u;
  return os;
}
template<typename T>
void finish(T ans) {cout << ans << '\n'; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << '\n';
  
  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if((a+b)%2!=0){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << abs((a+b)/2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int mp[8] = {0};
    int n; cin >> n;
    int cc = 0;
    rep(i, n) {
        int a; cin >> a;
        if (a <= 3199) mp[a / 400]++;
        else cc++;
    }
    int c = 0;
    rep(i, 7 + 1) {
        if (mp[i]) c++;
    }
    cout << (c == 0 ? 1 : c) << " " << c + cc << endl;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m=0,k,ans=0,fl=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(a[i]==a[j] || a[j]==a[k])
					continue;
				else if(a[i]+a[j]>a[k])
				{
				// cout<<i<<" "<<j<<" "<<k<<endl;

					m++;
				}
			}
		}
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3652
s = input()
ans = []

for i in range(len(s)):
  if len(ans) == 0 and s[i] == 'C':
    ans.append(s[i])
  elif len(ans) == 1 and s[i] == 'F':
    ans.append(s[i])

if len(ans) == 2 and ans[0] == 'C' and ans[1] == 'F':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(X);
    ll A = 100;
    ll cnt = 0LL;
    while( A < X){
        A += A/100;
        cnt++;
    }
    cout << cnt << endl; 
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> ball(n,0);
    int count=0;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        ball[tmp-1]++;
    }
    sort(ball.begin(),ball.end());
    for(int i=0;i<n-k;i++){
        count+=ball[i];
    }
    cout<<count<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int rally(int n,int a[])
{
  int sum=0,av,sum1=0;
  float avg;
  for(int i=0;i<n;i++)
    sum+=a[i];
  avg=(float)sum/n;
  av=round(avg);
  for(int i=0;i<n;i++)
  {
    sum1+=(a[i]-av)*(a[i]-av);
  }
  return sum1;
}
int main()
{
  int n,a[100],res;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  res=rally(n,a);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
const ll MOD = 1000000007;
ll T[200005]={0};
ll oya[200005]={0};
ll used[200005]={0};
vector<ll> V[200005];
ll T2[200005]={0};
ll oya2[200005]={0};
ll used2[200005]={0};
void ki(int x){
  for(int j=0;j<V[x].size();j++){
    int now=V[x][j];
    if(used[now]==0){
      oya[now]=x;
      T[now]=T[x]+1;
      used[now]++;
      ki(now);
    }
  }
}
void ki2(int x){
  for(int j=0;j<V[x].size();j++){
    int now=V[x][j];
    if(used2[now]==0){
      oya2[now]=x;
      T2[now]=T2[x]+1;
      used2[now]++;
      ki2(now);
    }
  }
}
int main(){
  int n;
  cin>>n;
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  used[1]=1;
  ki(1);
  used2[n]=1;
  ki2(n);
  ll B=0;ll W=0;
  for(int i=1;i<=n;i++){
    if(T[i]<=T2[i])B++;
    else W++;
  }
  if(B>W)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 20352
#include <iostream>
#include <vector>

struct DisjointSet {
  std::vector<size_t> parent, rank;

  DisjointSet(const size_t N) : parent(N), rank(N, 0) {
    for (size_t i = 0; i < N; i++) parent[i] = i;
  }

  size_t find(const size_t x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(size_t x, size_t y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(const size_t x, const size_t y) { return find(x) == find(y); }
};

void yosupo_aoj() {
  // https://judge.yosupo.jp/problem/unionfind
  // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=ja
  int N, Q;
  std::cin >> N >> Q;
  DisjointSet uft(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    std::cin >> t >> u >> v;
    if (t == 0) {
      uft.unite(u, v);
    } else {
      std::cout << uft.same(u, v) << std::endl;
    }
  }
}

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

  yosupo_aoj();
  return 0;
}



Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x; cin>>x;
  vector<int>ans;
  for(int i=2;i<=x;i++){
    for(int j=2;pow(i,j)<=x;j++){
      if(pow(i,j)<=x) ans.push_back(pow(i,j));
    }
  }
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  if(x<4) cout<<1<<endl;
  else cout<<ans[0]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m=1e9+7)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
ll get(ll x, ll y)
{
	return x*y;
}
void fff()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = LLONG_MIN;
	ans = max(ans, get(a, c));	
	ans = max(ans, get(a, d));	
	ans = max(ans, get(b, c));	
	ans = max(ans, get(b, d));
	cout << ans << ln;	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3644
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))



using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);



vector<pint> query;


ll N;
vector<ll> a, b;
ll sum[3 * 100005], ans[3*100005], ans2[3*100005], sumb[100005];
int main() {
	cin >> N;
	ll x;
	rep(i, 3 * N) {
		cin >> x;
		a.push_back(x);
		if (i != 0)
			sum[i] = sum[i - 1] + a[i];
		else
			sum[i] = a[0];

	}

	rep(i, 2 * N) {
		b.push_back(a[i + N]);
		
	}

	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	


	priority_queue<ll, vector<ll>, greater<ll>> pq;
	priority_queue<ll> pq2;
	rep(j, N) {

		pq.push(a[j]);
	}

	for (int i = 3 * N - 1; i > 2 * N - 1; i--) {
		pq2.push(a[i]);
	}

	

	ans[N - 1] = sum[N - 1];
	for (int j = N; j <= 2 * N - 1; j++) {
		pq.push(a[j]);
		ans[j] = (ans[j - 1] + a[j] - pq.top());
		pq.pop();
	}

	ans2[2 * N] = sum[3 * N - 1] - sum[2 * N - 1];

	for (int j = 2 * N - 1; j >= N; j--) {
		pq2.push(a[j]);
		ans2[j] = (ans2[j + 1] - pq2.top() + a[j]);
		pq2.pop();
	}

	ll m = -inf;
	for (int j = N - 1; j <= 2 * N - 1; j++) {

		m = MAX(m, ans[j] - ans2[j+1]);
	}
	
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 15212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  
  // 初期値
  int a, b;
  double fa, fb;
  cin >> a >> b;
  fa = a;
  fb = b;
 
  // メインループ
  cout << a / b << " ";
  cout << a % b << " ";
  printf("%.5f", fa / fb);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3236
# For taking integer inputs.
import math
import sys


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def valid(x, y):
    if x >= 0 and x < row and y >= 0 and y < col:
        return True
    return False


fx = [0, 0, 1, -1]
fy = [1, -1, 0, 0]
row, col = invr()

a = []

for _ in range(row):
    a.append(instr())

for i in range(row):
    for j in range(col):

        if a[i][j] == "#":
            can_paint = 0
            for k in range(4):
                nx = i + fx[k]
                ny = j + fy[k]
                if valid(nx, ny) and a[nx][ny] == "#":
                    can_paint = 1
                    break
            if can_paint == 0:
                print("No")
                sys.exit()
print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	string S; cin >> S;
	deque<char> de;
	rep(i,S.size()) de.emplace_back(S[i]);
	int Q; cin >> Q;
	int cnt = 0;
	rep(i,Q) {
		int q; cin >> q;
		if(q == 1) cnt++;
		else{
			int f; cin >> f;
			f += cnt;
			if(f%2 == 1) {
				char c; cin >> c;
				de.push_front(c);
			}
			else {
				char c; cin >> c;
				de.emplace_back(c);
			}
		}
		
	}
	if(cnt%2 != 0) {
		reverse(all(de));
		cnt = 0;
	}
	string ans = "";
	rep(i,de.size()) ans += de[i];
	cout << ans << endl;
}

Measured memory_bytes: 1368
#include<stdio.h>

int main(){
	
	int N,Y,i,j;
	scanf("%d",&N);
	scanf("%d",&Y);
	
	for(i=0;i<=N;i++){
		for(j=0;j<=N-i;j++){
		if(10000*i+5000*j+1000*(N-i-j)==Y){
			printf("\n\n%d %d %d\n\n",i,j,N-i-j);
			return 0;
		}
		}
	}
	
	printf("\n\n-1 -1 -1\n\n");
	
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
mi=0
ans=0
zero=0
a=abs(A[0])
for i in A:
    if i<0:
        mi+=1
    a=min(a,abs(i))
    ans+=abs(i)
if mi%2==0:
    print(ans)
else:
    print(ans-2*a)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int a, b, v, w, t;
signed main()
{
    cin >> a >> v >> b >> w >> t;
    if(abs(b-a)<=t*(v-w))
    {
        cout << "YES";
    } else{
        cout << "NO";
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
const int N=100100;
char s[N];
int n,siz[N],fa[N],node,lst,mn,rt;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0') {puts("-1");return 0;}
	for(int i=1;i<=(n-1)/2;i++)
		if(s[i]!=s[n-i]) {puts("-1");return 0;}
	for(int i=1;i<=n-1;i++)
		if(s[i]=='1')
		{
			++node;
			if(lst) fa[lst]=node;
			if(!mn&&i!=1) mn=i;
			int u=i-siz[lst]-1,p=node;
			siz[node]=i;
			lst=node;
			for(int j=1;j<=u;j++)
				fa[++node]=p;
		}
	for(int i=1;i<=n;i++)
		if(!fa[i]&&!rt) rt=i;
		else if(!fa[i]) fa[i]=rt;
	for(int i=1;i<=n;i++)
		if(fa[i]) printf("%d %d\n",i,fa[i]);
	return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n,m;
    cin2(n,m);
    lli max_g = m/n;
    REPE_R(i,max_g, 1) {
        if (m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"


template <typename T, typename K> struct P {
	T a; K b;
};

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
vector <P <ll, ll> >prime_factorize( ll N );
ll pow( ll a, ll n );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
int main( void ){
	// initialize();
	int N, M;
	cin >> N >> M;
	vector <int> vec( N );
	int sum = 0;
	int maximum = 0;
	rep( i, 0, N ){
		cin >> vec[i];
		sum+= vec[i];
	}
	sort_desc(vec);
	rep(i,0,M){
		if (vec[i]*4*M < sum){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

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

/*
 * @fn eratosthenes
 * @brief O(NloglogN)~=(N)
 * @param N: その数まで
 * @return 0 or 1 の配列 (boolは都合が悪い)
 */
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

/*
 * @fn prime_factorize
 * @brief O(√N): 素因数分解
 * @param N: 素因数分解する数
 * @return vec: (a: 素数, b: 個数)
 */
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
/*
 * @fn pow
 * @brief a^n
 * @param a: 基数
 * @param n: 指数
 */
ll pow( ll a, ll n ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

int main(){
    int n;
    cin >> n;
    int count = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(a==b)count++;
        else count = 0;
        if(count==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596