akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
typedef pair<int, int> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

bool check(string s, int i, string t) {
    for (int j = 0; j < t.size(); j++) {
        if (s[i + j] != t[j]) return false;
    }
    return true;
}

int main() {
    string s, t;
    cin >> s >> t;
    if (t.size() > s.size()) return 0;

    for (int i = 0; i <= s.size() - t.size(); i++) {
        if (check(s, i, t)) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 3220
#include <stdio.h>
int main(){
    int n,t0;
    scanf("%d %d",&n,&t0);
    int c[n];
    int t[n];
    int cmin = 10000;
    int y;
    y = 0;
    for(int i = 0;i<n;i++){
        scanf("%d %d",c+i,t+i);
        if(t[i]<=t0){
            if(c[i]<cmin){
               cmin = c[i];
            }
            y = 1;
        }
    }
    if(y == 0){
        printf("TLE\n");
    }
    else{
    printf("%d\n",cmin);
    }
    return 0;
}

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

using ll=long long;
string s;
bool ans = 1;

int main(){
  cin >> s;
  string sl = s.substr(0, 7);
  string sr = s.substr(s.size()-7,7);
  string sample = "keyence";
  for(int i = 0; i < 7; i++){
    if(sl[i] != sample[i] && sr[i] != sample[i]) ans = 0;
  }
  cout << ((ans) ?"YES" :"NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int p=1;
	while (a[p]-(n-p)<=0)
	p++;
	if (a[p]%2==(n-p)%2 || (a[p-1]==n-p+1 && count(a+1,a+p,a[p-1])%2))
	printf("First");
	else
	printf("Second");
}

Measured memory_bytes: 4200
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;
ll n  , a[maxN];
void solve(){
	cin>> n ;
	if(n)cout<<0;
	else cout<<1;
}

int main(){
// 	mahakal();
	fast;
	ll t =1 ;
// 	cin>> t ; 
	while(t--)solve();
// 	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 3640
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
#s, t = [int(v) for v in int(input())]


def main():
    n, r = map(int, input().split())

    if n >= 10:
        print(r)
    else:
        print(r + 100 * (10 - n))


main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define f(i, q) for(int i = 0; i < q; i++)
using namespace std;

typedef long long ll;

int main() {
    vector<int>  spot(5);
    int k;

    f(i, 5) cin >> spot.at(i);
    cin >> k;

    int flg = 1;
    f(i, 3) {
        for(int j = i + 1; j < 5; j++) {
            // cout << i << endl;
            if(abs(spot.at(i) - spot.at(j)) > k)
                flg = 0;
        }
    }

    if(flg == 0) puts(":(");
    else puts("Yay!");

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

int main() {
  int n, m, a[12][12], x, b[12], c[12], ans = 1000000000, cnt;
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < m; j++) {
      b[j] = 0;
    }
    cnt = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        cnt += c[j];
        for (int k = 0; k < m; k++) {
          b[k] += a[j][k];
        }
      }
    }
    int flag = 1;
    for (int j = 0; j < m; j++) {
      if (b[j] < x) {
        flag = 0;
      }
    }
    if (flag) {
      ans = min(ans, cnt);
    }
  }
  if (ans == 1000000000) {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

int mod_pow(int x, int n) {
    int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int cnt[100010] = {};

signed main(){
    
    int n; cin >> n;
    for(int i = n - 1; i > 0; i -= 2){
        cnt[i] += 2;
    }

    if(n % 2 == 1) cnt[0]++;

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

    bool flag = true;
    for(int i = 0; i < n; i++) if(cnt[i] != 0) flag = false;
    if(flag){
        cout << mod_pow(2, n / 2) << endl;

    }else{
        cout << 0 << endl;
    }

    
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;

int expr(void);
int term(void);
int num(void);

char str[262144];
int i;

int expr(void) {
  int res = term();
  while( str[i] == '+' ) {
    i += 1;
    int temp = term();
    res += temp;
  }
  return res;
}

int term(void) {
  int res = num();
  while( str[i] == '*' ) {
    i += 1;
    int temp = num();
    res *= temp;
  }
  return res;
}

int num(void) {
  int res = 0;
  while( '0' <= str[i] and str[i] <= '9' ) {
    res = res * 10 + (str[i] - '0');
    i += 1;
  }
  return res;
}

int expr2(void) {
  int res = num();
  while( str[i] == '+' or str[i] == '*' ) {
    char ope = str[i];
    i += 1;
    int temp = num();
    if( ope == '+' ) {
      res += temp;
    }
    else {
      res *= temp;
    }
  }
  return res;
}                                           

int main() {

  int bob;
  bool ans[2] = {false, false};
  
  scanf("%s", str);
  scanf("%d", &bob);

  i = 0;
  if( bob == expr() ) {
    ans[0] = true;
  }

  i = 0;
  if( bob == expr2() ) {
    ans[1] = true;
  }

  if( ans[0] and not ans[1] ) {
    std::cout << "M" << std::endl;
  }
  else if( not ans[0] and ans[1] ) {
    std::cout << "L" << std::endl;
  }
  else if( ans[0] and ans[1] ) {
    std::cout << "U" << std::endl;
  }
  else {
    std::cout << "I" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  val daysOfMonth = List(31,29,31,30,31,30,31,31,30,31,30,31)
  val days = Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")

  def getDays(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0) print(sb.result)
    else {
      sb.append(days((daysOfMonth.take(r(0)-1).sum + r(1) + 3) % 7) + "\n")
      getDays(sb)
    }
  }

  def main(args:Array[String]) = getDays(new StringBuilder)
}

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

using namespace std;

int main()
{
        int a, b, c;
        cin >> a >> b >> c;
        int cnt = 0;
        for(int i = a; i <= b; i++)
                if(!(c%i)) cnt++;
        cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 3096
from sys import stdin
high = [0] * 10000
par = [i for i in range(10000)]
def findSet(x):
    if par[x] == x: return x
    par[x] = findSet(par[x])
    return par[x]
def unite(x, y):
    x = findSet(x)
    y = findSet(y)
    if x == y: return
    if high[x] > high[y]: par[y] = x;
    else:
        par[x] = y
        if high[x] == high[y]: high[y] += 1
def same(x, y):
    return findSet(x) == findSet(y)
n, q = map(int, stdin.readline().split())
ans = []
ans_append = ans.append
for i in range(q):
    t, a, b = map(int, stdin.readline().split())
    if t == 0: unite(a, b);
    elif t == 1: ans_append(1 if same(a, b) else 0)
print(*ans, sep='\n')

Measured memory_bytes: 9996
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  a*=b;
  if(a%2==0){
    cout<<"No"<<"\n";
  }
  else{
    cout<<"Yes"<<"\n";
  }
  
  return 0;
}

Measured memory_bytes: 3608
N = int(input())
XL = [tuple(map(int, input().split())) for _ in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
cnt = 0
now = 10 ** 9 * -1
for x, l in XL:
    if now <= x - l:
        cnt += 1
        now = x + l

print(cnt)


Measured memory_bytes: 62936
#include<stdio.h>
#include <string.h>
int main()
{
	int a,b,c,k,d,i;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	
	if(a<=b){
		if(b<=c){
			d=c;
			for(i=0;i<k;i++){
				d=d*2;
			}
			d=a+b+d;
			printf("%d\n",d);
		}
		else{
			d=b;
			for(i=0;i<k;i++){
				d=d*2;
			}
			d=a+c+d;
			printf("%d\n",d);
		}
	}
	else{
		if(a<=c){
			d=c;
			for(i=0;i<k;i++){
				d=d*2;
			}
			d=a+b+d;
			printf("%d\n",d);
		}
		else{
			d=a;
			for(i=0;i<k;i++){
				d=d*2;
			}
			d=b+c+d;
			printf("%d\n",d);
		}
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOREACH(element, vec_name) for (auto &(element) : (vec_name))

#define VECCIN(vec_name) for (auto &element : (vec_name)) cin >> element

#define dump(x) cout << #x << " = " << (x) << endl;

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }//最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }//最小公倍数

int GCD(vector<int> vec){ //多入力のGCD．入力はvectorとして与える
    int g = vec[0];
    FOREACH(element, vec){
        g = gcd(g, element);
    }
    return g;
}


int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    VECCIN(h);
    sort(h.begin(), h.end());

    if(k >= n){
        cout << 0 << endl;
    }else{
        rep(i, k) h.pop_back();
        ll ans = 0;
        FOREACH(e, h)
        ans += e;
        cout << ans << endl;
    }

    
    

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

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

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    vl x(N);
    vl y(N);
    REP(i,N){
        ll tx,ty;
        cin >> tx >> ty;
        x[i] = tx+ty;
        y[i] = tx-ty;
    }
    sort(ALL(x));
    sort(ALL(y));
    cout << max(x[N-1]-x[0],y[N-1] - y[0]) << "\n";
}

Measured memory_bytes: 6368
n,k=gets.split.map &:to_i
a=[]
(2*k).times do |i|
  a << gets.split.map(&:to_i)
end
h=Hash.new(0)
a.each_with_index do |e,i|
  if i%2==0
    d = e[0]
  else
    e.each do |i|
      h[i]+=1
    end
  end
end
puts n-h.keys.size

Measured memory_bytes: 14416
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
#define MOD 1000000007

void solve(long long N, std::vector<std::string> S){
    ll res = 1;
    ll i=0, W = S[0].length(), type=0;
    while(i < W){
        if(S[0][i]==S[1][i]){//* type1
            if(type == 0){
                res = (res * 3) % MOD;
            }
            else if(type == 1){
                res = (res * 2) % MOD;
            }
            type = 1;
            i++;
        }
        else {
            if(type == 0){
                res = (res * 6) % MOD;
            }
            else if(type == 1){
                res = (res * 2) % MOD;
            }
            else{
                res = (res * 3) % MOD;
            }
            type = 2;
            i += 2;
        }
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(2);
    for(int i = 0 ; i < 2 ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int N, T, A;

int main() {
  cin >> N >> T >> A;
  int H[N];
  for (int i = 0; i < N; ++i) cin >> H[i];

  int min_index = 0;

  for (int i = 0; i < N; ++i) {
    if (abs(T - H[i] * 0.006 - A) < abs(T - H[min_index] * 0.006 - A)) {
      min_index = i;
    }
  }

  cout << min_index + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vl xs(n), ys(m);
    cin>>xs>>ys;

    mint s = 0;
    rep(i, n - 1) {
        mint d = xs[i + 1] - xs[i];
        s += d * (i + 1) * (n - i - 1);
    }

    mint ans = 0;
    rep(i, m - 1) {
        mint d = ys[i + 1] - ys[i];
        ans += s * d * (i + 1) * (m - i - 1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int x[110],y[110];

int main() {
    int n, Abs, s1 = 0, d8 = 0;
    long long tmp, s2 = 0, s3 = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &y[i]);
    for (int i = 0; i < n; ++i) {
        Abs = abs(x[i] - y[i]);
        d8 = max(d8, Abs);
        tmp = Abs;
        s1 += tmp;
        tmp *= Abs;
        s2 += tmp;
        tmp *= Abs;
        s3 += tmp;
    }
    printf("%lf\n%lf\n%lf\n%lf", double(s1), sqrt(s2), cbrt(s3), double(d8));
    return 0;
}



Measured memory_bytes: 2904
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a,b,c;

int main(){
	cin>>n;
	a=b=vi(n);
	ll t=0;
	for(auto &i:a){
		cin>>i;
		t+=i;
	}
	for(auto &i:b){
		cin>>i;
		t-=i;
	}
	if(t<0){
		cout<<-1<<endl;
		return 0;
	}
	int res=0;t=0;
	for(int i=0;i<n;i++){
		if(a[i]<b[i]) t+=b[i]-a[i],res++;
		else c.push_back(a[i]-b[i]);
	}
	sort(c.rbegin(),c.rend());
	int N=c.size();
	for(int i=0;i<N&&t>0;i++){
		t-=c[i];
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))


#if 0
//No.3
int main()
{
	INT N;
	map<string, int> S;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		string str;
		cin >> str;
		S.insert(pair<string, int>(str, 0));
	}

	cout << S.size();

	return 0;
}
#endif

#if 1
//No.2
int MyCeil(int A, int B)
{
	if (A % B) {
		return A / B + 1;
	}
	else {
		return A / B;
	}
}

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

	INT turn_takahashi = MyCeil(A, D);
	INT turn_aoki = MyCeil(C, B);

	if (turn_takahashi >= turn_aoki) { cout << "Yes"; }
	else { cout << "No"; }

	return 0;
}
#endif

Measured memory_bytes: 3596
//doctor chef
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{

  int n;
  cin>>n;
  if(n%1000==0)
  {
    cout<<0;
  }
  else
  cout<<(1000-(n%1000));
}


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

int sum(int data[],int n){
    int total=0;
    for (int i=0;i<n;i++){
        if(data[i]%10==0){
            total+=data[i];
        }else{
            total+=(data[i]-(data[i]%10)+10);
        }
    }
    return total;
}

int main(){
    int A,B,C,D,E;
    cin>>A>>B>>C>>D>>E;
    int array[5]={A,B,C,D,E};
    int Max=0;
    for (int j=0;j<5;j++){
        if(array[j]%10!=0){
            if (Max<10-array[j]%10){
                Max=10-array[j]%10;
            }   
        }
    }
    cout<<sum(array,5)-Max<<endl;
}




Measured memory_bytes: 256
l, r = [int(i) for i in input().split()]

ans = 2019

for i in range(l, min(l + 2019, r + 1)):
    for j in range(i + 1, min(l + 2019, r + 1)):
        ans = min(ans, (i * j) % 2019)

print(ans)

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

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

p = 1000
kabu = 0

uri = False

for i in range(n):
    if i == n-1 or (uri and a[i+1] < a[i]):
        #uri
        p += kabu * a[i]
        kabu = 0
        uri = False
    elif (not uri) and a[i+1] > a[i]:
        #kai
        kabu = p // a[i]
        p -= a[i] * kabu
        uri = True

    #print(p, kabu)

print(p)

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

int main()
{
	int n,y,a,b,c;
	cin>>n>>y;
	for(a=0;a<=n;a++)
		for(b=0;b<=n;b++)
		{
			c=n-a-b;
			if(c>=0 && a*10000+b*5000+c*1000==y)
			{
				cout<<a<<" "<<b<<" "<<c<<endl;
				return 0;
			}
		}
	cout<<"-1 -1 -1"<<endl;
	return 0;	
}

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

namespace debug
{
    class ProgramC
    {
        static void Main(string[] args)
        {

            //入力
            string[] s  = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            double sum = 0.0;

            //
            for(int i = 0;i < n;i++)
            {
                int temp = i + 1;
                int count = 0;

                while(temp < k)
                {
                    temp *= 2;
                    count++;
                }

                sum += Math.Pow(0.5, count)/ n;
            }

            Console.WriteLine(sum);
            return;

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}

int main(void) {

int input[120];
char input1[120];
int j,count;
int N,B,C,A;

inp_str(input);
N=input[0];

	//printf("%d\n",N);

scanf("%s",input1);

//printf("%s\n",input1);

C=0;

for(B=0;B<N;B++){
if(input1[B]=='R'){C=C+1;}  // red c
	
}


//printf("%d\n",C);

A=N-C;

if(C>A) {
	printf("Yes\n");
}else{
printf("No\n");
}
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{

	char a[4];
	int c = 6;
	scanf("%s",&a);
	for (int i = 0; i < 3;i++) {
		
		if (a[i] == '7') {
			printf("Yes");
			return 0;
		}
	}
	printf("No");

	return 0;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll t,x; cin>>t>>x;

  cout<<(double)t/x<<endl;


}






Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long long N,T;
  cin >> N;
  T=0;
  vector<long long> a(N);
  for (int i=0;i<N;i++) {
    cin >> a.at(i);
    if (i+1!=a.at(i)) {T++;}
  }
  if (T==0 || T==2) {cout << "YES" << endl;} else {cout << "NO" << endl;}
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n,i,j;
  int a[10];
  int b[10];
  int c[10];
 
  cin >> n;
  int k =0;
  while(k<n){
    for(i=0;i<10;i++){
        cin >> a[i];
    }
    for(j=1;j<10;j++){
        b[0]=a[0];
        c[0]=0;
             
        if(b[j-1] < a[j]){
            b[j]=a[j];
            c[j]=c[j-1];
        }
        else if(c[j-1]<a[j]){
            c[j]=a[j];
            b[j]=b[j-1];
        }
        else{
            cout << "NO" << endl;
            break;
        }
        if(j==9){
            cout << "YES" << endl;
        }
    }
    k++;
 }
}  



Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int main ()
 { 
	 ll n;cin>>n;
	 ll a[n];
	 for (ll i=0;i<n;i++) cin>>a[i];
	 sort(a,a+n);
	 ld ans=1,p=1000000000000000000;
	 ll ans1=-1;
	 for (ll i=0;i<n;i++) {
		 ans=ans*a[i];
		 if (ans>p) {ans1=-1;break;}
		 else {
			 ans1=(long long int)ans;
		 }
	 }
	 cout<<ans1<<endl;
 }

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int d = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) d++;
    }
    if (d == 8) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int value[N];
    for(int i = 0; i < N; i++)
        cin >> value[i];
    sort(value, value + N);

    double mean_value = value[0];
    for(int i = 1; i < N; i++)
    {
        mean_value = (mean_value + value[i]) / 2.0;
    }
    printf("%.6f\n", mean_value);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int width, hight, x, y, radius;
    
    scanf("%d%d%d%d%d", &width, &hight, &x, &y, &radius);
    
    if(x - radius >= 0 && x + radius <= width
        && y - radius >= 0 && y + radius <= hight) {
            printf("Yes\n");
    }
    else {
        printf("No\n");
    }
	return 0;
}



Measured memory_bytes: 1988
N=int(input())
card=[[0 for i in range(14)] for i in range(4)]
for i in range(N):
    kind,num=map(str,input().split())
    num=int(num)
    if kind=="S":
        card[0][num]+=1
    elif kind=="H":
        card[1][num]+=1
    elif kind=="C":
        card[2][num]+=1
    elif kind=="D":
        card[3][num]+=1

for j in range(4):
    for t in range(1,14):
        if card[j][t]==0:
            if j==0:
                print("S {}".format(t))
            elif j==1:
                print("H {}".format(t))
            elif j==2:
                print("C {}".format(t))
            elif j==3:
                print("D {}".format(t))


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+2,0);
    for(int i=0;i<n;i++){
        cin>>a[i+1];
    }
    int sum=0;
    
    for(int i=0;i<n+1;i++){
        sum+=abs(a[i+1]-a[i]);
    }
    for(int i=0;i<n;i++){
        cout<<sum-abs(a[i+2]-a[i+1])-abs(a[i+1]-a[i])+abs(a[i+2]-a[i]) <<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import sys 
n=int(input())
w=[]
for i in range(n):
    w.append(input())
#print(w)
#print(w[1][-1])
if len(w)!=len(set(w)):
    print("No")
    #print(1)
    sys.exit()
else:
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            print("No")
            sys.exit()
        #print(w[i][-1],w[i+1][0])
print("Yes")

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

#define MAX_SEC 15
#define MAX_STATE 1 << 9

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}

using namespace std;

double dp[MAX_SEC+1][9];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int dir[4] = {1,3,-1,-3};

int main(void){
  int n;
  while(cin >> n && n){
    FILL(dp,0);
    char tmp;
    int s,t,b,x,y;

    cin >> tmp; s = (int)(tmp - 'A');
    cin >> tmp; t = (int)(tmp - 'A');
    cin >> tmp; b = (int)(tmp - 'A');

    dp[0][s] = 1;
    for(int i=0;i<n;i++){
      for(int j=0;j<9;j++){
	if(dp[i][j] == 0) continue;
	x = j%3;
	y = j/3;
	for(int k=0;k<4;k++){
	  if(0 <= x+dx[k] && x+dx[k] < 3 &&
	     0 <= y+dy[k] && y+dy[k] < 3 &&
	     j+dir[k] != b){
	    dp[i+1][j+dir[k]] += dp[i][j] * 0.25;
	  }else{
	    dp[i+1][j] += dp[i][j] * 0.25;
	  }
	}
      }
    }
    printf("%.8lf\n", dp[n][t]);
  }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.buffer.readline
H, N = map(int, input().split())
A = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]
INF = 1 << 30
dp = [INF]*(H+1)
dp[H] = 0
for i in range(N):
    a, b = A[i]
    for h in range(H, -1, -1):
        x = h-a if h-a > 0 else 0
        if dp[x] > dp[h]+b:
            dp[x] = dp[h]+b
print(dp[0])


Measured memory_bytes: 71800
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    int M = Math.min(A, B);
    List<Integer> list = new ArrayList<>();
    for(int i=1; i<=M; i++){
      if(A%i==0 && B%i==0){
        list.add(i);
      }
    }
    System.out.print(list.get(list.size() - K));
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string.h>
using namespace std;
int main ()
{
	int n,m;
	cin>>n>>m;
	int a[60];
	int b[60],c[60];
	memset(a,0,sizeof(a));
	int x,y;
	for(int i=1;i<=m;i++)
	{
		
		cin>>b[i]>>c[i];
		a[b[i]]++;
		a[c[i]]++;
		
	 } 
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
	
	
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   string t;
   int i, pd=0;
   cin >> t;
   for(i=0;i<t.size();i++){
      if(t[i]=='?'){
         t[i]='D';  
      }
   }
   cout << t <<endl;
   return 0;
}



Measured memory_bytes: 3756
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

map<int, int>mp;

int getans(const vector<vector<int>>&field,const int row, const map<vector<int>, int>&memo) {
	if (row == 4) {
		int ans = 0;
		for (auto m : memo) {
			vector<int>changed(m.first);
			int nextscore(m.second);
			for (int j = 0; j < 5; ++j) {
				if (field[row][j]) {
					const int number = (field[row][j] + changed[j]) % 4;
					nextscore += mp[number];
				}
			}
			ans = max(ans, nextscore);
			
		}
		return ans;
	}
	map<vector<int>, int>newmemo;
	for (auto m : memo) {
		for (int i = 0; i < 256; ++i) {
			int num(i);
			vector<int>push(4);
			for (int j = 0; j < 4; ++j) {
				push[j] = num % 4;
				num /= 4;
			}
			vector<int>fliped(5);
			for (int j = 0; j < 4; ++j) {
				fliped[j] += push[j];
				fliped[j + 1] += push[j];
			}
			vector<int>changed(m.first);
			for (int j = 0; j < 5; ++j) {
				changed[j] += fliped[j];
			}
			for (int j = 0; j < 5; ++j)changed[j] %= 4;
			int nextscore(m.second);
			for (int j = 0; j < 5; ++j) {
				if (field[row][j]) {
					const int number = (field[row][j] + changed[j]) % 4;
					nextscore += mp[number];
				}
			}
			newmemo[fliped] = max(newmemo[fliped], nextscore);
		}
	}
	return getans(field, row + 1, newmemo);
	
}

int getans(const vector<vector<int>>field) {
	map<vector<int>, int>amap;
	amap[vector<int>(5, 0)] = 0;
	return getans(field, 0, amap);
}

int main() {
	mp[1] = 0;
	mp[2] = 60;
	mp[3] = 70;
	mp[0] = 80;
	int N; cin >> N;
	while (N--) {
		vector<vector<int>>field(5, vector<int>(5));
		for (int y = 0; y < 5; ++y) {
			for (int x = 0; x < 5; ++x) {
				cin >> field[y][x];
			}
		}
		int ans = getans(field);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
module mod_binary_indexed_tree
  implicit none
  type fenwick_tree
    integer :: n
    integer, pointer :: arr(:)
  end type fenwick_tree
  private
  public :: fenwick_tree, init_bit, release_bit
  public :: add, summate, update, maximum
contains
  subroutine init_bit(bit,n)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: n
    bit%n = n
    allocate(bit%arr(n))
    bit%arr = 0
    return
  end subroutine init_bit
  subroutine release_bit(bit)
    implicit none
    type(fenwick_tree) :: bit
    if (associated(bit%arr)) deallocate(bit%arr)
    return
  end subroutine release_bit
  subroutine add(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    if (i.eq.0) return
    x = i
    do while (x.le.bit%n)
      bit%arr(x) = bit%arr(x)+v
      x = x+and(x,-x)
    end do
    return
  end subroutine add
  function summate(bit,i) result(s)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, s
    x = i
    s = 0
    do while (x.gt.0)
      s = s+bit%arr(x)
      x = x-and(x,-x)
    end do
    return
  end function summate
  subroutine update(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i, v
    integer :: x
    x = i
    do while (x.le.bit%n)
      if (bit%arr(x).lt.v) bit%arr(x) = v
      x = x+and(x,-x)
    end do
    return
  end subroutine update
  function maximum(bit,i) result(m)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x, m
    x = i
    m = 0
    do while (x.gt.0)
      m = max(m,bit%arr(x))
      x = x-and(x,-x)
    end do
    return
  end function maximum
end module mod_binary_indexed_tree
program snuke_line
  use mod_binary_indexed_tree
  implicit none
  type(fenwick_tree) :: bit
  integer :: n, m, a(300000,3), ans(100000), i, j, k, x
  a = 0
  ans = 0
  read(*,*) n, m
  do i = 1, n
    read(*,*) a(i,1), a(i,2)
    a(i,3) = a(i,2)-a(i,1)+1
  end do
  call quick_sort(a(1:n,1:3),3)
  call init_bit(bit,m+1)
  ans(1) = n
  j = 1
  do i = 2, m
    do while (j.le.n)
      if (a(j,3).gt.i) exit
      call add(bit,a(j,1),1)
      call add(bit,a(j,2)+1,-1)
      j = j+1
    end do
    x = n-j+1
    do k = i, m, i
      x = x+summate(bit,k)
    end do
    ans(i) = x
  end do
  do i = 1, m
    write(*,'(i0)') ans(i)
  end do
  stop
contains
  recursive subroutine quick_sort(a,i)
    implicit none
    integer, intent(inout) :: a(:,:)
    integer, intent(in) :: i
    integer :: p, c(size(a(1,:)))
    integer :: n, l, r, m
    n = size(a(:,1))
    l = 1
    r = n
    m = (l+r)/2
    p = a(l,i)+a(m,i)+a(r,i)-max(a(l,i),a(m,i),a(r,i))-min(a(l,i),a(m,i),a(r,i))
    do
      do while (a(l,i).lt.p)
        l = l+1
      end do
      do while (a(r,i).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l,:)
      a(l,:) = a(r,:)
      a(r,:) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1,:),i)
    if (n.gt.r+1) call quick_sort(a(r+1:n,:),i)
    return
  end subroutine quick_sort
end program snuke_line

Measured memory_bytes: 5248
n,k = map(int,input().split())
List = [list(map(int, input().split())) for i in range(2*k)]
List_a = []
for x in range(1,2*k,2):
    for i in List[x]:
        List_a.append(i)

List_a =set(List_a)
print(n-len(List_a))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += max(0, a[i] - a[i-1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(b % a == 0) cout << a+b << "\n";
  else cout << b-a << "\n";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct RollingHash{
    static const int MD = 3;
    static const vector<ll> hash_base, hash_mod;

    int n;
    vector<ll> hs[MD], pw[MD];

    RollingHash(){}
    RollingHash(const string &s){
        n = s.size();
        rep(i,MD){
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            rep(j,n){
                pw[i][j+1] = pw[i][j]*hash_base[i] % hash_mod[i];
                hs[i][j+1] = (hs[i][j]*hash_base[i]+s[j]) % hash_mod[i];
            }
        }
    }

    // 1-index
    ll hash_value(int l, int r, int i){
        return ((hs[i][r] - hs[i][l]*pw[i][r-l])%hash_mod[i]+hash_mod[i])%hash_mod[i];
    }

    bool match(int l1, int r1, int l2, int r2){
        bool ret = true;
        rep(i,MD) ret &= (hash_value(l1-1,r1,i) == hash_value(l2-1,r2,i));
        return ret;
    }

    vector<ll> calc(int l, int r){
        vector<ll> ret(MD);
        rep(i,MD) ret[i]=hash_value(l-1,r,i);
        return ret;
    }
};
const vector<ll> RollingHash::hash_base{1009,1021,1013};
const vector<ll> RollingHash::hash_mod{1000000009,1000000007,1000000021};

int main()
{
    string s,t;
    cin >>s >>t;
    RollingHash sh(s), th(t);

    int S = s.size(), T = t.size();
    int ans = 0;
    rep(i,S-T+1)
    {
        int l=0,r=T+1;
        while(r-l>1)
        {
            int m =(l+r)/2;
            if(sh.calc(1+i,1+i+m-1) == th.calc(1,m)) l=m;
            else r=m;
        }

        if(l>=T-1)
        {
            ans += (l==T-1);
            continue;
        }

        ans += (sh.calc(1+i+l+1,i+T) == th.calc(l+2,T));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<int>> text(n, vector<int>(m));
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++)cin >> text[i][j];
  }
  
  int ans = 12345678;
  
  for(int s = 0; s < (1<<n); s++){
    int total = 0;
    vector<int> understand(m);
    for(int i = 0; i < n; i++){
      if((s>>i) & 1){
        total += c[i];
        for(int j = 0; j < m; j++)understand[j] += text[i][j];
      }
    }
    bool ok = true;
    for(int i = 0; i < m; i++){
      if(understand.at(i) < x) ok = false;
    }
    if(ok) ans = min(ans, total);
  }
  
  if(ans == 12345678) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    string s, t;
    cin >> s >> t;

    int a[26] = {}, b[26] = {};
    rep(i, s.length()) {
        a[s[i] - 'a']++;
        b[t[i] - 'a']++;
    }

    sort(a, a + 26);
    sort(b, b + 26);

    bool ok = true;
    rep(i, 26) {
        if (a[i] != b[i]) ok = false;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var lr = Console.ReadLine().Split();
            var l = int.Parse(lr[0]);
            var r = int.Parse(lr[1]);

            if(r - l + 1 >= 2019)
            {
                Console.WriteLine(0);
            }

            else
            {
                var ans = 2019;
                for(int i = l; i <  r; i++)
                {
                    for(int j = i + 1; j <= r; j++)
                    {
                        if (i % 2019 == 0 || j % 2019 == 0)
                        {
                            Console.WriteLine(0);
                            return;
                        }

                        if(ans > (i % 2019) * (j % 2019) % 2019)
                        {
                            ans = (i % 2019) * (j % 2019) % 2019;
                        }
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 27512
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
int N;
char c[202020];
void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    itn ans = 1;
    FOR(i, 0, N) {
        cin >> c[i];
    }
    FOR(i, 1, N) {
        if (c[i] != c[i - 1])
            ans++;
    }
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int n,a[100]={0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        
    }
    
    for (int i=n-1;i>=0;i--){
        
    if(i==n-1){
        cout<< a[i];
    }
    else {
        cout << " " << a[i];
    }
    }
    
    cout << endl;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = -1;
    REP(i, n){
        int a[26], b[26];
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        REP(j, i+1){
            a[s[j]%26]++;
        }FOR(j, i+1, n){
            b[s[j]%26]++;
        }
        int tmp = 0;
        REP(j, 26){
            if(a[j] >0 && b[j] >0) tmp++;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(void) {
    string S;
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256