akhauriyash/Code-Regression huggingface dataset:
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();
if((a+b)%2==0){
System.out.println((a+b)/2);
}else{
System.out.println((a+b)/2+1);
}
}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main (void)
{
  int a,b,c,x,y,s[3],i,min;
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
  s[0]=a*x+b*y;
  min=s[0];
  
  if(x>=y)
  {
    s[1]=2*c*y+a*(x-y);
    s[2]=2*c*x;
  }
  else
  {
    s[1]=2*c*x+b*(y-x);
    s[2]=2*c*y;
  }
  
  for(i=1;i<3;i++)
    if(min>=s[i])
      min=s[i];
    
  
  printf("%d",min);
}

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

const int INF = 1e9;
int main(){
  int w;
  scanf("%d",&w);
  vector<int> a(w);
  for(int i=0;i<w;i++)scanf("%d",&a[i]);

  vector<int> pop(w,0);

  int t = 0;
  for(int i=0;i<w;i++){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else{
      pop[i] = max(pop[i], t);
    }
    t = max(t-1,0);
  }

  t = 0;
  for(int i=w-1;i>=0;i--){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else{
      pop[i] = max(pop[i], t);
    }
    t = max(t-1,0);
  }

  int ans = 0;
  for(int i=0;i<w;i++){
    if(a[i]>0)ans += min(pop[i], a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1800
import sys
input=lambda: sys.stdin.readline().rstrip()

r,c,k=map(int,input().split())
D=[[0]*c for _ in range(r)] 
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri][ci]=v

DP0=[[0]*(c+1) for i in range(r+1)]
DP1=[[0]*(c+1) for i in range(r+1)]
DP2=[[0]*(c+1) for i in range(r+1)]
DP3=[[0]*(c+1) for i in range(r+1)]
for i in range(r):
	for j in range(c):
		v=D[i][j]
		if v!=0:
			DP1[i][j]=max(DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])+v

		DP0[i][j]=max(DP0[i][j],DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i-1][j]+v,DP1[i-1][j]+v,DP2[i-1][j]+v,DP3[i-1][j]+v)
		DP0[i][j]=max(DP0[i][j],DP0[i][j-1])
		DP1[i][j]=max(DP1[i][j],DP1[i][j-1])
		DP2[i][j]=max(DP2[i][j],DP2[i][j-1])
		DP3[i][j]=max(DP3[i][j],DP3[i][j-1])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i][j-1]+v)
			DP2[i][j]=max(DP2[i][j],DP1[i][j-1]+v)
			DP3[i][j]=max(DP3[i][j],DP2[i][j-1]+v)
		
ans=max(DP0[r-1][c-1],DP1[r-1][c-1],DP2[r-1][c-1],DP3[r-1][c-1])
print(ans)



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

const int N = 2e5 + 10, mod = 1e9 + 7;



int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        string s; cin >> s;
        if(s[2] == s[3] && s[4] == s[5]) puts("Yes");
        else puts("No");
    }    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    System.out.println(LongStream.rangeClosed(1, sc.nextInt())
      .filter(e -> e % 3 != 0)
      .filter(e -> e % 5 != 0)
      .sum());
  }
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>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 {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int x,y;cin >> x >> y;
    if((2*x-y)%3!=0||(2*y-x)%3!=0) {
        cout << 0 << endl;
        return 0;
    }
        if((2*x-y)<0||(2*y-x)<0) {
        cout << 0 << endl;
        return 0;
    }

    int n = (2*x-y)/3;
    int m = (2*y-x)/3;
    mint ans=1;

    for(int i=1;i<=m;i++){
        ans *= (n+i);
        ans *= mint(i).inv();
    }

    cout << ans << endl;



 }

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

int main(){
    int n;
    cin >> n;
    int card[5][14];
    
    for(int i=1;i<=4;i++){
        for (int j=1;j<=13;j++){
            card[i][j]=0;
        }
    }
    
    for(int i=1;i<=n;i++){
        char m;
        int a;
        cin >> m >> a;
        if(m=='S'){
            card[1][a]=1;
        }
        else if(m=='H'){
            card[2][a]=1;
        }
        else if(m=='C'){
            card[3][a]=1;
        }
        else if(m=='D'){
            card[4][a]=1;
        }
    }
    
    for(int i=1;i<=13;i++){
        if(card[1][i]!=1){
            cout << "S"<< " "<< i << endl;
        }
    }
    for(int i=1;i<=13;i++){
     if(card[2][i]!=1){
            cout << "H"<<" " << i << endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(card[3][i]!=1){
            cout << "C"<<" " << i << endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(card[4][i]!=1){
            cout << "D"<<" " << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;

	S[5] = ' ';
	S[13] = ' ';

	co(S);

	Would you please return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;


void solve() {
    int N;
    cin >> N;
    map<int,int> mp; // 重複カウンタ用, 値が2以上の場合は答えに含まれない
    set<int> st; //　値のset
    set<int> hurui; // (値,存在しない: 値の約数はそれのみ, 存在する: 値の約数が<集合stから自身を除いたもの>の中に存在する。)
    REP(i,N) {
        int a; cin >> a;
        st.insert(a);
        if(mp.count(a) == 0) mp[a] = 0;
        mp[a]++;
    }
    auto maxel = *max_element(ALL(st));
    int ans = 0;
    for(const auto &a: st) {
        // 存在しないなら値の約数はそれのみなので、重複カウンタもおkだったら答えとなる。
        if((!hurui.count(a)) && (mp[a] < 2) ) ans++;
        int ax = a,i = 0;
        while((ax*(i+1)) <= maxel) {
            i++;
            hurui.insert(ax*i);
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 64760
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int a, b, c, k;
	cin >> a >> b >> c >> k;
  	if(k <= a)
    {
    	cout << k;
    }
  	else if(k <= a+b)
    {
    	cout << a;
    }
  	else
    {
    	cout << a - (k-a-b);
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
int main(){
    int n;cin>>n;
    int l=1;
    while(l*(l+1)<n*2){
        l+=1;
    }
    if(l*(l+1)!=n*2){
        cout<<("No")<<endl;
        //bool flag=true;
    }
    else{
        ll cnt = l*(l+1)/2;
        vector<vector<int> > ans(l+1,vector<int>(l));
        int c=0;
        int r=0;
        rep(i,cnt){
            ans[c][r]=i+1;
            ans[r][c]=i+1;
            if(r==l-1){
                ans[l][c]=ans[c][c];
                c+=1;
                r=c;
            }
            else{
                r+=1;
            }
        }
        cout<<"Yes"<<endl;
        cout<<l+1<<endl;
        rep(i,l+1){
            cout<<l<<" ";
            rep(j,l){
                cout<<ans[i][j]<<" ";
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 2176
N = int(input())
str_list = input().split()
num_list = [int(a) for a in str_list]
Alice = 0
Bob = 0
count = 1
while num_list:
    temp = max(num_list)
    if count % 2 != 0:
        Alice += temp
    else:
        Bob += temp
    num_list.remove(temp)
    count += 1

print(Alice - Bob)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int matrix[30][30];
int dp[25][2097160];
int n;

int solve(int index, int number) {

	if (index == n)	return 1;

	if (dp[index][number] != -1)	return dp[index][number];

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (!((number >> i) & 1) && matrix[index][i] == 1) {
			ans += solve(index + 1, number + (1 << i));
			ans %= mod;
		}
	}
	return dp[index][number] = ans % mod;
}


int32_t main() {

	fastIO();

	cin >> n;
	fo(i, 0, n, 1) {
		fo(j, 0, n, 1) {
			cin >> matrix[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) << endl;

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

Measured memory_bytes: 409984
use strict;
use warnings;

my ($n, $m);
{
  my $in = <STDIN>;
  ($n, $m) = split(" ", $in);
}
my (@s, @c);
{
  for (my $i=0; $i<$m; $i++) {
    my $in = <STDIN>;
    ($s[$i], $c[$i]) = split(" ", $in);
  }
}

for (my $i=0; $i<1000; $i++) {
  my $ans = 0;
  next unless length($i) == $n;
  for (my $j=0; $j<$m; $j++) {
    if (substr($i, $s[$j]-1, 1) eq $c[$j]) {
      $ans++;
    }
  }
  if ($ans==$m) {
    print $i, "\n";
    exit;
  }
}
print "-1\n";

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int N;
  cin >> N;
  vpr L, R;
  vector<string> vec(N);
  rep(i, N) {
    string s;
    cin >> s;
    vec[i] = s;
    int sz = s.size();
    int maxl = 0, maxr = 0, l = 0, r = 0;
    rep(j, sz) {
      if(s[j] == ')') l++;
      else l--;
      chmax(maxl, l);
      if(s[sz-j-1] == '(') r++;
      else r--;
      chmax(maxr, r);
    }
    if(maxl <= maxr) L.push_back(make_pair(maxl, i));
    else R.push_back(make_pair(maxr, i));
  }
  sort(ALL(L), less<pair<ll, ll>>());
  sort(ALL(R), greater<pair<ll, ll>>());
  copy(ALL(R), back_inserter(L));
  int cnt = 0;
  for(auto& l : L) {
    int sz = vec[l.second].size();
    rep(j, sz) {
      cerr << vec[l.second][j];
      if(vec[l.second][j] == '(') cnt++;
      else cnt--;
      if(cnt < 0) {
        cout << "No\n";
        return;
      }
    }
  }
  cerr << "\n";
  if(cnt == 0) cout << "Yes\n";
  else cout << "No\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 58748
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int h = s[0];
            int a = s[1];
            int ans = 0;
            while(h > 0){
              ans++;
              h-=a;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11348
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
c = STR()
arr = [0 if i == 'R' else 1 for i in c]
wnum = sum(arr)
rnum = n - wnum
ans = 0
for i in range(rnum):
    if arr[i] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 86888
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#ifdef DEBUG
    #include <ctime>
#endif
using namespace std;

// template

// abbreviations
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define ii pair<int, int>
#define a first
#define b second
#define vii vector<ii>
#define mii map<ii>
#define vvi vector<vi>
#define vvl vector<vl>
#define que queue
#define pque priority_queue
#define stk stack
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define pu push
#define po pop
#define mp make_pair
#define sz(var) ((int) var.size())
#define rep(it, n) for(int it = 0; it < n; ++it)
#define dep(it, n) for(int it = n - 1; it >= 0; --it)
#define rep1(it, n) for(int it = 1; it <= n; ++it)
#define dep1(it, n) for(int it = n; it > 0; --it)
#define loop(it, from, to) for(int it = (from); it <= (to); ++it)
#define iter(it, cont) for(__typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it)
#define riter(it, cont) for(__typeof((cont).rbegin()) it = (cont).rbegin(); it != (cont).rend(); ++it)
#define all(cont) (cont).begin(), (cont).end()
#define rng(cont, n) cont, cont + n
#define memclr(var) memset(var, 0, sizeof(var))

typedef unsigned long long ull;
typedef long long ll;

const int INF = INT_MAX;
const int NINF = INT_MIN;
const ll INF_LL = LLONG_MAX;
const ll NINF_LL = LLONG_MIN;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;

#ifdef DEBUG
    #define debug(fmt, args...) printf("Line %d, in %s\t: " fmt, __LINE__, __FUNCTION__, ##args)
    #define rep_rt() printf("[Run time: %.3fs]\n", ((double) clock()) / CLOCKS_PER_SEC)
#else
    #define debug(...)
#endif

// end of template

#define MAXN (int) (1e5)

int arr[MAXN + 1];

int main() {
#ifdef DEBUG
    freopen("agc003_b.in", "r", stdin);
#endif
    
    int n;
    scanf("%d", &n);
    rep1(val, n) {
        scanf("%d", arr + val);
    }

    ll ans = 0;
    ll temp = 0;
    rep1(val, n) {
        if (arr[val])
            temp += arr[val];
        else {
            ans += temp / 2;
            temp = 0;
        }
    }
    ans += temp / 2;
    printf("%lld\n", ans);

#ifdef DEBUG
    rep_rt();
#endif
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define M 1000000

typedef struct{
  int t;
  char n[10];
}qu;

qu Q[M];
int H,T;

void en(qu q){
  Q[T] = q;
  T++;
}

qu de(){
  qu q;

  q = Q[H];
  H++;
  return q;
}

int main(){
  int i,n,cnt,sum;
  qu q;

  scanf("%d %d",&n,&cnt);

  for(i=0;i<n;i++){
    scanf("%s",Q[i].n);
    scanf("%d",&Q[i].t);
  }

  sum = 0;
  H = 0;
  T = n;

  while(H != T){
    q = de();

    if(q.t <= cnt){
      sum += q.t;
      printf("%s %d\n",q.n,sum);
    }
    else {
      q.t -= cnt;
      en(q);
      sum += cnt;
    }
  }

  return 0;
}



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

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

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    //(sx,tx)->(tx,ty)
    rep(i,dx) cout << "R";
    rep(i,dy) cout << "U";
    //(tx,ty)->(sx,sy)
    rep(i,dx) cout << "L";
    rep(i,dy) cout << "D";
    //(sx,sy)->(tx,ty)
    cout << "D";
    rep(i,dx+1) cout << "R";
    rep(i,dy+1) cout << "U";
    cout << "L";
    //(tx,ty)->(sx,sy)
    cout << "U";
    rep(i,dx+1) cout << "L";
    rep(i,dy+1) cout << "D";
    cout << "R";
    cout << endl;
}

Measured memory_bytes: 256
def solve():
    N=int(input())
    AL=list(map(int,input().split()))
    now=1
    broken=0
    
    for a in AL:
        if a==now:
            now+=1
        else:
            broken+=1
        
    if 1 not in AL:
        return -1
    
    return broken

print(solve())


Measured memory_bytes: 77516
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	string a;
	cin >> a;
	int t = 0;
	rep(i, a.size()) {
		t += a[i] - '0';
	}
	int num = atoi(a.c_str());

	if (num % t == 0)  cout << "Yes" << endl;
	else  cout << "No" << endl;
}


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

signed main(){
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vector<int> > dp(n + 1, vector<int> (m + 1, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	string ans;
	int i = n, j = m;
	while(i && j){
		if(dp[i][j] == dp[i - 1][j]) i--;
		else if(dp[i][j] == dp[i][j - 1]) j--;
		else{
			ans += s[i - 1];
			i--; 
			j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 38608
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <memory>
#include <set>
#include <map>
#include <list>
#include <cmath>

using namespace std;

int main()
{
    char s[128];
    scanf("%s",s);
    int a[30];
    memset(a,0,sizeof(a));
    int bad=0;
    for(int i=0;i<strlen(s);i++)
    {
        if(a[s[i]-'a']>0) bad=1;
        a[s[i]-'a']++;
    }
    if(bad) cout<<"no"<<endl;
    else cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
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;}
string s,t;
ll dp[3100][3100];
int main(void){
    // Your code here!
    rep(0,i,3100)rep(0,j,3100)dp[i][j]=0;
    cin>>s>>t;
    rep(0,i,s.size()){
        rep(0,j,t.size()){
            if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    string res="";
    ll i=s.size(),j=t.size();
    while(i>0 && j>0){
        if(dp[i][j]==dp[i-1][j])--i;
        else if(dp[i][j]==dp[i][j-1])--j;
        else{
            res=s[i-1]+res;
            --i,--j;
        }
    }
    cout<<res<<endl;
    
}


Measured memory_bytes: 75392
#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[200001];
    char *a,*z;
    scanf("%s",str);
    a = strchr( str, 'A');
    z = strrchr(str, 'Z');
    printf("%d\n",z-a+1);
    return 0;
}

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

int main() {
  string N;
  cin >> N;
  int size = N.size();
  int last = size - 1;
  char L = N.at(last);
  
  if (L == '3') {
    cout << "bon";
  }
  else if ((N.at(last) == '0') || (N.at(last) == '1') || (N.at(last) == '6') || (N.at(last) == '8')) {
    cout << "pon";
  }
  else {
    cout << "hon";
  }
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    char C; cin >> C;
    cout << (char)(C + 1) << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> xs(5);
    for (int& x : xs) {
        cin >> x;
    }
    int k;
    cin >> k;
    int hi = *max_element(xs.begin(), xs.end());
    int lo = *min_element(xs.begin(), xs.end());
    cout << (hi-lo <= k ? "Yay!" : ":(") << endl;
    return 0;
}


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

int main() {
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a<=40){a=40;}
if(b<=40){b=40;}
if(c<=40){c=40;}
if(d<=40){d=40;}
if(e<=40){e=40;}
cout << (a+b+c+d+e)/5 << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  vector<pair<int,int>> a(n);
  rep(i,0,n) {cin>>a[i].f; a[i].s=i;}
  sort(a.begin(),a.end());
  int mid1=a[n/2-1].f,mid2=a[n/2].f;
  vector<int> ans(n);
  rep(i,0,n){
    if(i<=n/2-1) ans[a[i].s]=mid2;
    else ans[a[i].s]=mid1;
  }
  rep(i,0,n) cout<<ans[i]<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 5528
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	string a;
	cin >> a;
	sort(a.begin(), a.end());
	if ((a[0] == a[1] && a[2] == a[3]) && (a[2]!=a[1])) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
ll const MAX = 3e3 + 5;
ll x[MAX];
ll dp[MAX][MAX] = {};
ll sumx[MAX];

int main() {
	ll n;
	cin >> n;
	sumx[0] = 0;
	REP(i, 1, n) {
		cin >> x[i];
		sumx[i] += sumx[i - 1] + x[i];
	}
	REP(i, 1, n) {
		dp[i][i] = x[i];
	}
	REP(l, 2, n) {
		REP(i, 1, n + 1 - l) {
			ll j = i + l - 1;
			dp[i][j] = max(x[i] + sumx[j] - sumx[i] - dp[i + 1][j], 
				x[j] + sumx[j - 1] - sumx[i - 1] - dp[i][j - 1]);
		}
	}
	cout << dp[1][n] - (sumx[n]  - dp[1][n]) << endl;
}

Measured memory_bytes: 70016
def main():
    n = input()
    d_list = list(map(int, input().split()))
    d_list.sort()
    arc = d_list[int(len(d_list) / 2)]
    abc = d_list[int(len(d_list) / 2) - 1]
    print(arc - abc)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <cstdlib>
#include <cassert>

using namespace std;

using Result = vector<pair<int,int>>;

Result solve(string s) {
  int n = s.size();
  s = " " + s;

  if (s[n] != '0' || s[1] == '0') {
    return {};
  }

  Result result;
  int next = 2;
  int root = 1;
  for (int i = 1; i <= (n + 1) / 2; ++i) {
    if (s[i] != s[n - i]) {
      return {};
    }
    result.emplace_back(root, next);
    if (s[i] == '1') {
      root = next;
    }
    next += 1;
  }

  while (next <= n) {
    result.emplace_back(root, next);
    next += 1;
  }

  return result;
}

int main(void)
{
  string s; cin >> s;
  Result result = solve(s);

  if (result.empty()) {
    cout << "-1\n";
  } else {
    for (auto it : result) {
      cout << it.first << " " << it.second << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 2548
#include <iostream>

using namespace std;

int main() {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;
    if(A%K==0) {
        cout << "OK" << endl;
    } else {
        if((A/K+1)*K<=B) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		//入力を取得します
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();

		
		List<Integer> a = new ArrayList<>(n);
		List<Integer> b = new ArrayList<>(n);
		for (int i = 0 ; i < n; i++) {
		  int sin1 = sc.nextInt();
		  int sin2 = sc.nextInt();
		  a.add(sin1);
		  b.add(sin2);
		}
		sc.close();
		
	
		//計算部分

		int count = 0;
		
		Collections.sort(a,Comparator.reverseOrder());
		Collections.sort(b,Comparator.reverseOrder());
		int a1 = a.get(0);
		roop:
		for (int i=0; i<n; i++) {
			if (b.get(i) > a1){
				h -= b.get(i);
				count++;
				if (h <= 0) {
					break roop;
				}
				if (i == n-1) {
					if (h%a1 == 0) {
						count += h/a1;
						break roop;
					} else {
						count += h/a1 + 1;
						break roop;
					}
					
				}
				
			} else {
				if (h%a1 == 0) {
					count += h/a1;
					break roop;
				} else {
					count += h/a1 + 1;
					break roop;
			    }
			}
			
		}
		
		    System.out.println(count);
	}
		

}


Measured memory_bytes: 92788
import java.util.ArrayDeque;
import java.util.Scanner;

class Main {
	static int N;
	static long[] x;
	final static long MODULO = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		x = new long[N];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextLong();
		}

		long ans = 1;
		ArrayDeque<Long> stack = new ArrayDeque<>();
		int p = 0;
		while (true) {
			while (p < N && stack.size() * 2 + 1 <= x[p]) {
				stack.add(x[p]);
				++p;
			}
			ans = (ans * (stack.size() + (p != N ? 1 : 0))) % MODULO;
			stack.pollFirst();
			if (stack.size() == 0 && p == N)
				break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50828
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = [int(i) for i in input().split()]
    m = sum(s)/n
    a = [(s[i]-m)**2 for i in range(n)]
    v = sum(a)/n
    sb = math.sqrt(v)
    print("{:.5f}".format(sb))

Measured memory_bytes: 7832
#include <stdio.h>
int h, w, a, b, c;
int main() {
	scanf("%d%d%d%d", &h, &w, &a, &b);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			c = 1;
			if (i < b && j < a)c = 0;
			if (i >= b && j >= a)c = 0;
			printf("%d", c);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define M 1<<22
typedef long long int ll;
struct edge{ ll to,cost;};

void dfs(vector<vector<edge> > g,ll r,vector<ll> count,vector<ll> ans,ll e){
	priority_queue<ll>q;
	q.push(r);
	ans[r]=0;
	int t=0;
	while(!q.empty()){
		ll now=q.top();
		count[now]++;
	
	//	ans[now]=0;
		q.pop();
		for(ll i=0;i<g[now].size();i++){
			if(ans[now]+g[now][i].cost<ans[g[now][i].to]){
				ans[g[now][i].to]=ans[now]+g[now][i].cost;
		//		cout<<g[now][i].to<<' '<<ans[g[now][i].to]<<endl;
				count[g[now][i].to]++;
				q.push(g[now][i].to);
				if(count[g[now][i].to]>e){
				//	cout<<g[now][i].to<<endl;
					cout<<"NEGATIVE CYCLE"<<endl;
				//	return false;
				return;
				}
			}
		}
	}

		for(ll i=0;i<ans.size();i++){
			if(ans[i]==M) {
				cout<<"INF"<<endl;
			}
		else{	cout<<ans[i]<<endl;
		}
		}

//	return true;
return;
}
int main(void){
	ll v,e,r;
	cin>>v>>e>>r;
	vector<vector<edge> >  g(v);
	vector<ll> count(v,0),ans(v,M);
	ll s,t,d;
	for(ll i=0;i<e;i++){
		cin>>s>>t>>d;
		edge a;
		a.to=t;
		a.cost=d;
		g[s].push_back(a);
	}
	/*
	cout<<"ex"<<endl;
	cout<<g.size()<<endl;
	for(int i=0;i<v;i++){
		cout<<g[i].size()<<endl;
		for(int j=0;j<g[i].size();j++){
			cout<<i<<' '<<g[i][j].to<<' '<<g[i][j].cost<<endl;
		}
	}*/
	dfs(g,r,count,ans,e);
/*	if(dfs(g,r,count,ans)){
		for(int i=0;i<v;i++){
			if(ans[i]==M)cout<<"INF"<<endl;
		else	cout<<ans[i]<<endl;
		}
	}else{
		cout<<"NEGATIVE CYCLE"<<endl;
	}*/
	return 0;
}


Measured memory_bytes: 3252
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
    //  freopen("test.in", "r", stdin);
    //  freopen("ac.txt", "w", stdout);
    int x;
    scanf("%d",&x);
    if(x>=30) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

i64 res = -1;

signed main() {

    int M;  cin >> M;
    i64 s = 0;
    REP(i, M) {
        i64 C, D;
        cin >> D >> C;
        res += C;
        s += D * C;
    }
    res += (s - 1) / 9;

    cout << res << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1LL<<63)
#define MAX 70
#define deb(a) cout << #a << " " << a << endl

using namespace std;

typedef long long ll;

ll N,M;
ll C[MAX][MAX];

void makeC()
{
  C[0][0] = 1;
  rep(i,MAX-1)rep(j,i+1)
    {
      C[i+1][j] += C[i][j];
      if(j+1<MAX)C[i+1][j+1] += C[i][j];
    }
}

void compute()
{
  M--;
  if(M == 0)
    {
      cout << string(N,'0') << endl;
      return;
    }
  string ans = "";
  int NumberOfBits = 1;
  ll sum = 0;
  while(true)
    {
      sum += C[N][NumberOfBits]; 
      if(sum >= M)break;
      NumberOfBits++;
    }
  sum -= C[N][NumberOfBits];
  sum = M - sum;

  for(int i=N;i>=1;i--)
    {
      ll cost = sum - C[i-1][NumberOfBits];
      if(cost >  0)
	{
	  ans += "1";
	  sum -= C[i-1][NumberOfBits];
	  NumberOfBits--;
	}
      else ans += "0";
    }

  cout << ans << endl;
}

int main()
{
  makeC();

   while(cin >> N >> M,N|M)compute();

  return 0;
}

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

int main(){
  int pe[31] = {0};
  for(int i=0;i<28;i++){
    int t; cin >> t;
    pe[t] = 1;
  }
  for(int i=1;i<=30;i++){
    if(!pe[i]) cout << i << endl;
  }
}

Measured memory_bytes: 1160
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//Fukushimaken
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[17];
		int[] p = new int[100];
		int[] w = new int[100];
		int[] sit = new int[100];
		for(int i=0;i<100;i++){
			p[i] = i%5==1?5:2;
			w[i] = 17*(i%2)+3*(i%3)+19;
		}
		int i = 0;
		int t = 0;
		Queue<Integer> q = new LinkedList<Integer>();
		boolean end = false;
		while(!end){
			if(t==i*5&&i<100){
				q.add(i++);
			}
			for(int k=0;k<17;k++)c[k]=Math.max(0, c[k]-1);
			boolean con = true;
			while(!q.isEmpty()&&con){
				con = false;
				int id = q.peek();
				for(int j=0;j+p[id]-1<17;j++){
					boolean e = true;
					for(int k=0;k<p[id];k++){
						if(c[j+k]!=0){
							e = false;break;
						}
					}
					if(e){
						q.poll();
						for(int k=j;k<j+p[id];k++)c[k]=w[id];
						sit[id] = t;
						if(id==99)end = true;
						con = true;
						break;
					}
				}
			}
			t++;
		}
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.println(sit[n]-5*n);
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int N;
map<int, int> mp;
int cntover;

int main() {
  cin >> N;
  rep(i, 0, N) {
    int a;
    cin >> a;
    a /= 400;
    ++mp[a];
    if (a >= 8) {
      ++cntover;
    }
  }

  int ansmin = 0;
  for (auto e : mp) {
    if (e.first <= 7) {
      ++ansmin;
    }
  }

  if (ansmin == 0 && cntover) {
    ++ansmin;
    --cntover;
  }

  cout << ansmin << " " << ansmin + cntover;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin >> n;
  	int a[n] , b[n];
  	int sum = 0;
 	for(int i = 0 ; i < n ;i++)
      cin >>a[i];
  	for(int j = 0 ; j < n ; j++)
      cin >> b[j];
  	for(int i = 0 ; i < n ; i++){
		if(a[i] > b[i])
          sum += (a[i] - b[i]);
    }
  	cout << sum << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define float long double 
#define int long long
#define vl vector<int> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=998244353;

int i,j,k;
void solve(){
    string s; cin >> s; 
    if(s[3] == s[2] and s[4] == s[5]){
      cout << "Yes"<< endl;
    }
    else cout <<"No" << endl;

   return ; 
}
    signed main(){
   
    //CASET
    solve();
    
   
    return 0;
}


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

int n,h[100005],dp[100005],k;

int main(){
    scanf("%d%d",&n,&k);
    memset(dp,64,sizeof(dp));
    for(int i=0;i<n;++i)    scanf("%d",h+i);
    dp[0] = 0;
    for(int i=1;i<k;++i)
        dp[i] = max(h[i],h[0])-min(h[i],h[0]);
    for(int i=k;i<n;++i)
        for(int j=i-k;j<i;++j)
            dp[i] = min(dp[i],dp[j]+max(h[i],h[j])-min(h[i],h[j]));
    printf("%d",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
R = [int(input()) for _ in range(n)]

maxv = R[1] - R[0]
minv = R[0]
for i in range(1, n):
    value = R[i] - minv
    if value > maxv:
        maxv = value
    if R[i] < minv:
        minv = R[i]

print(maxv)



Measured memory_bytes: 13592
from itertools import permutations
n,m,r=map(int, input().split())
r_l=[int(i)-1 for i in input().split()]
town = [[float("INF")]*n for _ in range(n)]
for i in range(m):
    a,b,c=map(int, input().split())
    town[a-1][b-1]=c
    town[b-1][a-1]=c

for k in range(n):
    for i in range(n):
        for j in range(n):
            town[i][j] = min(town[i][j],town[i][k]+town[k][j])
res = float("INF")
for root in list(permutations(r_l)):
    tmp = 0
    for i in range(1,r):
        tmp += town[root[i]][root[i-1]]
    res = min(tmp,res)

print(res)


Measured memory_bytes: 80340
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll, ll>P;

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true, fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
#define ALL(x) (x).begin(),(x).end()

ll par[200010], Rank[200010];
void init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (Rank[x] < Rank[y])par[x] = y;
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}

map<P, ll>M;

int main() {
	ll n, k, l, p[200010], q[200010], r[200010], s[200010], road[2000010], train[200010];
	cin >> n >> k >> l;
	for (int i = 0;i < k;i++)cin >> p[i] >> q[i];
	for (int i = 0;i < l;i++)cin >> r[i] >> s[i];
	init(n);
	for (int i = 0;i < k;i++)unite(p[i] - 1, q[i] - 1);
	for (int i = 0;i < n;i++)road[i] = find(par[i]);
	init(n);
	for (int i = 0;i < l;i++)unite(r[i] - 1, s[i] - 1);
	for (int i = 0;i < n;i++)train[i] = find(par[i]);
	for (int i = 0;i < n;i++) {
		P a = P(road[i], train[i]);
		auto it = M.find(a);
		if (it != M.end())M[a]++;
		else M[a] = 1;
	}
	for (int i = 0;i < n;i++) {
		if (i != n - 1)cout << M[P(road[i], train[i])] << ' ';
		else cout << M[P(road[i], train[i])] << endl;
	}
}

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

int main() {
    int n, t;
    cin >> n >> t;
    pair<int, int> a[n];
    rep(i, n) cin >> a[i].first >> a[i].second;

    int ans = 1001;
    rep(i, n) {
        if (a[i].second <= t) ans = min(ans, a[i].first);
    }

    if (ans == 1001)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int cmp(const void *a, const void *b){return (*(ll*)a > *(ll*)b)?-1:1;}

ll n, m, a[100100], b[100100] = {}, ans = 0, sum = 0, num=0, numm = 0;

int main(){
    scanf("%lld%lld", &n, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    qsort(a, n, sizeof(ll), cmp);
    for(int i=1; i<=n; i++){
        b[i] = a[i-1] + b[i-1];
    }
    int lo=-1, hi=200200;
    while(hi-lo > 1){
        int mi = (hi+lo)/2;
        numm=0;sum=0;
        for(int i=0; i<n; i++){
            int l=-1, r=n;
            while(r-l > 1){
                int mid = (l+r)/2;
                if(a[mid]+a[i] < mi)r = mid;
                else l = mid;
            }
            numm += r;
            sum += b[r] + a[i]*r;
        }
        //printf("%lld %lld\n", numm, sum);
        if(numm <= m){
            hi = mi;
            ans = max(ans, sum);
            num = max(numm, num);
        }else lo = mi;
    }
    //printf("%lld, %d, %d, %lld\n", ans, hi, lo, num);
    ans += (m-num)*(lo);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1788
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    ai, bi = map(int, input().split())
    a[i] = ai
    b[i] = bi

a.sort(reverse=True)
b.sort(reverse=True)
b_select = []
for i in range(n):
    if b[i] < a[0]:
        break
    else:
        b_select.append(b[i])

if sum(b_select) >= h:
    for i in range(n):
        h -= b_select[i]
        if h <= 0:
            break
    counter = i + 1
else:
    h -= sum(b_select)
    counter = len(b_select)
    counter += (h + a[0] - 1) // a[0]

print(counter)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

string s[51];
int d[51][51];
int h, w;
bool flg = false;
typedef pair<int, int> P;

void bfs(int y, int x) {
  queue<P> que;
  P p;
  que.push(P(y, x));

  while (que.size()) {
    p = que.front(), que.pop();

    for (int i = 0; i < 4; i++) {
      int nx = p.second + dx[i], ny = p.first + dy[i];

      if (0 <= nx && nx < w && 0 <= ny && ny < h && s[ny][nx] != '#' &&
          d[ny][nx] == INF) {
        que.push(P(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
}

int main() {
  int cnt = 0;
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  rep(i, h) rep(j, w) if (s[i][j] == '#') cnt++;
  rep(i, h) rep(j, w) d[i][j] = INF;
  d[0][0] = 0;

  bfs(0, 0);
  int di = d[h - 1][w - 1];
  cout << (di == INF ? -1 : h * w - (di + 1 + cnt)) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a1,a2;
	cin>>a1>>a2;
	int sum=0;
	for(int y=0;y<a1.size();y++){
		if(a1[y]!=a2[y])
		sum++;
	}
	cout<<sum;
	return 0;
}

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

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

def ans(N, W):
    d = [0] * (W+1)

    for i in range(N):
        wi, vi = [int(i) for i in input().split()]
        for w in range(W, wi - 1, -1):
            v_ = d[w - wi] + vi
            if v_ > d[w]:
                d[w] = v_
    return d[W]

print(ans(N, W))


Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define X first
#define Y second
#define PB push_back
#define eps 1e-9
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0; i<(int)(n); ++i)

const int maxn = 1e4+7;

inline int read() {
    int ret=0,c,f=1;
    for(c=getchar(); !(isdigit(c)||c=='-'); c=getchar());
    if(c=='-') f=-1,c=getchar();
    for(; isdigit(c); c=getchar()) ret=ret*10+c-'0';
    if(f<0) ret=-ret;
    return ret;
}
int b[maxn];

int main() {
	
    ios_base::sync_with_stdio(0);
    cin.tie(0);    
    // #ifndef ONLINE_JUDGE
    // freopen("i.txt", "r", stdin);
    // freopen("o.txt", "w", stdout);
    // #endif

    int n,m;
    cin>>n>>m;
    multiset<ii> g;
    ll ans = 0;
    rep(i,n) {
      int a,b;
      cin>>a>>b;
      g.insert({a,b});
    }

    ll cur = 0;
    for(auto it=g.begin(); it != g.end(); ++it) {
      if(m == 0) break;
      ll cena = (it->first);
      ll kolvo = (it->second);
      if(m - kolvo >= 0) {
        m -= kolvo;
        cur += (cena * kolvo);
      } else {
        //smaller than needed
        cur += (m*cena);
        m = 0;
      }
    }
    cout<<cur;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MAXK 1010
#define MOD 1000000007
#define ll long long
#define F0R(a,b) for(int a=0; a<b; a++)
#define FOR(a,b,c) for(int a=b; a<c; a++)
vector<int> c, s, f;
int main()
{
	int n;
	cin >> n; c.resize(n); s.resize(n); f.resize(n);
	F0R(i,n-1)
	{
		cin >> c[i] >> s[i] >> f[i];
	}
	F0R(i,n-1)
	{
		int t = s[i]+c[i];
		FOR(j,i+1,n-1)
		{
			t = ( t%f[j]==0 ? t : f[j]*(t/f[j]+1) );
			t = max(t, s[j]);
			t += c[j];
		}
		cout<<t<<endl;
	}
	cout<<0<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long tk = 1;
		long ao = 1;
		for (int i = 0; i < n; i++) {
			long t = sc.nextLong();
			long a = sc.nextLong();
			
			long tn = tk / t + (tk % t == 0 ? 0 : 1);
			long an = ao / a + (ao % a == 0 ? 0 : 1);
			
			long num = Math.max(tn, an);
			
			tk = t * num;
			ao = a * num;
		}
		
		System.out.println(tk + ao);
		
		sc.close();
	}
}




Measured memory_bytes: 30872