akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iterator>
using namespace std;

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n=in();
  vi ans;
  rep(i,n)
  {
    string s; cin>>s;
    set<string> d;
    rep(j,s.size())
    {
      string a=s.substr(0,j+1);
      string b=s.substr(j+1,s.size()-j-1);
      string ta=a, tb=b;
      reverse(ALL(ta));
      reverse(ALL(tb));
      d.insert(a+b);
      d.insert(b+a);
      d.insert(ta+tb);
      d.insert(tb+ta);
      d.insert(a+tb);
      d.insert(tb+a);
      d.insert(ta+b);
      d.insert(b+ta);
    }
    ans.pb(d.size());
  }
  EACH(e,ans) print(e);

  return 0;
}


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int d = Integer.parseInt(in.next());
            int x[][] = new int[n][d];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    x[i][j] = Integer.parseInt(in.next());
                }
            }
            int ans = 0;
            int s = 0;

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    for (int k = 0; k < d; k++) {
                        s += Math.pow(x[i][k] - x[j][k], 2);
                    }
                    int a = (int) Math.sqrt(s);
                    if (s == a * a) ans++;
                    s = 0;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int cost[50][50],grid[505][505],n,c;
ll box[3][50],dp[50][3];
vector<pair<int,int> >v[4];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n>>c;
    for(int i=1; i<=c; i++)
        for(int j=1; j<=c; j++)
            cin>>cost[i][j];
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            cin>>grid[i][j];
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int m=(i+j)%3;
            v[m].push_back({i,j});
        }
    }
    int sz0=v[0].size(),sz1=v[1].size(),sz2=v[2].size();
    for(int i=1; i<=c; i++)
    {
        ll cur=0;
        for(int j=0; j<sz0; j++)
        {
            int x=v[0][j].first;
            int y=v[0][j].second;
            if(grid[x][y]!=i)
            {
                cur+=cost[grid[x][y]][i];
            }
        }
        box[0][i]=cur;

        cur=0;
        for(int j=0; j<sz1; j++)
        {
            int x=v[1][j].first;
            int y=v[1][j].second;
            if(grid[x][y]!=i)
            {
                cur+=cost[grid[x][y]][i];
            }
        }
        box[1][i]=cur;
        cur=0;
        for(int j=0; j<sz2; j++)
        {
            int x=v[2][j].first;
            int y=v[2][j].second;
            if(grid[x][y]!=i)
            {
                cur+=cost[grid[x][y]][i];
            }
        }
        box[2][i]=cur;
    }
    ll ans=INT_MAX;
    for(int i=1; i<=c; i++)
    {
        for(int j=1; j<=c; j++)
        {
            if(i==j)
                continue;
            for(int k=1; k<=c; k++)
            {
                if(i==k || j==k)
                continue;
            ans=min(ans,box[0][i]+box[1][j]+box[2][k]);
            }
        }
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 6216
@n = gets.to_i
@shop_opens = []
@n.times do 
  @shop_opens << gets.chomp.split.map(&:to_i)
end

@shop_points = []
@n.times do
  @shop_points << gets.chomp.split.map(&:to_i)
end

# 各店の開店してる同じ時間帯に開店した回数ぶんだけポイントになる、これを全店でやったポイントの総数の最大値を答える
# -> 開店する時間帯の決め方は月~金それぞれ午前午後で、とりうるすべての組み合わせは2^10程度なのでこれを全探索する
# 開店/閉店は1と0で表されるのを利用してビット演算してANDとる方法もあるがビット演算を調べるのがめんどくさいので愚直に配列でやろうと思う

@ans = -10000000000

time_period = Array.new(10, 0)

def rec(arr, idx)
  if idx>=10
    # 各店で同じ時間帯に開いてる数から利益を算出して比較アンド更新
    if arr.uniq != [0]
      # 「最低一回は開店する」ので「1度も開店してない」状態以外についてのみ考える
      temp_point = 0
      @n.times do |i|
        match_count = 0
        (0...10).each do |j|
          match_count += arr[j] == @shop_opens[i][j] && arr[j] == 1 ? 1 : 0
        end
        temp_point += @shop_points[i][match_count]
      end
      @ans = [@ans, temp_point].max
    end
  else
    # 探索
    nex_arr = arr.dup
    nex_arr[idx] = 1
    rec(nex_arr, idx+1)
    nex_arr[idx] = 0
    rec(nex_arr, idx+1)
  end
end

rec(time_period, 0)

puts @ans

Measured memory_bytes: 1916
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    string s;cin >> s;
    map<char,int> mp;
    for(auto &p:s) mp[p]++;
    int ma = -1,mi = inf;
    for(auto p:{'a','b','c'}) chmax(ma,mp[p]),chmin(mi,mp[p]);
    cout << (ma-mi>1?"NO\n":"YES\n");
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

const int MAX = 3010000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  long x,y;
  cin >> x >> y;
  COMinit();
  if((x + y) % 3 != 0) cout << 0 << endl;
  else{
    long m = (x + y)/3;
    long a = x - m;
    long b = y - m;
    cout << COM(a+b,a) << endl;
  }
}

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

ll groupingRec(vector<vector<ll>> &arr, int n, int mask, vector<ll> &dp,
               vector<ll> &scores){

    if(dp[mask] != -1)
        return dp[mask];
    // Pick a non-empty subset of not chosen rabbits among 2^n possible subsets
    // and take that as one group
    ll ans = 0;
    // We only go to all the valid subsets
    // (the subsets having only not chosen elements)
    for(int group = mask; group>0; group=(group-1)&mask){
            ll currGroupScore = scores[group];
            // Mark the bits of current group as 0 in the mask
            // indicating that we have picked these elements
            ll currRecAns = groupingRec(arr, n, mask^group, dp, scores) +
                            currGroupScore;
            if(currRecAns > ans)
                ans = currRecAns;

    }
    dp[mask] = ans;
    return ans;
}

void precalculateScores(vector<vector<ll>> &arr, int n, vector<ll> &scores){

    // Store the score for every group combinations

    for(int group=0; group<(1<<n); group++){
        ll score = 0;
        for(int i=0; i<n; i++)
            if((group&(1<<i)))
                for(int j=i+1; j<n; j++)
                    if((group&(1<<j)))
                        score += arr[i][j];
        scores[group] = score;
    }
}


ll grouping(vector<vector<ll>> &arr, int n){

    // O(3^n)
    // Earlier, In the recursive function,
    // we were going to all the 2^n subsets
    // regardless of whether the elements in those subsets are available
    // to use or not
    // We denote the unused elements as '1' in the bit (instead of 0)
    // For eg: if we have mask = 00001011  (total 8 elements)
    // Here the bits at position 0, 1, 3 are set meaning we can currently
    // pick these elements and make groups (or subsets) using these elements
    // Earlier we would go to all the 2^8 subsets and check
    // if all the elements in those subsets are unused or not
    // But instead of going to all the 2^n subsets,
    // we can also directly go to all the 2^k subsets
    // (where k is the no. of set bits)
    // So in the above case, we can go to all the 2^3 subsets (instead of 2^8)
    // and that is beneficial for us because out of 2^8 subsets
    // only 2^3 subsets will be valid and we directly go to all the valid subsets

    // Consider following segment of code:

    // for(int mask=0; mask<(1<<n); mask++)
    //      for(int group=mask; group>0; group = (group-1)&mask)
    //          // Do something

    // The time complexity of this segment of code will be O(3^n)
    // Refer to: https://codeforces.com/blog/entry/45223 --> Suboptimal solution


    vector<ll> dp(1<<n, -1);
    vector<ll> scores(1<<n);
    precalculateScores(arr, n, scores);
    // Initially set all the bits (those will be unused elements)
    ll ans = groupingRec(arr, n, (1<<n)-1, dp, scores);
    return ans;
}

int main()
{
 int n;
 cin>>n;
 vector<vector<ll>> arr(n, vector<ll>(n));
 for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
        cin>>arr[i][j];
 ll ans = grouping(arr, n);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 4312
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> x >> y;

    vector<ll> done(3, 0);
    done[x - 1] = 1;
    done[y - 1] = 1;

    fo(i, 3) {
        if (!done[i]) {
            cout << i + 1;
            break;
        }
//        break;
    }


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n,k ; cin >> n >> k;
  double ans=0;
  for(int i=1; i<=n; i++){
    double act = 1.0/n;
    int now =i;
    while(now<k){
      now*=2;
      act/=2;
    }
    ans+=act;
  }
  cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, res, ans;
std::string S;

int main()
{
	in >> N >> S;
	std::vector<int>w(N + 1), e(N + 1);
	rep(i, N)
	{
		if (S[i] == 'W') w[i + 1] = 1;
		else e[i + 1] = 1;
	}
	rep(i, N)
	{
		w[i + 1] += w[i];
		e[i + 1] += e[i];
	}
	ans = 312345;
	rep(i, N)
	{
		res = w[i];
		res += e[N] - e[i + 1];
		ans = std::min(ans, res);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3076
n=int(input())
c=input()
w=c.count(".")
b=n-w
#全部黒にする場合
ans1=w
#全部白にする場合
ans2=b
"""
まずi=0とし、iを境に左にある黒の合計と右にある白の合計の最小を求める
"""
ans=ans1
tmp_b=0
tmp_w=w
for i in range(n):
    if c[i]==".":
        tmp_w-=1
    else:
        tmp_b+=1
    tmp_ans=tmp_b+tmp_w
    ans=min(ans,tmp_ans)
print(ans)

Measured memory_bytes: 9496
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
static const double PI = 3.14159265359;

int main()
{
	std::string N;
	std::cin >> N;
	for (size_t i = 0; i < N.size(); ++i) {
		if (N[i] == '7') {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
int R, C;
char grid[1005][1005];
int dist[1005][1005];
queue<pair<int, int>> q;
int main() {
    cin >> R >> C;
    
    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') q.push({i, j});
            dist[i][j] = 1e9;
            // if (grid[i][j] == '#') dist[i][j] = 0;
        }
    }
    int step = 0, ans = 0;
    while (q.size()) {
        int sz = q.size();
        while (sz--) {
            pair<int, int> f = q.front(); q.pop();
            // cout << f.fi << " " << f.se << "\n";
            if (dist[f.fi][f.se] == 1e9) {
                if (dist[f.fi + 1][f.se] == 1e9 && f.fi < R) q.push({f.fi + 1, f.se});
                if (dist[f.fi - 1][f.se] == 1e9 && f.fi > 1) q.push({f.fi - 1, f.se});
                if (dist[f.fi][f.se + 1] == 1e9 && f.se < C) q.push({f.fi, f.se + 1});
                if (dist[f.fi][f.se - 1] == 1e9 && f.se > 1) q.push({f.fi, f.se - 1});
            }
            dist[f.fi][f.se] = min(dist[f.fi][f.se], step);
        }
        step++;
    }
    // cout << step << "\n";
    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 21556
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=int(input())
b=factorization(a)
ans=0
for i in range(len(b)):
    c=b[i][1]
    check=math.floor(((-1)+math.sqrt(1+8*c))/2)
    ans=ans+check
if a==1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 63572
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,L;
  cin>>N>>L;
  vector<string> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  sort(all(vec));
  for(ll i=0;i<N;i++) {
cout<<vec[i];
  }
  cout<<endl;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    int s = 0,t = 0;
    for(int i = 0;i < n;i ++){
        if(a.at(i) % 4 == 0){
            s ++;
        }

        if(a.at(i)%2 == 1){
            t ++;
        }
    }

    int ans;

    if(s + t == n){
        if(n%2 == 0){
            if(s >= t){
                ans = 1;
            }else{
                ans = 0;
            }
        }else{
            if(t < s+2){
                ans = 1;
            }else{
                ans = 0;
            }
        }
    }else{
        if(t < s+1){
            ans = 1;
        }else{
            ans = 0;
        }
    }

    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
n,m = map(int,input().split())
s = input()
t = input()
#greatest common divisor/least common multiple
import fractions
gcd = int(fractions.gcd(n,m))
lcm = int(n*m/gcd)
counter=0
for i in range(gcd):
    if s[int(n/gcd)*i]!=t[int(m/gcd)*i]:
        print(-1)
        counter+=1
        exit()
if counter == 0:
    print(lcm)

Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define int long long
using namespace std;
int x,q,n,a[100005],f[100005],ans[100005],m;
void gao(int x,int v)
{
	if(!x) return;int t=upper_bound(a+1,a+m+1,x)-a-1;
	if(t==0) ans[1]+=v,ans[x+1]-=v;else f[t]+=(x/a[t])*v,gao(x%a[t],v);
}
main()
{
	scanf("%lld%lld",&n,&q);a[++m]=n;
	for(int i=1;i<=q;++i) {scanf("%lld",&x);while(m&&a[m]>=x) m--;a[++m]=x;}
	f[m]=1;for(int i=m;i>=2;--i) f[i-1]+=f[i]*(a[i]/a[i-1]),gao(a[i]%a[i-1],f[i]);
	ans[1]+=f[1];ans[a[1]+1]-=f[1];for(int i=2;i<=n;++i) ans[i]+=ans[i-1];
	for(int i=1;i<=n;++i) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 4096
#include <stdio.h>
 
int main (){
  int x,y,w,h,r;
 
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(((x-r)<0)||((y-r)<0)||((x+r)>w)||((y+r)>h)) printf("No\n");
  else  printf("Yes\n");
 
  return 0;
}

Measured memory_bytes: 584
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 1;
    vector<bool> prime(n+1,true);
    for(ll i=2;i<=n;++i){
        if(prime[i]==true){
            ll cnt = 0;
            for(ll j=2*i;j<=n;j+=i){
                prime[j]=false;
            }
            ll t = 1;
            while(pow(i,t)<=n){
                ll x = pow(i,t);
                cnt += (n/x);
                t++;
            }
            ans *= (cnt+1);
            ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ll long long int
#define F first
#define S second
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define REP(i,a,n) for(i=a;i<(n);i+=1)
#define REPL(i,a,n) for(i=a;i<=(n); i+=1)
#define REPr(i,n) for(i=n-1;i>=0;i-=1)

typedef vector<ll> vll;
typedef set<int>::iterator sit;
typedef unordered_set<int>::iterator usit;
typedef multiset<int>::iterator msit;
typedef unordered_multiset<int>::iterator umsit;
typedef vector<ll>::iterator vllit;

//cin.ignore(numeric_limits<streamsize>::max(),'\n');

ll MAX3(ll x , ll y, ll z){
    ll t = max(x,y);
    return max(t,z);
}

const int N = 3000 + 5;
    int dp[N][N];

void solve(){

    // int a,b;
    // cin>>a>>b;
    string s,t;
    cin>>s;
    cin>>t;
    int x = s.length();
    int y = t.length();
    int i,j;
    //dp[i][j] - The LCS if we consider the first i characters of s and first j characters of t
    REPL(i,0,y) dp[0][i]=0;
    REPL(i,0,x) dp[i][0]=0;

    REPL(i,1,x){
        REPL(j,1,y){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1] +1;
            }
            else{
                dp[i][j] = MAX3(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]);
            }
        }
    }
    int len = dp[x][y];
    string lcs;
    int num = 1;
    i=x;
    j=y;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            lcs.PB(s[i-1]);
            i=i-1;
            j=j-1;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i=i-1;
        else j = j-1;
    }
    reverse(lcs.begin(), lcs.end());
    cout<<lcs<<endl;
}

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

    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int N,M;
    cin >> N >> M;
    
    vector<int> city(N);
    vector<int> road(M*2);

    for (int i=0; i<M*2; i++) {
        cin >> road[i];
    }
    for (int i=0; i<M*2; i++) {
        debug(road[i]-1);
        city[road[i]-1]++;
    }
    for (int i=0; i<N; i++) {
        cout << city[i] << endl;
    }

}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 


#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;


signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		//2 1 3 
		//2 3 1 4 
		//2 1 4 3 5 
		//2 3 4 1 5 
		//2 3 4 5 1 6 
	int n;
	cin>>n;
	// vector<int> arr(n);
	// for(int i=0;i<n;i++)
	// {
	// 	arr[i]=i+1;
	// }
	// int maxi=0;
	// do{
	// 	int ans=0;
	// 	for(int i=1;i<=n;i++)
	// 	{
	// 		ans+=(i%arr[i-1]);
	// 	}
	// 	cout<<ans<<endl;
	// 	maxi=max(maxi,ans);
	// 	for(int i=0;i<arr.size();i++)
	// 	{
	// 		cout<<arr[i]<<" ";
	// 	}
	// 	cout<<endl;
	// }while(next_permutation(arr.begin(),arr.end()));
	int ans=(n*(n-1))/2;
	cout<<ans<<endl;
 	return 0;
}
 

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
}

Measured memory_bytes: 27208
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] f=br.readLine().split(" ");
        int n=Integer.parseInt(f[0]);
        int m=Integer.parseInt(f[1]);
        int l=Integer.parseInt(f[2]);
        int[][] A=new int[n][m];
        int[][] B=new int[m][l];
        for(int i=0;i<n;i++){
        	String[] s=br.readLine().split(" ");
        	for(int j=0;j<m;j++){
        		A[i][j]=Integer.parseInt(s[j]);
        	}
        }
        for(int i=0;i<m;i++){
        	String[] t=br.readLine().split(" ");
        	for(int j=0;j<l;j++){
        		B[i][j]=Integer.parseInt(t[j]);
        	}
        }
    	StringBuilder sb = new StringBuilder();
        for(int nc=0;nc<n;nc++){
        	for(int lc=0;lc<l;lc++){
        		long b=0;
            	for(int mc=0;mc<m;mc++){
            		b+=A[nc][mc]*B[mc][lc];
            	}
            	sb.append(b);
            	if(lc!=l-1) sb.append(" ");
        	}
        	sb.append("\n");
        }
    	System.out.print(sb);
	}
}

Measured memory_bytes: 27036
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int n;
string dic[100];
string s[100];
string input;

void dfs(int pos, string ans) {
  if (pos == input.size()) {
    cout << ans.substr(0, ans.size()-1) + "." << endl;
    return;
  }
  REP(i,n) {
    if (pos + dic[i].size() > input.size()) continue;
    if (dic[i] == input.substr(pos, dic[i].size())) {
      dfs(pos + dic[i].size(), ans + s[i] + " ");
    }
  }
}

int main() {
  int button = 2, cnt = 0;
  map<char, int> mp;
  for (char c='a'; c<='z'; ++c) {
    mp[c] = button;
    cnt++;
    if (cnt == 4 || (button != 7 && button != 9) && cnt == 3) {
      cnt = 0;
      button++;
    }
  }
  while(cin >> n, n) {
    REP(i,n) {
      cin >> s[i];
      dic[i] = "";
      FOR(it, s[i]) {
        dic[i].push_back(mp[*it]+'0');
      }
    }
    cin >> input;
    dfs(0, "");
    cout << "--" << endl;
  }
}

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

int A,B,C,X;

int main(){
  int count=0;
  cin >> A >> B >> C >> X;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k==X) count++;
      }
    }
  }
  cout << count << endl;
}

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


int main(){
	bool flag = true;
	int n, k;
	cin >> n >> k;
	char hate[k];
	for (int i = 0; i < k; ++i){
		cin >> hate[i];
	}

	for (int i = n; i <= n*10; ++i){
		flag = true;
		string target = to_string(i);
		for (int j = 0; j < k; ++j){
			if (target.find(hate[j]) != string::npos){
				flag = false;
			}
		}
		if (flag){
			cout << i << endl;
			break;
		}
	}

}

Measured memory_bytes: 256
N, X, M = map(int, input().split())
sup = 10**11
db = [[0]*M for _ in range(sup.bit_length())]
dbcum = [[0]*M for _ in range(sup.bit_length())]
db[0] = [i**2 %M for i in range(M)]
dbcum[0] = [i**2 %M for i in range(M)]
for i in range(1,sup.bit_length()):
  for j in range(M):
    db[i][j] = db[i-1][db[i-1][j]]
    dbcum[i][j] = dbcum[i-1][j]+dbcum[i-1][db[i-1][j]]
ans = X
p = 0
N -= 1
while N:
  if N%2:
    ans += dbcum[p][X]
    X = db[p][X]
  p += 1
  N >>= 1
print(ans)

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


int main() {
int n; 
  cin>>n;
  int num[n+1];
  num[0]=1000000009;
  for(int i=1;i<=n;i++){
    cin>>num[i];}
  
sort(num,num+n+1);
  vector<int> vec;
  vector<int> vec2;
  int p=num[0];
  int z=num[1];
  
  bool ss=true;
 for(int i=1;i*i<=p;i++){
   if(p%i==0){
     vec.push_back(i);
     vec.push_back(p/i);
     if(i>=2){
   ss=false;}
   }
 }
  if(ss){
    vec.push_back(p);}
  vec.push_back(1);
  
  sort(ALL(vec));
  reverse(ALL(vec));
  
  int ans1=0;
  for(int i=0;i<=vec.size();i++){
    int dc=0;
    int tt=vec[i];
    bool imp=false;
    for(int j=1;j<=n-1;j++){
      if(num[j]%tt!=0){
        dc++;}
      if(dc>=2){
        imp=true;
      break;}
    }
    
    if(imp){continue;}
    else{ans1=tt;
        break;}
  }
  
  
  
  
  bool ss2=true;
 for(int i=1;i*i<=z;i++){
   if(z%i==0){
     vec2.push_back(i);
     vec2.push_back(z/i);
     if(i>=2){
   ss2=false;}
   }
 }
  if(ss2){
    vec2.push_back(z);}
  
  sort(vec2.begin(), vec2.end());
  reverse(vec2.begin(), vec2.end());
  
  int ans2=0;
  for(int i=0;i<=vec2.size();i++){
    int dc2=0;
    int tt2=vec2[i];
    bool imp2=false;
    for(int j=1;j<=n-1;j++){
      int k;
      if(j==1){k=0;}
      else{k=j;}
        
      if(num[k]%tt2!=0){
        dc2++;}
      if(dc2>=2){
        imp2=true;
      break;}
    }
    
    if(imp2){continue;}
    else{ans2=tt2;
        break;}
  }
  
  cout<<max(ans1,ans2)<<endl;

}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
import static java.lang.System.*;
public class Main
{
public static void main(String args[])throws Exception
{
     Scanner sc=new Scanner(in);
     int n=sc.nextInt();
     int x=n*800;
     int z=n/15;
     int y=z*200;
     out.println(x-y);

 }
}

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


int main(void){
    
    string S;
    cin >> S;
    string ans = "No";
    for(int i = 0; i < S.size();i++){
        if(S[i]=='7')ans = "Yes";
    }
    
    cout << ans <<endl;
    
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(1000000)

def getGrundyNumber(x):
    ans = 1
    while x % (ans * 2) == 0:
        ans *= 2
    return ans


def dfs(iT, Hgt):
    num = 0
    for c in Trie[iT]:
        if c != -1:
            dfs(c, Hgt - 1)
            num += 1

    if num == 1:
        Hgts[Hgt - 1] = Hgts.get(Hgt - 1, 0) + 1


N, L = map(int, input().split())
Ss = [input() for i in range(N)]

# トライ木を作成する
Trie = [[-1, -1]]
for S in Ss:
    iT = 0
    for c in map(int, S):
        if Trie[iT][c] == -1:
            Trie += [[-1, -1]]
            Trie[iT][c] = len(Trie) - 1
        iT = Trie[iT][c]

# 子が１つの頂点を探す
Hgts = {}
dfs(0, L + 1)

# Grundy数のXORを求める
ans = 0
for Hgt, num in Hgts.items():
    if num % 2:
        ans ^= getGrundyNumber(Hgt)

if ans:
    print('Alice')
else:
    print('Bob')


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007
#define M 2000

bool is_matched(char x, char y)
{
    return x == y or x == '?' or y == '?';
}

void solveE()
{
    string a, b, c;
    cin >> a >> b >> c;

    int A = a.length();
    int B = b.length();
    int C = c.length();

    vector<bool> ab(M * 8, true);
    vector<bool> ac(M * 8, true);
    vector<bool> bc(M * 8, true);
    rep(i, A) rep(j, B) if (!is_matched(a[i], b[j])) ab[i - j + M * 4] = false;
    rep(i, A) rep(j, C) if (!is_matched(a[i], c[j])) ac[i - j + M * 4] = false;
    rep(i, B) rep(j, C) if (!is_matched(b[i], c[j])) bc[i - j + M * 4] = false;

    int ans = A + B + C;
    for (int i = -M * 2; i <= M * 2; i++)
        for (int j = -M * 2; j <= M * 2; j++)
            if (ab[i + M * 4] and ac[j + M * 4] and bc[j - i + M * 4])
            {
                int L = min(0, min(i, j));
                int R = max(A, max(i + B, j + C));
                ans = min(ans, R - L);
            }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int mod=1e9+7;
const int MAX=2e5+5;
int a[MAX];
int suf[MAX];
int ans=0;
int32_t main(){
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)cin>>a[i];
  suf[n+1]=0;
  for (int i=n;i>=1;i--){
    suf[i]=(suf[i+1]+a[i])%mod;
  }
  
  for (int i=1;i<=n;i++){
   ans=(ans+a[i]*suf[i+1])%mod; 
  }
  
  cout<<ans;
  return 0; 
}


Measured memory_bytes: 6736
#include<iostream>

using namespace std;
int main(){
  int H,W;
  char S[55][55];
  cin >> H >> W;
  int i,k;
  for(i=0;i<=H+1;i++)
    for(k=0;k<=W+1;k++)
      S[i][k] = '.';
  for(i=1;i<=H;i++)
    for(k=1;k<=W;k++)
      cin >> S[i][k];
  bool x = true;
  for(i=1;i<=H;i++)
    for(k=1;k<=W;k++)
      if(S[i][k]=='#' && S[i][k+1]=='.' && S[i][k-1] == '.' && S[i+1][k]=='.' && S[i-1][k]=='.')
        x = false;
  if(x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,c,k;
  cin>>n>>c>>k;
  vector<int>t(n);
  for(int i=0;i<n;i++)cin>>t[i];
  sort(t.begin(),t.end());
  int count=0;
  int bus=0;
  int tlim=0;
  for(int i=0;i<n;i++)
  {
    if(i==0)
    {
      count++;
      tlim=t[i]+k;
      continue;
    }
    if(count==c || tlim<t[i])
    {
      bus++;
      count=1;
      tlim=t[i]+k;
    }
    else count++;
  }
  cout<<bus+1<<endl;
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

const int N = 2e5+34;

pair<int, int> x[N];
int a[N];

void solve() {
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x[i].first);
        x[i].second = i;
    }
    sort(x, x+n);
    int m = n/2-1;
    for (int i = 0; i < n; ++i) {
        a[x[i].second] = i<=m ? x[m+1].first : x[m].first;
    }
    for (int i = 0; i < n; ++i) {
        printf("%d\n", a[i]);
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4608
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    val m = sc.nextLong()
    val d = sc.nextLong()
    println((if (d == 0L) 1.0 else 2.0) * (m - 1) * (n - d) / (n * n))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

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

int main(){
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a;
    cin>>a;
    cout<<k[a-1];

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,k;
    cin>>n>>k;
    int r,p,s;
    cin>>r>>s>>p;
    string st;
    cin>>st;
    string done;
    int dp[n+1][3];
    mem(dp,0);
    ffor(i,1,k+1)
    {
    	ffor(j,0,3) dp[i][j]=max({dp[i-1][1],dp[i-1][0],dp[i-1][2]});
    	if(st[i-1]=='r') { dp[i][1]+=p; done.pb('p'); }
    	else if(st[i-1]=='p')  {dp[i][2]+=s; done.pb('s'); }
    	else { dp[i][0]+=r; done.pb('r'); }
    	//cout<<max({dp[i][0],dp[i][1],dp[i][2]})<<" "<<i<<endl;
    }
    ffor(i,k+1,n+1)
    {
    	ffor(j,0,3) dp[i][j]=max({dp[i-1][1],dp[i-1][0],dp[i-1][2]});
    	if(st[i-1]=='r'&&done[i-1-k]!='p') { dp[i][1]+=p; done.pb('p'); }
    	else if(st[i-1]=='p'&&done[i-1-k]!='s') {dp[i][2]+=s; done.pb('s'); }
    	else if(st[i-1]=='s'&&done[i-1-k]!='r') { dp[i][0]+=r; done.pb('r'); }
    	else done.pb('.');
    	//cout<<max({dp[i][0],dp[i][1],dp[i][2]})<<" "<<i<<endl;
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > a(N);
  REP(i, N) {
    CIN(t);
    a[i] = t - i - 1;
  }

  sort(ALL(a));

  int center = a[N / 2];
  ll ans = 0ll;
  REP(i, N) {
    ans += abs(a[i] - center);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    if(a>=b){
      System.out.println("delicious");
    }else if((b-a)>x){
      System.out.println("dangerous");
    }else{
      System.out.println("safe");
    }

  }
  

  
}


Measured memory_bytes: 21332
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;
int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> cnt(n);
  ll cnt_sum;
  for (ll i=0;i<n;i++) {
	cin>> a.at(i);
	ll x=a.at(i);
	while (x%2 != 1) {
	  x/=2;
	  cnt.at(i)++;
	}
	cnt_sum += cnt.at(i);
  }
  cout <<cnt_sum;
}

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

using namespace std;
int n, q;
string s;
const int N = 300000;
char t[N], d[N];
int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> q;	
	cin >> s;
	for (int i = 1; i <= q; i++) {
		cin >> t[i] >> d[i];
	}
	int l = 1;
	int r = n + 1;
	while (r - l > 0) {
		int mid = (r + l) / 2;
		int x = mid;
		int fnd = 0;
		for (int j = 1; j <= q; j++) {
			if (x == 0) {
				fnd = 1;
				break;
			}
			if (x == n + 1) {
				fnd = 2;
				break;
			}
			if (t[j] == s[x - 1]) {
				if (d[j] == 'L') {
					x--;
				} else {
					x++;
				}
			}
			if (x == 0) {
				fnd = 1;
				break;
			}
			if (x == n + 1) {
				fnd = 2;
				break;
			}
		}
		if (fnd != 1) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	int li = l;
	l = 0;
	r = n;
	while (r - l > 0) {
		int mid = (r + l) / 2 + 1;
		int x = mid;
		int fnd = 0;
		for (int j = 1; j <= q; j++) {
			if (x == 0) {
				fnd = 1;
				break;
			}
			if (x == n + 1) {
				fnd = 2;
				break;
			}
			if (t[j] == s[x - 1]) {
				if (d[j] == 'L') {
					x--;
				} else {
					x++;
				}
			}
			if (x == 0) {
				fnd = 1;
				break;
			}
			if (x == n + 1) {
				fnd = 2;
				break;
			}
		}
		if (fnd != 2) {
			l = mid;
		} else {
			r = mid - 1;
		}
	}
	int ri = l;
	cerr << li << " " << ri << "\n";
	cout << ri - li + 1 << "\n";
	return 0;
}

Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, k;
    cin >> n >> k;
    vi x(n);
    vi x_copy;
    vi y(n);
    vi y_copy;
    rep(i, n)
    {
        cin >> x[i] >> y[i];
        x_copy.push_back(x[i]);
        y_copy.push_back(y[i]);
    }
    sort(all(x_copy));
    sort(all(y_copy));
    lint ans = LLONG_MAX;
    rep(x1, n - 1)
    {
        repi(x2, x1 + 1, n)
        {
            rep(y1, n - 1)
            {
                repi(y2, y1 + 1, n)
                {
                    int count = 0;
                    rep(i, n)
                    {
                        if (x_copy[x1] <= x[i] && x[i] <= x_copy[x2] && y_copy[y1] <= y[i] && y[i] <= y_copy[y2])
                        {
                            count++;
                        }
                    }
                    if (count >= k)
                    {
                        lint area = (x_copy[x2] - x_copy[x1]) * (y_copy[y2] - y_copy[y1]);
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100001
#define INF INT_MAX
using namespace std;

int n, k;
int abc[3][MAXN];
int dp[3][MAXN];

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
    	cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
    	dp[0][i] = dp[1][i] = dp[2][i] = INF;
    }
    
    dp[0][n-1] = abc[0][n-1];
    dp[1][n-1] = abc[1][n-1];
    dp[2][n-1] = abc[2][n-1];

	for(int i = n-2; i >= 0; i--){
		dp[0][i] = abc[0][i] + max(dp[1][i+1],dp[2][i+1]);
		dp[1][i] = abc[1][i] + max(dp[0][i+1],dp[2][i+1]);
		dp[2][i] = abc[2][i] + max(dp[1][i+1],dp[0][i+1]);
	}
    
    cout << max(max(dp[0][0],dp[1][0]),dp[2][0]) << "\n";
    
    return 0;
}


Measured memory_bytes: 2560