akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.next());
        int M = Integer.parseInt(s.next());
        boolean[] completed = new boolean[N];
        int[] wa = new int[N];
        int acCount = 0;
        int waCount = 0;
        for (int i = 0; i < M; i++) {
            int p = Integer.parseInt(s.next()) - 1;
            if (completed[p]) {
                s.next();
                continue;
            }
            String S = s.next();
            if (Objects.equals(S, "WA")) {
                wa[p]++;
            } else {
                acCount++;
                waCount += wa[p];
                completed[p] = true;
            }
        }
        System.out.println(acCount + " " + waCount);
    }

}


Measured memory_bytes: 51192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int dp[21000], ar[21000], n, m, k;
signed main() {
	cin>>n>>m>>k;
	for1(i, n)cin>>ar[i];
	for(int i=2;i<=n+1;i++){
		dp[i]=dp[i-1]+k;
		int a=ar[i-1],b=ar[i-1];
		for(int j=1;j<=min(m, i-1);j++){
			a=max(a,ar[i-j]);
			b=min(b,ar[i-j]);
			dp[i]=min(dp[i],dp[i-j]+k+j*(a-b));
		}
	}
	cout<<dp[n+1]<<endl;
	return 0;
}


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

int main(){
    int H,W,N;cin>>H>>W>>N;
    int c;
    vector<int> clr;
    rep(i,0,N){
        cin>>c;
        rep(j,0,c){
            clr.push_back(i+1);
        }
    }
    rep(i,0,H){
        if(i%2==0){
            rep(j,0,W){
                cout<<clr.at(i*W+j);
                if(j!=W-1)cout<<" ";
            }
        }
        else{
            for(int j=W-1;j>=0;j--){
                cout<<clr.at(i*W+j);
                if(j!=0)cout<<" ";
            }
        }
        cout<<endl;
    }
}







Measured memory_bytes: 384
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = list(input())
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]
from collections import defaultdict
graphAB = defaultdict(list)

for i in range(m):
    u,v=map(int,input().split())
    graphAB[u].append(v)
    graphAB[v].append(u)



def incrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]+=1
    if s[adj-1] == 'B':
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]-=1
    if s[adj-1] == 'B':
        bli[node-1]-=1


def adjAB(node):
    if ali[node-1]!=0 and bli[node-1]!=0:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 'C'
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)


while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    gen = (j for j in graphAB[i] if s[j-1]!='C')
    for j in gen:
        decrementAB(j,i)
        if not adjAB(j):
            visitset.add(j)
    s[i-1] = 'C'

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
    print('Yes')
else:
    print('No')





Measured memory_bytes: 58144
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll,ll> P;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

ll C;

ll sol(const std::vector<P> &s) {
  ll ans = 0, D = 0;
  int N = sz(s);

  // cyclic only
  std::vector<ll> Lr(N);
  D = 0;
  rep(i,N) {
    if ( i != 0 ) D += s[i].second-(s[i].first - s[i-1].first);
    else D += (s[i].second - s[i].first);
    chmax(ans, D);
    Lr[i] = D;
  }

  // mae keisann
  std::vector<ll> Ll(N);
  ll tmp = 0;
  D = 0;
  for(int k=N-1; k>=0; k--) {
    if ( k != N-1 ) D += s[k].second - (s[k+1].first - s[k].first);
    else D += (s[k].second - (C-s[k].first));
    chmax(tmp, D);
    Ll[k] = tmp;
  }

  // cyclic i, un-cyc j
  rep(i,N-1) {
    D = Lr[i];
    D -= s[i].first;
    D += Ll[i+1];
    chmax(ans, D);
  }

  return ans;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N >> C;
  std::vector<P> s(N); rep(i,N) std::cin >> s[i].first >> s[i].second;
  std::vector<P> t(N); rep(i,N) t[i] = { C-s[N-i-1].first, s[N-i-1].second };
  
  std::cout << std::max( sol(s), sol(t) ) << std::endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
int N,Q;
int a[200000],b[200000];
int p[200000],x[200000];

ll ans[200000+1];//頂点iのスコア

//各頂点のスコアを計算
void solve(){
    memset(ans,0,sizeof(ll)*200001);//頂点iのスコアを0で初期化
    vector<vector<int>> list(N+1);//list[i]は頂点iから行ける点の集合
    for(int i = 0;i<N-1;i++){
        list[a[i]].push_back(b[i]);
        list[b[i]].push_back(a[i]);
    }
    for(int i = 0;i<Q;i++){
        ans[p[i]] += x[i];
    }

    bool visited[200001];//頂点iに訪れているならばvisited[i] = true;
    memset(visited,0,sizeof(bool)*200001);
    queue<int> q;//各頂点をキューに突っ込む
    q.push(1);

    /*キューを根に近い頂点から見ていき、見たらvisitedを更新し、
    見た頂点の子の頂点が、まだ訪れていなかったら子の頂点のスコアを
    親の頂点のスコアだけ足していく 子の頂点をキューに突っ込む
    */
    while(!q.empty()){
        int vertex = q.front();
        q.pop();
        visited[vertex] = true;
        for(auto next_node : list[vertex]){
            if(!visited[next_node]){
                ans[next_node] += ans[vertex];
                q.push(next_node);
            }
        }
    }
}
int main() {
    cin >> N >>Q;
    for(int i = 0;i<N-1;i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0;i<Q;i++){
        cin >> p[i] >> x[i];
    }
    solve();

    for(int i=1;i<=N;i++){
		cout << ans[i] << ' ';
	}
	cout << endl;
}


Measured memory_bytes: 17652
#include<iostream>

using namespace std;

int partition(pair<char,int>* a, int p, int r) {
	int x = a[r - 1].second;
	int cnt = p - 1;
	for (int i = p;i < r;i++) {
		if (a[i].second <= x) {
			cnt++;
			swap(a[cnt], a[i]);
		}
	}
	return cnt;
}

void quicksort(pair<char, int>* a, int l, int r) {
	if (l < r) {
		int q = partition(a, l, r);
		quicksort(a, l, q);
		quicksort(a, q + 1, r);
	}
}

int main() {
	int n;
	cin >> n;
	pair<char,int>* a = new pair<char,int>[n];
	pair<char, int>* original = new pair<char, int>[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i].first>>a[i].second;
		original[i].first = a[i].first;
		original[i].second = a[i].second;
	}

	quicksort(a, 0, n);
	bool flag = true;
	for (int i = 0;i < n - 1&&flag;i++) {
		if (a[i].second == a[i + 1].second) {
			for (int j = 0;j < n;j++) {
				if (original[j] == a[i])break;
				if (original[j] == a[i + 1]) {
					flag = false;
					break;
				}
			}
		}
	}
	if (flag)cout << "Stable\n";
	else cout << "Not stable\n";
	for (int i = 0;i < n;i++) {
		cout << a[i].first<<" "<<a[i].second <<endl;
	}
}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);

int main(){
	ll N,K;
	cin >> N >> K;
	vector<ll> H(N);
	FOR(i,0,N) cin >> H[i];
	SORT(H);
	REV(H);

	ll ans = 0;
	FOR(i,K,N){
		ans += H[i];
	}

	cout << ans << endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  if (s[1] == s[2] && (s[0] == s[1] || s[3] == s[2])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
 int a, b, c;
  int yn = 0;
  cin >> a >> b >> c;
  
  if (a == 7 && b == 5 && c == 5) {
    yn = 1;
  } else if (a == 5 && b == 7 && c == 5) {
   yn = 1; 
  } else if (a == 5 && b == 5 && c == 7) {
    yn = 1;
  }
  
  if (yn == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    double a, b, h, m, ans;
    double pi = 3.141592653589793, sita1, sita2;
    cin >> a >> b >> h >> m;
    sita1 = 6 * m;
    sita2 = 30 * h + 0.5 * m;
    if (sita1 > sita2) {
        sita1 = sita1 - sita2;
    }
    else {
        sita1 = sita2 - sita1;
    }
    if (sita1 > 180){
        sita1 = 360 - sita1;
    }
    sita1 = (sita1 / 180.0) * pi;
    ans = sqrt(a * a + b * b - 2 * a * b * cos(sita1));
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}

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

long long x, k, d;

int main() {
    cin >> x >> k >> d;
    if(abs(x/d) <= k) {
        k -= (x/d);
        x -= d*(x/d);
        if(k) {
            if(x >= 0 && abs(x-d) < abs(x)) {
                x -= d;
                k--;
            }
            else if(x < 0 && abs(x+d) < abs(x)) {
                x += d;
                k--;
            }
        }

        if(k%2 == 0) cout << abs(x);
        else cout << min(abs(x+d), abs(x-d));
    } else {
        if(x > 0) cout << abs(x-k*d);
        else cout << abs(x+k*d);
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        cout << r * x - d << endl;
        x = r * x - d;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
from sys import stdin

n, W = map(int, raw_input().strip().split())
inp = stdin.readlines()

dp = [[0 for i in xrange(W + 1)] for j in xrange(n)]

# dp[i][j] is total value if using only the first i elements, weight j can be taken
# and 0 otherwise

i = 0
for line in inp:
    wi, vi = map(int, line.strip().split())

    if i == 0:
        dp[0][wi] = vi
    else:
        for X in xrange(wi):
            dp[i][X] = dp[i - 1][X]
        for X in xrange(wi, W + 1):
            dp[i][X] = max(dp[i - 1][X], dp[i - 1][X - wi] + vi)

    i += 1

print max(dp[n - 1])

Measured memory_bytes: 111212
import Control.Applicative

operate :: String -> [Int] -> [Int]
operate op (n2:n1:stack)
  | op == "+" = (n1+n2):stack
  | op == "-" = (n1-n2):stack
  | op == "*" = (n1*n2):stack
operate op stack = (read op :: Int):stack

operates :: [String] -> Int
operates ops = loop ops []
  where
    loop :: [String] -> [Int] -> Int
    loop [] [x]         = x
    loop (op:ops) stack = loop ops (operate op stack)

main :: IO ()
main = do
  ops <- words <$> getLine
  print $ operates ops



Measured memory_bytes: 3916
#include<iostream>
#include<sstream>
#include<algorithm>
#include<string>
#include<cstring>
#include<iomanip>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define MAXN 100005
#define ll long long

using namespace std;

bool cmp(ll x, ll y)
{
	return x < y;
}

int main()
{
	ll a[5],ans;
	cin >> a[0] >> a[1] >> a[2];
	if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		sort(a,a+3,cmp);
		ans = a[0] * a[1];
		cout << ans << endl;
	}
	return 0; 
}


Measured memory_bytes: 256
from math import gcd

N = int(input())
num_lis = list(map(int, input().split()))
c = True

def osa_k(max_num):
  lis = [i for i in range(max_num+1)]
  p = 2
  while p**2 <= max_num:
    if lis[p] == p:
      for q in range(2*p, max_num+1, p):
        if lis[q] == q:
          lis[q] = p
    p += 1
  return lis

hoge = 0
for i in num_lis:
  hoge = gcd(hoge, i)
if hoge > 1:
  print("not coprime")
  exit()

d_lis = osa_k(10**6+10)
tmp = set()
for i in num_lis:
  num = i
  new_tmp = set()
  while num > 1:
    d = d_lis[num]
    new_tmp.add(d)
    num //= d
  for j in new_tmp:
    if j in tmp:
      c = False
      break
    else:
      tmp.add(j)
  else:
    continue
  break

if c:
  print("pairwise coprime")
else:
  print("setwise coprime")

Measured memory_bytes: 134500
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            if ((S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) ||
                (S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) ||
                (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]))
            {
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;


int modpow(int a, int b, int mod){
	int res = 1;
	a %= mod;
	while(b > 0){
		if(b&1)
			res = (res*a)%mod;
		a = (a*a)%mod;
		b >>= 1;
	}
	return res;
}

int32_t main(){
	int n, k;
	cin >> n >> k;
	
	vector<int> adj[k+1];
	for(int i = 1; i <= k; i++){
		for(int j = i; j <= k; j += i)
			adj[i].push_back(j);
	}
	int ans[k+1] = {0};
	for(int i = k; i >= 1; i--){
		int temp = 0;
		for(auto x : adj[i])
			if(x != i){
				temp += ans[x];
				temp %= MOD;
			}
		ans[i] = modpow(adj[i].size(),n,MOD);
		ans[i] -= temp;
		ans[i] %= MOD;
		if(ans[i] < 0)
			ans[i] += MOD;
	}
	int res = 0;
	for(int i = 1; i <= k; i++){
		res = (res + ans[i]*i) % MOD;
	}
	cout << res << endl;
	
	

	return 0;
}



Measured memory_bytes: 19416
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int, int> P;
struct edge{
    int to;
    int cost;
};
int main(){
    int N;
    cin >> N;
    vector<P> X(N), Y(N);
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        X[i] = P(x, i);
        Y[i] = P(y, i); 
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    vector<edge> G[N];
    for(int i = 0; i < N - 1; i++){
        int dx = X[i + 1].first - X[i].first, dy = Y[i + 1].first - Y[i].first;
        edge e = {X[i + 1].second, dx}, e2 = {X[i].second, dx};
        edge e3 = {Y[i + 1].second, dy}, e4 = {Y[i].second, dy};
        G[X[i].second].push_back(e);
        G[X[i + 1].second].push_back(e2);
        G[Y[i + 1].second].push_back(e4);
        G[Y[i].second].push_back(e3);
    }
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));
    vector<int> used(N, 0);
    long long ans = 0;
    while(!que.empty()){
        P v = que.top();
        que.pop();
        if(used[v.second] == 1) continue;
        ans += v.first;
        used[v.second] = 1;
        for(edge e: G[v.second]){
            que.push(P(e.cost, e.to));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M))
#define mod 1000000007
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  lli B,C,D,E,F,N,M,K,sum=0,num=0,ans=0;
  DV(P,lli,3,3);Vec(Q,lli,3,0);
  rep(i,0,3)rep(j,0,3)cin >> P[i][j];
  Q[0]=min(P[0][0],min(P[0][1],P[0][2]));
  Q[1]=min(P[1][0],min(P[1][1],P[1][2]));
  Q[2]=min(P[2][0],min(P[2][1],P[2][2]));
  rep(i,0,3)rep(j,0,3)P[i][j]-=Q[i];
  rep(i,0,3)if(P[0][i]==P[1][i]&&P[0][i]==P[2][i])sum++;
  if(sum==3)Out("Yes");
  else Out("No");
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
a2 = 0

while a > 0:
    a1 = a
    l = []
    while a1 >= 1:
        l.append(int(a1 % 10))
        a1 = a1 / 10
    if sum(l) >= b and sum(l) <= c:
        a2 = a2 + a

    a = a - 1
print(a2)


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    internal static void Main(string[] args)
    {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = inp[0];
        int B = inp[1];
        int K = inp[2];
        int hoge = B - A;
        var lst = new List<int>();

        int a = A;
        for (int i = 0; i < K; i++) {
            if (i > hoge) { break; }
            lst.Add(a);
            a++;
        }

        int b = B;
        for (int i = 0; i < K; i++) {
            if (i > hoge) { break; }
            lst.Add(b);
            b--;
        }

        lst = lst.OrderBy((i => i)).Distinct().ToList();
        foreach (int i in lst) {
            WriteLine(i);
        }
    } 
}

Measured memory_bytes: 13408
import java.util.LinkedList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int m = in.nextInt();
			int s = in.nextInt()-1;
			int g1 = in.nextInt()-1;
			int g2 = in.nextInt()-1;
			if(n == 0) break;
			int[][] edge = new int[n][n];
//			int[][] root = new int[n][n];
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
//					root[i][j] = i;
					if(i==j) continue;
					edge[i][j] = 1000000;
				}
			}
			for(int i=0; i<m; i++){
				int b1 = in.nextInt()-1;
				int b2 = in.nextInt()-1;
				int c = in.nextInt();
				edge[b1][b2] = c;
			}
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					for(int k=0; k<n; k++){
						if(edge[j][k] > edge[j][i]+edge[i][k]){
							edge[j][k] = edge[j][i] + edge[i][k];
//							root[j][k] = i;
						}
					}
				}
			}
			int res = edge[s][g1] + edge[s][g2];
			for(int i=0; i<n; i++){
				res = Math.min(res, edge[s][i]+edge[i][g1]+edge[i][g2]);
			}
//			LinkedList<Integer> list = rooting(root, s, g1);
//			for(int i: list){
//				res = Math.min(res, edge[s][g1] + edge[i][g2]);
//			}
			
//			list = rooting(root, s, g2);
//			for(int i: list){
//				res = Math.min(res, edge[s][g2] + edge[i][g1]);
//			}
			
			System.out.println(res);
		}
	}
	
	public static LinkedList<Integer> rooting(
			int[][] root, int s, int t){
		LinkedList<Integer> res = new LinkedList<Integer>();
		refound(root, s, t, res);
		return res;
	}
	
	public static void refound(
			int[][] root, int s, int t
			, LinkedList<Integer> res){
		int center = root[s][t];
		if(s == center){
			res.add(t);
			return;
		}
		refound(root, s, center, res);
		refound(root, center, t, res);
	}
}

Measured memory_bytes: 62892
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long H;

	cin >> H;

	long long count = 0;

	long long base = 1;

	while(H) {
		H /= 2;
		count += base;
		base *= 2;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
if n == 1:
    a = input()
    print(0)
else:
    a = np.array(list(map(int, input().split())))
    check = np.arange(1, n+1)
    c = sorted(list(a - check))
    b1 = c[int(n/2)]
    b2 = c[int(n/2)+1]
    count1 = 0
    count2 = 0
    for i in range(1, n+1):
        count1 += abs(a[i-1] - i - b1)
        count2 += abs(a[i-1] - i - b2)
    print(min(count1, count2))


Measured memory_bytes: 34236
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 300005
#define M 1000005
#define LOG 18
#define KOK 4000000
using namespace std;

int n,k,x[N];

int main() {

	//freopen("input.txt","r",stdin);	

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

	int gcd=0;

	for(int i=1;i<=n;i++) {

		scanf("%d",&x[i]);

		gcd=__gcd(x[i],gcd);

	}

	bool ok=false;

	for(int i=1;i<=n;i++) {

		if(k>x[i]) continue ;

		if((x[i]-k)%gcd==0) ok=1;

	}

	if(!ok) printf("IM");

	printf("POSSIBLE");

}



Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int gi() {
	int w;bool q=1;char c;
	while (((c=getchar())<'0'||'9'<c)&&c!='-');
	if (c=='-') q=0,c=getchar();
	w=c-'0';
	while ('0'<=(c=getchar())&&c<='9') w=w*10+c-'0';
	return q?w:-w;
}
const int mod=1e9+7;
inline int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}
const int N=1e5;
int p[N],c[N],f[N];
int main()
{
	int n=gi(),m=gi(),i,j,ans=0,sq=sqrt(n),len=0;
	const int inv2=(mod+1)>>1;
	for (i=1;i<=sq;i++) if (!(n%i)) p[++len]=i;
	for (i=sq*sq==n?sq-1:sq;i;i--) if (!(n%i)) p[++len]=n/i;
	for (i=1;i<=len;i++) {
		f[i]=qpow(m,(p[i]+1)>>1);
		for (j=1;j<i;j++)
			if (!(p[i]%p[j]))
				(f[i]-=f[j])%=mod;
	}
	for (i=1;i<=len;i++) ans=(ans+1LL*f[i]*p[i]%mod*(p[i]&1?1:inv2))%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 256
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll dp[405][405];
ll pre[405];
ll fun(ll l,ll r)
{
   if(dp[l][r]!=1e18)
      return dp[l][r];
    if(l==r)
      return 0;
    for(int i=l;i<r;i++)
    {
        dp[l][r]=min(dp[l][r],fun(l,i)+fun(i+1,r)+pre[r]-pre[l-1]);
    }
    return dp[l][r];
}
void solve()
{
   ll n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=n;j++)
        dp[i][j]=1e18;
   }
   for(int i=1;i<=n;i++)
   {
       ll x;
       cin>>x;
       pre[i]=pre[i-1]+x;
   }
   cout<<fun(1,n);
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            int mini = i;
            for (int j = i; j < N; j++) {
                if (A[mini] > A[j]) {
                    mini = j;
                }
            }
            if (mini != i) {
                int tmp = A[mini];
                A[mini] = A[i];
                A[i] = tmp;
                cnt++;
            }
        }
        for (int i = 0; i < N; i++) {
            System.out.print(A[i] + ((i == N - 1) ? "\n" : " "));
        }
        System.out.println(cnt);
    }
}

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

int yakusu(int N){
    int num = 0;
    int i = 1;
    while (pow(i,2) <= N){
        if (N % i == 0){
            if (pow(i,2) == N){
                num += 1;
                break;
            }
            num += 2;
        }
        i += 1;
    }
    return num;
}

int main(){
    int N;
    cin >> N;
    int cnt = 0;

    for (int i=1; i<=N; i++){
        if (yakusu(i) == 8 && i % 2 == 1){
            cnt += 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
 {
     long min,max,a;
     long long sum;
     int n;
     sum = 0;
     cin >> n;

     for (int i = 0; i < n; ++i)
     {
         cin >> a;
         if(i==0) min=a, max=a;
         if(a<min) min = a;
         if(a>max) max = a;
         sum += a;
     }

     cout << min << " " << max << " " << sum << endl;

     return 0;
 }

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

int main()
{
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    string s[100000];
    cin >> n;
    for (int in = 0; in < n; in++)
    {
        cin >> s[in];
    }

    for (int i = 0; i < n; i++)
    {
        if (s[i] == "AC") ac++;
        else if (s[i] == "WA") wa++;
        else if (s[i] == "TLE") tle++;
        else if (s[i] == "RE") re++;
    }

    cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;++i)

using namespace std;

int main() {
	long long int a, n[90] = { }; cin >> a;
	n[0] = 2; n[1] = 1;
	FOR(i, 2,a+1) {
		n[i] = n[i - 1] + n[i - 2];
	}
	cout << n[a] << endl;
	return 0;
}

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

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] inputList = br.readLine().split(" ");
			int r = Integer.parseInt(inputList[0]);
			int c = Integer.parseInt(inputList[1]);
			int[][] list = new int[r + 1][c + 1];
			int i, j, num, sum;
			for (i = 0; i < r; i++) {
				sum = 0;
				String[] hoge = br.readLine().split(" ");
				for (j = 0; j < c; j++) {
					num = Integer.parseInt(hoge[j]);
					list[i][j] = Integer.parseInt(hoge[j]);
					sum = sum + num;
				}
				list[i][c] = sum;
			}

			for (i = 0; i < c + 1; i++) {
				sum = 0;
				for (j = 0; j < r + 1; j++) {
					sum = sum + list[j][i];
				}
				list[r][i] = sum;
			}

			String output;
			for (i = 0; i < r + 1; i++) {
				output = "";
				for (j = 0; j < c + 1; j++) {
					output = output + list[i][j] + " ";
				}
				System.out.println(output.substring(0, output.length() - 1));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 38028
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    StringBuilder s1=new StringBuilder(s);
    if(s1.charAt(s.length()-1)=='s')
      		s1.append("es");
    else
      	s1.append("s");
    System.out.println(s1);
  }
}
  

Measured memory_bytes: 35632
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ret(n, -1);
  bool found = false;
  while (m--) {
    int x, y;
    cin >> x >> y;
    --x;
    if (ret[x] < 0) {
      ret[x] = y;
    } else {
      if (ret[x] != y) found = true;
    }
  }
  if (found || (n > 1 && ret[0] == 0)) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (ret[i] < 0) {
      cout << (n > 1 && i == 0 ? 1 : 0);
    } else {
      cout << ret[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;

class Base {
public:
    virtual void f() {
        cout << "base" << endl;
    }
};
class Derive : public Base {
public:
    virtual void f() {
        cout << "derive" << endl;
    }
};
void solve() {
   int x, y, a, b;
   cin >> x >> y >> a >> b;
   x = max(x, a);
   y = min(y, b);
   int res = max(y - x, 0);
   cout << res << endl;
}

int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    solve();
    return 0;
}


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

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

    int a = A[0];
    int b = A[1];
    int diff = abs(a - b);
    for (int i = 1; i < N; i++) {
        if (diff < abs(A[i] - a)) {
            b = A[i];
            diff = abs(A[i] - a);
        } else if (diff < abs(A[i] - b)) {
            a = A[i];
            diff = abs(A[i] - b);
        }
    }
    cout << diff << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  long ans = 0;
  long n = s.length();

  for (int bit = 0; bit < (1<<n-1); bit++) {
    string save = {s[0]};
    for(int i = 0; i < n - 1; i++) {
      if (bit & (1 << i)) {
        ans += atoll(save.c_str());
        save = {s[i+1]};
      }else {
        save += {s[i+1]};
      }
    }
    ans += atoll(save.c_str());
  }

  cout << ans << endl;
}


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

const ll m=1e9+7;

ll power(ll a,ll b)
{
	if(b==0)
		return 1;

	else if(b%2==0)
		return power((a%m*a%m)%m,b/2);
	else
		return (a*power((a%m*a%m)%m,(b-1)/2))%m;
}

int main()
{
	int n,k;
	cin>>n>>k;

	ll dp[k+1];


	for(int i=k;i>=1;i--)
	{
		dp[i]=power((k/i),n);

		for(int j=2*i;j<=k;j=j+i)
		{
			dp[i]=dp[i]-dp[j];
		}
	}

	ll ans=0;
	for(int i=1;i<=k;i++)
	{
		ans=ans+dp[i]*i;
	}
	cout<<ans%m<<endl;

	return 0;
}

Measured memory_bytes: 4356
def main():
    import sys
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    
    n = ini()
    rick = 0
    import math
    for i in range(1,n+1):
        rick+=math.floor((n-1)/i)
    print(rick)
        


    
        


        


    




















if __name__ == "__main__":
    main()

Measured memory_bytes: 63640
import sys
import math
from decimal import Decimal

def main():
    a, b, c = [int(_) for _ in input().split()]

    a_sq = Decimal(a).sqrt()
    b_sq = Decimal(b).sqrt()
    c_sq = Decimal(c).sqrt()

    if a_sq + b_sq < c_sq:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vl A(N);
	REP(i,N) cin >> A[i];

	vl Ai(N);
	vl Aj(N);
	REP(i,N) {
		Aj[i] = i - A[i];
		Ai[i] = i + A[i];
	}

	map<ll, int> mp;
	ll res = 0;
	REP(i,N) {
		res += mp[Aj[i]];
		mp[Ai[i]] += 1;
	}

	cout << res << endl;
}

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


Measured memory_bytes: 30640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int a, b; cin >> a >> b;
  if(a == 1){
    if(b == 1) cout << "Draw\n";
    else cout << "Alice\n";
  }
  else if(b == 1){
    cout << "Bob\n";
  }
  else if(a > b){
    cout << "Alice\n";
  }
  else if(a < b){
    cout << "Bob\n";
  }
  else cout << "Draw\n";
  return;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define INF 10000000000000LL
#define ll long long

typedef struct{
	int from;
	int to;
	int cost;
} Edge;
Edge edge[2000];
ll d[1000];
int neg[1000];
int main(void)
{
	int m,n,flag,i,j;
	Edge e;
	scanf("%d%d",&n,&m);
	FOR(i,0,n) d[i]=INF;
	FOR(i,0,m){
		scanf("%d%d%d",&edge[i].from,&edge[i].to,&edge[i].cost);
		edge[i].from--;
		edge[i].to--;
		edge[i].cost*=-1;
	}
	d[0]=0;
	FOR(i,0,2*n){
		flag=0;
		FOR(j,0,m){
			e=edge[j];
			if(d[e.from]==INF) continue;
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				if(e.to==n-1) flag=1;
			}
		}
		if(i>=n-1&&flag){
			puts("inf");
			return 0;
		}
	}
	printf("%lld\n",-d[n-1]);
	return 0;
}
    
    
    


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			string s;
			while((s = Console.ReadLine()) != null)
			{
				var n = s.Split(' ').Select(i => int.Parse(i)).ToArray();
				Console.WriteLine(n[0] + n[1]);
			}
		}
	}
}

Measured memory_bytes: 5948
s = list(input())
c = 0
for i in range(len(s)):
    if (i != 0):
        if (s[i] == s[i - 1]):
            c += 1
            if (s[i] == "0"):
                s[i] = "1"
            else:
                s[i] = "0"
print(c)

Measured memory_bytes: 3956
#include <stdio.h>
#define AMX 10000
 

 
int main()
{
  int RYOMA[AMX] = {0},i,ra=0,j,N,a;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &a);
        RYOMA[a]++;
    }
    for (i=0; i<AMX; i++) {
        if (RYOMA[i] != 0) {
            ra = i;
        }
    }
     
    for (i=0; i<ra; i++) {
        for (j=0; j<RYOMA[i]; j++) {
            printf("%d ", i);            
        }
    }
    for (i=0; i<RYOMA[ra]-1; i++) {
        printf("%d ", ra);
    }
    printf("%d\n", ra);
     
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string a,b; cin>>a>>b;
  ll n=a.size(), m=b.size();
  
  if(n==m){
    if(a>b) cout<<"GREATER"<<endl;
    else if(a<b) cout<<"LESS"<<endl;
    else cout<<"EQUAL"<<endl;
  }else{
    if(n>m){
      cout<<"GREATER"<<endl;
    }else{
      cout<<"LESS"<<endl;
    }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define INF ( 1 << 30 )
#define fr first
#define sc second
typedef pair < int , int > Pi;
typedef pair < Pi , Pi > Pii;
const int dy[] = { 0, 1, -1, 0}, dx[] = { 1, 0, 0, -1};
int h, w, Sx, Sy, Gx, Gy;
vector< Pi > hoge[5];
int dp[5][1000][1000], num;
char c;
int dis(Pi x1,Pi x2){
  return abs(x1.fr - x2.fr) + abs(x1.sc - x2.sc);
}
int rec(int now,int y, int x){
  if(dp[now][y][x] != -1) return dp[now][y][x];
  int ret = INF, next = ( now + 1 ) % 5;
  if(now == num) ret = dis(Pi(y,x),Pi(Gy,Gx));
  else for(int i = 0 ; i < hoge[next].size() ; i++ ){
    ret = min( ret, rec( next, hoge[next][i].fr, hoge[next][i].sc) + dis(Pi(y,x),hoge[next][i]));
  }
  return dp[now][y][x] = ret;
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < 5 ; i++ ) hoge[i].clear();
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> c;
        if(c == 'S') Sy = i, Sx = j;
        else if(c == 'G') Gy = i, Gx = j;
        else if(c != '.') hoge[c-'1'].push_back(Pi(i,j));
      }
    }
    Pi ret = Pi(INF,INF);
    for(int i = 0 ; i < 5 ; i++ ){
      for(int j = 0 ; j < 5 ; j++ )
        for(int k = 0 ; k < h ; k++ )
          for(int l = 0 ; l < w ; l++ ) dp[j][k][l] = -1;
      num = ( i + 4 ) % 5;
      ret = min( ret, Pi( rec( i, Sy, Sx), i + 1));
    }
    if( ret.fr == INF ) cout << "NA" << endl;
    else cout << ret.sc << " " << ret.fr << endl;
  }
}

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

int main() {
    int op; cin >> op;
    if (op == 1) {
        cout << "Hello World" << endl;
    }
    if (op == 2) {
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
from heapq import heappush, heappop

def dijkstra(V, E, s):
    '''
    Input:
        V = list(range(N))
        E = defaultdict(dict)
        s (in V) : start vertex
    Output:
        dist: the list of the minimum cost from s to arbitrary vertex v in the given graph
    '''
    INF = float('inf')
    dist = {v: INF for v in V}
    heap = []
    dist[s] = 0; rem = len(V);
    heappush(heap, (0, s))
    while heap and rem:
        d, v = heappop(heap)
        # don't need to check when the stored value is greater than provisional distance
        if d > dist[v]: continue
        rem -= 1;
        for u, c in E[v].items():
            temp = d + c
            if temp < dist[u]:
                dist[u] = temp
                heappush(heap, (temp, u))
    return dist

MON = 10**15
n, m, s, t = map(int, input().split())
V = list(range(1, n+1))
E1, E2 = {v: {} for v in V}, {v: {} for v in V}
for _ in range(m):
    u, v, a, b = map(int, input().split())
    E1[u][v] = a
    E1[v][u] = a
    E2[u][v] = b
    E2[v][u] = b
ans = [MON]*n
dist_yen = dijkstra(V, E1, s)
dist_snuuk = dijkstra(V, E2, t)
temp = float('inf')
for v in V[::-1]:
    temp = min(temp, dist_yen[v] + dist_snuuk[v])
    ans[v-1] -= temp
print(*ans, sep='\n')

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

#define ll long long
#define ar array

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

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

	cin >> n >> k;
	for (int i=0; i<n; ++i) cin >> h[i];
	fill(dp+1, dp+n, 2e9);
	for (int i=1; i<n; ++i) {
		for (int j=1; j<=k; ++j) {
			if (i-j<0) break;
			dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n-1];
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/



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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// change max/min
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  INPUT1(X);
  if (X == 0)
  {
    cout << 1;
  }
  else
  {
    cout << 0;
  }

  // INPUT2(A, B);
  // INPUT3(A, B, C);
  // INPUTS(S);
  // INPUTA(N, A);
  // INPUTB(X, Y, B);
}


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

int main() {
	// your code goes here
	int k, n, mx=INT_MIN;
	cin >> k >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
		if(i>0)
			mx=max(mx, v[i]-v[i-1]);
	}
	mx=max(mx, k-(v[n-1]-v[0]));
	cout << k-mx << endl;
	return 0;
}		


Measured memory_bytes: 1024