akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;
int main(){
    long int N;
   // int K=10000000;
    //rep(k,K){
    //N=k+1;
    cin>>N;
    long int order=(long int)ceil(log(N)/log(26));
    if(N==1)order=1;
   // cout <<order;
    vector<long int> ans(order);
    long int temp=N;
    string list[26]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    for(int i=order-1;i>=0;i--){
        ans.at(i)=(long int)temp/pow(26,i);
    //    cout <<fixed<<temp<<" "<<ans.at(i)<<"    "<<pow(26,i)<<endl;
        temp=temp-(long int)pow(26,i)*ans.at(i);
    }
    rep(i,order-1){
        if(ans.at(i)<=0){
            ans.at(i)+=26;
            ans.at(i+1)--;
        }
    }
    if(ans.at(order-1)==0){
        order--;
    }

    string a="";
    for(int i=order-1;i>=0;i--){
      //  cout<<a<<endl;
        a=a+list[ans.at(i)-1];
    }
    cout <<a<<endl;
    //}
    return 0;
}


Measured memory_bytes: 4132
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main() {

	int n;
	cin >> n;

	long long int t, a;
	cin >> t >> a;

	t *= 1000LL;
	a *= 1000LL;

	vector<long long int> h(n);

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

	vector<long long int> x2(n);
	vector<P> aa(n);
	for (long long int i = 0; i < n; i++) {
		x2[i] = t - h[i] * 6LL;
		//cout << x2[i] << endl;
		aa[i] = P(abs(a - x2[i]), i);
	}

	sort(aa.begin(), aa.end());
	cout << aa[0].second + 1LL << endl;

	return 0;
}

Measured memory_bytes: 384
from itertools import accumulate
Q = int(input())

def prime(n):
    # 素数列挙
    # nまでの素数をリストで返す(nを含む)
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

prime_set = set(prime(10**5))
ans = []

for i in range(10**5+1):
    if i%2 == 0:
        ans.append(0)
    else:
        if i in prime_set and (i+1)//2 in prime_set:
            ans.append(1)
        else:
            ans.append(0)
ans = list(accumulate(ans))

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l-1])

Measured memory_bytes: 14440
s = input()
num = len(s)
ans = 0
stack = []
for i in range(num//2):
  stack.append(s[i])
if num % 2 == 0:
  t = num//2
else:
  t = num//2 + 1
for i in range(t, num):
  k = stack.pop()
  if k != s[i]:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll A, B, C, K;
  std::cin >> A >> B >> C >> K;

  ll ans = A - B;
  if (K % 2 == 1) {
    ans = B - A;
  }

  if (std::fabs(ans) >= 1e18) {
    std::cout << "Unfair" << std::endl;
  } else {
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
c = list(map(int, input().split()))

R = {}
for a, b in ab:
  if a - 1 in R:
    R[a - 1].append(b - 1)
  else:
    R[a - 1] = [b - 1]
  if b - 1 in R:
    R[b - 1].append(a - 1)
  else:
    R[b - 1] = [a - 1]

L = [0] * N
L[0] = 1
F = []
RL = {}
RL[1] = [0]
RL[2] = []
for i in R[0]:
  F.append(i)
  L[i] = 2
  RL[2].append(i)

k = 2
while F != []:
  k += 1
  Ft = []
  RL[k] = []
  for i in F:
    for j in R[i]:
      if L[j] == 0:
        L[j] = k
        Ft.append(j)
        RL[k].append(j)
  F = Ft

Ans = [0] * N
c.sort()
cnt = 0
for i in range(k - 1, 0, -1):
  for j in RL[i]:
    Ans[j] = c[cnt]
    cnt += 1
print(sum(c) - max(c))
s = str(Ans[0])
for i in range(1, N):
  s += " " + str(Ans[i])
print(s)

Measured memory_bytes: 142596
#include<bits/stdc++.h>
using namespace std;
int a[405];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    int diff = 'A' - 'a';
    //cout << diff <<endl;
    cout << char(s1[0]+diff) << char(s2[0] +diff) << char(s3[0] + diff) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N, T, A; cin >> N >> T >> A;

    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    int min = 1000000;
    int ans = -1;
    for (int i = 0; i < N; i++) {
        int a = abs(1000 * A - (1000 * T - H[i] * 6));
        if (min > a) {
            min = a;
            ans = i;
        }
    }

    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


A = [
    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
]

print(A[int(input()) - 1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
ll int gcd (ll int a,ll int b) { return b ? gcd (b, a % b) : a; }

int main()
{
	string s,t;
	cin>>s>>t;
	int res=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s.at(i)!=t.at(i))
			res++;
	}
	cout<<res;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,i,m,j,x,y,a[105];
	cin >> x >> n;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}

	sort(a,a+n);
	int fl = -1;
	for(i=0;i<n;i++)
	{
		if(a[i] == x)
		{
			fl = i;
			break;
		}
	}
	
	if(fl == -1)
	{
		cout << x;
		return 0;
	}

	int l = a[0]-1, r = a[n-1]+1;
	for(i=fl;i>=0;i--)
	{
		if(a[i] != a[fl] - (fl-i))
		{
			l = a[fl] - (fl-i);
			break;
		}
	}

	for(i=fl;i<n;i++)
	{
		// cout << i << " " << a[i] << endl;
		if(a[i] != a[fl] + (i-fl))
		{
			r = a[fl] + (i-fl);
			break;
		}
	}
	// cout << r;
	if(x - l <= r - x )
	{
		cout << l ;
	}
	else
	{
		cout << r;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N, M; cin >>N>>M;

    ll ans = 0;
    ans = min(N, M/2);
    ans += (M - 2 * ans) / 4;
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/local/bin/python3

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

N = int(input()) - 1

ans = 0
left = 1
while True:
    right = N // left
    if right < left:
        break
    # print(f"{left}×({left}〜{right})")
    ans += right - (left - 1)
    left += 1

last_left = left -1
ans = (ans - last_left)*2 + last_left

print(ans)


Measured memory_bytes: 9212
# A_i should be min(B_(i-1), B_i)
N = int(input())
B = [int(i) for i in input().split()]
maximal = B[0]
for i in range(1, N-1):
    maximal += min(B[i], B[i-1])
maximal += B[-1]
print(maximal)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  string str;
  cin >> str;
  ll sum = 0;
  vector<int> vec(26, 0);
  for(int i=0; i<n; i++){
    vec[str[i]-'a']++;
    ll mul = 1;
    for(int j=0; j<26; j++){
      if(j==str[i]-'a') continue;
      mul *= vec[j]+1;
      mul %= 1000000007;
    }
    sum += mul;
    sum %= 1000000007;
  }
  cout << sum << endl;
  return 0;
}
      


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
    int64_t H;
    cin >> H;
    int64_t count = 0;
    for(int i = 0, n = static_cast<int>(floor(log2(H))); i <= n; ++i){
        count += 1L << i;
    }
    cout << count << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
  cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int suma=0,sumb=0;
  for (int i=0;i<N;i++){
  if (i%2==0){
  suma+=a.at(i);
  }
  else {
  sumb+=a.at(i);
  }
  }
  cout << suma - sumb << endl;
}

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

#define MAX 200000
#define S 2000000000
typedef long long llong;


int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int l, int m, int r) {
    int i, j, k;
     llong cnt = 0;
     int n1 = m - l;
     int n2 = r-m;
    
     for ( i = 0; i < n1; i++ )
                  L[i] = A[l + i];
     for ( i = 0; i < n2; i++ )
                 R[i] = A[m+ i];
    
     L[n1] = R[n2] = S;
      i = j = 0;
      for ( k = l; k < r; k++ ) {
          if ( L[i] <= R[j] ){
               A[k] = L[i++];
          }
          else {
                 A[k] = R[j++];
                 cnt += n1 - i;  
               }
      }
     return cnt;
 }

llong mergeSort(int A[], int n, int l, int r) {
     int mid;
     llong v1, v2, v3;
     if (l+1<r) {
         mid =(l + r)/2;
         v1 = mergeSort(A, n, l, mid);
         v2 = mergeSort(A, n, mid, r);
         v3 = merge(A, n, l, mid, r);
         return v1 + v2 + v3;
     }   
     else return 0;
}

int main(){
    int A[MAX], n, i;
    cin >> n;

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

    llong ans = mergeSort( A, n, 0, n );
    cout << ans << endl;    
    return 0;
}
         





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

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

    if (d == 25) { cout << "Christmas" << endl;}
    else if (d == 24) { cout << "Christmas Eve" << endl;}
    else if (d == 23) { cout << "Christmas Eve Eve" << endl;}
    else if (d == 22) { cout << "Christmas Eve Eve Eve" << endl;}

}

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

#define N 100
int a[11];
int ans = -1000000000;
int f[N][10];
int p[N][11];
int n;

void func(){
    int score = 0;
    int count = 0;
    int count_zero = 0;
    for(int i = 0; i < 10; i++){
        if(a[i] == 0){
            count_zero++;
        }
    }
    if(count_zero == 10){
        return;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            if(a[j] == f[i][j] && a[j] == 1){
                count++;
            }
        }
        
        score += p[i][count];
        //cout << p[i][count] << endl;
        count = 0;
    }

    ans = max(score, ans);
    return;
}

void dfs(int pos){
    if(pos == 10){
        func();
        return;
    }
    a[pos] = 0; dfs(pos+1);
    a[pos] = 1; dfs(pos+1);
}

int main(){
   
    cin >> n;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }

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

    dfs(0);

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String s = sc.next();
      char c1;
      char c2;
      int count = 0;

      for (int i = 0;i<s.length()/2 ;i++ ) {

        c1 = s.charAt(i);
        c2 = s.charAt(s.length()-i-1);

        if(c1==c2){
          continue;
        }else{
          count++;
        }

      }
        System.out.println(count);


  }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> S;
    ll x = 0;
    REP(i, N) {
        if (S[i] == 'I') {
            x++;
        } else {
            x--;
        }
        chmax(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int loop=0;
int loop2=0;

VI bit;
int n;
// sum of[0..i]
ll sum(ll i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i -= i & -i;
    }
    return s;
}

void add(ll i,ll x){
    while(i<=n){
        bit[i]+=x;
        i += i & -i;
    }
}



int main(){
  int i,j;
  cin>>n;
  int a[n],b[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    cin>>b[i];
  }
  int ans=inf;
  for(int l=0;l<(1<<n);l++){
    vector<P> v0,v1;
    for(i=0;i<n;i++){
      if(((l>>i)&1)==1){
        if(i%2==0) v0.pb(P(a[i],i));
        else v1.pb(P(a[i],i));
      }
      else {
        if(i%2==0) v1.pb(P(b[i],i));
        else v0.pb(P(b[i],i));
      }
    }
    if(v1.size()!=n/2) continue;

    loop2++;

    sort(v0.begin(),v0.end());
    sort(v1.begin(),v1.end());

    vector<P> v(n);
    for(i=0;i*2<=n;i++){
      if(i<v0.size()) v[2*i]=v0[i];
      if(i<v1.size()) v[2*i+1]=v1[i];
    }
    bool ng=0;
    for(i=1;i<n;i++){
      if(v[i-1].fi>v[i].fi) {
        ng=1;
        break;
      }
    }
    if(ng) continue;

    loop++;

   
    bit=VI(n+1,0);
    int cnt=0;
    for(i=0;i<n;i++){
      cnt+=i-sum(1+v[i].se);
      add(1+v[i].se,1);
    }
    ans=min(ans,cnt);
    

  }
  if(ans!=inf) cout<<ans<<endl;
  else cout<<-1<<endl;
  //cout<<loop<<endl;
  //cout<<loop2<<endl;

  return 0;
}


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

using namespace std;

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")


int vec[900006];

int main(){

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

   int n;
   cin >> n;
   int x;
   for(int i=1; i<n; i++){
       cin >> x;
       vec[x]++;
   }

   for(int i=1; i<=n; i++)
      cout<<vec[i]<<endl;



    return 0;
}

Measured memory_bytes: 4356
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 10;

vector<int> g[N];
bool mark[N];

int dfs(int v) {
  mark[v] = true;
  int ans = 0;
  for (int u : g[v]) {
    if (mark[u]) {
      continue;
    }
    ans += dfs(u);
  }
  ++ans;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark[i] == false) {
      ans = max(ans, dfs(i));
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 24112
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		for (int i=0;i<N;i++){
			p[i]=sc.nextInt();
		}
		Arrays.sort(p);
		p[N-1]/=2;

		int sum=0;
		for (int i=0;i<N;i++){
			sum+=p[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int n;
  cin >> n;

  vector<int> a(n);
  REP(i, n) cin >> a[i];
  
  int b[n];
  if(n%2==0){
    REP(i,n/2){
      b[i+n/2]=a[i*2];
    }
    REP(i,n/2){
      b[i]=a[n-i*2-1];
    }
  }else{
    REP(i,n/2){
      b[i+n/2+1]=a[i*2+1];
    }
    REP(i,n/2+1){
      b[i]=a[n-i*2-1];
    }
  }
  REP(i,n){
    cout << b[i];
    if(i!=n-1){
      cout << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;

int main(){
  int N; cin >> N;
  vector<ld> X(N), Y(N);
  rep(i, N) cin >> X[i] >> Y[i];

  auto radius = [&](ld x, ld y){
    ld cmax = -1;
    rep(i, N){
      ld r = sqrt(pow(x - X[i], 2) + pow(y - Y[i], 2));
      if (r > cmax) cmax = r;
    }
    return cmax;
  };

  ld min_x = *min_element(ALL(X));
  ld max_x = *max_element(ALL(X));
  ld min_y = *min_element(ALL(Y));
  ld max_y = *max_element(ALL(Y));

  auto f = [&](ld x){
    ld yl = min_y;
    ld yr = max_y;
    ld gl = radius(x, yl);
    ld gr = radius(x, yr);
    while (abs(yl - yr) > EPS) {
      ld ym1 = (2*yl + yr) / 3;
      ld ym2 = (yl + 2*yr) / 3;
      ld gm1 = radius(x, ym1);
      ld gm2 = radius(x, ym2);
      if (gm1 > gm2) {
        yl = ym1;
        gl = gm1;
      }
      else {
        yr = ym2;
        gr = gm2;
      }
    }
    return (gl + gr) / 2;
  };

  ld xl = min_x;
  ld xr = max_x;
  ld fl = f(xl);
  ld fr = f(xr);
  while (abs(xl - xr) > EPS * 10) {
    ld xm1 = (2*xl + xr) / 3;
    ld xm2 = (xl + 2*xr) / 3;
    ld fm1 = f(xm1);
    ld fm2 = f(xm2);
    if (fm1 > fm2) {
      xl = xm1;
      fl = fm1;
    }
    else {
      xr = xm2;
      fr = fm2;
    }
  }
  ld ans = (fl + fr) / 2;

  cout << setprecision(10);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x;
	cin >> x;
	int cnt = 0;
	int a = 0;
	while (1)
	{
		a += x;
		cnt++;
		if (a % 360==0)
			break;
		if (a > 360)
			a -= 360;
	}
	cout << cnt << endl;
} 

Measured memory_bytes: 3552
#include<iostream>
#include<set>
#include<math.h>
using namespace std;
#define N 100010
#define MAX 450
int n;
bool can;
set<int> S[MAX];
set<int>::iterator it;
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        can=false;
        int k;//分成k个集合 每个集合k-1个元素
        for(int i=1;i<=sqrt(2*n);i++)
        {
            if(i*(i+1)==2*n)
            {
                k=i+1;
                can=true;
                break;
            }
        }
        if(!can)
        {
            cout<<"No"<<endl;
            continue;
        }
        else
        {
            //构造集合输出...
            cout<<"Yes"<<endl;
            cout<<k<<endl;//k个集合
            for(int i=1;i<=k;i++) S[i].clear();
            int cnt=1;
            for(int i=1;i<=k;i++)
            {
                for(int j=i+1;j<=k;j++)
                {
                    S[i].insert(cnt);
                    S[j].insert(cnt);
                    cnt++;
                }//边添加边输出 也可以全部添加完毕后输出
                cout<<S[i].size();
                for(it=S[i].begin();it!=S[i].end();it++)
                {
                    cout<<" "<<*it;
                }
                cout<<endl;
            }
        }
    }
    
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

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

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

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

int n , cnt = 0 , gcd = 0 ;

int main() {


   cin >> n ;
   vector < int > a( n ) ;
   forn( int , i , 0 , n ){
       cin >> a[ i ] ;
       gcd += a[ i ] % 2 == 0 ;
   }



   while( gcd == n ){
      gcd = 0 ;
      for( int i = 0 ; i < n ; i++ ){
         if( a[ i ] % 2 == 0 ){
            a[ i ] /= 2 ;
         }
         if( a[ i ] % 2 == 0 ) gcd++ ;
      }
      cnt++ ;
   }


   cout << cnt << "\n" ;




   return 0 ;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int maxBit = -1;
    vector<bool> onBit(20, false);
    int x = l;
    while(x > 0){
        onBit[++maxBit] = x % 2 == 1;
        x /= 2;
    }

    vector<tuple<int, int, int>> edge;
    rep(i, maxBit){
        edge.emplace_back(i+1, i+2, pow(2, maxBit - 1 - i));
        edge.emplace_back(i+1, i+2, 0);
    }

    int sum = pow(2, maxBit);
    for(int i = maxBit - 1; i >= 0; i--){
        if(not onBit[i]){
            continue;
        }
        edge.emplace_back(1, maxBit - i + 1, sum);
        sum += pow(2, i);
    }

    cout << maxBit + 1 << " " << edge.size() << endl;
    rep(i, (int)edge.size()){
        cout << get<0>(edge[i]) << " " << get<1>(edge[i]) << " " << get<2>(edge[i]) << endl;
    }

    return 0;
}


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

int main() {
	
	int n = 0;
	int a = 0;
	int b = 0;
	
	cin>>n>>a>>b;
	
	int x = n*a;
	
	int ans = min(x,b);
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c,d; cin >> a>>b>>c>>d ;
	//string s,t; cin >> s>>t;
	cout << max(a * b, c * d);


	cout << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  ll a,b,n;
  cin >> a >> b >> n;
  cout << a*min(b-1,n)/b << endl;
}

Measured memory_bytes: 3584
N,M,L = (int(i) for i in input().split())
A = [[int(i) for i in input().split()] for i in range(N)]
B = [[int(i)for i in input().split()] for i in range(M)]
for i in range(N):
    for i2 in range(L):
        ans = 0
        for i3 in range(M):
            ans += A[i][i3]*B[i3][i2]
        if i2 == L-1:
            print(ans)
        else:
            print(ans,end=" ")

Measured memory_bytes: 8616
#include <stdio.h>

int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	
	int A[N];
	int i;
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	int ans = 1;
	N = N - K;
	K--;
	while(1){
		if(N <= 0) break;
		ans++;
		N -= K;
	}
	printf("%d",ans);
	return 0;
}
	




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  string s, t;
  cin >> s >> t;

  ll ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		double a = Double.parseDouble(sc.next());
		double b = Double.parseDouble(sc.next());
		double h = Double.parseDouble(sc.next());
		double m = Double.parseDouble(sc.next());
		double hour = 30*(h%12) + (30*(m /60));
		double min = 6*m;
	
		double  radianA = hour * Math.PI / 180;
		double y1 = Math.sin(radianA) * a;
		double x1 = Math.cos(radianA) * a;

		double  radianB = min * Math.PI / 180;
		double y2 = Math.sin(radianB) * b;
		double x2 = Math.cos(radianB) * b;

	    double distance = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

	    System.out.println(distance);
	}
}


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

#define PI acos(-1)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define io  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define file freopen ("maxflow.in", "r", stdin),freopen ("maxflow.out", "w", stdout);
#define all(v) ((v).begin()), ((v).end())

using namespace std;

typedef pair<int, int> pii;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pli;

const int N = 55;

int a[N], b[N], use[N], f[N][N];
int n;


bool can() {

  memset(f, 0, sizeof f);

  for (int i = 0; i <= 50; i++) {
    f[i][i] = 1;
    for (int j = 1; j <= 50; j++) {
      if (use[j]) {
        f[i][i % j] = 1;
      }
    }
  }

  for (int k = 0; k <= 50; k++) {
    for (int i = 0; i <= 50; i++) {
      for (int j = 0; j <= 50; j++) {
         f[i][j] |= f[i][k] && f[k][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!f[a[i]][b[i]]) {
        return false;
    }
  }
  return true;
}

int main () {

//#ifndef ONLINE_JUDGE
//  freopen ("in.txt", "r", stdin);
//#endif

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

  fill(use, use + N, 1);


  ll ans = 0;
  for (int i = 50; i >= 1; i--) {
    use[i] = 0;
    if (!can()) {
      use[i] = 1;
      ans += 1LL << i;
    }
  }
  if (!can()) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	int answer = 0;
	if(N * 2 > M) {
		cout << M / 2 << endl;
	}
	else {
		answer += N;
		M -= 2 * N;
		answer += M / 4;
		cout << answer << endl;
	}
}

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

struct Node {
	int		key;
	Node	*prev;
	Node	*next;
};

Node *nil;

Node*	list_search(int key)
{
	Node *cur;

	cur = nil->next;
	while (cur != nil && cur->key != key)
		cur = cur->next;
	return (cur);
}

void	init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
}

void	print_list()
{
	Node	*cur;
	bool	isf;

	cur = nil->next;
	isf = true;
	while (1)
	{
		if (cur == nil)
			break;
		if (!isf)
			cout << ' ';
		isf = false;
		cout << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

void	delete_node(Node *t)
{
	if (t == nil)
		return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void	delete_first()
{
	delete_node(nil->next);
}

void	delete_last()
{
	delete_node(nil->prev);
}

void	delete_key(int key)
{
	delete_node(list_search(key));
}

void	insert(int key)
{
	Node *x;
	x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

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

	int		n;
	int		i;
	int		size;
	int		np;
	int		nd;

	size = 0;
	np = 0;
	nd = 0;
	cin >> n;
	init();
	rep(i, n)
	{
		string	com;
		cin >> com;

		int		key;
		if (com.size() == 6)
			cin >> key;
		if (com.at(0) == 'i')
		{
			insert(key);
			np++;
			size++;
		}
		else if (com.at(0) == 'd')
		{
			if (com.size() > 6)
			{
				if (com.at(6) == 'F')
					delete_first();
				else
					delete_last();
			}
			else
			{
				delete_key(key);
				nd++;
			}
			size--;
		}
	}
	print_list();
}




Measured memory_bytes: 34472
n,m=map(int,input().split())

s=[]
for i in range(m):
    l=list(map(int,input().split()))
    l.pop(0)
    s.append(l)
p=list(map(int,input().split()))

res=0
for i in range(pow(2,n)):
    sw=("0000000000000000000000"+bin(i)[2:])[-n:]
    failed=False
    for j in range(m):
        sum=0
        for k in range(len(s[j])):
            sum+=int(sw[s[j][k]-1])
        if sum%2!=p[j]:
            failed=True
            break
    if not failed:
        res+=1
print(res)


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

int main() {
  int n = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      } while (x);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3096
H,W,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(M)]
Tr=[0 for _ in range(H+1)]
Tc=[0 for _ in range(W+1)]
for i in range(M):
    Tr[s[i][0]]+=1
    Tc[s[i][1]]+=1
mr=max(Tr)
mc=max(Tc)
Mr=[0 for _ in range(H+1)]
Mc=[0 for _ in range(W+1)]
Nmr=0
Nmc=0
for i in range(len(Tr)):
    if Tr[i]==mr:
        Mr[i]=1
        Nmr+=1
for i in range(len(Tc)):
    if Tc[i]==mc:
        Mc[i]=1
        Nmc+=1
cnt=0
for i in range(M):
    if Mr[s[i][0]]==1 and Mc[s[i][1]]==1:
        cnt+=1
if cnt<Nmr*Nmc:
    print(mr+mc)
else:
    print(mr+mc-1)

Measured memory_bytes: 73208
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 100001
typedef long long ll;
using namespace std;

int main(){
    ll N,Q;
    ll sum = 0;
    map<ll,ll> A;
    cin >> N;
    for(ll i = 0 ; i < N ; i++){
        ll num;
        cin >> num;
        A[num]++;
        sum += num;
    }
    cin >> Q;
    for(ll i = 0 ; i < Q ; i++){
        ll B,C;
        cin >> B >> C;
        sum -= B * A[B];
        A[C] += A[B];
        sum += C * A[B]; 
        cout << sum << endl;
        A[B] = 0;

    }
    return 0;
}

Measured memory_bytes: 9364
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    vs32 P;
    cin >> N;
    P.resize(N);
    rep (i, N) cin >> P[i];

    vs32 vmin(N + 1);
    vmin[0] = N + 1;
    rep (i, N)
    {
        vmin[i + 1] = MIN(vmin[i], P[i]);
    }

    int ans = 0;
    rep (i, N)
    {
        if (P[i] <= vmin[i])
        {
            ++ans;
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N;
cin >> N;
if(N%2 ==0){
	cout << fixed << setprecision(6) << 1.0/2.0;
}

else{
	cout << fixed << setprecision(6) <<( (double)(N-1)/2.0+1)/(double)(N);
}









	return 0;

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 空白区切りの数列をリストに代入
k = [int(i) for i in input().split()]


k.sort()

if k[0]==1 and k[1]==4 and k[2]==7 and k[3]==9 :
    print("YES")
else:
    print("NO")


Measured memory_bytes: 21804
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[1111][1111];

main(){
	int h,w;cin>>h>>w;
	char a[h][w];rep(i,h)rep(j,w)cin>>a[i][j];
	dp[0][0]=1;
	rep(i,h){
		rep(j,w){
			if(a[i][j]=='.'){
				dp[i+1][j]+=dp[i][j];
				dp[i][j+1]+=dp[i][j];
				dp[i+1][j]%=MOD;
				dp[i][j+1]%=MOD;
			}
		}
	}
	dump(dp[h-1][w-1]);
}






Measured memory_bytes: 9856
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N =sc.nextInt();
      int L =sc.nextInt();
      
     
      int at[] =new int[N];
      int pt[] =new int[N];
      int tt =0;
      for(int i=0; i<N; i++){
        at[i] =L+i;
        tt +=at[i];
      }

      for(int i=0; i<N; i++){
        pt[i] =tt-at[i];
      }
      int diff =1000000;
      int ans =0;
        
      for(int i=0; i<N; i++){
        int d0 =Math.abs(tt-pt[i]);
        if(diff>d0){
        diff =d0;
        ans=pt[i];
        }
        
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
  ll w,h;
	cin>>w>>h;
	ll ans=0;
  vector<ll>p(w),q(h);
  rep(i,w)cin>>p[i],ans+=p[i];
  rep(i,h)cin>>q[i],ans+=q[i];
  sort(all(p));
  vector<ll>sum(w+1);
  rep(i,w)sum[i+1]=sum[i]+p[i];
  rep(i,h){
    int pos=lower_bound(all(p),q[i])-p.begin();
    ans+=sum[pos];
    ans+=(w-pos)*q[i];
  }
  cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 2560
import sys
input = sys.stdin.readline

# K+1 - x でうつす -> i と 2K+2-i は同じ

MOD = 998244353
U = 10000
fact = [1] * (U+1)
fact_inv = [1] * (U+1)
for n in range(1,U+1):
    fact[n] = fact[n-1] * n % MOD
fact_inv[n] = pow(fact[n], MOD-2, MOD)
for n in range(U,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

def comb(n,k):
    if not (0 <= k <= n):
        return 0
    return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD

K,N = map(int,input().split())

def F(x,y,N):
    n = min(x, N)
    return sum(comb(x,i) * pow(2,i,MOD) * comb(N+y-1,i+y-1) for i in range(n+1)) % MOD

answer = []
for S in range(2,K+2):
    if S & 1:
        x = F((S-1)//2, K - S + 1, N)
    else:
        x = F((S-1)//2, K - S + 1, N) + F((S-1)//2, K - S + 1, N - 1)
    answer.append(x % MOD)

answer += answer[:-1][::-1]

print('\n'.join(map(str,answer)))

Measured memory_bytes: 49396
#include <stdio.h>
#define N 44
int fib(int);
int F[N];
int main(){
int n,i;
for( i=0;i<N;i++){
F[i] = 0;
}
scanf("%d",&n);
printf("%d\n",fib(n));
}

int fib(int n){
if(n == 0 || n ==1){
return F[n] =1;
}
if(F[n] != 0){
return F[n];
}
return F[n] = fib(n-2) +fib(n-1);
}




Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, W; cin >> n >> W;
    vector<int> v(n);
    vector<int> w(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        cin >> w[i];
    }
    vector<vector<int> > dp(n+1, vector<int>(W+1, 0));
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= W; j++){
            if(j == 0 || i == 0)
                continue;
            dp[i][j] = dp[i-1][j];
            if(j - w[i-1] >= 0)
                dp[i][j] = max(dp[i][j-w[i-1]] + v[i-1],dp[i-1][j]);
        }
    }
    // for(int i = 0; i <= n; i++){
    //     for(int j = 0; j <= W; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][W] << endl;
}



Measured memory_bytes: 6800
#include <iostream>
using namespace std;
int main(void) {
	int x, y;
	cin >> x >> y;
	bool ok = false;
	for (int i = 0; i <= x; ++i) {
		int crane = i, turtle = x - i;
		if (crane * 2 + turtle * 4 == y) ok = true;
	}
	cout << (ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3632
import numpy as np

n,m = map(int,input().split()) #nがカードの数、mがBの数
a = list(map(int, input().split())) #数のカウント
b = [1 for i in range(n)] #枚数カウント

for i in range(m):
  x, y = map(int, input().split())
  b.append(x)
  a.append(y)
c = np.array(a) #カードの数字
d = np.array(b) #カードの枚数
e = np.argsort(-c) #インデックスをカードの数字の大きい順にソート
#print(c,d,e)
ans = 0
N = 0 #取った枚数のカウント
i = 0
while N < n:
  j = e[i]
  if N + d[j] <= n:
    ans += c[j]*d[j]
    N += d[j]
    i += 1
  else:
    ans += c[j]*(n-N)
    N = n
    i += 1
print(ans)

Measured memory_bytes: 31012
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int j = 1; j <= n; j += 2) {
            int cnt = 0;
            for (int i = 1; i <= j; i++) {
                if (j % i == 0) {
                    cnt++;
                }
            }
            if (cnt == 8) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N = 2e5+5;
ll a[N];

int main()
{
	ios_base::sync_with_stdio(false);

	ll n;cin>>n;
	forn(i,n){cin>>a[i];a[i]-=(i+1);}
	sort(a,a+n);
	ll x=(n/2);
	ll s=0;
	forn(i,n)s+=abs(a[i]-a[x]);
	cout<<s<<endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    string s,t;cin>>s>>t;
    ll ans=0;
    rep(i,0,s.size()-1){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3756