akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

template <typename T>
T calc(T a, T b, T p) {
    if (b == 0) return 1;

    if (b % 2 == 0) {
		T d = calc(a, b / 2, p);
		return (d * d) % p;
    } else {
		return (a * calc(a, b - 1, p)) % p;
    }

    return 0;
}

int main() {
	const ll MOD = 1e9 + 7;
	ll H, W, A, B;
	cin >> H >> W >> A >> B;

	vector<ll> v(H + W, 0);
	vector<ll> v_inv(H + W, 0);
	v[0] = 1;
	v_inv[0] = 1;

	for (int i = 1; i < H + W; i++) {
		v[i] = v[i - 1] * i;
		v[i] %= MOD;
		
		v_inv[i] = calc(v[i], MOD - 2, MOD);
		v_inv[i] %= MOD;
	}

	ll res = 0;
	for (int i = B + 1; i <= W; i++) {
		int x = i - 1, y = H - A - 1;
		ll tmp1 = (v[x + y] * v_inv[x]) % MOD;
		tmp1 *= v_inv[y];
		tmp1 %= MOD;

		x = W - i;
		y = A - 1;
		ll tmp2 = (v[x + y] * v_inv[x]) % MOD;
		tmp2 *= v_inv[y];
		tmp2 %= MOD;

		res += (tmp1 * tmp2);
		res %= MOD;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3328
(* O(b log b) *)
Scanf.scanf "%d %d" @@ fun a b ->
  let rev n =
    let rec f acc n = if n <= 0 then acc else f (acc * 10 + n mod 10) @@ n / 10 in f 0 n in
  let ans = ref 0 in
  for n = a to b do
    if rev n = n then incr ans
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 2432
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defparameter *hash-memo* (make-hash-table :test #'equal))

(defmacro dp (&body func)
  `(let* ((f (quote func))
          (num (gethash f *hash-memo*)))
     (if num
       num
       (setf (gethash f *hash-memo*) ,func))))

(let ((x (read-line)))
  (loop repeat (length x)
        do
        (princ #\x)))


Measured memory_bytes: 14004
#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)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m){
        cin >> a[i];
        if(i > 0 && a[i] == a[i-1] + 1){
            cout << 0 << endl;
            return 0;
        }
    }

    vector<int> f(100010);
    f[0] = f[1] = 1;
    for(int i = 2; i < 100010; i++){
        f[i] = f[i-1] + f[i-2];
        f[i] %= MOD;
    }

    int pos = 0;
    int ans = 1;
    rep(i, m){
        if(pos > a[i]){
            continue;
        }

        int d = a[i] - pos - 1;
        ans *= f[d];
        ans %= MOD;
        pos = a[i] + 1;
    }

    if(pos < n){
        int d = n - pos;
        ans *= f[d];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x/a;
  double rad;
  if (s >= a*b/2) {
    double h = (a*b-s)*2/a;
    rad = atan2(h,a);
  } else {
    double w = s*2/b;
    rad = atan2(b,w);
  }
  double PI = acos(-1);
  double deg = rad/(2*PI)*360;
  printf("%.10f\n", deg);
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b, ans = 0;
  cin >> n >> a >> b;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  map<int, int> done;
  for (int i = 0; i < n; i++) {
    if (arr[i] <= a && done[i] == 0) {
      done[i] = 1;
      int c = 0;
      for (int j = i + 1; j < n; j++) {
        if (done[j] != 0) continue;
        if (c == 2) {
          break;
        } else if (c == 0) {
          if (arr[j] >= a + 1 && arr[j] <= b) {
            done[j] = 1;
            c++;
          }
        } else if (c == 1) {
          if (arr[j] >= b + 1) {
            done[j] = 1;
            c++;
          }
        }
      }
      if (c == 2) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


class maki {
	static long gcd(long x,long y){
    	if(y==0){
    		return x;
    	}
    	return gcd(y,x%y);
    }
    static void Main(string[] args) {
        var cin=Console.ReadLine().Split().Select(long.Parse).ToArray();
        //int n = int.Parse(Console.ReadLine());
        //string s=Console.ReadLine();
 
        long a=cin[0];
        long b=cin[1];
        long c=cin[2];
        long d=cin[3];
        long e=c*d/gcd(c,d);
        a--;

        long ans= b-((b/c)+(b/d)-(b/e));
        ans-= a-((a/c)+(a/d)-(a/e));
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;

  cout << c << " " << a << " " << b << endl;
  return 0;
}

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


typedef long long ll;


int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<ll> p(A), q(B), r(C);
	for (int i = 0; i < A; ++i) cin >> p[i];
	for (int i = 0; i < B; ++i) cin >> q[i];
	for (int i = 0; i < C; ++i) cin >> r[i];

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());

	p.resize(X);
	q.resize(Y);
	
	int D = p.size() + q.size() + r.size();
	vector<ll> s(D);
	for (int i = 0; i < p.size(); ++i) s[i] = p[i];
	for (int i = 0; i < q.size(); ++i) s[i + p.size()] = q[i];
	for (int i = 0; i < r.size(); ++i) s[i + p.size() + q.size()] = r[i];

	sort(s.rbegin(), s.rend());

	ll ans = accumulate(s.begin(), s.begin() + X + Y, 0LL);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 7376
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int n,C;
pair<P,int> p[111111];
int s[111111],t[111111],c[111111],ke[111];
int table[111111];
signed main(){
	cin>>n>>C;
	rep(i,n){
		int s,t,c;
		cin>>s>>t>>c;
		p[i]={{s,t},c};
	}
	sort(p,p+n);
	rep(i,n){
		if(ke[p[i].second]==p[i].first.first){
			table[p[i].first.first+1]++;
			table[p[i].first.second+1]--;
		}
		else{
			table[p[i].first.first]++;
			table[p[i].first.second+1]--;
		}
		ke[p[i].second]=p[i].first.second;
	}
	
	rep(i,100011){
		table[i+1]+=table[i];
	}
	rep(i,100011){
		ans=max(ans,table[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4864
N = int(input())
a = [int(input()) for _ in range(N)]
p = 1
c = 0
while True:
  c += 1
  next = a[p-1]
  if next == 2:
    print(c)
    break
  if next == 0:
    print(-1)
    break
  a[p-1] = 0
  p = next


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

bool pal(int x)
{
  int ax[5];
  int y = x;
  for (int i = 0; i < 5; i++) {
    ax[i] = y % 10;
    y = (y-ax[i])/10;
  }
  if (ax[0] == ax[4] && ax[1] == ax[3])
    return true;
  else
    return false;
}

int main()
{
  int a, b;
  cin >> a >> b;
  int num;
  for (int x = a; x <= b; x++) {
    if (pal(x))
      num++;
  }
  cout << num << endl;
  return 0;
}


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

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

    
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    int sum = 0;
    rep(i,n) cin >> a[i];
    rep(i,n){
        cin >> b[i];
        sum += b[i];
    }
    rep(i,n-1) cin >> c[i];
    
    rep(i,n-1){
        if(a[i+1] - a[i] == 1){
            sum += c[a[i] - 1];
        }
    }
    
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> ans(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
		ans[0]=0;
	ans[1]=abs(v[1]-v[0]);
	ans[2]=abs(v[2]-v[0]);
	for(int i=3;i<n;i++){
	ans[i]=(min(abs(v[i]-v[i-1])+ans[i-1],abs(v[i]-v[i-2])+ans[i-2]));
  }
  cout<<ans[n-1];
}

Measured memory_bytes: 4024
#include<stdio.h>
#include<stdlib.h>

#define MAX 5000001


int H = 0;

void swap(int* A, int i, int j) {
    int temp;
    temp = A[i];
    A[i] = A[j];
    A[j] = temp;
}

void maxheapify(int* A, int i) {
    int left, right, largest;
    left = 2 * i;
    right = 2 * i + 1;
    if (left <= H && A[left] > A[i]) largest = left;
    else largest = i;
    if (right <= H && A[right] > A[largest]) largest = right;

    if (largest != i) {
        swap(A, i, largest);
        maxheapify(A, largest);
    }
}

int heapextractmax(int* A) {
    int max;

    max = A[1];
    A[1] = A[H];
    H--;
    maxheapify(A, 1);
    return max;
}

void heapincreasekey(int* A, int i, int key) {
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        swap(A, i, i / 2);
        i = i / 2;
    }
}
void maxheapinsert(int* A, int key) {
    H++;
    heapincreasekey(A, H, key);
}

int main() {
    int max, A[MAX], k;
    char com[16];

    while (1) {
        scanf(" %s", com);
        if (com[0] == 'i') {
            scanf("%d", &k);
            maxheapinsert(A, k);
        }
        else if (com[1] == 'x') {
            max = heapextractmax(A);
            printf("%d\n", max);
        }
        else break;
    }

    return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

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

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,a,b,c,d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	for(ll i=a-1;i<max(c,d)-1;i++){
			if(s[i]=='#' && s[i+1]=='#'){
				cout << "No\n";
				return 0;
			}
	}
	bool frag=true;
	if(c>d){
		frag=false;
		for(ll i=b-1;i<=d-1;i++){
			if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') frag=true;
		}
	}
	Yes(frag);
	return 0;
}


Measured memory_bytes: 640
#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;

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

vector<int> d;

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

    int N;
    cin >> N;

    d.resize(N, 0);
    int total = 0;
    rep (i, N) { cin >> d[i]; total += d[i]; }

    u64 ans = 0;
    rep (i, N)
    {
        ans += d[i] * (total - d[i]);
    }

    cout << ans / 2 << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] W = new int[n];
        for(int i=0;i<n;i++)W[i] = sc.nextInt();
        System.out.println(minsort(W));
    }
    public static int minsort(int [] W){
        int cost = 0;
        int [] sorted = W.clone();
        Arrays.sort(sorted);
        for(int i=0;i<W.length;i++){
            int cnt = 0;
            int x = getindex(W,sorted[i]);
            while(x>i){
                cnt++;
                int y = getindex(W,sorted[x]);
                cost+=W[y];
                swap(W,x,y);
                x = y;
            }
            cost+=Math.min(sorted[i]*cnt,sorted[i]*2+sorted[0]*(cnt+2));
        }
        return cost;
    }
    public static void swap(int [] W,int i,int j){
        int w = W[i];
        W[i] = W[j];
        W[j] = w;
    }
    public static int getindex(int [] L,int num){
        for(int i=0;i<L.length;i++){
            if(L[i] == num) return i;
        }
        return -1;
    }
}


Measured memory_bytes: 31944
# import sys

n = int(raw_input())
S = map(int, raw_input().strip(" ").split(" "))
q = int(raw_input())
T = map(int, raw_input().strip(" ").split(" "))

count = 0
for j in T:
	for n in S:
		if n == j:
			count += 1
			break

print count 

Measured memory_bytes: 4708
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
B = [abs(A[i-1] - A[i]) for i in range(1, N+2)]
C = sum(B)
for i in range(1, N+1):
    x = B[i-1]
    y = B[i]
    z = abs(A[i-1] - A[i+1])
    print(C - x - y + z)

Measured memory_bytes: 13920
#include <iostream>
#include <limits>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = numeric_limits<ll>::max();
    for(ll nc = 0; nc <= max(2 * x, 2 *y); ++nc){
        const ll na = max(0LL, (2 * x - nc + 1) / 2);
        const ll nb = max(0LL, (2 * y - nc + 1) / 2);
        ans = min(
            ans,
            a * na + b * nb + c * nc
        );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def comb_mod(a, b)
  return 0 if a < b
  return comb_mod(a, a - b) if b > a - b
  mul = div = 1
  b.times do |i|
    mul *= a - i
    div *= i + 1
    mul %= MOD
    div %= MOD
  end
  mul * pow_mod(div, MOD - 2) % MOD
end

def pow_mod(a, pow)
  if pow == 0
    1
  elsif pow.odd?
    a * pow_mod(a, pow - 1) % MOD
  else
    half = pow_mod(a, pow / 2)
    half * half % MOD
  end
end

X, Y = gets.split.map(&:to_i)

if (X + Y) % 3 != 0
  puts 0
  exit
end

m = (2 * X - Y) / 3
n = X - 2 * m

if m < 0 || n < 0
  puts 0
  exit
end

puts comb_mod(n + m, n)


Measured memory_bytes: 1788
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			long m = sc.nextLong();
			long n = sc.nextLong();
			
			System.out.printf("%d %d\n",gcd(m, n), lcm(m, n));
		}
	}
	
	public static long gcd(long a, long b){
		
		if(b == 0)	return a;
		else return gcd(b, a % b);
	}
	
	public static long lcm(long a, long b){
		return a * b / gcd(a, b);
	}
}

Measured memory_bytes: 18084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
    int ans;
    vector<int> x(m);
    for (int i = 0; i < m; i++)
    {
        cin >> x[i];
    }

    if(n > m){
        ans = 0;
    }
    else{
        sort(x.begin(), x.end());

        vector<int> l(m-1);
        for (int i = 0; i < m-1; i++)
        {
            l[i] = x[i+1] - x[i];
        }
        sort(l.begin(), l.end());

        int sum = 0;
        for (int i = 0; i < n-1; i++)
        {
            sum += l[m-2-i];
        }

        ans = x[m-1] - x[0] - sum;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 4028
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1010101010
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define mp make_pair

using namespace std;





int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

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

	return ans;
}



bool negative[1010];
int main() {
	string A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	int a = A.length(), b = B.length(), c = C.length();
	if (A[a - 1] == B[0] && B[b - 1] == C[0])cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#pragma  warning (disable:4996) 
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#include<iomanip>
#include<set>
#include <numeric>
#include<map>
using namespace std;
typedef long long ll;

int main()
{
	int n, k[101];
	scanf("%d", &n);
	double sum = 0; int pjs;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &k[i]);
		sum += k[i]*1.0;
	}
	sum /= n;
	pjs = round(sum);
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans += (k[i] - pjs) * (k[i] - pjs);
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<ll> dat;
void make(ll now,int cnt){
  dat.emplace_back(now);
  if(cnt==11){
    return ;
  }
  ll p=now%10;
  if(p==9){
    make(now*10+8,cnt+1);
    make(now*10+9,cnt+1);
  }
  else if(p==0){
    make(now*10+1,cnt+1);
    make(now*10+0,cnt+1);
  }
  else{
    make(now*10+p+1,cnt+1);
    make(now*10+p,cnt+1);
    make(now*10+p-1,cnt+1);
  }
}
int main(){
ll k;
cin>>k;
for(ll i=1;i<10;i++)make(i,1);
sort(all(dat));
cout<<dat[k-1]<<"\n";
}

Measured memory_bytes: 10604
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            // 2<= K<=100
            int K = int.Parse(Console.ReadLine());
            //1<=n<=Kから偶数と奇数を選ぶ
            int result = 0;

            for (int i = K; 1 < i; --i)
            {
                result += i / 2;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

LL f[5000 * 5000 + 1];

int main() {
  LL n;
  cin >> n;
  LL a[4], b[4];
  FI(i, 1, 3) cin >> a[i];
  FI(i, 1, 3) cin >> b[i];
  LL mv = 0;
  FI(i, 1, 3) {
    if (a[i] >= b[i]) continue;
    LL d = b[i] - a[i];
    for (int j = a[i]; j <= n; j++) {
      f[j] = max(f[j], f[j - a[i]] + d);
      mv = max(mv, f[j]);
    }
  }
  memset(f, 0, sizeof f);
  n += mv;
  mv = 0;
  FI(i, 1, 3) {
    if (a[i] <= b[i]) continue;
    LL d = a[i] - b[i];
    for (int j = b[i]; j <= n; j++) {
      f[j] = max(f[j], f[j - b[i]] + d);
      mv = max(mv, f[j]);
    }
  }
  n += mv;
  cout << n << endl;
}


Measured memory_bytes: 195584
N = int(input())
N_base = N
i = 1
while True:
    mod = N%10
    N = N//10
    if N == 0 and mod != 0:
        break
    elif N == 0 and mod == 0:
        i += 1
        break
    else:
        i += 1
if i == 1:
    print(N_base)
else:
    num = 0
    for j in range(1,i+1,2):
        if j == i:
            num += N_base - 10**(i-1) + 1
        else:
            num += 10**(j) - 10**(j-1)
    print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int>a(n);rep(i,n)cin>>a[i];
  vector<int>b = a;
  sort(all(b));
  int tmp = b[n/2];
  int tmp2 = b[n/2-1];
  rep(i,n){
    if(a[i] < tmp)print(tmp);
    else print(tmp2);
  }
  return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c,i=0,x,y,z;
	cin >> a >> b >> c;
	while(i<50000)
	{
		if(a%2!=0||b%2!=0||c%2!=0)
		{cout << i;break;}
		x=a/2;y=b/2;z=c/2;
		a=y+z;b=x+z;c=x+y;
		i++;
	}
	if(i>=50000)
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
P p[ohara];

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

  cin >> n;
  rep(i, n) {
    cin >> a >> b;
    p[i] = m_p(b, a);
  }
  sort(p, p + n);
  ll now = 0;
  rep(i, n) {
    if (now + p[i].se <= p[i].fi) {
      now += p[i].se;
    } else {
      Cout("No");
      return 0;
    }
  }
  Cout("Yes");
  return 0;
}

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


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};


ll dp[5050][5050];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    UnionFind uf(n);
    vector<int>used(n);
    rep(i,n){
        int x;
        cin>>x;
        if(x==-1)continue;
        if(!uf.unite(i,x-1)){
            used[i]=1;
            used[x-1]=1;
        }
    }
    vector<int> ng(n);
    rep(i,n){
        ng[uf.find(i)]|=used[i];
    }
    vector<int> b;
    int cnt=0;
    rep(i,n){
        if(uf.find(i)!=i)continue;
        if(!ng[i])b.push_back(uf.size(i));
        else ++cnt;
    }
    int m = b.size();
    dp[0][0]=1;
    ll sum=0;
    rep(i,m){
        rep(j,m){
            dp[i+1][j+1]+=dp[i][j]*b[i]%mod;
        }
        rep(j,m){
            dp[i+1][j]+=dp[i][j]*(n-1)%mod;
            if(dp[i+1][j]>=mod)dp[i+1][j]-=mod;
        }
        sum += b[i]-1;
    }
    ll ans = n-cnt;
    rep(i,m)ans=ans*(n-1)%mod;
    ll fact=1;
    REP(i,2,m+1){
        ans+=mod-fact*dp[m][i]%mod;
        fact*=i;
        fact%=mod;
    }
    rep(i,m-1){
        sum=sum*(n-1)%mod;
    }
    ans+=mod-sum;
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 200896
(function set_utils(undefined){
	this.print_float = function print_float(val, base, pad, prec) {
		var p10=Math.pow(10,prec);
		var ival=""+Math.round(val*p10);
		if ( ival === '0' )
			return '0.000';
		var ilen=ival.length-prec;
		if(ilen===0)
			return "0."+ival.substr(ilen,prec);
		return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
	};
}).call(global);

(function(undefined){
	'use strict';

	(function init() {
		this.output = function() {
			console.log.apply( console, arguments );
		};
		this.stdin = process.openStdin();
		stdin.setEncoding('utf8');
		this.input_list = [];
		stdin.on('data', function(chunk){
			var result = chunk.match(/[-]?\d+/g);
			input_list = input_list.concat(result);
		});
		stdin.on('end', function(){
			fire();
		});
		this.input_number = function() {
			return parseInt( input_list.splice(0,1)[0] );
		};
		this.has_next = function() {
			return ! input_list.length;
		};
	}).call( this );

	(function solver(){
		function sq(x) {
			return x * x;
		}
		function check(v) {
		}
		this.fire = function() {
			setTimeout( function solve() {
				var a = input_number();
				var b = input_number();
				var c = input_number();
				var d = input_number();
				var e = input_number();
				var f = input_number();
				var delta = 1.0 / ( a*e - b*d );
				var x = ( e * c - b * f ) * delta;
				var y = ( a * f - d * c ) * delta;
				output( print_float(x,10,3,3) + ' ' + print_float(y,10,3,3)  );
				if ( ! has_next() )
					setTimeout( solve, 0, this );
			}, 0, this );
		};
	}).call(this);

}).call(global);

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

bool taro[201], hanako[201];
int taro_remain, hanako_remain;
int main()
{
  while(true){
    
    //chap1
    int n;
    cin >> n;
    if(!n)
      break;
    memset(taro, false, sizeof taro);
    memset(hanako, false, sizeof hanako);
    for(int i = 0; i < n; i++){
      int in;
      cin >> in;
      taro[in] = true;
    }

    //chap2
    for(int i = 1; i <= 2 * n; i++)
      if(!taro[i])
	hanako[i] = true;

    //chap3
    bool taros_turn = true;
    int field = 0;
    taro_remain = hanako_remain = n;
    while(taro_remain && hanako_remain){
      if(taros_turn){
	for(int i = field + 1; i <= 2 * n; i++){
	  if(taro[i]){
	    taro[i] = false;
	    taro_remain--;
	    field = i;
	    goto change;
	  }
	}
      }
      else{
	for(int i = field + 1; i <= 2 * n; i++){
	  if(hanako[i]){
	    hanako[i] = false;
	    hanako_remain--;
	    field = i;
	    goto change;
	  }
	}
      }
      field = 0;
    change:taros_turn = !taros_turn;
    }
    cout << hanako_remain << endl << taro_remain << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, i, res;
    cin >> N >> i;
    res = 0;
    for (int j = N; j >= i; i++) res++;
    cout << res << endl;
	return 0;
}

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

int kakuketanowa (int x) {
  int t=0;
  while (x>0) {
    t+=x%10;
    x/=10;
  }
  return t;
}
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  
  int s =0;
  for (int i=1;i<=N;i++) {
    int p = kakuketanowa (i);
    if (p>=A&&p<=B) {
      s+=i;
    }
  }
cout << s << endl;    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc160_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string a = input.Substring(2,1);
            string b = input.Substring(3,1);
            string c = input.Substring(4,1);
            string d = input.Substring(5,1);
            if (a == b && c==d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>

int main(){
	int d,r;
	double x=0,y=0;
	double rad=90;
	int a,b;
	
	while(scanf("%d,%d",&d,&r)!=EOF){
		if(!d && !r)break;
		
		x+=d*cos(rad*M_PI/180);
		y+=d*sin(rad*M_PI/180);
		
		rad-=r;
	}
	
	a=(int)x;
	b=(int)y;
	
	printf("%d\n%d\n",a,b);
	
	return 0;
	
}


Measured memory_bytes: 2096
def fun(x):
    if x==1:
        return 300000
    elif x==2:
        return 200000
    elif x==3:
        return 100000
    else:
        return 0
s=input()
s=s.split()
a=eval(s[0])
b=eval(s[1])
su=0
if a==b==1:
    su+=400000
su+=fun(a)
su+=fun(b)
print(su)


Measured memory_bytes: 3060
n = int(input())
a = []
for _ in range(n):
  a.append([int(i) for i in input().split(" ")])
b = []
for i in range(n):
  if a[i][0] == a[i][1]:
    b.append(1)
  else:
    b.append(0)
ans = False
for i in range(n-2):
  if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
    ans = True
    break
if ans:
  print("Yes")
else:
  print("No")

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

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 2*1e5+1;

int main()
{
	ll n;
	cin>>n;
	vector<ll> c(n);
	for(int i = 0; i < n; i++){
		cin>>c[i];
	}
	vector<ll> dp(MAXN,0);
	dp[c[0]]=1;
	for(int i = 1; i < n; i++){
		if(c[i]!=c[i-1]){
			dp[c[i]] = (dp[c[i]]+dp[c[i-1]]) % mod;
		}
	}

	cout << dp[c[n-1]] << endl;

	return 0;
}

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

long long n, a[200003], cnt[200003], ans=0;

int main(){
	memset(cnt,0,sizeof cnt);
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i=1;i<=n;i++){
		ans+=(cnt[i]*(cnt[i]-1))/2;
	}
	for (int i=0;i<n;i++){
		ans-=(cnt[a[i]]*(cnt[a[i]]-1))/2;
		ans+=max((long long)0,((cnt[a[i]]-1)*(cnt[a[i]]-2))/2);
		cout << ans << "\n";
		ans-=max((long long)0,((cnt[a[i]]-1)*(cnt[a[i]]-2))/2);
		ans+=(cnt[a[i]]*(cnt[a[i]]-1))/2;
	}
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

#define square(s) (s)*(s)
#define scast(type,e) static_cast<type>(e)
#define rep(i,n) for(int i = 0; i < n;i++)
#define range(a) a.begin(),a.end()


template<class T>
using vec = vector<T>;
using ll = long long;
using ull = unsigned long long;

constexpr ll mod = 1000000007;

int main() {
	int N,D;
	cin >> N >> D;

	cout << (N - 1) / (D * 2 + 1) + 1 << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int N, x; cin >> N >> x;
	vector<int> a(N);
	REP(i,N){ 
		cin >> a[i];
	}

	SORT(a);

	int k = 0;
	int sum = 0;
	int ans = 0;
	REP(i,N){
		sum += a[i];
		if(sum <= x) k++;
		else break;
	}
	if(k == N){
		if(sum == x) ans = N;
		else ans = N - 1;
	}else ans = k;

	cout << ans << endl;



	return 0;

}


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

int main(){
  int N;
  cin>>N;
  double ans =0;
  for(int i=0;i<N;i++){
    double x;
    string s;
    cin>>x>>s;
    if(s=="JPY") ans += x;
    else ans += x*380000.0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int dp0[2005][2005];
int dp1[2005][2005];

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> s(n+1), t(m+1);
  REP(i, n) cin >> s[i];
  REP(i, m) cin >> t[i];
  dp0[0][0] = 1;

  REP(i, n+1) REP(j, m+1){
    dp0[i+1][j] = (dp0[i+1][j] + dp0[i][j]) % mod;
    dp1[i][j] = (dp1[i][j] + dp0[i][j]) % mod;
    dp1[i][j+1] =(dp1[i][j+1] + dp1[i][j]) % mod;
    if(s[i] == t[j])  dp0[i+1][j+1] = (dp0[i+1][j+1] + dp1[i][j]) % mod;
  }
  cout << dp1[n][m] << endl;


  return 0;
}

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

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

    vector<string> ans;
    if (n & 1)
    {
        for (int i = n-1; i >= 0; i-=2)
        {
            ans.push_back(a[i]);
            cout << a[i] << endl;
        }
        for (int i = 1; i < n-1; i+=2)
        {
            cout << a[i] << endl;
        }
    }
    else
    {
        vector<string> sub;
        for (int i = 0; i < n-1; ++i)
        {
            sub.push_back(a[i]);
        }

        cout << a[n-1] << endl;
        for (int i = n-3; i >= 0; i -= 2)
        {
            cout << sub[i] << endl;
        }
        for (int i = 0; i <= n-2; i += 2)
        {
            cout << sub[i] << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 17652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n; cin >> n;
    ll mod = 1e9 + 7;
    ll res = modpow(10, n, mod);
    res += modpow(8, n, mod);
    res %= mod;
    ll resmin = (modpow(9, n, mod) * 2) % mod;
    res -= resmin;
    if (res < 0) res += mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> duration;

int calc(int start, int end) {
    return (end/100-start/100)*60 + end%100-start%100;
}

int main() {
    while(true) {
        int N, P, Q;
        cin >> N >> P >> Q;
        if(!N && !P && !Q) break;

        vector<duration> v;

        for(int i = 0; i < N; ++i) {
            int M;
            cin >> M;
            duration d;
            d.first = P;
            cin >> d.second;
            v.push_back(d);
            for(int j = 0; j < M-1; ++j) {
                cin >> d.first >> d.second;
                v.push_back(d);
            }
            cin >> d.first;
            d.second = Q;
            v.push_back(d);
        }

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

        int start = v[0].first, end = v[0].second;
        int ans = 0;
        for(int i = 1; i < v.size(); ++i) {
            if(v[i].first > end) {
                ans = max(ans, calc(start, end));
                start = v[i].first;
                end = v[i].second;
            }
            if(start < v[i].second) end = max(end, v[i].second);
        }
        ans = max(ans, calc(start, end));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
program main
    implicit none
    character(100) :: s
    read*, s

    if (trim(s) == 'Sunny')then
        print*, 'Cloudy'
    else if(trim(s) == 'Cloudy')then
        print*, 'Rainy'
    else
        print*, 'Sunny'
    end if
    stop


    
end program

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

int main(){
    int N;
    int n_AC = 0, n_WA = 0, n_TLE = 0, n_RE = 0;
    string stat;

    std::cin >> N;
    string AC = "AC";
    for(int i = 0; i < N; i++){
        std::cin >> stat;
        //scanf("%s", stat);
        //printf("%s", stat);
        //std::cout << stat << "\n";
        if(stat == "AC"){
            n_AC = n_AC+1;
        }else if(stat == "WA"){
            n_WA = n_WA+1;
        }else if(stat == "TLE"){
            n_TLE = n_TLE+1;
        }else if(stat == "RE"){
            n_RE = n_RE+1;
        }
    }
    std::cout << "AC x " << n_AC << "\n";
    std::cout << "WA x " << n_WA << "\n";
    std::cout << "TLE x " << n_TLE << "\n";
    std::cout << "RE x " << n_RE << "\n";


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  print(6-a-b);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        while(A>=0&&C>=0){
            C=C-B;
          	if(C<=0) break;
          	A=A-D;
          	if(A<=0) break;
        }
      	//System.out.println(A+" "+C);
        if(A<=0)
            System.out.println("No");
        if(C<=0)
            System.out.println("Yes");
    }
}

Measured memory_bytes: 35720
from heapq import heappush, heappop


def solve(x, y, a, b, c, p_list, q_list, r_list):
    res = sum(p_list[:x]) + sum(q_list[:y])
    res_max = res
    # print(res)
    h = []
    for i in range(x):
        heappush(h, p_list[i])
    for j in range(y):
        heappush(h, q_list[j])
    for i in range(min(x + y, c)):
        d = heappop(h)
        res -= d
        res += r_list[i]
        res_max = max(res, res_max)
        # print(res)

    return res_max


def main():
    x, y, a, b, c = map(int, input().split())
    p_list = list(sorted(list(map(int, input().split())), reverse=True))
    q_list = list(sorted(list(map(int, input().split())), reverse=True))
    r_list = list(sorted(list(map(int, input().split())), reverse=True))
    res = solve(x, y, a, b, c, p_list, q_list, r_list)
    print(res)
    # for r in res:
    #     print(r)


def test():
    assert solve(1, 2, 2, 2, 1, [4, 2], [5, 1], [3]) == 12
    assert solve(2, 2, 2, 2, 2, [8, 6], [9, 2], [2, 1]) == 25
    assert solve(2, 2, 4, 4, 4, [14, 13, 12, 11], [24, 23, 22, 21], [4, 3, 2, 1]) == 74


if __name__ == "__main__":
    test()
    main()


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

int main() {
	int N; cin >> N;
	int a[200010];
	long b[200010];
	b[0]=0;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    b[i+1]=b[i]+a[i];
	}
	map<long, int> mp;
	for(int i=0; i<=N; ++i) ++mp[b[i]];
	long S=0, P, i;
	for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
	    i=itr->second;
	    P=i*(i-1)/2;
	    S += P;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include<algorithm>
#include <vector>
#include<map>
#include<deque>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main(){
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a + a - 1, b + b - 1));
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    A = I()
    B = I()
    print(6-(A+B))

main()



Measured memory_bytes: 27124
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    string s;
    cin>>s;
    int64 lo=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='x'){
            lo++;
        }
    }
    if(lo>7){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}

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

using namespace std;

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

    int arr[3];
    int maxCandies = -1;
    for (int i = 0; i < 3; i++) cin >> arr[i];

    sort(arr, arr + 3);

    cout << ((arr[2] == arr[0] + arr[1]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  map<int, int> mp;
  mp[3] = 100000;
  mp[2] = 200000;
  mp[1] = 300000;

  Cin(int, x, y);
  int ans = mp[x] + mp[y];
  if (x == 1 && y == 1) ans += 400000;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256