akhauriyash/Code-Regression huggingface dataset:
from collections import deque

N = int(input())
# mtx = np.zeros([N, N], dtype=np.int32)
tree = [[] for i in range(N)]

key_order = [0] * (N-1)
for i in range(N-1):
    in1, in2 = map(int, input().split())
    in1 -= 1
    in2 -= 1
    tree[in1].append(in2)
    tree[in2].append(in1)

    key_order[i] = (in1, in2)

# [print(i, t) for i, t in enumerate(tree)]


def bfs(tree, p):
    seen = [False] * len(tree)
    queue = deque((p,))

    edge_colors = dict()
    node_colors = [0] * len(tree)
    while len(queue) > 0:
        q = queue.popleft()
        seen[q] = True

        parent_color = node_colors[q]

        cnt = 1
        for v in tree[q]:
            if not seen[v]:
                if cnt == parent_color:
                    cnt += 1

                edge_colors[(q, v)] = cnt
                node_colors[v] = cnt
                queue.append(v)
                cnt += 1



    """
    node_colors = [set() for _ in tree]
    edge_colors = dict()
    all_colors = set()
    color = 0

    while len(queue) > 0:
        q = queue.popleft()
        seen[q] = True

        for v in tree[q]:
            if not seen[v]:
                residual = all_colors - node_colors[q]
                if len(residual) > 0:
                    this_color = residual.pop()
                else:
                    color += 1
                    this_color = color
                edge_colors[(q, v)] = this_color
                node_colors[q].add(this_color)
                node_colors[v].add(this_color)
                all_colors.add(this_color)

                queue.append(v)
    """

    return edge_colors


edge_colors = bfs(tree, 0)

print(max([c for key, c in edge_colors.items()]))
[print(edge_colors[t]) for t in key_order]
# print(edge_colors)

# show_tree(tree)


Measured memory_bytes: 47688
package main

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

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	X := sc.NextIntArray()

	if M == 1 {
		fmt.Println(0)
		return
	}
	sort.Ints(X)

	diff := make([]int, M-1)
	for i := 1; i < M; i++ {
		diff[i-1] = X[i] - X[i-1]
	}
	sort.Ints(diff)
	for h := 0; h < N-1 && h < len(diff); h++ {
		diff[len(diff)-1-h] = 0
	}

	total := 0
	for h := 0; h < len(diff); h++ {
		total += diff[h]
	}
	fmt.Println(total)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	string ss; cin >> ss;
	int res = INF;
	for(int i=0;i<26;i++){
	    string s = ss;
		for(int j=0;;j++){
			for(int k=0;k<s.size();k++) if(s[k] != 'a'+i) goto nxt;
			res = min(res,j); break; nxt:;
			string t = "";
			for(int k=1;k<s.size();k++){
				if(s[k-1] == 'a'+i || s[k] == 'a'+i) t.pb('a'+i);
				else t.pb(s[k]);
			}
			s = t;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <long long int> arr,pref;
long long int dp[100001],n=0;
long long int solve(long long int k){
	//long long int min = INT_MAX-1;
  	int ans=0;
  	if(k==0){return dp[k] = 0;}
  	else if(dp[k]!=-1){return dp[k];}
  	else{
      for(int i = 0;i<n;i++){
        if(arr[i]>k){continue;}
      	if(solve(k-arr[i])==0){
          ans = 1;
          break;
        }
      }
    }
 return dp[k] = ans;
}
int main(){
	long long int i=0,z=0,j=0,k=0,max=0,count1=0,count2=0;
  	string out;
  	cin >> n >> k ;
  	for(i=0;i<n;i++){
    	cin >> z;
      	arr.push_back(z);
    }
  	memset(dp,-1,sizeof(dp));
  	if(solve(k)){cout << "First"<<endl;}
  	else cout << "Second" <<endl;
}

Measured memory_bytes: 4096
import sys
input = sys.stdin.readline
N=int(input().rstrip())
count=0

def resolve():
    global count
    dfs("")
    print(count)

def dfs(s):
    global count
    
    if s!="":
        if int(s)>N:
            return

    if s.find("3")!=-1 and s.find("5")!=-1 and s.find("7")!=-1:
        count+=1
    
    s3=str(s)+str(3) if s!="" else str(3)
    s5=str(s)+str(5) if s!="" else str(5)
    s7=str(s)+str(7) if s!="" else str(7)

    dfs(s3)
    dfs(s5)
    dfs(s7)



    """
    s3=str(s)+str(3) if s!="" else str(3)
    s5=str(s)+str(5) if s!="" else str(5)
    s7=str(s)+str(7) if s!="" else str(7)

    if s3.find("3")!=-1 and s3.find("5")!=-1 and s3.find("7")!=-1 and int(s3)<=N:
        count+=1
    if int(s3)>N:
        return
    dfs(s3)

    if s5.find("3")!=-1 and s5.find("5")!=-1 and s5.find("7")!=-1 and int(s5)<=N:
        count+=1
    if int(s5)>N:
        return
    dfs(s5)

    if s7.find("3")!=-1 and s7.find("5")!=-1 and s7.find("7")!=-1 and int(s7)<=N:
        count+=1
    if int(s7)>N:
        return
    dfs(s7)
    """

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """575"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3600"""
        output = """13"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """999999999"""
        output = """26484"""
        self.assertIO(input, output)

if __name__ == "__main__":
#    unittest.main()
    resolve()

Measured memory_bytes: 5700
#include<stdio.h>

int N,i,j,c,a,b;
char D[20];
int cv(char c)
{
	if(c<';')return c-'0';
	else if(c=='A'){a++;return 11;}
	else return 10;
}
int main()
{
	scanf("%d\n",&N);
	for(;N--;)
	{
		for(i=0;i<10;i++)
			scanf("%c%*c",D+i);
		for(i=1;;i++)
		{
			for(j=a=c=0;j<=i;j++)
				c+=cv(D[j]);
			for(b=c;b>21&&a--;)b-=10;
			if(b>17||(b==17&&!a))break;
		}
		if(b==21&&i==1)puts("blackjack");
		else if(b>21)puts("bust");
		else printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           int ans=0;
           vin a(n);
           rep(i,0,n)cin>>a[i];
           rep(i,0,n-1){
            if(a[i]==a[i+1]){
             a[i+1]=-1;
              ans++;
            }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

  //   String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu[3]);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

if(Math.abs(A-C)<=D || (Math.abs(A-B)<=D && Math.abs(B-C)<=D)){

System.out.println("Yes");
}else{
System.out.println("No");

}


	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	long H;cin>>H;
	long t=1;
	while(t<=H) t*=2;
	cout<<t-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ss substr
typedef long long ll ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;
typedef map<ll,ll> mapi ;
typedef map<string,string> maps ;


int main()
{
  //freopen("lifeguards.out", "w", stdout) ;
  //freopen("lifeguards.in", "r", stdin) ;
  ios_base::sync_with_stdio(0) ;
  cin.tie(NULL) ;
  cout.tie(NULL) ;
 
 //int t ; cin >> t ; while(t--){} 
 
 int n ; cin >> n ;
 for ( int i = 1 ; i <= 9 ; i++ )
 {
   if ( n % i == 0 && n/i <= 9 )
   {
     cout << "Yes" ;
     return 0 ;
   }
 }
 cout << "No" ;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            BigInteger k = BigInteger.valueOf(in.nextInt());

            long[] w = new long[n];
            long[] d = new long[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextLong();
                d[i] = in.nextLong();
            }

            BigInteger high = BigInteger.valueOf(Long.MAX_VALUE / 2);
            BigInteger low = BigInteger.ZERO;
            while (high.subtract(low).longValue() > 1) {
                BigInteger mid = high.add(low).shiftRight(1);

                BigInteger sum = BigInteger.ZERO;
                for (int i = 0; i < n; i++) {
                    if (mid.longValue() < w[i]) continue;
                    sum = sum.add(BigInteger.valueOf((mid.longValue() - w[i]) / d[i] + 1));
                }

                if (sum.compareTo(k) >= 0) {
                    high = mid;
                } else {
                    low = mid;
                }
            }

            out.println(high);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

using P = pair<int, int>;

struct edge {
    int to; 
    long long cost;

    edge(int t, long long c): to(t), cost(c) {}
};

const long long INF = 1ll << 60;
const int MAX_V = 300000;
int V;
vector<edge> G[MAX_V + 1];
long long d[MAX_V + 1];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    V = n * 3;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        for (int i = 0; i < 3; i++) {
            G[u * 3 + i].push_back(edge(v * 3 + (i + 1) % 3, 1));
        }
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    dijkstra(s * 3);

    cout << (d[t * 3] == INF ? -1 : d[t * 3] / 3) << endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>    
#define pb push_back
 
#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
 
typedef long long ll;
using namespace std;
ll MOD = 998244353;
 
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;
 
void mosA(vector<ll> a){
	for(int i=0; i<a.size(); i++) printf("%lld ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}
 
ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/
 
bool ord(ll a, ll b){
	return a>b;
}
 
ll ans = 0;
int a,n,w,t,k,m,z,q,l,r,x,b;
int C[200005];
char S[200005];
vector<ii> G[100005];
 
 
void dfs(int v, int ant){
	for(auto &x:G[v]){
		if(ant!=x.first){
			if(x.second == 0){
				C[x.first] = C[v];
			} else C[x.first] = (C[v]+1)%2;
			dfs(x.first,v);
		}
	}
 
}
 
 
int main(){
	scanf("%d",&n);
	FOR(i,n-1){
		scanf("%d%d%d",&a,&b,&w);
		w = w%2;
		G[a].pb({b,w});
		G[b].pb({a,w});
	}
 
	C[1] = 1;
	dfs(1,-1);
	
	F0R(i,1,n+1) printf("%d\n",C[i]);
}
 
 
 
 
// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

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

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

  cout << a << " " << b << " " << c << endl;

  return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();

		if(T*S >= D) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35800
package main

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

type stack struct {
	Body []int
	Top  int
	Max  int
}

func NewStack(max int) *stack {
	s := new(stack)
	s.Top = 0
	s.Max = max
	s.Body = make([]int, max)
	return s
}

func (s *stack) isEmpty() bool {
	return s.Top == 0
}

func (s *stack) isFull() bool {
	return s.Top >= s.Max-1
}

func (s *stack) Push(x int) error {
	if s.isFull() {
		err := errors.New("body is full")
		return err
	}
	s.Top++
	s.Body[s.Top] = x
	return nil
}

func (s *stack) Pop() (int, error) {
	if s.isEmpty() {
		err := errors.New("body is empty")
		return 0, err
	}
	s.Top--
	return s.Body[s.Top+1], nil
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	sl := strings.Split(sc.Text(), " ")
	st := NewStack(len(sl))
	for _, s := range sl {
		switch s {
		case "+":
			a, _ := st.Pop()
			b, _ := st.Pop()
			_ = st.Push(a + b)
		case "-":
			b, _ := st.Pop()
			a, _ := st.Pop()
			_ = st.Push(a - b)
		case "*":
			a, _ := st.Pop()
			b, _ := st.Pop()
			_ = st.Push(a * b)
		default:
			n, _ := strconv.Atoi(s)
			_ = st.Push(n)
		}
	}
	n, _ := st.Pop()
	fmt.Println(n)

}


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

int main() {
  int N, M; cin >> N >> M;
  int s[M], c[M];
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  
  int ans[N];
  for (int i = 0; i < N; i++) ans[i] = 10;
  bool flag = false;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      if (s[j] - 1 == i){
        if (ans[i] == 10) ans[i] = c[j];
        else if (ans[i] != c[j]) flag = true;
      }
    }
    if (N != 1 && i == 0){
      if (ans[i] == 10) ans[i] = 1;
      else if (ans[i] == 0) flag = true;
    }
    else if (ans[i] == 10) ans[i] = 0;
  }
  
  if (flag == true) cout << -1 << endl;
  else if (N == 3) cout << ans[0] * 100 + ans[1] * 10 + ans[2] << endl;
  else if (N == 2) cout << ans[0] * 10 + ans[1] * 1 << endl;
  else if (N == 1) cout << ans[0] << endl;
}

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

#define M 1e9+7

int main() {
    int sx,sy,tx,ty;
    char ox, oy, ix, iy;    //out bound, in bound
    string ans = "";
    cin >> sx >> sy >> tx >> ty;
    if(sx < tx) {
        ox = 'R'; ix = 'L';
    } else {
        ox = 'L'; ix = 'R';
    }
    if(sy < ty) {
        oy = 'U'; iy = 'D';
    } else {
        oy = 'D'; iy = 'U';
    }

    /* first out bound */
    for(int i = 0; i < abs(ty-sy); i++)ans.push_back(oy);
    for(int i = 0; i < abs(tx-sx); i++)ans.push_back(ox);
    
    /* first in bound */
    for(int i = 0; i < abs(ty-sy); i++)ans.push_back(iy);
    for(int i = 0; i < abs(tx-sx); i++)ans.push_back(ix);

    /* second out bound */
    ans.push_back(ix);
    for(int i = 0; i < abs(ty - sy) + 1; i++)ans.push_back(oy);
    for(int i = 0; i < abs(tx - sx) + 1; i++)ans.push_back(ox);
    ans.push_back(iy);

    /* second out bound */
    ans.push_back(ox);
    for(int i = 0; i < abs(ty - sy) + 1; i++)ans.push_back(iy);
    for(int i = 0; i < abs(tx - sx) + 1; i++)ans.push_back(ix);
    ans.push_back(oy);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";


int SetAns() {
	int a;
	cin >> a;
	return a + a*a + a*a*a;
}

int main() {
	
	cout << SetAns() << endl;
	return 0;
}


Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, k;
	cin >> n >> k;
	Vi P(n);
	Vl C(n);
	rep(i, n) {
		int t;
		cin >> t;
		t--;
		P[i] = t;
	}
	rep(i, n)  cin >> C[i];



	ll ansmincase = -1e17;
	for (int i = 0; i < n; i++) {
		int u = i;
		ll sum = 0;
		for (int j = 0; j < min(k, 2000); j++) {
			sum += C[P[u]];
			u = P[u];
			ansmincase = max(ansmincase, sum);
		}
	}
	if (k < 2000) {
		cout << ansmincase << endl;
		return 0;
	}

	ll ans = -1e17;
	for (int i = 0; i < n; i++) {
		int u = i;
		ll cirsum = 0;
		ll pathcnt = 0;
		while (true) {
			cirsum += C[P[u]];
			u = P[u];
			pathcnt++;
			if (u == i) break;
		}
		ll path = 0;
		int cnt = 0;

		while (true) {
			cnt++;
			path += C[P[u]];

			if (cnt > k) break;

			int num = (k - cnt) / pathcnt;
			ll score = path + max(0ll, cirsum) * num;
			chmax(ans, score);

			u = P[u];
			if (u == i) break;
		}
	}

	cout << max(ans, ansmincase) << endl;
	return 0;
}


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

int main() {
	int H = 0, A = 0;
	int result = 0;
	cin >> H >> A;

	while(H > 0) {
		H -= A;
		result++;
	}

 	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string x,y,z,k;
  cin >> x >> y >> z;
  cout << x[0] << y[1] << z[2] << endl;
  return 0;
}


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

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

const long long INF = 1LL << 60;
long long dp[100100];

long long calc(long long X) {
    long long cnt = (X+1) / 2;
    long long ans = cnt % 2;
    if (X % 2 == 0) ans ^= X;
    return ans;
}

int main() {
    long long A, B; cin >> A >> B;

    long long ans = calc(B) ^ calc(A-1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
even = []
ans = []
for i in li:
    if i % 2 == 0:
        even.append(i)
for j in even:
    if j % 3 == 0 or j % 5 == 0:
        ans.append(j)
if len(even) == len(ans):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
N,M=map(int,input().split())
SC=[input().split() for _ in range(M)]
ans=["0"]*N
for s,c in SC:
  if ans[int(s)-1]!="0" and ans[int(s)-1]!=c:
    print(-1)
    exit()
  if N>1 and s=="1" and c=="0":
    print(-1)
    exit()
  ans[int(s)-1]=c
if ans[0]=="0" and N>1:
  ans[0]="1"
print("".join(ans))

Measured memory_bytes: 9104
#!/usr/bin/env python

n = int(input())
p = input().split()
q = input().split()
a = []
b = []
a_start = 0
a_end = 0

for i in p:
    a.append(int(i))
for i in q:
    b.append(int(i))
for i in a:
    a_start += i

for i,j in enumerate(b):
    if a[i] > b[i]:
        a[i] -= b[i]
    else:
        b[i]   -= a[i]
        a[i]    = 0
        if a[i+1] > b[i]:
            a[i+1] -= b[i]
            b[i] = 0
        else:
            a[i+1] = 0
            b[i] -= a[i+1]

for i in a:
    a_end += i

print(a_start - a_end)

Measured memory_bytes: 25556
#import math.sqrt as sqrt
#data = list(map(input().split()))
N = int(input())
S = input()

ans =""

alf = ["A", "B", "C", "D", "E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

n = int(len(S))

for i in range(n):
    for j in range(len(alf)):
        if S[i]==alf[j]:
            if j+N < len(alf):
                ans += alf[j+N]
            else:
                k = int(j+N-len(alf))
                ans += alf[k]




print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int ans = 1;
  int num = K;
  while (true) {
    if (num >= N) {
      break;
    }
    num += K-1;
    ans++;
  }
  cout << ans << endl;
}


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

ans = 0

for i in range(N):
    for j in range(N):
        ans += ((XY[i][0]-XY[j][0])**2 + (XY[i][1]-XY[j][1])**2)**0.5

print(ans/N)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
const int MAX_N = 2 * 1e5;
const int inf = 1 << 30;
int dp[MAX_N + 2][2];

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  REP(i, 0, N) {
    REP(j, 0, 2) { dp[i][j] = inf; }
  }
  int B = 1;
  int W = 0;
  dp[0][0] = 0;
  dp[0][1] = 0;
  if (S[0] == '#') {
    dp[1][B] = 0;
    dp[1][W] = 1;
  } else {
    dp[1][B] = 1;
    dp[1][W] = 0;
  }
  REP(i, 1, N) {
    if (S[i] == '#') {
      dp[i + 1][W] = dp[i][W] + 1;
      dp[i + 1][B] = min(dp[i][B], dp[i][W]);
    } else {
      dp[i + 1][W] = dp[i][W];
      dp[i + 1][B] = min(dp[i][W] + 1, dp[i][B] + 1);
    }
  }
  // REP(i, 0, N+1) { cerr << dp[i][B] << ", " << dp[i][W] << endl; }

  cout << min(dp[N][B], dp[N][W]) << endl;

  return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    long long a,b,x;
    cin>>a>>b>>x;
    long long ans=0;
    ans=b/x-a/x;
    if(a%x==0)ans++;
    cout<<ans<<endl;
}

   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int a,b;
    cin>>a>>b;
    if (a>8||b>8)
        cout<<":(";
    else
        cout<<"Yay!";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    vector<int> in(n, 0);
    for(int i = 0; i < n - 1 + m; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        ++in[b];
    }

    queue<int> que;
    for(int i = 0; i < n; ++i){
        if(in[i] == 0){
            que.push(i);
            break;
        }
    }

    vector<int> order;  // トポロジカル昇順
    // 入次数 = 0 になった頂点をコンテナに入れていく
    while(!que.empty()){
        int from = que.front();
        que.pop();
        order.push_back(from);
        for(int to : graph[from]){
            if(--in[to] == 0){
                que.push(to);
            }
        }
    }
    
    vector<P> ans(n, P(-1, -1));
    for(int i = 0; i < n; ++i){
        int from = order[i];
        for(int to : graph[from]){
            if(i > ans[to].first){
                ans[to] = P(i, from);
            }
        }
    }
    
    for(int i = 0; i < n; ++i){
        cout << ans[i].second + 1 << '\n';
    }
}

Measured memory_bytes: 8056
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p;
  for (int i=0; i<n; ++i) {
    int x;
    cin >> x;
    p.push_back(x);
  }
  sort(begin(p), end(p));
  p[p.size()-1] /= 2;
  int ans = accumulate(begin(p), end(p), 0);
  cout << ans << endl;
  return 0;
}


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

int main () {
  long N;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort (A.begin(), A.end());
  long b = A.at(N-1);
  vector<bool> B(b, false);
  for (long i = 0; i < N; i++) {
    long a = A.at(i);
    if (B.at(a-1)) B.at(a-1) = false;
    else B.at(a-1) = true;
  }
  long ans = 0;
  for (long i = 0; i < b; i++) {
    if (B.at(i)) ans++;
  }
  cout << ans << endl;
}

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

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

    vector<vector<ll>> vec(9,vector<ll>(9,0));

    for (ll i=1; i<=N; i++) {
        ll keta = 1;
        ll i_temp = i;
        while (i_temp>=10) {
            i_temp/=10;
            keta++;
        }
        ll i_st = i/pow(10,keta-1);
        ll i_en = i%10;
        if (i_en!=0) {
            vec[i_st-1][i_en-1]++;
        }
    }
    ll ans = 0;
    for (ll i=0; i<9; i++) {
        for (ll j=0; j<9; j++) {
            ans += vec[i][j]*vec[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int x,v;
    cin>>x;
    vector<bool> ve(x+1);
    ve[1]=1;
    for(int i=2;i<=x;i++)
    {
        v=i*i;
        while(v<=x)
        {
            ve[v]=1;
            v*=i;
        }
    }
    
    for(int i=x;i>=1;i--)
    {
        if(ve[i])
        {
            cout<<i<<"\n";
            return 0;
        }
        
        
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

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

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,p;
int people[55];

void init(){
  rep(i,55)people[i]=0;
}

void solve(){
  int stone=p;
  for(int i=0;;i++){
    
    if(people[i%n]==p){
      
      cout<<i%n<<endl;
      break;
    }else if(stone==0){
      stone=people[i%n];
      people[i%n]=0;
    }else{
      people[i%n]++;
      stone--;
    }
  }
}

int main(){
  while(cin>>n>>p){
    if(n==0&&p==0)break;
    init();
    solve();
  }
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int n, cnt = 1; 
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.size()-1; i++){
		if(s[i] != s[i+1])cnt ++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

const int MAX = 101;
int n;
int a[MAX];


void solve() {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            if (a[j-1] > a[j]) {
                ans++;
                swap(a[j-1], a[j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
    printf("%d\n", ans);
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 3224
use proconio::input;
use std::f64::consts::PI;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let d1 = h * PI / 6.0 + m * PI / 360.0;
    let d2 = m * PI / 30.0;
    let x1 = a * d1.cos();
    let y1 = a * d1.sin();
    let x2 = b * d2.cos();
    let y2 = b * d2.sin();

    let ans = ((x1 - x2).powf(2.0) + (y1 - y2).powf(2.0)).sqrt();
    println!("{}", ans);
}


Measured memory_bytes: 2940
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            a[j] -= x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
            b[j] -= y;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64260
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define FO(n) for (ll i = 0; i < n; i++)
#define endl "\n"
const long long int M = 10e9 + 7;
vector<vector<int>> G;
vector<bool> visited;
int dfs(int i)
{
    int cur = 0;
    visited[i] = true;
    for (auto it : G[i])
    {
        if (!visited[it])
        {
            cur += dfs(it);
        }
    }
    return ++cur;
}
void solve()
{
    int n, m;
    cin >> n >> m;
    G.resize(n);
    visited.resize(n);
    FO(m)
    {
        int x, y;
        cin >> x >> y;

        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (!visited[i])
            ans = max(ans, dfs(i));
    }
    cout << ans << endl;
}
int main()
{
    faster;
    // int t;
    //cin >> t;
    //while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 23404
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N;
	vector<int> L;
	int tmp,ret=0;
	cin>>N;
	for(int i=0;i<2*N;i++){
		cin>>tmp;
		L.push_back(tmp);
	}
	sort(L.begin(),L.end());

	for(int i=0;i<N;i++){
		ret+=L[2*i];
	}
	cout<<ret<<endl;
	return 0;
}

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

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

int main(int argc, char *argv[])
{
  int n;
  while(cin >> n && n){
    vector<int> k(n);
    rep(i, n) cin >> k[i];
    string s;
    cin >> s;
    int idx = 0;
    for(auto c : s){
      int p = islower(c) ? c - 'a' : c - 'A' + 26;
      p -= k[idx];
      p %= 52;
      p += 52;
      p %= 52;
      cout << char(p < 26 ? p + 'a' : p-26 + 'A');
      idx = (idx + 1) % n;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> first(n+1, false), last(n+1, false);
	int a, b;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b;
		if (a == 1) first[b] = true;
		if (b == n) last[a] = true;
	}

	for (int i = 1; i <= n; i++) {
		if(first[i] && last[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]
    M = max(A)
    X = [i for i in range(M+1)]
    S = [True for i in range(M+1)]
    S[0] = False
    S[1] = False

    for i in range(1, M+1):
        if S[i]:
            for j in range(i, M+1, i):
                if S[j]:
                    S[j] = False
                    X[j] = i
    flag = True
    s = set()
    ls = 0
    for x in A:
        tmp = set()
        while(X[x] != 1):
            tmp.add(X[x])
            x //= X[x]
        l = len(tmp)
        s |= tmp
        if len(s) == ls + l:
            ls += l
            continue
        else:
            flag = False
            break

    if flag:
        print("pairwise coprime")
    else:
        for x in A[1:]:
            g = gcd(g, x)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()


Measured memory_bytes: 110824
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM =  1000000007;


int main()
{
    // 整数の入力
    ll N;
    vector<ll> P,Q;
    cin >> N;
    for(int i = 0;i< N;i++){
        ll p;
        cin >> p;
        P.push_back(p);
    }
    for(int i = 0;i< N;i++){
        ll q;
        cin >> q;
        Q.push_back(q);
    }
    ll count_p = 0;
    ll count_q = 0;
    while(next_permutation(P.begin(),P.end())){
        count_p++;
    }
    while(next_permutation(Q.begin(),Q.end())){
        count_q++;
    }
    cout << abs(count_p - count_q) << endl;
    return 0;
}

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


#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;
void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,k;
    c_p_c();
    cin>>n;
    string s;
    cin>>s;
    // watch(s.size());
    if(s.size()<=n)
    	cout<<s<<endl;
    else{
    	for (int i = 0; i < n; ++i)
    	{
    		cout<<s[i];
    	}
    	cout<<"...";
    	cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;
 
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

void solve() {
    int n; cin >> n;
    cout << 1 - n;    
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int calcCost(int c, int n, vector<int> path, vector<int> rt){
	priority_queue<int> costs;
	for(int i=1; i<rt.size(); i++){
		costs.push(path[rt[i]+n*rt[i-1]]);
	}
	int total = 0;
	while(costs.size() && c--){
		total += costs.top() / 2;
		costs.pop();
	}
	while(costs.size()){
		total += costs.top();
		costs.pop();
	}
	return total;
}
int main(){
	for(;;){
		int c,n,m,s,d;
		cin>>c>>n>>m>>s>>d;
		if(c+n+m+s+d==0) break;
		vector<pair<int, vector<int>>> route(n,make_pair(-1,vector<int>()));
		vector<int> path(n*n,-1);
		for(int i=0; i<m; i++){
			int a,b,f;
			cin>>a>>b>>f;
			path[--a+n*--b] = path[b+n*a] = f;
		}
		priority_queue<pair<int, vector<int>>, vector<pair<int, vector<int>>>, greater<pair<int, vector<int>>>> pq;
		pq.push(make_pair(0,vector<int>(1,s-1)));
		while(pq.size()){
			int cur = *(pq.top().second.rbegin());
			if(route[cur].first == -1){
				route[cur] = pq.top();
				for(int i=0; i<n; i++){
					if(route[i].first == -1 && path[i+n*cur] != -1){
						auto copy = pq.top();
						copy.second.push_back(i);
						copy.first = calcCost(c,n,path,copy.second);
						pq.push(copy);
					}
				}
			}
			pq.pop();
		}
		cout<<route[d-1].first<<endl;
	}
}

Measured memory_bytes: 3176
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int N,A;
  int s[110];
  cin >> N;
  int total = 0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A%10!=0) s[cnt] = A, ++cnt;
    total += A;
  }

  sort(s,s+cnt);
  // for(int i = 0; i < cnt; i++) printf("%d\n",s[i]);

  if(total%10!=0) printf("%d\n",total);
  else{
    if(cnt!=0) printf("%d\n",total - s[0]);
    else printf("0\n");
  }

  return 0;

}


Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		ans += s[i] == t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    lli a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int cpa[N];
    for (int i = 0; i < N; i++)
    {
        cpa[i] = a[i];
    }
    lli ans = 1000;
    lli num = 0;
    int price = a[0];
    for (int i = 0; i < N - 1; i++)
    {
        if (a[i] < a[i + 1])
        {
            num = ans / a[i];
            ans += (a[i + 1] - a[i]) * num;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
const int maxn = 200010;
int n, K, c[maxn];
ll ans, a[maxn], s[maxn];
vector<ll> V;

void add(int p) {
    for (; p <= V.size(); p += p & -p) c[p]++;
}

int sum(int p) {
    int s = 0;
    for (; p; p -= p & -p) s += c[p];
    return s;
}

int main() {
    scanf("%d %d", &n, &K);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]), s[i] = s[i - 1] + a[i] - K;
    }
    for (int i = 0; i <= n; i++) {
        V.push_back(s[i]);
    }
    sort(V.begin(), V.end());
    V.resize(unique(V.begin(), V.end()) - V.begin());
    for (int i = 0; i <= n; i++) {
        s[i] = lower_bound(V.begin(), V.end(), s[i]) - V.begin() + 1;
    }
    for (int i = 0; i <= n; i++) {
        ans += sum(s[i]), add(s[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#define PII pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') { if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f==1?x:-x;
}
inline void print(int x){
	if(x<0) x=~x+1,putchar('-');
	if(x>=10) print(x/10);
	putchar((x%10)|48);
}
int n,k;
int a[300010];
int maxn[2000010];
const int N=300000;
void pushup(int p){
	maxn[p]=max(maxn[p<<1],maxn[p<<1|1]);
}
void update(int p,int l,int r,int pos,int k){
	if(l==r){
		maxn[p]=max(maxn[p],k);return ;
	}
	int mid=l+r>>1;
	if(pos<=mid) update(p<<1,l,mid,pos,k);
	else update(p<<1|1,mid+1,r,pos,k);
	pushup(p);
}
int query(int p,int l,int r,int L,int R){
	if(l>=L&&r<=R) return maxn[p];
	int mid=l+r>>1;
	int res=0;
	if(L<=mid) res=max(res,query(p<<1,l,mid,L,R));
	if(R>mid) res=max(res,query(p<<1|1,mid+1,r,L,R));
	return res;
}
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;++i) a[i]=read();
	int ans=0;
	for(int i=1;i<=n;++i){
		int x=query(1,0,N,max(0,a[i]-k),min(N,a[i]+k))+1;
		ans=max(ans,x);
		update(1,0,N,a[i],x);
	} 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9036
N = int(input())
A = list(map(int, input().split()))
even = []

for i in A:
    if i%2 == 0:
        even.append(i)
cnt = 0

for j in even:
    if j % 3 == 0 or j % 5 == 0:
        cnt += 1

if cnt == len(even):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060