akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int n;
double p,dp[2][3003],ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int i,j;
	dp[0][0]=dp[1][0]=1.0;
	for(i=1;i<=n;++i){
		cin>>p;
		dp[i%2][0]=(1-p)*dp[(i+1)%2][0];
		for(j=1;j<=n;++j) dp[i%2][j]=p*dp[(i+1)%2][j-1]+(1-p)*dp[(i+1)%2][j];
	}
	for(i=n/2+1;i<=n;++i) ans+=dp[n%2][i];
	cout<<fixed<<setprecision(9)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pa pair<int,int>
#define F first
#define S second
#define maxth 9999
#define d n%3
typedef long long ll;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll MIN=0x8000000;
    ll a,b;
    if(m-n>=2019)
    {
        cout<<"0";
        return 0;
    }
    for(ll i=n; i<=m; i++)
        for(ll j=i+1; j<=m; j++)
            if(i*j%2019<MIN)
            {
                MIN=i*j%2019;
                a=i;
                b=j;
            }
    cout<<a*b%2019<<endl;
    return 0;
}




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

int h, w;
char c[100][100];
char ta[100] = {};

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			ta[j] = c[i][j];
		}
		for (int j = 0; j < w; j++) {
			cout << ta[j];
		}
		cout << endl;
		for (int j = 0; j < w; j++) {
			cout << ta[j];
		}
		cout << endl;
		for (int j = 0; j < w; j++) {
			ta[j] = 0;
		}
	}
	return 0;
}

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

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

struct Data {
	int x, y, n;
};

int w, h;
int c[51][51];
stack<Data> st;

void land_dfs(int x, int y, int n) {
	

	c[x][y] = n;

	// 島の発見中
	// 周囲8マスに島チェック

	for (int yy = -1; yy <= 1; yy++) {
		for (int xx = -1; xx <= 1; xx++) {
			if (x + xx < 0 || x + xx >(w - 1)) continue;
			if (y + yy < 0 || y + yy >(h - 1)) continue;
			if (c[x + xx][y + yy] != 1) continue;

				st.push({ x + xx, y + yy, n });

		}
	}

}

int main() {

	while (true) {
		cin >> w >> h;
		if (w == 0 &&  h == 0) break;

		int count = 0;

		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				cin >> c[x][y];
			}
		}

		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (c[x][y] == 1) {
					count++;
					st.push({ x, y, count + 1 });


					while (!st.empty()) {
						const auto d = st.top();
						st.pop();
						land_dfs(d.x, d.y, d.n);
					}
				}
			}
		}

		cout << count << endl;
	}


	return 0;
}


Measured memory_bytes: 3228
import bisect
from collections import deque
N = int(input())
A = [int(input()) for i in [0]*N]


ls = deque([A[0]])
for a in A[1:]:
	ind = bisect.bisect_left(ls,a)
	if ind == 0:
		ls.appendleft(a)
	else:
		ls[ind-1] = a

print(len(ls))






Measured memory_bytes: 8812
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    ll res=0;
    VVI a(n,vector<ll>(n)),dis(n,vector<ll>(n,INF));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>> a[i][j];
            dis[i][j]=a[i][j];
            if(i==j) dis[i][j]=dis[j][i]=0;
            res+=a[i][j];
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    res/=2;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(dis[i][j]<a[i][j]){
                cout<<-1<<endl;
                return 0;
            }
            bool flag=false;
            for(int k=0;k<n;k++){
                if(i==k || j==k) continue;
                if(dis[i][j]==dis[i][k]+dis[k][j]) flag=true;
            }
            if(flag) res-=dis[i][j];
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    if(s<="2019/04/30"){
        cout<<"Heisei"<<endl;
    }
    else cout<<"TBD"<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int H, W;
        
        sscanf(input.c_str(), "%d %d\n", &H, &W);
        
        if((H | W) == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return(0);
}



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

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

using ll = long long;
const ll mod = 998244353;

ll inv2;
ll modpow(ll a, ll b)
{
  if (b == 0)
    return 1;
  return modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod;
}

struct SegTree
{
  int n;
  vector<ll> node, lazy;

  SegTree(int sz)
  {
    n = 1;
    while (n < sz)
      n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1);
  }

  void eval(int k, int l, int r)
  {
    if (lazy[k] != 0)
    {
      (node[k] += lazy[k]) %= mod;

      if (r - l > 1)
      {
        (lazy[2 * k + 1] += lazy[k] * inv2 % mod) %= mod;
        (lazy[2 * k + 2] += lazy[k] * inv2 % mod) %= mod;
      }

      lazy[k] = 0;
    }
  }

  void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = n;
    eval(k, l, r);

    if (b <= l or r <= a)
      return;
    if (a <= l and r <= b)
    {
      (lazy[k] += (r - l) * x % mod) %= mod;
      eval(k, l, r);
    }
    else
    {
      add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
    }
  }

  ll get(int a, int b, int k = 0, int l = 0, int r = -1)
  {
    if (r < 0)
      r = n;
    if (b <= l or r <= a)
      return 0;

    eval(k, l, r);
    if (a <= l and r <= b)
      return node[k];
    ll vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return (vl + vr) % mod;
  }
};

int main()
{
  inv2 = modpow(2, mod - 2);

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

  vector<int> l(n), r(n);
  rep(i, 0, k) cin >> l[i] >> r[i];

  SegTree st(n);
  st.add(0, 1, 1);
  rep(i, 0, n)
  {
    rep(j, 0, k)
    {
      st.add(i + l[j], min(n, i + r[j] + 1), st.get(i, i + 1));
    }
  }

  cout << st.get(n - 1, n) << endl;

  // rep(i, 0, n) cout << st.get(i, i + 1) << " ";
  // // cout << endl;

  return 0;
}


Measured memory_bytes: 12960
#include <iostream>

using namespace std;

int main(){
    int s;
    cin >> s;
    bool c[1000000] = {false};
    int idx = 1;
    while(true){
        if(c[s]){
            cout << idx << endl;;
            return 0;
        }
        idx++;
        c[s] = true;
        if(s%2 == 0) s = s/2;
        else s = s*3+1;
    }
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >>N;
    int cnt=0;
    for (int i=0;i<20;i++){
        for (int k=0;k<20;k++){
            
            if ((4*i+7*k)==N){
                cout << "Yes" <<endl;
                cnt++;
                return 0;
            }
        }
    }
    if (cnt==0){
        cout << "No" <<endl;
    }
}


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

using namespace std;

int main()
{
	int n;
	double s = 0;
	vector<pair<double, double>> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		pair<double, double> x;
		cin >> x.first >> x.second;
		v.push_back(x);
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			s += sqrt(pow(v[i].first - v[j].first, 2) + pow(v[i].second - v[j].second, 2));
		}
	}

	cout << setprecision(7) << (s * 2) / n;
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto s = readln.chomp;
    auto t = readln.chomp;

    if ((s ~ s).indexOf(t) != -1)
        writeln("Yes");
    else
        writeln("No");
}

Measured memory_bytes: 2496
// 2014/07/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if(a<b && b<c){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 1124
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

int n;
int w[110];

bool compare(const int &a, const int &b)
{
	return a < b;
}

int main()
{
	scanf("%d", &n);

	int sumA = 0;
	int sumB = 0;
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(w[i]));		
		sumB = sumB + w[i];
	}

	int curDiff;
	int minDiff = -1;
	for (int t = 0 ; t < n ; t++)
	{
		sumA = sumA + w[t];
		sumB = sumB - w[t];
		curDiff = abs(sumA - sumB);
		if ((minDiff == -1) || (minDiff > curDiff))
			minDiff = curDiff;
	}
	
	printf("%d\n", minDiff);
	

	return 0;
}


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

using str = string;
using ss = stringstream;

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

    str s;cin>>s;

    int cnt=0;
    int cntmax=0;

    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')cnt++;
        else
        {
            cntmax=max(cntmax,cnt);
            cnt=0;
        }
    }

    cntmax=max(cntmax,cnt);

    cout<<cntmax<<"\n";

    return 0;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

w, a, b = map(int, input().split())
if a <= b:
    if a+w < b:
        print(b-a-w)
    else:
        print(0)
else:
    if b+w < a:
        print(a-b-w)
    else:
        print(0)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	long long mini, t,maxi = -1000000000;
	cin >> n;
	cin >> t;
	mini = t;

	for (int i = 1; i < n; i++) {
		cin >> t;
		maxi = max(maxi, t - mini);
		mini = min(mini, t);
	}
	cout << maxi << endl;
}


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

int main() {
  int a,b,c, num = 0;
  do{
    cin >> a >> b >> c;
  } while(a>b);
  for(int i = a; i <= b; i++){
    if(c%i==0)
      num++;
  }
  cout << num << "\n";
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll a;
    string s;
    cin >> a >> s;
    if(a >= 3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
      .bytes()
      .map(|c| c.expect("failed to read char") as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect();
  token.parse().ok().expect("failed to parse token")
}

fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
      0 => a,
      _ => {
          a.push(read::<T>());
          read_n_logic(n - 1, a)
      },
  }
}

fn calc(a: usize, b: usize, c: usize) -> bool {
  if a > b && b > c {
    true
  } else if c > b && b > a {
    true
  } else {
    false
  }
}

fn main() {
  let n = read::<usize>();
  let p = read_n::<usize>(n);

  let mut count = 0;

  for l in 0..n-2 {
    if calc(p[l], p[l + 1], p[l + 2]) {
      count+=1;
    }
  }

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,m;
cin>>n>>m;
map<ll,ll>rensou;
ll a,b;
for(int i=0;i<m;i++){
    cin>>a>>b;
    rensou[a]++;
    rensou[b]++;
}
for(int i=1;i<n+1;i++){
    cout<<rensou[i]<<endl;
}
}










Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#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()
{
    ll x;
    vector<ll> pows;
    // rep(i, 101)
    // {
    //     pows[i] = i * i * i * i * i;
    // }

    cin >> x;

    int l, r;
    for (ll i = 0;; i++)
    {
        pows.push_back(i * i * i * i * i);
        rep(j, i + 1)
        {
            if (pows[i] - pows[j] == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
            else if (pows[i] + pows[j] == x)
            {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  int d=0;
  rep(i,a)
    d+=c[i];
  sort(all(c));
  out((b-d)/c[0]+a);
}


Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    int res = N;
    reple(i, 0, N)
    {
        int count = 0;
        int t = i;
        while (t > 0)
        {
            count += t % 6;
            t /= 6;
        }

        t = N - i;
        while (t > 0)
        {
            count += t % 9;
            t /= 9;
        }

        chmin(res, count);
    }

    cout << res << endl;

    return 0;
}

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

int main(){
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    ve<int> l(k),r(k);
    int i = 0, cnt = 0;
    while(i<n){
        if(s[i] == 'o'){
            l[cnt] = i;
            cnt++;
            i += c;
            if(cnt == k) break;
        }
        i++;
    }
    i = 0, cnt = 0;
    reverse(s.begin(), s.end());
    while(i<n){
        if(s[i] == 'o'){
            r[k-cnt-1] = n-1-i;
            cnt++;
            i += c;
            if(cnt == k) break;
        }
        i++;
    }
    rep(i,k){
        if(l[i] == r[i]) cout << r[i]+1 << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    int maxi = 0;
    vector<string> ans;
    for(int i = 0 ; i < n ; i += 1){
        string a;
        cin >> a;
        mp[a] += 1;
        if(mp[a] == maxi){
            ans.push_back(a);
        }else if(mp[a] > maxi){
            ans.clear();
            ans.push_back(a);
            maxi = mp[a];
        }
    }
    sort(ans.begin(),ans.end());
    for(string i : ans){
        cout << i << endl;
    }
}

Measured memory_bytes: 26736
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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



int main(void) {
	long long int n, k;
	vector<long long int> u(100001, 0);
	string s;
	long long int maxi = 0;
	bool flag;
	long long int pos = 0;

	cin >> n >> k;
	cin >> s;

	if (s[0] == '0') {
		flag = false;
	}
	else {
		flag = true;
	}

	bool check;
	check = flag;
	long long int point = 1;
	FOR(i, 1, s.size()-1) {

		if (i != s.size() - 1) {
			if (check) {
				if (s[i] == '0') {
					u[pos] = point;
					pos++;
					point = 1;
					check = false;
				}
				else {
					point++;
				}
			}
			else {
				if (s[i] == '1') {
					u[pos] = point;
					pos++;
					point = 1;
					check = true;
				}
				else {
					point++;
				}
			}
		}
		else {
			if (check) {
				if (s[i] == '0') {
					u[pos] = point;
					pos++;
					point = 1;
					check = false;
				}
				else {
					u[pos] = point + 1;
					pos++;
				}
			}
			else {
				if (s[i] == '1') {
					u[pos] = point;
					pos++;
					point = 1;
					check = true;
				}
				else {
					u[pos] = point + 1;
					pos++;
				}
			}
		}

	}

	pos--;

	long long int fi = 0;
	

	point = 0;
	if (flag) {
		if (2 * k >= pos) {
			maxi = n;
		}
		else {
			FOR(i, 0, 2 * k) {
				point += u[i];
			}
			maxi = point;

			for (long long int i = 2 * k + 1; i <= pos; i += 2) {
				point -= u[fi];
				point -= u[fi + 1];
				fi += 2;
				point += u[i];
				point += u[i + 1];

				maxi = max(point, maxi);
			}
		}
	}
	else {
		if (2 * (k - 1) >= pos) {
			maxi = n;
		}
		else {
			FOR(i, 0, 2 * k - 1) {
				point += u[i];
			}
			maxi = point;

			point -= u[fi];
			fi++;
			point += u[2 * k];
			point += u[2 * k + 1];
			maxi = max(point, maxi);

			for (long long int i = 2 * k+2; i <= pos; i += 2) {
				point -= u[fi];
				point -= u[fi + 1];
				fi += 2;
				point += u[i];
				point += u[i + 1];

				maxi = max(point, maxi);
			}
		}
	}

	cout << maxi << endl;


	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int cnt, A[500010];

inline void mergeSort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    cnt += right - left;
  }
}

int main() {
  int N;
  scanf("%d", &N);
  REP(i, N) scanf("%d", A+i);
  mergeSort(0, N);
  sort(A, A + N);
  REP(i, N) {
    if (i) {
      printf(" %d", A[i]);
    } else {
      printf("%d", A[i]);
    }
  }
  printf("\n%d\n", cnt);
  return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>

int main(void){

  int a, b;
  scanf("%d %d",&a,&b);
  int i, j;
  if(a>b){
    for(i=0;i<a;i++){
      printf("%d",b);
    }
  }else{
 for(i=0;i<b;i++){
      printf("%d",a);
 }}
  

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);

	bool ok[100] = {false};
	for (int i = 0; i < K; i++) {
		int d;
		scanf("%d", &d);
		for (int t = 0; t < d; t++) {
			int A;
			scanf("%d", &A);
			ok[A - 1] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (!ok[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int main(){
	string s;cin>>s;long long n=s.size();
	long long ans=n*(n-1)/2+1;
	long long cnt[26]={0};
	for(int i=0;i<n;i++){
		cnt[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(cnt[i]==0)continue;
		ans-=(cnt[i]*(cnt[i]-1))/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void) {
    int n, *r, i = 0, min = INT_MAX, result = INT_MIN;
    scanf("%d", &n);
    r = malloc(sizeof(int) * n);
    while (i < n) {
        scanf("%d", &r[i]);
        i++;
    }
    min = r[0];
    for (i = 1; i < n; i++) {
        if (r[i] - min > result) {
            result = r[i] - min;
        }
        if (r[i] < min)
            min = r[i];
    }

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

Measured memory_bytes: 2580
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			 int sum ;
			
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int a = sc.nextInt();

			ArrayList<Integer> stateList = new ArrayList<Integer>();
					
			for (int i = 0; i < a;i ++ ){
				stateList.add(sc.nextInt());
			}
			 
			 Collections.sort(stateList);
			 
			 sum = stateList.get(a-1) - stateList.get(0);
			 
    		 // 出力
			System.out.println(sum);
		}
}


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

int main() {
  int N;
  cin >> N;
  
  string S,T;
  cin >> S >> T;
  
  for ( int i = 0; i < N; i++){
    cout << S.at(i) << T.at(i);
  }
  
  cout << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
long long f=1;
for(int i=1;i<=a;i++){
    if(i==1)f*=b;
    else f*=(b-1);
}
cout<<fixed<<setprecision(0)<<f;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		int a;
		a = n / 2;
		if (n % 2 == 0) {
			System.out.println(a * a);
		} else {
			System.out.println(a * (a + 1));
		}

	}

}


Measured memory_bytes: 23124
from collections import Counter

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = list(read().decode().rstrip().split())

c = Counter(s)
m = max(c.values())
l = sorted([k for k, v in c.items() if v == m])
print(*l)

Measured memory_bytes: 38500
s=input()
s_l=len(s)

s1=s[:s_l//2]
s2=s[s_l//2+1:]

c=1

for i in range(len(s)-1):
  if s[i]!=s[-1-i]:
    c=0

for i in range(len(s1)-1):
  if s1[i]!=s1[-1-i]:
    c=0
for i in range(len(s2)-1):
  if s2[i]!=s2[-1-i]:
    c=0

print('Yes' if c==1 else 'No')

Measured memory_bytes: 3064
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

K = int(input())
A, B = [int(x) for x in input().split()]

for n in range(A, B+1):
    if n % K == 0:
        print('OK')
        exit(0)

print('NG')


Measured memory_bytes: 9112
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b; cin>>a>>b; 
    if (a*4>=b and a*2<=b and b%2==0) printf("Yes\n");
    else printf("No\n");
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3648
N, M = map(int, input().split())
MOD = 10**9 + 7



def factorial(n,mod):
    fac = [0]*(n+1)
    fac[0] = fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
    return fac

fs = factorial(max(N,M),MOD)

if abs(N-M) >= 2:
    print(0)
    exit()
elif abs(N-M) == 1:
    print((fs[N]*fs[M])%MOD)
else:
    print((2*fs[N]**2)%MOD)



Measured memory_bytes: 6900
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;




signed main() {
 ll X;
 int A=0,B=0;
cin >> X;
for(ll i=-5000;i<5000;i++){
for(ll j=-5000;j<5000;j++){
    if(i*i*i*i*i - j*j*j*j*j == X){
        cout << i << " " << j << endl;
        return 0 ;
    }
}
}

}

Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( int val ){
	
	cout << val << endl;
}

int main( int argc , char ** argv ){
	
	int K = 0 , T = 0;
	cin >> K >> T;

	// check(K);
	vector<int> a;
	int max_point = 0;
	for(int i = 0 ; i < T ; i++){
		int buf;
		cin >> buf;
		a.push_back(buf);
		if(buf > a[max_point]) max_point = i;
	}

	int max_value = a[max_point];

	a.erase(a.begin()+ max_point);

	int other_sum = 0;
	for(auto _a : a) other_sum += _a;
	
	int result = max_value - other_sum;

	if(result <= 0) cout << 0 << endl;
	else cout << result -1 << endl;

}



Measured memory_bytes: 256
h,w = map(int,input().split())
field = [list(input()) for i in range(h)]

l = [[0]*w for i in range(h)]
r = [[0]*w for i in range(h)] 
u = [[0]*w for i in range(h)] 
d = [[0]*w for i in range(h)] 

for i in range(h):
    for j in range(w):
        if field[i][j] == "#":
            l[i][j] = 0
        
        elif j == 0:
            l[i][j] = 1
        
        else:
            l[i][j] = l[i][j-1] + 1

for i in range(h):
    for j in range(w)[::-1]:
        if field[i][j] == "#":
            r[i][j] = 0
        
        elif j == w-1:
            r[i][j] = 1
        
        else:
            r[i][j] = r[i][j+1] + 1

for j in range(w):
    for i in range(h):
        if field[i][j] == "#":
            d[i][j] = 0
        
        elif i == 0:
            d[i][j] = 1
        
        else:
            d[i][j] = d[i-1][j] + 1
    
for j in range(w):
    for i in range(h)[::-1]:
        if field[i][j] == "#":
            u[i][j] = 0
        
        elif i == h-1:
            u[i][j] = 1
        
        else:
            u[i][j] = u[i+1][j] + 1
        
max_light = 0       
for i in range(h):
    for j in range(w):
        n_light = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
        
        max_light = max(max_light,n_light)

print(max_light)

Measured memory_bytes: 309000
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).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;}

ll N;

void solve();

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

// 1 <= N <= 10^7

// ll N
// 値 \sum_{K=1}^N K× f(K) を出力せよ。
void solve(){
    ll ans=0;
    repe(i,1,N){
        ll t=N/i;
        ans+=i*t*(t+1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int n,C[10001]={},a;
  cin>>n;
  for(int i=0;i<n;i++)scanf("%d",&a),C[a]++;
  for(int i=0,cnt=0;cnt<n;i++){
    for(int j=0;j<C[i];j++){
      if(cnt)printf(" ");
      printf("%d",i),cnt++;
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int main() {
  char b;
  cin >> b;
  switch (b) {
    case 'A':
      cout << 'T' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  int n, d, x;
  cin >> n >> d >> x;
  long long int sum = 0;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    sum += 1 + (d-1)/a;
  }
  cout << sum + x;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N ;
ll dp[101][4][4][4];
ll mo = MOD;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    dp[0][0][0][0] = 1; // now,
    rep(i, N)rep(a1, 4)rep(a2, 4)rep(a3, 4) rep(b, 4){
        if(b==2 and a1 == 3 and a2 == 1            ) continue;
        if(b==2 and a1 == 1 and a2 == 3            ) continue;
        if(b==3 and a1 == 2 and a2 == 1            ) continue;
        if(b==2             and a2 == 3 and a3 == 1) continue;
        if(b==2 and a1 == 3             and a3 == 1) continue;
        
//        if(           a2 == 1 && a1 == 3 && b == 2) continue;
//        if(           a2 == 3 && a1 == 1 && b == 2) continue;
//        if(           a2 == 1 && a1 == 2 && b == 3) continue;
//        if(a3 == 1 && a2 == 3 &&  /*?*/     b == 2) continue;
//        if(a3 == 1 &&   /*?*/    a1 == 3 && b == 2) continue;
        dp[i+1][b][a1][a2] += dp[i][a1][a2][a3] %= MOD;
    }
    ll ans =0 ;
    rep(i, 4)rep(j,4)rep(k, 4) ans += dp[N][i][j][k];
    cout << ans % MOD << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int n = pint();
        int last = 0;
        int cx = 0;
        int cy = 0;
        boolean res = true;
        for(int i=0;i<n;i++) {
            int[] a = intarr();
            int t = a[0];
            int mx = a[1];
            int my = a[2];

            int dist = abs(cx - mx) + abs(cy - my);
            int diff = t - last;
            if((diff < dist) || ((dist-diff)%2 != 0)) {
                res = false;
                break;
            }

            last = t;
            cx = mx;
            cy = my;
        }
        out(res?"Yes":"No");
    }

    private int pint() throws IOException {
        return pint(rd.readLine());
    }

    private int pint(String s) {
        return Integer.parseInt(s);
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


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

A_sum = [0]
[A_sum.append(A_sum[-1]+int(a)) for a in input().split()]

score = []
for r in range(1,N+1):
    for l in range(0,r):
        score.append(A_sum[r]-A_sum[l])

ans = 0
for i in range(40,-1,-1):
    count = 0
    score_a = []
    for j in score:
        if (j & (1<<i)):
            count += 1
            score_a.append(j)
    if count >= K:
        ans += (1<<i)
        score = [i for i in score_a]

print(ans)


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  int n, k;
  cin >> n >> k;
  vi p(n);
  cin >> p;
  sort(all(p));
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += p[i];
  }
  cout << ans << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


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

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//const ll MOD = 1e+9 + 7;
//const int MAX = 10001;

int main() {

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A , B) << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int x ,z,s;
    cin>>x>>z;
    if(z<10)
        s=(x*10)+z;
    else if(z>=10&&z<100)
        s=(x*100)+z;
    else if(z==100)
        s=(x*1000)+z;
    if( (sqrt(s)-int(sqrt(s)))==0)
        cout<<"Yes";
    else cout<<"No";

       return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> v;
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(a==1){
            v.pb(b);
        }
        if(b==n){
            v.pb(a);
        }
    }
    sort(be(v));
    int maki=v.size();
    for(int i=1;i<maki;i++){
        if(v[i]==v[i-1]){
            cout << "POSSIBLE"<<endl;
            return 0;
        }
    }
    cout <<"IMPOSSIBLE"<<endl;
    return 0;
}






Measured memory_bytes: 1400