akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int tag[2000005];
int n;
void print()
{
    for(int j=0;j<n;j++)
    {
        if(j)cout<<' ';
        cout<<tag[j];
    }
    cout<<endl;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>tag[i];
    print();
    for(int i=1;i<n;i++)
    {
        int key=tag[i];
        int j=i-1;
        while(key<tag[j]&&j>=0)
            tag[j+1]=tag[j--];
        tag[j+1]=key;
        print();
    }
}

Measured memory_bytes: 3084
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
count = 1
st = k
i = 0
while true
    if st + (k-1) * i >= n
        puts count
        break
    end
    i += 1
    count += 1
end

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

int n,ar[2000];

int main(){

    while(cin>>n){

        for(int i=0;i<n;i++)
            scanf("%d",ar+i);

        sort(ar,ar+n);

        int mncost=INT_MAX;

        for(int i=ar[0];i<=ar[n-1];i++){

            int cost=0;
            for(int j=0;j<=n-1;j++)
                cost+=(int)abs(ar[j]-i)*(int)abs(ar[j]-i);

//            cout<<"to make "<<i<<" cost is: "<<cost<<endl;
            mncost=min(mncost,cost);
        }

        cout<<mncost<<endl;

    }




return 0;
}


Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
t=[int(input()) for i in range(D)]
C=sum(c)
l=[0]*26
a=0
m=0
for i in range(D):
    b=t[i]-1
    m+=C-c[b]*(i-l[b]+1)
    a+=s[i][b]-m
    l[b]=i+1
    print(a)

Measured memory_bytes: 9276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    int N, M, t, s, a;
    s = 0; a = 0;
    vector<int> v;
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> t;
        v.push_back(t);
        s += t;
    }
    for (auto e: v) {
        if (e * 4 * M >= s) ++a;
    }
    if (a >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;
int m, k;
int per, ans;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        
        vint persons[150];
        for (int i = 0; i < n; ++i) {
            persons[i].clear();
            cin >> m;
            for (int j = 0; j < m; ++j) {
                cin >> per; persons[i].PB(per);
            }
            sort(ALL(persons[i]));
        }
        cin >> k;
        vint answer;
        for (int i = 0; i < k; ++i) {
            cin >> ans; answer.PB(ans);
        }
        
        int con[150];
        memset(con, 0, sizeof(con));
        
        for (int i = 0; i < answer.size(); ++i) {
            int l = answer[i];
            
            for (int j = 0; j < n; ++j) {
                if (binary_search(ALL(persons[j]), l)) {
                    con[j]++;
                }
            }
        }
        
        vint res;
        for (int i = 0; i < n; ++i) {
            if (con[i] == k) res.PB(i+1);
        }
        
        if (res.size() == 1) cout << res[0] << endl;
        else cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1272
using System;


class MainClass
{
	public static void Main (string[] args)
	{
		while (true) {
			string str = Console.ReadLine ();
			string[] spStr = str.Split (' ');

			int x = int.Parse (spStr [0]);
			int y = int.Parse (spStr [1]);

			if (x > y) {
				int z = x;
				x = y;
				y = z;

			}

			if (x == 0 && y == 0) {
				break;
			}

			Console.WriteLine (x + " " + y);

		}
	}
}

Measured memory_bytes: 9276
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag) {
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;
}

void ansYES(bool flag) {
    if (flag) cout << "YES" << endl; else cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

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

struct datas {
    Int max;
    Int size;
};

class ContainChecker {
protected:
    Int minx, miny, maxx, maxy;
public:
    ContainChecker(Int minx, Int miny, Int maxx, Int maxy) : minx(minx), miny(miny), maxx(maxx), maxy(maxy) {};

    bool in(Int x, Int y) {
        return (minx <= x && miny <= y && x <= maxx && y <= maxy);
    }
};

Int getHead(Int n) {
    while(n / 10 > 0){
        n /= 10;
    }
    n %= 10;
    return n;
}

int main(void) {
    Int x;
    cin >> x;
    Int ans = (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;
}




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

int32_t main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(nullptr), cout.tie(nullptr);

	int a; cin >> a;
	int ans = a;
	ans += pow(a, 2);
	ans += pow(a, 3);
	cout << ans << endl;
}

Measured memory_bytes: 3980
#include <stdio.h>
int main() {
	int n;
	int i;
	
	scanf("%d",&n);
	
	int a[101];
	
	for(i=0;i<n;i++) scanf("%d",&a[i]);

	for(i=n-1;i>=1;i--) 
		{
			printf("%d ",a[i]);
		}
	printf("%d\n",a[0]);
	return 0;
}


Measured memory_bytes: 2700
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int main() {

	char s[4];

	scanf("%s", s);

	int c = 0;
	rep(i, 3) if (s[i] == '1') c++;

	printf("%d\n", c);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

int main() {

	int N;
	cin >> N;
	vector<int> p(N);
	int num = 0;

	for (int i = 0; i < N; i++)
		cin >> p[i];
	sort(p.begin(), p.end());

	for (int i = 0; i < N-1; i++)
	{
		num += p[i];
	}
	num += int(p[N - 1] / 2);
	cout << num << endl;
}

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

import sys

sys.setrecursionlimit(10**7)


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    read_h()
    A = read_h()

    num_odd = 0
    for a in A:
        if a % 2 != 0:
            num_odd += 1

    if num_odd % 2 != 0:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 14196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String S = s.substring(s.indexOf("A"), s.lastIndexOf("Z"));
		int N = S.length();
		System.out.println(N + 1);
	}
}


Measured memory_bytes: 28116
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a = [0i64; 5];

    for _ in 0..n {
        match read::<String>().chars().next().unwrap() {
            'M' => a[0] += 1,
            'A' => a[1] += 1,
            'R' => a[2] += 1,
            'C' => a[3] += 1,
            'H' => a[4] += 1,
            _ => (),
        }
    }

    let mut ans = 0;
    for i in 0..3 {
        for j in i + 1..4 {
            for k in j + 1..5 {
                ans += a[i] * a[j] * a[k];
            }
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

void output(vi &data, int p)
{
    rep(i, data.size()) {
        cout << p*2 << " ";
        p = data[i] - p;
    }
    cout << endl;
}

int solve(vi &data, int p)
{
    //cout << "call : ";
    int ptr = p;
    rep(i, data.size()) {
        //cout << ptr << " ";
        if (data[i] < ptr) {
            //cout << endl;
            return -1;
        }
        ptr = data[i] - ptr;
    }
    //cout << ptr << endl;
    return !(ptr == p);
}

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }

    int yui = 0;
    rep(i, n) {
        yui = data[i] - yui;
    }
    output(data, yui/2);

    return 0;

    int l = 0, r = data[0];
    if (solve(data, 0) == 0) {
        output(data, 0);
        return 0;
    }
    if (solve(data, data[0]) == 0) {
        output(data, data[0]);
        return 0;
    }
    while (r - l > 1) {
        int mid = (l + r) / 2;
        int state = solve(data, mid);
        if (state < 0) {
            l = mid;
        } else if (state == 0) {
            output(data, mid);
            break;
        } else {
            r = mid;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
s = str(input())
t = str(input())

n = len(s)
m = len(t)
if m > n:
    print('UNRESTORABLE')
    exit()

ans = []
for i in range(n-m+1):
    flag = True
    for j in range(m):
        if s[i+j] != t[j]:
            if s[i+j] != '?':
                flag = False
    if flag:
        p = s[:i]
        q = s[i+m:]
        temp = p.replace('?', 'a')+t+q.replace('?', 'a')
        ans.append(temp)

ans.sort()
if ans:
    print(ans[0])
else:
    print('UNRESTORABLE')


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

int main() {
    long long h, ans = 0;
    cin >> h;
    int i = 0;
    while(h >= 1){
        ans += pow(2, i);
        h /= 2;
        i++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4064
import numpy as np
N, K = map(int, input().split())
H = np.array(list(map(int, input().split())), dtype=int)

dp = np.zeros(N, dtype=int)
for i in range(1, N):
    s = max(i-K, 0)
    dp[i] = (np.abs(H[i] - H[s:i]) + dp[s:i]).min()
print(dp[-1])

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

int main()
{
    double X, Y, x, y, b1, b2, b3, b4;
    int ans=0;
    cin >> X >> Y >> x >> y;
    b1 = x * Y, b2 = (X - x) * Y, b3 = y * X, b4 = (Y - y) * X;
    //cout << b1 << " " << b2 << " " << b3 << " " << b4 << endl;
    if (2 * x == X && 2 * y == Y)
    {
        ans = 1;
    }

        cout << fixed;
        cout << setprecision(6) << X*Y/2 << " " << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    set<int> st;
    for(int i = A; i < (K+A) && i <= B; ++i) st.insert(i);
    for(int i = B; i > (B-K) && i >= A; --i) st.insert(i);

    for(auto i : st)
        cout << i << endl;

    return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  int n, k;
  cin >> n >> k;

  if (n < k) {
    cout << 0 << endl;
    return 0;
  }

  auto factorials = MakeFactorialTable(n + k + 1);
  auto c_fn = [&factorials](int x, int y) {
    return factorials[x] / factorials[y] / factorials[x - y];
  };
  FiniteField value = c_fn(n - 1, k - 1);
  cout << value.Value() << endl;
}



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

namespace AtCoder
{
    public class ABC096C
    {
        public static void Main(string[] args)
        {
            string[] lineArgs = Console.ReadLine().Split(' ');
            int H = int.Parse(lineArgs[0]);
            int W = int.Parse(lineArgs[1]);
            bool[][] target = new bool[H][];

            for (int index = 0; index < H; index++)
            {
                target[index] = Console.ReadLine().ToCharArray().Select<char, bool>(arg => arg == '#').ToArray<bool>();
            }

            // 独立した一つの黒がなければ大丈夫と判断
            // 全ての黒について確認する
            bool notIndependent = false;
            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    notIndependent = false;
                    if (target[h][w] == false) continue;
                    if (1 <= w && target[h][w - 1]) notIndependent = true;
                    if (w + 1 < W && target[h][w + 1]) notIndependent = true;
                    if (1 <= h && target[h - 1][w]) notIndependent = true;
                    if (h + 1 < H && target[h + 1][w]) notIndependent = true;
                    if (notIndependent == false)
                    {
                        Console.WriteLine("No");
                        goto exit;
                    }
                }
            }
            Console.WriteLine("Yes");
        exit:;
        }
    }
}


Measured memory_bytes: 13396
from heapq import heappush, heappop
from collections import deque

def main():
    V = int(input())
    q = []
    G = [deque() for i in range(V)]
    
    for i in range(V):
        tmp = list(map(int, input().split()))
        
        if tmp[0] == 0:
            for j in range(tmp[1]): heappush(q, (tmp[2+2*j:4+2*j][::-1]))
                
        else:
            for j in range(tmp[1]): G[tmp[0]].append(tmp[2+2*j:4+2*j])
            
    dist = [float('inf')] * V
    visited = [False] * V
    dist[0], visited[0] = 0, True
    
    while q:
        cost, v = heappop(q)
        
        if visited[v]: continue
    
        dist[v], visited[v] = cost, True
        for u, c in G[v]:
            if visited[u] or dist[u] < cost + c: continue
            heappush(q, [c+cost, u])
        
    for i in range(V): print(i, dist[i])
    
if __name__ == '__main__':
    main()
    


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


int main(void){

	int n, p;

	while (cin >> n >> p, n, p){

		int num[100] = { 0 };
		int stack = p;
		int result;

		for (int i = 0; i < 1100000; i++){
			if (stack == 0){
				stack += num[i%n];
				num[i%n] = 0;
			}
			else if (stack == 1 && num[i%n] == p - 1){
				result = i % n;
				break;
			}
			else{
				stack--;
				num[i%n]++;
			}
		}

		cout << result << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1160
n = int(input())
a = list(map(int, input().split()))

d = {}

for i in range(max(a)+1):
  d[i] = 0

for a_ in a:
  d[a_] += 1

d[-1] = 0
d[max(a)+1] = 0

ans = 0

for x in range(max(a)+1):
  if x-1 in d:
    ans = max(ans, d[x-1] + d[x] + d[x+1])

print(ans)
    

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

int main(void) {
    vector<string> s(3);
    for(int i=0;i<3;i++) {
        cin >> s[i];
    }
    for(int i=0;i<3;i++) {
        cout << s[i][i];
    }
    cout << endl;
    return 0;
}


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

int main()
{
    int N, X, count=0;
    cin >> N >> X;
    vector<int> D(N+1);
    D.at(0) = 0;
    for (int i = 0; i < N;i++){
        int x;
        cin >> x;
        D.at(i + 1) = D.at(i) + x;
    }
    //for (int i = 0; i < N;i++)
     //   cout << L.at(i) << endl;

    for (int i = 0; i<=N; i++)
    {
        //cout << D.at(i) << endl;
        if (D.at(i) <= X)
        {
            count++;
            //cout << "hoge" << endl;
        }
    }
    cout << count << endl;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define segc int M = (L + R - 1) >> 1, lc = id << 1, rc = lc | 1

const int N = 500054, M = N * 2;

int n, K, E = 0;
int a[N], b[N];
int to[M], first[N], next[M], deg[N];
int x[N * 4];
std::priority_queue <int> pq;

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline int min(const int x, const int y) {return x < y ? x : y;}
inline int max(const int x, const int y) {return x < y ? y : x;}
inline void addedge(int u, int v) {to[++E] = v, next[E] = first[u], first[u] = E, ++deg[v];}

void adj(int id, int L, int R, int h, int v) {
	if (L == R)	{x[id] = v; return;}
	segc; h <= M ? adj(lc, L, M, h, v) : adj(rc, M + 1, R, h, v);
	x[id] = max(x[lc], x[rc]);
}

int range(int id, int L, int R, int ql, int qr) {
	if (ql > qr) return 0;
	if (ql <= L && R <= qr) return x[id];
	segc, s = 0;
	if (ql <= M) up(s, range(lc, L, M, ql, qr));
	if (qr > M) up(s, range(rc, M + 1, R, ql, qr));
	return s;  
}

int main() {
	int i, j, x, y;
	scanf("%d%d", &n, &K), --K;
	for (i = 1; i <= n; ++i) scanf("%d", a + i), b[a[i]] = i;
	for (i = 1; i <= n; ++i) {
		if (x = range(1, 1, n, max(b[i] - K, 1), b[i] - 1)) addedge(b[i], b[x]);
		if (x = range(1, 1, n, b[i] + 1, min(b[i] + K, n))) addedge(b[i], b[x]);
		adj(1, 1, n, b[i], i);
	}
	for (i = 1; i <= n; ++i) if (!deg[i]) pq.emplace(i);
	for (i = n; i; --i) {
		b[i] = x = pq.top(), pq.pop(); 
		for (j = first[x]; j; j = next[j])
			if (!--deg[y = to[j]]) pq.emplace(y);
	}
	for (i = 1; i <= n; ++i) a[b[i]] = i;
	for (i = 1; i <= n; ++i) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 27764
#include <iostream>
using namespace std;
using ll = long long;

ll gcd(ll x, ll y){
  return y ? gcd(y,x%y) : x;
}

ll lcm(ll x, ll y){
  return (x / gcd(x,y)) * y;
}

int main(){
  ll a,b,c,d; cin >>a >> b >> c >> d;
  ll dif = b-a+1;
  
  ll cd = lcm(c,d);
  
  ll divc = (b/c) - ((a-1)/c);
  ll divd = (b/d) - ((a-1)/d);
  ll divcd = (b/cd) - ((a-1)/cd);
  
  //cout << cd << endl;
  cout << dif - divc - divd + divcd << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>

using namespace std;


typedef long long llint;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

int n, k, sol, x;
int a[201000];
vector<int> v;

int main(void) {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    cin >> x;
    a[x]++;
  }
  for(int i = 0; i <= n; ++i) {
    if(a[i] != 0) v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < (int) v.size() - k; ++i) sol += v[i];
  cout << sol << endl;
	return 0;
}


Measured memory_bytes: 2168
const
	t:array[1..3] of char=('3','5','7');
var
	n:string;
	l,ans,b,j:longint;
procedure make(x:longint; s:string);
var
	i,a:longint;
begin
	if x=j+1 then
	begin
		if pos('3',s)=0 then exit;
		if pos('5',s)=0 then exit;
		if pos('7',s)=0 then exit;
		val(s,a);
		if a>b then exit;
		inc(ans);
		exit;
	end;
	for i:=1 to 3 do make(x+1,s+t[i]);
end;
begin
	read(b);
	str(b,n);
	l:=length(n);
	ans:=0;
	for j:=3 to l do make(1,'');
	writeln(ans);
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <stdio.h>
#include <set>
using namespace std;

void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
	unsyncIO();
	if(s.size()){
		setIn(s + ".in");
		setOut(s + ".out");
	}
}


#define ll long long
const ll mod = 1e9 + 7;
const int MX = 200005;

int n, m;
int par[MX], sz[MX];

int f(int x){
	if(par[x] == x) return x;
	return f(par[x]);
}

int main(){
//setIO();

	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i ++){
		par[i] = i; sz[i] = 1;
	}
	for(int u, v, i = 0; i < m; i ++){
		scanf("%d%d", &u, &v);
		u = f(u); v = f(v);
		if(u != v) {
			if(u < v) swap(u, v);
			sz[v] += sz[u], par[u] = v;
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i ++)
		if(par[i] == i) ans = max(ans, sz[i]);
	printf("%d\n", ans);
}

Measured memory_bytes: 5308
n = int(input())


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a * b // g


num = int(input())
for i in range(n - 1):
    a = int(input())
    num = lcm(num, a)


print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max({ (N - 1) / A + 1, (N - 1) / B + 1, (N - 1) / C + 1, (N - 1) / D + 1, (N - 1) / E + 1 }) + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# n = int(input())
s = input()
slist = list(s)
no = 0

for i in range(len(slist)):
  w = slist[i]
  if i % 2 == 0:
    if w != 'R' and w != 'U' and w != 'D':
      no = 1
  else:
    if w != 'L' and w != 'U' and w != 'D':
      no = 1
      
if no == 0:
  print('Yes')
elif no == 1:
  print('No')
else:
  print('Error')

Measured memory_bytes: 3064
#include <iostream> 
    #include <algorithm> 
    #include <cstring> 
    #include <cstdio>
    #include <vector> 
    #include <queue> 
    #include <cstdlib> 
    #include <iomanip>
    #include <cmath>
    #include <cassert>
    #include <ctime> 
    #include <map> 
    #include <set> 
    using namespace std; 
    #define lowbit(x) (x&(-x)) 
    #define max(x,y) (x>y?x:y) 
    #define min(x,y) (x<y?x:y) 
    #define MAX 100000000000000000 
    #define MOD 1000000007
    #define pi acos(-1.0) 
    #define ei exp(1) 
    #define PI 3.141592653589793238462
    #define ios() ios::sync_with_stdio(false)
    #define INF 1044266558
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    const int maxn=1e6+7;
    char a[55],b[55];
    int flag,i,n;
    ll ans;
    int main()
    {
        while(scanf("%d %s %s",&n,a,b)!=EOF)
        {
            ans=1,i=0;
            if(a[i]==b[i]) i++,ans=ans*3%MOD,flag=1;
            else i+=2,ans=ans*6%MOD,flag=0;
            while(i<n)
            {
                if(a[i]==b[i])
                {
                    if(flag) ans=ans*2%MOD,i++;
                    else flag^=1,i++;
                }
                else
                {
                    if(flag) ans=ans*2%MOD,flag^=1,i+=2;
                    else ans=ans*3%MOD,i+=2;
                }
            }
            printf("%lld\n",ans);
        }
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=55,OO=1e18;
int a[N],b[N],m[N][N],g[N][N],cost[N];
void f(){
    forn(i,N){
        for(int j=1;j<=i;++j)upn(g[i][i%j],cost[j]);
        g[i][i]=0;
    }
    forn(k,N)forn(i,N)forn(j,N)upn(g[i][j],max(g[i][k],g[k][j]));
}
int32_t main(){
    int n;
    cin>>n;
    forn(i,n)cin>>a[i];
    forn(i,n)cin>>b[i];
    forn(i,N)cost[i]=i;
    forn(i,N)forn(j,N)g[i][j]=OO;
    int ans=0;
    while(1){
        f();
        int mx=0;
        forn(i,n)upx(mx,g[a[i]][b[i]]);
        if(mx==OO){
            cout<<"-1\n";
            return 0;
        }
        if(!mx)break;
        ans+=1ll<<mx;
        cost[mx]=0;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;cin>>n>>k;
    char d[k];
    for(int i=0;i<k;i++)cin>>d[i];
    for(int i=n;i<=10*n;i++){
        string b=to_string(i);
        int ll=b.size();
        bool jud=false;
        for(int j=0;j<ll;j++){
            for(int m=0;m<k;m++){
                //cout<<d[m]<<" "<<b[j]<<endl;
                if(d[m]==b[j]){
                    jud=true;
                    break;
                }
            }
        }
        if(!jud){
            cout<<i<<endl;
            return 0;
       }
    }
}


Measured memory_bytes: 256
n = int(input())
if n == 1:
    print(0)
    exit()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def is_prime(n):
  if n <= 1: return False
  for i in range(2, int(n**0.5)+1):
    if n%i == 0: return False
  return True

x = make_divisors(n)[1:]
if len(x) == 1:
    print(1)
    exit()

cnt = 0
numbers = []
for a in x:
    if is_prime(a):
        n //= a
        e = 2
        cnt += 1
        while n%(a**e)==0:
            numbers.append(a**e)
            e += 1
    if a in numbers:
        if n%a == 0:
            n //= a
            cnt += 1
print(cnt)

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

int main()
{
	int n, m; 
	
	cin >> n;
	vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i];

	cin >> m;
	vector<string> t(m); for (int i = 0; i < m; i++) cin >> t[i];

	int s_cnt;
	int ans = 0;
	for (int i = 0; i < n; i++) {
	
		s_cnt = 1;
		for (int j = 0; j < n; j++) {
			if (j != i && s[j] == s[i]) s_cnt++;
		}		
	
		for (int j = 0; j < m; j++) {
			if (t[j] == s[i]) s_cnt--;
		}
	
		ans = max(ans, s_cnt);
	
	}
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a[5];
    int k;
    scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
    scanf("%d",&k);
    if(a[4] - a[0] <= k) printf("Yay!\n");
    else printf(":(\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int a[1000];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int sum = 0;
	int N; cin >> N;
	int L; cin >> L;
	REP(i, N) {
		a[i] = L + i;
	}
	int idx = 0;
	int mx = INF;
	REP(i, N) {
		if (abs(a[i]) < mx) {
			idx = i;
			mx = abs(a[i]);
		}
	}
	REP(i, N) {
		if (i == idx)continue;
		sum += a[i];
	}
	print(sum);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <list>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int binarySearch(const vector<int>& haystack, int needle, int beginIndex, int endIndex){
    // if 0 or size
    int current = (endIndex - beginIndex) / 2 + beginIndex;
    // printf("begin: %d end: %d\n", beginIndex, endIndex);
    // printf("current: %d\n", current);
    // printf("needle: %d cur: %d\n", needle, haystack[current]);
    while(true) {
        if (haystack[current] == needle) return 1;
        
        // end (not found)
        // if(current == 0) break;
        // if(current == haystack.size() - 1) break;
        if(current == beginIndex) break;
        if(current == endIndex) break;

        if (haystack[current] < needle) return binarySearch(haystack, needle, current + 1, endIndex);
        if (haystack[current] > needle) return binarySearch(haystack, needle, beginIndex, current);
    }
    return 0;
}

void solve() {
    int n1;
    scanf("%d", &n1);
    vector<int> s(n1);
    for(int i = 0; i < n1; i++){
        int v;
        scanf("%d", &v);
        s[i] = v;
    }

    int n2;
    int common = 0;
    scanf("%d", &n2);
    for(int i = 0; i < n2; i++){
        int v;
        scanf("%d", &v);
        common += binarySearch(s, v, 0, s.size() - 1);
    }
    printf("%d\n", common);
}


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



Measured memory_bytes: 3204
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();
        if (x1 == 0) {
            System.out.println(1);
        } else if (x2 == 0) {
            System.out.println(2);
        } else if (x3 == 0) {
            System.out.println(3);
        } else if (x4 == 0) {
            System.out.println(4);
        } else if (x5 == 0) {
            System.out.println(5);
        }
    }

}

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

using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  long int a[n],i;
  
  for(i=0;i<n;++i)
       scanf("%ld",&a[i]);
  
  int cnt=0,flag=0;
  while(1)
  {
    flag=0;
    for(i=0;i<n;++i)
    {
      if(a[i]%2==0)
      { a[i]=a[i]/2;
         flag=1;
      }
      
      else
      {
        flag=0;
        break;
      }
    }
    
    if(flag==0)
        break;
        
    else
     cnt++;
  }
  
  printf("%d",cnt);
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
  }
  
  auto it = max_element(A.begin(), A.end());
  int mx = *it;
  A.erase(it);
  
  vector<int> B(A.size());
  for (int i = 0; i < A.size(); ++i) {
    B[i] = min(A[i], mx - A[i]);
  }
  
  auto idx = max_element(B.begin(), B.end()) - B.begin();
  cout << mx << ' ' << A[idx] << '\n';
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

string a;
int L;
map<string,int>data;

string add_zero(string s){
  while(s.size()!=L){
    s="0"+s;
    //cout<<"s: "<<s<<endl;
  }
  return s;
}


int str_to_int(string s){
  //cout<<"s"<<s<<endl;
  int n=0,ten=1;
  char c;
  ten=pow(10,L-1);
  rep(i,s.size()){
    c=s[i];
    n+=int(c-'0')*ten;
    ten/=10;
  }
  return n;
}

string change_str(string s){
  s=add_zero(s);
  sort(all(s));
  int mini=str_to_int(s);
  reverse(all(s));
  int maxi=str_to_int(s);
  //cout<<mini<<" "<<maxi<<endl;
  maxi-=mini;
  string str;
  str=to_string(maxi);
  str=add_zero(str);
  //cout<<"str: "<<str<<endl;
  return str;
}

void solve(){
  data.clear();
  int cnt=1;
  a=add_zero(a);
  data.insert(make_pair(a,0));
  string str=change_str(a);
  while(1){
  	//cout<<str<<endl;
    if(data.find(str)!=data.end())break;
    data.insert(make_pair(str,cnt));
    str=change_str(str);
    cnt++;
  }
  cout<<data[str]<<" "<<str_to_int(str)<<" "<<cnt-data[str]<<endl;
}


int main(){
  while(cin>>a>>L){
    if(a=="0"&&L==0)break;
    solve();
  }
  return 0;
}

Measured memory_bytes: 3356
#include <stdio.h>

int main()
{   int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    long long ans=0;
    for(int i=0;i<n;i++){
        if(i<k)ans+=x;
        else ans+=y;
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
t = input()
n = len(s)
m = len(t)
L = ''
for i in range(n):
    L += s[i]
    if i >= m:
        continue
    L += t[i]
print(L)

Measured memory_bytes: 38384
N = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
cnt = Hash.new(0)
as.each do |a|
  cnt[a - 1] += 1
  cnt[a] += 1
  cnt[a + 1] += 1
end
ans = 0
cnt.each do |k, v|
  ans = v if v > ans
end
p ans



Measured memory_bytes: 14212
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
static const int MAX = 1000;

int main(){
  int n,R[MAX],j,v,a;
  int flag = 1;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> R[i];
  }
  while(flag){
    flag = 0;
    for (int i = n-1; i >= 1; i--){
      if(R[i] < R[i-1]){
        swap(R[i],R[i-1]);
        a++;
        flag = 1;
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(i != n-1){
      cout << R[i] << " ";
    }else{
      cout << R[i] << endl;
    }
  }
  cout << a << endl;
  return 0;
}



Measured memory_bytes: 3088
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
ll t,n,m,k,x,y,w;
int main(){
	fastio;
	cin>>n>>w;
	ll ach[w+1]={0};
	forn(i,n){
		cin>>x>>y;
		rforn(i,w){
			if(i+x<=w) ach[i+x]=max(ach[i+x],ach[i]+y);
		}
	}
	ll ans=0;
	forn(i,w+1) ans=max(ans,ach[i]);
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    long x[N], y[N], z[N];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    long ans = 0;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                long temp[N]; fill(temp, temp + N, 0);
                for(int m=0; m<N; m++){
                    temp[m] = (2 * i - 1) * x[m] + (2 * j - 1) * y[m] + (2 * k - 1) * z[m];
                }
                sort(temp, temp + N, greater<long>());
                long s = 0;
                for(int l=0; l<M; l++) s += temp[l];
                ans = max(ans, s);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,cas=1;

void solve(){
    id1=n+1;
    id2=n;
    id3=1;
    c=c1=0;
    while(id3<=n){
        if(id3>=k){
            c=(c+id1)%MOD;
        }
        id3++;
        id2-=2;
        id1+=(id2);
    }
    c=(c+1)%MOD;
    printf("%lld\n",c);
}
int main()
{
    // scanf("%lld",&t);
    t=1;
    while(t--){
        scanf("%lld%lld",&n,&k);
        solve();
    }
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) {
            System.out.println("a > b");
        } else if(a < b){
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }

    }
}



Measured memory_bytes: 26176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <deque>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    string S;
    cin >> S;
    string Str[3] = {"Sunny", "Cloudy", "Rainy"};
    int a = 0;
    for(int i=0;i<3;i++){
        if(Str[i]==S) a = i;
    }
    cout << Str[(a+1)%3] << endl;

    return 0;
}

Measured memory_bytes: 256