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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n, a, b, c, d;
    string road;
    cin >> n >> a >> b >> c >> d >> road;
    a--;
    b--;
    c--;
    d--;
    bool q = true;
    rep(i, a+1, c+1){
        if(road[i]=='#' && road[i-1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, b+1, d+1){
        if(road[i]=='#' && road[i-1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(c<d){
        cout << "Yes" << endl;
        return 0;
    }else{
        rep(i, b, d+1){
            if(i-1<0 || i+1>=n)continue;
        if(road[i+1]=='.' && road[i]=='.' && road[i-1]=='.'){
            cout << "Yes" << endl;
            return 0;  
        }
        }
    }
    cout << "No" << endl;
    return 0;
}

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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            char before = '.';
            int count = 0;
            var list = new List<int>();
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != before)
                {
                    before = S[i];
                    list.Add(count);
                    count = 1;
                }
                else count++;
            }

            if (count            != 0) list.Add(count);
            if ((list.Count & 1) == 0) list.Add(0);

            if (list.Count == 1)
            {
                Console.WriteLine(0);
                return;
            }

            int left = 0, right = 0;
            for (int i = 0; i < list.Count; i += 2)
            {
                right += list[i];
            }

            var counts = new List<int>();

            for (int i = 1; i < list.Count; i += 2)
            {
                right -= list[i - 1];
                counts.Add(left + right);
                left += list[i];
            }

            counts.Add(left);
            Console.WriteLine(counts.Min());
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 16736
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, k = i2()
h = intl()
h.sort()
cnt = 0
if n > k:
    for i in range(n-k):
        cnt += h[i]
    print(cnt)
else:
    print(0)

Measured memory_bytes: 25896
#include<stdio.h>
int main()
{
    int H,N,i,a,sum=0;

    scanf("%d",&H);

    scanf("%d",&N);
    for(i=1;i<=N;i++)
    {
        scanf("%d",&a);
        sum=sum+a;
    }
    if(sum<H)
        printf("\nNo");
    else printf("\nYes");
    return 0;
}


Measured memory_bytes: 1736
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

double  x[10], y[10];

int main()
{

    int n;
    while(~scanf("%d",&n))
    {
        double sum =0;
        for(int i = 0; i < n; i++)
        {

            scanf("%lf%lf",&x[i],&y[i]);
        }
        for(int i = 0; i < n; i++)
        {

            for(int j = i; j<n; j++)
            {
                double dx = x[i] - x[j];
                double dy = y[i] - y[j];

                double z = sqrt(dx*dx+dy*dy);

                sum += z*2/n;

            }
        }
        printf("%.10lf\n",sum);

    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==


const int N = 1000010;
bool isPrime[N];

void sieve(){
    for(int i=2;i<N;i++) isPrime[i] = true;
    for(int i=2;i*i<N;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<N;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    vector<int> C(N);
    sieve();
    C[0] = 0;
    for(int i=1;i<N;i++){
        if(isPrime[i]){
            C[i] = C[i-1] + 1;
        }else{
            C[i] = C[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << C[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 5952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (b - a) * (b - a + 1) / 2 - b << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Endl "\n"
#define endl "\n"
#define in(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,n) vector<int> a(n);fo(i,n)cin>>a[i];
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define eb emplace_back
#define pii pair<int,int>


void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

void solve()
{
	in(x);
	if(x>=30)cout<<"Yes\n";
	else cout<<"No\n";
}

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C;

int main(void){
    
    scanf("%d %d %d", &A, &B, &C);
    printf("%d\n", min({abs(A - B) + abs(B - C), abs(A - C) + abs(C - B), abs(B - A) + abs(A - C), abs(B - C) + abs(C - A), abs(C - A) + abs(A - B), abs(C - B) + abs(B - A)}));
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int work[3];
	cin>>work[0]>>work[1]>>work[2];
	sort(work,work+3);
	cout<<abs(work[0]-work[1])+abs(work[1]-work[2])<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;

  int ans=0;
  rep(i,n){
    if(a[i]==b[i]){
      if(b[i]!=c[i]) ans++;
    }
    else if(b[i]==c[i]) ans++;
    else if (c[i]==a[i]) ans++;
    else ans+=2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> yoko(h);
    bool map[2001][2001] = {{0}};
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            char c; cin >> c;
            if (c == '#') {
                yoko[i].push_back(j);
                map[i][j] = true;
            }
            map[h][j] = true;
        }
    }
    int lamp[h][w];
    for (int i=0; i<h; i++) {
        yoko[i].push_back(w);
        int now=-1;
        size_t len = yoko[i].size();
        for (size_t j=0; j<len; j++) {
            for (int k=now+1; k<yoko[i][j]; k++) {

                //// cerr << i << ' ' << j << ' ' << k << ' ' << yoko[i][j] << endl;
                lamp[i][k] = yoko[i][j] - now - 1; 
            }
            now = yoko[i][j];
            lamp[i][now] = 0;
        }
    }
    int best=0;
    for (int j=0; j<w; j++) {
        int cnt=0, b=0;
        for (int i=0; i<=h; i++) {
            if (map[i][j]) {
                best = max(best, b + cnt);
                cnt = b = 0;
            } else {
                cnt++;
                b = max(b, lamp[i][j]);
            }
        }
    }
    cout << best - 1 << '\n';
    return 0;
}


Measured memory_bytes: 37888
#include<iostream>
using namespace std;
int t[10000];
int n,m,a,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    for(int j=0;j<n;j++){
      if(t[j]==a){
	ans++;
	break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define ll long long
#define ar array

const int mxN=100000;
int n, M, ans[mxN];
ll dp[mxN];
vector<int> adj[mxN];
vector<ll> pre[mxN], suf[mxN];

void dfs(int u=0) {
	dp[u]=1;
  	for (int v : adj[u]) {
		adj[v].erase(find(adj[v].begin(), adj[v].end(), u));
    	dfs(v);
    	dp[u]=dp[u]*(dp[v]+1)%M;
  	}
  	ll curp=1, curs=1;
  	for (int i=0; i<(int)adj[u].size(); ++i) {
    	int to=adj[u][i], rto=adj[u][(int)adj[u].size()-i-1];
    	pre[u].push_back(curp);
	    suf[u].push_back(curs);
    	curp=curp*(dp[to]+1)%M;
    	curs=curs*(dp[rto]+1)%M;
  	}
  	reverse(suf[u].begin(), suf[u].end());
}
 
void dfs2(int u=0, int par=-1) {
  	ans[u]=dp[u];
  	for (int i=0; i<(int)adj[u].size(); ++i) {
    	int to=adj[u][i], olds=dp[u], oldto=dp[to];
    	dp[u]=pre[u][i]*suf[u][i]%M;
    	if (par!=-1)
			dp[u]=dp[u]*(dp[par]+1)%M;

    	dp[to]=dp[to]*(dp[u]+1)%M;
    	dfs2(to, u);
    	dp[u]=olds;
    	dp[to]=oldto;
  	}
}

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

	cin >> n >> M;
	for (int i=1, u, v; i<n; ++i) {
		cin >> u >> v, --u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs();
	dfs2();
	for (int i=0; i<n; ++i)
		cout << ans[i] << '\n';
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // 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 all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int A, B, N; cin >> A >> B >> N;
  int ans = 0;
  if(N >= B-1){
    N = B-1;
  }
  ans = (A*N)/B - A*(N/B);
  if(B == 1) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3636
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  ll a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c);
}

Measured memory_bytes: 256
import bisect


def factorization(n):
    arr = dict()
    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[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if not arr and n != 1:
        arr[n] = 1

    return arr


N = int(input())

tri = [i * (i + 1) // 2 for i in range(1, 50)]
ans = 0
for v in factorization(N).values():
    ans += bisect.bisect_right(tri, v)
print(ans)


Measured memory_bytes: 9508
#include <iostream>


int main()
{
    std::string str;
    std::getline(std::cin, str);
    unsigned long size = str.size();
    int cnt = 0;
    for (unsigned long i = 0; i < size /2; i++) {
        if (str[i] == 'w' || str[i] == 'i') {
            if (str[i] != str[size - 1 - i]) cnt++;
        } else {
            if (str[i] == str[size - 1 - i] || (str[size- 1 -i] == 'w' || str[size - 1 - i] == 'i')) cnt++;
        }

    }
    if (size % 2 != 0 && (str[size / 2] != 'w' && str[size / 2] != 'i')) {
        cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}



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

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

  int term = 7;
  for (int i=1; i<=k; i++) {
    term %= k;
    if (term == 0) {
      cout << i << endl;
      return 0;
    }
    term = term * 10 + 7;
  }

  cout << "-1" << endl;
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    W,H,X,Y = cin.mapInt()
    print(float(W) * float(H) * 0.5,"01"[X * 2 == W and Y * 2 == H])
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  vector<int> vec;
  for(auto ch : str) {
    vec.emplace_back(ch - '0');
  }
  long long int sum = 0;
  long long int N = vec.size();
  for(auto i = 0; i < N; i++) {
    sum += vec.at(i);
  }
  if(sum % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4504
n,d = map(int,input().split())
x = [0]*n
for i in range(n) :
    x[i] = list(map(int,input().split()))
ans = 0
for i in range(n) :
    for j in range(i+1,n) :
        a = 0
        for k in range(d) :
            a += (x[i][k] - x[j][k])**2
        a = a**0.5
        if int(a) == a :
            ans += 1
print(ans)

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

# Case : a%K = b%K = c%K = 0
nk = N // K
ans = nk * nk * nk

# Case : a%K = b%K = c%K = K/2
if K%2 == 0:
    nk = (N+K//2) // K
    ans += nk*nk*nk
print(ans)


Measured memory_bytes: 2940
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in a:
    m = m * i
    if m > 1000000000000000000:
        m = -1
        break
if 0 in a:
    print(0)
else:
    print(m)

Measured memory_bytes: 21788
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt = Counter(a)
ans = {}
for key in cnt.keys():
    v = cnt[key]
    ans[key] = v * (v-1) // 2
s = sum(list(ans.values()))
for ai in a:
    if cnt[ai] == 1:
        print(s)
    else:
        print(int(s - ans[ai] + (ans[ai] / cnt[ai]) * (cnt[ai] - 2)))

Measured memory_bytes: 30728
#!/usr/bin/env python
# coding: utf-8

# In[47]:


from collections import deque


# In[50]:


H,W = map(int, input().split())
grid = [list("#"*(W+2))]
b_cnt = 0
for _ in range(H):
    tmp = list(input())
    grid.append(["#"]+tmp+["#"])
grid.append(list("#"*(W+2)))


# In[52]:


grid[1][1] = 1
q = deque([[1,1]])
move = [
    [1,0],[-1,0],[0,1],[0,-1]
]
while q:
    x,y = q.popleft()
    for dx,dy in move:
        if grid[x+dx][y+dy] == ".":
            grid[x+dx][y+dy] = grid[x][y]+1
            q.append([x+dx,y+dy])
if grid[H][W] == ".":
    print(-1)
else:
    print((H+2)*(W+2) - sum(g.count("#") for g in grid) - grid[H][W])


# In[ ]:






Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, x;

int main(void){
    cin >> n >> x;
    vector<lli> a(n+1), p(n+1);
    a[0] = 1;
    p[0] = 1;
    for(int i = 1; i <= n; i++){
        a[i] = 2*a[i-1]+3;
        p[i] = 2*p[i-1]+1;
    }
    //cout << a[n] << " " << p[n] << endl;
    function<lli(lli N, lli X)> f = [&](lli N, lli X){
        if(N == 0){
            if(X > 0) return 1LL;
            else return 0LL;
        }
        if(X <= 1+a[N-1]) return f(N-1, X-1);
        else return p[N-1]+1LL+f(N-1, X-a[N-1]-2LL);
    };
    cout << f(n, x) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define double long double
const int N=200050;
const double pi=acos(-1.0);
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct dot{
  int x,y;
  bool operator < (const dot &c) const {
    return x<c.x;
  }
}d[N];
int lx,rx,ly,ry,mx,my,xx,yy;
int mn[N],top;
int work(int n){
  for (int i=1; i<=n; ++i){
    int l=1,r=top,mid,ans=0;
    while(l<=r){
      mid=(l+r)>>1;
      if (mn[mid]<d[i].y)
	ans=mid,l=mid+1;
      else
	r=mid-1;
    }
    if (ans==top) ++top,mn[top]=d[i].y;
    else mn[ans+1]=min(mn[ans+1],d[i].y);
  }
  return top;
}
double ans;
int main(){
  lx=gi(),ly=gi(),rx=gi(),ry=gi();
  mx=min(lx,rx),xx=max(lx,rx);
  my=min(ly,ry),yy=max(ly,ry);
  if (lx>rx) swap(lx,rx),swap(ly,ry);
  int n=gi();
  for (int i=1; i<=n; ++i){
    d[i]=(dot){gi(),gi()};
    if (d[i].x<mx||d[i].x>xx||d[i].y<my||d[i].y>yy)
      --i,--n;
  }
  sort(d+1,d+n+1);
  if (ly>ry)
    for (int i=1; i<=n; ++i)
      d[i].y=-d[i].y;
  int v=work(n);
  ans=1ll*(xx-mx+yy-my)*100;
  if (v==min(xx-mx+1,yy-my+1))
    ans+=5*pi;
  ans-=v*(20-5*pi);
  printf("%.15Lf",ans);
  return 0;
}


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

// a^n (mod) を計算する
int64_t modpow(int64_t a, int64_t n, int64_t mod) {
    int64_t res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int64_t MOD = 1e+09 + 7;

int main(){
    int64_t N,K;
    cin >> N >> K;
    vector<int64_t> num(K+1); // xの倍数の個数はnum(x)
    
    for ( int64_t i = K; i >= 1; --i){
        int64_t count;
        count = modpow( (K/i), N, MOD );
        for ( int64_t j = 2; j <= K; ++j){
            if ( i * j > K ){
                break;
            } else {
                count = count - num.at(i*j);
            }
        }
        num.at(i) = count % MOD;
    }
    int64_t res = 0;
    for ( int i = 1; i <= K; ++i){
        res =  ( res + i * num.at(i) ) % MOD;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  string s, t; cin >> s >> t;
  vector<int> start(26, -1);
  vector<int> goal(26, -1);

  bool flag = true;
  rep(i, s.length()) {
    int a = s[i] - 'a';
    int b = t[i] - 'a';

    // どちらかに既に値が入っている場合
    if(start[a]!=-1 || goal[b]!=-1) {
      if(start[a]!=b || goal[b]!=a) {
        flag = false;
      }
    } else {
      start[a] = b;
      goal[b] = a;
    }
  }

  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 916
#include <iostream>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int n,x;
signed main(){
	cin>>n>>x;
	if(x==1||x==2*n-1){
		puts("No");
		ggr;
	}
	puts("Yes");
	bool flag=false;
	int i=2,cnt=0;
	for(;cnt<n-2;i++,cnt++){
		if(i!=x)cout<<i<<endl;
		else cnt--;
	}
	cout<<1<<endl<<x<<endl<<2*n-1<<endl;
	while(i<=2*n-2){
		if(i!=x)cout<<i<<endl;
		i++;
	}
	ggr;
}

Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var b = new List<int>() { };
        if (n % 2 == 0)
        {
            for (int i = n - 1; i >= 0; i--)
            {
                if (i % 2 == 1)
                {
                    b.Add(a[i]);
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    b.Add(a[i]);
                }
            }
        }
        else
        {
            for (int i = n - 1; i >= 0; i--)
            {
                if (i % 2 == 0)
                {
                    b.Add(a[i]);
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 1)
                {
                    b.Add(a[i]);
                }
            }
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write("{0} ", b[i]);
        }
    }
}


Measured memory_bytes: 39720
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    H = list(map(int, input().split())) + [0]

    ans = 0
    change = True
    while change:
        change = False

        left = 0
        found = False
        for i in range(len(H)):
            if H[i] != 0:
                if not found:
                    found = True
                    left = i

            if H[i] == 0:
                if found:
                    ans += 1
                    change = True
                    for j in range(left, i):
                        H[j] -= 1

                    left = i + 1
                    found = False

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <stdio.h>

int N;
int A[1024];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (A[i] % 2 == 0) {
			if (!(A[i] % 3 == 0 || A[i] % 5 == 0)) {
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
int arr[26];

void solve(){
    ll x;
    cin>>x;
    ll a=x/500;
    ll b=(x%500)/5;
    cout<<(a*1000+b*5);
    
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 256
N = int(input())  # 1 <= N <= 100
b = 1 
for i in range(25):  # the limit 4 * 25 = 100
    b |= b << 4
for i in range(15):  # the limit 7 * 15 = 105
    b |= b << 7
ans = "Yes" if (b >> N) & 1 else "No"
print(ans)      

Measured memory_bytes: 2940
n = int(input())

def F(a, b):
    return max(len(str(a)), len(str(b)))

ans = 10**10
for i in range(1, int(n**(1/2))+1):
    j = n / i
    if (n/i)%1 == 0:
        j = n // i
        if ans > F(i, j):
            ans = F(i, j)
        
print(ans)

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

int main() {
  int N, i;
  string s;
  bool f = false;

  cin >> N;

  for (i = 0; i < N; i++){
    cin >> s;
    if (s == "Y") {
      f = true;
      break;
    }
  }

  if (f) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }

}

Measured memory_bytes: 256
#include<stdio.h>

int n=0,i=0;
long long lt=0,sumt=0,dt;


int main(){
	scanf("%d %lld",&n,&lt);
	int t[n+1];
	for(i=1;i<=n;i++){
		scanf("%d",&t[i]);
	}
	sumt=lt*n;

	for(i=2;i<=n;i++){
		dt=t[i]-t[i-1];
		if(dt<lt)
			sumt=sumt-lt+dt;
	}
	printf("%lld",sumt);
}

Measured memory_bytes: 896
n = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(n-2):
    subList = L[i:i+3]
    if subList[0] < subList[1] < subList[2] or subList[0] > subList[1] > subList[2]:
        count += 1
print(count)


Measured memory_bytes: 2940
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b - 3) / (a - 1) << endl;
}

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

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    
    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
//SとS.substr(i,|S|-i)(i=0~|S|-1)の最長共通接頭辞の長さを格納した配列を返す
vector<long long> Z_algorithm(string S)
{
    long long siz = S.size();
    vector<long long> ret(siz);
    long long pre = 0;
    for (long long i = 1; i < siz; i++)
    {
        //計算済みの最大共通接頭辞に完全に覆われる
        if (i + ret[i - pre] < pre + ret[pre])
            ret[i] = ret[i - pre];
        //はみ出すorそもそもかぶらない場合
        else
        {
            //覆われている部分の長さ(かぶらない場合は0)
            long long j = max(0ll, pre + ret[pre] - i);
            //愚直にチェック
            while ((i + j) < siz && S[j] == S[i + j])
                j++;
            ret[i] = j;
            //鋳型となる最大共通接頭辞を変更する
            pre = i;
        }
    }
    //先頭はイレギュラーなので別に求める
    ret[0] = siz;
    return ret;
}
int main()
{
    cout << fixed << setprecision(30);
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    loop(i, N)
    {
        string SS = S.substr(i, N - i);
        vector<ll> check = Z_algorithm(SS);
        ll siz = check.size();
        loop(j, siz)
        {
            if (check[j] <= j)
                ans = max(ans, check[j]);
        }
    }
    putout(ans);
    return 0;
}


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

int dp[2019] = {0};

int main() {
    string S;
    cin >> S;
    long long mod = 0;
    long long d = 1;
    dp[0] = 1;
    int ans = 0;
    for (int i = S.size() - 1; i >= 0; i--) {
        mod = ((S[i] - '0') * d + mod) % 2019;
        ans += dp[mod]++;
        d = (d * 10) % 2019;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define int long long
#define PI 3.14159265
int mod = 1000000009;
#define fi(i,start,end) for(int i=0; i<n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define ll long long
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
using namespace std;
template<typename T>



void debug(vector<T> x){
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<"\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve(){
    int n,x,t;
    cin>>n>>x>>t;
    int ans = 0;
    ans = n/x;
    if(n%x > 0){
        ans++;
    }
    ans = ans*t;
    cout<<ans;bye;

}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;
int main(void){
  int N;
  cin >>N;
  int h[N+1];
  for (int i=0;i<N;i++) cin >>h[i];
  h[N]=0;
  int res=0;
  bool can=false;
  while (accumulate(h,h+N,0)!=0){
    for (int i=0;i<N+1;i++){
      if (can){
        if (h[i]==0){
          res++;
          can=false;
        }else{
          h[i]-=1;
        }
      }else if(h[i]==0){
        continue;
      }else{
        h[i]-=1;
        can=true;
      }
    }
  }  
  cout <<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    int now=1;
    for(int i=0;i<N;i++) cin>>A[i];
    
    for(int i=0;i<N;i++){
        if(A[i]==now){
            now++;
        }
    }
    
    if(now==1) cout<<-1<<endl;
    else cout<<N-(now-1)<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	bool flag=false;
	int a=0,b=0,n=0,s=0,f=0;
	cin>>a;
	cin>>b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		cin>>f;
		if((s<=a&&a<f)||(s<b&&b<=f)||(a<s&&b>f)){
			flag=true;
		}
	}
	if(flag){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	
	return (0);
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int>P;
#define pb push_back
#define X first
#define Y second


int main(){
	int m,n,tx,ty;
	while(cin>>m,m){
		vector <P>M;
		vector <P>N;
		for(int i=0;i<m;i++){
			cin>>tx>>ty;
			M.pb(P(tx,ty));
		}
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>tx>>ty;
			N.pb(P(tx,ty));
		}
		N.pb(P(9999999,9999999));
		sort(N.begin(),N.end());
		
		for(int i=0;i<N.size();i++){//1000
			int flg=1;
			int x=N[i].X-M[0].X;
			int y=N[i].Y-M[0].Y;
			for(int j=0;j<M.size();j++){//200
				P p=P(M[j].X+x,M[j].Y+y);
				vector<P>::iterator it=lower_bound(N.begin(),N.end(),p);
				if(p!=(*it)){
					flg=0;
					break;
				}
			}
			if(flg){
				cout<<x<<" "<<y<<endl;
				break;
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 1212
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sz = 0, w = 0;
	for(int i = 1; i <= 100000; i++){
		sz += i;
		w = i;
		if(sz > n){
			cout << "No" << endl;
			return 0;
		}
		if(sz == n) break;
	}
	int h = 2*n/w;
	vector<set<int>> ans(h);
	int cnt = 1;
	rep(i,h){
		for(int j = i+1; j < h; j++){
			ans[i].insert(cnt);
			ans[j].insert(cnt++);
		}
	}
	cout << "Yes" << endl;
	cout << h << endl;
	rep(i,h){
		cout << w;
		for(auto p : ans[i]){
			cout << " " << p;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 10752
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int,raw_input().split())
A = [raw_input() for i in xrange(N)]
B = [raw_input() for i in xrange(M)]

for i in xrange(N - M + 1):
    for j in xrange(N - M + 1):
        same = True
        for y in xrange(M):
            for x in xrange(M):
                if A[i + y][j + x] != B[y][x]: same = False
            if not same: break
        if same:
            print "Yes"
            exit()
print "No"


Measured memory_bytes: 4392
n = int(input())
l = list(map(int,input().split()))
ans = 0
cnt = 0

for i in range(n-1):
  if l[i] >= l[i+1]:
    cnt += 1
  else:
    if ans < cnt:
      ans = cnt
    cnt = 0
if ans < cnt:
  ans = cnt
print(ans)
  

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {
	int n, c;
	cin >> n >> c;

	int cou[3][30] = {};
	int d[30][30] = {};

	REP(i, c) {
		REP(j, c) {
			scnaf("%d", &d[i][j]);
		}
	}

	REP(i, n) {
		REP(j, n){
			int a;
			scnaf("%d", &a);

			cou[(i + j + 2) % 3][a - 1]++;
		}

	}

	int ans = 0;
	ll Mcos = INT_MAX;


	REP(i, c) {
		REP(j, c) {
			if (j == i) continue;
			REP(k, c) {
				if (k == j || k == i) continue;

				ll cost = 0;

				REP(cc, c) {
					cost += 1LL * d[cc][i] * cou[0][cc];
					cost += 1LL * d[cc][j] * cou[1][cc];
					cost += 1LL * d[cc][k] * cou[2][cc];
				}

				if (Mcos > cost) Mcos = cost;
			}
		}
	}

	cout << Mcos << endl;
	return 0;
}


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

long long digitsum(long long b, long long n) {
    long long result = 0;
    while (n > 0) {
        result += n % b;
        n /= b;
    }
    return result;
}

int main() {
    long long n, s, result = LLONG_MAX;
    cin >> n >> s;
    if (n == s) {
        result = n + 1;
    } else {
        for (long long b = 2; b * b <= n; b++) {
            if (digitsum(b, n) == s) {
                result = b;
                break;
            }
        }
        for (long long i = 1; i * i <= n - s; i++) {
            if ((n - s) % i == 0) {
                if (digitsum((n - s) / i + 1, n) == s) {
                    result = min(result, (n - s) / i + 1);
                }
                if (digitsum(i + 1, n) == s) {
                    result = min(result, i + 1);
                }
            }
        }
    }
    if (result == LLONG_MAX) {
        result = -1;
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
A=deque()

def push(A,d,x):
    if d==0:
        A.appendleft(x)
    else:
        A.append(x)
    return A

def randomaccess(A,p):
    print(A[p])

def pop(A,d):
    if d==0:
        A.popleft()
    else:
        A.pop()
    return A

q=int(input())

for i in range(q):
    query=list(map(int,input().split()))

    if query[0]==0:
        A=push(A,query[1],query[2])
    elif query[0]==1:
        randomaccess(A,query[1])
    else:
        A=pop(A,query[1])


Measured memory_bytes: 21840
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        input.nextLine();
        for(int i = 0 ; i < n ; i++){
        	BigInteger a = new BigInteger(input.nextLine());
        	BigInteger b = new BigInteger(input.nextLine());
        	if(a.add(b).toString().length() <= 80){
        		System.out.println(a.add(b));
        	}else{
        		System.out.println("overflow");
        	}
        }
    }    
}

Measured memory_bytes: 16792
import itertools
import copy
h, w, k = map(int, input().split())

cs = []
for i in range(h):
    cs.append(list(input()))

# print(cs)

hpatterns = []
for i in range(h + 1):
    hpatterns += list(itertools.combinations(range(h), i))
wpatterns = []
for i in range(w + 1):
    wpatterns += list(itertools.combinations(range(w), i))

# print(hpatterns)
# print(wpatterns)

c = 0
for hpattern in hpatterns:
    for wpattern in wpatterns:
        black = 0
        cs2 = copy.deepcopy(cs)
        for pi in hpattern:
            cs2[pi] = ['' for k in range(w)]

        for pj in wpattern:
            for s in range(len(cs2)):
                # print(pj, s)
                cs2[s][pj] = ''
        # print(wpattern, hpattern, cs2)
        for s in cs2:
            black += s.count('#')

        if black == k:
            c += 1

print(c)


Measured memory_bytes: 9304
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  int k=0;
  cin >> a;
  cin >> b;
  for(int i =0; i < 3; ++i){
    if(a[i]==b[2-i]) k+=1;
  }
  if(k==3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
// さんすう
// いや〜むずい めっちゃ計算間違えた
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, X float64
	fmt.Scan(&A, &B, &X)
	if (A*B)/2 < X/A {
		l, r := .0, 90.
		for r-l > math.Pow(10, -10) {
			mid := (r + l) / 2
			s := X/A + (math.Pow(A, 2)*math.Tan(mid*math.Pi/180))/2
			if s > A*B {
				r = mid
			} else {
				l = mid
			}
		}
		fmt.Println(l)
	} else {
		l, r := .0, 90.
		for r-l > math.Pow(10, -10) { // lかrかどっちが満たしてんのかわからんくなったのでどっちでもよくなるようにしただけです
			mid := (l + r) / 2
			d := math.Sqrt(X / A * 2 * math.Tan(mid*math.Pi/180))
			if d > B {
				r = mid
			} else {
				l = mid
			}
		}
		fmt.Println(l)
	}
}


Measured memory_bytes: 512
#include <iostream>
#define endl '\n'
using namespace std;

int main()
{
    long long c = 0;
    int n,k;
    cin >> n;
    int A[n];
    for(int i = 0;i < n;i++)
    {
        cin >> k;
        A[i] = k;
    }

    for(int i = 0;i < n;i++)
    {
        if(A[i] % 2 == 0)
        {
            c += A[i]/2;
        }
        else
        {
            c += A[i]/2;
            if(i+1 < n && A[i+1] > 0)
            {
                c++;
                A[i+1] -= 1;
            }
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 640
q=int(input())
lis=[]
lq=[]
for i in range(q):
	lq.append([int(x) for x in input().split(' ')])

for i in lq:
	order=i[0]
	if order==0:
		lis.append(i[1])
	elif order==1:
		print(lis[i[1]])
	elif order==2:
		lis.pop(-1)






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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        if(a!=c){
            puts("Yes");
            return 0;
        }
    }
    if(b==c){
        if(a!=c){
            puts("Yes");
            return 0;
        }
    }
    if(a==c){
        if(b!=c){
            puts("Yes");
            return 0;
        }
    }
    
    puts("No");

    return 0;
}

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

int main(){
    int n;
    ll k;
    cin >> n >> k;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll x = 0;
    for(int i = 55; i >= 0; i--){
        ll cnt = 0;
        for(int j = 0; j < n; j++){
            if(a[j] >> i & 1) cnt++;
        }
        if(x + (1LL << i) <= k && cnt * 2 <= n) x += (1LL << i);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += x ^ a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char color = s[0];
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (color != s[i]) {
            ans++;
            color = s[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	cin >> k >> a>>b;
	for(int i=a;i<a+k&&i<=b;i++){
		if(i%k==0){
			cout<<"OK";return 0;
		}
	}
	cout<<"NG";
	
	return 0;
}

Measured memory_bytes: 3648