akhauriyash/Code-Regression huggingface dataset:
import re

def judge(check_string):

    # check length.
    if not((1 <= len(check_string)) and (len(check_string) <= 10)):
        print("No")

    # check character.
    allow_pattern = "[a-z]+"
    group = re.match(allow_pattern, check_string)

    HITACH_STRING = "^(hi){1,}$"

    if(re.match(HITACH_STRING, check_string)):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    hitachi_string = input()
    judge(hitachi_string)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define M0D 1000000007
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n,m,ans=0,nuA=0;
  cin >> n >> m;
  int p[m];
  int numWA[n+1];
  bool Ac[n+1];
  string s;
  rep(i,n+1) numWA[i]=0;
  rep(i,n+1) Ac[i] = false;
  rep(i,m){
    cin >> p[i] >> s;
      if(s=="WA"){
        if(!Ac[p[i]]) numWA[p[i]]++;
      }else{
        if(!Ac[p[i]]) Ac[p[i]] = true;
      }

  }
  rep(i,n+1) if(Ac[i]) ans += numWA[i];
  rep(i,n+1) if(Ac[i]) nuA++;
  cout << nuA << " " << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
w, h, n = gets.split.map(&:to_i)
spots = []
n.times { spots << gets.split.map(&:to_i) }
right = w
left = 0
up = h
down = 0
spots.each do |x, y, direction|
  case direction
  when 1
    left = [left, x].max
  when 2
    right = [right, x].min
  when 3
    down = [down, y].max
  when 4
    up = [up, y].min
  end
end
puts [(right - left), 0].max * [(up - down), 0].max


Measured memory_bytes: 1916
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if (s[0] == '1') ++ans;
  if (s[1] == '1') ++ans;
  if (s[2] == '1') ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))
C = []
for i in range(H):
    c = input()
    C.append(c)

re = []

for i in range(2*H):
    index = (i + 2) // 2 - 1
    tmp = ''
    for j in range(W):
        tmp += C[index][j]
    print(tmp)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] cn1 = sc.next().split("");
        String[] cn2 = sc.next().split("");

        System.out.println((cn1[0].equals(cn2[2]) &&
                            cn1[1].equals(cn2[1]) &&
                            cn1[2].equals(cn2[0])) ? "YES" : "NO");
    }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,kotae=0;
  cin>>n;
  vector<int> kati(n), cost(n);
  for (int i=0;i<n;i++){
    cin>>kati.at(i);
  }
  for (int j=0;j<n;j++){
    cin>>cost.at(j);
  }
  for (int k=0;k<n;k++){
    if(kati.at(k)>cost.at(k)){
      kotae+=(kati.at(k)-cost.at(k));
    }
  }
  cout<<kotae;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String str = stdIn.next();
    boolean ans = true;

    if(str.charAt(0) != 'A')
      ans = false;
    
    if(!check(str, 1))
      ans = false;

    int cnt = 0;
    for(int i = 2; i < str.length() - 1; i++){
      if(str.charAt(i) == 'C')
        cnt++;
      if(!check(str, i))
      ans = false;
    }

    if(!check(str, str.length() - 1))
      ans = false;
   
    if(cnt != 1)
      ans = false;

    if(ans)
      System.out.println("AC");
    else
      System.out.println("WA");
  }

  public static boolean check(String str, int i){
    switch(str.charAt(i)){
    case 'B' : return false;
    case 'D' : return false;
    case 'E' : return false;
    case 'F' : return false;
    case 'G' : return false;
    case 'H' : return false;
    case 'I' : return false;
    case 'J' : return false;
    case 'K' : return false;
    case 'L' : return false;
    case 'M' : return false;
    case 'N' : return false;
    case 'O' : return false;
    case 'P' : return false;
    case 'Q' : return false;
    case 'R' : return false;
    case 'S' : return false;
    case 'T' : return false;
    case 'U' : return false;
    case 'V' : return false;
    case 'W' : return false;
    case 'X' : return false;
    case 'Y' : return false;
    case 'Z' : return false;
    }

    return true;
  }
}

Measured memory_bytes: 23124
N, K = gets.split.map(&:to_i)

ans = 0.0
1.upto(N) do |i|
  n = i
  prob = 1.0 / N # サイコロの目は 1/N の確率
  while n < K
    n    *= 2
    prob /= 2
  end
  ans += prob
end

puts ans

Measured memory_bytes: 1916
/**
 *      ABc 107 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-19 08:45:45
**/

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, K; cin >> N >> K;
    int x[N] = {};
    for (int i = 0; i < N; ++i) cin >> x[i];
    int answer = 1000000000;    
    if (N == K){
        cout << min(abs(x[N - 1] - x[0]) + abs(x[0]), abs(x[N - 1] - x[0]) + abs(x[N - 1])) << '\n'; return 0;
    }
    for (int i = 0; i <= N - K; ++i) {
        int sum1 = abs(x[i + K - 1] - x[i]) + abs(x[i + K - 1]);
        int sum2 = abs(x[i + K - 1] - x[i]) + abs(x[i]);
        int min1 = min(sum1, sum2);
        if (min1 < answer) answer = min1;
    }
    cout << answer << '\n';
    return 0;
}

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

    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] H = new int[N];
    long sum = 0;
    long sum1 = 0;

    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt();
      sum = sum + H[i];
    }

    Arrays.sort(H);

      if (K < N && K != 0) {
        for(int i=0;i<N-K;i++) {
          sum1 = sum1 + H[i];
        }
        System.out.println(sum1);
      } else if (K == 0) {
        System.out.println(sum);
      } else if (K >= N) {
        System.out.println("0");
      }
    }
  }

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

using namespace std;

int main() {
  vector<int> flights(3);
  for (int i = 0; i < 3; ++i) {
    cin >> flights[i];
  }
  sort(flights.begin(), flights.end());
  
  cout << flights[0] + flights[1] << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; i < (n); i++)

int main(){
  int n, d, c[100] = {}, ans = 0;
  cin >> n;
  rep(i, n) {
    cin >> d;
    c[d - 1] = 1;
  }
  rep(i, 100) if(c[i] == 1) ans++;
  cout << ans << endl;
}	

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

static const int M = 1000000007;

void compute(int N, int H, vector<int> v){
  vector<pair<int, int> > R; //
  int s, t;
  for ( int i = 0; i < H; i++ ){
    cin >> s >> t;
    swap(v[s], v[t]);
  }

  for ( int i = 1; i <= N; i++ ){
    if ( v[i] != i ) R.push_back(make_pair(v[i], i));
  }

  long long cnt = 0;
  long long a = 1, f = 1;
  for ( int p = N; p > 0; p-- ){
    long long L = max(v[p]-1, p-1);
    long long W = max(L-p, 0LL);
    for ( int i = 0; i < R.size(); i++ ){
      if ( R[i].second <= p ) continue;
      if ( R[i].second <= L) W--;
      if ( R[i].first < v[p] ) W++;
    }
    cnt = (cnt + (W*a)%M)%M;
    a = (a*f)%M;
    f = (f+1)%M;
  }
  cout << cnt << endl;
}

int main(){
  int N, H;
  while(1){
    cin >> N;
    if ( N == 0 ) break;
    cin >> H;
    vector<int> v;
    v.push_back(0);
    for ( int i = 0; i < N; i++ ) v.push_back(i+1);
    compute(N, H, v);
  }
}

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;


void energy_drink_collector()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n);
  for (int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;

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

  long long int total_fee = 0;
  for (int i = 0; i < n && m > 0; ++i)
  {
    total_fee += (long long int)ab[i].first * (long long int)min(m, ab[i].second);
    m -= min(m, ab[i].second);
  }

  cout << total_fee << "\n";
}


void get_AC()
{
  int n, q;
  string S;
  cin >> n >> q >> S;

  vector<int> cnt(n + 1);
  for (int i = 0; i < n; ++i)
  {
    if (i + 1 < n && S[i] == 'A' && S[i + 1] == 'C') cnt[i + 1] = cnt[i] + 1;
    else cnt[i + 1] = cnt[i];
  }

  for (int i = 0; i < q; ++i)
  {
    int l, r;
    cin >> l >> r;
    cout << cnt[r - 1] - cnt[l - 1] << "\n";
  }
}


void five_transportations()
{
  long long int n;
  cin >> n;
  long long int v_min = 1000000000000000, tmp;
  for (int i = 0; i < 5; ++i) 
  {
    cin >> tmp;
    v_min = min(v_min, tmp);
  }

  cout << (n - 1)/ v_min + 5;
}


void coloring_colorfully()
{
  string s;
  cin >> s;

  int cnt_01 = 0, cnt_10 = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (i % 2 == 0)
    {
      if (s[i] != '0') ++cnt_01;
      else ++cnt_10;
    }
    else
    {
      if (s[i] != '1') ++cnt_01;
      else ++cnt_10;
    }
  }

  cout << min(cnt_01, cnt_10) << "\n";
}


//skip
void gcd_on_blackboard()
{

}


void dice_and_coin()
{
  int n, k;
  cin >> n >> k;

  double res = 0;
  for (int i = 1; i <= n; ++i)
  {
    double tmp = 1.0 / n;
    int point_now = i;
    while (point_now < k)
    {
      point_now *= 2;
      tmp /= 2;
    }
    res += tmp;
  }
  cout << setprecision(10) <<res << "\n";
}


int main()
{
  //energy_drink_collector();
  //get_AC();
  //five_transportations();
  //coloring_colorfully();
  //gcd_on_blackboard();
  dice_and_coin();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	// your code goes here
	char a,b;
	scanf("%c",&a);
	scanf(" %c",&b);
	if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
		printf("H\n");
	}else{
		printf("D\n");
	}
	return 0;
}


Measured memory_bytes: 128
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0]*(n-1)

for i in range(n):
    for j in range(i+1, n):
        # print(i+1, j+1, min(j-i, abs(i-x)+abs(j-y)+1))
        ans[(min(j-i, abs(i-x)+abs(j-y)+1))-1] += 1

ans = list(map(str, ans))

print("\n".join(ans))

Measured memory_bytes: 3316
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll s,w;
            cin>>s>>w;
            if(s>w)
            {
                cout<<"safe"<<endl;
            }
            else
            {
                cout<<"unsafe"<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 3640
#include<iostream>
#include<string>
using namespace std;
int main(){
string a,b,c;
  cin>>a>>b>>c;
  char t='a';
  
  while(1){
    if(t=='a'&&a.empty()){
      cout<<"A"<<endl;
      return 0;
    }
    else if(t=='b'&&b.empty()){
      cout<<"B"<<endl;
      return 0;
    }
    else if(t=='c'&&c.empty()){
      cout<<"C"<<endl;
      return 0;
    }
    
    if(t=='a'){
      t=a[0];
      a.erase(a.begin());
    }
    else if(t=='b'){
      t=b[0];
      b.erase(b.begin());
    }
    else if(t=='c'){
        t=c[0];
      c.erase(c.begin());
    }
  }
  return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>    //ソート用

using namespace std;

int main(void){
    
    int n,k;
    cin >> n >> k;
    vector<int> l(n); //vectorの大きさをnに設定
//    for(int i = 0; i < n; i++){
//        cin >> l[i];
//    }
    for(int &val : l){
        cin >> val;
    }
    
    sort(l.begin(),l.end());    //C++ではソート用の関数が用意されていることが多いため、ソート関数を実装する必要はない
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += l[n-1-i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define H_MAX 100
#define W_MAX 100

int H, W;

string f[H_MAX];      // field
bool p[H_MAX][W_MAX]; // have passed?

void go(int x, int y) {
    if (p[y][x]) {
        cout << "LOOP\n";
        return;
    }
    p[y][x] = true;
    switch (f[y][x]) {
        case '>':
            go(x+1, y);
            break;
        case '<':
            go(x-1, y);
            break;
        case '^':
            go(x, y-1);
            break;
        case 'v':
            go(x, y+1);
            break;
        default:
            cout << x << ' ' << y << endl;
            break;
    }
}

int main() {
    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++) {
            cin >> f[i];
            for (int j = 0; j < W; j++) {
                p[i][j] = false;
            }
        }
        go(0, 0);
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  long long int ll;
using namespace std;
const int M=1e9+7;
const int N=1e5+5;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
ll ans[N];
int main()
{
    ll n,k;cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;++i)
    {
        ans[i]=M;
        cin>>a[i];
    }
  //  ans[2]=abs(a[1]-a[2]);
  ans[1]=0;
    for(ll i=2;i<=n;++i)
    {
        for(ll j=i-1;j>=max(i-k,1LL);--j)
        {
        ans[i]=min(abs(a[j]-a[i])+ans[j],ans[i]);
        }
    }
    cout<<ans[n];
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000
int n,a[50],ans=INF,s[50];
bool dp[50][4005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++){
        s[i]+=a[i];
        if(i>0)s[i]+=s[i-1];
    }
    for(int i=0;i<n;i++)for(int j=0;j<=4000;j++)dp[i][j]=false;
    n--;
    dp[0][0]=true;
    for(int i=0;i<n;i++)for(int j=0;j<=4000;j++)if(dp[i][j])dp[i+1][j+a[i]]=true,dp[i+1][j]=true;
    for(int i=2;i<n;i++){
        for(int j=a[i]+1;s[n-1]-a[i]-j>a[n];j++){
            if(dp[i][j])ans=min(ans,abs(a[i]+j-(s[n]-a[i]-j)));
        }
    }
    if(ans==INF)ans=-1;
    cout<<ans<<endl;
}



Measured memory_bytes: 3292
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D&lang=jp

n = int(input())
maximum = -10e10
minimum = 10e10
# maximum, minimum = max(maximum, minimum), min(maximum, minimum)
maxmin = []
prev_num = 10e10
max_diff_between_two = -10e10
for i in range(n):
    in_num = int(input())
    if in_num - prev_num > max_diff_between_two and prev_num != 10e10:
        max_diff_between_two = in_num - prev_num
    if in_num < minimum:
        if maximum != -10e10 and minimum != 10e10:
            maxmin.append(maximum - minimum)
        minimum = in_num
        maximum = -10e10
    elif in_num > maximum:
        maximum = in_num
    prev_num = in_num
if maximum != -10e10 and minimum != 10e10:
    maxmin.append(maximum - minimum)

if len(maxmin) == 0:
    print(max_diff_between_two)
    quit()

max_diff = -10e10
for i in maxmin:
    if max_diff < i:
        max_diff = i

print(max_diff)


Measured memory_bytes: 5632
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;
	vector<i64> H(N);
	for (auto& v : H)
	{
		cin >> v;
	}

	i64 ans = 0;
	i64 high = 0;
	REP(i, N)
	{
		if (H[i] >= high)
		{
			++ans;
			high = H[i];
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int l,m;
    cin >> l >> m;
    int x=1,y=l;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        x=max(x,a);
        y=min(y,b);
    }
    
    if(y-x>=0) cout << y-x+1 << endl;
    else cout << 0 << endl;
    
    return 0;
}





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	string S;
	cin>>S;
	cout<<S.substr(0,4)<<' '<<S.substr(4,8)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
//#include<math.h>
using namespace std;

int main(void){

    int i,j;
    int n;
    long long int a,b;

   cin>>a>>b;

    if(a==1){
        if(b==1){
            printf("1\n");
        }else if(b==2){
            printf("0\n");
        }else{
            cout<<b-2<<endl;
        }
    }else if(a==2){
        printf("0\n");
    }else{
        if(b==1){
            cout<<a-2<<endl;
        }else if(b==2){
            printf("0\n");
        }else{
            cout<<(a*b-2*(a+b)+4)<<endl;
        }
    }
        
}

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

using namespace std;

const double PI = 3.14159265358979323846;

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

	int r;
	cin >> r;
	r *= 2;

	cout << fixed << setprecision(20) << r * PI << endl;

	return 0;
}

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


const int n_day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
struct Date {
  // year, month, day, a day of the week
  int y, m, d, e;
  Date() {}
  Date(int y, int m, int d, int e) : y(y), m(m), d(d), e(e) {}
 
  bool operator < (const Date &o) const {
    if(y != o.y) return y < o.y;
    if(m != o.m) return m < o.m;
    return d < o.d;
  }
 
  bool isLeapYear() {
    if(y % 400 == 0) return true;
    if(y % 100 == 0) return false;
    if(y % 4 == 0) return true;
    return false;
  }

  int getDays() {
    int nd = n_day[m];
    if(m == 2) nd += isLeapYear();
    return nd;
  }

  void next() {
    e = (e+1)%7;
    if(d == getDays()) {
      d = 1;
      if(m == 12) {
        m = 1;
        ++y;
      } else {
        ++m;
      }
    } else {
      ++d;
    }
  }
 
  void back() {
    e = (e+6)%7;
    if(d == 1) {
      if(m == 1) {
        m = 12;
        --y;
      } else {
        --m;
      }
      d = getDays();
    } else {
      --d;
    }
  }
};

// AOJ 0093
int main() {
  for(int tc = 0; ; ++tc)  {
    int a, b;
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    Date d(a,1,1,-1), end(b+1,1,1,-1);
    int res = 0;
    if(tc) cout << endl;
    while(d < end) {
      if(d.isLeapYear()) {
	cout << d.y << endl;
	++res;
      }
      ++d.y;
    }
    if(res == 0) cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  for (int i=0; i<S.size(); i++) {
    if (S[i] != T[i]) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3884
from heapq import heappop, heappush


def kruskal(edges, v):
    nums = [i for i in range(v)]
    rank = [0 for i in range(v)]

    def find_top(x):
        if (nums[x] != x):
            nums[x] = find_top(nums[x])
        return nums[x]

    def unite(x, y):
        x = find_top(x)
        y = find_top(y)
        if rank[x] > rank[y]:
            nums[y] = x
        else:
            nums[x] = y
            if (rank[x] == rank[y]):
                rank[y] += 1

    def same(x, y):
        return find_top(x) == find_top(y)
    weight = 0
    while len(edges) > 0:
        w, s, t = heappop(edges)
        if not same(s, t):
            unite(s, t)
            weight += w
    return weight


def main():
    v, e = map(int, input().split())
    edges = []
    for _ in range(e):
        s, t, w = map(int, input().split())
        heappush(edges, (w, s, t))
    print(kruskal(edges, v))


if __name__ == "__main__":
    main()



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

int main () {
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=1;
    for(int i=1;i<n;i++){
        if (s[i]!=s[i-1])
           ans+=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3736
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       mut L:[usize;N],
    }

    L.sort();
    let mut ans: usize = 0;
    for i in 0..N {
        for j in i + 1..N {
            for k in j + 1..N {
                if (L[i] != L[j] && L[j] != L[k] && L[i] != L[k]) && (L[i] + L[j] > L[k]) {
                    mydbg!(L[i], L[j], L[k]);
                    ans += 1;
                }
            }
        }
    }

    echo!(ans);
}


Measured memory_bytes: 2156
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


class CmbMod:
    def __init__(self, n, p):
        """
        二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める
        """
        self.n = n
        self.p = p
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]

    def cmb_mod(self, n, r):
        """
        二項係数nCr(mod p)をO(r)にて計算。nが大きいがrは小さい時に使用。
        """
        numer, denom = 1, 1
        for i in range(r):
            numer = (numer * (n - i)) % self.p
            denom = (denom * (i + 1)) % self.p
        return (numer * pow(denom, self.p - 2, self.p)) % self.p

    def prep(self):
        """
        二項係数nCr(mod p)をO(1)で求める為の前処理をO(N)にて実行。
        """
        for i in range(2, self.n + 1):
            self.fact.append((self.fact[-1] * i) % self.p)
            self.inv.append((-self.inv[self.p % i] * (self.p // i)) % self.p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % self.p)

    def cmb_mod_with_prep(self, n, r):
        """
        二項係数nCr(mod p)をO(1)で求める。事前にprepを実行する事。
        """
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.p


def resolve():
    n, k = map(int, input().split())
    k = min(n - 1, k)
    cmb = CmbMod(n, mod)
    cmb.prep()
    res = 0
    for i in range(k + 1):
        res += (cmb.cmb_mod_with_prep(n, i) * cmb.cmb_mod_with_prep(n - 1, i)) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32852
#include<stdio.h>
#define MAX 100000
#define NO -1

int pa[MAX];
int le[MAX];
int ri[MAX];

int n,Dp[MAX],Hi[MAX];

void depth(int,int);
int height(int);
int sibling(int);
void ans(int);

int main(){

  int v, l, r;
  int root = 0;
  int i;
  int esc;

  scanf("%d",&n);

  for(i = 0; i < n; i++) pa[i] = NO;

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&l,&r);
    le[v] = l;
    ri[v] = r;
    if(l != NO) pa[l] = v;
    if(r != NO) pa[r] = v;
  }

  for(i = 0; i < n; i++){
    if(pa[i] == NO) root = i;
  }

  depth(root,0);
  esc = height(root);

  for(i = 0; i < n; i++) ans(i);

  return 0;
}

void depth(int a,int d){
  if(a == NO) return;
  Dp[a] = d;
  depth(le[a],d+1);
  depth(ri[a],d+1);
}

int height(int a){
  int hi1 = 0,hi2 = 0;
  if(le[a] != NO) hi1 = height(le[a]) + 1;
  if(ri[a] != NO) hi2 = height(ri[a]) + 1;
  return Hi[a] = (hi1 > hi2 ? hi1 : hi2);
}

int sibling(int a){
  if(pa[a] == NO) return NO;
  if(le[pa[a]] != a && le[pa[a]] != NO) return le[pa[a]];
  if(ri[pa[a]] != a && ri[pa[a]] != NO) return ri[pa[a]];
  return NO;
}

void ans(int a){
  int degree = 0;
  printf("node %d: ",a);
  printf("parent = %d, ",pa[a]);
  printf("sibling = %d, ",sibling(a));
  if(le[a] != NO) degree++;
  if(ri[a] != NO) degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",Dp[a]);
  printf("height = %d, ",Hi[a]);

  if(pa[a] == NO) printf("root\n");
  else if(le[a] == NO && ri[a] == NO) printf("leaf\n");
  else printf("internal node\n");
}

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

typedef long long int ll;
typedef long double   ld;
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    up                       cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int t; cin >> t; while(t--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>

#define MAX 2000
ll arr[MAX + 5][MAX + 5];

void ncr(){
    arr[0][0] = 1;

    for(int i = 1; i <= MAX; i++){
        arr[i][0] = 1;
        for(int j = 1; j <= i; j++){
            arr[i][j] = (arr[i-1][j-1] + arr[i-1][j])%mod;
        }
    }
}


int main(){
     ncr();
     speed up
     ll n , k , ans;
     cin >> n >> k;
     n-=k;
     f(i,1,k){
         if(i>n+1){
             cout << "0\n"; continue;
         }
         ans = arr[n+1][i];
         ans = (ans%mod*arr[k-1][i-1]%mod)%mod;
         cout << ans << '\n';
     }
}

Measured memory_bytes: 30208
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;
const int MAX = 100000;

int main(){
    int N,M;
    map<int,vector<pair<int,int> > > m;
    pair<int,int> ans[MAX];

    cin >> N >> M;
    for(int i = 0;i < M;i++){
        int p,y;
        cin >> p >> y;

        if(m.count(p) == 0){
            vector<pair<int,int> > v;
            m[p] = v;
        }

        m[p].push_back(make_pair(y,i));
    }

    for(map<int,vector<pair<int,int> > >::iterator i = m.begin();i != m.end();i++){
        sort(i->second.begin(),i->second.end());

        for(vector<pair<int,int> >::iterator j = i->second.begin();j != i->second.end();j++){
            ans[j->second].first = i->first;
            ans[j->second].second = j - i->second.begin() + 1;
        }
    }

    for(int i = 0;i < M;i++){
        printf("%06d%06d\n",ans[i].first,ans[i].second);
    }

    return 0;
}

Measured memory_bytes: 13184
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* UnionFind */

struct UnionFind{
  vector<int> data, tree_size;
  UnionFind(int s):data(s,-1),tree_size(s,1) {}
  
  int root(int x){
    if(data[x]==-1) return x;
    return data[x]=root(data[x]);
  }
  
  bool set(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return false;
    data[y]=x;
    tree_size[x] += tree_size[y];
    tree_size[y] = 0;
    return true;
  }
  
  bool check(int x,int y){
    x=root(x);
    y=root(y);
    return x==y;
  }
  
  int size(int x){
    return tree_size[root(x)];
  }
  
};


int main(){
  int n, m;
  int p[SIZE], dic_p[SIZE];
  
  scanf("%d%d", &n, &m);

  for(int i=0;i<n;i++){
    scanf("%d", p+i);
    p[i]--;
    dic_p[p[i]] = i;
  }

  UnionFind uf(n);

  for(int i=0;i<m;i++){
    int x, y;
    scanf("%d%d", &x, &y);
    x--; y--;
    uf.set(x, y);
  }

  int root[SIZE],root_pos[SIZE];
  
  for(int i=0;i<n;i++){
    root[p[i]] = uf.root(p[i]);
    root_pos[i] = root[p[i]];
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    ans += root[i] == root_pos[i];
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

using P=pair<int,int>;
void solve(){
  int l;
  cin>>l;
  int mul=2,cnt=1;
  while(mul*2<=l){
    mul*=2;
    ++cnt;
  }
  vector<vector<P>>g(cnt);
  rep(i,cnt){
    g[i].eb(i+1,0);
    g[i].eb(i+1,(int)pow(2,i));
  }
  //この時点で2^cntまでしか表せない
  int lb=(int)pow(2,cnt);//表さなければいけない下限
  for(int i=cnt-1;i>=0;--i){//残りをL-1からlbまで埋めていく
    int x=pow(2,i)-1;//頂点iに到達するまでの最大コスト
    if(l-(x+1)>=lb){
      g[i].eb(cnt,l-(x+1));
      l-=x+1;
    }
  }
  int edge=0;
  for(auto e:g){
    edge+=e.size();
  }
  cout<<cnt+1<<" "<<edge<<endl;
  rep(i,cnt){
    for(auto e:g[i]){
      cout<<i+1<<" "<<e.first+1<<" "<<e.second<<endl;
    }
  }
}

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

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
using namespace std;
int dp[100000];
int n,a[100000],k;

int topdown()
{
	dp[n-1]=0;

	for(int i=n-2;i>=0;i--)
	{
		dp[i]=1e9;
		for(int j=1;j<=k;j++)
		{
          	if(i+j<n)
				dp[i]=min(dp[i] , abs(a[i]-a[i+j])+dp[i+j]);
		}
	}
	return dp[0];
}

int main()
{
  	ios_base::sync_with_stdio(0);            //fast input and output
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];

	cout<<topdown();

	return 0;
}


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

int main(void){
  int N;
  std::vector<int> A;
  std::cin >> N;
  long long int sum=0;
  long long int sum2=0;
  long long int sum3=0;
  for(int i=0;i<N;i++){
    int tmp;
    std::cin >> tmp;
    A.push_back(tmp);
    sum+=tmp;
  }
  
  int flag=0;
  for(int i=0;i<N;i++){
    sum2+=A[i];
    //std::cout << "sum2=" << sum2 << " sum=" << sum << std::endl;
    if(sum2>=sum*0.5){
      sum3 = sum2 - A[i];
      break;
    }
  }
  std::cout << ((2*sum2-sum) > (sum - 2*sum3) ? (sum - 2*sum3) : (2*sum2-sum) );
  return 0;
}


Measured memory_bytes: 1400
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in); 
		int N = input.nextInt();
		int max = (int)(1e6)+1;
		int[] arr = new int[N];
		int[] cnts = new int[max];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
			cnts[arr[i]]++;
		}
		if (cnts[1]==1) ans++;
		else if (cnts[1]>1) ans=0;
		else {
			for (int i = 0; i < N; i++) {
				int num = arr[i];
				if (cnts[num]==1) {
					boolean bad=false;
					for (int p = 2; p <= Math.sqrt(num); p++){
						if (num%p==0) {
							if (cnts[p]>=1||cnts[num/p]>=1) {
								bad=true;
								break;
							}
						}
					}
					if (!bad) ans++;
				}
			}
		}
		System.out.println(ans);
	}	
}


Measured memory_bytes: 53700
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
//char s1[1005];
//char s2[1005];
int d[1005][1005];

int main(){
    string s1,s2;
    cin>>s1>>s2;
    //int l1=strlen(s1);
    //int l2=strlen(s2);
    s1=' '+s1;
    s2=' '+s2;
    int l1=s1.size();
    int l2=s2.size();
    int i,j;
    for( i=1;i<l1;i++)d[i][0]=i;
    for( j=1;j<l2;j++)d[0][j]=j;
    for( i=1;i<l1;i++){
        for( j=1;j<l2;j++){
            if(s1[i]==s2[j]){
                d[i][j]=d[i-1][j-1];
            }else{
                d[i][j]=min(d[i][j-1],min(d[i-1][j],d[i-1][j-1]))+1;
            }
        }
    }cout<<d[l1-1][l2-1]<<endl;
return 0;
}

Measured memory_bytes: 7088
from collections import defaultdict
from bisect import bisect_right

S = input()
T = input()

s_set = set(list(S))
t_set = set(list(T))

if not t_set <= s_set:
    print(-1)
    exit()


s_position = defaultdict(list)
for i, s in enumerate(S):
    s_position[s].append(i)


now_position = -1
t_position = [-1] * len(T)
for i, t in enumerate(T):
    ti = bisect_right(s_position[t], now_position)
    if ti >= len(s_position[t]):
        ti = 0

    t_position[i] = s_position[t][ti]
    now_position = s_position[t][ti]

ans = 0
for i in range(len(T) - 1):
    if t_position[i] >= t_position[i + 1]:
        ans += len(S)

print(ans + t_position[-1] + 1)


Measured memory_bytes: 54232
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int x[3];
    for(int i=0;i<3;i++){
    cin>>x[i];
    }
    sort(x,x+3);
    cout<<x[2]-x[1]+x[1]-x[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,k;
string s,t;
signed main()
{
	cin>>k>>a;
	if(500*k>=a){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数



int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    
    //計算
    long fre=0;
    vector<bool> color(8,false);
    for(int i=0;i<N;i++){
        if(a.at(i)/400<8) color.at(a.at(i)/400)=true;
        else fre++;
    }
    
    long base=0;
    for(int i=0;i<8;i++){
        base+=color.at(i);
    }
    
    //出力
    cout<<max((long)1,base)<<" "<<base+fre<<endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for A in range(a+1):
    for B in range(b+1):
        for C in range(c+1):
            if 500*A+100*B+50*C==x:
                count+=1
print(count)

Measured memory_bytes: 3060
//package ABC172;
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		String s1=sc.next();
		int count=0;
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)!=s1.charAt(i))
			{
				count++;
			}
		}
		System.out.println(count);
		
	}

}


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

typedef long long LL;
typedef pair<int, int> II;

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

    int ans;
    if (s == "SUN") {
        ans = 7;
    } else if (s == "MON") {
        ans = 6;
    } else if (s == "TUE") {
        ans = 5;
    } else if (s == "WED") {
        ans = 4;
    } else if (s == "THU") {
        ans = 3;
    } else if (s == "FRI") {
        ans = 2;
    } else if (s == "SAT") {
        ans = 1;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M,X,Y;
    cin >>N>>M>>X>>Y;
    ll XZ=X;
    ll YZ=Y;
    rep(i,N){
        ll x;
        cin>>x;
        chmax(XZ,x);
    }

    rep(i,M){
        ll y;
        cin>>y;
        chmin(YZ,y);
    }

    if(XZ<YZ){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }
  

    return 0;
    

}

Measured memory_bytes: 3612
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	ll s; cin >> s;
	ll k1 = 0, k2 = 0;
	k2 += s % 10;
	s = s / 10;
	k2 += (s % 10) * 10;
	s = s / 10;
	k1 += s % 10;
	s = s / 10;
	k1 += (s % 10) * 10;
	bool flag1 = false;
	if (1 <= k1 && k1 <= 12) flag1 = true;
	bool flag2 = false;
	if (1 <= k2 && k2 <= 12) flag2 = true;
	if (flag1 && flag2) cout << "AMBIGUOUS" << endl;
	else if (flag1) cout << "MMYY" << endl;
	else if (flag2) cout << "YYMM" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 998244353
#define N 200009
using namespace std;

int n,a[N],b[N][9],dp[N][9];
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int ksm(int x,int y){
	int ans=1;
	for (; y; y>>=1,x=(ll)x*x%mod) if (y&1) ans=(ll)ans*x%mod;
	return ans;
}
int calc(int x,int y){
	if (y==1 || y==5) return x;
	if (y==2 || y==4) return x==0?2:(x&1);	
	return x&1^1;
}
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]);
		for (j=1; j<=5; j++) b[i][j]=calc(a[i],j);
	}
	memset(dp,60,sizeof(dp));
	dp[0][1]=dp[0][2]=dp[0][3]=dp[0][4]=dp[0][5]=0;
	for (i=1; i<=n; i++)
		for (j=1; j<=5; j++) dp[i][j]=min(dp[i][j-1],dp[i-1][j]+b[i][j]);
	printf("%d\n",dp[n][5]);
	return 0;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int a=2*n-m/2;
	int b=m/2-n; 
	if( m<2*n || m>4*n ||m%2!=0){
		printf("No");
	}else if(a>=0&&b>=0){
		printf("Yes");
	}
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 18) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 200010;

int n;
int a[MAXN];

int main()
{
	
	n = inp();
	for (int i = 1; i <= n; ++ i)
	{
		a[i] = inp()-i;
	}
	if (a[1] != -1)
	{
		puts("-1");
		return 0;
	}
	for (int i = 2; i <= n; ++ i)
		if (a[i] > a[i-1])
		{
			puts("-1");
			return 0;
		}
	map<int, int> F;
	for (int i = 1; i <= n; ++ i)
		F[-i] = i;
	for (int i = 1; i <= n; ++ i)
		F[a[i]] = max(F[a[i]], i);
	ll ans = 0;
	for (int i = 1; i <= n; ++ i)
		ans += F[-i]-i;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\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 ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

// greatest common divisor
long long gcd(long long a, long long b) {
  long long r = 1;
  while (r != 0) {
    r = a%b; a = b; b = r;
  }
  return a;
}

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

  int n; cin >> n;
  int ans = 0;
  while(n--) {
    int a; cin >> a;
    ans = gcd(ans, a);
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
   long long int h,c=0,sum=0;
   cin>>h;
   while(h!=1)
   {
       h=h/2;
       c++;
   }
   for(int i=0;i<=c;i++)
   {
       sum=sum+pow(2,i);
       
   }
   cout<<sum;
    return 0;
}


Measured memory_bytes: 256