akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

int main(){
  int *a;
  int i,j,n,v,l;

  scanf("%d",&n);

  a=(int *)malloc(n*sizeof(int));

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

  for(i=1;i<n;i++){
    v=a[i];
    j=i-1;

    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }

    a[j+1]=v;

    for(l=0;l<n;l++){
      if(l!=n-1)
	printf("%d ",a[l]);
      
      else if(l==n-1)
	printf("%d",a[l]);
      
    }

    printf("\n");
  }

  free(a);

  return 0;
}



Measured memory_bytes: 2140
N,M = map(int,input().split(" "))
inedge = [0] * N
edge = [ [] for _ in range(N) ]
for i in range(M):
    x,y = map(int,input().split(" "))
    inedge[y-1] += 1
    edge[x-1].append(y-1)

stack = []
for i in range(N):
    if inedge[i] == 0:
        stack.append((i,0))

ans = [0] * N
while len(stack) != 0:
    nextVer,passLen = stack.pop()
    for e in edge[nextVer]:
        inedge[e] -= 1
        ans[e] = max(ans[e],passLen+1)
        if inedge[e] == 0:
            stack.append((e,ans[e]))

print(max(ans))

Measured memory_bytes: 59680
A = int(input())
B = int(input())
if A == 1 and B == 2:
    print(3)
elif A == 1 and B == 3:
    print(2)
elif A == 2 and B == 1:
    print(3)
elif A == 2 and B == 3:
    print(1)
elif A == 3 and B == 1:
    print(2)
elif A == 3 and B == 2:
    print(1)

Measured memory_bytes: 3060
//#include "gap.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int32_t main(){
    int n, m;
    cin >> n >> m;
    int st = pow(2, m);
    cout << st * (1800*m + 100*n) << endl;
    return 0;
}


Measured memory_bytes: 512
import copy
def getPrimes(n):
    res = {}
    for i in range(2, n+1):
        if n % i == 0:
            res[i] = 0
            while n % i == 0:
                res[i] = res[i] + 1
                n = n // i
        if i * i > n:
            break;
        
    if n != 1:
        res[n] = 1
    return res

def add(a, b):
    res = copy.deepcopy(a)
    for i in b:
        if i in res:
            res[i] = res[i] + b[i]
        else:
            res[i] = b[i]
    return res

N = int(input())
cnt = {}
for i in range(1, N+1):
    cnt = add(cnt, getPrimes(i))

num = []
for i in cnt:
    num.append(cnt[i])
num.sort()
ans  = 0
for i in range(len(num)):
    for j in range(len(num)):
        for k in range(j + 1, len(num)):
            if i == j or i == k:
                continue
            if num[i] >= 2 and num[j] >= 4 and num[k] >= 4:
                ans = ans + 1
                
for i in range(len(num)):
    for j in range(len(num)):
        if i != j and num[i] >= 2 and num[j] >= 24:
            ans = ans + 1
            
for i in range(len(num)):
    for j in range(len(num)):
        if i != j and num[i] >= 4 and num[j] >= 14:
            ans = ans + 1
            
for i in range(len(num)):
    if num[i] >= 74:

        
        ans = ans + 1
print(ans)




Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{
    int N, M, C, A, count=0, sum=0;
    int B[30];
    cin >> N >> M >> C;
    for(int i=0;i<M;i++){
        cin >> B[i];
    }

    for(int i=0;i<N;i++){
        sum = C;
        for(int j=0;j<M;j++){
            cin >> A;
            sum += A * B[j];
        }
        if(sum > 0) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    // http://abc042.contest.atcoder.jp/tasks/abc042_a
    public class Abc042_a
    {
#if !Development
		public static void Main(string[] args)
		{
			Abc042_a.Solve(args);
		}
#endif

        public static void Solve(string[] args)
        {
            var line1 = ReadLineInt();
            var word5Count = line1.Where(num => num == 5).Count();
            var word7Count = line1.Where(num => num == 7).Count();
            var result = string.Empty;

            if (word5Count != 2 || word7Count != 1)
                result = "NO";
            else
                result = "YES";

            Console.WriteLine(result);
        }

        public static List<string> ReadLineString() { return Console.ReadLine().Split(' ').ToList(); }
        public static List<int> ReadLineInt() { return Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToList(); }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

string s1,s2;

void input(void){
   cin>>s1>>s2;
}

void solve(void){
    ll a=0;
    rep(i,3){
    	if(s1[i]==s2[i])a++;
    }
    cout<<a<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int s = 0;
  for (int i = a; i <= b; ++i) {
    if (c <= i && i <= d) ++s;
  }

  cout << (s ? s-1 : 0) << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double ans = 0.0;
    double a;

    for(int i=0;i<n;i++) {
      a=sc.nextDouble();
      ans = ans+ 1/a;
    }
    ans = 1/ans;
    System.out.println(ans);
    
}
}


Measured memory_bytes: 23252
n,k=map(int,input().split())
A=list(map(int,input().split()))
ans=10**11
for i in range(2**(n-1)):
  s=format(i,"16b")
  a=0
  for j in range(16):
    if s[j]=="1":
      a=a+1
  if a>=k-1:
    cost=0
    B=[A[0]]
    for j in range(n-1):
      if s[-1-j]!="1":
        B.append(A[j+1])
      else:
        if A[j+1]>max(B):
          B.append(A[j+1])
          continue
        else:
          B.append(max(B)+1)
          cost=cost+max(B)-A[j+1]
    if cost<ans:
      ans=cost
print(ans)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int main(void) {
	string s;
	cin >> s;
	const int n = s.size();

	int ans = n;
	rep(i, n - 1) if (s[i] != s[i + 1]) chmin(ans,max(i + 1, n - i - 1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stack>
using namespace std;
int main()
{
	string S;
	cin >> S;
	stack<char> st;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'T' && !st.empty() && st.top() == 'S')
			st.pop();
		else
			st.push(S[i]);
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,A,B;
    cin >> N >> A >> B;
    if((B-A)&1) pr("Borys");
    else pr("Alice");
    return 0;
    
    while(1){
        //Alice
        if(A == 1 && B == 2){
            pr("Borys");
            return 0;
        }
        if(A+1 < B){
            A++;
        }else{
            A--;
        }

        //Borys
        if(B == N && A == N-1){
            pr("Alice");
            return 0;
        }
        if(A < B-1){
            B--;
        }else{
            B++;
        } 

    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string n;
int main()
{
    int i,c=0;
    cin>>n;
    for(i=0;i<n.length();i++)
    {
        if(n[i]=='7')
        {
            cout<<"Yes\n";
            c=1;
            break;
        }
    }
    if(c==0)
    {
        cout<<"No\n";
    }

return 0;
}



Measured memory_bytes: 3632
def xor_matching(m, k)
  return -1 if 2 ** (m) <= k

  if m == 0
    return -1 if k != 0
    return [0, 0]
  end

  if m == 1
    return -1 if k != 0
    return [0, 0, 1, 1]
  end

  subsequence = Array.new(2 ** (m)) { |i| i }
  subsequence.delete_at(k)
  [subsequence, k, subsequence.reverse, k].flatten!
end

m, k = gets.split.map(&:to_i)
puts xor_matching(m, k)


Measured memory_bytes: 6012
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[3100];
long long dp[3100][3100];
long long sum[3100];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	dp[0][0]=1;
	for(int i=1;i<a;i++){
		for(int j=0;j<=i;j++){
			sum[j+1]=(sum[j]+dp[i-1][j])%mod;
		}
		for(int j=0;j<=i;j++){
			if(in[i-1]=='<'){
				dp[i][j]=sum[j];
			}else{
				dp[i][j]=(sum[i+1]-sum[j]+mod)%mod;
			}
		}
	}
	long long ret=0;
	for(int i=0;i<=a-1;i++){
		ret+=dp[a-1][i];
	}
	ret%=mod;
	printf("%lld\n",ret);
}

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

int main(){

	int H, W;
	cin >> H >> W;
	char map[H+2][W+2];

	for(int i=0; i<H+2; i++)
		for(int j=0; j<W+2; j++)
			if(i == 0 || i == H+1 || j == 0 || j == W+1)
				map[i][j] = '.';
			else
				cin >> map[i][j];
	
	for(int i=1; i<H+1; i++){
		for(int j=1; j<W+1; j++){
			if(map[i][j] == '#'){
				cout << '#';
				continue;
			}
			int cnt = 0;
			if(map[i-1][j-1] == '#') cnt++;
			if(map[i-1][j] == '#') cnt++;
			if(map[i-1][j+1] == '#') cnt++;
			if(map[i][j-1] == '#') cnt++;
			if(map[i][j] == '#') cnt++;
			if(map[i][j+1] == '#') cnt++;
			if(map[i+1][j-1] == '#') cnt++;
			if(map[i+1][j] == '#') cnt++;
			if(map[i+1][j+1] == '#') cnt++;
			cout << cnt;
		}
		cout << endl;
	}

	return 0;


}


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

using namespace std;

typedef long long ll;

int main() {
    int N;
    ll K;
    cin >> N >> K;

    vector<ll> A(N, 0);
    ll sum = 0;
    for(int i = 0 ; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    vector<ll> v;
    for(ll i = sqrt(sum); i >= 1 ; i--) {
        if(sum % i == 0) {
            v.push_back(i);
            v.push_back(sum/i);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(ll i = 0; i < v.size() ; i++) {
        vector<ll> diff;
        ll diff_sum = 0;
        vector<ll> diff_minus;        
        ll diff_minus_sum = 0;

        for(ll j = 0; j < N; j++) {
            if(A[j] % v[i] == 0) continue;
            diff.push_back(A[j]%v[i]);
            diff_sum += A[j]%v[i];
            diff_minus.push_back(v[i] - A[j]%v[i]);
            diff_minus_sum += v[i] - A[j]%v[i];
        }
        if(diff.size() == 0) cout << v[i] << endl;
        sort(diff.begin(), diff.end());
        sort(diff_minus.begin(), diff_minus.end(), greater<ll>());
        
        ll cum_sum = 0;
        ll cum_minus_sum = 0;
        for(int k = 0; k < diff.size(); k++) {
            cum_sum += diff[k];
            cum_minus_sum += diff_minus[k];
            if(cum_sum == (diff_minus_sum - cum_minus_sum)) {
                if(cum_sum <= K) {
                    cout << v[i] << endl;
                    return 0;
                }
            }

        }
    }




}

Measured memory_bytes: 256
N,K=map(int,input().split())

Kbit=[0]*30
K2=K
for i in range(30):
  if K2%2==1:
    Kbit[-1-i]=1
  K2//=2
#print(Kbit)

alist=[]
blist=[]
for _ in range(N):
  A,B=map(int,input().split())
  alist.append(A)
  blist.append(B)
  
answer=0
for i in range(N):
  if K|alist[i]==K:
    answer+=blist[i]
#print(answer)

for j in range(30):
  if Kbit[j]==1:
    K2bit=Kbit[:]
    K2bit[j]=0
    for k in range(j+1,30):
      K2bit[k]=1
    K2=0
    for k in range(30):
      K2<<=1
      K2+=K2bit[k]
    #print(K2bit,K2)
      
    neq_ans=0
    for i in range(N):
      if K2|alist[i]==K2:
        neq_ans+=blist[i]
    #print(neq_ans)
    answer=max(answer,neq_ans)
    
print(answer)

Measured memory_bytes: 85612
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;

#define LL long long
 int main()
{
    LL t,a[5];
    cin>>t;
    while(t--)
    {
        for(LL i=0;i<3;i++)
        cin>>a[i];
        sort(a,a+3);
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
   return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 

const ll MAX=1e5+1L;
const ll inf=1e18L;
int main()
{
    fastio;
    ll n,m,i,j;
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    //dp[i][j] = LCS in s[-1,i] and t[-1,j];
    //NOTE :  string is 0 based , dp is 1 based   
    vector<vector<ll>>dp(n+1,vector<ll>(m+1,0));
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            dp[i][j]=max({dp[i-1][j],dp[i][j-1],dp[i-1][j-1] + (s[i-1]==t[j-1]) });  
    
    // if have to print size of LCS
    // cout<<dp[n][m];
    i=n,j=m;
    //printing LCS
    string ans="";
    while(i!=0 && j!=0){
        if(i>0 && dp[i-1][j]==dp[i][j])    i--;
        else if(j>0 && dp[i][j-1]==dp[i][j]) j--;
        else ans = s[i-1] + ans , i--,j--;
    }
    cout<<ans;


    

    
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"B":"A");
}
int main() {
  int x,a,b;cin>>x>>a>>b;
  bool ans=abs(x-a)>abs(x-b);
  cout<<btos(ans)<<endl;
  return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                #DaRkSouL OP in the chat Guyzzz... :):):)

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a;
    cin>>a;
    int res = a+a*a+a*a*a;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>
#include <climits>

using namespace std;
using i64 = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const i64 INFL = (1LL<<62);
const i64 MOD = 1000000007;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> i64 mod_pow(i64 a, i64 n, T mod) { mod=(i64)mod; i64 res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

// template<class T> inline void chmax(T &x, const T &y) {if (x < y) x = y;}
// template<class T> inline void chmin(T &x, const T &y) {if (x > y) x = y;}

const int M = 1e9+7;

long long n, k;
long long ans;

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

  for (long long i = k; i <= n + 1; i++) {
    ans += -i * i + (n + 1) * i + 1;
    ans %= M;
  }

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

Measured memory_bytes: 3636
'use strict'

const main = input => {
	const n = parseInt(input.split('\n')[0], 10)
	let sum = 0
	for (let i = 1; i <= n; i++) {
		sum += i
	}
	console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
fun main() {
    val N = readLine()!!.toInt()
    val X = readLine()!!
    val nMax = 2 * 100000
    val table = IntArray(nMax + 1)
    for(i in 1..nMax){
        table[i] = table[i % popCount(i)] + 1
    }

    val bitCount = X.filter { c ->  c == '1' }.count()
    val plus = bitCount + 1
    val minus = bitCount - 1
    val twoRemPlus = LongArray(N).apply { this[0] = (1L % plus) }
    val twoRemMinus = LongArray(N).apply { if(1 <= minus) this[0] = (1L % minus) else this[0] = 0}
    for(i in 1 until N){
        twoRemPlus[i] = (twoRemPlus[i - 1] * 2) % plus
        twoRemMinus[i] = if(1 <= minus) (twoRemMinus[i - 1] * 2) % minus else 0
    }
    var remPlus = 0L
    var remMinus = 0L
    for(i in 0 until N){
        if(X[N - 1 - i] == '1'){
            remPlus = (remPlus + twoRemPlus[i]) % plus
            remMinus = if(1 <= minus) (remMinus + twoRemMinus[i]) % minus else 0
        }
    }

    val ans = LongArray(N)
    for(i in 0 until N){
        if(X[N - 1 - i] == '1'){
            ans[i] = (remMinus - twoRemMinus[i]).let {
                if(minus == 0){
                    -1
                }else{
                    (it % minus).let {
                        if(it < 0) it + minus else it
                    }
                }
            }
        }else{
            ans[i] = (remPlus + twoRemPlus[i]).let { it % plus }
        }
    }
    println(ans.map { if(it.toInt() == -1) 0 else (table[it.toInt()] + 1) }.reversed().joinToString(separator = "\n"))
}

fun popCount(n: Int): Int {
    var tmp = n
    var ans = 0
    while (tmp != 0){
        if(tmp % 2 == 1) ans++
        tmp /= 2
    }
    return ans
}

Measured memory_bytes: 60244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
const ll maxi = 1000001;
ll calscore(pair<ll,ll> pa1,pair<ll,ll> pa2){
  ll ret;
  if(pa1.first < pa2.first){
    ret = min(pa2.second-pa2.first,pa1.second-pa2.first);
  }else{
    ret = min(pa2.second-pa1.first,pa1.second-pa1.first);
  }
  return max(ret+1,0ll);
}
ll mscore(pair<ll,ll> p){
  return max(p.second - p.first + 1,0ll);
}
int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> vec(n);
  vector<ll> score(n);
  rep(i,n){
    cin >> tmp1 >> tmp2;
    vec[i] = make_pair(tmp1,tmp2);
  }
  sort(all(vec));
  rep(i,n){
    score[i] = vec[i].second - vec[i].first + 1;
  }
  pair<ll,ll> ran1,ran2;
  ran1 = make_pair(vec[0].first,vec[0].second);
  ran2 = make_pair(vec[1].first,vec[1].second);
  ll range1 = score[0];
  ll range2 = score[1];
  for(ll i=2;i<n;i++){
    tmp1 = calscore(ran1,ran2) + score[i];
    tmp2 = calscore(ran2,vec[i]) + range1;
    tmp3 = calscore(vec[i],ran1) + range2;
    //cout << tmp1 << " " << tmp2 << " " <<  tmp3 << endl;
    if(tmp1 >= tmp2 && tmp1 >= tmp3){
      ran1.first = max(ran1.first,ran2.first);
      ran1.second = min(ran1.second,ran2.second);
      ran2.first = vec[i].first;
      ran2.second = vec[i].second;
      range1 = mscore(ran1);
      range2 = score[i];
    }else if(tmp2 >= tmp1 && tmp2 >= tmp3){
      ran2.first = max(ran2.first,vec[i].first);
      ran2.second = min(ran2.second,vec[i].second);
      range2 = calscore(ran2,vec[i]);
    }else{
      ran1.first = max(ran1.first,vec[i].first);
      ran1.second = min(ran1.second,vec[i].second);
      range1 = calscore(ran1,vec[i]);
    }
  }
  //cout << ran1.first << " " << ran1.second << endl;
  //cout << ran2.first << " " << ran2.second << endl;
  //cout << range1 << " " << range2 << endl;
  cout << range1+range2 << endl;
}


Measured memory_bytes: 2560
while True :
    n,x = map(int,input().split())
    if n == 0 and x == 0 :
        break
    else :
        ans = 0
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if j < x-i-j <= n :
                    ans += 1
        print(ans)



Measured memory_bytes: 5596
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
void sol() {
    int a; cin >> a;
    cout << (a + a * a + a * a * a) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    int T(1);
    while (T--)
        sol();


    return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scanner.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++)
			b[i] = scanner.nextInt();

		int ans = 0;
		for (int i = 0; i < m - ans; i++) {
			int idx = i;
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if (n - j + cnt < ans)
					break;
				if (b[idx] == a[j]) {
					cnt++;
					idx++;
				}
			}
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    */
    int n,k,q;
    cin>>n>>k>>q;
    int a[q];
    for(int i=0;i<q;i++) {
        cin>>a[i];
    }

    int pref[n+1],ans[n+1];
    for(int i=0;i<=n;i++) pref[i]=0,ans[i]=0;
    pref[1]=k;
    for(int i=0;i<q;i++) {
        pref[1]-=1;
        //
    }
    for(int i=1;i<=n;i++) {
        ans[i]=ans[i-1]+pref[i];
    }
    for(int i=0;i<q;i++) {
        ans[a[i]]+=1;
    }
    for(int i=1;i<=n;i++) {
        if(ans[i]>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

long long mod = 1000000007;

int main()
{
    int N;
    long long a[200005];
    long long res = 0;;
    long long sum = 0;
    
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> a[i];
        sum += a[i]%(2*mod);
        res += ((a[i]%(2*mod))*(a[i]%(2*mod)))%(2*mod);
        sum = sum%(2*mod);
        res = res%(2*mod);
    }
    
    long long num = (sum*sum)%(2*mod);
    
    if (num >= res){
        cout << ((num - res)%(2*mod))/2 << endl;
    }
    else {
        cout << ((num - res + 2*mod)%(2*mod))/2 << endl;
    }
    
}


Measured memory_bytes: 5200
import bisect
N = int(input())

num_list = list(map(int,input().split()))
num_list.sort()
res = 0

for a in range(N-2):
    for b in range(a+1,N-1):
        k = bisect.bisect_left(num_list,num_list[a]+num_list[b])
        res += max(k-(b+1),0)
print(res)

Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  string As, Bs, Ts;
  cin >> As >> Bs >> A >> B >> Ts;
  if (Ts == As) {
    A--;
  } else {
    B--;
  }
  cout << A << ' ' << B << endl;
}

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

int main() {
    int a,b,c,d,n;
    cin>>a>>b>>c>>d;
    if(c%b==0) {
        n = c/b;
    } else {
        n = c/b + 1;
    }
    if(a-(n-1)*d<=0) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
package main

import "fmt"

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	fmt.Println(lcm(A, B))
}


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

int main() {
	unsigned int n;
	int h, m, s;
	cin >> n;
	h = n / 3600;
	m = (n - (h*3600)) / 60;
	s = n - (h*3600) - (m*60);
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3100
import itertools
n=int(input())
plot=[list(map(int,input().split())) for _ in range(n)]
lis=[]
for i in range(n):
    lis.append(i)

p=list(itertools.permutations(lis,n))
#print(plot)
#print(plot[p[0][0]])
cnt=0
for j in range(len(p)):
    dis=0
    for k in range(n-1):
        dis+=((plot[p[j][k+1]][1]-plot[p[j][k]][1])**2+(plot[p[j][k+1]][0]-plot[p[j][k]][0])**2)**.5
    cnt+=dis
    #print(dis)
print(cnt/len(p))

Measured memory_bytes: 8180
from sys import stdin
import math
    
def calc(r,g,b,n):
    ans = 0

    for ri in range(0, math.floor(n/r)+1):
        numR = ri * r
        if n - numR == 0:
            ans += 1
            continue

        for gi in range(0, math.floor((n-numR)/g)+1):
            numG = gi * g

            left = n - numR - numG
            
            if left == 0:
                ans += 1
            elif left % b == 0:
                ans += 1
    return ans

def main():
    r,b,g,n = [int(x) for x in stdin.readline().rstrip().split()]
    ans = calc(r,b,g,n)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
S = input()
T = input()
X = "UNRESTORABLE"
ans = ""
x = 0
res = []
for inds, s in enumerate(S):
    if (inds + len(T) > len(S)):
        break
    flag = 0
    for indt, t in enumerate(T):
        if S[inds + indt] == t or S[inds+indt] == "?":
            flag += 1
    if flag == len(T):
        res.append(ans+T + S[inds + len(T):len(S)])
    ans += s
if (len(res) > 0):
    ans = res[0].replace("?", "a")
    for i in res:
        ans = min(i.replace("?", "a"), ans)
    print(ans)
else:
    print(X)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define int long long
#define eps 0.0000000001
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
    if(c-a-b>=0) {
    	if(4*a*b<(c-a-b)*(c-a-b))
    	cout<<"Yes"<<endl;
        else{
        	cout<<"No"<<endl;
        }
    }
    else 
    	cout<<"No";
	return 0;
}


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

using namespace std;
#define INF 1e9+5
void solve(int n, int K){
    vector<int>h(n+1);
    for(int i=0;i<n;++i){
        cin>>h[i];
    }
    vector<int>dp(n, INF);
    dp[0]=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<=i+K;++j){
            if(j<n){
                dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}
int main()
{
    int n, k;
    cin>>n>>k;
    solve(n, k);
    return 0;
}


Measured memory_bytes: 4000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int a[200005]={0};
int n,k;
int solve(int fun){
    int num = 0 ;
    for(int i=0;i<n;i++){
        num += (a[i]-1)/fun;
    }
    if(num<=k)
        return 1;
    return 0;
}
int main()
{
    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >> a[i];
    int l=1,r=1000000007;
	int ans = 0 ;
    while(l<r){
        int m = (l+r)/2;
        if(solve(m)){
			r=m;
			ans = m;
		}
        else
            l=m+1;
        //cout << l << " " << r << endl;
    }
    	cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 4396
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
#define pb push_back

const int INF = 1000000000;

typedef pair<int,int> pii;

class Edge{
	public:
	int a,b,c,f;
	Edge(int a,int b,int c,int f):a(a),b(b),c(c),f(f){}
};

class Flow{
	public:
	static const int N = 1111;
	static const int INF = 1000000000;
	
	vector<Edge> e[N];
	vector<pii> r[N];
	
	void addEdge(int a,int b,int c){
		e[a].push_back(Edge(a,b,c,0));
		r[b].push_back(pii(a,e[a].size()-1));
	}
	int visit[N];
	int flow(int p, int f, int end){
		if(p==end)return f;
		if(visit[p]==1)return 0;
		visit[p]=1;
		
		rep(i,e[p].size()){
			int d = e[p][i].c - e[p][i].f;
			if(d > 0){
				int val = flow(e[p][i].b, min(f,d), end);
				if(val!=0){
					e[p][i].f += val;
					return val;
				}
			}
		}
		rep(i,r[p].size()){
			int r1 = r[p][i].first;
			int r2 = r[p][i].second;
			int d = e[r1][r2].f;
			if(d > 0){
				int val = flow(e[r1][r2].a, min(f,d), end);
				if(val!=0){
					e[r1][r2].f -= val;
					return val;
				}
			}
		}
		return 0;
	}
	int solve(int start, int end){
		int ans = 0;
		while(1){
			rep(i,N)visit[i]=0;
			int val = flow(start, INF, end);
			if(val==0)break;
			ans += val;
		}
		return ans;
	}
};

const int S = 4000;
int sosu[S];
vector<int> prime;
int sosuInit(){
	sosu[0]=sosu[1]=1;
	rep(i,S){
		if(sosu[i]==1)continue;
		for(int j=i*2;j<S;j+=i)sosu[j]=1;
		prime.push_back(i);
	}
}

map<int, vector<int> > canop;

int main(){
	sosuInit();
	
	A:;
	
	canop.clear();
	
	int n,m;
	cin>>n>>m;
	
	if(n==0 && m==0)return 0;
	
	Flow flow;
	
	rep(i,n){
		int a;
		cin>>a;
		rep(j,prime.size()){
			if(a%prime[j]==0){
				canop[prime[j]].push_back(i+1);
				a/=prime[j];
				j--;
			}
		}
		if(a!=1)canop[a].push_back(i+1);
		flow.addEdge(0,i+1,1);
	}
	
	rep(i,m){
		int b;
		cin>>b;
		rep(j,prime.size()){
			if(b%prime[j]==0){
				rep(k,canop[prime[j]].size()){
					flow.addEdge(canop[prime[j]][k], i+n+1, 1);
				}
				b/=prime[j];
				j--;
			}
		}
		if(b!=1){
			rep(k,canop[b].size()){
				flow.addEdge(canop[b][k], i+n+1, 1);
			}
		}
		flow.addEdge(i+n+1, n+m+1, 1);
	}
	
	int ans = flow.solve(0, n+m+1);
	printf("%d\n",ans);
	
	goto A;
}
/*

4 3
2 6 6 15
2 3 5
0 0

*/

Measured memory_bytes: 14848
#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
 
h, w, n = [int(item) for item in input().split()]
blk_cnt = defaultdict(int) 
 
for i in range(n):
    a, b = [int(item) - 1 for item in input().split()]
    for j in range(-1, 2):
        for k in range(-1, 2):
            blk_cnt[(a + j, b + k)] += 1
ans = [0] * 10 
for key in blk_cnt.keys():
    if key[0] < 1 or key[1] < 1 or key[0] >= h-1 or key[1] >= w-1:
        continue
    ans[blk_cnt[key]] += 1
total = (w - 2) * (h - 2)
ans[0] = total - sum(ans)
for item in ans:
    print(item)

Measured memory_bytes: 151932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll u=pow(2,n);
  ll a[u];
  for(ll i=0;i<u;i++)cin>>a[i];
  ll mm[u][2];
  for(ll i=0;i<u;i++){
    mm[i][0]=a[0];
    mm[i][1]=0;
  }
  ll ma=0;
  for(ll i=1;i<u;i++){
    if(a[i]>=mm[i][0]){
      mm[i][1]=mm[i][0];
      mm[i][0]=a[i];
    }
    else if(a[i]>=mm[i][1])mm[i][1]=a[i];
    ma=max(ma,mm[i][0]+mm[i][1]);
    cout<<ma<<endl;
    ll b=i;
    b=i|(b+1);
    while(b<u){
      if(a[i]>=mm[b][0]){
        mm[b][1]=mm[b][0];
        mm[b][0]=a[i];
      }
      else if(a[i]>=mm[b][1])mm[b][1]=a[i];
      b=i|(b+1);
    }
    //cout<<mm[5][0]<<" "<<mm[6][1]<<endl;
  }
  for(ll i=0;i<u;i++){
    //cout<<mm[i][0]<<" "<<mm[i][1]<<endl;
  }
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

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

void solve() {
  bool flag=true, bl=false;
  int h,w,sum=0,k=0;
  cin >> h >> w;

  vector<string> v(h);
  rep(i,0,h) cin >> v.at(i);

  rep(i,0,h)
  {
    rep(j,0,w)
    {
      if(v.at(i).at(j)=='#')
      {
        bl=false; k=0;
        while(k<4)
        {
          if(dy[k]+i>=0 && dy[k]+i<h && dx[k]+j>=0 && dx[k]+j<w && v.at(dy[k]+i).at(dx[k]+j)=='#') bl=true;
          ++k;
        }
        if(!bl) flag=false;
      }
      if(!flag) break;
    }
    if(!flag) break;
  }

  if(flag) print("Yes");
  else print("No");

  return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

class Segtree{
public:
  int n;
  vector<int> lazy, val;
  inline void lazy_eval(int k){//dbg(mp(k,v));
    if(lazy[k]>-1){
      if(lazy[k]==0) val[k]=0;
      else val[k] = 1;
      if(k<n-1){
        lazy[2*k+1]=lazy[k];
        lazy[2*k+2]=lazy[k];
      }
      lazy[k]=-1;
    }
  }
  int get(int v){
    v += n-1;
    int ret = val[v];
    if(lazy[v]>-1) ret = lazy[v];
    while(v>0){
      v = (v-1)/2;
      if(lazy[v]>-1) ret = lazy[v];
    }
    return ret;
  }
  void _update(int a, int b, int v, int k, int l, int r){// dbg(k);
    lazy_eval(k);
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
      lazy[k]=v;
      lazy_eval(k);
      return;
    }
    int m=(l+r)/2;
    _update(a,b,v,k*2+1,l,m);
    _update(a,b,v,k*2+2,m,r);
    val[k] = val[k*2+1] + val[k*2+2] - get(m-1) * get(m);
    return;
  }
  void update(int a, int b, int v){ _update(a,b,v,0,0,n); return; }
  Segtree(int n_){
    n=1;
    while(n<n_) n*=2;
    lazy = vector<int>(2*n-1, -1);
    val = vector<int>(2*n-1, 0);
  }
};


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

  Segtree st(n);
  rep(i,n) st.val[st.n-1+i] = s[i]=='1';

  function<pair<int,int>(int)> idfs = [&](int i){
    if(i>=st.n-1){
      return mp(i-(st.n-1), i-(st.n-1)+1);
    }
    auto pl = idfs(i*2+1);
    auto pr = idfs(i*2+2);assert(pl.se==pr.fi);
//    cout << vector<int>{i, st.val[i*2+1], st.val[i*2+2], st.val[pr.fi-1], st.val[pr.fi]} << endl;
    st.val[i] = st.val[i*2+1] + st.val[i*2+2] - st.val[st.n-1+pr.fi-1]*st.val[st.n-1+pr.fi];
    return mp(pl.fi, pr.se);
  };
  idfs(0);

//  dbg(st.val);

  int q;cin>>q;
  rep(_,q){
    int l,r,b;
    cin>>l>>r>>b;
    st.update(l-1,r,b);// dbg(st.val);dbg(st.lazy);
    cout << st.val[0] << endl;
  }


  return 0;
}

Measured memory_bytes: 5304
#include<stdio.h>
#include<math.h>
int main()
{
    int n,s[1005],i;
    double a,x;
    for(;scanf("%d",&n),n;)
    {
        for(i=a=0;i<n;a+=s[i++])
            scanf("%d",&s[i]);
        a/=n;
        for(i=x=0;i<n;i++)
            x+=(s[i]-a)*(s[i]-a);
        printf("%.8f\n",sqrt((double)x/n));
    }
    return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int N,A,B,C,D;
string s;
bool Check(int l,int r){
    for(int i=l+1;i<=min(r,N-1);i++){
        if(s[i]=='#' && s[i+1]=='#'){
            return false;
        }
    }
    return true;
}
bool SafeareaValid(int l,int r){
    for(int i=l;i<=r;i++){
        if(s.substr(i-1,3)=="..."){
            return true;
        }
    }
    return false;
}
int main(){
    cin>>N>>A>>B>>C>>D;
    A--;B--;C--;D--;
    cin>>s;
    if(Check(A,C) && Check(B,D)){
        if(D<C){
            if(SafeareaValid(B,D)){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"Yes"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return 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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    bool y = false;
    int n;
    cin >> n;
    rep(i, n) {
        char c;
        cin >> c;
        if(c == 'Y') y = true;
    }
    if(y) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 3584
#if defined(LOCAL)
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define MAX(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__y:__x;})
#define MIN(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  stack<l> s;
  l answer = numeric_limits<int>::max();
  F(j, 1, 10) {
    vl v(n, numeric_limits<int>::max());
    v[j % n] = j;
    vb in_queue(n);
    in_queue[j % n] = true;
    queue<l> q; q.emplace(j % n);
    while (not q.empty()) {
      l a = q.front(); q.pop();
      in_queue[a] = false;
      F(i, 0, 10) {
        l t = (a * 10 + i) % n;
        if (v[t] <= v[a] + i) continue;
        v[t] = v[a] + i;
        if (in_queue[t]) continue;
        in_queue[t] = true;
        q.emplace(t);
      }
    }
    answer = min(answer, v[0]);
  }
  cout << answer << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 1908
#include <stdio.h>
int main(void)
{
  int i, n, k, h[100000], count=0;
  scanf("%d%d", &n, &k);
  for(i=0; i<n; i++)
    scanf("%d", &h[i]);
  for(i=0; i<n; i++){
    if(h[i] >= k)
      count++;
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 512