akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    string s, t;
    scan(s);
    scan(t);

    auto vs = new int[][](26, 0);
    auto vt = new int[][](26, 0);

    foreach (int i, ch ; s) {
        vs[ch - 'a'] ~= i;
    }

    foreach (int i, ch ; t) {
        vt[ch - 'a'] ~= i;
    }

    vs.sort();
    vt.sort();

    writeln(vs == vt ? "Yes" : "No");
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4664
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 100000
//---------------------

ll n,k;

int main(){
	cin>>n>>k;
	if(k==1) {cout<<0<<endl;return 0;} 
	cout<< ((n-k+1)-1) <<endl;
	return 0;
}

Measured memory_bytes: 256
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

int main(int argc, char const *argv[]) {
    int n, k; cin >> n >> k;

    int x = n / k; 
    int y = n / k + (n % k >= k / 2);

    if(k & 1) cout << (ll) x * x * x << endl;
    else cout << (ll) x * x * x + (ll) y * y * y << endl;
}

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

n = int(input())
a = [int(item) for item in input().split()]
cumsum = [0] * (n + 1)
total_len = sum(a)
for i in range(n):
    cumsum[i+1] = cumsum[i] + a[i]

ans = 10**15 
for i in range(n+1):
    ans = min(ans, abs(cumsum[i] - (cumsum[n] - cumsum[i])))

print(ans)

Measured memory_bytes: 81232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  auto f = [&](int a) {
    rep(i, n) {
      rep(j, n) {
        if (s[(i+a)%n][j] != s[(j+a)%n][i]) {
          return false;
        }
      }
    }
    return true;
  };

  int ans = 0;
  rep(a, n) {
    if (f(a)) ans += n;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T=1;
	//cin >> T;
	ll t=0;
	while(t++<T){
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll w=0;
		fo(i,n)if(s[i]=='W')w++;
		ll cnt=0;
		for(ll i=0;i<n-w;i++)if(s[i]=='W')cnt++;
		cout<<cnt<<endl;

	}
return 0;
}


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

int main(){
  int N;
  char S[4000];
  long long int count = 0;
  long long int r, g, b;
  r = 0; g = 0; b = 0;
  long long int set, ans;

  cin >> N;
  cin >> S;

  for (int i = 0; i < N; i++){
    if (S[i] == 'R'){
      r++;
    }
  }

  for (int i = 0; i < N; i++){
    if (S[i] == 'G'){
      g++;
    }
  }

  for (int i = 0; i < N; i++){
    if (S[i] == 'B'){
      b++;
    }
  }

  set = r * g * b;

  for (int i = 0; i < N - 1; i++){
    for (int j = i + 1; j < N; j++){
      long long int k = j * 2 - i;
      if ((S[i] != S[j]) && (S[i] != S[k]) && (S[j] != S[k]) && k < N){
        count++;
      }
    }
  }

  ans = set - count;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,k,n,m,c,cnt,t,mn=1000000000;
    string s,p;
    cin>>s;
    n=s.length();
    for(i=0;i<n-2;i++)
    {

        c=0;
        c+=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        k=abs(753-c);
        mn=min(mn,k); 
    }
    cout<<mn<<endl;




    return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp

#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int>P;

class MCF{
public:
	class edge{
	public:
		int to, cap, cost, rev;
		edge(){};
		edge(int _to, int _cap, int _cost, int _rev){
			to = _to;
			cap = _cap;
			cost = _cost;
			rev = _rev;
		}
	};

	vector<vector<edge> >G;
	vector<int>h;
	vector<int>dist;
	vector<int>prevv;
	vector<int>preve;
	MCF(int n){
		G.resize(n);
		preve.resize(n, 0);
		prevv.resize(n, 0);
	}
	void addEdge(int from, int to, int cap, int cost){
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}
	int flow(int s, int t, int f){
		int res = 0;
		h.clear();
		h.resize(G.size(), 0);
		while (f > 0){
			priority_queue<P, vector<P>, greater<P> >que;
			dist.clear();
			dist.resize(G.size(), 1145141919);
			dist[s] = 0;
			que.push(P(0, s));
			while (!que.empty()){
				P p = que.top();
				que.pop();
				int v = p.second;
				if (dist[v] < p.first)continue;
				for (int i = 0; i < G[v].size(); i++){
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(P(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == 1145141919){
				return -1;
			}
			for (int v = 0; v < G.size(); v++)h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]){
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d*h[t];
			for (int v = t; v != s; v = prevv[v]){
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main(){

	int V, E, F;
	cin >> V >> E >> F;
	MCF mcf(V);
	for (int i = 0; i < E; i++){
		int from, to, cap, cost;
		cin >> from >> to >> cap >> cost;
		mcf.addEdge(from, to, cap, cost);
	}
	cout << mcf.flow(0, V - 1, F) << endl;

	return 0;
}


Measured memory_bytes: 3176
import Data.List (group)
import Data.Sequence (ViewL((:<)),ViewR((:>)),(<|),(|>),viewl, viewr)
import qualified Data.Sequence as Seq


solve :: Integer -> Seq.Seq Integer -> Integer -> Integer
solve len sq m
  | Seq.length sq == 1 = m
  | Seq.length sq == 2 = min m $ max l r
  | otherwise = if l < r
                  then let (l1:<r1) = viewl rr
                      in solve len ((l+l1)<|r1) $ min m (len-l)
                  else let (l1:>r1) = viewr ll
                      in solve len (l1|>(r+r1)) $ min m (len-r)
    where (l:<rr) = viewl sq
          (ll:>r) = viewr sq

main :: IO ()
main = do
  s <- getLine :: IO String
  let sq = (Seq.fromList.map (fromIntegral.length).group) s
      ls = (fromIntegral.length) s
  print $ solve ls sq ls


Measured memory_bytes: 12540
import heapq
n=int(input())
a=list(map(int,input().split()))
heapq.heapify(a)
stack=[]
p=[]
neg=[]
for i in range(n):
    if(a[i]<0):
        neg.append(a[i])
    else:
        p.append(a[i])
heapq.heapify(neg)
heapq.heapify(p)
for i in range(n-1):
    if neg!=[]:
        if len(p)>1:
            b=heapq.heappop(p)
            c=heapq.heappop(neg)
            stack.append([c,b])
            heapq.heappush(neg,c-b)
        elif len(p)==1:
            b=heapq.heappop(p)
            c=heapq.heappop(neg)
            stack.append([b,c])
            heapq.heappush(p,b-c)
        else:
            neg.sort(reverse=True)
            b=neg.pop(0)
            c=neg.pop(-1)
            stack.append([b,c])
            heapq.heappush(p,b-c)
            heapq.heapify(neg)
    else:
        if len(p)>2:
            b=heapq.heappop(p)
            c=heapq.heappop(p)
            stack.append([b,c])
            heapq.heappush(neg,b-c)
        else:
            b=heapq.heappop(p)
            c=heapq.heappop(p)
            stack.append([c,b])
            heapq.heappush(p,c-b)
if p!=[]:
    print(p[0])
else:
    print(neg[0])
for i in range(n-1):
    print(stack[i][0],stack[i][1])

Measured memory_bytes: 22972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int x=0,y=0,z=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%4==0){
      x++;
    }
    else if(a[i]%2==0){
      y++;
    }
    else{
      z++;
    }
  }
  if(y==0&&x+1>=z){
    cout << "Yes" << endl;
  }
  else if(y!=0&&x>=z){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	char[] cary = sc.next().toCharArray();
    	int code = (int)cary[0];
    	code++;
    	char c = (char)code;
    	sc.close();
    	System.out.println(c);
    }
}

Measured memory_bytes: 21716
from itertools import accumulate
from bisect import bisect_left

n, m = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
c = 0
s = 0


def f(x):
    global c, s
    c = 0
    s = 0
    for i in range(n):
        left = bisect_left(a, x - a[i])
        c += n - left
        s += cs[n] - cs[left] + (n - left) * a[i]
    return c


ok = 0
ng = 2 * 10 ** 5 + 1
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    if f(x) >= m:
        ok = x
    else:
        ng = x

print(s - (c - m) * ok)


Measured memory_bytes: 14452
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
#define MOD3 999999937
ll power(ll a, ll b){ll res=1;a=a%MOD1;while(b>0){if(b&1){res=(res*a)%MOD1;}a=(a*a)%MOD1;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD1-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo INT_MAX

void solve(){
   ll n;
   cin>>n;
   ll ans = n/1000LL;
   if(n%1000==0)cout<<"0";
   else {
       ans++;
       ans*=1000LL;
       ans-=n;
       cout<<ans;
   }
}

int main(){
    Boost();
    #ifndef ONLINE_JUDGE 
    kill
    #endif
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
 
 
 
 
 

Measured memory_bytes: 3608
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

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

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
        ll K_{};
    ll N_{};
    vector<ll> v_{};
    explicit C1(ll K, vector<ll> v) : K_(K), N_(v.size()), v_(move(v)){}
    ll resolve() {
        std::sort(v_.begin(), v_.end());
        auto s = lower_bound(v_.begin(), v_.end(), K_);
        auto num = distance(v_.begin(), s);
        return N_ - num;
    }
};

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{K, move(v)};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


Measured memory_bytes: 1400
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500+j*100+k*50:
                ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.*;

class Main {
    static int[] h;
    static int n,A,B;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        h = new int[n+1];
        int max = 0;
        for(int i=1;i<=n;i++) {
            h[i] = sc.nextInt();
            max = Math.max(max,h[i]);
        }
        int lo = 0;
        int hi = (max-1)/B+1;
        while(hi-lo>1){
            int mid = (hi+lo)/2;
            if(check(mid)) hi = mid;
            else lo = mid;
        }
        System.out.println(hi);
    }
    static boolean check(int target){
        int cnt = 0;
        for(int i=1;i<=n;i++){
            int temp = h[i]-target*B;
            if(temp>0) cnt += (temp-1)/(A-B)+1;
            if(cnt>target) return false;
        }
        return true;
    }
}


Measured memory_bytes: 52828
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

constexpr int mod=2019;

int main(){
    string S;
    cin>>S;
    
    unordered_map<int,int> cnt;
    int l=S.length(),acc=0,ans=0;
    for(int i=l-1,b=1;i>=0;--i){
        int d=S[i]-'0';
        acc=(acc+b*d)%mod;
        b=(b*10)%mod;
        ans+=!acc;
        ans+=cnt[acc]++;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3704
N,M = map(int,input().split())
edges = []
graph = [[] for _ in range(N+1)]
for _ in range(M):
    a,b = map(int, input().split())
    edges.append([a,b])
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(M):
    visited = [0]*(N+1)
    p = [edges[i][0]]
    visited[p[0]] = 1
    p.extend(graph[edges[i][0]])
    p.remove(edges[i][1])
    for k in p:
        if visited[k]:
            continue
        visited[k] = 1
        p.extend(graph[k])
    if visited[edges[i][1]] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
    input <- getContents
    let [n, m] : list : _ = map read . words <$> lines input :: [[Int]]
    let mlist = (map (`mod` m) . scanl (+) 0) list
    let zero              = 0 -- (length . filter (== 0)) mlist
    let f n = (n * (n - 1)) `div` 2
    let x = ((+ zero) . sum . map f . map length . group . sort) mlist
    putStrLn $ show x


Measured memory_bytes: 13820
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node{
  int p,l,r;
};
typedef struct Node Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ", u,T[u].p, D[u]);
  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c != NIL;i++,c = T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
  
}
void calcDepth(int u,int p){
  D[u] = p;
  if(T[u].r!=NIL) calcDepth(T[u].r,p);
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
}
int main(){
  int i,j,k;
  int n;
  int id,sib,child;
  int root = NIL;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0,sib=NIL;j<k;j++){
      scanf("%d",&child);
      T[child].p = id;
      if(j==0)T[id].l = child;
      else T[sib].r = child;
      sib = child;
    }
  }

  for(i=0;i<n;i++){
    if(T[i].p==-1) root=i;
  }
  calcDepth(root, 0);
  for(i=0;i<n;i++) print(i);
   
  
  return 0;

}





Measured memory_bytes: 6412
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(n: int, m: int):
    print((n-1)*(m-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    m = int(next(tokens))  # type: int
    solve(n, m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
    char x, y;
    int ix, iy;
    scanf("%c %c", &x, &y);
    switch (x)
    {
    case 'A':
        ix = 10;
        break;
    case 'B':
        ix = 11;
        break;
    case 'C':
        ix = 12;
        break;
    case 'D':
        ix = 13;
        break;
    case 'E':
        ix = 14;
        break;
    case 'F':
        ix = 15;
        break;
    default:
        break;
    }

    switch (y)
    {
    case 'A':
        iy = 10;
        break;
    case 'B':
        iy = 11;
        break;
    case 'C':
        iy = 12;
        break;
    case 'D':
        iy = 13;
        break;
    case 'E':
        iy = 14;
        break;
    case 'F':
        iy = 15;
        break;
    default:
        break;
    }
    if (ix > iy)
        printf(">");
    else if (ix < iy)
        printf("<");
    else
        printf("=");

    return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (s == u) {
    cout << a - 1 << " " << b << endl;
  } else {
    cout << a << " " << b - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*void mayank()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}*/
#define ll long long
#define inf 1e9
const int mxN = 1e5;
ll a[mxN + 1], b[mxN + 1];
struct activity
{
	int A, B, C;

};
int solve(vector<activity>ar, int n) {
	int dp[n + 1][3];
	dp[1][0] = ar[1].A;
	dp[1][1] = ar[1].B;
	dp[1][2] = ar[1].C;
	for (int i = 2; i <= n; i++) {
		dp[i][0] = ar[i].A + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = ar[i].B + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = ar[i].C + max(dp[i - 1][0], dp[i - 1][1]);
	}
	return max(dp[n][0], max(dp[n][1], dp[n][2])) ;

}
int main()
{
	//mayank();
	int n;
	cin >> n;
	vector<activity>ar(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> ar[i].A;
		cin >> ar[i].B;
		cin >> ar[i].C;
	}
	cout << solve(ar, n);

	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        long L = scanner.nextLong();
        long R = scanner.nextLong();
        if (R - L >= 2018L) {
            System.out.println(0);
            return;
        }
        long m1 = L  % 2019L;
        long m2 = R % 2019L;
        if (m1 > m2) {
            System.out.println(0);
            return;
        }
        long ans = 2019;

        for (long i = m1; i < m2; ++i) {
            for (long j = i + 1; j <= m2; ++j) {
                long current = ((i % 2019L) * (j) % 2019L) % 2019L;
                ans = Math.min(ans, current);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
N,K = map(int,input().split())
A = list(map(int,input().split()))

dic={}
for i in A:
    if i not in dic.keys():
        dic[i]=1
    else:
        dic[i]+=1
dic=sorted(dic.items(),key=lambda x:x[1],reverse=True)
k=0
ans=0
for key,value in dic:
    if k>=K:
        ans+=value
    k+=1
print(ans)


Measured memory_bytes: 42724
N = gets.to_i
h = gets.split(' ').map(&:to_i)
a = [0,(h[1]-h[0]).abs]

(2...N).each do |i|
  one = a[i-1] + (h[i]-h[i-1]).abs
  two = a[i-2] + (h[i]-h[i-2]).abs
  a[i] = [one,two].min
end
print a[N-1]

Measured memory_bytes: 11396
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main() {
    int N,K;
    cin >> N >> K;
    ll tmp = 1;
    int count = 0;
    while(1){
        count++;
        if(tmp > N){
            count--;
            break;
        }else if(tmp == N) {

            break;
        }
        tmp *= K;
    }
    cout << count << endl;
    return 0;
}

// int main(){
//     // int n;
//     // int k;
//     // cin >> n >> k;
//     // int tmp = 1;
//     // int count = 0;
//     // while(true){
//     //     if(n < k)break;
//     //     n /= k;
//     //     count++;
        
//     // }

    
//     // cout << count+1 << endl;
//     return 0;
// }

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


int main() {
  long long N,M;
  cin>>N>>M;
  
  map<long long,long long> kaz;
  for(int i=0;i<N;i++){
    long long a,b;
    cin>>a>>b;
    kaz[a]+=b;
  }
  long long sum=0;
  for(auto &x:kaz){
    if(x.second<M){
      sum+=x.first*x.second;
      M-=x.second;
    }
    else{
      sum+=x.first*M;
      break;
    }
  }
  cout<<sum<<endl;
    
  
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 2e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n, X;
LL sum[N];
LL diff[N];

LL mult(LL a, LL b){
	if((a * b) / b != a)
		return INF;
	return a * b;
}

int main(){
	scanf("%d %d", &n, &X);
	for(int i = 1; i <= n + 1; ++i)
		diff[i] = 1LL * i * i - 1LL * (i - 1) * (i - 1);

	for(int i = 1; i <= n; ++i){
		scanf("%lld", &sum[i]);
		sum[i] += sum[i - 1];
	}
	
	LL res = INF;
	for(int i = 1; i <= n; ++i){
		LL cur = 1LL * X * i + 2LL * (sum[n] - sum[n - i]);
		int t = n, step = 2;
		while(t > 0){
			int to = max(t - i, 0);
			cur += mult((sum[t] - sum[to]), diff[step]);
			cur = min(cur, INF);
			t = to; ++step;
		}
		
		res = min(res, cur);
	}
	
	printf("%lld\n", res + 1LL * X * n);
	return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e8)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
class pointseg{
	private:
	   int n;
	   vector<ll>t,a;
	   void upd(int v,int tl,int tr,int pos,ll val){
		   if(tl == tr){
			   t[v] = val;
			   return;
		   }
		   int tm = (tl+tr)/2;
		   if(pos <= tm){
			   upd(2*v,tl,tm,pos,val);
		   }else{
			   upd(2*v+1,tm+1,tr,pos,val);
		   }
		   t[v] = merge(t[2*v],t[2*v+1]);
	   }
	   ll query(int v,int l,int r,int tl,int tr){
		   if(l > r)return 0;
		   if(l == tl && r == tr){
			   return t[v];
		   }
		   int tm = (tl+tr)/2;
		   return merge(query(2*v,l,min(r,tm),tl,tm),
		                query(2*v+1,max(l,tm+1),r,tm+1,tr));
	   }
	   void build(int v,int tl,int tr){
		   if(tl == tr){
			   t[v] = a[tl];
			   return;
		   }
		   int tm = (tl+tr)/2;
		   build(2*v,tl,tm);
		   build(2*v+1,tm+1,tr);
		   t[v] = merge(t[2*v],t[2*v+1]);
	   }
	public:
	   ll merge(ll a,ll b){
		   return max(a,b);
	   }
	   void upd(int pos,ll val){
		   upd(1,1,n,pos,val);
	   }
	   ll query(int l,int r){
		   return query(1,l,r,1,n);
	   }
	   void build(){
		   build(1,1,n);
	   }
	   pointseg(int _n,vector<ll>_a ={}){
		   n = _n;
		   t.assign(4*(n+4),0);
		   a = _a;
	   }
	   pointseg(){}
	   void reset(int _n,vector<ll>_a = {}){
		   n = _n;
		   t.clear();
		   t.assign(4*(_n+4),0);
		   a.clear();
		   a = _a;
	   }
	
};
int main()
{
	owo
	ll n,k;
	cin>>n>>k;
	vector<ll>a(n+1);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]++;
	}
	ll ans = 1;
	pointseg s(400000);
	for(int i=0;i<n;i++){
		ll l = max(1LL,a[i]-k);
		ll r = min(ll(300001),a[i]+k);
		ll res = s.query(l,r);
		ll now = s.query(a[i],a[i]);
		if(res+1 > now)s.upd(a[i],res+1); 
		ans = max(ans,now);
		ans = max(ans,res+1);
	}
	cout<<ans;
}



Measured memory_bytes: 17980
from collections import defaultdict 

dic_b = defaultdict(int)
dic_r = defaultdict(int)

N = int(input())
for _ in range(N):
    dic_b[input()] +=1 

M = int(input())
for _ in range(M):
    dic_r[input()] +=1 
#print(dic_b); print(dic_r)

dif = []
for key in dic_b:
    dif.append(dic_b[key] - dic_r[key])
#print(dif)

print( max(0, max(dif)) ) 

Measured memory_bytes: 3316
n, y = map(int, input().split())
ans = [-1, -1, -1]
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        temp = i * 10000 + j * 5000 + (n-i-j) * 1000
        if temp == y:
            ans = [i, j, n-i-j]
            falg = 1
            break
    if flag == 1:
        break

print(" ".join(map(str, ans)))


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 1001001001;
  rep(i,s.size()-2) {
    int res =0;
    res = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0')*1;
    ans = min(ans, abs(res-753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
	#define cerr if(0)cout
#endif

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
    int n,m; cin >> n >> m;
  	if (n==m) cout << "Yes\n";
  	else cout << "No\n";
  	
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll L, R;
    cin >> L >> R;
    if(R - L >= 2020) {
        cout << 0 << endl;
    } else {
        ll res = INF;
        for(ll i = L; i < R; i++) {
            for(ll j = i + 1; j <= R; j++) {
                res = min(res, (i * j % 2019));
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 

  string a,b,c;
  cin>>a>>b>>c;

  if(a.back()==b.front() && b.back()==c.front())
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 3628
n, q = gets.strip.split.map(&:to_i)
ab = (n-1).times.map {|line| gets.strip.split.map(&:to_i) }
pq = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [] }
ab.each do |a, b|
  graph[a] << b
  graph[b] << a
end

tree = Array.new(n+1, 0)
pq.each do |p, x|
  tree[p] += x
end

checked = Array.new(n+1, false)
currents = [1]

until currents.empty?
  current = currents.shift
#  next if checked[current]

  checked[current]=true
  graph[current].each do |cc|
    next if checked[cc]
    tree[cc] += tree[current]
  end

  graph[current].each do |cc|
    currents << cc unless checked[cc]
  end
end

puts tree[1..n].join(' ')



Measured memory_bytes: 62000
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter(",|\n");
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] num;
        num = new int[w];
        int i;
        for(i=0;i<w;i++){
            num[i] = i+1;
        }
        for(int j=0;j<n;j++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int temp = num[a];
            num[a] = num[b];
            num[b] = temp;
        }
        for(i=0;i<w;i++) System.out.println(num[i]);
        sc.close();
    }
}


Measured memory_bytes: 26196
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;

    VL a(n);
    REP(i,n){
        cin>>a[i];
    }
    SORT_DESC(a);

    LL result = 0;
    multiset<LL> s;
    s.insert(a[0]);

    FOR(i,1,n){
        auto itr = s.end();
        itr--;
        result += *itr;
        s.erase(itr);
        s.insert(a[i]);
        s.insert(a[i]);
    }
    cout<<result<<endl;



    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 14288
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}


int main()
{	boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

ll h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
ll p=0;

if(h1==h2)
{
	ll e=m2-m1;
			if(e-k>=0)
	cout<<e-k<<"\n";
else
	cout<<"0\n";
return 0;
} 
if(m1>0)
{
m1=60-m1;
h1++;
}
if(h1>h2)
p=24+h2-h1;
else
p=h2-h1;
ll e=(m1)+m2+(p)*60;
if(e-k>=0)
	cout<<e-k<<"\n";
else
	cout<<"0\n";

}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,f[10004];
void solve(){
    cin>>n;
    rep(i,1,101){
        rep(j,1,101){
            rep(k,1,101){
                if(i*i+j*j+k*k+i*j+j*k+k*i>n) continue;
                f[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    rep(i,1,n+1) cout<<f[i]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

for i in range(1, N):
    s = A[i] + A[i-1]
    if s > x:
        y = s-x
        if A[i] > y:
            A[i] -= y
            A[i-1] -= y
            ans += y
        else:
            z = y - A[i]
            A[i] = 0
            A[i-1] -= A[i]
            A[i-1] -= z
            if i >= 2:
                A[i-2] -= z
            ans += y
print(ans)




Measured memory_bytes: 14052
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<set>
long long mod = 10e18;
long long is(int n)
{
	if (n == 0)
		return 2;
	if (n == 1)
		return 1;
	return (is(n - 1) + is(n - 2));
}
int main()
{
	int n, z, v;
	cin >> n >> z >> v;
	n -= v;
   //if(n%(z+v)==0)
	cout << n / (z + v);
 
	
}

Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//139 B
int main(void) {
	ll a, b;
	cin >> a >> b;
	ll consent = 1;
	ll ans = 0;
	while (consent < b) {
		consent += a - 1;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
//#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, P;
    cin >> N >> P;
    string s;
    cin >> s;
    int V[N];
    rep(i, N) {
        V[i] = s[i] - '0';
    }
    //P==2or5の時だけ別
    if(P != 2 && P != 5) {
        int now = 1;
        for(int i = N - 1; i >= 0; i--) {
            now = (now * 10 % P);
            V[i] = (V[i] * now) % P;
        }
        vector<int> R(N + 1, 0);
        rep(i, N) {
            R[i + 1] = (R[i] + V[i]) % P;
        }
        vector<int> VV(P, 0);
        rep(i, N + 1) VV[R[i]]++;
        int ans = 0;
        rep(i, P) ans += VV[i] * (VV[i] - 1) / 2;
        cout << ans << endl;
    }
    if(P == 2 || P == 5) {
        int ans = 0;
        rep(i, N) if(V[i] % P == 0) ans += (i + 1);
        cout << ans << endl;
    }
}


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

int R;

int main() {
	// your code goes here
	cin >> R;
	if (R < 1200)  {
		cout << "ABC" <<endl;
	}else if (R < 2800){
		cout << "ARC" <<endl;
	}else{
		cout << "AGC" <<endl;
	}
}

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

int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

int main() {
  int N; cin >> N;
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    int A; cin >> A;
    ans = gcd(ans,A);
  }
  
  cout << ans << endl;
}


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

int main() {
	int x, y, d;
	cin >> x >> y;
	while (1) {
		if (x == y) {
			d = x;
			break;
		}
		if (x > y) {
			x = x % y;
			if (x == 0) {
				d = y;
				break;
			}
		}
		if (x < y) {
			y = y % x;
			if (y == 0) {
				d = x;
				break;
			}
		}
	}
	cout << d << endl;

	return 0;
}

Measured memory_bytes: 3080
import sys
import math
import decimal
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
    N = int(readline())
    JPY = 0
    BTC = 0
    for _ in range(N):
        x, u = readline().decode('utf-8').strip().split()
        if u == 'JPY':
            JPY += int(x)
        else:
            BTC += decimal.Decimal(x)

    ans = JPY + BTC*380000
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9992
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void) {
   char s[100010];
   scanf("%s", s);
   int n = strlen(s);
   char cand1[100010];
   char cand2[100010];
   for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
         cand1[i] = '0';
         cand2[i] = '1';
      } else {
         cand1[i] = '1';
         cand2[i] = '0';
      }
   }
   int cnt1=0;
   int cnt2=0;
   for (int i = 0; i < n; i++) {
      if (cand1[i] == s[i]) {
         cnt1++;
      }
      if (cand2[i] == s[i]) {
         cnt2++;
      }
   }
   printf("%d\n",MIN(cnt1,cnt2));

   return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	int A[3];
	cin>>A[0]>>A[1]>>A[2];
	sort(A,A+3);
	if(A[0]==5&&A[1]==5&&A[2]==7) return _P("YES\n");
	_P("NO\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int H,W,K;
char s[805][805];
bool vis[805][805];
int dis[805][805];
queue<pii > Q;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void Solve() {
    read(H);read(W);read(K);
    for(int i = 1 ; i <= H ; ++i) {
	scanf("%s",s[i] + 1);
    }
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    if(s[i][j] == 'S') {
		Q.push(mp(i,j));vis[i][j] = 1;
	    }
	}
    }
    while(!Q.empty()) {
	pii u = Q.front();Q.pop();
	if(dis[u.fi][u.se] == K) continue;
	for(int k = 0 ; k < 4 ; ++k) {
	    int tx = u.fi + dx[k],ty = u.se + dy[k];
	    if(s[tx][ty] == '.' && !vis[tx][ty]) {
		Q.push(mp(tx,ty));
		vis[tx][ty] = 1;
		dis[tx][ty] = dis[u.fi][u.se] + 1;
	    }
	}
    }
    int ans = 1000000000;
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    if(vis[i][j]) {
		if(i == 1 || j == 1 || i == H || j == W) ans = min(ans,1);
		else {
		    int t = min(i - 1,j - 1);
		    t = min(t,min(H - i,W - j));
		    ans = min(ans,1 + (t - 1) / K + 1);
		}
	    }
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 4096
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	map<string, vector<int>> mp;
	string s;
	int a;
	while (cin >> s >> a) {
		mp[s].emplace_back(a);
	}
	sort(mp[s].begin(), mp[s].end());
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		cout << itr->first<< endl;
		sort(mp[itr->first].begin(), mp[itr->first].end());
		for (int i = 0; i < mp[itr->first].size(); i++) {
			cout << mp[itr->first][i];
			if (i != mp[itr->first].size() - 1)cout << " ";
			else cout << endl;
		}
	}
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<char,int> M;
const ll mod=1000000000+7;

int main(){
    ll N;
    cin>>N;
    vector<ll> H(N);
    for(ll i=0;i<N;i++)cin>>H.at(i);
    bool jud=true;
    ll x=H.at(0);
    for(ll i=1;i<N;i++){
        x=max(x,H.at(i));
        if(x-H.at(i)>1){
            jud=false;
            break;
        }
    }
    if(jud)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >>d;
  int e=abs(a-b); int f=abs(a-c); int g=abs(b-c);
  if(f <= d) cout<<"Yes"<<endl;
  else if(e <= d && g <= d) cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
  return 0;
}


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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define EREP(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define erep(i, n) EREP(i, 0, n)
#define ALL(r) (r).begin(), (r).end()

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

const long long INF = 1LL << 60;

void Main();

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main() {
    int n, k;
    long long h[100100];
    long long dp[100100];

    cin >> n >> k;
    rep(i, n) cin >> h[i];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;

    rep(i, n)
        erep(j, k)
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 5200