akhauriyash/Code-Regression huggingface dataset:
/**
 * D - RGB Tripletsc
 * https://atcoder.jp/contests/abc162/tasks/abc162_d
 */
#include <bits/stdc++.h>
using namespace std;

int main() {
    // R, G, B のみからなる、長さ N の文字列 S があります。
    int N;
    string S;
    cin >> N >> S;

    // 以下の 2 つの条件をともに満たす組 (i, j, k) (1≤i<j<k≤N) の数を求めてください。
    // Si≠Sj かつ Si≠Sk かつ Sj≠Sk である
    // j−i≠k−j である
    long long r = 0, g = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            r++;
        } else if (S[i] == 'G') {
            g++;
        } else if (S[i] == 'B') {
            b++;
        }
    }

    // Si≠Sj かつ Si≠Sk かつ Sj≠Sk である
    // RとGとBの組み合わせによって決まる
    long long cnt = r * g * b;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = 2 * j - i;
            if (k >= N) {
                continue;
            }

            // Si≠Sj かつ Si≠Sk かつ Sj≠Sk である
            if  (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
                cnt -= 1;
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
	int i, j, n, isprime[51000];

	/* pre-processing */
	for(i = 0; i < 51000; i++) isprime[i] = 1;
	isprime[0] = 0;
	isprime[1] = 0;
	for(i = 2; i < 51000; i++) if(isprime[i]) for(j = 2; i * j < 51000; j++) isprime[i * j] = 0;

	while(scanf("%d", &n) != EOF) {
		for(i = n - 1; i > 0; i--) if(isprime[i]) break;
		for(j = n + 1; j < 51000; j++) if(isprime[j]) break;
		printf("%d %d\n", i, j);
	}
	return 0;
}

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

int main()
{
	int month_1,month_2,day_1,day_2;
	cin>>month_1>>day_1;
	cin>>month_2>>day_2;
	
	if(month_1!=month_2)
		cout<<"1"<< endl;
	else
		cout<<"0"<< endl;
		
	return 0;
}

Measured memory_bytes: 256
s = input()
a = 0
n = len(s)

for i in range (n):
    if i % 2 == 1:
        if s[i] != "R":
            a=a+1
    if i % 2 == 0:
        if s[i] != "L":
            a=a+1
if a == len(s):
    print('Yes')
else:
    print('No')
  

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

int main(){
	string s;
	cin >> s;

	for (int i = 0; i < 4; i++){
		cout<<s[i];
	}
	cout<<" ";
	for (int i = 4; i < 12; i++){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
def f_10_to_m2(n):
    if n == 0:
        return 0 

    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base*2) == 0:
            digits.append(0)
        else:
            digits.append(1)
            n -= base
        i += 1
        base *= -2
    return ''.join(map(str, reversed(digits)))

print(f_10_to_m2(int(input())))

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

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for (int i = 2; i <= M; ++i)
    for (int j = 2; j <= D; ++j)
      if (j / 10 != 1 && j % 10 != 1 && i == (j / 10) * (j % 10))
        ++ans;
  cout << ans << endl;
}

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 n;
    cin >> n;
    int answer = 1;
    while (n > 1)
    {
        n /= 2;
        answer *= 2;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
require 'complex'

# Complex * Complex -> Double                                                                                        

def dot(c1, c2)
  (c1.conj * c2).real
end

def cross(c1, c2)
  (c1.conj * c2).imag
end

def main
  xp0, yp0, xp1, yp1 = gets.chomp.split(/\s/).collect { |x| x.to_f}
  q = gets.chomp.to_i
  (1..q).each do |ca|
    p0 = Complex(xp0, yp0)
    p1 = Complex(xp1, yp1)
    x, y = gets.chomp.split(/\s/).collect { |x| x.to_f}
    p = Complex(x, y)
    t = (p1 - p0) * dot(p1 - p0, p - p0)/((p1 - p0).abs ** 2) + p0
    puts ("%.9f" % t.real) + " " + ("%.9f" % t.imag)
  end
end

main

Measured memory_bytes: 6292
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
int x[10], y[10];

signed main() {

    cin >> n;

    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];

    double sum = 0.0;
    vector<int> v;
    for(int i = 0; i < n; i++) v.bash(i);
    int count = 0;
    do        
        for(int i = 0; i < n-1; i++) 
            sum += hypot(x[v[i]]-x[v[i+1]], y[v[i]]-y[v[i+1]]);

    while(count++, next_permutation(ALL(v)));
    
    cout << sum/count << endl;
           
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
int sum[2][maxn];
char s[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
	{
		sum[0][i] = sum[0][i - 1];
		sum[1][i] = sum[1][i - 1];
		if (s[i] == '#') sum[1][i]++;
		else sum[0][i]++;
	}
	int res = n + 1;
	for (int i = 0; i <= n; i++)
		res = min(res, sum[1][i - 1] + sum[0][n] - sum[0][i]);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 2048
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	v := gcd(A, B)
	arr := []int{1}
	for i := 2; i <= v; i++ {
		if A%i == 0 && B%i == 0 {
			arr = append(arr, i)
		}
	}
	fmt.Println(arr[len(arr)-K])
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] h = new int[n];

        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        boolean isAns = true;
        if (n >= 2) {
            for (int i = n - 2; i >= 0; i--) {
                if (h[i] > h[i+1]) {
                    if (h[i]-1 <= h[i+1]) {
                        h[i]--;
                    } else {
                        isAns = false;
                        break;
                    }
                }
            }
        }

        System.out.println(isAns ? "Yes" : "No");
    }
}

Measured memory_bytes: 49708
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int64_t count_5(int64_t n)
{
    int64_t ans = 0;
    while (n > 0)
    {
        ans += n / 5;
        n /= 5;
    }
    return ans;
}

int main()
{
    int64_t n;
    cin >> n;

    if (n % 2 == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << (count_5(n / 2)) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

int n,k;
int _ans,ans=0;
int l_max;

vector<int> edge[2000];
bool arrived[2000];

void calc(int now, int len) {
	if(arrived[now]) return;
	arrived[now] = true;
	_ans++;
	if(len<l_max) for(int next : edge[now]) calc(next,len+1);
}

int main() {
	scanf("%d%d",&n,&k);
	l_max = (k+1)/2;
	for(int i = 0; i < n-1; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	if(k%2==0) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) arrived[j] = false;
			_ans = 0;
			calc(i,0);
			ans = max(ans,_ans);
		}
		printf("%d\n",n-ans);
	}else {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < edge[i].size(); j++) {
				for(int l = 0; l < n; l++) arrived[l] = false;
				_ans = 0;
				arrived[edge[i][j]] = true;
				calc(i,1);
				arrived[edge[i][j]] = false;
				calc(edge[i][j],1);
				//printf("%d,%d,%d\n",i,edge[i][j],_ans);
				ans = max(ans,_ans);
			}
		}
		printf("%d\n",n-ans);
	}
}


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

int main() {
    int N, i;
    cin >> N;
    vector<int> emp(N - 1);
    vector<int> boss(N);
    for (i = 0; i < N - 1; i++) {
        cin >> emp.at(i);
        boss.at(emp.at(i) - 1)++;
    }
    
    for (i = 0; i < N; i++) {
        cout << boss.at(i) << endl;
    }
    
}

Measured memory_bytes: 4792
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int length = int.Parse(ReadLine());
        string num = ReadLine();
        int count = 0;
        for(int a=0;a<10;a++){
        for(int b=0;b<10;b++){
        for(int c=0;c<10;c++){
            string num1 = a.ToString();
            string num2 = b.ToString();
            string num3 = c.ToString();
            string temp = num;
            if(temp.IndexOf(num1) <0 ||temp.IndexOf(num2) <0||temp.IndexOf(num3) <0){
                continue;
            }
            if(temp.IndexOf(num1) >= 0){
                temp = temp.Substring(temp.IndexOf(num1)+1);
                if(temp.IndexOf(num2) >= 0){
                temp = temp.Substring(temp.IndexOf(num2)+1);
                    if(temp.IndexOf(num3) >= 0){
                        //WriteLine($"{num3} {temp}");
                    count++;
                    }
                }
            }
        }
        }
        }
        WriteLine(count);
    }
}


Measured memory_bytes: 31840
#include <stdio.h>

int s_ans[512][10] = {0};
int table[10] = {0};
int k[10] = {0};
int k_num = 0;

void makeans(void) {
	int i;
	int s = 0;

	if(k_num) {
		for(i = 0; i < k_num; i++) {
			s += (i + 1) * k[i];
		}
		s_ans[s][k_num - 1]++;
	}

	for(i = 0; i < 10; i++) {
		if(!table[i]) {
			k[k_num] = i; k_num++;
			table[i] = 1;
			makeans();
			k_num--;
			table[i] = 0;
		}
	}
}

int main(void) {
	int n, s;
	
	makeans();
	while(scanf("%d %d", &n, &s) != EOF) {
		if(s >= 512)
			printf("0\n");
		else
			printf("%d\n", s_ans[s][n - 1]);
	}

	return 0;
}

Measured memory_bytes: 624
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
input:
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output: in_order + pre_order
 1 12 17 20 25 30 88
 30 12 1 20 17 25 88

"""

import sys


class Node(object):
    def __init__(self, data):
        self.data = data
        self.left, self.right = None, None

    def insert(self, data):
        """
        insert data according to BST rules
        """
        if data < self.data:
            if not self.left:
                self.left = Node(data)
            else:
                self.left.insert(data)
        # insert duplicate value to right
        else:
            if not self.right:
                self.right = Node(data)
            else:
                self.right.insert(data)

        return self.data


def pre_order(node):
    if node is not None:
        print('', node.data, end='')
        pre_order(node.left)
        pre_order(node.right)
    return None


def in_order(node):
    if node is not None:
        in_order(node.left)
        print('', node.data, end='')
        in_order(node.right)
    return None


def action(command, content):
    if command.startswith('in'):
        tree_root.insert(int(content))
    # print tree walk
    else:
        in_order(tree_root)
        print('')
        pre_order(tree_root)
        print('')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    # assert len(command_list) == array_length

    flag, tree_root = False, None
    for each in command_list:
        command, content = each[0], each[-1]
        if (not flag) and command.startswith('in'):
            tree_root = Node(data=int(content))
            flag = True
            continue
        action(command, content)

Measured memory_bytes: 288640
import java.util.*;

public class Main {
	public static void check(int h,int w,char c[][]){
		for(int i=0;i<h+2;i++){
			if(i==0||i==h+1)continue;
				for(int j=0;j<w+2;j++){
					if(c[i][j]=='.'||j==0||j==w+1){
						continue;
					}else{
						if(c[i+1][j]=='#'||c[i-1][j]=='#'||c[i][j+1]=='#'||c[i][j-1]=='#'){
							continue;
						}else{
							System.out.print("No");
							return;
							}
					}
	          }
		}
		System.out.print("Yes");
		return;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int H=s.nextInt();
		int W=s.nextInt();
		String st[]=new String[H+2];
		char c[][]=new char[H+2][W+2];
        System.out.println();
		for(int i=0;i<H+1;i++){
			st[i]=s.nextLine();
		}
		
		for(int i=1;i<H+1;i++){
			for(int j=1;j<W+1;j++){
				c[i][j]=st[i].charAt(j-1);
			}
		  }
		 Main a=new Main();
		 a.check(H,W,c);
		}
	}

Measured memory_bytes: 21972
import java.util.Scanner;


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

        int n = sc.nextInt();
        int A[] = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
            // System.out.println(A[i]);
        }

        int q = sc.nextInt();
        int m[] = new int[q];
        for (int i = 0; i < q; i++) {
            m[i] = sc.nextInt();
        }

        String result;
        for (int i = 0; i < q; i++) {
            if(canSolve(m[i], 0, A)){
                result = "yes";
            }else{
                result = "no";
            }

            System.out.println(result);
        }

        sc.close();
    }

    public static boolean canSolve(int sum, int i, int[] A){
        int n = A.length;

        if(sum == 0){
            return true;
        }
        if(i >= n){
            return false;
        }
        boolean result = canSolve(sum, i+1, A) || canSolve(sum-A[i], i+1, A);
        return result;
    }

}


Measured memory_bytes: 26836
<?php
  // $x = (int)trim(fgets(STDIN));
  while(true) {
    $line = explode(" ",fgets(STDIN));
    $H = (int)$line[0];
    $W = (int)$line[1];
    if($H ==0 && $W == 0) {
      break;
    }
    for($i=0;$i<$H;$i++) {
      for($j=0;$j<$W;$j++) {
        print("#");
      }
      print("\n");
    }
    print("\n");
  }


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
string S[220000];
map<string, int> mp;
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> S[i];
        mp[S[i]]++;
    }
    int m = 0;
    rep(i, N) { chmax(m, mp[S[i]]); }
    set<string> st;
    rep(i, N) { if (m == mp[S[i]]) { st.insert(S[i]); }}
    for (string s:st) { cout << s << endl; }
}


Measured memory_bytes: 36352
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())
maxa = max(As)

l, r = 0, maxa+1
while r-l>1:
    half = (l+r)//2
    cnt = 0
    for a in As:
        cnt += -(-a//half)-1
    if cnt>K:
        l = half
    else:
        r = half

print(r)

Measured memory_bytes: 94028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=1145141919810893;
void Main(){
    cin>>n;
    vector<ll> a(n);
    For(i,0,n) cin>>a.at(i);
    ll dp[n+1];dp[0]=0;
    For(i,0,n) dp[i+1]=dp[i]+a[i];
    For(i,0,n){
        ans=min(ans,abs(dp[n]-dp[i]*2));
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;
using boost::algorithm::join;
// TOP

int		f(int y, int x, int n, vector<vector<int>> V)
{
	if (x == n - 1)
	{
		if (y == 0)
			return (V.at(0).at(n - 1) + V.at(1).at(n - 1));
		else
			return (V.at(1).at(n - 1));
	}
	else if (y == 1)
		return (V.at(1).at(x) + f(1, x + 1, n, V));
	return (V.at(0).at(x) + max(f(1, x, n, V), f(y, x + 1, n, V)));
}

void	Main()
{
	int	n;
	cin >> n;
	vector<vector<int>>	V(2, vector<int>(n));
	rep(i, n)
		cin >> V.at(0).at(i);
	rep(i, n)
		cin >> V.at(1).at(i);
	cout << f(0, 0, n, V);
}
// END
















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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    itn x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;


    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S =list(input())

list_abc = ['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']

list_ans =[]

for i in range(len(S)):
    if (list_abc.index(S[i])+N) > 25:
        list_ans.append(list_abc[list_abc.index(S[i])+N-26])
    else:
        list_ans.append(list_abc[list_abc.index(S[i])+N])

for i in list_ans:
    print(i,end="")


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int Q;
  cin >> Q;
  int l[Q+5],r[Q+5];
  for(int i = 0; i < Q;++i) cin >> l[i] >> r[i];
  int N = 100005;
  int S[N] = {0};
  
  
  for(int i = 0; i < N; ++i){
    S[i+1] = S[i];
    if(i%2 == 1){
      if(IsPrime(i)){
      	if(IsPrime((i+1)/2)) S[i+1] = S[i] + 1;
      }
    }
  }
  
  int ans = 0;
  for(int i = 0; i < Q; ++ i){
    ans = S[r[i]+1] - S[l[i]];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
import sys

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))

# code here
N = ni()
W = []
w = input()
l = w[-1]
W.append(w)
for i in range(N-1):
    w = input()
    if w in W:
        print('No')
        break

    if not w[0] == l:
        print('No')
        break

    l = w[-1]
    W.append(w)
else:
    print('Yes')



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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main()
{
    FAST;

   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll mx1=0,mx2=0,mx3=0,ans1=0,ans2=0,ans3=0,ans4=0;
   ans1=a*c;
   ans2=a*d;
   ans3=b*c;
   ans4=b*d;
   mx1=max(ans1,ans2);
   mx2=max(mx1,ans3);
   mx3=max(mx2,ans4);
   cout<<mx3<<endl;


    return 0;
}










Measured memory_bytes: 3648
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N,M,Q=map(int,readline().split())
    a=[]
    b=[]
    c=[]
    d=[]
    for i in range(Q):
        li=list(map(int,readline().split()))
        a.append(li[0])
        b.append(li[1])
        c.append(li[2])
        d.append(li[3])

    As=[]
    de=[]
    for i in range(1,M+1):
        de.append([i])
    de=deque(de)
    while len(de)>=1:
        x=de.popleft()
        if len(x)==N:
            As.append(x)
        else:
            n=x[-1]
            for i in range(n,M+1):
                y=x[:]
                y.append(i)
                de.append(y)

    max_res=0
    for i in range(len(As)):
        A=As[i]
        res=0
        for j in range(Q):
            if A[b[j]-1]-A[a[j]-1]==c[j]:
                res+=d[j]
        max_res=max(max_res,res)
    print(max_res)
if __name__=="__main__":
    main()

Measured memory_bytes: 29904
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
const int base = 1000000007;
 
int main()
{ //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
  //ll n,t;
 // cin>>t>>n;
  /* ll ar[n];
   f(i,0,n) cin>>ar[i]; */
   int n,x;
   string s;
   cin>>n>>s>>x;
   char xx=s[x-1];
   f(i,0,n)
    if(s[i]!=xx)
     s[i]='*';
    cout<<s; 
}


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

using namespace std;
typedef long long ll;

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

const int MOD = 2019; 

int main()
{
  ll L, R;
  cin >> L >> R;

  if((R/2019)!=(L/2019) || R%2019==0 || L%2019==0)
    {
      cout << 0 << endl;
      return 0;
    }

  ll min=1e10;
  for(ll i=L; i<R; i++)
    for(ll j=i+1; j<R+1; j++)
      if(min>(i*j)%MOD)
	min = (i*j)%MOD;

  cout << min << endl;
      
  

  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 256
n=int(input())
taka=[]
ao=[]
s=set()
for i in range(n):
    a,b=map(int,input().split())
    taka.append([a+b,a,i])
    ao.append([a+b,b,i])
    s.add(i)
taka.sort(reverse=True)
ao.sort(reverse=True)
takapt=0
takaind=0
aopt=0
aoind=0
while len(s)>0:
    while taka[takaind][2] not in s:
        takaind+=1
    s.remove(taka[takaind][2])
    takapt+=taka[takaind][1]
    if len(s)==0:
        break
    while ao[aoind][2] not in s:
        aoind+=1
    s.remove(ao[aoind][2])
    aopt+=ao[aoind][1]
print(takapt-aopt)


Measured memory_bytes: 84056
def main():
    n=int(input())
    s=input()
    l1=[0]*(n)
    l2=[0]*(n)
    l3=[0]*(n)
    for i in range(1,n):
        if s[i]=="R":
            l1[i-1]+=1
        elif s[i]=="G":
            l2[i-1]+=1
        else:
            l3[i-1]+=1
    for i in range(n-1,0,-1):
        l1[i-1]+=l1[i]
        l2[i-1]+=l2[i]
        l3[i-1]+=l3[i]
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            if set([s[i],s[j]])=={"G","B"}:
                ans+=l1[j]
                if 2*j-i<n and s[2*j-i]=="R":
                    ans-=1
            elif set([s[i],s[j]])=={"R","B"}:
                ans+=l2[j]
                if 2*j-i<n and s[2*j-i]=="G":
                    ans-=1
            elif set([s[i],s[j]])=={"R","G"}:
                ans+=l3[j]
                if 2*j-i<n and s[2*j-i]=="B":
                    ans-=1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 74940
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  vll h(n);

  rep(i, n) cin >> h[i];
  sort(all(h));

  ll ans = MOD;
  rep(i, n-k+1) chmin(ans, h[i+k-1] - h[i]);

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3992
S = [input() for _ in range(3)]
i = 0
while True:
  head = S[i][0:1]
  if len(S[i]) == 0:
    if i == 0:
      print("A")
    elif i == 1:
      print("B")
    elif i == 2:
      print("C")
    exit()
  else:
    S[i] = S[i][1:]
    if head == "a":
      i = 0
    elif head == "b":
      i = 1
    elif head == "c":
      i = 2 

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using ll=int_fast64_t;
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}

class FSmallProducts {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k,m;
        in>>n>>k;
        m=(int)sqrt(n);
        vector<modint> c(2*m),s(2*m+1),ns(2*m+1);
        fr(i,m) c[i]=1,c[i+m]=n/(m-i)-n/(m-i+1);
        if(n/m==m) c[m]-=1;
        s[0]=1;
        fr(_,k){
            ifr(i,2*m) ns[i]=ns[i+1]+(s[0]-s[2*m-i])*c[i];
            s.swap(ns);
        }
        out<<s[0]<<endl;
    }
};

int main() {
    FSmallProducts solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

int main() {
  int N, M, R[3000];
  memset(R, -1, sizeof(R));

  string S;

  cin >> N >> M;
  cin >> S;
  for(int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    R[l] = max(R[l], r);
  }
  for(int i = 0; i < N; i++) {
    if(i > 0) R[i] = max(R[i], R[i - 1]);
    R[i] = max(R[i], i);
  }

  vector< int > sum(N + 1);
  int one = 0;
  for(int i = 0; i < N; i++) {
    one += S[i] == '1';
    sum[i] = one;
  }

  vector< int > dp(3001);
  dp[0] = 1;
  for(int i = 0; i < N; i++) {
    vector< int > dp2(3001);
    for(int j = 0; j < dp.size(); j++) {
      int rest = sum[R[i]] - j;
      if(dp[j] == 0) continue;
      if(rest > 0) (dp2[j + 1] += dp[j]) %= mod;
      if(R[i] - i + 1 != rest) (dp2[j] += dp[j]) %= mod;
    }
    dp.swap(dp2);
  }
  cout << dp[sum[N - 1]] << endl;
}

Measured memory_bytes: 256
/*
<>>><<><<<<  <  >  >  >  <
012345678910 11 12 13 14 15
0<1>2>3>4<5<6>7<8<9<10<11<12>13>14>15<16
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main(){
  string S;
  cin >> S;
  vector<int> num(S.size());
  if(S[0] == '<'){
    num[0] = 0;
  }
  
  if(S[S.size()-1] == '>'){
    num[S.size()] = 0;
  }
  for(int i = 0; i < S.size()-1; i++){
    if(S[i] == '>' && S[i+1] == '<'){
      num[i+1] = 0;
    }
  }
  for(int i = 0; i < S.size()-1; i++){
    if(S[i] == '<' && S[i+1] == '<'){
      num[i+1] = num[i] + 1;
    }
  }
  for(int i = S.size()-1; i >= 0; i--){
    if(S[i-1] == '>' && S[i] == '>'){
      num[i] = num[i+1] + 1;
    }
  }
  for(int i = 0; i < S.size()-1; i++){
    if(S[i] == '<' && S[i+1] == '>'){
      num[i+1] = max(num[i],num[i+2])+1;
    }
  }
  if(S[0] == '>'){
    num[0] = num[1] + 1;
  }
  if(S[S.size()-1] == '<'){
    num[S.size()] = num[S.size()-1] + 1;
  }
  ll sum = 0;
  for(int i = 0; i < S.size()+1; i++){
    //cout << num[i] << " ";
    sum += num[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

ll lcm(ll a, ll b) {
    return a/gcd(a,b)*b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    ll ans = 1;
    rep(i, n) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
s=input()
s=list(s)
if len(s)%2==0:
    s.pop(len(s)-1)
    s.pop(len(s)-1)
else:
    s.pop(len(s)-1)

while len(s)>0:
    if s[:int(len(s)/2)]==s[int(len(s)/2):]:
        print(len(s))
        sys.exit()
    s.pop(len(s)-1)
    s.pop(len(s)-1)


Measured memory_bytes: 3060
n, k = map(int, input().split())
s = input()

now = None
cnt = []
before_i = 0
for i, c in enumerate(s):
	if i==0:
		now = c
		continue
	if now==c:
		continue
	else:
		cnt.append(i-before_i)
		now = c
		before_i = i
cnt.append(i+1-before_i)
l=0

if s[0] == '0':
	tmp = sum(cnt[:2*k])
	r = 2*k-1
	l0 = True
else:
	tmp = sum(cnt[:2*k+1])
	r = 2*k
	l0 = False

if r>=len(cnt):
	print(tmp)
	exit()

ans = tmp

while r+1<len(cnt):
	if l0:
		tmp = tmp - cnt[l]
		l += 1
		l0 = (cnt[l]==0)
	else:
		tmp = tmp - cnt[l] - cnt[l+1]
		l += 2
		l0 = (cnt[l]==0)
	tmp += cnt[r+1]
	if r+2<len(cnt):
		tmp += cnt[r+2]
		r += 2
	else:
		r += 1
	r0 = (cnt[r]==0)

	if tmp>ans:
		ans = tmp

print(ans)

Measured memory_bytes: 4596
import math
import sys
input = sys.stdin.readline

n = int(input())
a = [int(i) for i in input().split()]
maxNode = 1
total = 0
b = a[:]
for i in range(n, 0, -1):
	b[i - 1] += b[i]
for i in range(n + 1):
	maxNode = min(maxNode, b[i])
	if maxNode == 0 or maxNode < a[i]:
		print(-1)
		exit(0)
	total += maxNode
	maxNode = (maxNode - a[i]) * 2 
print(total)

Measured memory_bytes: 82980
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#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() {
  int n;
  cin >> n;

  int ans = n % 10;

  if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9) {
    cout << "hon" << endl;
  }else if (ans == 0 || ans == 1 || ans ==6 || ans == 8) {
    cout << "pon" << endl;
  }else {
    cout << "bon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] data = new char[str.length()];
		for(int i=0; i<str.length(); i++){
			data[i] = str.charAt(i);
		}
		if(data[0]!=data[1]&&data[1]!=data[2]&&data[2]!=data[0]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

int main()
{
  vector<int> a;
  int N;
  int s, t;
  long A = 0;
  int B = 0;

  cin >> N;
  //cout << N;
  //443211

  for (int i; i < 3*N; i++)
  {
    cin >> s;
    a.push_back(s);
    //cout << a.at(i);
  }

  sort(a.rbegin(), a.rend());

  for (int i; i < N; i++)
  {
    A += a[i*2+1];
  }

  cout << A << endl;
}

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

int main(){
    int n;
	cin >> n;
	vector<int> a;
	for(int i=0; i<n; i++){
		int num;
		cin>>num;
		a.push_back(num);
	}
	vector<int> b;
	for(int i=0; i<n; i++){
		int num;
		cin>>num;
		b.push_back(num);
	}
	vector<int> c;
	for(int i=0; i<n-1; i++){
		int num;
		cin>>num;
		c.push_back(num);
	}
	
	int sum=0;
	for(int i=0; i<a.size(); i++){
		int cur_index = a[i]-1;
		sum += b[cur_index];
		if(i+1<a.size() && a[i+1]-2==cur_index) sum += c[cur_index];
	}
	
	cout << sum << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        string s = ReadLine();
        WriteLine(s.Replace("eraser", "").Replace("erase", "").Replace("dreamer", "").Replace("dream", "") == "" ? "YES" : "NO");
    }
}

Measured memory_bytes: 13096
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <functional>
 
using namespace std;
 
 
int main() {
    int n, A, B;
    cin >> n >> A >> B;

    string s;
    cin >> s;

    int a = 0, b = 0;
    for(int i=0; i<n; i++){
        if(s[i]=='a'){
            if(a+b<A+B){
                cout << "Yes" << endl;
                a++;
                continue;
            }
        }
        else if(s[i]=='b'){
            if(a+b<A+B && b < B){
                cout << "Yes" << endl;
                b++;
                continue;           
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	int A, B, C, K;	cin >> A >> B >> C >> K;
	if (A >= B && A >= C) {
		cout << A * pow(2, K) + B + C << endl;
		return 0;
	}
	else if (B >= A && B >= C) {
		cout << B * pow(2, K) + A + C << endl;
		return 0;
	}
	else {
		cout << C * pow(2, K) + B + A << endl;
		return 0;
	}
}

Measured memory_bytes: 384
#1000 8
#1 3 4 5 6 7 8 9
n,k = map(int, raw_input().split())
s = set(map(int, raw_input().split()))
letters = [u for u in range(10) if u not in s]
def dfs(u,n,letters):return min([dfs(u*10 +l,n,letters) for l in letters if u or l]) if u < n else u

print dfs(0,n,letters)

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

using namespace std;

int main() {
    int d;
    cin >> d;

    if (d == 25) {
        cout << "Christmas" << endl;
    }else if (d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if (d == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }else {
        cout << "Christmas Eve" << endl;
    }
    return 0;
}


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

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

int dfs(int u, Graph &g, int *a, int *d){   // 1 : lose, 2 : win
    if(d[u]) return d[u];
    for(int v : g.g[u]){
        if(a[v] < a[u]){
            if(dfs(v, g, a, d) == 1) return d[u] = 2;
        }
    }
    return d[u] = 1;
}

int main()
{
    int n;
    cin >> n;
    int a[3005];
    for(int i = 0; i < n; i++) cin >> a[i];
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.add_edge(u, v);
        g.add_edge(v, u);
    }
    int d[3002]{0};
    for(int i = 0; i < n; i++){
        if(dfs(i, g, a, d) == 2) cout << i + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int a[2000002],all;	
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; all^=a[i];
	}
	for(int i=1;i<=n;i++)cout<<(all^a[i])<<" "; 
	return 0;
 } 

Measured memory_bytes: 4408
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

typedef long long LL;

int read() {
  int ans = 0, c, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f *= -1;
  do ans = ans * 10 + c - '0';
  while (isdigit(c = getchar()));
  return ans * f;
}

const int N = 2050;

int n, pre[N], nxt[N * 2], to[N * 2], cnt;

void addEdge(int x, int y) {
  nxt[cnt] = pre[x];
  to[pre[x] = cnt++] = y;
  nxt[cnt] = pre[y];
  to[pre[y] = cnt++] = x;
}

int A[N * 2];
int m, p2[N], n2[N * 2], t2[N * 2], inv[N * 2], c2;
int dir[N * 2], S[N];
bool vis[N];

void addE2(int x, int y) {
  n2[c2] = p2[x];
  t2[p2[x] = c2++] = y;
  n2[c2] = p2[y];
  t2[p2[y] = c2++] = x;
}

int fa[N];
int Find(int x) { return ~fa[x] ? fa[x] = Find(fa[x]) : x; }

int dfs0(int x, int f) {
  for (int i = pre[x]; ~i; i = nxt[i])
    if (to[i] != f)
      S[x] += dfs0(to[i], x);
  for (int i = p2[x]; ~i; i = n2[i]) {
    ++S[x];
    if (vis[t2[i]]) S[Find(t2[i])] -= 2;
  }
  fa[x] = f;
  vis[x] = true;
  return S[x];
}

void dfs(int x, int f) {
  for (int i = pre[x]; ~i; i = nxt[i])
    if (to[i] != f) dfs(to[i], x);
  int t = -1;
  for (int i = p2[x]; ~i; i = n2[i])
    if (dir[i] == -1) {
      if (t2[i] == x) {
        dir[i] = 0;
        dir[inv[i]] = 1;
      } else if (~t) {
        t2[inv[i]] = t2[t];
        t2[inv[t]] = t2[i];
        inv[inv[i]] = inv[t];
        inv[inv[t]] = inv[i];
        t = -1;
      } else {
        t = i;
      }
    }
  if (~t) {
    t2[inv[t]] = f;
    n2[t] = p2[f];
    p2[f] = t;
  }
}

int getd(int x) {
  if (~dir[x]) return dir[x];
  else return dir[x] = getd(inv[x]) ^ 1;
}

int main() {
  n = read(); m = read();
  memset(pre, -1, sizeof pre);
  memset(p2, -1, sizeof p2);
  memset(dir, -1, sizeof dir);
  memset(fa, -1, sizeof fa);
  for (int i = 1; i < n; ++i) addEdge(read(), read());
  for (int i = 0; i < m; ++i) addE2(read(), read());
  for (int i = 0; i < c2; ++i) A[i] = t2[i], inv[i] = i ^ 1;
  dfs0(1, 0);
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans += std::min(S[i], 2);
  dfs(1, 0);
  printf("%d\n", ans);
  for (int i = 0; i < c2; i += 2)
    if (getd(i)) printf("%d %d\n", A[i], A[i + 1]);
    else printf("%d %d\n", A[i + 1], A[i]);
  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

const long long INF = LLONG_MAX / 2;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        a[i] -= k;
    }

    long long sum = 0;
    map<long long, int> index;
    index[-INF];
    index[0];
    index[INF];
    for(int i=0; i<n; ++i){
        sum += a[i];
        index[sum];
        index[-sum];
    }
    int m = 0;
    for(auto& p : index){
        p.second = m;
        ++ m;
    }

    long long ans = 0;
    BinaryIndexedTree bit(m);
    sum = 0;
    for(int i=0; i<n; ++i){
        bit.add(index[sum], 1);
        sum += a[i];
        ans += bit.sum(0, index[sum]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27648
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ans = new int[n+1];
		for(int x = 1; x <= 100; x++) {
			for(int y = 1; y <= 100; y++) {
				for(int z = 1; z<= 100; z++) {
					int num =  x*x+y*y+z*z+x*y+y*z+x*z;
					if(num<=n) {
						ans[num]++;
					}
				}
			}
		}
		for(int i =1; i <= n; i++) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 38960
import numpy as np

def main():
    n = int(input())
    a = np.zeros([n], dtype=int)
    for i in range(n):
        a[i] = int(input())

    ma = np.argmax(a)
    sec = 0
    for i in range(n):
        if i == ma:
            continue
        if a[i] > sec:
            sec = a[i]
    for i in range(n):
        if a[i] < a[ma]:
            print(a[ma])
        else:
            print(sec)


if __name__ == "__main__":
    main()

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

int main()
{
  string s;
  cin >> s;
  vector<bool> found(26, false);

  for (int i=0; i<s.size(); i++)
    found.at(s.at(i) - 'a') = true;
  
  bool complete = false;
  for (int i=0; i<26; i++) {
    if (found.at(i) == false) {
      char tmp = 'a' + i;
      cout << tmp << endl;
      break;
    }
  	if (i==25) complete = true;
  }
  if (complete) cout << "None" << endl;
}

Measured memory_bytes: 512
from itertools import product
def main():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        c = input()
        C.append(c)
    r = 0
    for i in product(range(2), repeat=H):
        for j in product(range(2), repeat=W):
            t = 0
            for ii in range(H):
                for jj in range(W):
                    if i[ii] == 0 and j[jj] == 0 and C[ii][jj] == '#':
                        t += 1
            if t == K:
                r += 1
    return r
print(main())


Measured memory_bytes: 9220
// abc140-c
object Main extends App {
  val n = io.StdIn.readInt
  val bs = io.StdIn.readLine.split(" ").map(_.toInt)

  def rec(baselist: List[Int], acc: List[Int]): List[Int] = baselist match {
    case head::Nil  => acc:+head
    case head::tail => rec(tail, acc:+math.min(head, tail.head))
  }

  val result = rec(bs.toList, List(bs.head)).sum
  println(result)
}

Measured memory_bytes: 54968