akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,x,y,h;
    cin>>n;
    std::vector<vector<pair<long long int,long long int>>> vec(101,vector<pair<long long int,long long int>>(101));
    std::vector<vector<int>> flag(101,vector<int>(101));
    for (int l=0;l<n;l++) {
        cin>>x>>y>>h;
        for (long long int i=0;i<=100;i++) {
            for (long long int j=0;j<=100;j++) {
                if (h==0) {
                    if (vec[i][j].second==0) {
                        vec[i][j]=make_pair(abs(x-i)+abs(y-j),1);
                        flag[i][j]=1;
                    } else if (vec[i][j].first>abs(x-i)+abs(y-j)) {
                        if (flag[i][j]==1) {
                            vec[i][j].first=abs(x-i)+abs(y-j);
                            vec[i][j].second++;
                            if (vec[i][j].second==n) {
                                cout<<i<<" "<<j<<" "<<vec[i][j].first<<endl;
                                return 0;
                            }
                        }
                    } else if (vec[i][j].first<=abs(x-i)+abs(y-j)) {
                        vec[i][j].second++;
                        if (vec[i][j].second==n) {
                            cout<<i<<" "<<j<<" "<<vec[i][j].first<<endl;
                            return 0;
                        }
                    }
                } else {
                    long long int H=h+abs(x-i)+abs(y-j);
                    if (vec[i][j].second==0) {
                        vec[i][j]=make_pair(H,1);
                    } else if (vec[i][j].first==H) {
                        flag[i][j]=0;
                        vec[i][j].second++;
                        if (vec[i][j].second==n) {
                            cout<<i<<" "<<j<<" "<<vec[i][j].first<<endl;
                            return 0;
                        }
                    } else if (flag[i][j]==1&&H<=vec[i][j].first) {
                        vec[i][j].first=H;
                        flag[i][j]=0;
                        vec[i][j].second++;
                        if (vec[i][j].second==n) {
                            cout<<i<<" "<<j<<" "<<vec[i][j].first<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int tall;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    vector<int> Ryokan(N);
    
    int ans;
    ans = 0;
    
    for (int i = 0; i < N; i++) cin >> Ryokan[i];
    
    tall = Ryokan[0];
    
    for (int i = 1; i < N; i++){
        if (tall <= Ryokan[i]){
            ans += 1;
            tall = Ryokan[i];
        }
    }
    
    cout << ans + 1 << endl;
    
    
    
    
    
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

def main():
    h, w = map(int, input().split())

    a = [input()[:-1] for i in range(h)]

    already = [[False]*w for i in range(h)]
    key = deque([])
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                if not key:
                    judge = (i, j)
                key.append((i, j))
                already[i][j] = True
    
    ans = -1
    way = [(-1, 0), (1, 0), (0, 1), (0, -1)]
    change = False
    while key:
        value = key.popleft()
        if value == judge:
            ans += 1
            judge = value
            change = True
        i, j = value
        for x, y in way:
            p, q = i+x, j+y
            if 0 <= p < h and 0 <= q < w  and not already[p][q]:
                already[p][q] = True
                key.append((p, q))
                if change:
                    judge = (p, q)
                    change = False

    print(ans)







    
if __name__ == "__main__":
    main()



Measured memory_bytes: 115736
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = pow(10,15);
int k,x,m, n, h,r,c=0,w; string s;
const ll MOD= 1000000007;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
} 
struct Corr {
    int x;
    int y;
    int depth;
};
queue<Corr> q; vector<vector<char>> v;
vector<vector<bool>> ispassed;
vector<vector<int>> dist;
void bfs () {
    int dx[8] = { 1, 0, -1, 0 };
    int dy[8] = { 0, 1, 0, -1 };
    while (!q.empty()) {
        Corr now = q.front(); q.pop();
        for (int i = 0; i < 4; i++) {
            int nextx = now.x + dx[i];
            int nexty = now.y + dy[i];
            if (nextx >= w || nextx < 0) continue;
            if (nexty >= h || nexty < 0) continue;
            if (dist[nexty][nextx] != -1) continue;
            dist[nexty][nextx] = now.depth + 1;
            Corr next = { nextx, nexty, now.depth + 1 };
            q.push(next);
        }
    }
}
int main() {
    cin >> h >> w; v.resize(h, vector<char>(w));
    dist.resize(h, vector<int>(w, -1));
    rep(i, h) {
        rep(j, w) {
            cin >> v[i][j];
            if (v[i][j] == '#') {
                dist[i][j] = 0;
                Corr st = { j,i,0 };
                q.push(st);
            }
        }
    }
    bfs();
    rep(i, h) rep(j, w) c = max(dist[i][j], c);
    cout << c << endl;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



int n,a;
int x[51];
/*
dp[j][k][s] j番目までの数列でk個選んでsにできる個数

dp[j][k][s] = dp[j-1][k][s] j番目がsより大きい場合
dp[j][k][s] = dp[j-1][k-1][s-x[j]]
*/
ll dp[51][51][2550] = {{{0}}};
int main(){
  cin >>n>>a;
  FOR(i,1,n+1){
    cin >>x[i];
  }
  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 1;
  FOR(j,1,n+1){
    dp[j][0][0] = 1;
    FOR(k,1,n+1){
      REP(s,n*a+1){
          if(s<x[j]){
            dp[j][k][s] = dp[j-1][k][s];
          }else if(s>=x[j]){
            dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
          }
      }
    }
  }
  ll sum = 0;
  FOR(k,1,n+1){
    sum += dp[n][k][a*k];
  }
  cout << sum << endl;
}


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

typedef long long   ll;

vector< ll > ddiv;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    
    cin >> n;
    
    for(ll d = 2LL ; d * d <= n ; d++){
        if(n % d == 0LL){
            ddiv.push_back(d);
            
            if(n != d * d){
                ddiv.push_back(n / d);
            }
        }
    }
    
    ll cnt = 0;
    
    for(auto u: ddiv){
        ll tmp = n;
        
        while(tmp % u == 0LL){
            tmp /= u;
        }
        
        if(tmp % u == 1LL){
            cnt++;
        }
    }
    
    n -= 1LL;
    
    for(ll d = 1LL ; d * d <= n ; d++){
        if(n % d == 0LL){
            cnt++;
            
            if(n != d * d){
                cnt++;
            }
        }
    }
    
    printf("%lld\n", cnt);
    
	return 0;
}


Measured memory_bytes: 384
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def ex(s):
    n = int(s)
    nn = (n+1) * (n/2)
    return nn / n

# main
N, K = mis()
exs = list(map(ex, input().split()))

if N == K:
    print(sum(exs))
    exit(0)

ex_max = 0

for i in range(K):
    ex_max += exs[i]

left = 0
ex_temp = ex_max
for i in range(K, N):
    ex_temp = ex_temp - exs[left] + exs[i]
    left += 1
    if ex_max < ex_temp:
        ex_max = ex_temp

print('{:.7f}'.format(ex_max))


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

string board[1005];
ll dp[1005][1005];

const ll MAX = MOD;

void solve(){
  string s,t; cin>>s>>t;
  int N = s.size();
  int M = t.size();
  int ans = 10000;
  for(int idx=0;idx+M<=N;++idx){
    int temp = 0;
    REP(d,M){
      if(s[idx+d]!=t[d]){
        ++temp;
      }
    }
    chmin(ans,temp);
  }
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  if (N/1000==N%1000/100 && N%1000/100==N%100/10){
    cout<<"Yes"<<endl;
  }
  else if (N%1000/100==N%100/10 && N%100/10==N%10 ){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  } 
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i]+A[i])

for i in range(m):
    b.append(b[i]+B[i])

i = 0
ans = 0
j = m
while(i < len(a)):
    if a[i] > k:
        break

    else:
        while(b[j] > k-a[i]):
            j = j-1

        ans = max(ans,i+j)

    i = i+1

print(ans)

Measured memory_bytes: 134424
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  int ret=0;
  for(int i=1;i<=N;i++)
    ret+=i;
  cout<<ret;
}


Measured memory_bytes: 384
import math

N =int(input())
A =int(input())
B =int(input())
C =int(input())
D =int(input())
E =int(input())

list1 = [math.ceil(N/i) for i in [A,B,C,D,E]]

max_index = list1.index(max(list1))

print(max(list1) + 4)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
    long long N, T, A, x = 1, y = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T >> A;
        long long n = ceil(max(x / (long double)T, y / (long double)A));
        x = n * T;
        y = n * A;
    }
    cout << x + y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll H, W, h, w, X = 1e8;
    cin >> H >> W >> h >> w;
    vector<vector<ll> > ans(H, vector<ll>(W, 1));
    for(int i=h-1;i<H;i+=h){
        for(int j=w-1;j<W;j+=w){
            ans[i][j] = -h*w-X;
        }
    }
    for(int i=0;i<H;i+=h){
        for(int j=0;j<W;j+=w){
            ans[i][j] += X;
        }
    }
    ll sum = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            sum += ans[i][j];
        }
    }
    if(sum > 0){
        cout << "Yes" << endl;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << ans[i][j] << " \n"[j==W-1];
            }
        }
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x; cin >> x;

    ll cnt500, cnt5;

    cnt500 = x / 500;
    x -= cnt500 * 500;
    cnt5 = x / 5;

    cout << cnt500 * 1000 + cnt5 * 5 << endl;

    return 0;
}

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

int main()
{
    int N;
    string S;
    int count = 0;
    cin >> N >> S;
    
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            count++;
        }
       }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    char a;
    cin >> a;
    if (a - 'A' < 26)cout << 'A' << endl;
    else cout << "a" << endl;
}

Measured memory_bytes: 3592
#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;
  string s;
  cin >> s;
  
  int count = 0;
  for(int i=1; i < N-1; i++){
    if( s[i-1]=='A' && s[i]=='B' && s[i+1]=='C' ) count++;
  }
  cout << count << endl;
}
      
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int d;
    cin>>d;
    vector<int>c(26),t(d),nod(26);
    rep(j,26)cin>>c[j];
    vector<vector<int>>s(d,vector<int>(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    //rep(i,d)cin>>t[i];
    int pt=0,mx,tx;
    rep(i,d){
        mx=-1000000;
        rep(j,26){
            tx=s[i][j]+nod[j]*c[j];
            if(tx>mx){
                mx=tx;
                t[i]=j+1;
            }
        }
        
        rep(j,26){
            if(t[i]-1==j){
                pt+=s[i][j];
                nod[j]=0;
            }
            else{
                nod[j]++;
                pt-=c[j]*nod[j];
            }
        }
        //cout<<pt<<endl;
        
    }
    rep(i,d)cout<<t[i]<<endl;
	return 0;
}


Measured memory_bytes: 3680
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<complex>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

int main(){
  ll n,a,b;

  cin >> n >> a >> b;

  cout << min(a,b) << " " << max(0ll,(a + b) - n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int P[30][100010];
int main() {
    string s, t; cin >> s >> t;
    fill(P[0], P[29] + 100010, -1);

    loop (s.size(), i) {
        int c = s[i] - 'a';
        P[c][i] = i;
    }

    loop (26, k) {
        loop (s.size() - 1, i) {
            int j = s.size() - 2 - i;
            if (P[k][j] != -1) continue;
            P[k][j] = P[k][j + 1];
        }
    }

    // loop (5, i) {
    //     cout << P[0][i] << " ";
    // }
    // cout << endl;

    ll a = 0, b = 0;
    int crr = 0;
    for (char c : t) {
        if (crr >= s.size()) {
            crr = 0;
            a++;
        }

        int v = c - 'a';
        int nxt;
        while (1) {
            nxt = P[v][crr];
            if (nxt == -1 && crr == 0) {
                cout << -1 << endl;
                return 0;
            }
            if (nxt == -1) {
                crr = 0;
                a++;
                continue;
            } else break;
        }

        b = nxt;
        crr = nxt + 1;

        // cout << b << ", " << crr << ", " << a << endl;
    }

    cout << a * (ll) s.size() + b + 1 << endl;
    return 0;
}



Measured memory_bytes: 12288
#include <stdio.h>

int main(void){

	int x, y;

	scanf("%d%d", &x, &y);
		
	if(x > y){
		printf("a > b\n");
	}else if(x < y){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	
	}
	
	return 0;

	}

Measured memory_bytes: 580
N = int(input())
A = list(map(int, input().split()))

for a in A:
    # 4は2で割れるから飛ばす　余りが1でもあったら
    if a % 2 == 1:
        continue
    if a % 3 == 0 or a % 5 == 0:
        continue
    print('DENIED')
    exit()
print('APPROVED')

Measured memory_bytes: 2940
a, b, c = map(int, input().split())
if(a==7):
    if(b==5 and c==5):
        print('YES')
    else:
        print('NO')
elif(b==7):
    if(a==5 and c==5):
        print('YES')
    else:
        print('NO')
elif(c==7):
    if(b==5 and a==5):
        print('YES')
    else:
        print('NO')
else:
    print('NO')

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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int k;
  scanf("%d", &k);
  if (k == 1) {
    puts("1");
    puts("1");
    return 0;
  }
  int n = (k + 3) / 4 * 2;
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int color = (i + j) % n;
      if ((i & 1) && color + n < k) {
        color += n;
      }
      printf("%d%c", color + 1, j == n - 1 ? '\n' : ' ');
    }
  }
  return 0;
}


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

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

    int X, N, temp, bias = 0;
    set<int> nums;
    cin >> X >> N;
    if(N==0){
        cout << X;
        return 0;
    }else{
        for(int i=0; i<N; i++){
            cin >> temp;
            nums.insert(temp);
        }
    }

    while(1){
        if(nums.find(X-bias) == nums.end()){
            cout << X-bias;
            break;
        }else if(nums.find(X+bias) == nums.end()){
            cout << X+bias;
            break;
        }
        bias++;
    }
    
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        bool flg = true;
        rep(i, 0, N) {
                if (even(A[i])) {
                        bool f = A[i] % 3 == 0 or A[i] % 5 == 0;
                        if (not f) flg = false;
                }
        }

        if (flg) {
                cout << "APPROVED" << endl;
        } else {
                cout << "DENIED" << endl;
        }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
string c;
cin>>c;
string m;
for(int i=0;i<c.size();i++)
{
	if(c[i]=='B')
	{
		if (c.size()!=0)
		{
			m=m.substr(0,m.size()-1);	
		}
    }
    else
    {
    	m+=c[i];
	}
	}
cout<<m<<endl;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


v,e = mi()
sb = [[]for i in range(e)]
ub = [[]for i in range(e)]
w = [[float('inf')] * v for i in range(v)]
dp = [[-1] * v for i in range(2**v +1) ] 


for i in range(e):
    s,t,d = mi()
    sb[s].append(t)
    w[s][t] = d

def rec(s,p,dp):
    if dp[s][p] >0:
        return dp[s][p]
    
    if s == (1<<v)-1 and p == 0:
        dp[s][v-1] = 0
        return 0

    res = float('inf')
    for i in sb[p]:
        if (s >> i&1) == 0:
            a = rec(s|(1<<i), i,dp) + w[p][i]
            res = min(res, a)
    
    dp[s][p] = res
    return res

if v >= 3 and e >= 3:
    ans = rec(0,0,dp)
else:
    ans = -1

if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 18792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll N, L;
    cin >> N >> L;
    vector<ll> W(N);
    vector<ll> V(N);
    rep(i,N) cin >> W.at(i) >> V.at(i);
    ll DP[N+1][L+1];
    memset(DP, 0, sizeof(DP));
    for (int i = 0; i <= N - 1; i++) {
        for (int j = 0; j <= L; j++) {
            if (j + W[i] <= L) {
                chmax(DP[i+1][j + W[i]], DP[i][j] + V[i]);
            }
            chmax(DP[i+1][j], DP[i][j]);
        }
    }
    /*
    rep (i,N+1) {
        rep(j,L+1) printf(" %3ld", DP[i][j]);
        printf("\n");
    }
    */
    cout << DP[N][L] << endl;
}

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

int main()
{
    int ans = 0, cnt = 0;
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++){
        switch (s[i])
        {
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            cnt++;
            break;
        
        default:
            ans = max(ans, cnt);
            cnt = 0;
            break;
        }
    }
    cout << max(ans, cnt) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

s = deque((str(input())))
loop = int(input())

rev = 0
for i in range(loop):
    queries = input().split()
    if len(queries) == 1:
        rev = (rev+1) % 2
    else:
        type = int(queries[1])
        c = str(queries[2])
        if (type + rev) % 2 == 1:
            s.appendleft(c)
        else:
            s.append(c)
if rev == 1:
    print("".join(reversed(list(s))))
else:
    print("".join(list(s)))

Measured memory_bytes: 10228
N = int(input())
A = []
for _ in range(N):
    A.append([x - 1 for x in map(int, input().split())])

game = []
for p1 in range(N):
    p2 = A[p1][0]
    if A[p2][0] == p1 and p1 < p2:
        game.append((p1, p2))

cursors = [0] * N
days = 0
while game:
    days += 1
    new_game = []
    for p1, p2 in game:
        cursors[p1] += 1
        if cursors[p1] < N - 1:
            p3 = A[p1][cursors[p1]]
            if cursors[p3] < N - 1 and A[p3][cursors[p3]] == p1:
                new_game.append((p1, p3))
        cursors[p2] += 1
        if cursors[p2] < N - 1:
            p3 = A[p2][cursors[p2]]
            if cursors[p3] < N - 1 and A[p3][cursors[p3]] == p2:
                new_game.append((p2, p3))
    game = new_game

if all(c == N - 1 for c in cursors):
    print(days)
else:
    print(-1)

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

long long n,m,c,x,y,a,b, hasil, tag;
int arr[200001];
bool mulai[200001];
bool sel[200001];
bool valid;

int main() {
    cin >> m >> n;
    for (int i = 1; i <= n; i++){
        cin >> x >> y;
        if (x == 1){
            mulai[y] = true;
        }
        if (y == m){
            sel[x] = true;
        }
    }
    valid = false;
    for (int i = 1; i <= m; i++){
        if (mulai[i] && sel[i]){
            valid = true;
        }
    }
    if (valid == true){
        cout << "POSSIBLE" << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}
    
    
    
    

    
   


Measured memory_bytes: 3896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int n, m, q;
int a[50], b[50], c[50], d[50];
int ans;
void dfs(vector<int> &A) {
	if (A.size() == n) {
		int now = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
		}
		ans = max(ans, now);
		return;
	}
	int p = (A.empty() ? 1 : A.back());
	repl(i, p, m + 1) {
		A.push_back(i);
		dfs(A);
		A.pop_back();
	}
	return;
}
int main() {
	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	vector<int> A;
	dfs(A);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: u32 = iterator.next().unwrap().parse().unwrap();
    let x: u32 = iterator.next().unwrap().parse().unwrap();

    return if k * 500 >= x {
        String::from("Yes")
    } else {
        String::from("No")
    }
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"2 900"
        ),
        "Yes"
    );
    assert_eq!(
        solve(
            r"1 501"
        ),
        "No"
    );
    assert_eq!(
        solve(
            r"4 2000"
        ),
        "Yes"
    );
}


Measured memory_bytes: 4352
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val M = Array.fill[Int](n, n)(0)

  (0 until n).foreach { i =>
    M(i) = StdIn.readLine().trim().split(' ').map(_.toInt)
  }

  val color = Array.fill[Int](n)(0)
  val distance = Array.fill(n)(Int.MaxValue)
  val parent = Array.fill(n)(-1)
  
  private val WHITE = 0
  private val GRAY = 1
  private val BLACK = 9
  
  var mincost = -1
  var u = 0
  distance(0) = 0
  while(mincost != Int.MaxValue){
    mincost = Int.MaxValue
    (0 until n).foreach{ i =>
      if(color(i) != BLACK && distance(i) < mincost){
        mincost = distance(i)
        u = i
      }
    }

    if(mincost != Int.MaxValue){
      color(u) = BLACK
      
      (0 until n).foreach{ v =>
        if(color(v) != BLACK && M(u)(v) != -1){
          if(M(u)(v) < distance(v)){
            distance(v) = M(u)(v)
            parent(v) = u
            color(v) = GRAY
          }
        }
      }
      
    }

  }

  println(distance.sum)

}



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

using namespace std;

int main()
{
	int n;
	vector<int> result;
	
	while (cin >> n, n != -1){
		while (1){
			result.push_back(n % 4);
			n /= 4;
			if (n == 0){
				break;
			}
		}
		for (int i = result.size() - 1; i >= 0; i--){
			cout << result[i];
		}
		cout << endl;
		result.clear();
	}
	return (0);
}

Measured memory_bytes: 1212
N = int(input())
A = list(map(int, input().split()))

dp = [[N, N] for i in range(N)]
dp[0] = [1, 1]
for i, a in enumerate(A[1:], 1):
  pre_a = A[i-1]
  if pre_a < a:
    dp[i][0] = min(dp[i-1][0], dp[i-1][1]+1)
    dp[i][1] = min(dp[i-1][0]+1, dp[i-1][1]+1)
  elif pre_a == a:
    dp[i][0] = min(dp[i-1][0], dp[i-1][1]+1)
    dp[i][1] = min(dp[i-1][0]+1, dp[i-1][1])
  else:
    dp[i][0] = min(dp[i-1][0]+1, dp[i-1][1]+1)
    dp[i][1] = min(dp[i-1][0]+1, dp[i-1][1])

print(min(dp[-1]))

Measured memory_bytes: 22288
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
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

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
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;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; 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;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
ll dp[100][100];
bool used[500005];
char s[500005],t[500005];
bool flag,dame;

int main(){
	cin >> n >> m;
	n *= 3;
	n += m;
	n /= 2;
	p(n);
	return 0;
}

Measured memory_bytes: 24704
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.Char (intToDigit)

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  sss <- lines <$> getContents
  putStr . unlines $ solve h w sss

solve :: Int -> Int -> [[Char]] -> [[Char]]
solve h w sss = map (map count) [[(i, j) | i <- [0 .. w - 1]] | j <- [0 .. h - 1]]
  where
    count :: (Int, Int) -> Char
    count (i, j) = if sss !! j !! i == '#'
      then '#'
      else  intToDigit . length $ filter isBomb [(i + x, j + y) | x <- [-1 .. 1], y <- [-1 .. 1]]
    isBomb :: (Int, Int) -> Bool
    isBomb (x, y) = 0 <= x && x < w && 0 <= y && y < h && sss !! y !! x == '#'


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,r,l,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
     {
         cin>>l>>r;
         sum=r-l+1+sum;
     }
    cout<<sum<<endl;
}

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

int main(){
	int a, b;
	while (cin >> a >> b)cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000

void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  string s; 
  cin>>n;
  if(n==0) {cout<<0<<endl;
  }else{
      while(n){
          if(n%2){
               s="1"+s;n--;
          } else {
              s="0"+s;
          }
          n/=(-2);
      }  
  }
  cout<<s<<endl;
}

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

Measured memory_bytes: 256
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    val x = Seq(Array(0, in.next.head-1, 2147483647))
    in.foldLeft(x)((qs, q) => q match {
        case Array(0, _*) => q.tail +: qs
        case Array(1, i) => {
            println((qs.find(y => y(0) <= i && y(1) >= i).get)(2))
            qs
        }
    })
}

Measured memory_bytes: 187264
n=int(input())
m=len(str(n))
k=int(input())
N=[int(i) for i in str(n)]
dp0=[[0]*(k+1) for _ in range(m+1)]
dp1=[[0]*(k+1) for _ in range(m+1)]
dp1[0][0]=1
for i in range(m):
  for j in range(k+1):
    dp1[i+1][j]+=dp1[i][j]*(N[i]==0)
    dp0[i+1][j]+=dp0[i][j]+dp1[i][j]*(N[i]>0)
    if j<k:
      dp1[i+1][j+1]+=dp1[i][j]*(N[i]>0)
      dp0[i+1][j+1]+=dp0[i][j]*9+dp1[i][j]*max(0,N[i]-1)
print(dp1[m][k]+dp0[m][k])

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int val[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &val[i]);
	}
	sort(val, val + n);
	int maxi = 0;
	REP(i, 0, n - 1) {
		if (abs(val[n - 1] - val[i] * 2) < abs(val[n - 1] - val[maxi] * 2)) {
			maxi = i;
		}
	}
	printf("%d %d\n", val[n - 1], val[maxi]);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()

    return

#B
def B():
    n = I()

    return

#C
def C():
    def dist(a,b):
        xa,ya,ra = a
        xb,yb,rb = b
        return max(0, ((xa-xb)**2+(ya-yb)**2)**0.5-(ra+rb))

    xs,ys,xt,yt = LI()
    n = I()
    p = LIR(n)
    v = [[] for i in range(n+2)]
    a = (xs,ys,0)
    b = (xt,yt,0)
    d = dist(a,b)
    v[0].append((n+1, d))
    for i in range(n):
        d = dist(a,p[i])
        v[0].append((i+1,d))
        d = dist(p[i],b)
        v[i+1].append((n+1,d))
        for j in range(i+1,n):
            d = dist(p[i],p[j])
            v[i+1].append((j+1,d))
            v[j+1].append((i+1,d))
    d = [float("inf")]*(n+2)
    q = [(0,0)]
    d[0] = 0
    while q:
        dx,x = heappop(q)
        if x > n:
            print(d[x])
            return
        if d[x] < dx:
            continue
        for y,w in v[x]:
            nd = dx+w
            if nd < d[y]:
                d[y] = nd
                heappush(q,(nd,y))
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 130952
#include<bits/stdc++.h>
using namespace std;
int actx[8]={-1,0,1,1,1,0,-1,-1};
int acty[8]={1,1,1,0,-1,-1,-1,0};
int main()
{
	int m,n;
	char pic[105][105];
	int picx[105][105];
	cin>>n>>m;
	for(int i=0;i<=n+1;i++)
	{
		for(int j=0;j<=m+1;j++)
			pic[i][j]='0';
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>pic[i][j];
			picx[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(pic[i][j]!='#')
			{
				for(int l=0;l<8;l++)
				{
					if(pic[i+actx[l]][j+acty[l]]=='#')
						picx[i][j]++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(pic[i][j]!='#')
				cout<<picx[i][j];
			else
				cout<<'#';
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
check_list = []
for i in range(2 ** n):
    a = bin(i)[2::]
    while len(a) < n:
        a = "0" + a
    #print(len(a))
    check_list.append(a)
#print(check_list)

num = 0
ans = 0
for i in check_list:
    num = 0
    key = 1
    for j in ks:
        cnt = 0
        #print(j, i)
        for k in range(1, len(j)):
            #print(i, j, k)
            #i[j[k] - 1]
            if i[j[k] - 1] == "1":
                #print(i, j, cnt, j[k], i[j[k] - 1], p[num], 321321321)
                cnt += 1
        if cnt % 2 != p[num]:
            #print(i, j, cnt, j[k], i[j[k] - 1], p[num])
            key = 0
            break
        num += 1
    if key:
        ans += 1
print(ans)

Measured memory_bytes: 40816
#include <stdio.h>
int main(void)
{
    char S[3];
    int n = 0;
    scanf("%s", &S);
    if (S[0] == 'M')
        n = 6;
    else if (S[0] == 'W')
        n = 4;
    else if (S[0] == 'F')
        n = 2;
    else if (S[0] == 'S')
    {
        if (S[1] == 'U')
            n = 7;
        else
            n = 1;
    }
    else
    {
        if (S[1] == 'U')
            n = 5;
        else
            n = 3;
    }
    printf("%d", n);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
records = [tuple(map(int, input().split(' '))) for _ in range(N)]

pre_t = 0
pre_x = 0
pre_y = 0

for t, x, y in records:
    turn = t - pre_t
    dx = abs(x - pre_x)
    dy = abs(y - pre_y)

    if turn < (dx + dy):
        print('No')
        break

    if turn % 2 != (dx + dy) % 2:
        print('No')
        break

    pre_t = t
    pre_x = x
    pre_y = y
else:
    print('Yes')


Measured memory_bytes: 17312
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
  int H, W;
  while (cin >> H >> W) {
    if (H == 0 && W == 0) return 0;
    REP(h, H) {
      REP(w, W) {
        if (h == 0 || h == H - 1 || w == 0 || w == W - 1) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3100
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 2010
#define M 4000010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int f[N][N];
int fac[M],inv[M];
int n,k;
const int mod=1e9+7;
inline int C(int n,int m){if(n<m)return 0;return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline int Z(int x){return x>=mod?x-mod:x;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),k=read();
	if(k==1){printf("1\n");return 0;}
	fac[0]=1;
	for(register int i=1;i<=n*k;i++)fac[i]=1LL*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	for(register int i=2;i<=n*k;i++)inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(register int i=2;i<=n*k;i++)inv[i]=1LL*inv[i]*inv[i-1]%mod;
	f[0][0]=1;
	for(register int i=1;i<=n;i++)
	{
		f[i][0]=1;
		for(register int j=1;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			f[i][j]=Z(f[i][j]+1LL*f[i][j-1]*(n-j+1)%mod*C(n*k-(j-1)*(k-1)-i-1,k-2)%mod);
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 48692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') l++;
    }
    if(l > n-l){
        cout<<"Yes";
    }
    else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define N 1200001
using namespace std;
char c[220001][11],fuck[220001][11];
int fuckfuckfuck[N],ch[N][27],cnt,fuckfuckljx,ed[N][27],sum[N][27],id[N][27],len[N],ans[N][27],n;
long long fuckljx;
void insert(int fuckfuck){
	int p=0;
	for(int i=1;i<=len[fuckfuck]-1;i++){
		for(int j=1;j<=26;j++){
//			cout<<p<<" "<<j<<" "<<sum[id[fuckfuck][i]][j]<<endl;
			if(sum[id[fuckfuck][i]][j])fuckljx+=(long long)ed[p][j],ans[p][j]++;
		}
		if(!ch[p][fuck[fuckfuck][i]-'a'+1])ch[p][fuck[fuckfuck][i]-'a'+1]=++cnt;
		p=ch[p][fuck[fuckfuck][i]-'a'+1];
	}
//	cout<<fuckljx<<endl;
	fuckljx+=(long long)ans[p][fuck[fuckfuck][len[fuckfuck]]-'a'+1];
	ed[p][fuck[fuckfuck][len[fuckfuck]]-'a'+1]++;
//	cout<<"fuck "<<p<<' '<<fuck[fuckfuck][len[fuckfuck]]-'a'+1<<endl;
//	cout<<fuckljx<<endl;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%s",c[i]+1);
		len[i]=strlen(c[i]+1);
		for(int j=1;j<=len[i];j++)fuck[i][j]=c[i][len[i]-j+1],id[i][j]=++fuckfuckljx;
		for(int j=len[i];j>=1;j--){
			for(int k=1;k<=26;k++)sum[id[i][j]][k]=sum[id[i][j]+1][k];
			sum[id[i][j]][fuck[i][j]-'a'+1]++;
		}
		insert(i);
	}
	cout<<fuckljx;
}

Measured memory_bytes: 364496