akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline


def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    diff = []
    for i in range(N-1):
        diff.append(A[i+1] - A[i])
    diff.append(A[0]+K-A[N-1])
    print(sum(diff)-max(diff))


if __name__ == '__main__':
    main()


Measured memory_bytes: 25876
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public boolean isEven(Integer number) {
		if (number % 2 == 0)
			return true;
		else
			return false;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Main product = new Main();
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					System.in));
			String inputLine = reader.readLine();
			String numbers[] = inputLine.split(" ");
			System.out.println(product.isEven(Integer.valueOf(numbers[0])
					* Integer.valueOf(numbers[1])) ? "Even" : "Odd");
		} catch (IOException ignore) {
		}
	}
}


Measured memory_bytes: 18900
#include <iostream>

using namespace std;

int f(int n) {
    int result = 0;
    for (int i = 1; i <= n; i++) {
        result += i;
    }
    return result;
}

int main() {

    int n;
    cin >> n;

    int result = f(n);
    cout << result << endl;

    return 0;
}


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

int main() {
  int n;long long ans = 0;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  ans += data.at(0)+data.at(n-2);
  for(int i = n-3;i >= 0;i--){
    if(data.at(i) <= data.at(i+1)){
      ans += data.at(i);
    }
    else{
      ans += data.at(i+1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;



int main(){
	
	string s;
	cin>>s;
	
	int n, res = 0;
	cin>>n;
	
	for(int i=0; i<n; ++i){
		
		string t;
		cin>>t;
		
		t += t.substr(0, s.size()-1);
		
		for(int j=0; j<t.size(); ++j){
			
			string sub = t.substr(j, s.size());
			
			if(sub==s){
				res++;
				break;
			}
		}
		
	}
	
	cout << res << endl;
	
	return 0;	
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

const int MAXN = 123456;
const long long oo = 1e18;
long long DP[123][MAXN];
long long Sum[123][MAXN];
const long long MOD = 1e9 + 7;

void solve() {
    int n, k; cin >> n >> k;
    int arr[n + 1];
    arr[0] = 0;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    for (int i = 0; i <= n; i++) DP[i][0] = Sum[i][0] = 1;
    for (int j = 0; j <= k; j++) Sum[0][j] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
//            for (int t = 0; t <= arr[i]; t++) {
//                if (j >= t) DP[i][j] += DP[i - 1][j - t];
//                else break;
//            }
            DP[i][j]  = Sum[i - 1][j];
            if (j > arr[i]) DP[i][j] -= Sum[i - 1][j - arr[i] - 1];
            DP[i][j] += MOD;
            DP[i][j] %= MOD;
            Sum[i][j] = Sum[i][j - 1] + DP[i][j];
            Sum[i][j] %= MOD;
        }
    }
//    for (int i = 0; i <= n; i++) {
//        for (int j = 0; j <= k; j++) cout << DP[i][j] << " ";
//        cout << endl;
//    }
    cout << DP[n][k];
}

int main()
{
   // rwFile();
    solve();
}


Measured memory_bytes: 198528
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()




int main() {
	ll N, K;
	cin >> N >> K;
	vll h(N);
	rep(i, N) cin >> h[i];
	sort(all(h));

	vll ans(N, INF);
	fori(i, K - 1, N) ans[i] = h[i] - h[i - K + 1];
	cout << *min_element(all(ans)) << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)


//ABC091_b
int main() {
	int N;
	cin >> N;
	set<string> ss;
	vector<string> A(110);
	vector<string> B(110);

	rep(i, N) {
		string s;
		cin >> s;
		ss.insert(s);
		A.at(i) = s;
	}

	int M;
	cin >> M;
	rep(i, M) {
		string s;
		cin >> s;
		ss.insert(s);
		B.at(i) = s;
	}

	int ans = 0;
	for(auto str : ss) {
		int sum = 0;
		rep(i, N) {
			if (str == A.at(i)) {
				sum +=1;
			}
		}
		rep(i, M) {
			if (str == B.at(i)) {
				sum -=1;
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int a, b;
    cin >> a >> b;
    if (a * b % 2 != 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

array = []
for _ in range(H):
    array.append(list(input()))

possible = True
prev_min_hash = W

for h in range(H-1, -1, -1):
    max_hash = 0
    for w in range(W):
        if array[h][w] == "#":
            max_hash = w

    if max_hash > prev_min_hash:
        possible = False
        break

    for w in range(W-1, -1, -1):
        if array[h][w] == "#":
            prev_min_hash = w

if possible:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3188
MOD = 10 ** 9 + 7
ans = 1

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

if n == k:
    for x in a:
        ans *= x
        ans %= MOD
    print(ans % MOD)
    exit()

pos = []
neg = []

for x in a:
    if x >= 0:
        pos.append(x)
    else:
        neg.append(x)

pos.sort(reverse=True)
neg.sort()

if len(pos) == 0 and k % 2:
    for i in range(1, k+1):
        ans *= neg[-i]
        ans %= MOD
    print(ans % MOD)
    exit()

if k % 2:
    ans *= pos.pop(0)
    k -= 1


l = []

for i in range(1, len(pos), 2):
    l.append(pos[i] * pos[i - 1])

for i in range(1, len(neg), 2):
    l.append(neg[i] * neg[i - 1])

l.sort(reverse=True)

for i in range(k // 2):
    ans *= l[i]
    ans %= MOD

print(ans % MOD)


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

int main(){
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if( abs( b-a ) > abs( c-a ) ){
    
    cout << 'B' << endl;
    
  }
  
  else{
    
    cout << 'A' << endl;
    
  }
  
}


Measured memory_bytes: 3632
#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<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

ll f(ll A){
    ll base, r;
    vll res;
    
    r = (A/2) % 2;
    res.push_back(r);
    base = 4;
    while(base/2 < A){
        r = A % base;
        r = max(0LL, r - base/2);
        res.push_back(r%2);
        base *= 2;
    }
    ll ans=0;
    base = 1;
    rep(i, res.size()){
        ans += base * res[i];
        base *= 2;
    }
    return ans;
}

void solve(long long A, long long B){
    ll x, y;
    x = f(B+1);
    y = f(A);
    cout << (x^y) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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


int main(int argc, char const *argv[]) {
    std::string s, output;
    std::cin >> s;
    output = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0') {
            output += "0";
        } if (s[i] == '1') {
            output += "1";
        } if (s[i] == 'B') {
            if (output.length() > 0) {
                output = output.erase(output.length()-1);
            }
        }
        // std::cout << s[i] << " " << output << std::endl;
    }
    std::cout << output << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  scanf("%d", &n);
  multiset<int> d;
  rep (i, n) {
    int di;
    scanf("%d", &di);
    d.insert(di);
  }
  int m;
  scanf("%d", &m);
  vi t(m);
  rep (i, m) {
    scanf("%d", &t[i]);
  }
  rep (i, m) {
    auto p = d.find(t[i]);
    if (p == end(d)) {
      puts("NO");
      return 0;
    }
    d.erase(p);
  }

  puts("YES");

  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define dfor(i,a,b) for(int i=(a);i<(b);++i)
#define drfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define drep(i,n) dfor(i,0,n)
#define drrep(i,n) drfor (i,n,0)
#define dump(x)  cout << #x << " = " << (x) << endl;

const double EPS = 1e-10;
const double PI = acos(-1.0);

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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

	int i;
	string s;
	cin >> s;
	for (i = 0; i < s.length();i++) {
		if (s[i] == 'C') break;
	}
	if (i == s.length()) {
		cout << "No";
		return 0;
	}
	for (; i < s.length();i++) {
		if (s[i] == 'F') break;
	}	
	if (i == s.length()) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}


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

#define LINE_BUF_SIZE  1024

int main(void) {
    static char line[LINE_BUF_SIZE];

    int n;
    int i;
    scanf("%d", &n);
    int a[n];
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }

    int c = 0;
    int now = 0;

    for (;;) {
        if (c >= n) {
            printf("%d\n", -1);
            break;
        } else if (now == 1) {
            printf("%d\n", c);
            break;
        }
        c++;
        now = a[now]-1;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,S=0,T=0,mod=1000000007,A,ans;cin>>N;
  REP(i,N){cin>>A;S+=A;S%=mod;T+=A*A%mod;T%=mod;}
  ans=S*S%mod-T;if(ans%2!=0)ans+=mod;ans/=2;ans%=mod;if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  ll min1 = 10000000000;
  ll max1 = -1000000000;
  ll min2 = 10000000000;
  ll max2 = -1000000000;
  rep(i, n){
    ll x, y;
    cin >> x >> y;
    min1 = min(min1, x+y);
    max1 = max(max1, x+y);
    min2 = min(min2, -1*x+y);
    max2 = max(max2, -1*x+y);
  }
  ll ans = max(max1-min1, max2-min2);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define v  vector<int>
#define pb  push_back

int gcd(int a, int b)
{ return (b==0 ? a: gcd(b,a%b));}
string s;
int a=0;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='+')
            ++a;
        else
            --a;
    }
    cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[300005];
char s[300005];
int main()
{
    int n,i,f,j,ans,p;p=f=ans=0;
    memset(a,-1,sizeof(a));
    scanf("%d",&n);
    scanf("%s",s);
    for(i=1;i<n;i++)
        {
            if(s[i]=='E')
             {f+=1;
              a[i]=0;
             }
             else
                a[i]=1;
        }ans=f;
      for(i=1;i<n;i++)
      {
          if(s[i]=='E'&&s[i-1]=='E')
          {
               f=f-1;
          }

          else if(s[i]=='W'&&s[i-1]=='W')
            {
                f=f+1;
            }
            if(f<ans)
            {
                ans=f;
            }
      }
      printf("%d",ans);
      return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        double h = 30 * (H + M/60.0);
        double m = M * 6.0;
        double k = Math.abs(m - h);
        double cos = Math.cos(Math.toRadians(k));
        double a = A*A + B*B - (2*A*B*cos);
        System.out.println(Math.sqrt(a));
    }

}

Measured memory_bytes: 35960
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll x, y, A, B, C;
  cin >> x >> y >> A >> B >> C;
  ll a[A], b[B], c[C];
  fi(0, A)
    cin >> a[i];
  fi(0, B)
    cin >> b[i];
  fi(0, C)
    cin >> c[i];

  sort(a, a + A, greater<ll>());
  sort(b, b + B, greater<ll>());
  sort(c, c + C, greater<ll>());
  
  int i = x - 1;
  int j = y - 1;
  int k = 0;
  while(1) {
    if(i == -1 && j == -1)
      break;
    if(k == C)
      break;
    if(i >= 0 && j >= 0 && c[k] <= min(a[i], b[j]))
      break;
    if(i == -1 && c[k] <= b[j])
      break;
    if(j == -1 && c[k] <= a[i])
      break;
    if(a[i] <= b[j] || j == -1) {
      a[i--] = c[k++];
    }
    else if(b[j] <= a[i] || i == -1) {
      b[j--] = c[k++];
    }
  }

  fi(0, x)
    ans += a[i];
  fi(0, y)
    ans += b[i];
  cout << ans << endl;
  return 0;
}



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

const int MAXN = 101, MAXW = 100010;
struct Item {
	int weight;
	long long value;
}item[MAXN];
long long dp[MAXW];
int main() {
	int n, W;
	cin>>n>>W;
	for (int i=0; i<n; i++)
		cin>>item[i].weight>>item[i].value;
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (int i=0; i<n; i++)
		for (int j=W-item[i].weight; j>=0; j--)
			if (dp[j])
				dp[j + item[i].weight] = max(dp[j + item[i].weight], dp[j] + item[i].value);

	long long ans=0;
	for (int i=W; i>=0; i--)
		ans = max(ans, dp[i]);
	cout<<ans-1<<endl;
	return 0;
}


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

const int INF=1e9+7;
struct SegmentTree{
    private:
        int n;
        vector<int> node;
    public:
        SegmentTree(vector<ll> v){
                int sz = v.size();
                n=1;while(n<sz) n*=2;
                node.resize(2*n-1, 0);

                rep(i,sz){
                    node[i+n-1] = v[i];
                }
                for(int i=n-2;i>=0;i--){
                    node[i]=node[2*i+1]|node[2*i+2];
                }
        }

        void update(int x,int val){
                x+=n-1;
                node[x]=val;
                while(x>0){
                    x=(x-1)/2;
                    node[x]=node[x*2+1]|node[x*2+2];
                }
        }

        ll getmin(int a,int b,int k=0,int l=0, int r=-1){
            if(r<0) r=n;
            if(r<=a||b<=l) return 0;
            if(a<=l&&r<=b) return node[k];

            ll vl=getmin(a,b,2*k+1,l,(l+r)/2);
            ll vr=getmin(a,b,2*k+2,(l+r)/2,r);
            return vl|vr;
        }

};

int main(){
    int n,q;
    string s;
    cin>>n>>s>>q;
    vector<ll> v(n,0);
    rep(i,n){
        v[i]=1<<(s[i]-'a');
    }
    SegmentTree tree(v);
    vector<ll> ans;
    rep(i,q){
        int tp;cin>>tp;
        if(tp==1){
            int l;string c;
            cin>>l>>c;
            int val=1<<(c[0]-'a');
            tree.update(l-1,val);
        }else{
            int a,b;
            cin>>a>>b;
            ll tans=0;
            tans=tree.getmin(a-1,b);
            ans.emplace_back(__builtin_popcount(tans));
        }
    }
    for(auto k:ans){
        cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 12804
N,M = map(int,input().split())
H = list(map(int,input().split()))

d = []
for i in range(M):
    A,B = map(int,input().split())
    d.append((A-1,B-1))

cnt = 0
res = {}
for i in range(N):
    res[i] = False
flag = {}
for i in range(N):
    flag[i] = True

for i in d:
    A = i[0]
    B = i[1]
    #print("H[A] > H[B]",H[A],H[B])
    if H[A] > H[B] and flag[A] == True:
        res[A] = True
    else:
        flag[A] = False
        res[A] = False
    #print("H[A] < H[B]",H[A],H[B])
    if H[B] > H[A] and flag[B] == True:
        res[B] = True
    else:
        flag[B] = False
        res[B] = False
print(list(flag.values()).count(True))

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

int main() {
  int N;
  int K;
  vector <int> magassag;
  cin >> N;
  cin >> K;
  int seged;
  for(int i=0;i<N;i++){
    cin >> seged;
     magassag.push_back(seged);
  }
  seged=0;
  for(int j=0;j<N;j++){
    if(magassag[j]>=K){
      seged+=1;
    }
  }
  cout << seged;
	return 0;
}


Measured memory_bytes: 3864
#include<iostream>
using namespace std;
int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
       int n;
       cin >> n;
       int h=0, oldh=0, maxh=0, nowh=0;
       for (int i=0; i<n;i++){
           cin >> h;
           if(h<=oldh){
               nowh++;
               if(maxh<nowh){
                   maxh=nowh;
               }
           }else{
               nowh=0;
           }
           oldh=h;
       }
    cout << maxh;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b;
    cin >> a >> b;
    int ctr=0;
    repi(i,a,b+1){
        if((i-i/10000)%10==0&&((i/10)-(i/1000))%10==0)
        ctr++;
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int ans = INF;
  repp(x, -100, 100) {
    int temp = 0;
    rep(i, N) {
      temp += pow(a[i] - x, 2);
    }
    chmin(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
S=list(input())

for a0,a1 in [[1,1],[1,-1],[-1,1],[-1,-1]]:
  ans=[0]*N
  ans[0],ans[1]=a0,a1
  for i in range(2,N):
    if S[i-1]=="o":
      ans[i]=ans[i-2]*ans[i-1]
    else:
      ans[i]=-ans[i-2]*ans[i-1]

  if S[N-1]=="o":
    if ans[0]==ans[N-2]*ans[N-1]:
      if S[0]=="o":
        if ans[1]==ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
      else:
        if ans[1]==-ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
  else:
    if ans[0]==-ans[N-2]*ans[N-1]:
      if S[0]=="o":
        if ans[1]==ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
      else:
        if ans[1]==-ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()

print(-1)

Measured memory_bytes: 6280
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}








Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int k, a, b, f;
	cin >> k >> a >> b;
	f = 0;
	for(int i = a; f == 0 && i <= b; i++){
		if(i % k == 0 ) f = 1;
	}
	if(f == 1) cout << "OK";
	else cout << "NG";
	return 0;
}


Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author jignesh1604
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define debugg(x) out << #x << " is " << x << "\n" ;
#define gcd(a , b) __gcd(a,b) ;
#define lssetbitindex(x) __builtin_ffs(x)-1 ;           // __builtin_ffs(x) = 1 + least significant 1-bit of x

using namespace std;

class CMaximumVolume {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long double a , b , c , l ;
	    in >> l ;
	    out <<fixed << setprecision(12) << (long double)((long double)(l/(long double)3)*(long double)(l/(long double)3)*(long double)(l/(long double)3)) << "\n" ;

	}
};


int main() {
	CMaximumVolume solver;
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define mod 1000000007
using namespace std;
int solve(){
	int n,k;
	cin>>n>>k;
	int pos=0;
	vector<pair<long long int,int> > vec;
	for(int i=0;i<n;i++){
		long long int a;
		cin>>a;
		if(a>0)pos=1;
		if(a<0)vec.push_back(make_pair(-a,1));
		else vec.push_back(make_pair(a,0));
	}
	if(k==n){
		long long int ans=1;
		int cnt=0;
		for(int i=0;i<n;i++){
			ans*=vec[i].first;
			ans%=mod;
			if(vec[i].second==1)cnt++;
		}
		if(cnt%2!=0)ans=mod-ans;
		ans%=mod;
		cout<<ans<<endl;
	}
	else if(pos==0&&k%2){
		sort(vec.begin(),vec.end());
		long long int ans=1;
		for(int i=0;i<k;i++){
			ans*=vec[i].first;
			ans%=mod;
		}
		ans=mod-ans;
		ans%=mod;
		cout<<ans<<endl;
	}
	else{
		sort(vec.begin(),vec.end());
		reverse(vec.begin(),vec.end());
		int take[n]={0};
		int lstp=-1,lstn=-1,flag=0;
		long long int ans=1;
		for(int i=0;i<k;i++){
			take[i]=1;
			if(vec[i].second==1&&flag==0){
				flag=1;lstn=i;
			}
			else if(vec[i].second==1){
				flag=0;
				lstn=-1;
			}
			else if(vec[i].second==0)lstp=i;
		}
		if(flag==1){
			if(lstn!=-1&&lstp!=-1){
				int i=k,j=k;
				while(i<n&&vec[i].second!=0)i++;
				while(j<n&&vec[j].second!=1)j++;
				if(i==n){
					take[lstp]=0;
					take[j]=1;
				}
				else if(j==n){
					take[lstn]=0;
					take[i]=1;
				}
				else{
					long long int p=vec[i].first*vec[lstp].first;
					long long int q=vec[j].first*vec[lstn].first;
					if(p>q){
						take[lstn]=0;
						take[i]=1;
					}
					else{
						take[lstp]=0;
						take[j]=1;
					}
				}
			}
			else if(lstp==-1){
				int i=k;
				while(vec[i].second==1)i++;
				take[lstn]=0;
				take[i]=1;
			}
		}
		for(int i=0;i<n;i++){
			if(take[i]==1){
				ans*=vec[i].first;
				ans%=mod;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
} 
int main(){
	int t=1;
//	cin>>t;
	while(t--)solve();
}

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

int main() {
  int n;
  cin >> n;
  if(n>999) cout <<"ABD" << endl;
  else cout <<"ABC" << endl;
  return 0;
}


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

int main() {
    ll N,K;
    cin >> N >> K;
    ll res = min(N%K,K-N%K);
    cout << res;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long dis(long long a, long b){
	return abs(a - b);
}
long long solve(long long p, vector<long long>&a){
	auto mayor = upper_bound(a.begin(), a.end(), p);
	auto menor = lower_bound(a.begin(), a.end(), p);
	long long ans = LLONG_MAX;
	if(mayor != a.end()) ans = min(ans, dis(p, *mayor));
	if(menor != a.begin()){
		menor--;
		ans = min(ans, dis(p, *menor));
	}
	return ans;
}
int main(){
	int n, m, q;
	long long x;
	cin >> n >> m >> q;
	vector<long long> a(n), b(m);
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < m; ++i) cin >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	while(q--){
		cin >> x;
		auto ya = upper_bound(a.begin(), a.end(), x);
		auto yb = upper_bound(b.begin(), b.end(), x);
		if(ya == a.end()) ya--;
		if(yb == b.end()) yb--;
		
		auto ma = lower_bound(a.begin(), a.end(), x);
		auto mb = lower_bound(b.begin(), b.end(), x);
		
		if(ma == a.end() or *ma > x and ma != a.begin() ) ma--;
		if(mb == b.end() or *mb > x and mb != b.begin()) mb--;
		
		long long menor_a = *ma;
		long long menor_b = *mb;
		long long mayor_a = *ya;
		long long mayor_b = *yb;
		long long ans = LLONG_MAX, aux;
		
		if(mayor_b >= x){ 
			aux =  solve(mayor_b, a);
			if(aux != LLONG_MAX) 
			ans = min(ans, dis(mayor_b, x) + aux);
		}
		if(mayor_a >= x){ 
			aux =  solve(mayor_a, b);
			if(aux != LLONG_MAX) 
			ans = min(ans, dis(mayor_a, x) + aux);
		}
		if(menor_b <= x){ 
			aux =  solve(menor_b, a);
			if(aux != LLONG_MAX) 
			ans = min(ans, dis(menor_b, x) + aux);
		}
		if(menor_a <= x){ 
			aux =  solve(menor_a, b);
			if(aux != LLONG_MAX) 
			ans = min(ans, dis(menor_a, x) + aux);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
// ソートすると、自分より小さいやつだけが対象となる
// 自分iを割り切るjがいたとき、jはiの約数のどれかである
// エラトステネス的に考えると、min(A)~max(A)までのすべてをA[i]の倍数で埋めていく感じになる？
// 1を含む場合・同じのを複数含む場合みたいな探索上しんどそうなやつは省く（ほかなんかある？）
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N := nextInt()
	preA := nextInts(N)
	Distinct := make(map[int]bool)
	A := []int{}
	T := make([]bool, int(1e6+100)) // なんか知らんがRE出たのでたぶんこれが怪しいと踏んで余分に増やした
	sort.Ints(A)
	for _, a := range preA {
		if !Distinct[a] {
			Distinct[a] = true
			A = append(A, a)
		} else {
			// 同じのがあったらそれは駄目
			T[a] = true
		}
	}
	if A[0] == 1 {
		if N == 1 {
			fmt.Println(1)
			return
		} else {
			// は？？？？？？？？？？？？？？？？？？？？？？？？？？
			fmt.Println(0)
			return
		}
	}
	for _, a := range A {
		for x := a * 2; x <= int(1e6+10); x += a {
			T[x] = true
		}
	}
	ans := 0
	for _, a := range A {
		if T[a] == false {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


Measured memory_bytes: 17340
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
ll A[50];

int main() {
    fastio();
    cin >> N;
    REP(i, N) cin >> A[i];
    ll ans = 0, tmp, prev = 0, res, M = N + 1;
    while (1) {
        tmp = 0;
        REP(i, N) {
           A[i] += prev;
           if(A[i] < N) continue;
           res = A[i] / N;
           A[i] -= res * M;
           tmp += res;
        }
        if(tmp < 1) break;
        ans += tmp;
        prev = tmp;
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

while True:
    a, l = map(int, input().split())
    if a == 0 and l == 0: break

    d, i = {}, 0
    while True:
        if d.get(a) != None:
            print(d[a], a, i-d[a])
            break
        d[a] = i; i += 1
        s = str(a)
        s = "0"*(l-len(s)) + s

        big = int( "".join( sorted(s, reverse=True) ) )
        little = int( "".join( sorted(s) ) )

        a = big-little


Measured memory_bytes: 5600
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
vector<int>adj[200001];
bool v[200001];
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    ll a[n];
     map<ll,ll>mp;
    for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;}
    sort(a,a+n);
    ll g=0;
    for(int i=0;i<=n-1;i++)
    {
        g=gcd(g,a[i]);
    }
    if(g>1){
    cout<<"not coprime";
    exit(0);}
    if(g==1)
    {
        for(int i=0;i<n;i++)
        {
            if(mp[a[i]]>1&&a[i]>1){
            cout<<"setwise coprime";
            exit(0);}
        }
    }
    set<int>p;
    for(int i=0;i<n;i++)
    {
        set<int>s;
        ll x=a[i];
        while(x%2==0)
        {
            s.insert(2);
            x=x/2;
        }
        for(int i=3;i<=sqrt(x);i=i+2)
        {
            while(x%i==0)
            {
                x=x/i;
                s.insert(i);
            }
        }
        if(x>2)
        s.insert(x);
        for(auto it=s.begin();it!=s.end();it++)
        {
            
            ll y=*it;
            if(p.find(y)==p.end())
            p.insert(y);
            else
            {
                cout<<"setwise coprime";
                exit(0);
            }
        }}
        cout<<"pairwise coprime";}
        
        
    

Measured memory_bytes: 78512
#include <iostream>
int main(){
    int x;
    std::cin >> x;
    if(x%7==1){
        std::cout << "fri" << std::endl;
    }
    if(x%7==2){
        std::cout << "sat" << std::endl;
    }
    if(x%7==3){
        std::cout << "sun" << std::endl;
    }
    if(x%7==4){
        std::cout << "mon" << std::endl;
    }
    if(x%7==5){
        std::cout << "tue" << std::endl;
    }
    if(x%7==6){
        std::cout << "wed" << std::endl;
    }
    if(x%7==0){
        std::cout << "thu" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3064
a,b,q=map(int,input().split())
import bisect
inf=10**18
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)]
s=[-inf]+s+[inf]
t=[-inf]+t+[inf]
for q in x:
    c,d=bisect.bisect_left(s,q),bisect.bisect_left(t,q)
    ans=float("inf")
    for i in [c,c-1]:
        for j in [d,d-1]:
            ans=min(ans,abs(s[i]-t[j])+abs(q-s[i]),abs(s[i]-t[j])+abs(q-t[j]))
    print(ans)
    

Measured memory_bytes: 17760
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> menu(5);
  int Ma=0;
  int m=0;
  for(int i=0;i<5;i++){
   cin>>menu.at(i);
    if(menu.at(i)%10!=0&&menu.at(i)%10<menu.at(Ma)%10)
      Ma=i;
  }
  for(int i=0;i<5;i++){
    if(i!=Ma){
     if(menu.at(i)%10!=0){
      m+=menu.at(i)+(10-menu.at(i)%10); 
     }else{
       m+=menu.at(i);
     }
    }
  }
  m+=menu.at(Ma);
  cout<<m<<endl;
}

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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template configure" from the list 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const int bill = 1000;
    int n, result;
    cin >> n;
    result = (bill - n % bill) % bill;
    cout << result;
    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));
  cout << (s < t ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String t = sc.next();
		sc.close();
		if(a.equals(t)) {
			prtln(0);
			return;
		}
		char[] ac = a.toCharArray();
		char[] tc = t.toCharArray();
		int answer = 0;
		for(int i = 0; i < ac.length; i++) {
			if(ac[i] != tc[i]) answer++;
		}
		prtln(answer);
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<LL> v(N + 1);
    v[0] = INF;
    for(int i = 1; i <= N; ++i) {
        cin >> v[i];
    }
    sort(all(v), greater<LL>());

    LL res = 0;
    for(int i = 2; i <= N; ++i) {
        res += v[(i + 1) / 2];
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 4776
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];  // A
			int b = vs[1];  // B
			int c = vs[2];  // AB
			int x = vs[3];
			int y = vs[4];

			int ans = 0;
			int i = Math.Min(x, y);
			ans += a + b < c * 2 ? (a + b) * i : c * 2 * i;
			x -= i;
			y -= i;
			ans += a < c * 2 ? a * x : c * 2 * x;
			ans += b < c * 2 ? b * y : c * 2 * y;
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 28120
A=[0]*2019
s=input()
a=0
b=1
for i in range(len(s)):
    b=b%2019
    a=(a+int(s[len(s)-1-i])*b)%2019
    b=b*10
    A[a]+=1
x=A[0]
for j in range(2019):
    x+=int(A[j]*(A[j]-1)/2)
print(x)    


Measured memory_bytes: 81408
#include<iostream>
#include <string>
#include<vector>
using namespace std;

int main() {
	int A[81], k = 0, N;
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			A[k] = i * j;
			k++;
		}
	}
	int ans = 0;
	for (int i = 0; i < 81; i++) {
		if (N == A[i]) {
			ans = 1;
		}
	}
	if (ans == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

		return 0;
	}






Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    long int N,K,Q;
    long int point[1000001]={0};
    
    scanf("%ld %ld %ld\n",&N,&K,&Q);
    
    long int i,tmp;
    
    for(i=1;Q>=i;i++){
        scanf("%ld",&tmp);
        point[tmp]++;
        
    }
    
    for(i=1;N>=i;i++){
        //printf("%ld:",point[i]);
        if(point[i]+K>Q) printf("Yes\n");
        else             printf("No\n");
        
    }
    
    return 0;
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

int f(ll x)
{
  int ret = 0;
  while(x){
    x /= 10;
    ret++;
  }
  return ret;
}

int main()
{
  ll n;
  cin >> n;

  int ans = 1e+9;
  for(ll i = 1; i*i <= n; i++){
    if(n % i == 0){
      ans = min(ans, max(f(i), f(n/i)));  
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int64_t s[n]; rep(i,n) cin>>s[i];
    int64_t ans=0;
    for(int c=1;c<n;c++){
        int64_t sum=0;
        set<int> used;
        for(int k=0;k*c<n;k++){
            int a=(n-1)-k*c;
            if(a<=0) continue;
            int b=a-c;
            if(a<=b) continue;
            if(k>0 and b<=0) continue;
            if(used.find(k*c)!=used.end()) break;
            used.insert(k*c);
            sum+=s[k*c];
            if(used.find((n-1)-k*c)!=used.end()) break;
            used.insert((n-1)-k*c);
            sum+=s[(n-1)-k*c];
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}

// 愚直
// for(int a=1;a<n;a++){
//     for(int b=1;b<a;b++){
//         // cerr<<a<<" "<<b<<endl;
//         int sum=0;
//         set<int> used; used.insert(0);
//         int now=0;
//         bool end=1;
//         while(1){
//             now+=a;
//             if(now>=n){
//                 end=0;
//                 break;
//             }
//             if(used.find(now)!=used.end()){
//                 end=0;
//                 break;
//             }
//             used.insert(now);
//             sum+=s[now];
//             if(now==n-1) break;
//             now-=b;
//             if(now<0){
//                 end=0;
//                 break;
//             }
//             if(used.find(now)!=used.end()){
//                 end=0;
//                 break;
//             }
//             used.insert(now);
//             sum+=s[now];
//         }
//         if(end) cerr<<a<<" "<<b<<" "<<sum<<endl;
//     }
// }


Measured memory_bytes: 5760
type Range = (Int, Int)

main:: IO ()
main = do
    [n,a,b,c,d] <- (map read . words) <$> getLine
    putStrLn $ if solve (n-1) (b-a) (c,d) then "YES" else "NO"

-- |
--
-- >>> solve 4 4 (2,4)
-- True
--
-- >>> solve 3 (-1) (4,5)
-- False
--
-- >>> solve 48791 (681218449-105960835) (90629745,90632170)
-- False
--
-- >>> solve 3 (0) (0,0)
-- True
solve :: Int -> Int -> (Int, Int) -> Bool
solve n' k (c,d) = any f [n'*d, n'*d-(c+d) .. 0]
  where
    k' = abs k
    f x = x-(d-c)*n' <= k' && k' <= x

ok :: Int -> Range -> Bool
x `ok` (xmin, xmax)
  | x > 0     = xmin <= x && x <= xmax
  | otherwise = (-xmax) <= x && x <= (-xmin)


Measured memory_bytes: 1020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        
        A -= K;
        if(A < 0){
            B += A;
            A = 0;
            if(B < 0){
                B = 0;
            }
        }
        
        System.out.println(A + " " + B);
    }
}

Measured memory_bytes: 21844