akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace れんすううう
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] array = s.Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);

            int c = a * b;
            if(c%2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
           


        }
    }
}


Measured memory_bytes: 27184
from statistics import mean
n, a, b = [int(_) for _ in input().split()]
values = [int(v) for v in input().split()]
values.sort(reverse=True)
maximum_mean = mean(values[:a])
print(maximum_mean)

min_value = values[:a][-1]
accepted = values[:a].count(min_value)
full = values.count(min_value)

# def cmb(n, r):
#     if n - r < r: r = n - r
#     if r == 0: return 1
#     if r == 1: return n

#     numerator = [n - r + k + 1 for k in range(r)]
#     denominator = [k + 1 for k in range(r)]

#     for p in range(2,r+1):
#         pivot = denominator[p - 1]
#         if pivot > 1:
#             offset = (n - r) % p
#             for k in range(p-1,r,p):
#                 numerator[k - offset] /= pivot
#                 denominator[k] /= pivot

#     result = 1
#     for k in range(r):
#         if numerator[k] > 1:
#             result *= int(numerator[k])

#     return result
nCr = {}
def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]



if min_value == maximum_mean:
    ans = 0
    for r in range(a, b+1):
        ans += cmb(full, r)
else:
    ans = cmb(full, accepted)

print(ans)






Measured memory_bytes: 5276
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	if(i%3!=0&&i%5!=0)
	sum+=i;	
	}
	cout<<sum;
	
}

Measured memory_bytes: 3592
n = int(input())
a  = [int(i) for i in input().split()]

dic = {}
for i in range(n):
  dic[i+1] = a[i]

ans = ""
for k, v in sorted(dic.items(), key=lambda x: x[1]):
  ans += str(k) + " "
print(ans[:-1])

Measured memory_bytes: 25496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int[] arr = new int[5];
        for(int i=0; i<5; i++)
            arr[i] = Integer.parseInt(s[i]);
        
        for(int i=0; i<5; i++) {
            if(arr[i] == 0) {
                System.out.print(i+1);
                return;
            }
        }
        System.out.print(-1);
    }
}

Measured memory_bytes: 32716
using System;
using System.Collections.Generic;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input;
			List<string> outList = new List<string> ();
			while ((input = Console.ReadLine()) != null) {
				string[] array = input.Split (' ');
				List<double> list = new List<double> ();
				foreach (string s in array) {
					list.Add (double.Parse(s));
				}

				double y = Math.Round((list [2] * list [3] - list [0] * list [5]) / (list [1] * list [3] - list [0] * list [4]),3,MidpointRounding.AwayFromZero);
				double x = Math.Round((list [2] * list [4] - list [1] * list [5]) / (list [0] * list [4] - list [1] * list [3]),3,MidpointRounding.AwayFromZero);
				string outString = string.Format ("{0:f3} {1:f3}", x, y);
				outList.Add (outString);

			}

			foreach (string s in outList) {
				Console.WriteLine (s);
			}


		}
	}
}

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

int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
void maxHeapify(int a[], int i, int n)
{
    int l = left(i);
    int r = right(i);
    int largest = 0;

    if (l <= n && a[l] > a[i])
        largest = l;
    else
        largest = i;
    if (r <= n && a[r] > a[largest])
        largest = r;

    if (largest != i)
    {
        swap(a[i], a[largest]);
        maxHeapify(a, largest, n);
    }
}
void buildMaxHeap(int a[], int n)
{
    for (int i = n / 2; i > 0; i--)
        maxHeapify(a, i, n);
}

int main()
{
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    buildMaxHeap(a, n);
    for (int i = 1; i <= n; i++)
    {
        cout << ' ';
        cout << a[i];
    }
    cout << endl;
}


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

int main() {
  int N, A;
  
  cin >> N >> A;
  
  if(A==0){
    if(N%500==0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  else if(N%500<=A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//iの各桁の和を計算し、a以上b以下であればtrueを返す関数
bool check(int i, int a, int b){
  int sum = 0;
  sum += i/10000 + i/1000%10 + i/100%10 + i/10%10 + i%10;
  if (a<=sum && sum<=b){
    return true;
  }else{
    return false;
  }
}
 
int main() {
  int n,a,b; cin >>n >>a >>b;
  int ans = 0;
  for (int i=1; i<n+1; i++){
    if (check(i,a,b)){
      ans += i;
    }
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var map = new char[H][];
            var memo = new int[H, W] ;
            for (var i=0;i<H;i++)
            {
                map[i] = ReadLine().ToCharArray();
            }
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    memo[i, j] = -1;
                }
            }
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    if (map[i][j] == '#') memo[i, j] = 0;
                }
            }

            var q = new Queue<List<int>>();
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    if (map[i][j] == '#') q.Enqueue(new List<int> { i, j });
                }
            }
            while (q.Any())
            {
                var item = q.Dequeue();
                if (item[0] <0|| H<=item[0] || item[1]<0||W<= item[1]) continue;
                if (0<=item[0] - 1 && item[0] - 1 < H &&
                    memo[item[0] - 1, item[1]] == -1)
                {
                    q.Enqueue(new List<int> { item[0]-1, item[1] });
                    memo[item[0] - 1, item[1]] = memo[item[0], item[1]] + 1;
                }
                if (0 <= item[0] + 1 && item[0] + 1 < H &&
                    memo[item[0] + 1, item[1]] == -1)
                {
                    q.Enqueue(new List<int> { item[0]+1, item[1] });
                    memo[item[0] + 1, item[1]] = memo[item[0], item[1]] + 1;
                }
                if (0 <= item[1] - 1 && item[1] - 1 < W &&
                    memo[item[0], item[1] - 1] == -1)
                {
                    q.Enqueue(new List<int> { item[0], item[1]-1 });
                    memo[item[0], item[1] - 1] = memo[item[0], item[1]] + 1;
                }
                if (0 <= item[1] + 1 && item[1] + 1 < W &&
                    memo[item[0], item[1] + 1] == -1)
                {
                    q.Enqueue(new List<int> { item[0], item[1]+1 });
                    memo[item[0], item[1] + 1] = memo[item[0], item[1]] + 1;
                }
            }
            var max = 0;
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    if (max < memo[i, j]) max = memo[i, j];
                }
            }
            WriteLine(max);
        }
    }
}

Measured memory_bytes: 133660
//#define		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<cstdio>

using namespace std;

#define		MAX		(250 + 1)

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE

	int			H[MAX];
	int			n;
	cin >> n;

	for (int i = 1; i <= n; ++i)
	{
		cin >> H[i];
	}

	for (int i = 1; i <= n; ++i)
	{
		printf("node %d: key = %d, ", i, H[i]);
		if (i != 1)
			printf("parent key = %d, ", H[i / 2]);
		if (i * 2 <= n)
			printf("left key = %d, ", H[i * 2]);
		if ((i * 2 + 1) <= n)
			printf("right key = %d, ", H[i * 2 + 1]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define Rep(i,n,m) for(int i = (int)(n);i < (int)(m);i++)
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl 
 
int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;
    x3 = x2 - y2 + y1;
    y3 = y2 + x2 - x1;
    x4 = x1 + x3 - x2;
    y4 = y1 + y3 - y2;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 <<endl;
}

Measured memory_bytes: 256
package main

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

const (
	N = 8
	FREE = -1
	ATTACKED = 1
)

var scanner = bufio.NewScanner(os.Stdin)

var (
	row []int // row[x](x = 0, 1, ... ,N-1)がATTACKEDなら行xは襲撃されている
	col []int // col[x](x = 0, 1, ... ,N-1)がATTACKEDなら列xは襲撃されている
	dpos []int // dpos[x](x = 0, 1, ... ,2(N-1))がATTACKEDなら左下方向の列xは襲撃されている
	dneg []int // dneg[x](x = 0, 1, ... ,2(N-1))がATTACKEDなら右下方向の列xは襲撃されている
	X [][]bool // 目当ての盤目を指定するための二次配列
)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func initialize() {
	row = make([]int, N)
	col = make([]int ,N)
	dpos = make([]int, 2*N-1)
	dneg = make([]int, 2*N-1)
	for i := 0; i < N; i++ {
		row[i] = FREE
		col[i] = FREE
	}
	for i := 0; i < 2*N-1; i++ {
		dpos[i] = FREE
		dneg[i] = FREE
	}
}

func printBoard() {
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if X[i][j] {
				if row[i] != j {
					return
				}
			}
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if row[i] == j {
				fmt.Printf("Q")
			} else {
				fmt.Printf(".")
			}
		}
		fmt.Println()
	}
}

func solve(i int) {
	if i == N {
		printBoard()
		return
	}
	for j := 0; j < N; j++ {
		if ATTACKED == col[j] || ATTACKED == dpos[i+j] || ATTACKED == dneg[i-j+N-1] {
			continue
		}
		row[i] = j
		col[j] = ATTACKED
		dpos[i+j] = ATTACKED
		dneg[i-j+N-1] = ATTACKED
		solve(i+1)
		row[i] = FREE
		col[j] = FREE
		dpos[i+j] = FREE
		dneg[i-j+N-1] = FREE
	}
}

func main() {
	scanner.Split(bufio.ScanWords)
	k := nextInt()
	initialize()
	X = make([][]bool, N)
	for i := 0; i < N; i++ {
		X[i] = make([]bool, N)
		for j := 0; j < N; j++ {
			X[i][j] = false
		}
	}
	for i := 0; i < k; i++ {
		r := nextInt()
		c := nextInt()
		X[r][c] = true
	}
	solve(0)

}


Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
 
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
 
int main() {
    ll n,m;
    cin >> n >> m;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll p[n];
    rep(i,n) p[i]=a[i]/2;
    ll P=p[0];
    bool OK=true;
    for(ll i=1;i<n;i++) {
        P=lcm(P,p[i]);
    }
    rep(i,n){
        if((P/p[i])%2==0) OK=false;
    }
    if(OK){
        if((m/P)%2==1) cout << ((m/P)+1)/2 << endl;
        else cout << (m/P)/2 << endl;
    }
    else {
        cout << 0 << endl;
    }
    
    
}



Measured memory_bytes: 1792
n,p = map(int,input().split())
dp = [[0]*(p+1) for _ in range(n)]
W,V = [],[]
for _ in range(n):
    w,v = map(int,input().split())
    W.append(w)
    V.append(v)
for i in range(n):
    for j in range(p+1):
        if j -W[i]>=0:
            dp[i][j] = max(dp[i][j], dp[i-1][j],dp[i-1][j-W[i]] + V[i])
        else:
            dp[i][j] = max(dp[i][j], dp[i-1][j])
print(max(dp[-1]))


Measured memory_bytes: 151692
#include<bits/stdc++.h>
using namespace std;
 
bool bz[500010];
int gs,n;
long long b[1010][1010],c[1010][1010],ans[1010][1010],zs[500010];
int fx[4][2]={{0,-1},{0,1},{-1,0},{1,0}};
 
long long gcd(long long a,long long b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}
 
long long lcm(long long x, long long y) 
{
	if (x==0 || y==0) return x+y;
	return x/gcd(x,y)*y;
}
 
int main()
{
	for (int i=2;i<=500000;i++)
	{
		if (!bz[i])
		{
			gs++;
			zs[gs]=i;
			for (int j=1;j<=500000/i;j++)
			{
				bz[j*i]=true;
			}
		}
	}
	scanf("%d",&n);
	if (n==2)
	{
		printf("4 7\n");
		printf("23 10\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (i%2==1)
		{
			int x=1;int y=i;
			while (x<=n && y<=n)
			{
				b[x][y]=zs[i];
				x++;y++;
			}
			if (i==1) continue;
			x=i;y=1;
			while (x<=n && y<=n)
			{
				b[x][y]=zs[i-1];
				x++;y++;
			}
		}
	}
	for (int i=n;i>=1;i--)
	{
		if (i%2==1)
		{
			int x=1;int y=i;
			while (x<=n && y>=1)
			{
				c[x][y]=zs[n+n-i+1];
				x++;y--;
			}
			if (i==n) continue;
			if (n%2==0) x=n-i+1;
			else x=n-i+1;y=n;
			while (x<=n && y>=1)
			{
				c[x][y]=zs[n+n-i];
				x++;y--;
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if ((i+j)%2==0)
			{
				ans[i][j]=b[i][j]*c[i][j];
			}
		}
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(!ans[i][j]) 
			{
				ans[i][j]=lcm(lcm(ans[i-1][j],ans[i][j-1]),lcm(ans[i][j+1],ans[i+1][j]))+1;
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			printf("%lld ",ans[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 16364
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        long x = scanner.nextLong();
        final long y = scanner.nextLong();

        int counter = 0;
        while (x <= y) {
            x *= 2L;
            counter++;
        }

        System.out.println(counter);
    }
}


Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0,ans=0;
    REP(i,n){
        if(s[i]=='I')cnt++;
        else cnt--;
        ans=max(cnt,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : B.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-06-14
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10) << fixed;
    int x, y;
    cin >> x >> y;
    bool f = 0;

    for (int i = 1; i <= x; i++) {
        int xx = x - i;
        int val = (xx * 2) + (i * 4);

        if (val == y) f = 1;

        val = (xx * 4) + (i * 2);

        if (val == y) f = 1;
    }

    if (f) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    int N, K;
    cin >> N >> K;
    int l[N];
    rep(i, N) cin >> l[i];
    sort(l, l + N);
    for(int i = N - 1; i >= N - K; i--) cnt += l[i];
    cout << cnt << endl;
}

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

ansl = [0]*(n+1)

for x in range(1,10**2):
    for y in range(1, 10**2):
        for z in range(1,10**2):
            val = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if val <= n:
                ansl[val] += 1

for i in range(1,n+1):
    print(ansl[i])

Measured memory_bytes: 68596
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second



signed main(){
  string s;
  cin>>s;
  if(s[0]=='a')cout<<"square1001"<<endl;
  else cout<<"e869120"<<endl;
}


Measured memory_bytes: 3160
#include <stdio.h>

int main(void)
{
  int N, K;
  char dummy;

  scanf("%d%c", &N, &dummy);

  char S[N+1];

  scanf("%s", S);
  scanf("%d", &K);

  char tmp = S[K-1];

  for (int i=0;i<N;i++){
    if (S[i] != tmp){
      S[i] = '*';
    }
  }

  printf("%s\n", S);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int n,m,a,b,c;
	int d[100005] = {};
	string s;

    cin >> a >> b >>c;

    if(a != b){
        if(a != c){
            P(a);
        }else{
            P(b);
        }
    }else P(c);
    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int x; cin>>x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
}

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

int main() {
  int s;
  scanf("%d", &s);
  set<int> a;
  int i=1;
  while(1) {
    if ( a.count(s) ) break;
    a.insert(s);
    if ( s%2==0 ) s/=2;
    else s=s*3+1;
    i++;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, K = map(int, input().split())

ans = 1
if K % 2 == 0:
    x = N // K
    y = N // K + (1 if K * x + K // 2 <= N else 0)
    print(x ** 3 + y ** 3)
else:
    x = N // K
    print(x ** 3)



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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define FILL(v,p) memset(v,p,sizeof v)
#define FIO ios::sync_with_stdio(NULL); cin.tie(NULL)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define PI acos(-1.0)

const ll MOD = 1000000007;
const ll INF = 2000000000000000001LL;
const ld EPS = 1e-9;

int main()
{
    FIO;
    
    double x;
    cin >> x;
    
    cout << setprecision(13) << (x/3)* (x/3) * (x/3) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
			while (n-- > 0) {
				int sum = 0;
				int num = scanner.nextInt();
				for (int i = 0; i < 4; i++) {
					sum += scanner.nextInt() * 60;
					sum += scanner.nextInt();
				}
				map.put(sum, num);
			}
			int count = 0;
			int size = map.size();
			for (int entry : map.values()) {
				if (count == 0 || count == 1 || count == size - 2)
					System.out.println(entry);
				count++;
			}
		}
	}
}

Measured memory_bytes: 63156
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e5+5;
ll dp[N], arr[N];
ll n, k;
ll solve(ll x)
{
    if(x==n-1)
        return 0;
    else if(dp[x]!=-1)
        return dp[x];
    ll ret=2e9;
    for(int i=x+1; i<n && i-x<=k; i++)
        ret=min(ret, solve(i)+abs(arr[i]-arr[x]));
    // ll ret = solve(x+1)+abs(arr[x+1]-arr[x]);
    dp[x] = ret ;
    return ret ;
}


int main()
{
     _69e27
     memset(dp, -1, sizeof dp);
     cin >> n >> k;
     for(int i=0; i<n; i++)
        cin >> arr[i];
     cout << solve(0);


    return 0 ;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
using P = std::pair<int, ll>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[123],b[123],dv[123],d[123],p[123],cnt[123];
std::vector<int> g[123];
std::queue<int> que;
std::vector<P> ans;

P bfs(void){
	int u,v,j,i,m=0;
	ll ret = 1ll;
	std::fill(cnt,cnt+123,0);
	while(!que.empty()){
		u = que.front();
		que.pop(); i = 0;
		m = std::max(m,d[u]);
		for(j=(g[u].l_ength()-1); j>=0; --j){
			v = g[u][j];
			if(v==p[u]){
				continue;
			}
			p[v] = u;
			d[v] = d[u] + 1; ++i;
			que.push(v);
		}
		cnt[d[u]] = std::max(cnt[d[u]],i);
	}
	for(i=0; i<m; ++i){
		ret *= cnt[i];
	}
	return P(m+1,ret);
}

int main(void){
	int n,i,j,u,v;
	P tmp;
	std::cin >> n;
	for(i=1; i<n; ++i){
		std::cin >> a[i] >> b[i];
		--a[i]; --b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
		++dv[a[i]]; ++dv[b[i]];
	}
	for(i=0; i<n; ++i){
		p[i] = n; d[i] = 0;
		que.push(i);
		tmp = bfs();
		if(dv[i]==1){
			++tmp.second;
		}
		ans.push_back(tmp);
	}
	for(i=1; i<n; ++i){
		p[a[i]] = b[i]; p[b[i]] = a[i];
		d[a[i]] = 0; d[b[i]] = 0;
		que.push(a[i]); que.push(b[i]);
		tmp = bfs();
		tmp.second *= 2;
		ans.push_back(tmp);
	}
	sort(ans.begin(),ans.end());
	std::cout << ans[0].first << " " << ans[0].second << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 100005;
const int md = 1e9+7;
int n, k, a, b;
vector<int> G[mx];
long long ans;
bool used[mx];
void dfs(int p, int u){
	int t = p ? k-2 : k-1;
	for(int nx: G[u]){
		if(nx == p) continue;
		(ans *= t--) %= md;
		dfs(u,nx);
	}
}
int main(){
	scanf("%d%d", &n, &k);
	ans = k;
	rep(i,n-1){
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,1);
	printf("%lld\n", ans);
}

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

using namespace std;

int main() {
	int K, X;

	cin >> K >> X;

	int start = max( -1000000, X - K + 1);
	int end   = min(  1000000, X + K);

	for (int i = start; i < end; i++)
	{
		cout << i << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int p[N], q[N], r[N];
int a, b, c, x, y;

int main()
{
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	for (int i = 0; i < a; i++) {
		scanf("%d", p + i);
	}
	for (int i = 0; i < b; i++) {
		scanf("%d", q + i);
	}
	for (int i = 0; i < c; i++) {
		scanf("%d", r + i);
	}
	sort(p, p + a, greater<int>());
	sort(q, q + b, greater<int>());
	sort(r, r + c, greater<int>());
	priority_queue<int> pq;
	for (int i = 0; i < x; i++) {
		pq.push(-p[i]);
	}
	for (int i = 0; i < y; i++) {
		pq.push(-q[i]);
	}
	for (int i = 0; i < c; i++) {
		int t = pq.top();
		if (-t < r[i]) {
			pq.pop();
			pq.push(-r[i]);
		} else break;
	}
	ll ans = 0;
	while (!pq.empty()) {
		ans -= pq.top();
		pq.pop();
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int x, e;
    int min;

    while(cin >> e) {
        if (!e) break;
        min = e;
        for(int y = 0; y * y <= e; y++) {
            for(int z = 0; z * z * z <= e; z++) {
                x = e - y * y - z * z * z;
                if(x < 0) continue;
                if(x + y + z < min) min = x + y + z;
            }
        }
        cout << min << endl;
    }
}

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

int main(){
	int N, M;
	cin >> N >> M;
	int a[N], b[N];
	int c[M], d[M];
	rep(i,N) cin >> a[i] >> b[i];
	rep(i,M) cin >> c[i] >> d[i];

	rep(i,N) {
		int dist_min = 1e9;
		int cp;
		rep(j,M) {
			int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if (dist < dist_min) {
				dist_min = dist;
				cp = j+1;
			}
		}
		cout << cp << endl;
	}
	return 0;
}


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

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

	int N, M;
	cin >> N >> M;
	long a[50], b[50], c[50], d[50];
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	int z[50][50];
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
		for (int j = 0; j < N; j++) {
			z[j][i] = abs(a[j] - c[i]) + abs(b[j] - d[i]);
		}
	}
	for (int i = 0; i < N; i++) {
		long m = 400000000;
		int check;
		for (int j = 0; j < M; j++) {
			if (z[i][j] < m) {
				m = z[i][j];
				check = j;
			}
		}
		cout << check+1 << endl;
	}
}

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

#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
#define DEBUG(x) cerr << #x << " = " << x << endl

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	
	string s;

	cin >> s;
	bool ok = true;
	vector<int> f(4, 0);
	REPU(i, 0, s.size()) {
		if (s[i] == 'S') f[0] = 1;
		if (s[i] == 'N') f[1] = 1;
		if (s[i] == 'W') f[2] = 1;
		if (s[i] == 'E') f[3] = 1;
	}
	if (f[0] != f[1] || f[2] != f[3]) ok = false;
	puts(ok ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
// by hjnan
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
int T, a, b, c, d;
map<int, int> mp;
main(void) {
  for(read(T); T --;) {
    read(a); read(b); read(c); read(d);
    mp.clear();
    if(b > d || a < b) puts("No");
    else {
      int p = __gcd(d, b);
      int ta = (a - c) % p + c;
      if(ta == c) ta += p;
      if(ta < b) puts("No");
      else puts("Yes");
    }
  }
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        String s = sc.nextLine();
//        int k = sc.nextInt();
//        int a = sc.nextInt();
//        int b = sc.nextInt();        
        int r = sc.nextInt();
        sc.close();
        System.out.println(2*r*Math.PI);
//        if(s <= w){
//            System.out.println(Math.PI);
//        }else{
//            System.out.println("safe");
//        }
//        System.out.println(s);
//        if(s.contains("RRR")){
//            System.out.println(3);
//        }else if(s.contains("RR")){
//            System.out.println(2); 
//        }else if(s.contains("R")){
//            System.out.println(1);
//        }else{
//             System.out.println(0);
//        }
//        String s = sc.nextLine();
//        String t = sc.next();
//        String[] arr =  s.split("　");
//        sc.close();
//        System.out.println("input: "+ s);
//        System.out.println("k:" + k);
//        System.out.println("a:" + a);
//        System.out.println("b:" + b);
//        String ans = "NG";
//        for(int x = a; x<=b; x++){
//            if(x%k == 0){
//                ans = "OK";
//            }
//        }
//        System.out.println(ans);
//        \
//        System.out.println("arr[1]:" + arr[1]);
//
//        if(s.equals("ABC")){
//            System.out.println("ARC");
//        }else{
//            System.out.println("ABC");
//        }
//        String[] arr1 =  s.split("");
//        String[] arr2 =  t.split("");
////        List<String> list1 = Arrays.asList(s.split(""));
//        List list1 = new LinkedList(Arrays.asList(s.split("")));
////        List<String> list2 = Arrays.asList(t.split(""));
//        List list2 = new LinkedList(Arrays.asList(t.split("")));
////        int num = Integer.parseInt(arr[arr.length - 1]);
//        list2.remove(arr2.length - 1);
////        System.out.println(list1);
////        System.out.println(list2);
//         if(list1.toString().contentEquals(list2.toString())){
//             System.out.println("Yes");
//         }else{
//             System.out.println("No");
//         }
//        switch(num){
//            case 3:
//                System.out.println("bon");
//                break;
//            case 0:
//            case 1:
//            case 6:
//            case 8:
//                System.out.println("pon");
//                break;
//            default:
//                System.out.println("hon");
//                break;
//        }
//        String[] array = str.split(" ");
//        int sum = 0;
//        for(int i=0; i<array.length; i++) {
//            int num = Integer.parseInt(array[i]);
//            sum += num;
//        }
//        System.out.println(15-sum);
    }
}

Measured memory_bytes: 35888
#include <cstdio>
#include <algorithm>
#define ll long long
#define N 200005
int n, a[N][2], q[N<<1][2];
ll ans;
char s[15];
void proc(int id)
{
	int l=0, ok=0;
	ll num=0;
	for(int i=1; s[i]; ++i)
	{
		if(s[i]=='.') ok=1;
		else
		{
			num=10*num+s[i]-'0';
			l+=ok;
		}
	}
	while(num%2==0) num/=2, ++a[id][0];
	while(num%5==0) num/=5, ++a[id][1];
	a[id][0]-=l, a[id][1]-=l;
}
int lb, rb, lim, sum[N], id[N<<1];
inline int lowbit(int x) { return x&(-x); }
inline void add(int p) { while(p<=lim) ++sum[p], p+=lowbit(p); }
inline int ask(int p) { int ret=0; while(p) ret+=sum[p], p-=lowbit(p); return ret; }
bool cmp(int a, int b) { return q[a][0]==q[b][0]?q[a][1]==q[b][1]?(a&1)<(b&1):q[a][1]>q[b][1]:q[a][0]>q[b][0]; }
int main()
{
//	freopen("A.in", "r", stdin);
	scanf("%d", &n);
	lb=100, rb=-100;
	for(int i=1; i<=n; ++i) scanf("%s", s+1), proc(i), id[i<<1]=i<<1, q[i<<1][0]=a[i][0], q[i<<1][1]=a[i][1],
	id[i<<1|1]=i<<1|1, q[i<<1|1][0]=-a[i][0], q[i<<1|1][1]=-a[i][1], ans-=(a[i][0]>=0&&a[i][1]>=0),
	lb=std::min(lb, a[i][1]<0?a[i][1]:-a[i][1]), rb=std::max(rb, a[i][1]<0?-a[i][1]:a[i][1]);
	++rb;
	lim=rb-lb;
	std::sort(id+2, id+(n<<1|1)+1, cmp);
	for(int i=2; i<=(n<<1|1); ++i)
	{
		if(id[i]&1) ans+=ask(rb-q[id[i]][1]);//, printf("ask %d %d %d\n", q[id[i]][0], q[id[i]][1], ask(rb-q[id[i]][1]));
		else add(rb-q[id[i]][1]);//, printf("add %d %d\n", q[id[i]][0], q[id[i]][1]);
	}
	printf("%lld\n", ans/2);
	return 0;
}

Measured memory_bytes: 9276
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    size_t N, K;
    long long L, R;
    scanf("%zu %zu %lld %lld", &N, &K, &L, &R);

    vector<long long> a(N);
    for (size_t i=0; i<N; ++i)
        scanf("%lld", &a[i]);

    vector<pair<size_t, long long>> former(1<<(N/2));
    for (size_t i=0; i<former.size(); ++i)
        for (size_t j=0; (1u<<j)<=i; ++j)
            if (1<<j & i) {
                ++former[i].first;
                former[i].second += a[j];
            }

    vector<pair<size_t, long long>> latter(1<<(N-N/2));
    for (size_t i=0; i<latter.size(); ++i)
        for (size_t j=0; (1u<<j)<=i; ++j)
            if (1<<j & i) {
                ++latter[i].first;
                latter[i].second += a[N/2+j];
            }

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

    size_t total=0;
    for (pair<size_t, long long> v: former) {
        vector<pair<size_t, long long>>::iterator lb=lower_bound(
            latter.begin(), latter.end(), make_pair(K-v.first, L-v.second)
        );

        vector<pair<size_t, long long>>::iterator ub=upper_bound(
            latter.begin(), latter.end(), make_pair(K-v.first, R-v.second)
        );

        total += ub-lb;
    }

    printf("%zd\n", total);
    return 0;
}

Measured memory_bytes: 35076
//package Contest077;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            String str1 = sc.next();
            String str2 = sc.next();
            StringBuilder sb = new StringBuilder(str1);
            sb = sb.reverse();
            str1 = sb.toString();
            if(str1.equals(str2))
                out.println("YES");
            else
                out.println("NO");

        out.flush();
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    double a = scan.nextDouble();
    double b = scan.nextDouble();
    double h = scan.nextDouble();
    double m = scan.nextDouble();

    double t = h * 60 + m;

    double diff = Math.abs(t / 720 - m / 60);
    diff = Math.min(diff, 1 - diff);

    double ans = a * a + b * b;
    // System.out.println(diff);
    ans -= 2 * a * b * Math.cos(diff * 2 * Math.PI);
    System.out.println(Math.sqrt(ans));
  }
}

Measured memory_bytes: 28876
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K, S = MAP()

if S == 10**9:
	tmp = 1
else:
	tmp = 10**9
ans = [S]*K + [tmp]*(N-K)

print(*ans)


Measured memory_bytes: 7420
#include <stdio.h>
int main (void) {
  int i,j,num,a,b;
  char str[1001],tem[1001],com[20];
  scanf("%s",str);
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s %d %d",com,&a,&b);
    if(com[0]=='p'){
      for(j=a;j<=b;j++) 
      printf("%c",str[j]);
      printf("\n");
    }
    else if(com[2]=='p'){
      scanf("%s",tem);
      for(j=a;j<=b;j++) str[j]=tem[j-a];
    }
    else if(com[2]=='v'){
      for(j=a;j<=b;j++) tem[j]=str[j];
      for(j=a;j<=b;j++) str[j]=tem[b-(j-a)];
    }
  }
  return 0;
}


Measured memory_bytes: 2108
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if A[i] <= A[i+1]:
        pass
    else:
        plus = A[i]-A[i+1]
        #print(plus)
        ans += plus
        A[i+1] = A[i]
print(ans)

Measured memory_bytes: 105104
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n;cin>>n;
  
  ll p=sqrt(n);
    cout<<p*p;
}
  
        
  

Measured memory_bytes: 256
N,M=map(int,input().split());A=[input()for _ in range(N)];B=[input()for _ in range(M)];print("YNeos"[all(any(t!=s[j:j+M]for s,t in zip(A[i:],B))for i in range(N-M+1)for j in range(N-M+1))::2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN

const int N=1e5+5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
void EE(ll a,ll b,ll &co1,ll &co2)
{
    if(a%b==0)
    {
        co1=0;
        co2=1;
        return;
    }
    EE(b,a%b,co1,co2);
    ll temp=co1;
    co1=co2;
    co2=temp-co2*(a/b);
}
ll modinv(ll a,ll m)
{
    ll x,y;
    EE(a,m,x,y);
    if(x<0) x+=m;
    return x;
}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={0},ip;
    for(ll i=0;i<m;i++)
    {
        cin>>ip;
        a[ip] = -1;
    }
    a[0] = 1;  
    if(a[1]!=-1)
        a[1] = 1;
    for(ll i=2;i<=n;i++)
    {
        ll x=a[i-1];
        if(a[i-1]==-1)
            x = 0;
        ll y=a[i-2];
        if(a[i-2]==-1)
            y = 0;
        if(a[i]!=-1)
            a[i] = (x+y)%mod;
    }
    cout<<a[n]%mod;
    return 0;
}  

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

int main(){
    int a;
    cin >> a;
    int b[a];
    for(int i=0;i<a;i++){
        cin >> b[i];
    }
    int num1=0,num2=1000000000;
    for(int j=1;j<a;j++){
        if(num1<=max(b[j-1],b[j]))
        num1=max(b[j-1],b[j]);
        if(num2>=min(b[j-1],b[j]))
        num2=min(b[j-1],b[j]);
    }
    cout << num1-num2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int count = 0;
    string word, the;
    cin >> the;
    while(1){
        cin >> word;
        if(word == "END_OF_TEXT") break;
        for(int i=0; i < sizeof(word); i++){
            word[i] = tolower(word[i]);
        }
        if(word == the) count++;

    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1192
from collections import deque

X, Y, A, B, C = map(int, input().split())
P = sorted([int(n) for n in input().split()])
Q = sorted([int(n) for n in input().split()])
R = sorted([int(n) for n in input().split()], reverse=True)

PQ = deque(sorted(P[-X:] + Q[-Y:]))
R = deque(R)

while R and R[0] > PQ[0]:
    PQ.append(R.popleft())
    PQ.popleft()

print(sum(PQ))

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

using namespace std;

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

	int pos_a = -1;
	int pos_z = -1;
	for(int i=0;i<z.size();++i){
		if(z[i]=='A' && pos_a==-1)pos_a=i;
		if(z[i]=='Z' && i>pos_a)pos_z=i;
	}

	cout << (pos_z-pos_a+1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node_struct{int p,l,r;}; /*p: 親(parent), l: 一番左の子(left child), r:右のこども(right child)*/
typedef struct Node_struct Node;

Node T[MAX];
int D[MAX];
int H[MAX];
int deg[MAX];
int S[MAX];
int t;

void print(int u){
  
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,S[u],deg[u],D[u],H[u]);
  
  if(T[u].p == NIL) printf("root");
  else if(T[u].l == NIL && T[u].r== NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
}

void calcDepth(int u, int p){
  D[u] = p;
  
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
  if(T[u].r != NIL) calcDepth(T[u].r,p+1);
}

void calcHeight(int u, int p){
  if(T[u].p != NIL) calcHeight(T[u].p,p+1);
  if(p >= H[u]) H[u] = p;
}

int main(){
  int i,j;
  int n;
  int c;
  int id,L_child,R_child;
  int root = NIL;
  scanf("%d",&n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = S[i] = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d",&id);  
    scanf("%d%d",&L_child,&R_child);
    
    T[id].l = L_child;
    T[id].r = R_child;
    
    if(i == 0){
      S[id] = NIL;
      T[id].p = NIL;
    }
    if(L_child != NIL){
      T[L_child].p = id;
      if(R_child != NIL){
	S[L_child] = R_child;
      }
    }
    
    if(R_child != NIL){
      T[R_child].p = id;
      if(L_child != NIL){
	S[R_child] = L_child;
      }
    }


  }
  
  //根
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //深さ
  calcDepth(root, 0);
    
  //高さ
  for(i=0; i<n; i++){
    calcHeight(i,0);
  }
  
  //こどもの数
  for(i=0; i<n; i++){
    if(T[i].l != NIL && T[i].r != NIL) deg[i] = 2;
    if((T[i].l != NIL && T[i].r == NIL) || (T[i].l == NIL && T[i].r != NIL)) deg[i] = 1;
    if(T[i].l == NIL && T[i].r == NIL) deg[i] = 0;
  }
  
  //出力
  for(i=0; i<n; i++){
    print(i);
  }
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> data(n);
	ff(i, 0, n) {
		int a;
		cin >> a;
		data.at(i).first = a;
		data.at(i).second = i+1;
	}
	sort(data);
	cout << data.at(0).second;
	ff(i, 1, n) {
		cout << " " << data.at(i).second;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    t.pop_back();
    cout << (s == t ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3528