akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Shuffle
 * JOI 8th, Pre 5
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			int m = parseInt(br.readLine());

			words = br.readLine().split(" ");

			int p, q, r;
			p = parseInt(words[0]);
			q = parseInt(words[1]);
			r = parseInt(words[2]);

			//shuffle
			//ABC -> CBA
			Deque<int[]> ABC = new ArrayDeque<>();
			ABC.offer(new int[]{1, n});

			for (int i = 0; i < m; i++) {
				line = br.readLine();

				int x, y;
				x = parseInt(line.substring(0, line.indexOf(' ')));
				y = parseInt(line.substring(line.indexOf(' ') + 1));
				y -= x;

				Deque<int[]> A = head(ABC, x);
				Deque<int[]> B = head(ABC, y);

				//C+B+A
				for (int[] b : B) ABC.offer(b);
				for (int[] a : A) ABC.offer(a);
			}

			//solve
			int count = 0;
			p--;
			q -= p;

			head(ABC, p);
			ABC = head(ABC, q);

			for (int[] c : ABC) {
				if (c[1] <= r) {
					count += c[1] - c[0] + 1;
				} else if (c[0] <= r && r < c[1]) {
					count += r - c[0] + 1;
				}
			}

			System.out.println(count);

		}
	}

	static Deque<int[]> head(Deque<int[]> deque, int size) {

		Deque<int[]> head = new ArrayDeque<>();

		while (size > 0) {
			int _x = deque.peek()[1] - deque.peek()[0] + 1;
			if (size == _x) {
				head.offer(deque.poll());
				size = 0;
			} else if (size > _x) {
				head.offer(deque.poll());
				size -= _x;
			} else if (size < _x) {
				head.offer(new int[]{
						deque.peek()[0],
						deque.peek()[0] + size - 1
				});
				deque.peek()[0] = deque.peek()[0] + size;
				size = 0;
			}
		}

		return head;
	}
}

Measured memory_bytes: 170328
n = int(input())
query = [0]*1001
mod = 10**9+7
tmp = n
for tmp in range(1,n+1):
 for i in range(2,1002):
  while tmp%i == 0:
   query[i-1] += 1
   tmp = tmp//i
ans = 1
for i in query:
  ans= ans*(1+i)%mod
print(ans%mod)


Measured memory_bytes: 3060
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

/*全てのライブラリをインクルード*/
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << "A" << s2[0] << "C" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	init();
	ll A,B,C,D;cin>>A>>B>>C>>D;
	cout<<max(0LL,min(B,D)-max(A,C))<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int a[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int n;

   scanf("%d",&n);
   printf("%d\n",a[n-1]);
   return 0;
}


Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
int main() {
	string sd, t, s;
	cin >> sd >> t;
	for (int i = sd.size() - t.size(); i >= 0; i--) {
		s = sd;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] == '?') {
				s[i + j] = t[j];
			}
			else if (s[i + j] != t[j]) {
				break;
			}
			if (j == t.size() - 1) {
				for (int k = 0; k < sd.size(); k++) {
					if (s[k] == '?') {
						s[k] = 'a';
					}
				}
				cout << s << endl;
				return 0;
			}
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1, -100), B(N + 1,-100), C(N,-100);
	for (int n = 1; n <= N; n++) {
		cin >> A[n];
	}
	for (int n = 1; n <= N; n++) {
		cin >> B[n];
	}
	for (int n = 1; n < N; n++) {
		cin >> C[n];
	}
	int res = 0;
	for (int n = 1; n <= N; n++) {
		res += B[A[n]];
		if (n + 1 <= N && A[n + 1] == A[n] + 1) {
			res += C[A[n]];
		}


	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3628
r1,c1,r2,c2=map(int,input().split())
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**6+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
print((cmb(c2+r2+2,c2+1,mod)-cmb(c2+r1+1,c2+1,mod)-cmb(c1+r2+1,c1,mod)+cmb(c1+r1,c1,mod)+mod)%mod)

Measured memory_bytes: 132932
#include<bits/stdc++.h>
using namespace std;
#define lb(x) ((x)&(-x))
int c[27][200005];
char ch[200005];
int l[100005],r[100005],n,totl=0,totr=0,f=27;
int fd[200005],ad[100005];
int v[200005];
void add(int x,int a){
	while(x<=totr)v[x]+=a,x+=lb(x);
}
int V(int x){
	int res=0;while(x)res+=v[x],x-=lb(x);return res;
}
int main(){
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for(int j=1;j<=n;++j){
		c[ch[j]-'a'][++c[ch[j]-'a'][0]]=j;
	}
	// for(int i=0;i<=26;++i)cout<<c[i][0]<<endl;
	for(int i=0;i<26;++i){
		if(c[i][0]%2){
			// cout<<f<<endl;
			if(f<27||n%2==0){
				puts("-1");return 0;
			}
			f=i;fd[c[i][c[i][0]/2+1]]=0;
		}
		for(int j=1;j<=c[i][0]/2;++j){
			fd[c[i][j]]=-1;
			fd[c[i][c[i][0]-j+1]]=1;
		}
	}
	int g=0;
	long long res=0;
	for(int i=1;i<=n;++i){
		if(fd[i]==0)g=1,res+=totr;
		if(fd[i]==1)r[++totr]=ch[i]-'a';
		if(fd[i]==-1)l[++totl]=ch[i]-'a',res+=totr+g;
	// cout<<res<<endl;
	}
	// for(int i=1;i<=n;++i)cout<<fd[i]<<' ';cout<<endl;
	// cout<<res<<endl;
	// for(int i=1;i<=totr;++i)cout<<r[i]<<' ';cout<<endl;
	memset(c,0,sizeof c);
	for(int j=1;j<=totr;++j){
		c[r[j]][++c[r[j]][0]]=totr-j+1;
	}
	for(int i=1;i<=totl;++i){
		res+=c[l[i]][c[l[i]][0]]+V(totr-c[l[i]][c[l[i]][0]]+1)-i;
		// if(c[l[i]][c[l[i]][0]]>i)
		add(totr+1-c[l[i]][c[l[i]][0]--],1);
		// if(ad[i]==1)add(totr+1-i,-1);
	// cout<<res<<V(totr-i+1)<<endl;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 23552
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List <Integer> queue = new ArrayList<Integer>(200000);
        for(int i = 0; i < n; i++){
            int command = sc.nextInt();
            switch(command){
                case 0:
                    queue.add(sc.nextInt());
                    break;
                case 1:
                    System.out.println(queue.get(sc.nextInt()));
                    break;
                case 2:
                    queue.remove(queue.size() - 1);
            }
            
        }
    }
}



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s, t; cin >> s >> t;

    int a, b; cin >> a >> b;

    string u; cin >> u;

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

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {
int N;
	char S[1000][2];
	int end=0;
	scanf("%d", &N);
	for (int i=1; i<=N; i++) {
		scanf("%s", &S[i-1]);
		if(S[i-1][0]== 'Y'){
			end=1;
			break;
		}
	}
	if (end==1) printf("Four");
	else printf("Three");
return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
#define inf 99999999999;
int root[200001];

int find(int x){
	if(x!=root[x]){
		root[x] = find(root[x]);
	}
	return root[x];
}
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x!=y){
		root[x]=y;
	}
	return ;
}
int main(){
	for(int i=0;i<=200000;i++){
		root[i]=i;
	}
	vector <pair<long long,pair<int,int> > > node;
	int n,q;
	cin >> n >> q;
	int a,b;
	long long c;
	long long d[200001];
	long long ans=0;
	for(int i=0;i<n;i++){
		d[i]=inf;
	}
	for(int i=0;i<q;i++){
		cin >> a >> b >> c;
		if(a!=b+1||a!=b-1||a!=b){
			pair<long long,pair<int,int> > tmp;
			tmp = make_pair(c,make_pair(a,b));
			node.push_back(tmp);
		}
		d[a]=min(d[a],c+1);
		d[b]=min(d[b],c+2);
	}
	for(int i=0;i<n;i++){
		if(i==n-1){
			d[0] = min(d[0],d[n-1]+2);
		}else{
			d[i+1] = min(d[i+1],d[i]+2);
		}
	}
	for(int i=0;i<n;i++){
		if(i==n-1){
			d[0] = min(d[0],d[n-1]+2);
		}else{
			d[i+1] = min(d[i+1],d[i]+2);
		}
	}
	for(int i=0;i<n;i++){
		pair<long long,pair<int,int> > tmp2;
		if(i!=n-1)tmp2 =make_pair(d[i],make_pair(i,i+1));
		else tmp2 = make_pair(d[i],make_pair(n-1,0));
		node.push_back(tmp2); 
	}
	sort(node.begin(),node.end());
	for(int i=0;i<node.size();i++){
		if(find(node[i].second.first)!=find(node[i].second.second)){
			ans+=node[i].first;
			union_set(node[i].second.first,node[i].second.second);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std; 

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

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

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

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

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

int n;
VI a;
VVI e;
vector<bool> visited;
VI dp;
VI result;

void dfs(int now, int point){
    auto itr = lower_bound(dp.begin(), dp.begin()+point, a[now]);
    int change = *itr;
    *itr = a[now];
    //dump(now)
    //dump(point)
    //dump(itr-dp.begin())

    if(itr-dp.begin() >= point){
        point++;
    }
    result[now] = point;

    for(auto next : e[now]){
        if(visited[next]){
            continue;
        }
        visited[next] = true;
        dfs(next,point);
    }

    *itr = change;

}

void Main()
{
    cin>>n;

    a.resize(n);
    REP(i,n){
        cin>>a[i];
    }

    e.resize(n);
    REP(i,n-1){
        int x,y;cin>>x>>y;
        x--;
        y--;
        e[x].PB(y);
        e[y].PB(x);
    }

    dp.resize(n+10,INF);
    visited.resize(n,false);
    result.resize(n);

    visited[0] = true;
    dfs(0,0);

    REP(i,n){
        cout<<result[i]<<endl;
    }



	return;
}

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

Measured memory_bytes: 30824
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var one = cin.ReadLine.Split(' ');
            var A = int.Parse(one[0]);
            var B = int.Parse(one[1]);
            var C = int.Parse(one[2]);

            var m = B / A;

            int result = 0;
            if (m-C > 0)
            {
                result = C;
            }
            else
            {
                result = m;
            }
            Console.Write(result);
        }

    }
    public class deci
    {
        public bool IsFinish { get; set; } = false;
        public int Len { get; set; }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N,M=mis()
    print('Yes' if N==M else 'No')


main()


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n,m;
    cin2(n,m);
    lli x[n];
    lli y[n];
    lli z[n];
    ncin3(n,x,y,z);

    lli ans = 0;
    REP(i,0,8) {
        lli sum[n];
        REP(j,0,n) {
            lli val = 0;
            if (i & 1) {
                val += x[j];
            }
            else {
                val -= x[j];
            }
            if (i & 2) {
                val += y[j];
            }
            else {
                val -= y[j];
            }
            if (i & 4) {
                val += z[j];
            }
            else {
                val -= z[j];
            }
            sum[j] = val;
        }
        sort_r(sum, sum+n);
        lli cur_ans = 0;
        REP(j,0,m) {
            cur_ans += sum[j];
        }
        ans = max(ans, cur_ans);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

}

Measured memory_bytes: 22612
#include<cstdio>
#include<cctype>

int main(){
 char ch;

 while(1){
  scanf("%c", &ch);
  if(isalpha(ch)){
   if(islower(ch)) printf("%c", toupper(ch));
   else printf("%c", tolower(ch));
  } else printf("%c", ch);

  if(ch == '\n') break;
 }

 return 0;
}

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

int main(){
  int N;

  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  bool ans = false;
  if(a[N - 1] == 0){
    ans = true;
  }

  if(
     (N % 3 == 0) &&
     (a[0] == a[N / 3 - 1]) &&
     (a[N / 3] == a[2 * N / 3 - 1]) &&
     (a[2 * N / 3] == a[N - 1]) &&
     ((a[0] ^ a[N / 3] ^ a[2 * N / 3]) == 0)
     ){
    ans = true;
  }

  cout << (ans? "Yes": "No") << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int w,h,n,a,b,c;
bool li[110][110]={};

int main(){
	cin >> w >> h >> n;
	REP(q,0,n){
		cin >> a >> b >> c;
		if(c == 1) REP(i,0,h) REP(j,0,a) li[i][j] = true;
		else if(c == 2) REP(i,0,h) REP(j,a,w) li[i][j] = true;
		else if(c == 3) REP(i,0,b) REP(j,0,w) li[i][j] = true;
		else if(c == 4) REP(i,b,h) REP(j,0,w) li[i][j] = true;
	}
	
	int c = 0;
	REP(i,0,h) REP(j,0,w) c += 1-li[i][j];
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(unsigned long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 510000;


int main() {
  int a,b;
  cin >> a >> b;
  int s=0,t=0;
  rep(i,b){
    s=s*10+a;
  }
  rep(i,a){
    t=t*10+b;
  }
  if(to_string(s)<to_string(t))cout <<s<< endl;
  else cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main()
{
	llong N;
	cin >> N;

	llong ans;

	if (N % 2 == 0) {
		ans = (N / 2) * (N - 1);
	} else {
		ans = N * (N - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
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 == 1 && b == 3 || a == 3 && b == 1) {
      System.out.println("2");
    }

    if (a == 2 && b == 3 || a == 3 && b == 2) {
      System.out.println("1");
    }

    if (a == 1 && b == 2 || a == 2 && b == 1) {
      System.out.println("3");
    }
  }
}


Measured memory_bytes: 23764
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    s = getS()
    k = getN()

    sn = [ord(i) - ord("a") for i in s]
    for i, c in enumerate(sn):
        if c != 0:
            if k >= 26 - c:
                k -= 26 - c
                sn[i] = 0

    sn[-1] = (sn[-1] + k) % 26

    # print(sn)

    print("".join([chr(i + ord("a")) for i in sn]))



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;

  bool flag = false;
  if(a==b && a!=c) flag = !flag;
  else if(a==c && a!=b) flag = !flag;
  else if(b==c && b!=a) flag = !flag;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define INF 1e9
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

class TaskA {
public:
    void solve() {
        char c;
        cin >> c;
        if (int(c) == 122) {
          cout << char(97);
          return;
        }
        cout << char(int(c + 1));
    }
};

int main() {
//    freopen("absum.in","r",stdin);
//    freopen("absum.out","w",stdout);
    TaskA solver;
    solver.solve();
}


Measured memory_bytes: 256
def resolve():
    '''
    code here

    '''
    import math

    N, M = [int(item) for item in input().split()]

    deff = N - M

    if deff == 0:
        temp = math.factorial(N)
        res = (temp**2 * 2) % (10**9+7)

    elif abs(deff) == 1:
        res = (math.factorial(N) * math.factorial(M)) % (10**9+7)

    else:
        res = 0
    
    print(res)

if __name__ == "__main__":
    resolve()


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max<int>({
        10*a+b+c,
        10*b+a+c,
        10*c+a+b
    })<<endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll n,a[20][20];
ll sum[1<<16];
ll dp[1<<16];

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	return;
}

void solve(){
	for(int i=1;i<(1<<n);i++){
		for(int j=0;j<n;j++)for(int k=j+1;k<n;k++){
			if((i&(1<<j))&&(i&(1<<k)))sum[i]+=a[j][k];
		}
	}
	for(int i=1;i<(1<<n);i++){
		for(int j=i;;j=(j-1)&i){
			dp[i]=max(dp[i],sum[j]+dp[i^j]);
			if(j==0)break;
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return;
}

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

Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 105;
char s[maxn];
int last[maxn], gap[maxn];
int main() {
	scanf("%s", s+1);
	int N = strlen(s+1);
	for(int i=1; i<=N; ++i) {
		int c = s[i]-'a';
		gap[c] = max(gap[c], i-last[c]-1);
		last[c] = i;
	}
	for(int c=0; c<26; ++c) 
		gap[c] = max(gap[c], N-last[c]);
	int ans = N;
	for(int c=0; c<26; ++c) 
		ans = min(ans, gap[c]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#include <tuple>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 最大公約数
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
#pragma endregion

#pragma region 最小公倍数
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
#pragma endregion

#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int a, b;
    cin >> a >> b;
    

    string a_str = "", b_str = "";

    forn(i, b)
    {
        a_str += ToString(a);
    }
    forn(i, a)
    {
        b_str += ToString(b);
    }

    if (a_str < b_str)
    {
        printf("%s\n", a_str.c_str());
    }
    else
    {
        printf("%s\n", b_str.c_str());
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define mod 1000000007
#define md 998244353 
#define N 2e5+10
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;


int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll d,s,t;
  cin>>d>>s>>t;
  if(s*t>=d)
    Yes
  else
    No
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int ans;
  
  for(int i = 0l; i < N; i++) {
    int h;
    cin >> h;
    if(h >= K) {
      ans++;
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 256
n=int(input())
l=[0]
l+=list(map(int,input().split()))
l.append(0)
tmp=0
for i in range(1,n+2):
  tmp+=abs(l[i]-l[i-1])

for i in range(n):
  v=abs(l[i+2]-l[i+1])+abs(l[i+1]-l[i])
  v2=abs(l[i+2]-l[i])
  print(tmp-abs(v2-v))

Measured memory_bytes: 14176
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int dp[3001][3001];
ll n, t, s;
struct A {
	int a, b;
};
A a[3000];
int solve(ll i, ll j) {
	if (i == n) return 0;
	int sum = 0;
	if (j + a[i].b <= t) {
		if (j<s&&j + a[i].b>s&&s+a[i].b<=t) {
			if (dp[i + 1][s + a[i].b] != -1) {
				sum = max(sum, a[i].a + dp[i + 1][s + a[i].b]);
			}
			else {
				sum = max(sum, a[i].a +
					(dp[i + 1][s + a[i].b] = solve(i + 1, s + a[i].b)));
			}
		}
		else if (!(j<s&&j + a[i].b>s)){
			if (dp[i + 1][j + a[i].b] != -1) {
				sum = max(sum, a[i].a + dp[i + 1][j + a[i].b]);
			}
			else {
				sum = max(sum, a[i].a +
					(dp[i + 1][j + a[i].b] = solve(i + 1, j + a[i].b)));
			}
		}
	}//??????
	if (dp[i + 1][j] != -1) {
		sum = max(sum, dp[i + 1][j]);
	}
	else {
		sum = max(sum, dp[i + 1][j] = solve(i + 1, j));
	}//????????????
	return sum;
}
int main() {
	while (cin >> n >> t >> s) {
		for (ll i = 0; i < n; i++) {
			cin >> a[i].a >> a[i].b;
			for (ll j = 0; j <= t; j++) {
				dp[i][j] = -1;
			}
		}
		cout << solve(0, 0) << endl;
	}
}

Measured memory_bytes: 38432
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
void dfs(ll n){
  if(n==0) return;
  n--;
  ll i = n%26;
  dfs(n/26);
  cout << (char)('a'+i);
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  cin >> n;
  dfs(n);
  cout << "\n";
  return 0;
}

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl

int f(int x) {

	int sum = 0;

	for(int i = 1; ; i++) {
		sum += i;
		if(sum > x) return (i-1);
	}
}

int main() {

	fast_cin;
	
	long long n;
	cin >> n;

	int ans = 0,cnt;

	for(long long i = 2; i*i <= n; i++) {
		
		if(n % i == 0) {
			cnt = 0;

			while(n % i == 0) {
				n /= i; cnt++;
			}

			ans += f(cnt);
		}
	}

	if(n > 1) ans += f(1);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc67
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            str = Console.ReadLine().Split(' ');
            int[] l = new int[N];
            int ans = 0;
            for(int i = 0; i < N; i++)
            {
                l[i] = int.Parse(str[i]);
            }
            Array.Sort(l);
            for(int i = 0; i < K; i++)
            {
                ans += l[N - 1 - i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL sum1[100005]={};
LL A[100005]={};
LL sum2[100005]={};
int main()
{
    int a,b;
    while(cin>>a>>b){
            LL z=0;
       for(int i=1;i<=a;i++){
        cin>>A[i];
       }
       for(int i=1;i<=a;i++){
        sum1[i]=sum1[i-1]+max(z,A[i]);
        sum2[i]=sum2[i-1]+A[i];
       }
       LL ans=0;
       for(int i=1;i+b-1<=a;i++){
        ans=max(ans,(sum1[a]-sum1[i+b-1] )+sum1[i-1] -max(z,sum2[i+b-1]-sum2[i-1]) );
     ans=max(ans,(sum1[a]-sum1[i+b-1] )+sum1[i-1] +max(z,sum2[i+b-1]-sum2[i-1]) );
       }
       cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  int N,M;
  string S;
  cin>>N>>M>>S;
  vector<int> a;
  int i=N;
  bool flag=true;
  while(i>0){
    if(i<=M){
      a.push_back(i);
      i=0;
    }else{
      bool sub=false;
      for(int j=M;j>0;j--){
        if(S.at(i-j)=='0'){
          a.push_back(j);
          i-=j;
          sub=true;
          break;
        }
      }
      if(!sub){
        flag=false;
        break;
      }
    }
  }
  if(flag){
    for(int i=a.size()-1;i>=0;i--){
      cout<<a.at(i)<<" ";
    }
    cout<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;

vector<int>g[200010];


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n;
    rep(i,0,n-1){
        cin>>a;
        a--;
        g[a].push_back(i+1);
    }
    rep(i,0,n){
        cout<<g[i].size()<<endl;
    }
}

Measured memory_bytes: 14596
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod - a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if (t == 0) return mint(1);
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
class modutils {
 vector<mint> fact, invfact;

 public:
  modutils(int n = 200005) : fact(n + 1), invfact(n + 1) {
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    invfact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) invfact[i - 1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) { return x.pow(n); }
  mint comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * invfact[k] * invfact[n - k];
  }
  mint perm(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] * invfact[n - k];
  }
  mint fac(ll n) { return fact[n]; }
};

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

  modutils mu;
  mint ans = mu.pow(n, m);

  cout << ans.x << endl;

  return 0;
}



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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

void solve() {
    ll n, W;
    cin >> n >> W;
    vector<ll> dp(W+1, 0);
    for (int i = 0; i < n; ++i) {
        int v, w;
        cin >> w >> v;
        for (int j = W-w; j >= 0; --j) {
            dp[j + w] = max(dp[j+w], dp[j] + v);
        } 
    }
    ll ans = 0;
    for (int i = 0; i <=W; ++i) {
        ans = max(ans, dp[i]);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

//  freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr); 
//  freopen ("out.txt", "w", stdout);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF pow(10,10)

vector<vector<ll>>g(100005);
vector<ll>memo(100005,-1);

ll pass(int v){
    if(memo[v]==-1){
        if(g[v].size() <= 0){
            memo[v]=0;
        } 
        else{
            ll max_pass = 0;
            for(int i=0;i<g[v].size();i++){
                ll tmp = pass(g[v][i]);
                if(max_pass < tmp) max_pass = tmp;
            }
            memo[v] = max_pass+1;
        }
    } 
    return memo[v];
}

int main(void){
    ll n,m; cin >> n >> m;
    for(int i=0;i<m;i++){
        ll x,y; cin >> x >> y; x--;y--;
        g[x].push_back(y);
    }
    for(int i=0;i<n;i++){
        pass(i);
    }
    cout << *max_element(memo.begin(),memo.end()) << endl;
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int n;
    cin >> n;
    deque<int> ans;
    bool even = false;
    if (n%2 == 0) even = true;
    rep(i,n) {
        int c;
        cin >> c;
        if ((i%2 == 0) ^ even) ans.push_front(c);
        else ans.push_back(c);
    }
    rep(i,ans.size()-1) {
        cout << ans.at(i) << " ";
    }
    ct(ans.at(ans.size()-1));
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    int n;
    if(b<=9){
        n = a*10+b;
    }
    else if(b<=99){
        n = a*100+b;
    }
    else{
        n = a*1000+b;
    }
    int i;
    int ans = 0;
    for(i=1; i<=350; i++){
        if(i*i == n){
            ans++;
        }
    }

    if(ans>0){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

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

int keta(int k){

    return k%10;
}
int main(void){
    
   int k,k_l;
   cin >> k;
   k_l = keta(k);
   
   if(k_l == 3){
       cout << "bon" << endl;
   }
   else if(k_l == 0 || k_l == 1 || k_l == 6 || k_l == 8){
       cout << "pon" << endl;
   } 
   else{
       cout << "hon" <<endl;
   }
}

Measured memory_bytes: 3544
import math
N = int(input())

x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())

sum = 0
M = math.factorial(N-1)
for i in range(N):
    for j in range(N):
           sum += math.sqrt((x[j]-x[i])*(x[j]-x[i]) + (y[j]-y[i])*(y[j]-y[i])) * M


print(sum/math.factorial(N))

Measured memory_bytes: 3064