akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll a, p;
    cin >> a >> p;
    p += 3 * a;
    cout << p / 2 << endl;
}


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


int main() {
	int N, K, a, b;
	long double sum = 0.0;
	long double pa = 0.0;
	vector<long double> p;
	std::cout.precision(16);
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		a = i;
		b = 0;
		while (a < K) {
			b++;
			a *= 2;
		}
		pa = 1.0/(long double)(pow(2, b) * N);
		p.emplace_back(pa);
	}
	for (int i = 0; i < p.size(); i++) {
		sum += p[i];
	}
	cout << sum;
}

Measured memory_bytes: 2420
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_rotn(void) {
	int n;
	string s;
	cin >> n >> s;

	for (int i = 0; i < s.size(); i++) {
		s[i] = s[i] + n;
		if (s[i] - 'A' >= 26) {
			s[i] -= 26;
		}
	}

	cout << s << endl;
}

int main()
{
    b_rotn();

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
char s[100] , b[100];
int main()
{
    scanf("%s",s);
    int l = strlen(s);
    for(int i = 0; i < l; i++)
    {
    	 if(s[i] == ',')
		  {
		  	  b[i] = ' ';
		  	  continue;
			}  
			b[i] = s[i];
	}
	printf("%s",b);
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np 

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.full_like(h, fill_value=sys.maxsize, dtype=int)
dp[0] = 0
# print(dp)

for i in range(1, n):
    start = max(i-k, 0)
    # print(f'start={start}, i={i}, np.absolute(h[start:i] - h[i])={np.absolute(h[start:i] - h[i])}, dp[start:i]={dp[start:i]}')
    # print(f'dp, h[i]={h[i]}')
    dp[i] = np.min(dp[start:i] + np.abs(h[start:i] - h[i]))
     

print(dp[-1])

Measured memory_bytes: 22792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] u = new int[n + 1];
		int[] v = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		sc.close();

		long[][] dp = new long[n + 1][w + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= w; j++) {
				long v1 = dp[i - 1][j];
				long v2 = 0;
				if (j >= u[i]) {
					v2 = dp[i - 1][j - u[i]] + v[i];
				}
				dp[i][j] = Math.max(v1, v2);
			}
		}

		long ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				ans = Math.max(ans, dp[i][j]);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 127316
import fractions

N,M = map(int,input().split())
S = input()
T = input()
L = fractions.gcd(N,M)
ans = N*M//L

if L == 1:
  print(ans) if S[0] == T[0] else print(-1)
else:
  print(ans) if S[::N//L] == T[::M//L] else print(-1)

Measured memory_bytes: 5432
# coding: utf-8
# Your code here!

S = input()
counter = 0
flag = 0

if S[0] == "A":
    if S.find("C", 2, len(S) - 1) != -1:
        counter = S.find("C", 2, len(S) - 1)
        if S[1:counter] == S[1:counter].lower() and S[counter + 1 ::] == S[counter + 1 ::].lower():
            print("AC")
            flag = 1

if flag == 0:
    print("WA")


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

using namespace std;

int main()
{
    int resp1 = 1, resp2 = 1;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (i + 1 < s.length() && s[i] == s[i + 1])
        {
           if(i+1 != s.length() - 1) {
                if (i + 2 == s.length()-1) resp1++;
                else resp1 += 2;
            }
            i += 2;
        }
        else if(i!=s.length()-1) resp1++;
    }

    for (int i = s.length() - 1; i >= 0; i--)
    {
        if (i - 1 >= 0 && s[i] == s[i - 1])
        {
            if( i-1 != 0) {
                if (i - 2 == 0) resp2++;
                else resp2 += 2;
            }
            i -= 2;
        }
        else if(i!=0) resp2++;
    }

    cout << max(resp1, resp2);
    return 0;
}

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

typedef array<int, 6> dice;

bool f(dice &d0, dice &d1)
{
	static const array<dice, 6> tbl = {
		0,1,2,3,4,5, 1,5,2,3,0,4, 2,1,5,0,4,3,
                3,1,0,5,4,2, 4,0,2,3,5,1, 5,1,3,2,4,0};

	for (dice t : tbl) {
		int i = 0, j;
		do {
			j = 0;
			for (; j < 6 && d0[t[j]] == d1[j]; j++)
				;
			if (j == 6)
				return true;
			int tmp = t[1]; t[1] = t[2]; t[2] = t[4]; t[4] = t[3]; t[3] = tmp;
		} while (i++ < 4);
	}
	return false;
}

int main()
{
	dice d[2];

	for (auto &x: d) {
		for (int &y: x) {
			cin >> y;
		}
	}

	cout << (f(d[0], d[1]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int solve(int x, int y){
	int digits=0,sumx=0,sumy=0;
	while(x>0){
		sumx += x%10;
		x /= 10;
	}
	while(y>0){
		sumy += y%10;
		y /= 10;
	}
	digits = sumx + sumy;

	return digits;
}

int main(){
	int n; cin>>n;
	int ans=2000000000;

	for(int i=1;i<n;i++){
		int j = n - i;
		ans = min(ans, solve(i, j));
	}

	cout<< ans <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> nn(n, false);
    for(int i = 0; i < k; i++){
        int d; 
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            nn[a-1] = true;
        }
    }
    int cnt = 0;
    for(auto aa : nn){
        if(!aa) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var mod = (int)Math.Pow(10, 9) + 7;
            var input = ReadArrayInt();
            var H = input[0];
            var W = input[1];
            var grid = new char[H, W];
            for (int i = 0; i < H; i++)
            {
                var line = Read();
                for (int j = 0; j < W; j++)
                {
                    grid[i, j] = line[j];
                }
            }
            var cnt = new int[H, W];
            cnt[0, 0] = 1;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (grid[i, j] == '#') continue;
                    if (j + 1 < W && grid[i, j + 1] != '#')
                    {
                        cnt[i, j + 1] += cnt[i, j];
                        cnt[i, j + 1] %= mod;
                    }
                    if (i + 1 < H && grid[i + 1, j] != '#')
                    {
                        cnt[i + 1, j] += cnt[i, j];
                        cnt[i + 1, j] %= mod;
                    }
                }
            }

            Console.WriteLine(cnt[H - 1, W - 1]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 23004
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int field[5][5];
int fv[5][5];

int main() {
    int m;
    scanf("%d", &m);
    while(m--) {
        for(int i=0; i<5; ++i) for(int j=0; j<5; ++j) scanf("%d", &field[i][j]);
        for(int i=0; i<5; ++i)
            for(int j=0; j<5; ++j) {
                if(i == 0) fv[i][j] = field[i][j];
                else if(field[i][j]) fv[i][j] = fv[i-1][j] + 1;
                else fv[i][j] = 0;
            }

        int ans = 0;
        for(int i=0; i<5; ++i) {
            vector<pair<int,int> > stk;
            stk.push_back(make_pair(0,0));
            stk.push_back(make_pair(0,fv[i][0]));

            for(int j=0; j<5; ++j) {
                if(fv[i][j] > stk.back().second) {
                    stk.push_back(make_pair(j,fv[i][j]));
                }else if(fv[i][j] < stk.back().second) {
                    int x = j;
                    while(!stk.empty()) {
                        if(stk.back().second < fv[i][j]) {
                            stk.push_back(make_pair(x,fv[i][j]));
                            break;
                        }else if(stk.back().second == fv[i][j]) break;
                        int tall = stk.back().second;
//                        printf("%d %d %d\n", i, j, tall*(j-stk.back().first));
                        ans = max(tall*(j-stk.back().first),ans);
                        x = stk.back().first;
                        stk.pop_back();
                    }
                }
            }

            while(!stk.empty()) {
                // printf("%d %d\n", stk.back().second, stk.back().first);
                // printf("%d %d %d\n", i, 4, stk.back().second*(5-stk.back().first));
                ans = max(stk.back().second*(5-stk.back().first), ans);
                stk.pop_back();
            }
        }

        printf("%d\n", ans);
    }
}

Measured memory_bytes: 0
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


# mathを使わない切り上げ
def ceil(n, m):
    return -(-n//m)


d, g = LI()
contest = [LI() for _ in range(d)]

ans = INF

# Bit全探索
for bit in range(1 << d):
    score = 0
    cnt = 0
    remain_max = -1

    # 各bitが立っているか確認
    for i in range(d):
        if bit >> i & 1:
            score += contest[i][0] * (i + 1) * 100 + contest[i][1]
            cnt += contest[i][0]
            continue
        # コンプリートしなかった問題の中で最も得点の高い問題をメモ
        remain_max = i

    if score >= g:
        ans = min(ans, cnt)
        continue

    need = ceil((g - score) // 100, remain_max + 1)

    if need >= contest[remain_max][0]:
        continue

    ans = min(ans, cnt + need)

print(ans)


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

approved = True

for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 != 0 and a[i]%5 != 0:
            approved = False
            break

if approved:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;


  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 0; i <= VMAX; i++) { 
    C[i] = 0;
  }

    for(i = 0; i < n; i++) {
        scanf("%hu", &A[i+1]);
        C[A[i + 1]]++;
    }

    for(i = 1; i <= VMAX; i++){ 
     C[i] = C[i] + C[i-1];
    }

    for(j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");


  return 0;
}


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

int main() {
  ll n, m, a, b;
  cin >> n >> m;
  vector<ll> h(n);
  map<int, int> ng;
  rep (i, n) cin >> h[i];
  rep (i, m) {
    cin >> a >> b;
    if (h[a - 1] == h[b - 1]) {
      ng.insert(make_pair(a, a));
      ng.insert(make_pair(b, b));
    } else if (h[a - 1] > h[b - 1]) {
      ng.insert(make_pair(b, b));
    } else {
      ng.insert(make_pair(a, a));
    }
  }
  cout << n - ng.size() << endl;
}


Measured memory_bytes: 6636
import math
a, b, x = list(map(int, input().split()))

h = x / (a**2)
if b - h <= b / 2:
    tan = ((b - h)*2) / a
    atan = math.degrees(math.atan(tan))
    print(atan)
else:
    tan = b / ((2 * (a*h)) / b)
    atan = math.degrees(math.atan(tan))
    print(atan)


Measured memory_bytes: 38384
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll inf = 1e18;
const ll mod1 = 1e9 + 7;
const ll mod2 = 228661337;
const ll N = (1 << 12) + 2;

#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
void include_file(bool a)
{
    if (!a) return;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}




int32_t main()
{
    shift();
    srand(time(0));
    include_file(false);
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    bool can = false;
    for(int i = 0; i < n; ++i)
    {
        for(int j = i; j < n; ++j)
        {
            swap(a[i], a[j]);
            bool g = true;
            for(int k = 1; k < n; ++k)
                g &= (a[k] >= a[k - 1]);
            can |= g;
            swap(a[i], a[j]);
        }
    }
    if (can)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>

#include <cstdio>
using namespace std;


int a1();
void a2();
int a3();
int a4();
int main()
{
	//cout << a1() << endl;
	//a2();
	//a3();
	a4();
	return 0;
}
//*********************4
//逆波兰表示
int a4()
{
	stack<int> s;
	string str;
	while (cin>>str)
	{
		//int t = stoi(str);
		//int t=atoi(str.c_str())
		if (str[0] == '+')
		{
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(a + b); //cout << s.top() << endl;
		}
		else if (str[0] == '-')
		{
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(b-a); //cout << s.top() << endl;
		}
		else if (str[0] == '*')
		{
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(a * b); //cout << s.top() << endl;
		}
		else
		{
			//cout << str << endl;
			s.push(stoi(str));
			//cout << s.top() << endl;
		}

	}
	cout << s.top() << endl;
	return 0;
}


Measured memory_bytes: 3176
#include<iostream>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    int s,w;
    cin >> s >> w;
    if(s <= w)     cout << "unsafe" << endl;
    else     cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<set> 
using namespace std;
set<int> mp;
int main(){
	int n=0;
	cin>>n;
	for(register int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(mp.count(x))mp.erase(x);
		else mp.insert(x);
	}
	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
int mod = 1e9 + 7;
int dp[100010][13];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    dp[0][0] = 1;
    rep(i, s.length())
    {
        if (s[i] == '?')
        {
            rep(k, 10)
            {
                rep(j, 13)
                {
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                    dp[i + 1][(j * 10 + k) % 13] %= mod;
                }
            }
        }
        else
        {
            int k = s[i] - '0';
            rep(j, 13)
            {
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + k) % 13] %= mod;
            }
        }
    }
    cout << dp[s.length()][5] << endl;
}

Measured memory_bytes: 5584
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort(reverse=True)
f.sort()
z = list(zip(a,f))
ok = max(x*y for x,y in z)
ng = -1
while ok-ng>1:
  mid = (ok+ng)//2
  if sum(x-mid//y for x,y in z if x*y > mid) <= k:
    ok = mid
  else:
    ng = mid
print(ok)

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

def main():
    l, k = map(int, input().split())

    dp = [[0] * 2 for i in range(101)]
    dp[0][1] = 1
    ans = 0
    for i in range(1, l+1):
        dp[i][0] = dp[i-1][1]
        if i-k >= 0:
            dp[i][0] += dp[i-k][1]
        dp[i][1] = dp[i-1][0]
        ans += dp[i][0]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        int N;
        long K;
        int[] A;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            N = in.Int();
            K = in.Long();
            A = in.Int(N);

            int[] cnt = new int[N];
            Arrays.fill(cnt, -1);
            cnt[0] = 0;
            int cur = 0;
            while (cnt[A[cur] - 1] < 0) {
                cnt[A[cur] - 1] = cnt[cur] + 1;
                cur = A[cur] - 1;
            }
            int ls = cnt[A[cur] - 1];
            int max = IntStream.of(cnt).max().getAsInt();
            int lc;
            if (K <= ls) {
                lc = (int) K;
            } else {
                lc = (int) ((K - ls) % (max + 1L - ls)) + ls;
            }
            for (int i = 0; i < N; i++) {
                if (cnt[i] == lc) {
                    out.println(i + 1);
                    return;
                }
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public long Long() {
            return Long.parseLong(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 56348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<vector<ll>> crossing(ll k, ll s){
    vector<vector<ll>> ans(0);
    if(k == 1){
        ans.push_back({s});
        ans.push_back({s});
        return ans;
    }
    ans.push_back({});
    rep(i, k){
        ans.at(0).push_back(i+s);
    }
    rep(i, k){
        ans.push_back({});
    }
    rep(i, k){
        ans.at(i+1).push_back(i+s);
    }
    vector<vector<ll>> tmp = crossing(k-1, k+s);
    rep(i, k){
        ans.at(i+1).insert(ans.at(i+1).end(), tmp.at(i).begin(), tmp.at(i).end());
    }
    return ans;
}

int main()
{
    ll N;
    cin >> N;
    ll k = 0;
    ll p = 0;
    rep(i, N+1){
        k += i;
        if(k > N){
            cout << "No" << endl;
            return 0;
        }
        if(k == N){
            p = i;
            break;
        }
    }
    vector<vector<ll>> ans = crossing(p, 1);
    cout << "Yes" << endl;
    cout << p+1 << endl;
    rep(i, p+1){
        cout << sz(ans.at(i)) << " ";
        rep(j, sz(ans.at(i))-1){
            cout << ans.at(i).at(j) << " ";
        }
        cout << ans.at(i).at(sz(ans.at(i))-1) << endl;
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXLG 60
#define MOD 1000000007

int N, count1[MAXLG + 3];

int main() {
    cin >> N;

    memset(count1, 0, sizeof(count1));
    for (int i = 1; i <= N; i++) {
        LL A;
        cin >> A;

        for (int lg = 0; lg <= MAXLG; lg++) {
            if (A & (1LL << lg))
                count1[lg] += 1;
        }
    }

    LL answer = 0;
    for (int lg = 0; lg <= MAXLG; lg++) {
        int count0 = N - count1[lg];

        LL temp1 = ((LL) count0 * count1[lg])%MOD;
        LL temp2 = (1LL << lg)%MOD;
        answer = (answer + (temp1 * temp2)%MOD)%MOD;
    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll p[5005],tr[5005],fac[5005],par[5005],dp[5005][5005],hell=pow(10,9)+7;
ll find(ll i){
	if(par[i]==i)
	return i;
	return par[i]=find(par[i]);
}
void merge(ll a,ll b){
	a=find(a),b=find(b);
	if(a==b)
	return ;
	par[b]=a;
}
void solve(){
	ll n,res=0,k=0;
	cin>>n;
	tr[0]=1;
	for(ll i=1;i<=n;i++){
		par[i]=i;
		tr[i]=((n-1)*tr[i-1])%hell;
	}
	for(ll i=1;i<=n;i++){
		cin>>p[i];
		if(p[i]==(-1)){
			k++;
			continue;
		}
		merge(i,p[i]);
	}
	vector<vector<ll>> g(5005);
	for(ll i=1;i<=n;i++)
	g[find(i)].push_back(i);
	vector<ll> v;
	for(ll i=1;i<=n;i++)
	if(!g[i].empty()){
		ll f=0;
		for(ll j=0;j<ll(g[i].size());j++)
		if(p[g[i][j]]==(-1))
		f=1;
		if(!f)
		res=(res-tr[k])%hell;
		else
		v.push_back(ll(g[i].size()));
	}
	ll m=ll(v.size());
	for(ll i=0;i<=m;i++)
	dp[i][0]=1;
	for(ll i=1;i<=m;i++)
	for(ll j=1;j<=k;j++)
	dp[i][j]=(dp[i-1][j]+v[i-1]*dp[i-1][j-1])%hell;
	for(ll i=2;i<=k;i++){
		ll val=(dp[m][i]*fac[i-1])%hell;
		val*=tr[k-i];
		val%=hell;
		res=(res-val)%hell;
	}
	for(ll i=0;i<m;i++)
	res=(res-(((v[i]-1)*tr[k-1])%hell))%hell;
	res+=(n*tr[k])%hell;
	res%=hell;
	if(res<0)
	res+=hell;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    fac[0]=1;
    for(ll i=1;i<5005;i++)
    fac[i]=(i*fac[i-1])%hell;
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 199680
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

int main() {
  int w,a,b;
  cin>>w>>a>>b;
  if(a > b) swap(a,b);
  cout<<max(0,b-(a+w));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main(){
  int n, m;
  cin >> n >> m;
  if(n==m){
    cout << "Yes" << endl;

  }else {
    cout << "No";
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] line1 = br.readLine().split(" ");
    int n = Integer.parseInt(line1[0]);
    int k = Integer.parseInt(line1[1]);
    
    String[] data = br.readLine().split(" ");
    int[] l = new int[n];
    for (int i=0; i<n; i++){
      l[i] = Integer.parseInt(data[i]);
    }
    Arrays.sort(l);
    int result = 0;
    for (int i=0; i<k; i++){
      result += l[l.length-i-1];
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define rrep(i,n,l) for(int i=n-1;i>=l;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	vi s(n);
	rep(i,0,n) cin>>s[i];
	int size=1;
	rep(i,1,n){
		if(s[i]!=s[i-size]){
			size=i+1;
		}
	}
	if(n%size==0) o(n/size);
	else o(1);
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    for(auto&& i : x){
        cin >> i;
    }
    for(auto&& i : y){
        cin >> i;
    }
    sort(rbegin(x), rend(x));
    sort(begin(y), end(y));
    if(max(X, x[0]) < min(Y, y[0])){
        cout << "No War\n";
    }else{
        cout << "War\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a, b, c;
	cin>>a>>b>>c;
	char fir = toupper(a[0]);
	char sec = toupper(b[0]);
	char thir = toupper(c[0]);
	cout<<fir<<sec<<thir<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        vs: [[usize; 3]; m],
    }

    let mut distance = vec![vec![100000; n]; n];
    for v in vs.iter() {
        distance[v[0] - 1][v[1] - 1] = v[2];
        distance[v[1] - 1][v[0] - 1] = v[2];
    }
    for x in 0..n {
        distance[x][x] = 0;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if distance[i][j] > distance[i][k] + distance[k][j] {
                    distance[i][j] = distance[i][k] + distance[k][j];
                }
            }
        }
    }

    let mut count = 0;
    for v in vs.iter() {
        if distance[v[0] - 1][v[1] - 1] != v[2] {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,T;
    vector<int> c(1000),t(1000);
    cin >> N>>T;
    int cost=1000;
    bool isTLE=true;
    for(int i=0;i<N;i++){
        cin >> c.at(i)>>t.at(i);
        if(t.at(i)<=T){
            isTLE=false;
            if(cost>c.at(i)){
                cost=c.at(i);
            }

        }
    }
    if(isTLE==true){
        cout<<"TLE"<<endl;
        return 0;
    }
    cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9 + 10)
#define PI (acos(-1))
#define MOD (1000000007)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }

int main() {
    int N;
    ll C;
    cin >> N;
    cin >> C;
    ll tempx[N], v[N];
        REP(i, N) {
        cin >> tempx[i];
        cin >> v[i];
    }
    ll x[N+1];
    RREP(i, N+1){
        if (i == N){
            x[i] = C - tempx[N-1];
        } else if (i == 0) {
            x[i] = tempx[i];
        } else {
            x[i] = tempx[i] - tempx[i-1];
        }
    }
    ll ans = 0;
    ll At[N+1];//反時計周りにi個食ったときのカロリー
    ll Bt[N+1];//時計回りにi個食って戻ってきたときのカロリー
    REP(i, N+1) {
        if (i == 0){
            At[i] = 0;
            Bt[i] = 0;
        } else {
            At[i] = At[i-1] + v[i-1] - x[i-1];
            Bt[i] = Bt[i-1] + v[N-i] - 2 * x[N+1-i];
        }
    }
    REP(i, N+1) {
        if (i != 0) {
            chmax(At[i], At[i-1]);
            chmax(Bt[i], Bt[i-1]);
        }
    }
    REP(i, N+1) {
        chmax(ans, Bt[i] + At[N-i]);
    }
    reverse(x, x + N + 1);
    reverse(v, v + N);

    REP(i, N+1) {
        if (i == 0){
            At[i] = 0;
            Bt[i] = 0;
        } else {
            At[i] = At[i-1] + v[i-1] - x[i-1];
            Bt[i] = Bt[i-1] + v[N-i] - 2 * x[N+1-i];
        }
    }
    REP(i, N+1) {
        if (i != 0) {
            chmax(At[i], At[i-1]);
            chmax(Bt[i], Bt[i-1]);
        }
    }
    REP(i, N+1) {
        chmax(ans, Bt[i] + At[N-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define inf 1000000000
using namespace std;
int maxi[4000009],a[1000009],len,locate,val,len1,b[1000009],maxii=-inf,ans,flag=1,n;
map<int,int>ma;
int pow1(int x)
{
    int res=1;
    for(int i=1;i<=x;i++)
        res*=2;
    return res;
}
void build(int left,int right,int o)
{
    int mid=(left+right)/2,lc=o*2,rc=o*2+1;
    if(left==right)
    {
        maxi[o]=left;
        return ;
    }
    build(left,mid,lc);
    build(mid+1,right,rc);
    maxi[o]=max(maxi[lc],maxi[rc]);
}
void update(int left,int right,int o)
{
    int mid=(left+right)/2,lc=o*2,rc=o*2+1;
    if(left==right)
    {
        maxi[o]=val;
        return ;
    }
    if(locate<=mid)
        update(left,mid,lc);
    else
        update(mid+1,right,rc);
    maxi[o]=max(maxi[lc],maxi[rc]);
}
void query(int left,int right,int o,int l,int r)
{
    if(!r)
        return ;
    int mid=(left+right)/2,lc=o*2,rc=o*2+1;
    if(l<=left&&r>=right)
    {
        ans=max(ans,maxi[o]);
        return ;
    }
    if(l<=mid)
        query(left,mid,lc,l,r);
    if(r>mid)
        query(mid+1,right,rc,l,r);
}
int main()
{
    scanf("%d",&n);
    len=pow1(n);
    for(int i=1;i<=len;i++)
        scanf("%d",&a[i]),ma[a[i]]++,maxii=max(maxii,a[i]);
    sort(a+1,a+1+len);
    len1=unique(a+1,a+len+1)-(a+1);
    build(1,len1,1);
    b[1]=lower_bound(a+1,a+len1+1,maxii)-a;
    ma[maxii]--;
    if(ma[maxii])
    {
        printf("No");
        return 0;
    }
    locate=b[1];
    val=-inf;
    update(1,len1,1);
    for(int i=0;i<=n-1;i++)
    {
        int tmp;
        tmp=pow1(i);
        for(int j=1;j<=tmp;j++)
        {
            locate=b[j];
            ans=-inf;
            query(1,len1,1,1,locate-1);
            if(ans==-inf)
            {
                flag=0;
                break;
            }
            ma[a[ans]]--;
            b[tmp+j]=ans;
            if(!ma[a[ans]])
            {
                locate=ans;
                val=-inf;
                update(1,len1,1);
            }
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 21760
#include<stdio.h>

int main(void){
    int a;
    int fir=0, sec=0, thi=0;
    int i;

    for ( i = 0; i < 10; i++ ) {
        scanf("%d", &a);
        if ( a >= fir ) {
            thi = sec;
            sec = fir;
            fir = a;
        } else if ( a >= sec ) {
            thi = sec;
            sec = a;
        } else if ( a >= thi ) {
            thi = a;
        }
    }
    printf("%d\n%d\n%d\n", fir, sec, thi);
    return 0;
}


Measured memory_bytes: 2076
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

if (g1.count(x) == 1 and g1.count(y) == 1) or (
        g2.count(x) == 1 and g2.count(y) == 1) or (g3.count(x) == 1
                                                   and g3.count(y) == 1):
    print('Yes')
else:
    print('No')


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

int64_t gcd(const int64_t &a,const int64_t &b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}

int main(){
  int64_t a,b;
  cin >> a >> b;

  cout << gcd(a,b) << endl;

  return 0;
}

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

char dic[52];

int main() {
  for (auto i = 0; i < 26; i++) {
    dic[i] = 'a' + i;
    dic[i+26] = 'A' + i;
  }
  int n;
  while (cin >> n && n) {
    int k[110];
    for (auto i = 0; i < n; i++) {
      cin >> k[i];
    }
    string s;
    cin >> s;
    for (auto i = 0; i < (int)s.size(); i++) {
      int a = 0;
      while (dic[a] != s[i]) {
        a++;
      }
      a -= k[i%n];
      if (a < 0) {
        a += 52;
      }
      s[i] = dic[a];
    }
    cout << s << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << ' ' << i;
    } else {
      while (1) {
        if (x % 10 == 3) {
          cout << ' ' << i;
          break;
        }
        x /= 10;
        if (!x) {
          break;
        }
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define int long long
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int n,k;
vector<int>v(n);
int valid(int x)
{
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]<=x)
            continue;
        cnt+=(v[i])/x;
    }
    return cnt;
}
int32_t main()
{
    FASTIO;
    cin>>n>>k;
    int x;
    int mx=INT_MIN;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mx=max(mx,x);
        v.push_back(x);
    }
    int low=1;
    int high=mx;
    if(k==0)
    {
        cout<<mx;
        return 0;
    }
    int ans=-1;
    while(low<=high)
    {
        int mid=(low+high)/2;
        if(valid(mid)<=k)
        {
            ans=mid;
            high=mid-1;
        }
        else
            low=mid+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5284
/*  -*- coding: utf-8 -*-
 *
 * 2894.cc: Binary String with Slit
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

char s[MAX_N + 2], t[MAX_N + 2];

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    scanf("%s%s", s, t);

    int n = strlen(s), k = 0;
    while (k < n && s[k] == t[k]) k++;
    if (k >= n) {
      puts("0");
      continue;
    }

    int se = n - 1, te = n - 1;
    while (s[se] == '0') se--;
    while (t[te] == '0') te--;
    //printf("n=%d, k=%d, se=%d, te=%d\n", n, k, se, te);

    int cnt = 0;
    if (se > k) cnt += se - k, se = k;
    cnt += abs(te - se);
    printf("%d\n", cnt);
  }
  return 0;
}



Measured memory_bytes: 3232
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

def islands_war(AB):
    AB.sort(key=lambda x: x[1])
    ans = 1
    bridge = AB[0][1] - 1
    for ab in AB:
        if bridge < ab[0]:
            bridge = ab[1] - 1
            ans += 1
    return ans

ans = islands_war(AB)
print(ans)


Measured memory_bytes: 29056
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> sp(n);
  rep(i, n) {
    int v;
    cin >> v;
    p[i] = sp[i] = v;
  }
  sort(sp.begin(), sp.end());
  int cnt = 0;
  rep(i, n)
  {
    if (p[i] != sp[i])
      cnt++;
    if (cnt >= 3)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

vector<int> edg[2005];
vector<int> ch[2005];
int cac[2005][2005];
int n, k, ans;

void dfs(int at, int par=-1)
{
	for (int u: edg[at]) if (u != par)
	{
		ch[at].push_back(u);
		dfs(u, at);
	}
}

int slv(int at, int far)
{
	if (cac[at][far]) return cac[at][far];
	if (far == 0) return cac[at][far]=1;
	if (ch[at].size() >= 1) for (int u: ch[at])
		cac[at][far] = max(cac[at][far], slv(u, far-1));
	if (ch[at].size() >= 2) for (int a = 0;a < far;a++)
	{
		int b = min(far, k-a-1)-1;
		if (b >= 0)
		{
			int t1 = 0, w1 = -1, t2 = 0;
			for (int u: ch[at])
			{
				int alt = slv(u, b);
				if (alt > t1)
				{
					t2 = t1;
					t1 = alt; w1 = u;
				} else if (alt > t2)
					t2 = alt;
			}
			for (int u: ch[at])
			{
				int alt = slv(u, a);
				if (u == w1) alt += t2;
				else alt += t1;
				if (alt > cac[at][far]) cac[at][far] = alt;
			}
		}
	}
	if (ch[at].size() >= 3) for (int giv = 0;giv < far;giv++)
	{
		if (giv+giv+2 > k) break;
		int tot = 0;
		for (int u: ch[at]) tot += slv(u, giv);
		int here = min(far, k-giv-1)-1;
		if (here >= 0) for (int u: ch[at])
		{
			int alt = tot;
			alt -= slv(u, giv);
			alt += slv(u, here);
			cac[at][far] = max(cac[at][far], alt);
		}
	}
	return ++cac[at][far];
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1;i < n;i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		--a, --b;
		edg[a].push_back(b);
		edg[b].push_back(a);
	}
	dfs(0);
	for (int i = 0;i < n;i++)
		ans = max(ans, slv(i, k));
	printf("%d\n", n-ans);
	return 0;
}


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


long dp(long i,vector<long>& h,long k,vector<long>& arr){
    long n=h.size()-1;
  	if(i==n) return 0;
     if(arr[i]!=-1) return arr[i];
  long ans=std::numeric_limits<int>::max();
  if(i<n-(k-1)){
      for(int l=1;l<=k;l++){
   ans=min(abs(h[i]-h[i+l])+dp(i+l,h,k,arr) , ans);
      }
  arr[i]=ans;
  return ans;
  }
  for(int l=1;l<=n-i;l++) ans=abs(h[i]-h[i+l]+dp(i+l,h,k,arr));
  arr[i]=ans;
	return ans;
	//memset(array, 0, sizeof(array[0][0]) * m * n);

}
int main(){
   // memset(arr, -1, sizeof(arr[0]) * 100000);
	long n,x,k;
	vector<long> arr(100000,-1);
  	cin>>n;
  	cin>>k;
  vector<long> v;
  	for(int i=0;i<n;i++){
      cin>>x;
      v.push_back(x);
    }
  long ans=dp(0,v,k,arr);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11252
using System;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    if (n == 1) {
      Console.WriteLine("Hello World");
    } else {
      int a = int.Parse(Console.ReadLine());
      int b = int.Parse(Console.ReadLine());
      Console.WriteLine(a + b);
    }
  }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
vec v , v2;
int a[1003] , b[1003] , c[1003];
signed main(){
  fast;
  int x , y , z , k;
  cin >> x >> y >> z >> k;
  for(int i = 1 ; i<=x ; i++)
    cin >> a[i];
  for(int i = 1 ;i <=y  ; i++)
    cin >> b[i];
  for(int i = 1 ; i<=z ; i++)
      cin >> c[i];


    for(int i = 1 ; i<= x ; i++ )
      for(int j = 1 ; j<= y ; j++)
         v.pb(a[i] + b[j]);

  sort(v.rbegin() , v.rend());
  int l = v.size();
  for(int i = 0 ; i < min((int)3000 , l) ; i++)
    for(int j = 1 ; j<= z ; j++)
        v2.pb(v[i] + c[j]);

  sort(v2.rbegin() , v2.rend());
  for(int i = 0 ; i < k ; i++)
    cout << v2[i] << endl;


}	





Measured memory_bytes: 43364
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")

	tmp2 := strings.Split(tmp, " ")
	n, _ := strconv.ParseInt(tmp2[0], 10, 64)
	m, _ := strconv.ParseInt(tmp2[1], 10, 64)

	var ans int64

	if n >= 2 {
		ans = n * (n - 1) / 2
	}

	if m >= 2 {
		ans += m * (m - 1) / 2
	}

	fmt.Printf("%d\n", ans)

}


Measured memory_bytes: 640
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    ll counter = 0;
    REP(i, S.length()) {
        if (i % 2 == 0) {  //実質奇数番目の文字
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') continue;
            counter++;
        } else {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') continue;
            counter++;
        }
    }
    if (counter == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

#define fto(i, x, y) for(auto i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(auto i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(auto i = (x); i <= (y); i += a)
#define ftoit(it, var) for (auto it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define ff first
#define ss second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 500007

int a[7];

int main() {
	
	scanf("%d%d%d%d", &a[1], &a[2], &a[3], &a[4]);	
	sort(a+1, a+5);

	if (a[1] == 1 && a[2] == 4 && a[3] == 7 && a[4] == 9) puts("YES");
	else puts("NO");

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] a){

		Scanner sc = new Scanner(System.in);





		while(sc.hasNext()) {
			int count = 0;
			int n = sc.nextInt();

			for(int i = 1; i <= n; i++) {
				if(isPrime(i)) {
					count++;
				}
			}


			System.out.println(count);
		}



	}






	public static boolean isPrime(int n) {

		if(n == 1){return false;}
		if(n == 2) {return true;}
		if(n%2 == 0){return false;}

		for(int i = 3;i <= Math.sqrt(n); i = i+2) {
			if((n%i) == 0) {
				return false;
			}
		}

		return true;

	}



}

Measured memory_bytes: 26616
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int K;
	cin>>K;
	int e=0,o=0;
	if(K%2==0){
		e=K/2;
		o=e;
	}else{
		e=(K-1)/2;
		o=e+1;
	}
	cout<<e*o<<endl;

	return 0;
}

Measured memory_bytes: 256