akhauriyash/Code-Regression huggingface dataset:
module fast_prime_sieve
  implicit none
contains
  subroutine primes(p, m, n)
    integer, allocatable, intent(inout) :: p(:)
    integer, intent(inout) :: m
    integer, intent(in) :: n
    integer :: lp(n), pr(n), i, j
    lp(n) = 0
    m = 0
    do i = 2, n
      if (lp(i) == 0) then
        lp(i) = i
        m = m + 1
        pr(m) = i
      end if
      j = 1
      do j = 1, m
        if (pr(j) > lp(i) .or. i * pr(j) > n) exit
        lp(i * pr(j)) = pr(j)
      end do
    end do
    allocate(p(m))
    p = pr(1:m)
  end
end module fast_prime_sieve
module bisection
  implicit none
  integer, private, parameter :: intkind = 4
contains
  integer function lower_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) < b) then
        l = m
      else
        r = m
      end if
    end do
    res = r
  end
  integer function upper_bound(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b
    integer :: l, r, m
    l = 0
    r = size(a) + 1
    do while (r - l > 1)
      m = (l + r) / 2
      if (a(m) > b) then
        r = m
      else
        l = m
      end if
    end do
    res = l
  end
end module bisection
module gcd_lcm
  implicit none
  integer, private, parameter :: intkind = 4
contains
  integer(intkind) function gcd(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    integer(intkind) :: a, b
    a = max(abs(x), abs(y))
    b = min(abs(x), abs(y))
    res = a
    do while (b > 0)
      res = b
      b = mod(a, b)
      a = res
    end do
  end
  integer(intkind) function lcm(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    res = x / gcd(x, y) * y
  end
end module gcd_lcm
program coprime
  use fast_prime_sieve
  use bisection
  use gcd_lcm
  implicit none
  integer :: n, m, d, q, i, j
  logical :: pairwise = .true.
  integer, allocatable :: a(:), p(:)
  logical, allocatable :: b(:)
  character(8), parameter :: x = 'pairwise', y = 'setwise ', z = 'not     '
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  call primes(p, m, maxval(a(1:n)))
  allocate(b(m))
  b = .false.
  do i = 1, n
    d = a(i)
    do j = 1, m
      q = p(j)
      if (q * q > d) exit
      if (mod(d, q) == 0) then
        if (b(j)) then
          pairwise = .false.
          goto 100
        end if
        b(j) = .true.
        do while (mod(d, q) == 0)
          d = d / q
        end do
      end if
    end do
    if (d /= 1) then
      j = lower_bound(p, d)
      if (b(j)) then
        pairwise = .false.
        goto 100
      end if
      b(j) = .true.
    end if
  end do
  100 if (pairwise) then
    write(*,'(a)') 'pairwise coprime'
    stop
  end if
  d = a(1)
  do i = 2, n
    d = gcd(d, a(i))
  end do
  write(*,'(a)') trim(merge('setwise', 'not    ', d == 1)) // ' coprime'
end program coprime

Measured memory_bytes: 11376
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int n;
double x[8], y[8], t = 0;

int main()
{	

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	
	for (int i = 0; i < n - 1; i++)
		for (int j = i + 1; j < n; j++)
			t += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));

	t *= 2;
	t /= n;

	cout << setprecision(12) << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

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

    int n; cin >> n;
    vector<double> heads(n+1); for (int i = 1; i <= n; ++i) cin >> heads[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, -1.0));

    dp[1][0] = 1 - heads[1];
    dp[1][1] = heads[1];
    for (int i = 2; i <= n; ++i) {
        dp[i][i] = heads[i] * dp[i-1][i-1];
        dp[i][0] = (1 - heads[i]) * dp[i-1][0];
    }
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j < i; ++j) {
            dp[i][j] = heads[i] * dp[i-1][j-1] + (1 - heads[i]) * dp[i-1][j];
        }
    }

    double ans = 0;
    for (int j = n/2 + 1; j <= n; ++j) ans += dp[n][j];
    cout << fixed << setprecision(10) << ans << '\n';
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

int t[510][510];
int sum[510][510];

void solve(){
    int n,m,q;
    cin >> n >> m >> q;
    rep(i,510){
        rep(j,510){
            t[i][j]=0;
        }
    }
    rep(i,m){
        int l,r;
        cin >> l >> r;
        t[l][r] += 1;
    }
    rep(i,510){
        rep(j,510){
            sum[i][j]=0;
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+t[i][j];
        }
    }
    vector<pair<int,int>> v;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        v.emplace_back(make_pair(a,b));
    }

    rep(i,q){
        int a,b;
        a=v[i].first;
        b=v[i].second;
        cout << sum[b][b]+sum[a-1][a-1]-sum[b][a-1]-sum[a-1][b] << endl;
    }

}

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


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



int main(){
	int n,s;
	while(cin>>n>>s&&(n||s)){
		int dp[11][11][101]={};
		dp[0][0][0] = 1;
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=10;j++){
				rep(k,s+1){
					if(k-(j-1)>=0) dp[i][j][k] = dp[i][j-1][k-1] + dp[i-1][j-1][k-(j-1)];
				}
			}
		}
		int ans = 0;
		rep(i,11) ans += dp[n][i][s];
		cout<<ans<<endl;
	}
}

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

int main() {
  int N, D;
  scanf("%d%d", &N, &D);

  int ans = 0;
  int range = 0;
  int add_range = 2 * D + 1;
  while (range < N) {
    range += add_range;
    ans++;
  }
  printf("%d", ans);
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-22.
//
# include <bits/stdc++.h>

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

string S;

bool is_kaibun(string s) {
    int n = s.size();
    if (n % 2 == 0) {
        string tmp = s.substr(n / 2, n / 2);
        reverse(tmp.begin(), tmp.end());
        return s.substr(0, n / 2) == tmp;
    } else {
        string tmp = s.substr(n / 2 + 1, n / 2);
        reverse(tmp.begin(), tmp.end());
        return s.substr(0, n / 2) == tmp;
    }
}

int main() {
    cin >> S;
    int N = S.size();
//    cout << is_kaibun(S) << endl;
//    cout << S.substr(0, (N-1)/2) << endl;
//    cout << S.substr((N+1)/2, (N-2)/2) << endl;
    if (is_kaibun(S) && is_kaibun(S.substr(0, (N-1)/2)) && is_kaibun(S.substr((N+1)/2, (N-1)/2))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int a[5], tmp, *b;
	
	while(1){
		cin >> tmp;
		if(tmp == 0){
			break;
		}
		a[0] = tmp;
		b = (int *)calloc(4, sizeof(int));
		b[tmp]++;
		for(int i = 1; i < 5; i++){
			cin >> tmp;
			a[i] = tmp;
			b[tmp]++;
		}
		
		if((b[1] != 0 && b[2] != 0 && b[3] != 0) || (b[1] == 0 && b[1] == b[2]) || (b[2] == 0 && b[2] == b[3]) || (b[3] == 0 && b[1] == b[3])){
			for(int i = 0; i < 5; i++){
				cout << "3" << endl;
			}
			free(b);
			continue;
		} else if(b[1] == 0){
			tmp = 2;
		} else if(b[2] == 0){
			tmp = 3;
		} else {
			tmp = 1;
		}
		
		for(int i = 0; i < 5; i++){
			cout << ((a[i] == tmp)? "1" : "2") << endl;
		}
		free(b);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;
//整形Shift + alt + f　2回
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/

/*
//桁数取得
unsigned GetDigit(unsigned num)
{
    unsigned digit = 0;
    while (num != 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}
*/

/*
//素数の真偽
vector<bool> IsPrime;
//素数のリスト
vector<int> PrimeList;
//素数の出現回数
map<int, int> CountPrime;

void sieve(int max)
{
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (int i = 2; i * i <= max; i++)         // 0からsqrt(max)まで調べる
        if (IsPrime[i])                        // iが素数ならば
            for (int j = 2; i * j <= max; j++) // (max以下の)iの倍数は
                IsPrime[i * j] = false;        // 素数ではない
}

void mkPrimeList()
{
    for (int i = 2; i <= IsPrime.size() - 1; i++)
    {
        if (IsPrime[i])
        {
            PrimeList.push_back(i);
        }
    }
}

void factor(int n)
{

    for (auto e : PrimeList)
    {
        int ct = 0;
        int tmp = n;
        while (tmp % e == 0)
        {
            tmp = tmp / e;
            ct++;
        }
        CountPrime.insert(make_pair(e, ct));
    }
}
*/

/*
// index が条件を満たすかどうか
bool isOK(int index)
{
    long double tmp = pow((double)index, n);
    //i^n が pを超えるか
    if (p < tmp)
        return true;
    else
        return false;
}

//二分探索
int binary_search()
{
    int left = 1;
    int right = p;

    while (right - left > 1)
    {
        long long int mid = left + (right - left) / 2;
        if (isOK(mid))
            right = mid;
        else
            left = mid;
    }

    //left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
    return right;
}
*/

int main()
{
    string s;
    string key = "keyence";
    int f = 0;
    int count = 0;

    cin >> s;

    int l = s.find("keyence");
    if (l == 0)
    {
        cout << "YES";
        return 0;
    }

    int r = s.rfind("keyence");
    if (r == s.length() - key.length())
    {
        cout << "YES";
        return 0;
    }

    for (int i = 1; i < key.length(); i++)
    {

        int l = s.find(key.substr(0, i));
        int r = s.rfind(key.substr(i, key.length() - i + 1));
        if (l != -1 && r != -1 && l < r)
        {
            //cout << l << " " << r << endl;
            if (l == 0 && r == s.length() - key.substr(i, key.length() - i + 1).length())
            {
                cout << "YES";
                return 0;
            }
        }
    }

    cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N, K;
    cin >> N >> K;
    if(K == 1) PRINT(0);
    else PRINT((N - K + 1) - 1);
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
    int a[3],b[3],v[5]={0},t=0;
    for(int i=0;i<3;i++){
        cin >> a[i]>>b[i];
    }
    for(int i=0;i<3;i++){
        if(a[i]==1)v[1]++;
        if(a[i]==2)v[2]++;
        if(a[i]==3)v[3]++;
        if(a[i]==4)v[4]++;
        if(b[i]==1)v[1]++;
        if(b[i]==2)v[2]++;
        if(b[i]==3)v[3]++;
        if(b[i]==4)v[4]++;
    }
    for(int i=1;i<=4;i++){
        if(v[i]%2==1) t++;
    }
    if(t==2 || t==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int l[300];
    for(int i = 0; i < n * 2; i++) cin >> l[i];
    sort(l, l + n * 2);
    int ans = 0;
    for(int i = 0; i < n; i++) ans += l[i * 2];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String t;
        String h;
        int t_point = 0;
        int h_point = 0;
        int n = sc.nextInt();
        for(int i = 0; i < n ;i++){
            t = sc.next();
            h = sc.next();
            if(t.compareTo(h) > 0){
                t_point += 3;
            }
            else if(t.compareTo(h) < 0){
                h_point += 3;
            }
            else{
                t_point += 1;
                h_point += 1;
            }
        }
        System.out.println(t_point + " " + h_point);
    }
}


Measured memory_bytes: 30348
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    long long s,x,t;
    cin>>n;
    int * a=new int[n];
    long long * b=new long long[n];
    s=0;
    x=0;
    t=99999999999999999999999999999;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        x+=a[i];
        b[i]=(long long)abs(s-2*x);
        if(t>b[i])
            t=b[i];
    }
    cout<<t<<endl;
    delete  a;
    delete  b;
    return 0;
}


Measured memory_bytes: 2560
//46
#include<iostream>
#include<algorithm>

using namespace std;

int fm(int y,int m,int d){
  return y*10000+m*100+d;
}

int main(){
  int year[]={1868,1912,1926,1989};
  int t[4]={fm(1868,9,8),fm(1912,7,30),fm(1926,12,25),fm(1989,1,8)};
  const char *s[]={"pre-meiji","meiji","taisho","showa","heisei"};
  for(int y,m,d;cin>>y>>m>>d;){
    int r=upper_bound(t,t+4,fm(y,m,d))-t;
    cout<<s[r];
    if(r>0){
      cout<<' '<<y-year[r-1]+1<<' '<<m<<' '<<d;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}


signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  Int ans=0;
  for(Int i=0;i<n;i++){
    Int tmp=0;
    for(Int j=0;j<=i;j++) tmp+=a[j];
    for(Int j=i;j<n;j++) tmp+=b[j];
    chmax(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

for i in range(A + 1):
    x = i
    y = A - i
    if (x * 2 + y * 4 == B):
        print('Yes')
        exit()

print('No')

'''
import sympy
#from numpy.linalg import solve
A, B = map(int, input().split())
# solve([x + y=A, 2 * x + 4 * y=B], [x, y])
x = sympy.Symbol('x')
y = sympy.Symbol('y')
eq1 = x + y - A
eq2 = 2 * x + 4 * y - B
aa = sympy.solve([eq1, eq2])
'''


Measured memory_bytes: 9176
A,B,K = map(int,input().split())
for i in range(K):
    if i%2 == 0:
        if A%2 == 1:
            A -= 1
        B += A/2
        A /= 2
    else:
        if B%2 == 1:
            B -= 1
        A += B/2
        B /= 2
print(int(A),int(B)) 

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<vector>


using namespace std;

struct A
{
	int n;
	int a;
};

struct A V_A[105];

class sort_
{
public:
		bool operator()(const A& a,const A& b)
		{
			if(b.n==a.n)
			{
				return a.a<b.a;
			}
			return b.n<a.n;
		}
};

int main()
{
	int n,m;
	while(true)
	{
		for(int i=0;i<100;i++)
		{
			V_A[i].n=0;
			V_A[i].a=i;
		}
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				int k=0;
				scanf("%d",&k);
				V_A[j].n+=k;
			}
		}
		sort(V_A,V_A+m,sort_());
		for(int i=0;i<m;i++)
		{
			if(i!=0)printf(" ");
			printf("%d",V_A[i].a+1);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1048
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll factorial(ll n){
    ll ret = 1;
    FOR(i, 1, n+1){
        ret *= i;
    }
    return ret;
}

const int N_MAX = 100010;
ll Per[N_MAX] = {}; // n!
ll Inv[N_MAX] = {}; // 1/2, 1/3, ...
ll Ac[N_MAX] = {}; // Invの累積和
 
// a^b mod p
ll mod_pow(ll a, ll b){
    if(b==0) return 1;
 
    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }
    Inv[1] = 1;
    FOR(i, 2, N_MAX){
        Inv[i] = mod_pow(i, 1000000005);
    }
    // 累積和
    Ac[1] = Inv[1];
    FOR(i, 2, N_MAX){
        Ac[i] = Ac[i-1] + Inv[i];
    }

    ll expectation = 0;

    FOR(i, 0, N){
        ll p = 0;
            
        // FOR(j, 0, N){
        //     ll n = abs(j-i)+1;
        //     p += Inv[n];
        //     p %= mod;
        // }

        p += Ac[N-1 - i + 1]; // 右
        p %= mod;

        p += Ac[i-0 + 1] - Ac[1]; // 左
        p %= mod;

        expectation += A[i] * p;
        expectation %= mod;
    }

    ll ans = expectation * Per[N];
    ans %= mod;
    p(ans);
    
    return 0;
}

Measured memory_bytes: 3456
A, B, C, X = map(int, [input() for i in range(4)])
ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + 50 * c == X:
                ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int r, d , x;
    cin >> r >> d >> x;
    int n = 10;
    rep (i, n){
        int ans = r * x - d;
        x = ans;
        cout << ans << endl;

    }
}

Measured memory_bytes: 256
import collections
n, x, y = map(int, input().split())
lst = []
for i in range(1, n+1):
  for j in range(i, n+1):
    tmp = min(abs(i-j), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j))
    lst.append(tmp)
lst = collections.Counter(lst)
for i in range(1, n):
  print(lst[i])

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

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if(n == 1 && n == b) cout << (a*b)/b - a * (b/b) << endl;
  else if (n >= b) cout << (a*(b-1))/b - a * ((b-1)/b)  << endl;
  else if (n < b) cout << (a*n)/b - a * (n/b)  << endl;



  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define MOD 1000000007
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define print_arr(a, n) \
  for (int i = 0; i < n; i++) cout << a[i] << ;
#define deb(n) cerr << #n << "=" << n << \n;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> grades;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    grades.pb(temp);
  }
  // unsigned ll product = 1;
  //
  // for (int i = 0; i <= k - 1; i++) {
  // product = product * grades[i];
  // }

  for (int i = 0; i < n - k; i++) {
    if (grades[k + i] > grades[i]) {
      cout << "Yes" << endl;

    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4312
rex = Regexp.new("^[#{Regexp.escape("+-*")}]$")
exp = gets.split(" ")
loop do
  s = exp.index {|x| (rex =~ x) != nil} - 2
  e = exp.size > 3 ? exp.slice(s, 3) : exp
  r = case e.last
    when "+" then e[0].to_i + e[1].to_i
    when "-" then e[0].to_i - e[1].to_i
    when "*" then e[0].to_i * e[1].to_i
  end
  if exp.size == 3
    exp = r
    break
  else
    exp[s, 3] = r.to_s
  end
end

puts exp

Measured memory_bytes: 8640
S=input()
n=len(S)
def dfs(i,f):
    if i==n-1:
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+S[i+1])+dfs(i+1,f+"+"+S[i+1])
    
print(dfs(0,S[0]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  ll ans = gcd(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
}


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

vector<int> G[100000];

int N, M, deg[100000], dp[100000], ans;
queue<int> que;
vector<int> ed;

void topological_sort(void){
	for(int i=0; i<N; i++){
		if(deg[i] == 0) que.push(i);
	}
	while(!que.empty()){
		int a = que.front(); que.pop();
		ed.push_back(a);
		for(int i=0; i<G[a].size(); i++){
			deg[G[a][i]]--;
			if(deg[G[a][i]] == 0) que.push(G[a][i]);
		}
	}
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int x, y; cin >> x >> y;
		x--; y--;
		deg[y]++;
		G[x].push_back(y);
	}
	topological_sort();
	for(int i=N-1; i>=0; i--){
		int b = ed[i];
		for(int j=0; j<G[b].size(); j++){
			if(dp[b] < dp[G[b][j]] + 1) dp[b] = dp[G[b][j]] + 1;
		}
	}
	for(int i=0; i<N; i++){
		if(ans < dp[i]) ans = dp[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<int> a(n); rep (i, n) cin >> a[i];
    sort(all(a));
    ll ok = 3000000000000000000, ng = -3000000000000000000;
    while (abs(ng - ok) > 1LL) {
        eprintf("ok:%lld, ng:%lld\n", ok, ng);
        ll med = (ng + ok) / 2LL;
        ll num = 0;
        rep (i, n) {
            if (a[i] < 0) {
                eprintf("neg\n");
                ll ok_i = n, ng_i = -1;
                ll y;
                if (med >= 0) y = -((med) / (-a[i]));
                else y = (-med - 1) / (-a[i]) + 1;
                eprintf("%lld\n", y);
                while (abs(ng_i - ok_i) > 1) {
                    eprintf("ok_i:%d, ng_i:%d\n", ok_i, ng_i);
                    ll med_i = (ng_i + ok_i) / 2;
                    if (a[med_i] >= y) ok_i = med_i;
                    else ng_i = med_i;
                }
                num += (n - ok_i); if (ok_i <= i) num--;
            } else if (a[i] == 0) {
                eprintf("zer\n");
                if (med >= 0) num += n - 1;
            } else {
                eprintf("pos\n");
                ll ok_i = -1, ng_i = n;
                ll y;
                if (med >= 0) y = (med) / a[i];
                else y = -(((-med) - 1) / a[i]) - 1;
                eprintf("%lld\n", y);
                while (abs(ng_i - ok_i) > 1) {
                    eprintf("ok_i:%d, ng_i:%d\n", ok_i, ng_i);
                    ll med_i = (ng_i + ok_i) / 2;
                    if (a[med_i] <= y) ok_i = med_i;
                    else ng_i = med_i;
                }
                num += ok_i + 1; if (ok_i >= i) num--;
            }
            eprintf("num:%lld\n", num);
        }
        num /= 2LL;
        eprintf("num: %lld, k: %lld\n", num, k);
        if (num >= k) ok = med;
        else ng = med;
    }
    cout << ok << "\n";
    return 0;
}

Measured memory_bytes: 1024
def BS(th, a):
    top = len(th)
    btm = 0

    while top > btm:
        mid = (top + btm)//2
        if th[mid] < a <= th[mid + 1]:
            return mid
        elif a <= th[mid]:
            top = mid
        else:
            btm = mid

N = int(input())
A = [int(i) for i in input().split()]

th = [0]
num_th = []
rem = []
max_i = 0
nonzeros = dict()

for i, a in enumerate(A):
    if a > th[-1]:
        th.append(a)
        num_th.append(1)
        rem.append(0)
        nonzeros[i] = max_i
        max_i += 1
    else:
        j = BS(th, a)
        if j - 1 >= 0:
            num_th[j - 1] += 1
        rem[j] += a - th[j]

for i in range(len(num_th) - 1, 0, -1):
    num_th[i - 1] += num_th[i]
'''
print(th)
print(num_th)
print(rem)
'''
for i in range(N):
    if i in nonzeros:
        ans = (th[nonzeros[i] + 1] - th[nonzeros[i]])*num_th[nonzeros[i]] + rem[nonzeros[i]]
        print(ans)
    else:
        print(0)

Measured memory_bytes: 27220
s = input()

s1 = int(s[:2])
s2 = int(s[2:])

if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12:
    print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MAX 8005
using namespace std;
 
int j, k, a[MAX], b[MAX];
set<int> dp1[MAX], dp2[MAX];

int main(){
  string s;
  int x, y, i;
  bool t = true;
  cin >> s >> x >> y;
  for(i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      t ^= true;
      if(t) j++;
      if(!t) k++;
    }else if(t) a[j]++;
    else b[k]++;
  }
  dp1[0].insert(0);
  dp2[0].insert(0);
  for(i = 0; i <= j; i++){
    for(set<int>::iterator it = dp1[i].begin(); it != dp1[i].end(); it++){
      dp1[i+1].insert(*it + a[i]);
      if(i) dp1[i+1].insert(*it - a[i]);
    }
  }
  for(i = 0; i <= k; i++){
    for(set<int>::iterator it = dp2[i].begin(); it != dp2[i].end(); it++){
      dp2[i+1].insert(*it + b[i]);
      dp2[i+1].insert(*it - b[i]);
    }
  }
  if(dp1[j+1].find(x) != dp1[j+1].end() && dp2[k+1].find(y) != dp2[k+1].end()){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
}


Measured memory_bytes: 232832
// 2017-07-13
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
	int n, m, s[15], d[100], sum[1 << 15], dp[1 << 15];
	while (cin >> n >> m, n) {
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> d[i];
		}
		sort(d, d + m);
		for (int i = 0; i < 1 << n; i++) {
			sum[i] = 0;
			for (int j = 0; j < n; j++) {
				if (i & 1 << j) {
					sum[i] += s[j];
				}
			}
		}
		fill(dp, dp + (1 << n), 0);
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < 1 << n; j++) {
				dp[j] += abs(sum[j] - d[i]);
			}
			for (int j = 0; j < 1 << n; j++) {
				for (int k = 0; k < n; k++) {
					dp[j] = min(dp[j], dp[j & ~(1 << k)]);
				}
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3336
x,y=map(int,input().split())

if y==0 and x<0:
    ans=abs(x)
elif y==0 and x>0:
    ans=abs(x)+1
elif x==0 and y<0:
    ans=abs(y)+1
elif x==0 and y>0:
    ans=abs(y)
elif x*y>0:
    if y-x>0:
        ans=y-x
    else:
        ans=x-y+2
else:
    ans=abs(abs(y)-abs(x))+1
print(ans)



Measured memory_bytes: 3060
#include<stdio.h>
#include<bitset>
#include<vector>
const int N = 10001;
int main()
{
	std::vector<int>v;
	std::bitset<N>p;
	int i,j,n,a[N]={0};
	p.set();
	for(i=2;i<N/2;++i)if(p[i])for(j=i*2;j<N;j+=i)p[j]=0;
	for(i=2;i<N;++i)if(p[i])v.push_back(i);
	for(i=0;i<v.size();++i)
	{
		n=v[i];
		++a[n];
		for(j=i+1;j<v.size() && (n+=v[j], n<N);++j)++a[n];
	}
	while(scanf("%d",&n),n)printf("%d\n",a[n]);
	return 0;
}

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

int main()
{
    int x, y; cin>>x>>y;
    long res=1L<<62;
    for(int i=0; i<4; ++i) {
        long cnt=0;
        int a=x, b=y;
        if (i/2) ++cnt, a=-x;
        if (i%2) ++cnt, b=-y;
        if (b>=a) {
            cnt+=b-a;
            res=min(res, cnt);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i = 1; i * i <= n - 1; i++) {
        if ((n - 1) % i == 0) {
            ll j = (n - 1) / i;
            cnt++;
            if (i != j) cnt++;
        }
    }
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ll t = n;
            while (t % i == 0) t /= i;
            if (t % i == 1) cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define _overload3(_1, _2, _3, name, ...) name
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll g=gcd(a,b);return a/g*b;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,max=0,sum=0;
    cin>>n;
    rep(i,n){
        int tmp;
        cin>>tmp;
        if(tmp>max)max=tmp;
        sum=sum+tmp;
    }
    if(max>=(sum-max))cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll X[1000], Y[1000];

signed main(){
    cin >> N;
    int cnt = 0;
    rep(i, N){
        cin >> X[i] >> Y[i];
        cnt += (abs(X[i])+abs(Y[i])) % 2;
    }
    if(0 < cnt && cnt < N){
        cout << -1 << endl;
        return 0;
    }
    
    if(cnt == 0){
        vector<ll> v;
        for(ll i=1LL<<32; i>0; i=(i>>1)){
            v.pb(i);
        }
        v.pb(1);
        cout << v.size() << endl;
        rep(i, v.size()){
            if(i != 0) cout << " ";
            cout << v[i];
        }
        cout << endl;

        rep(i, N){
            ll x = 0;
            ll y = 0;
            rep(j, v.size()){
                if(abs(X[i]-x) >= abs(Y[i]-y)){
                    if(X[i] > x){
                        x += v[j];
                        cout << "R";
                    }
                    else{
                        x -= v[j];
                        cout << "L";
                    }
                }
                else{
                    if(Y[i] > y){
                        y += v[j];
                        cout << "U";
                    }
                    else{
                        y -= v[j];
                        cout << "D";
                    }
                }
            }
            cout << endl;
        }
    }
    else{
        vector<ll> v;
        for(ll i=1LL<<32; i>0; i=(i>>1)){
            v.pb(i);
        }
        cout << v.size() << endl;
        rep(i, v.size()){
            if(i != 0) cout << " ";
            cout << v[i];
        }
        cout << endl;

        rep(i, N){
            ll x = 0;
            ll y = 0;
            rep(j, v.size()){
                if(abs(X[i]-x) >= abs(Y[i]-y)){
                    if(X[i] > x){
                        x += v[j];
                        cout << "R";
                    }
                    else{
                        x -= v[j];
                        cout << "L";
                    }
                }
                else{
                    if(Y[i] > y){
                        y += v[j];
                        cout << "U";
                    }
                    else{
                        y -= v[j];
                        cout << "D";
                    }
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
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++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

    int n,s;
    cin >> n >> s;
    vector<int> v(n),w(n);
    rep(i,n) cin >> v[i] >> w[i];
    vector<vector<int>> dp(n+1,vector<int>(s+1));
    rep(i,n) {
        rep(j,s+1) {
            if (j<w[i]) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]); 
        }
    }
    cout << dp[n][s] << endl;

    return 0;
}


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

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

 if (op == "+") {
      cout << a + b << endl;
 } else if (op == "-") {
      cout << a - b << endl;
  };
    
     
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

struct Task { int a, b; };

bool connect[100][100];

int main() {
  int n, k;
  cin >> n >> k;
  int max = (n-1)*(n-2)/2;
  if (k > max) {
    cout << -1 << endl;
    return 0;
  }
  int rem = max-k;
  int m2 = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (i == 0) {
        connect[i][j] = true;
        ++m2;
        continue;
      }
      if (rem > 0) {
        connect[i][j] = true;
        ++m2;
        --rem;
      }
      else { break; }
    }
  }
  cout << m2 << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (!connect[i][j]) continue;
      cout << i+1 << " " << j+1 << endl;
    }
  }
}


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

int main() {
	std::string s, t, u;
	long long A, B;
	std::cin >> s >> t >> A >> B >> u;
	if (s == u) {
		A--;
	}
	else {
		B--;
	}
	std::cout << std::max(0LL, A) << " " << std::max(0LL, B) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}


struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint nPk(int n, int k){
        return fact[n]*ifact[n-k];
    }
};

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

    combination nCk(1000009);
    mint ans = nCk.nPk(M,N) * nCk.nPk(M,N); // 全パターン
    for(int i=1;i<=N;++i){
        mint now = nCk.nPk(M,N); // Aの配列の順列
        now *= nCk(N,i); // Bの配列N要素のうち、最低でもi箇所Aと一致する場所を決める
        now *= nCk.nPk(M-i,N-i); // i箇所以外の場所を自由に並べる（結果的にi箇所以上かぶっても良い）
        if(i&1) now = -now; // 包除原理
        ans += now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18804
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double S,L,h;
        S = (double)(a * b * Math.sin(Math.toRadians(c))) / 2;
        double d = Math.sqrt((double)(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(c))));
        L = (double)(a + b + d);
        h = (double)(b * Math.sin(Math.toRadians(c)));
        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
    }
}


Measured memory_bytes: 26232
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        int[] h = new int[N];
        for(int i = 0; i < N; i++)
        {
            h[i] = 1;
        }

        bool[] d = new bool[N];
        d[0] = true;
        for(int i = 1; i < N; i++)
        {
            d[i] = false;
        }

        for(int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]) - 1;
            int y = int.Parse(input[1]) - 1;
            h[y]++;
            if (d[x] == true) d[y] = true;
            h[x]--;
            if (h[x] == 0) d[x] = false;
        }

        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            if (d[i] == true) ans++;
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 7252
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
    int n;
    long long ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),ans+=max(0,a[i-1]-a[i]),a[i]=max(a[i],a[i-1]);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4536
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
#define ll long long int

int main(){
    int n;
    cin >> n;
    int c=0;
    for(int i=1;i<=n;i++){
        if(i%2 != 0)
            c++;
    }
    double s =(double) c/n;
    printf("%.10lf", s);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[2001][2001] = {0};
int main()
{
    int n, k;
    const int x = 1000000007;
    for(int i = 0; i <= 2000; i++)
    {
        a[i][0] = 1;
        a[i][i] = 1;
    }
    for(int i = 2; i <= 2000; i++)
    {
        for(int j = 1; j < i; j++)
        {
            a[i][j] = (a[i - 1][j - 1] % x + a[i - 1][j] % x) % x;
        }
    }
    cin >> n >> k;
    for(int i = 1; i <= k; i++)
    {
        long long ans = 1;
        cout << (ans * a[k - 1][i - 1] * a[n - k + 1][i]) % x << endl;
    }
    return 0;
}


Measured memory_bytes: 17420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int N, T; cin >> N >> T;
    int cost=1010;
    for (int i=0;i<N;i++) {
        int c_i,t_i; cin >> c_i >> t_i;
        if (t_i<=T&&c_i<cost) cost = c_i;
    }
    if (cost<=1000) cout << cost << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    int a[N+1];
    for(int i=1;i<=N;i++)a[i]=1;
    for(int i=0;i<M;i++){
        int tmpa;
        cin >> tmpa;
        a[tmpa] = 0;
    }
    long long dp[N+1];
    dp[0] = 1;
    dp[1] = a[1];
    for(int i=2;i<=N;i++){
        if(a[i]){
            dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
        }
        else{
            dp[i] = 0;
        }
    }
    long long ans = dp[N];
    cout << ans;
}


Measured memory_bytes: 4364
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int answer = Math.max(a + b, a - b);
        answer = Math.max(answer, a * b);
        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 35772
def main():
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    s = [input().rstrip() for _ in range(H)]

    def wallen(g):
        L = len(g[0])
        ret = []
        ret.append('#' * (L + 2))
        for row in g:
            t = '#' + row + '#'
            ret.append(t)
        ret.append('#' * (L + 2))
        return ret

    g = wallen(s)
    # print(*g, sep='\n')

    left = [[-1] * (W + 2) for _ in range(H + 2)]  # 各方向に移動したときにぶつかる障害物の位置
    right = [[-1] * (W + 2) for _ in range(H + 2)]
    up = [[-1] * (W + 2) for _ in range(H + 2)]
    down = [[-1] * (W + 2) for _ in range(H + 2)]

    for r in range(H + 2):
        for c in range(W + 2):
            if g[r][c] == '#':
                left[r][c] = c
            else:
                left[r][c] = left[r][c - 1]

        for c in reversed(range(W + 2)):
            if g[r][c] == '#':
                right[r][c] = c
            else:
                right[r][c] = right[r][c + 1]

    for c in range(W + 2):
        for r in range(H + 2):
            if g[r][c] == '#':
                up[r][c] = r
            else:
                up[r][c] = up[r - 1][c]

        for r in reversed(range(H + 2)):
            if g[r][c] == '#':
                down[r][c] = r
            else:
                down[r][c] = down[r + 1][c]

    ans = 0
    for r in range(H + 2):
        for c in range(1, W + 1):
            t = right[r][c] - left[r][c] + down[r][c] - up[r][c] - 3
            ans = max(ans, t)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 193288
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, C = lr()
B = np.array(lr())
answer = 0
for i in range(N):
    A = np.array(lr())
    bl = (A * B).sum() + C > 0
    if bl:
        answer += 1

print(answer)

Measured memory_bytes: 19976
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  string S[3];
  rep(i,3){
    cin >> S[i];
    reverse(ALL(S[i]));
  }
  int x = 0;
  while(true){
    if (sz(S[x]) == 0) {
      cout << (char) ('A' + x) << endl;
      break;
    }

    int y = S[x].back() - 'a';
    S[x].pop_back();
    x = y;
  }
  return 0;
}



Measured memory_bytes: 256