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

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

  int n = s.size();
  int64_t num = 1 << (n - 1);
  int64_t sum = 0;
  for (int64_t i = 0; i < num; ++i) {
    vector<int> part;
    part.push_back(0);
    for (int j = 0; j < n - 1; ++j) {
      if (i & (1 << j)) {
        part.push_back(j + 1);
      }
    }
    part.push_back(n);
    int64_t tmpSum = 0;
    for (int j = 0; j < part.size() - 1; ++j) {
      tmpSum += stoull(s.substr(part.at(j), part.at(j + 1) - part.at(j)));
    }
    sum += tmpSum;
  }

  cout << sum << endl;
}


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

using namespace std;

const int N = 5 * 1000 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;
const int M = 998244353;

int n, m;
long long F[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

    return true;
}

long long naive() {
    vector< vector< vector<long long> > >
        dp(n + 1, vector< vector<long long> >(3 * m + 1, vector<long long>(n + 1, 0ll)));

    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i)
        for (int s = 0; s <= 3 * m; ++s)
            for (int j = 0; j <= i; ++j)
                for (int c = 0; c <= 2 * m && c + s <= 3 * m; ++c) {
                    if (j + c % 2 > n) continue;
                    dp[i + 1][s + c][j + c % 2] += dp[i][s][j];
                    dp[i + 1][s + c][j + c % 2] %= M;
                }

    auto res = 0ll;

    for (int j = 0; j <= 2 * m && j <= n; ++j)
        res = (res + dp[n][3 * m][j]) % M;

    return res;
}

long long bpow(long long a, int n, long long M) {
    auto res = 1ll;

    for (; n > 0; n /= 2, a = a * a % M)
        if (n & 1)
            res = res * a % M;

    return res;
}

long long rev(long long x) { return bpow(x, M - 2, M); }

long long binomial(int n, int k) {
    return n < 0 || k < 0 || k > n ? 0ll : F[n] * rev(F[k] * F[n - k] % M) % M;
}

long long gay(int s, int n) {
    return s == 0 ? 1ll : binomial(s + n - 1, n - 1);
}

long long sol() {
    auto res = gay(3 * m, n);

    for (int mx = 2 * m + 1; mx <= 3 * m; ++mx) {
        auto cur = gay(3 * m - mx, n - 1) * n % M;
        res = (res + M - cur) % M;
    }

    for (int odd = m + 1; odd <= 3 * m; ++odd)
        if ((3 * m - odd) % 2 == 0) {
            auto cur = gay((3 * m - odd) / 2, n) * binomial(n, odd) % M;
            res = (res + M - cur) % M;
        }

    return res;
}

void solve() {
    F[0] = 1ll;

    for (int i = 1; i < N; ++i)
        F[i] = i * F[i - 1] % M;

    cout << sol() << endl;

    /*for (n = 2; n <= 500; ++n)
        for (m = 1; m <= 10; ++m) {
            auto r1 = sol();
            auto r2 = naive();

            if (r1 != r2) {
                cout << n << ' ' << m << " : " << r1 << ' ' << r2 << endl;
            }
        }*/
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 39296
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

using LL = long long;
using VLL = vector<LL>;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define IN_LL(v) LL v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  IN_LL(N); IN_LL(M);

  VLL X;
  REP(i, M) {
    IN_LL(x);
    X.push_back(x);
  }
  SORT(X);

  VLL diffs(X.size());
  adjacent_difference(X.cbegin(), X.cend(), diffs.begin());
  diffs[0] = 0;
  SORT(diffs);

  if (N >= M)
    OUT(0);
  else {
    LL res = 0;
    REP(i, M - (N - 1))
      res += diffs[i];
    OUT(res);
  }
  // N個の連続する範囲に分割して、各範囲の長さが最小になるようにする
  // -> N-1個の辺を使わない！

  return 0;
}


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

using dbl=double;
const dbl PI=acos(-1);
const int LOOP=50;

dbl calcAns(dbl theta,int n,vector<dbl>& r){
    dbl sum=0;
    dbl v=cos(theta);
    for(int i=0;i<n;i++){
        dbl tmp=sin(acos(v));
        sum+=0.5*r[i]*r[(i+1)%n]*tmp;
        v=v*r[i]/r[(i+2)%n];
    }
    return sum;
}
dbl calcThetaSum(dbl theta,int n,vector<dbl>& r){
    dbl v=cos(theta);
    dbl sum=0;
    // cerr<<"$$$$$$$$$$"<<endl;
    for(int i=0;i<n;i++){
        dbl tmp=acos(v);
        // cerr<<tmp<<endl;
        if(::isnan(tmp)){
            if(v<0) return 3*PI;
            else return 0;
        }
        sum+=tmp;
        v=v*r[i%n]/r[(i+2)%n];
    }
    return sum;
}
dbl solve(int n,vector<dbl> r){
    dbl lb=0;
    dbl ub=PI;
    if(calcThetaSum(PI,n,r)<2*PI) return 0;
    if(calcThetaSum(0,n,r)>2*PI) return 0;
    for(int i=0;i<LOOP;i++){
        dbl mid=0.5*(lb+ub);
        if(calcThetaSum(mid,n,r)<2*PI) lb=mid;
        else ub=mid;
    }
    // cerr<<"#"<<lb<<" "<<2*PI/6<<endl;
    // cerr<<calcThetaSum(lb,n,r)<<endl;
    // cerr<<calcAns(lb,n,r)<<endl;
    return calcAns(lb,n,r);
}
int main(){
    int n;
    cin>>n;
    vector<dbl> r(n);
    for(int i=0;i<n;i++) cin>>r[i];
    vector<int> ids(n);
    iota(ids.begin(),ids.end(),0);
    dbl res=0;
    do{
        for(int i=3;i<=n;i++){
            vector<dbl> rtmp(i);
            for(int j=0;j<i;j++){
                // cerr<<ids[j]<<" ";
                rtmp[j]=r[ids[j]];
            }
            // cerr<<endl;
            res=max(res,solve(i,rtmp));
        }
    }while(next_permutation(ids.begin(),ids.end()));
    cout<<fixed<<setprecision(10);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3636
s[1<<17],t[1<<17];a,b,c;main(d){for(;d=getchar()-10;a++)s[a+1]=s[a]+d-54;for(;d=getchar()-10;b++)t[b+1]=t[b]+d-54;for(gets(&a);~scanf("%d%d%d%d",&a,&b,&c,&d);)puts((s[b]-s[a-1]-t[d]+t[c-1])%3?"NO":"YES");}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdbool.h>
bool binarySearch(int[],int,int);
  int main(){
  int count,n,A[100000],m,z,i;
  count=0;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&z);
    if(binarySearch(A,m,z))
      count++;
  }
  printf("%d\n",count);
  return 0;
}
bool binarySearch(int *A,int n,int key){
  int mid;
  int left=0;
  int right=n;
  while(left<right){
    mid=(left+right)/2;
      if(A[mid]==key)
	return true;
      else if(key<A[mid])
	right=mid;
      else
	left=mid+1;
  }
  return false;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, w;
  cin >> n >> w;
  vll ww(n), v(n);
  for (ll i = 0; i < n; i++) cin >> ww[i] >> v[i];

  vll dp(w + 1, 0);
  vector<vll> check(1, vll(n, 0));
  for (ll i = 1; i <= w; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (ww[j] <= i && check[max(0ll, i - ww[j])][j] == 0 && dp[i] < dp[max(0ll, i - ww[j])] + v[j]) {
        dp[i] = dp[max(0ll, i - ww[j])] + v[j];
        memo = j;
      }
    }
    if (memo == -1) check.push_back(check.back());
    else {
      check.push_back(check[max(0ll, i - ww[memo])]);
      check.back()[memo] = 1;
    }
  }
  cout << dp[w] << endl;
}

Measured memory_bytes: 83376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, k;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = INF;
  for(int i = 0; i < n; ++i){
    if(i + k - 1 < n){
      ans = min(ans, x[i+k-1] - x[i] + min(abs(x[i+k-1]), abs(x[i])));
    }
  }

  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
n = int(input())
for i in range(n):
  a = int(input())
  if a in A1:
    A1[A1.index(a)] = 0
  if a in A2:
    A2[A2.index(a)] = 0
  if a in A3:
    A3[A3.index(a)] = 0

if sum(A1)==0:
  print("Yes")
elif sum(A2)==0:
  print("Yes")
elif sum(A3)==0:
  print("Yes")
elif A1[0]+A2[0]+A3[0]==0:
  print("Yes")
elif A1[1]+A2[1]+A3[1]==0:
  print("Yes")
elif A1[2]+A2[2]+A3[2]==0:
  print("Yes")
elif A1[0]+A2[1]+A3[2]==0:
  print("Yes")
elif A1[2]+A2[1]+A3[0]==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007




int main() {

	ull n;
	ull k = 0;
	ull cnt = 0;

	cin >> n;
	vector<ull>num(n);
	vector<ull>c;

	rep(i, 0, n) {
		cin >> num[i];
		if (num[i] % 2 == 0) {
			
			while (num[i] % 2 == 0) {
				num[i] /= 2;
				cnt++;
			}


		}
	}

	
	cout << cnt << endl;





	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
//komennto C+udekaijo
//conbination n!/r!(n-r)!
class UnionFind{
	public:
	vector<int> parent;
	vector<int> rank;
	vector<int> size;
	UnionFind(signed n){
		parent.reserve(n);
		rank.reserve(n);
		size.reserve(n);
		rep(i,n){
			parent[i]=i;
			rank[i]=0;
			size[i]=1;
		}
	}
	signed find(signed x){
		//keiroassyuku
		if(parent[x]==x){
			return x;
		}else{
			return parent[x]=find(parent[x]);
		}
	}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			size[y]+=size[x];
			size[x]=size[y];
			parent[x]=y;
		}else{
			size[x]+=size[y];
			size[y]=size[x];
			parent[y]=x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
	int sizeis(int x){return size[find(x)];}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,c;
	cin>>n>>m;
	vector<pair<int,int> > v(n);
	rep(i,n)cin>>v[i].first>>v[i].second;
	sort(all(v),[&](auto a,auto b){return a.first<b.first;});
	long long ans=0;
	rep(i,n)rep(j,v[i].second){
		if(m==0){
			cout<<ans<<endl;
			return 0;
		}
		m--;
		ans+=v[i].first;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N; 
  cin >> N;

  string s;
  cin >> s;

  vector<int> black(N+1, 0);
  vector<int> white(N+1, 0);

  REP(i, N){
    if(s[i] == '#') black[i+1] = 1;
    if(i != 0) black[i+1] += black[i];
  }
  REP(i, N){
    if(s[i] == '.') white[i] = 1;
  }
  RREP(i, N) white[i] += white[i+1];

  int ans = INF;
  REP(i, N+1){
    chmin(ans, black[i]+white[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716
import itertools
import numpy as np
import sys

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
num = s.find("B")

cnt = 0
ans = 0
for i in range(max(0,num-1),N):
    if s[i] == "B":
        cnt += 1
    else:
        ans += cnt

print(ans)

Measured memory_bytes: 13008
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int N;
  scanf("%d", &N);
  vector<vector<long long int> >A(N, vector<long long int>(N, 0));
  long long int sumA = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      scanf("%lld", &(A[i][j]));
      sumA += A[i][j];
    }
  }
  vector<vector<long long int> >min_dist(A);
  bool possible = true;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        if ((j == i) || (k == i)){
          continue;
        }
        if ((min_dist[j][i] + min_dist[i][k]) < min_dist[j][k]){
          possible = false;
          break;
        }else if ((min_dist[j][i] + min_dist[i][k]) == A[j][k]){
          sumA -= A[j][k];
          A[j][k] = 0;
        }
      }
      if (!possible){
        break;
      }
    }
    if (!possible){
      break;
    }    
  }
  if (!possible){
    cout << "-1";
  }else{
    cout << (sumA/2);
  }
  
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}

int n, ans;
vector<ll> a;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) {
        ans += a[i]-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public int gcd(int a, int b)
   {
      if (a == 0) {
         return b;
      }
      if (b == 0) {
         return a;
      }
      if (a == b) {
         return a;
      }
      if (a > b) {
         return gcd(a - b, b);
      }
      return gcd(a, b-a);
   }
   public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
      int a = in.nextInt();
      int b = in.nextInt();
      Main main = new Main();
      System.out.println(main.gcd(a,b));

   }
}


Measured memory_bytes: 26244
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
long long a,b[10001],x,s;
int main()
{
	cin>>a>>x;
	for(int i=1;i<=a;i++)cin>>b[i];
	sort(b+1,b+1+a);
	for(int i=a;i>=a-x+1;i--)s=s+b[i];
	cout<<s;
	return 0;
}

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

using namespace std;

string lcs(string a, string b){
  int size = (int)a.size();
  vector< vector<int> > dp(size+1, vector<int>(size+1));
  vector< vector<int> > p(size+1, vector<int>(size+1));
  for(int i=0;i<size;++i){
    for(int j=0;j<size;++j){
      if(a[i] == b[j]){
	dp[i+1][j+1] = dp[i][j] + 1;
	p[i+1][j+1] = 0;
      }else if(dp[i+1][j] < dp[i][j+1]){
	dp[i+1][j+1] = dp[i][j+1];
	p[i+1][j+1] = 1;
      }else{
	dp[i+1][j+1] = dp[i+1][j];
	p[i+1][j+1] = -1;
      }
    }
  }
  string res;
  for(int i=size, j=size;i>0 && j>0;){
    if(p[i][j] > 0) --i;
    else if(p[i][j] < 0) --j;
    else{
      res += a[i-1];
      --i;
      --j;
    }
  }
  reverse(res.begin(), res.end());
  return res;
}

main(){
  string input;
  while(cin >> input){
    string tmp = input;
    reverse(tmp.begin(), tmp.end());
    cout << lcs(input, tmp) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

g_comb_table ={}
def Comb(n, k):
    global g_comb_table
    if (n, k) in g_comb_table:
        return g_comb_table[(n, k)]
    if n == k or k == 0:
        g_comb_table[(n, k)] = 1
        return 1L
    elif k == 1:
        g_comb_table[(n, k)] = n
        return n
    g_comb_table[(n, k)] = Comb(n-1, k-1) + Comb(n-1, k)
    return g_comb_table[(n, k)]


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    input_raw = read_func().strip().split()
    v = []
    v_nums = {}
    for i in range(N):
        v.append(long(input_raw[i]))
        if v[i] in v_nums:
            v_nums[v[i]] += 1L
        else:
            v_nums[v[i]] = 1L

    v.sort(reverse = True)
##    s =[0 for i in range(N)]
##    s[0] = v[0]
##    for i in range(1, N):
##        s[i] = s[i -1] + v[i]

    max_ave_s = 0
    max_count = 0L
    sum_count = 0
    max_n = 0

    len_count = 0
    for n in range(A, B + 1):
        if v[n - 1] == v[0]:
            len_count+= 1

    if len_count == 0:
        len_count = 1

    s = 0L
    for i in range(A):
        s += v[i]
    max_ave = float(s)/A


    for n in range(A, A + len_count):
        last_num = -1
        last_num_count = 0L
        for i in range(n):
            if last_num != v[i]:
                last_num = v[i]
                last_num_count = 1L
            else:
                last_num_count += 1L
        max_count += Comb(v_nums[last_num], last_num_count)
##        if abs(ave - max_ave) <= 1e-8:
##            max_count += 1
##        elif max_ave < ave:
##            max_count = 1
##            max_ave = ave

    print "%.6f" %(max_ave)
    print max_count


if __name__ == '__main__':
    main()


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int solve(){
    vector<int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[N-1] << endl;
    return 0;
}   

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


Measured memory_bytes: 256
package main

import "fmt"

func main(){

  var N int
  fmt.Scan(&N)

  ii := make([]int, N)
    for i := 0; i < N; i++ {
        fmt.Scan(&ii[i])
    }




  result := 10000000000

  for _,i := range ii {
    // fmt.Printf("%d\n",i)
    power:= 0
    for i%2 ==0 {
      // fmt.Println(i)
      i /= 2
      power +=1
    }
    if power <= result{
      result = power
    }
  }
  fmt.Println(result)
}

// 絶対あってるけど通らない


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
long long int b,z,m,n;
int main()
{
    scanf("%lld%lld%lld",&n,&m,&b);
    if(m>=n)
    {
        printf("1\n");
        return 0;
    }
    if(m<=b)
    {
        printf("-1\n");
        return 0;
    }
    else if((n-m)%(m-b)>=1)
        z=1;
    printf("%lld\n",((n-m)/(m-b)+z)*2+1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  int count = 0;
  long sum = 0;
  long y; 
  
  for (int i = 0; i < N; i++){
    sum += A[i];
  }
  
  if (sum % 4*M) y = sum/(4*M) + 1;
  else y = sum/(4*M);
  
  for (int i = 0; i < N; i++){
    if (A[i] >= y) count++;
  }
  
  if (count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
	long long N, M;
	cin >> N >> M;

	long long ans = 0;
	if( N == 2 || M == 2 ) ;
	else if( N == 1 || M == 1 ) {
		if( N == 1 && M == 1 ) ans = 1;
		else ans = max( N, M ) - 2;
	}
	else ans = (N - 2) * (M - 2);

	cout << ans << endl;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n, k;
    cin >> n >> k;
    vi borderX, borderY;
    vec<PII> xy(n);
    rep(i,n) {
        cin >> xy[i].first >> xy[i].second;
        borderX.emplace_back(xy[i].first);
        borderY.emplace_back(xy[i].second);
    }
    sort(all(borderX));
    sort(all(borderY));

    /**
     * 境界を考える。
     * 長方形の端を l, r, u, d とし、それぞれを選ぶ。
     */

    i64 S = infll;
    i32 l, r, u, d;
    for(i32 i = 0; i < n-1; ++i) {
        for(i32 j = i+1; j < n; ++j) {
            for(i32 ii = 0; ii < n-1; ++ii) {
                for(i32 jj = ii+1; jj < n; ++jj) {
                    l = borderX[i], r = borderX[j];
                    d = borderY[ii], u = borderY[jj];
                    i32 cnt = 0;
                    for(auto p : xy) {
                        i32 x = p.first, y = p.second;
                        if(l<=x && x<=r && d<=y && y<=u) ++cnt;
                    }
                    if(cnt >= k) chmin(S, (r-l)*(u-d));
                }
            }
        }
    }

    cout << S << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int N, M;
vector<vector<P>> graph(1001);
vector<ll> dist(1001, LLONG_MAX);

// 戻り値がtrueなら負の閉路を含む
bool Bellmanford(int n = N, int start = 1){// n = 頂点数, start = 始点
    dist[start] = 0; //始点の距離は 0
    for(int i = 1; i <= n; i++){
        for(int v = 1; v <= n; v++){
            for(int k = 0; k < graph[v].size(); k++){
                ll next, cost; tie(next, cost) = graph[v][k];
                if(dist[v] != LLONG_MAX && dist[next] > dist[v] + cost){
                    dist[next] = dist[v] + cost;
                    if (i == n && next == n) return true;
                }
            }
        }
    }
    return false;
}

int main(void){
	
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; ++i){
	    int a, b, c; scanf("%d %d %d", &a, &b, &c);
	    graph[a].push_back(make_pair(b, -c)); //pair(頂点、重み)
	}
	
	if(Bellmanford()) printf("inf\n");
	else printf("%lld\n", -dist[N]);
	
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int W, a, b;
    cin >> W >> a >> b;
    int dist = abs(a - b);
    if (dist < W) {
        cout << 0 << endl;
    } else {
        cout << dist - W << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
import resource
sys.setrecursionlimit(10 ** 9)

S = input()
l = []
def dfs(n):
  if n == len(S):
    l.append("YES")
  if n < len(S):
    if S[n:n+5] == "erase":
      dfs(n+5)    
    if S[n:n+5] == "dream":
      dfs(n+5)  
    if S[n:n+6] == "eraser":
      dfs(n+6)              
    if S[n:n+7] == "dreamer":
      dfs(n+7)
dfs(0)
if len(l) == 0:
  l.append("NO")
print(l[0])    

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

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l.at(i);
    }
    int count = 1;
    int d = 0;
    for(int i=0;i<n;i++){
        d=d+l.at(i);
        if(d<=x){
            count++;
        }
        else{
            break;
        }
    }
    cout<<count;
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> l(n+1);
	for (int i = 1; i <= n; ++i) cin >> l[i];
	vector<int> bounce(n+1);
	bounce[1] = 0; 
	int count = 1;
	for (int i = 2; i <= n+1; ++i) {
		bounce[i] = bounce[i-1] + l[i-1];
		//cout << bounce[i] << '\n';
		if (bounce[i] <= x) count += 1;
	}
	cout << count << '\n';
}



Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    if i == 1:
        dp[i] = abs(h[i] - h[i - 1])
    else:
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])

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

int main(void){
    int N;
    cin >> N;

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

    sort(a.begin(), a.end());

    int maxPosition = a.at(N-1);
    int minPosition = a.at(0);

    int ans = maxPosition - minPosition;

    printf("%d", ans);
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 998244353
#define MAX 100005
using namespace std;
int v[MAX+1];
long long rsq[MAX+1];
int mp[MAX+1];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	int x,m;
	cin>>n>>x>>m;
	if(n==1)
	{
		cout<<x<<endl;
		return 0;
	}
	v[1] = x;
	mp[x] = 1;
	long long sum = v[1];
	int a=0,b=0;
	for(int i=2;;++i)
	{
		int y = (v[i-1]*1LL*v[i-1])%m;
		sum += y*1LL;
		if(i==n)
		{
			cout<<sum<<endl;
			return 0;
		}
		if(mp[y]==0)
			v[i] = y,mp[y] = i;
		else
		{
			a = mp[y];
			b = i-1;
			break;
		}
	}	
	long long ans = 0;
	for(int i=1;i<a;++i)
		ans += 1LL*v[i],--n;
	int total = b-a+1;
	for(int i=a,j=1;i<=b;++i,++j)
		rsq[j] = rsq[j-1]+1LL*v[i];
	ans += (n/total)*rsq[total];
	n %= total;
	ans += rsq[n];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4548
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>12)
    cout<<b;
    else if(a>=6 && a<=12)
    cout<<(b/2);
    else
    cout<<0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main() {
    int N; cin >> N;
    vector<int> X(N), Y(N), H(N);
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i] >> H[i];
    }
    
    for(int i = 0; i <= 100; i++){ //cx
        for(int j = 0; j <= 100; j++){ //cy
            set<ll> tmpH;
            ll tmph;
            for(int k = 0; k < N; k++){
                ll tmp = -abs(X[k]-i) - abs(Y[k]-j);
                if(H[k] == 0) continue;
                else tmpH.insert(H[k] - tmp);
            }
            //cout << i << " " << j << " " << tmpH.size() << endl;
            if(tmpH.size()!= 1)continue;
            else tmph= *tmpH.begin();
            //else {
            //    cout << i << " " << j << " " << tmph << endl;
            //    return 0;
            //}
            bool flag = true;
            for(int k = 0; k < N; k++){
                if(H[k] == 0){
                    ll tmp = -abs(X[k]-i) - abs(Y[k]-j);
                    if(tmph+tmp > 0) {
                        flag = false;
                        continue;
                    }
                }
            }
            if(!flag) continue;
            else if(flag){
                cout << i << " " << j << " " << tmph << endl;
                return 0;
            }
            
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2005, INF = 1e9 + 5;
int a[N], b[N], c[N];
bool used[N];

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

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

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }


    int ans = INF;

    for (int h = 0; h < n; h++) {

        for (int i = 0; i < n; i++) {
            c[i] = (a[i] < a[h]);
        }

        // if (k == 0) {
        //     for (int i = 0; i < n; i++)
        //         cout << c[i];
        //     cout << "\n";
        // } 

        int l = 0, r = INF;
        while (r - l > 1) {
            int p = (l + r) >> 1;

            for (int i = 0; i < n; i++) {
                b[i] = (a[i] <= p);
            }

            if (p == 5 && h == 3) {
                for (int i = 0; i < n; i++) {
                    cout << b[i];
                }
                cout << "\n";
                for (int i = 0; i < n; i++) {
                    cout << c[i];
                }
                cout << "\n";
            }

            fill(used, used + n, 0);

            int z = 0, cq = 0, y = 0, ct = k;
            for (int i = 0, j = k - 1; j < n; j++, ct++) {

                // if (p == 623690081 && a[h] == 211047202) {
                //     cout << i << " " << j << " " << ct << "\n";
                // }


                while (ct > k) {
                    ct -= !used[i];
                    i++;
                }

                if (ct < k)
                    break;

                y = max(i, y);
                z = max(i, z);

                while (y < n && c[y] == 0)
                    y++;

                if (y <= j)
                    continue;

                while (true) {
                    while (z < n && b[z] == 0)
                        z++;
                    if (z > j)
                        break;
                    used[z] = true;
                    j++;
                    cq++;
                    z++;
                    if (j >= n || y <= j)
                        break;
                }
            }

            if (cq >= q) {
                r = p;
            }
            else {
                l = p;
            }
        }

        
        if (r != INF) {
            // cout << r << " " << a[h] << " " << r - a[h] << "\n";
            ans = min(ans, r - a[h]);
        }
    }

    cout << ans;

    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, m;
    std::cin >> n >> m;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;
    std::sort(a.begin(), a.end());

    i64 l = 0, r = std::numeric_limits<i64>::max() / 3, cnt = 0;
    while (r - l > 1) {
        i64 mid = (l + r) / 2;
        i64 s = 0;
        for (int i = 0; i < n; i++) {
            int j = std::upper_bound(a.begin(), a.end(), mid - a[i]) - a.begin();
            s += n - j;
        }
        if (s >= m) l = mid;
        else {
            r = mid;
            cnt = s;
        }
    }

    std::vector<i64> ss { 0 };
    i64 ret = (m - cnt) * r;
    for (int i = 0; i < n; i++) ss.push_back(ss.back() + a[i]);
    for (int i = 0; i < n; i++) {
        int j = std::upper_bound(a.begin(), a.end(), r - a[i]) - a.begin();
        ret += ss[n] - ss[j] + (n - j) * a[i];
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string a,b,c,d;
    cin>>a>>b>>c;
    d=a[0]-32;
    d+=b[0]-32;
    d+=c[0]-32;
    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	s := scanString()
	if s[0] == s[1] && s[0] == s[2] {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}

}


Measured memory_bytes: 640
// Problem : E - Divisible Substring
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000000007;
int abst(int a)
{return a<0?-a:a;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
//create(tree,node,a,start,end)
//query(tree,node,start,end,l,r)
//update(tree,node,start,end,index,value)
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,pr;cin>>n>>pr;
string s;cin>>s;
if(pr==2)
{
	int ans=0;
	for(int i=0;i<n;i++)
	if((s[i]-'0')%2==0)
	ans+=i+1;
	cout<<ans;
}
else if(pr==5)
{
	int ans=0;
	for(int i=0;i<n;i++)
	if((s[i]-'0')%5==0)
	ans+=i+1;
	cout<<ans;
}
else
{
	map<int,int> mp;
	mp[0]++;
	int sum=0,p=0,ans=0;
	md=pr;
	for(int i=n-1;i>=0;i--)
	{
		sum=(sum+(s[i]-'0')*Pow(10,p))%pr;
  ans+=mp[sum];
  mp[sum]++;
  p++;	
	}
	cout<<ans;
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 1044
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    int m = 0;
    rep(i, n) {
        if (a[i] < m) {
            ans += m - a[i];
        }
        else m = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4772
# 再帰回数の制限緩和.
import sys
sys.setrecursionlimit(10**6)
# dfs
def dfs(s):
    ## もしsがnより大きければ、0を返す.
    if int(s)>n: return 0
    ## そうでなければ、以下を行う.
    ## cに3,5,7が一つ以上あれば、カウントは1, そうでなければ0.
    cnt = 1 if all(s.count(c) for c in '753') else 0
    ## sに対して、3,5,7を末尾に足す.
    for c in '753':
        ### s+cについてカウントを足す.
        cnt += dfs(s+c)
    return cnt

n = int(input())
print(dfs('0'))

Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx=tx-sx,dy=ty-sy;
    for(int i=0; i<dy; i++) cout << 'U';
    for(int i=0; i<dx; i++) cout << 'R';
    for(int i=0; i<dy; i++) cout << 'D';
    for(int i=0; i<dx; i++) cout << 'L';
    cout << 'L';
    for(int i=0; i<dy+1; i++) cout << 'U';
    for(int i=0; i<dx+1; i++) cout << 'R';
    cout << 'D';
    cout << 'R';
    for(int i=0; i<dy+1; i++) cout << 'D';
    for(int i=0; i<dx+1; i++) cout << 'L';
    cout << 'U' << endl;



}


Measured memory_bytes: 256
#include <stdio.h>

#define N 101

int check(int s,int d,int v);

int root[N][N]; /* rooter path */
int distance[N]; /* already visited flag */

int main(){
    int n,r,k,t;
    int p,s,d,v;
    int i,j;
    char c;
    int ans;

    /* init root */
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            root[i][j]=0;
        }
    }

    /* input */
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&r);
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&t);
            root[r][j] = t;
        }
    }


    scanf("%d",&p);
    for(i=0;i<p;i++){
        scanf("%d %d %d",&s,&d,&v);
        ans = check(s,d,v);
        printf(ans?"%d\n":"NA\n",ans);
    }
    return 0;
}
  
  
int check(int s,int d,int v){
    int i,dis,id,nextid;

    for(i=0;i<N;i++)distance[i]=0;

    distance[s]=1;

    for(dis=1;dis<v;dis++){
        for(id=0;id<N;id++){
            if(distance[id]==dis){
                for(i=0;root[id][i]>0;i++){
                    nextid=root[id][i];
                    if(distance[nextid]==0){
                        distance[nextid]=dis+1;
                    }
                }
            }
        }
    }

    return distance[d];
}

Measured memory_bytes: 1784
n = int(input())
x_arr = []
y_arr = []

for i in range(n):
  a = int(input())
  x = []
  y = []
  for j in range(a):
    tmp1,tmp2 = map(int,input().split())
    x.append(tmp1)
    y.append(tmp2)
    
  x_arr.append(x)
  y_arr.append(y)

ans = 0
for i in range(2 ** n):
  
  flag3 = True
  bin_str = format(i,'b').zfill(n)
  array = [-1] * (n+1)
  for k in range(len(bin_str)):
    if (array[k+1] != -1) and (int(bin_str[k]) != array[k+1]):
      flag3 = False
      break
    
    if bin_str[k] == '0':
      array[k+1] = 0
      continue
    else:
      array[k+1] = 1
      

    x = x_arr[k]
    y = y_arr[k]
    
    flag2 = True
    for j in range(len(x)):
      flag = True
      tmp1 = x[j]
      tmp2 = y[j]
      if array[tmp1] == -1:
        array[tmp1] = tmp2
      elif array[tmp1] != tmp2:
        flag = False
      else:
        pass
      
      if not flag:
        flag2 = False
        break
        
    if not flag2:
      flag3 = False
      break
    
  if not flag3:
    continue
    
  ans = max(ans, len(bin_str.replace('0','')))
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
char base[N][N];
int dist[N][N];
int Move[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int main()
{
	int n,m;
	scanf("%i %i",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",base[i]+1);
	queue<int> q;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(base[i][j]=='#') q.push(i*N+j);
	int ans;
	while(q.size())
	{
		int x=q.front()/N;
		int y=q.front()%N;
		q.pop();
		ans=dist[x][y];
		for(int i=0;i<4;i++)
		{
			int nx=x+Move[i][0];
			int ny=y+Move[i][1];
			if(base[nx][ny]=='.' && !dist[nx][ny]) dist[nx][ny]=dist[x][y]+1,q.push(nx*N+ny);
		}
	}
	printf("%i\n",ans);
	return 0;
}

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

int main() {
	int64_t n; cin >> n;
	int64_t a, b; cin >> a >> b;
	if(a + b - 1 > n) {
		cout << -1 << '\n';
		return 0;
	}
	if(a * b < n) {
		cout << -1 << '\n';
		return 0;
	}
	vector<int> ans;
	ans.reserve(n);
	for(int i = b; i >= 1; --i) {
		ans.push_back(i);
	}
	int64_t res = n - b - (a - 1);
	int64_t now = b + 1;
	for(int i = 1; i < a; ++i) {
		int u = now + min<int64_t>(res, b - 1);
		for(int j = u; j >= now; --j) {
			ans.push_back(j);
		}
		now = u + 1;
		res -= min<int64_t>(res, b - 1);
	}
	for(int i = 0; i < n; ++i) {
		cout << ans[i] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
signed main(void)
{
    int k;
    scanf("%d", &k);
    if (k % 2 == 0)
    {
        cout << "-1";
        return 0;
    }
    int x = 7 % k;
    for (int i = 1; i <= k; i++)
    {
        if (x == 0)
        {
            cout << i << endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    string S, T;
    cin >> S >> T;
    if (S.length() + 1 != T.length()) {
        cout << "No" << endl;
    }
    else {
        REP(i, S.length()) {
            if (S[i] != T[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	r := nextFloat(sc)

	x := r * r * math.Pi
	y := r * 2 * math.Pi
	fmt.Printf("%f %f\n", x, y)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextFloat(sc *bufio.Scanner) float64 {
	f, err := strconv.ParseFloat(nextString(sc), 64)
	if err != nil {
		panic(err)
	}
	return f
}



Measured memory_bytes: 1116