akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long

int32_t main() {
	Fast_IO

	int a; cin >> a;
	long double b; cin >> b;
	int res = a * b;
	// cout << (a * b * 100) / 100;
	cout << res;
}

Measured memory_bytes: 3728
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() {
    string s;
    cin>>s;
    sort(all(s));
    //cout<<s<<endl;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

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

/// template end ///

void solve()
{
	while (true)
	{
		READ(int, n, m);
		if (!n && !m) { break; }

		auto taro = read<int>(n);
		auto hana = read<int>(m);

		int ret = INF, tr = 0, hr = 0;
		auto tx = accumulate(ALLOF(taro), 0);
		auto hx = accumulate(ALLOF(hana), 0);
		for (auto t:taro) for (auto h:hana)
		{
			if (tx - t + h == hx - h + t && ret > t + h)
			{
				ret = t + h;
				tr = t;
				hr = h;
			}
		}

		vector<int> r; r.push_back(tr); r.push_back(hr);
		if (ret == INF) { write(-1); }
		else { write(r); }
	}
}

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

//~ const int MOD=1000000007;
const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int a[5000];
ll dp[5000][5000];

int main(){
	int n,s;cin>>n>>s;
	rep(i,n)scanf("%d",&a[i]);
	dp[0][0]=ppow(2,n);
	ll t=(MOD+1)/2;
	rep(i,n)rep(j,s+1){
		if(dp[i][j]==0)continue;
		(dp[i+1][j]+=dp[i][j])%=MOD;
		if(j+a[i]<5000)(dp[i+1][j+a[i]]+=dp[i][j]*t)%=MOD;
	}
	cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 97780
#include <cstdio>
bool b[26];
int main(){
    register char ch;
    while((ch=std::getchar())!='\n') b[ch-'a']=true;
    for(int i=0;i<26;++i) if(!b[i]){std::putchar(i+'a');std::putchar(10);return 0;}
    std::puts("None");
}

Measured memory_bytes: 128
n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= m:
    print("0")
else:
    x.sort()

    l = [x[i+1] - x[i] for i in range(m - 1)]

    l.sort(reverse=True)

    ans = x[m-1] - x[0]
    for i in range(n-1):
        ans -= l[i]

    print(ans)

Measured memory_bytes: 13968
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

int H,W;
const int INF=160*80*2+20;
const int ORG=160*80+10;

int main(){
  cin >> H >> W;

  vector<vector<int> > A(H,vector<int>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A[i][j];
    }
  }
  int B;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> B;
      A[i][j]=abs(A[i][j]-B);
    }
  }
  
  vector<vector<bitset<INF> > > dp(H,vector<bitset<INF> >(W,0));
  dp[0][0].set(ORG+A[0][0]);
  dp[0][0].set(ORG-A[0][0]);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i!=0){
	dp[i][j]|=(dp[i-1][j]<<A[i][j]);
	dp[i][j]|=(dp[i-1][j]>>A[i][j]);
      }
      if(j!=0){
	dp[i][j]|=(dp[i][j-1]<<A[i][j]);
	dp[i][j]|=(dp[i][j-1]>>A[i][j]);
      }
    }
  }

  for(int i=0;i<ORG;i++){
    if(dp[H-1][W-1].test(ORG+i) || dp[H-1][W-1].test(ORG-i)){
      cout << i << endl;
      break;
    }
  }  
  return 0;
}


Measured memory_bytes: 20736
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int count = 0;
  int check = 1;
  for (int i=0;i<N;i++){
    if (A[i] == check){
      count++;
      check++;
    }
  }
  
  if (count == 0){
    cout << -1 << endl;
  }
  else{
    cout << N - count <<endl;
  }
   
}


Measured memory_bytes: 1024
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        p = self.sieve(300001)
        while True:
            n = input()
            if n == 1:
                break
            ans = '{0}: '.format(n)
            seq = []

            for i in range(len(p)):
                if n % p[i] == 0:
                    seq.append(str(p[i]))

            ans += ' '.join(seq)
            print ans
                    
        return None
    
    def mark(self, s, x):
        for i in xrange(x + x, len(s), x):
            s[i] = False

    def sieve(self, n):
        s = [True] * n
        for x in xrange(n):
            if x % 7 != 1 and x % 7 != 6:
                s[x] = False
        for x in xrange(2, int(n ** 0.5) + 1):
            if s[x]:
                self.mark(s, x)
        return [i for i in xrange(n) if s[i] and i > 1]

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 8036
function Main(input) {
    let a = 0;
    let b = 0;
    let c = 0;
    for (let str of input) {
        if (str == 'a') a++;
        if (str == 'b') b++;
        if (str == 'c') c++;
    }
    if (a && b && c)
        console.log('Yes');
    else
        console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> A(n);
    vector<vector<ll>> X(n,vector<ll>(15));
    vector<vector<ll>> Y(n,vector<ll>(15));
    REP(i,n){
    cin >> A[i];
        REP(j,A[i]){
            cin >> X[i][j] >> Y[i][j];
        }
    }
    
    ll mat[2][15];
    ll ans = 0 ;
    ll b = 1;
    REP(i,n){
        b *= 2;
    }
    REP(i,2){
        REP(j,15){
            mat[i][j] = 0;
        }
    }
    REP(i,b){
        ll mat[2][15];
        REP(i,2){
            REP(j,15){
                mat[i][j] = 0;
            }
        }
        ll B[15];
        ll j = i;
        REP(p,15){
            B[p] = j%2;
            j /= 2;
        }
        REP(q,n){
            if(B[q] == 1){
                mat[0][q] += 1;
                REP(k,A[q]){
                    if(Y[q][k] == 1){
                        mat[0][X[q][k]-1] += 1;
                    }
                    else{
                        mat[1][X[q][k]-1] += 1;
                    }
                }
            }
            if(B[q] == 0){
                mat[1][q] += 1;
            }
        }
        /*
        REP(i,15){
            cout << B[i];
        }
        cout << endl;
        REP(i,2){
            REP(j,15){
                cout << mat[i][j];
            }
            cout << endl;
        }
        */
        ll memo = 0;
        REP(r,15){
            memo += B[r];
        }
        ll memo2 = 0;
        REP(r,15){
            memo2 += mat[0][r] * mat[1][r];
        }
        
        if(memo2 == 0){
            if(ans < memo){
                ans = memo;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val mod = 1000000007
  val br = BufferedReader(InputStreamReader(System.`in`))

  val(n, m) = br.readLine().split(" ").map { it.toInt() }
  val isBroken = mutableSetOf<Int>()
  for(i in 1..m) { isBroken.add(br.readLine().toInt()) }

  val dp = IntArray(n+2)
  dp[0] = 1
  for(i in 0..n-1) {
    if(isBroken.contains(i))
      continue

    dp[i+1] = (dp[i+1] + dp[i]) % mod
    dp[i+2] = (dp[i+2] + dp[i]) % mod
  }

  val ans = dp[n]
  println(ans)
}

Measured memory_bytes: 47696
def knapsack(nums, k):
    n = len(nums)

    # dp[i] is min cost when reaching stone i
    dp = [float('Inf')] * n
    dp[0] = 0
    for i in range(1, n):
        dp[i] = min([
            dp[i-j] + abs(nums[i] - nums[i-j])
            for j in range(1, k+1) if i - j >= 0]
        )
    return dp[-1]


if __name__ == "__main__":
    _, k = [int(x) for x in input().split()]
    nums = [int(x) for x in input().split()]
    print(knapsack(nums, k))


Measured memory_bytes: 55264
#include<stdio.h>
int main(){
  int a = 0;
  int b = 0;
  scanf("%d %d",&a,&b);
  if(a == (a % 10) && b == (b % 10)){
    printf("%d",a*b);
  }else{
    printf("-1");
  }
  return 0;
}

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

int main() {
	long long a, b, c, d, n, x, m;
	cin >> a >> b;
	c = 0;
	for(int i = b - a - 1; i > 0; i--){
		c += i;	
	}
	cout << c - a << endl;
	// your code goes here
	return 0;
}

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

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, a, b, c);
	int ans = 0;
	int t = min(b, c);
	ans += t * 2;
	b -= t; c -= t;
	// debug(ans);
	int s;
	if (c > 0) {
		s = min(a, c);
		ans += s;
		a -= s; c -= s;
	}

	if (b > 0) ans += b;
	if (c > 0) ans++;
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

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

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

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  if(!(A%2) || !(B%2) || !(C%2)){
    cout << 0 << "\n";
  }else{
    cout << min(A*B, min(B*C, C*A)) << "\n";
  }
  return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    string ans;

    if (C < D)
    {
        string AD = S.substr(A - 1, D - A + 1);
        if (AD.find("##") == -1)
        {
            ans = "Yes";
        }else
        {
            ans = "No";
        }
        
    }else
    {
        string AC = S.substr(A - 1, C - A + 1);
        if (AC.find("##") == -1)
        {
            string BD = S.substr(B - 2, D - B + 3);
            if (BD.find("...") == -1)
            {
                ans = "No";
            }else
            {
                ans = "Yes";
            }
            
        }else
        {
            ans = "No";
        }
        
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
string keyence = "keyence";
int main()
{
    string s;
    cin >> s;
    int l = s.size();
    if (s == keyence)
    {
        cout << "YES" << endl;
        return 0;
    }
    for (size_t i = 0; i < l; i++)
    {
        for (size_t j = i; j < l; j++)
        {
            string a = "";
            for (size_t k = 0; k < l; k++)
            {
                if (i <= k && k <= j)
                {
                    continue;
                }
                else
                {
                    a.push_back(s[k]);
                }
            }
            if (a == keyence)
            {
                cout << "YES" << endl;
                return 0;
            }

            /* code */
        }
    }
    cout << "NO" << endl;

    return 0;
}

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

using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }
    vector<int> cnt(N, -1);
    vector<int> id(N, -1);
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(cnt[i] == -1) {
            int sum = 0;
            int now = i;
            while(cnt[now] == -1) {
                cnt[now] = sum++;
                id[now] = i;
                (now += a[now]) %= N;
            }
            if(id[now] == i) {
                res += sum - cnt[now];
            }
        }
    }
    cout << res << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> a(n+1),limit(n);
  rep(i, n+1)cin>>a[i];

  if(n==0){
    if(a[0]==1)cout<<1<<endl;
    else cout<<-1<<endl;
    return 0;
  }

  limit[n-1]=a[n]+a[n-1];
  rrep(i, n-1){
    limit[i] = limit[i+1]+a[i];
  }
  limit.push_back(a.back());

  ll result = 1;
  ll l=1;

  if(a[0]==1 && n>0) { cout<<-1<<endl; return 0; }

  rep(i, n){
    ll c=a[i];

    ll nl = min<ll>((l-c)*2, limit[i+1]);
//    if(l-c<0) { cout<<-1<<endl; return 0;}
    if(l-c<0 || nl-a[i+1]<0) { cout<<-1<<endl; return 0;}
//    if(l==0 && a[i]>0) { cout<<-1<<endl; return 0;}

    if(i<n-1)result += nl;
    swap(l, nl);
  }

  cout<<result+a.back()<<endl;

  return 0;
}


Measured memory_bytes: 5604
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
 
#define N  100005
 
ll int arr[5005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		vi v(n);
		memset(arr,0,sizeof(arr));
		for(ll int i=0;i<n;i++)
		{
			cin>>v[i];
			arr[v[i]]++;
		}
		ll int prefix[5005];
		prefix[0]=0;
		for(ll int i=1;i<5005;i++)
		{
			prefix[i]=prefix[i-1]+arr[i];
		}
		ll int ans=0;
		for(ll int i=0;i<n;i++)
		{
			for(ll int j=i+1;j<n;j++)
			{
				ll int l1=v[i];
				ll int l2=v[j];
				ll int mini=max(l1-l2+1,l2-l1+1);
				ll int maxi=l1+l2-1;
				ll int cnt=prefix[maxi]-prefix[mini-1];
				if(mini<=l1&&l1<=maxi) cnt--;
				if(mini<=l2&&l2<=maxi) cnt--;
				ans+=cnt;
			}
		}
		cout<<ans/3;
	}
	return 0;
}

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

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

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;

    if (A % 2 == 0) {
      if (!(A % 3 == 0 || A % 5 == 0)) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  string S,T;
  cin >> S >> T;

  int a, b;
  cin >> a >> b;

  string U; cin >> U;

  if (S == U) {
    cout << (a-1) << " " << b << "\n";
  } else {
    cout << a << " " << (b-1) << "\n";
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; ++i) cin >> a[i];
  sort(a, a+n, greater< int >());
  int alice=0, bob=0;
  for (int i=0; i<n; ++i) {
    (i%2==0 ? alice : bob) += a[i];
  }
  cout << alice-bob << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from copy import deepcopy
def input(): return sys.stdin.readline().strip()

def main():
    s = input()
    l = len(s)
    if s[0] == s[-1] and l % 2 == 0:
        print("First")
    elif s[0] == s[-1] and l % 2 != 0:
        print("Second")
    elif l % 2 == 0:
        print("Second")
    else:
        print("First")


if __name__ == "__main__":
    main()


Measured memory_bytes: 69140
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <random>
#include <set>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2")
#endif

using namespace std;

using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;
using vi = vector<int>;
using vi64 = vector<i64>;

#define seq(i, a, b) for (int i = (a); i < (b); ++i)
#define rev(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) \
  { cerr << #x << ": " << x << endl; }

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<char> occ(n * n, true);
  vector<int> cost(n * n, false);

  auto outside = [&](int x, int y) {
    return !(0 <= x && x < n && 0 <= y && y < n);
  };

  auto at = [&](int x, int y) -> auto& {
    static char unocc = false;
    if (outside(x, y)) return unocc;
    return occ[x + y * n];
  };

  auto cost_at = [&](int x, int y) -> auto& { return cost[x + y * n]; };

  seq(i, 0, n * n) {
    int x = i % n;
    int y = i / n;
    cost_at(x, y) = min({x, y, n - x - 1, n - y - 1});
  }

  vi A(n * n);
  for (auto& x : A) cin >> x;
  int res = 0;
  for (auto i : A) {
    --i;

    //seq(y,0,n) {
    //  seq(x,0,n) {
    //    cout << cost_at(x,y) << " ";
    //  }
    //  cout << "\n";
    //}
    //cout << "\n";
    int c = cost_at(i%n,i/n);
    res += c;

    // Update
    deque<tuple<int, int, int>> Q;
    Q.push_front({i % n, i / n, c});
    at(i % n, i / n) = false;
    while (!Q.empty()) {
      auto [x, y, cost] = Q.back();
      //cout << x << ", " << y << ", " << cost << endl;
      Q.pop_back();

      int nc = cost + at(x, y);
      auto f = [&nc, &Q, &cost_at, &outside](int nx, int ny) {
        if (!outside(nx, ny) && cost_at(nx, ny) > nc) {
          cost_at(nx, ny) = nc;
          Q.push_front({nx, ny, nc});
        }
      };

      f(x + 1, y);
      f(x - 1, y);
      f(x, y + 1);
      f(x, y - 1);
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 5296
from collections import Counter
from scipy.special import comb

n = int(input())
a = list(map(int,input().split()))

sa = [0]
for i in range(n):
  sa.append(sa[i]+a[i])
ans = 0
c = Counter(sa)
for vi in c.values():
  if vi >= 2:
    ans += comb(vi,2,exact=True)
print(ans)

Measured memory_bytes: 76932
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string n;
	cin >> n;
	if (count(n.begin(), n.end(), '9') >= 1)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io::{self, Write};
use parse::ParseNext;
use std::collections::HashMap;

fn main() {
    let str_count: Vec<u64> = {
        let stdin = io::stdin();
        let mut r = read::Reader::new(io::BufReader::new(stdin));
        let n = r.read_line().unwrap().parse().unwrap();
        let mut str_count = HashMap::with_capacity(n);
        for _ in 0..n {
            let mut s = r.read_line().unwrap().as_bytes().to_vec();
            s.sort();

            let mut count = str_count.entry(s).or_insert(0u64);
            *count += 1;
        }
        str_count.values().map(|x| *x).collect()
    };

    let mut sum = 0;
    for count in str_count {
        sum += count * (count - 1) / 2;
    }

    println!("{}", sum);
}

/// 文字列のパースの補助モジュール.
pub mod parse {
    use std::error;
    use std::fmt;
    use std::str::FromStr;

    #[derive(Eq, PartialEq, Copy, Clone, Hash, Debug)]
    pub enum Error<E> {
        GetNextError,
        ParseErr(E),
    }

    impl<E: fmt::Display> fmt::Display for Error<E> {
        #[inline]
        fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
            match self {
                &Error::GetNextError => f.write_str("Iterator has no next element"),
                &Error::ParseErr(ref e) => write!(f, "{}", e)
            }
        }
    }

    impl<E: error::Error> error::Error for Error<E> {
        #[inline]
        fn description(&self) -> &str {
            match self {
                &Error::GetNextError => "Iterator error",
                &Error::ParseErr(ref e) => e.description()
            }
        }
    }

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> Result<F, Error<F::Err>>;
    }

    impl<'a, S: AsRef<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> Result<F, Error<F::Err>> {
            if let Some(s) = self.next() {
                match s.as_ref().parse() {
                    Ok(x) => Ok(x),
                    Err(e) => Err(Error::ParseErr(e))
                }
            } else {
                Err(Error::GetNextError)
            }
        }
    }
}

/// 標準入力読み取りモジュール.
pub mod read {
    use std::io::{BufRead, Result};

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[inline]
        pub fn read_line(&mut self) -> Result<&str> {
            self.buf.clear();
            self.inner.read_line(&mut self.buf)?;
            Ok(self.buf.trim_right())
        }
    }
}


Measured memory_bytes: 12540
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h = ni()
w = ni()
n = ni()

print(min((n-1)//h+1, (n-1)//w+1))

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  long long int n, i, a, max=0, min=1000000000;
  scanf("%lld", &n);
  for(i=1; i<=n; i++)
  {
    scanf("%lld", &a);
    if(a>max) max=a;
    if(a<min) min=a;
  }
  printf("%lld", max-min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	ll k; cin >> k;
	int n = int(s.length());
	for(int i = 0; i < n - 1; i++)
	{
		int dist = 'z' - s[i] + 1;
		if(dist == 26) dist = 0;
		if(k >= dist)
		{
			s[i] = 'a';
			k -= dist;
		}
	}
	k%=26;
	for(int i = 0; i < k; i++)
	{
		if(s[n-1] <= 'y') s[n-1]++;
		else s[n-1] = 'a';
	}
	cout << s << '\n';
}


Measured memory_bytes: 592
#include <stdio.h>

int main () {
  int a,b,c;
  scanf ("%d %d %d",&a,&b,&c);
  int x;
  int n;
  for (n=0;n<10000;n++) {
  if (a > b) {
    x = b;
    b = a;
    a = x;
  }
  if (b > c) {
    x = b;
    b = c;
    c = x;
  }
  if (a > c) {
    x = a;
    a = c;
    c = x;
  }
  }
  printf ("%d %d %d\n",a,b,c);
  return 0;
}

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

int main(){
	int a[3000], b[3000], answer[3000], s, t;
	s = 0; t = 0;
	for (;;){
		char op;
		cin >> a[s] >> op >> b[s];
		switch (op){
		case '+':answer[s] = a[s] + b[s]; break;
		case '-':answer[s] = a[s] - b[s]; break;
		case '*':answer[s] = a[s] * b[s]; break;
		case '/':answer[s] = a[s] / b[s]; break;
		default: t++; break;
		}
		if (t == 1)break;
		s++;
	}
	for (int i = 0; i < s; i++){
		printf("%d\n", answer[i]);
	}
	return 0;
}



Measured memory_bytes: 3132
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] t = new int[N];
    int[] d = new int[N];
    for (int i = 0; i < N; i++) {
      t[i] = sc.nextInt();
      d[i] = sc.nextInt();
    }
    Main abc116D = new Main();
    System.out.println(abc116D.solve(N, K, t, d));
  }

  long solve(int N, int K, int[] t, int[] d) {
    List<Sushi> sushis = new ArrayList();
    for(int i = 0; i < N; i++){
      sushis.add(new Sushi(t[i], d[i]));
    }
    ABC116DSolveWork abc116DSolve = new ABC116DSolveWork(sushis, K);
    return abc116DSolve.solve();
  }

  class ABC116DSolveWork {
    List<Sushi> sushis;
    int K;

    public ABC116DSolveWork( List<Sushi> sushis, int K) {
      this.sushis = sushis;
      this.K = K;
      Collections.sort(this.sushis);
    }

    public long solve() {
      return searchAns();
    }

    private long searchAns() {
      long point = 0;
      long size = 0;
      Set<Integer> types = new HashSet<>();
      Stack<Sushi> chohukus = new Stack();
      Queue<Sushi> kouho = new LinkedList();

      for (int i = 0; i < K; i++) {
        Sushi sushi = this.sushis.get(i);
        point += sushi.d;
        if (types.contains(sushi.t)) {
          chohukus.push(sushi);
        } else {
          types.add(sushi.t);
          size += 1;
        }
      }
      long ans = point + size * size;

      for (int i = K; i < this.sushis.size(); i++) {
        Sushi sushi = this.sushis.get(i);
        if (!types.contains(sushi.t)) {
          types.add(sushi.t);
          kouho.add(sushi);
        }
      }

      while (!chohukus.isEmpty() && !kouho.isEmpty()) {
        Sushi delSushi = chohukus.pop();
        Sushi addSushi = kouho.poll();
        point = point - delSushi.d + addSushi.d;
        size += 1;
        long nextAns = point + size * size;

        if (nextAns > ans) {
          ans = nextAns;
        }
      }
      return ans;
    }
  }
  class Sushi implements Comparable<Sushi>{
    public int t;
    public int d;
    public Sushi(int t, int d){
      this.t = t;
      this.d = d;
    }

    @Override
    public int compareTo(Sushi other) {
      return other.d - this.d;
    }
  }
}

Measured memory_bytes: 71588
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  string s; cin >> s;
  list<string> l;
  l.push_back(s);
  int q; cin >> q;
  int front = 1;
  rep(i,q){
    int t; cin >> t;
    if(t == 1) front *= -1;
    else{
      int f; cin >> f;
      string c; cin >> c;
      if(front == 1){
        if(f == 1) l.push_front(c);
        else l.push_back(c);
      }else{
        if(f == 2) l.push_front(c);
        else l.push_back(c);
      }
    }
  }
  if(front == 1) for(auto x : l) cout << x;
  else{
    reverse(all(l));
    for(string x : l){
      reverse(all(x));
      cout << x;
    }
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 16368
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const n = Number(lines[0]);
  const c = () => ({
    "1": Array(10).fill(0),
    "2": Array(10).fill(0),
    "3": Array(10).fill(0),
  });
  const room = {
    "1": c(),
    "2": c(),
    "3": c(),
    "4": c(),
  };
  for (let i = 1; i <= n; i++) {
    const [b, f, r, v] = lines[i].split(" ").map(Number);
    room[b][f][r - 1] = room[b][f][r - 1] + v;
  }
  const outs = [];
  for (let i = 1; i <= 4; i++) {
    let o = "";
    for (let j = 1; j <= 3; j++) {
      o += ` ${room[i][j].join(" ")}\n`;
    }
    outs.push(o);
  }
  process.stdout.write(outs.join("####################\n"));
});



Measured memory_bytes: 16892
n=int(input())
M=0
A=0
R=0
C=0
H=0

for _ in range(n):
  s=input()
  if s[0]=='M':
    M+=1
  elif s[0]=='A':
    A+=1
  elif s[0]=='R':
    R+=1
  elif s[0]=='C':
    C+=1
  elif s[0]=='H':
    H+=1
    
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*C*H+A*R*H+R*C*H)
    

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
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; }
int main()
{
  int l;cin >> l;
  vector<ll> a(l);
  rep(i,l) cin >> a[i];
  
  vector<vector<ll>> dp(l+1, vector<ll>(5, 1e+15));
  dp[0][0] = 0;
  rep1(i,l) {
    rep(j,5) {
      rep(k,j+1) {
	if(j == 0 || j == 4) {
	  chmin(dp[i][j], dp[i-1][k] + a[i-1]);
	}
	else if(j == 1 || j == 3) {
	  if(a[i-1] == 0) chmin(dp[i][j], dp[i-1][k] + 2);
	  else if(a[i-1] % 2) chmin(dp[i][j], dp[i-1][k] + 1);
	  else chmin(dp[i][j], dp[i-1][k]);
	}
	else if(j == 2) {
	  if(a[i-1] % 2) chmin(dp[i][j], dp[i-1][k]);
	  else chmin(dp[i][j], dp[i-1][k] + 1);
	}
      }
    }
  }

  ll res = 1e+15;
  rep(i,5) chmin(res, dp[l][i]);
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 15872
n, m = gets.chomp.split(" ").map(&:to_i)
answers = []
n.times do
  answers.push(gets.chomp.split(" ").map(&:to_i))
end

answers.each do |answer|
  answer.shift
end

# puts answers

answers[1..answers.length - 1].each_with_index do |answer, index|
  answers[0].delete_if do |str|
    !answer.include?(str)
  end
end

puts answers[0].length

Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>
 
#define Length 1000

int LSCLength(char *X,char *Y){
 
  int i;
  int j;
  int m;
  int n;
  int c[Length+1][Length+1];
 
  m = strlen(X+1);
  n = strlen(Y+1);
   
  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
 
  for(j=0;j<=n;j++){
    c[0][j] = 0;
  }
 
  for(i=1;i<=m;i++){
   for(j=1;j<=n;j++){
      if(X[i] == Y[j]){
     c[i][j] = c[i-1][j-1] + 1;
  }
       
  else if(c[i-1][j] >= c[i][j-1] ){
     c[i][j] = c[i-1][j];
  }
 
  else{
    c[i][j] = c[i][j-1];
  }
       
   }
  }
   return c[m][n];
}

int main(){
 
   int i;
   int n;
   int match;
  char X[Length];
  char Y[Length];
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
  scanf("%s %s",X+1,Y+1);
  match = LSCLength(X ,Y);
  printf("%d\n",match);
  }
 
  return 0;
}
 

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

using ll = long long;
using vi = vector<int>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

    string s, t;
    cin >> s >> t;
    bool good = true;
    rep (i, 0, sz(s)) {
        if (s[i] != t[i]) good = false;
    }
    if (good) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

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

void solve()            
{
    int h1 , m1 , h2 , m2 ;
    cin >> h1 >> m1 >> h2 >> m2;
    int ts = h1*60 + m1 , te = h2*60 + m2;
    int k;
    cin >> k;
    te -= k;
    cout << max(0ll,te - ts) << endl;   
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    map<ll,ll>mp1;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        mp1[i-a[i]]++;
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
        ans+=mp1[a[i]+i];
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 27872
#include<bits/stdc++.h>
#define ll long long

const ll mod = 1000000007 ;

using namespace std ;

int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	string s;
	cin>>s;
	vector<int> v;
	int count = 0 ;
	for(int i=0 ; i<s.length() ; i++)
	{
		if(s[i]=='R' && s[i+1]!='S')
			count++ ;
		else if(s[i]=='R' && s[i+1]=='S')
		{
			v.push_back(count+1);
			count = 0 ;
		}
	}
	v.push_back(count);
	int maxi = *max_element(v.begin(),v.end());
	cout<<maxi;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n, a[N], k;
int dp[N];
void solve(){
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
        cin >> a[i]; 
    for(int i = 2; i <= n; ++i)
        dp[i] = INF;
    for(int i = 1; i <= n; ++i) 
        for(int j = i; j <= min(n, i + k); ++j)
            dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
    cout << dp[n];

}   
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 1024
number=input()
number=int(number)
card=input().rstrip().split()
card=list(map(int,card))
alice=0
bob=0
for i in range(number):
    a=max(card)
    if i%2==0:
        alice+=a
    else:
        bob+=a
    del card[card.index(max(card))]
print(alice-bob)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 998244353;
void add(ll &a, ll b)
{
    a = (a + b) % MOD;
}
int main()
{
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= s; j++)
        {
            add(dp[i+1][j], 2 * dp[i][j]);
            if(j+a[i] <= s) add(dp[i+1][j+a[i]], dp[i][j]);
        }
    }
    add(dp[n][s], MOD);
    cout << dp[n][s] << endl;
}




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

int main() {
  int N;
  cin >> N;
  string a;
  
   for (int i = 1; i <= N; i++) {
     cin >> a;
     if (a == "Y") {
       cout << "Four" << endl;
       break;
     }
     if (i == N)
       cout << "Three" << endl;
   }
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def print_ans(N, K):
    """Test Case
    >>> print_ans(3, 10)
    0.145833333333
    >>> print_ans(100000, 5)
    0.999973749998
    """
    prob = Decimal(1 / N)
    b = Decimal(math.log2(K))
    ans = 0
    for i in range(1, N + 1):
        if i >= K:
            ans += 1
        else:
            k = Decimal(math.ceil(b - Decimal((math.log2(i)))))
            ans += Decimal(2 ** (-k) ) 
    print(Decimal(ans * prob).quantize(Decimal('0.000000000001'), rounding=ROUND_HALF_EVEN))



if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    print_ans(N, K)


Measured memory_bytes: 5332
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 100;
typedef long long ll;


void solve(int k, int a, int b){
    bool ans;
    ans = false;
    for (int i=a; i<=b; i++){
        if (i%k==0) ans = true;
    }
    /**
    if (k <= b-a) ans=true;
    else ans = false;
    if (k==1 || a%k==0 || b%k==0) ans=true;
    **/
    if(ans) cout << "OK"<< endl;
    else cout << "NG" << endl;
}


int main(){
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    solve(k, a, b);
    return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
if n >= m:
    print(0)
    exit(0)
dist = []
for i in range(m-1):
    dist.append(abs(x[i]-x[i+1]))
dist.sort(reverse = True)
ans = 0
for i in range(n-1):
    ans += dist[i]
print(x[-1]-x[0]-ans)


Measured memory_bytes: 13960
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int n;
  cin >> n;
  vector<long> t(n);
  long sum = 0;
  rep(i,0,n){
    cin >> t[i];
    sum+=t[i];
  }

  int m;
  cin >> m;
  rep(i,0,m){
    int p;
    long x;
    cin >> p >> x;
    p--;
    P(sum - t[p] + x);
  }

  ret 0;
}

Measured memory_bytes: 256