akhauriyash/Code-Regression huggingface dataset:
class Main {
    public static void main(String[] args){
    	for(int i = 1; i < 10; i ++){
    		for(int j = 1; j < 10; j ++){
    			System.out.println("" + i + "x" + j + "=" + i * j);
    		}
    	}
	}
}

Measured memory_bytes: 24048
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)1e5+5;

int n,m,a,b,c,q,dp[N],tab[N];
vi V;

int R(int l, int p){
	return rand()%(p-l+1)+l;
}

void wczytaj(){
	cin>>n>>tab[1];
	tab[0]=tab[1];
	for (int i=2; i<=n; ++i){
		cin>>tab[i];
		dp[i]=min(dp[i-2]+abs(tab[i-2]-tab[i]),dp[i-1]+abs(tab[i-1]-tab[i]));
	}
	cout<<dp[n]<<'\n';
}

void solve(){

}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		solve();
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

string nextString(){string s;cin >> s;return s;}

int main(){
  int n,m;
  vector<string> regid;
  string id;
  int isopen=0;
  cin >> n;
  REP(i,n)regid.push_back(nextString());
  cin >> m;
  REP(i,m){
    cin >> id;
    REP(j,regid.size()){
      if(id == regid[j]){
	if(isopen){
	  isopen--;
	  cout << "Closed by " << id << endl;
	}else{
	  isopen++;
	  cout << "Opened by " << id << endl;
	}
	break;
      }
      if(j == regid.size()-1)
	cout << "Unknown " << id << endl;
    }
  }
      
  return 0;
}

Measured memory_bytes: 3208
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

n=int(input())

a=[]
for j in range(n):
    v,i=input().split()
    i=int(i)
    a.append([v,i,j])
a.sort(key=lambda x:(x[0],-x[1]))
for each in a:
    print(each[2]+1)

Measured memory_bytes: 3316
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print('No')
else:
    if C<D:
        print('Yes')
    else:
        if "..." in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')

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

int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double menseki = (double)w*h/2;
  int condition =0;
  if(x==w/2 && y==h/2) condition=1;
  
  printf("%6f %d", menseki, condition);
  return 0;
  
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long[] A = cin.ArrayLong(N);
        Array.Sort(A);
        int ok = 0;
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] > sum * 2) ok = 0;
            sum += A[i];
            ok++;
        }
        Console.WriteLine(ok);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 27740
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

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

	deque<char> ans;
	ll inv=0;
	REP(i,s.size()){
		ans.push_back(s[i]);
	}


	REP(i,q){
		char tmp;
		cin>>tmp;
		if(tmp=='1')inv++;
		if(tmp=='2'){
			cin>>tmp;
			tmp-='0';
			if((tmp+inv)%2==1){
				cin>>tmp;
				ans.push_front(tmp);
			}else{
				cin>>tmp;
				ans.push_back(tmp);
			}
		}
	}
	if(inv%2==0){
		REP(i,ans.size()){
			cout<<ans[i];
		}
	}else{
		REP(i,ans.size()){
			cout<<ans[ans.size()-i-1];
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstdint>
#include <vector>

int main() {
  intmax_t N;
  scanf("%jd", &N);

  intmax_t A[]={1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

  std::vector<int> dp(N+1, 1e7);
  dp[0] = 0;
  dp[1] = 1;
  for (int i=0; i<N; ++i) {
    for (int a: A) {
      if (i+a <= N)
        dp[i+a] = std::min(dp[i+a], dp[i]+1);
    }
  }

  printf("%d\n", dp[N]);
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++) cin>>A[i]>>B[i];

  vector<pair<ll,ll>> v;
  for(int i=0;i<N;i++) v.push_back(mkp(B[i],i));

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

  ll sum=0;
  for(int i=0;i<N;i++){
    sum+=A[v[i].second];
    if(sum>v[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 9584
N = int(input())
A = list(map(int, input().split()))
for i in range(1, len(A) + 1):
  buff = "node {}: key = {}, ".format(i, A[i - 1])
  j = i // 2
  if j > 0: buff += "parent key = {}, ".format(A[j - 1])
  j = i * 2
  if j <= len(A): buff += "left key = {}, ".format(A[j - 1])
  j = i * 2 + 1
  if j <= len(A): buff += "right key = {}, ".format(A[j - 1])
  print(buff)

Measured memory_bytes: 7644
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M := nextInt(), nextInt()
	lb := make([][]int, M)
	for i := 0; i < M; i++ {
		k := nextInt()
		lb[i] = make([]int, k)
		for j := 0; j < k; j++ {
			lb[i][j] = nextInt() - 1
		}
	}
	Pm := make([]int, M)
	for i := range Pm {
		Pm[i] = nextInt()
	}
	var cnt int
	for bit := 0; bit < 1<<uint(N); bit++ {
		ok := true
		for i := 0; i < M; i++ {
			sum := 0
			for j := 0; j < len(lb[i]); j++ {
				// bitのlb[i][j]個目の要素の状態がonかどうかチェック
				// https://qiita.com/3x8tacorice/items/0b8341d7fd3ff3779111
				if bit>>uint(lb[i][j])&1 == 1 {
					sum++
				}
			}
			if sum%2 != Pm[i] {
				ok = false
				break
			}
		}
		if ok {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

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

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

int main()
{
    string p,s;
    cin>>p>>s;
    REP(i,p.size())
    {
        bool flag=1;
        REP(j,s.size())
        {
            int sum=i+j;
            if(sum>=p.size())sum=sum-p.size();
            if(p.at(sum)!=s.at(j))flag=0;
        }
        if(flag==1){cout<<"Yes"<<endl;return 0;}
    }cout<<"No"<<endl;
}


Measured memory_bytes: 3216
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	string S, T;
	int a, b;
	cin >> S >> T;
	scanf("%d %d", &a, &b);
	string U;
	cin >> U;
	if (U == S) a--;
	if (U == T) b--;
	printf("%d %d\n", a, b);
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct N{
   int p, l, r;
};

struct N T[MAX];

int n;

void preParse(int u){
   if (u==NIL)
      return;
   printf(" %d", u);
   preParse(T[u].l);
   preParse(T[u].r);
}

void inParse(int u)
{
   if (u==NIL)
   {
      return;
   }
   inParse(T[u].l);
   printf(" %d", u);
   inParse(T[u].r);
}

void postParse(int u)
{
   if (u==NIL){
      return;
   }
   postParse(T[u].l);
   postParse(T[u].r);
   printf(" %d", u);
}

int main()
{
   int i, id, l, r, root;

   scanf("%d", &n);
   for (i=0; i<n; i++)
   {
      T[i].p = NIL;
   }

   for (i=0; i<n; i++)
   {
      scanf("%d %d %d", &id, &l, &r);
      T[id].l = l;
      T[id].r = r;
      if (l!=NIL)
         T[l].p = id;
      if (r!=NIL)
         T[r].p = id;
   }

   for (i=0; i<n; i++)
   {
      if (T[i].p==NIL)
      {
         root = i;
      }
   }

   puts("Preorder");
   preParse(root);
   printf("\n");
   puts("Inorder");
   inParse(root);
   printf("\n");
   puts("Postorder");
   postParse(root);
   printf("\n");

   return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    cout << 48 - n << endl;
    return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public struct AB
        {
            public int A;
            public int B;
        }
        public void Calc()
        {
            //var p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            //var N = p[0];
            //var M = p[1];
            //var X = p[2];

            //var C = new long[N];
            //var A = new long[N, M];


            //for (var i = 0; i < N; i++)
            //{
            //    p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            //    C[i] = p[0];

            //    for (var j = 0; j < M; j++)
            //    {
            //        A[i, j] = p[j + 1];
            //    }
            //}

            var p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var N = (int)p[0];
            var K = p[1];
            var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();


            var list = new List<int>();
            var contains = new HashSet<int>();
            var count = 1;
            var now = 1;
            contains.Add(now);
            list.Add(now);
            while (true)
            {
                now = A[now - 1];
                list.Add(now);

                if (contains.Contains(now))
                {
                    break;
                }
                contains.Add(now);

            }

            var last = list.Last();
            var idx = list.IndexOf(last);

            if (K < list.Count)
            {
                Console.WriteLine(list[(int)K]);

            }
            else
            {
                var K2 = (K - idx) % (list.Count - idx - 1);
                Console.WriteLine(list[(int)(idx + K2)]);
            }


        }


    }

}


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

ll mod=1e9+7;
vector<ll> tfact(1e7+1,-1);
ll n,k;
ll mpow(ll x, ll n){
   ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll fact(ll n) {
  if(tfact[n]<0) {
    if(n==0) {
      tfact[n]=1;
    }
    else {
      tfact[n]=fact(n-1)*n%mod;
    }
  }
  return tfact[n];
}

ll comb(ll n, ll k) {
  return fact(n)*mpow(fact(k),mod-2)%mod*mpow(fact(n-k),mod-2)%mod;
}


int main() {
  cin >> n >> k;
  vector<ll> x(n);
  for(int i=0;i<n;i++) {
    cin >> x.at(i);
  }
  sort(x.rbegin(),x.rend());
  
  ll ans=0;
  for(int i=0;i<=n-k;i++) {
    ans = (ans + x.at(i)*comb(n-1-i,k-1)%mod)%mod;
  }
  for(int i=0;i<=n-k;i++) {
    ans = (mod+ans - x.at(n-1-i)*comb(n-1-i,k-1)%mod)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 82304
S=int(input())
from math import*
def comb(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

count=0
ans=0
S-=3
while S>=count:
    ans+=comb(S,count)
    count+=1
    S-=2
ans%=10**9+7
print(ans)

Measured memory_bytes: 9060
"use strict";
function Main(input) {
  const args = input.split(' ').map(m => parseInt(m));
  const r = args.shift();
  const D = args.shift();
  let x = args.shift();

  for (let i = 0; i < 10; i++) {
    x = r * x - D;
    console.log(x);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
n = gets.to_i
a = gets.chomp
b = gets.chomp
c = gets.chomp

count = 0

n.times do |i|
  if a[i] == b[i] && a[i] == c[i]
    count += 0
  elsif a[i] == b[i] || b[i] == c[i] || a[i] == c[i]
    count += 1
  else
    count += 2
  end
end

puts count


Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>

main(){
  int M1,M2,D1,D2;
  scanf("%d%d",&M1,&D1);
  scanf("%d%d",&M2,&D2);
  
  if(M1 == M2){
    printf("0");
  }
  else{
    printf("1");
  }
}

Measured memory_bytes: 128
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, A, B;
int main() {
	ios::sync_with_stdio(false);
	cin >> N >> A >> B;
	cout << min(A * N, B) << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,k,s,ans=0;
  cin >> n >> m;
  vector<int> v[m];
  int p[m];
  for(int i=0;i<m;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> s;
      s--;
      v[i].push_back(s);
    }
  }
  for(int i=0;i<m;i++){
    cin >> p[i];
  }
  for(int bi=0;bi<(1<<n);bi++){
    int bit[n],tmp=bi;
    for(int i=0;i<n;i++){
      bit[i]=tmp%2;
      tmp/=2;
    }
    bool judge=false;
    for(int i=0;i<m;i++){
      int sum=0;
      for(size_t j=0;j<v[i].size();j++){
        sum+=bit[v[i][j]];
      }
      if(sum%2!=p[i]) judge=true;
    }
    if(!judge) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int a,b;

int main(){
    cin>>a>>b;
    out((a<=b?a:a-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::vector<long long> A)
{

  vector<PII> input;
  for (int i = 0; i < N; i++)
    input.emplace_back(A[i], i);
  sort(input.begin(), input.end());

  vector<vector<LL>> dp(N + 2, vector<LL>(N + 2, 0));

  for (int mid = 0; mid < N; mid++)
  {
    for (int left = 0; left < N; left++)
    {
      int right = left + mid;
      if (right >= N)
        continue;
      LL costL = input[mid].first * abs(input[mid].second - left);
      LL costR = input[mid].first * abs(input[mid].second - right);
      dp[left][right] = costL;
      if (mid == 0)
        continue;
      dp[left][right] = max(dp[left + 1][right] + costL, dp[left][right - 1] + costR);
    }
  }
  cout << dp[0][N - 1] << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 34664
N,K = map(int,input().split())
lis = list(map(int,input().split()))
dic = {}
for i in range(1,N+1):
    dic[i] = 0
for i in lis:
    dic[i] += 1
lis2 = list(dic.values())
lis2.sort()

print(sum(lis2[:N-K:]))

Measured memory_bytes: 37580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, y, z, N;
  x = 0;
  z = 0;
  y = 100000000;
  cin >> n;
  N = n;
  for (int i = 0; i < 9; i++) {
     z = n / y;
     x += z;
     n -= z * y;
     y /= 10;
   }
  if (N % x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ld a, b, h, m;
	cin>>a>>b>>h>>m;
	ld x = ((h*60 + m)*30 - m*360) / 60;
	x = abs(x);
	x = (x * M_PI) / 360;
	x = 2 * x;
	ld ans = a*a + b*b - 2*a*b*cos(x);
	ans = sqrt(ans);
	cout<<setprecision(18)<<fixed<<ans;
	return 0;
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin>>x;
    cout<<(1-x);
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int a, b, c;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    }
    else if (a == c) {
        cout << b << endl;
    }
    else {
        cout << a << endl;
    }
}


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

int main() {
  string N;
  cin >> N;
  string ans;
  int oddnum = 0;
  int evennum = 0;
  int count = 0;
  count = N.size();
  for (int i = 0; i < N.size(); i++) {
    if ((i+1)%2 == 1) {
      if (N.at(i) == 'R' || N.at(i) == 'U' || N.at(i) == 'D') {
        oddnum++;
      }
    }
    if ((i+1)%2 == 0) {
      if (N.at(i) == 'L' || N.at(i) == 'U' || N.at(i) == 'D') {
        evennum++;
      }
    }
  }
  
  if ((oddnum+evennum) == count)
    ans = "Yes";
  else
    ans = "No";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int Ans[305][305];
char Str[305] , Array[305][305];

void AssignNumbers( int r1 , int c1 , int r2 , int c2 , int Num ){
    for( int i = r1 ; i <= r2 ; ++i ){
        for( int j = c1 ; j <= c2 ; ++j ){
            Ans[i][j] = Num;
        }
    }
}

void FindPartition( int H , int W ){
    int i , j , Row = 1 , Column = 1;
    int Count = 0 , k = 1;

    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j )
            Ans[i][j] = 0;
    }

    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j ){
            if( Array[i][j] == '#' ){
                ++Count;

                if( Count == 2 ){
                    AssignNumbers( Row , Column , i , j - 1 , k );
                    ++k;
                    Count = 1;
                    Column = j;
                }
            }
        }

        if( Count == 1 ){
            AssignNumbers( Row , Column , i , W , k );
            ++k;
            Count = 0;
            Row = i + 1;
            Column = 1;
        }
    }

    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j ){
            if( Ans[i][j] == 0 ) Ans[i][j] = Ans[i - 1][j];
        }
    }
}

int main(){
    int H , W , K , i , j;
    scanf( "%d%d%d" , &H , &W , &K );

    for( i = 1 ; i <= H ; ++i ){
        scanf( "%s" , Str + 1 );

        for( j = 1 ; j <= W ; ++j ){
            Array[i][j] = Str[j];
        }
    }

    FindPartition( H , W ); 

    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j )
            printf( "%d " , Ans[i][j] );

        puts( "" ); 
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

int cnt = 0;
vector<ll> res;

void func(ll cur) {
  if(cur>3234566667)return;
  res.push_back(cur);

  ll lowest_place = cur%10;
  if(lowest_place==0) func(cur*10+1);
  else if(lowest_place==9) func(cur*10+8);
  else {func(cur*10+lowest_place-1); func(cur*10+lowest_place+1);}
  func(cur*10+lowest_place);
}

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

  // 再帰による全列挙
  // https://drken1215.hatenablog.com/entry/2020/04/05/150900
  int K; cin>>K;
  reps(i,1,10) func(i);
  sort(ALL(res));
  cout << res[K-1] << endl;

  return 0;
}


Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)		memset(v, d, sizeof(v))
const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>P;
const ll mod = ll(1e9 + 7);
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, -1, 1 };
const int N = 1000001;
#define endl '\n'
#define ever ;;
#define F first
#define S second
#define pii pair<int,int>
#define sz(v) ((int)((v).size()))
#define pll pair<ll,ll>
void stop() {
#ifndef ONLINE_JUDGE
	system("pause");
#endif
}
void file() {
#ifndef ONLINE_JUDGE
	freopen("pizza.in", "r", stdin);
	freopen("pizza.out", "w", stdout);
#endif
}
struct point {
	double x, y;
};
ull gcd(ull a, ull b) { return !b ? a : gcd(b, a % b); }
ll fixMod(ll a, ll b) { return ((a%b) + b) % b; }
double triangle_area(int x1, int y1, int x2, int y2, int x3, int y3) {
	return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2.;
};
ll dis(point a, point b) {
	ll x = a.x - b.x, y = a.y - b.y;
	return x * x + y * y;
}
ull LCM(ull a, ull b) {
	return a / gcd(a, b)*b;
}
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	if (y == 1)return x;
	ll r = power(x, y / 2) % mod;
	return r%mod*r%mod*power(x, y % 2) % mod;
}
int main() {
	fast
		ll a, b;
	cin >> a >> b;
	if (a > 12)cout << b;
	else if (a <= 5)cout << 0;
	else cout << b / 2;
	stop();
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int N,M;
vector<int> g[1010];
int col[1010];
bool used[1010];
bool flag;
void dfs(int v,int c){
	used[v]=true;
	col[v]=c;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(used[u]){
			if(col[u]==col[v]){
				flag = false;
			}
		}else{
			dfs(u,-c);
		}
	}
}
bool solve(){
	cin >> N >> M;
	if(N+M==0)return false;
	for(int i=0;i<N;i++)g[i].clear();
	for(int i=0;i<M;i++){
		int u,v;
		cin >> u >> v;
		u--;v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	flag = true;
	memset(col,0,sizeof(col));
	memset(used,false,sizeof(used));
	dfs(0,1);
	if(!flag){
		cout << 0 << endl;
		return true;
	}
	int a=0,b=0;
	for(int i=0;i<N;i++){
		if(col[i]==1)a++;
		else b++;
	}
	vector<int> ans;
	if(a%2==0)ans.pb(a/2);
	if(b%2==0)ans.pb(b/2);
	
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++)cout << ans[i] << endl;
	return true;
}
int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3308
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    auto as = readln.split.to!(long[]);
    auto res = long.max;
    while (true) {
        auto candidates = as.filter!(a => a > 0);
        if (candidates.empty) break;
        const m = candidates.reduce!min;
        foreach (ref a; as) 
            if (a != m)
                a %= m;
        res = min(res, m);
        if (candidates.all!(a => a == m)) break;
    }
    writeln(res);
}



Measured memory_bytes: 4404
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a, b, c, con;
    for(int i = 0; i <= 999; i++) {
        con = N + i;
        a = con % 10;
        con = con / 10;
        b = con % 10;
        con = con / 10;
        c = con % 10;
        if (a == b && b == c) {
            cout << N + i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import math
h,n = map(int,input().split())


a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = []
for i in range(h + max(a)):
    dp.append(pow(2, 31) - 1)
dp[0] = 0

for i in range(1, len(dp)):
    '''
    tmp = dp[i]
    for j in range(n):
        tmp = min(tmp, dp[max(0, i-a[j])] + b[j])
    dp[i] = tmp
    '''
    dp[i] = min(dp[i - A] + B for A, B in zip(a, b))

print(min(dp[h:]))

Measured memory_bytes: 3820
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£?????????????????§????????????????????????
		//????????\???
		Scanner sc = new Scanner(System.in);
		//???????????\???????????°???
		int n = sc.nextInt();
		//???????????£?¨?
		int list []  = new int[n];
		//?¬??????\????????°???
		for(int i = 0; i < n; i++){
			//???????????\??????
			list[i] = sc.nextInt();
		}
		for(int i = n - 1; i >=0; i--){
			if(i > 0){
				System.out.print(list[i] + " ");
			}else {
				System.out.print(list[i]);
			}
		}
		System.out.println();
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int MAX_N=114514;

int prime[MAX_N];
bool is_prime[MAX_N+1];

// エラトステネスの篩
// is_prime[i]=true⇔iが素数
void sieve(int n){
	int res=0;
	REP(i, n+1){
		is_prime[i]=true;
	}
	is_prime[0]=is_prime[1]=false;
	FOR(i, 2, n+1){
		if(is_prime[i]){
			prime[res++]=i;
			for(int j=2*i; j<=n; j+=i){
				is_prime[j]=false;
			}
		}
	}
}

int s[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q, l, r;
	cin>>q;
	sieve(1e5);
	for(int i=3; i<1e5; i+=2){
		s[i]=s[i-2]+(is_prime[i] && is_prime[(i+1)/2] ? 1 : 0);
	}
	REP(i, q){
		cin>>l>>r;
		cout<<s[r]-s[l-2]<<'\n';
		// DEBUG(s[r]);
		// DEBUG(s[l]);
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,X,D=0,cnt=1;
  cin>>N>>X;
  int L[N];
  for(int i=0;i<N;i++) cin>>L[i];
  for(int i=1;;i++,cnt++){
  	D=D+L[i-1];
    if(D>X) break;
  }
  cout<<cnt<<endl;
}	


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int N;
  queue<char> que;
  while(cin >> N , N){
    int sum[10] = {} , g = 0 , now = 0;
    for(int i = 0 ; i < 100 ; i++ ){
      char c;
      cin >> c;
      que.push(c);
    }
    while(!que.empty()){
      char Top = que.front(); que.pop();
      if(Top == 'M') sum[now]++;
      else if(Top == 'S') g += sum[now] + 1 , sum[now] = 0;
      else sum[now] += g + 1 , g = 0;
      now = ( now + 1 ) % N;
    }
    sort(sum,sum+N);
    for(int i = 0 ; i < N ; i++ ) cout << sum[i] << " ";
    cout << g << endl;
  }
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll H, W;
	cin >> H >> W;

	vector<vector<ll>> a(H, vector<ll>(W));

	for (ll h = 0; h < H; ++h) for (ll w = 0; w < W; ++w) cin >> a[h][w];



	vector<ll> n_odd(H, 0);
	for (ll h = 0; h < H; ++h) for (ll w = 0; w < W; ++w)
	{
		if (a[h][w] % 2 != 0) n_odd[h]++;
	}

	vector<ll> moveto(H, -1);
	bool flag = true;
	ll prev_h = -1;
	for (ll h = 0; h < H; ++h)
	{
		if (n_odd[h] % 2 == 0) continue;

		if (!flag)
		{
			moveto[prev_h] = h;
			flag = true;
			continue;
		}

		flag = false;
		prev_h = h;
	}

	vector<pair<P, P>> sousa;
	ll h = 0;
	while (true)
	{
		for (ll w = 0; w < W-1; ++w)
		{
			if (a[h][w] % 2 == 0) continue;

			a[h][w]--;
			a[h][w + 1]++;
			sousa.emplace_back(P(h, w), P(h, w + 1));
		}

		if (h == H - 1) break;

		if (a[h][W - 1] % 2 != 0)
		{
			a[h][W - 1]--;
			a[h+1][W - 1]++;
			sousa.emplace_back(P(h, W - 1), P(h + 1, W - 1));
		}

		h++;

		for (ll w = W-1; 0 < w; --w)
		{
			if (a[h][w] % 2 == 0) continue;

			a[h][w]--;
			a[h][w-1]++;
			sousa.emplace_back(P(h, w), P(h, w - 1));
		}

		if (h == H - 1) break;

		if (a[h][0] % 2 != 0)
		{
			a[h][0]--;
			a[h + 1][0]++;
			sousa.emplace_back(P(h, 0), P(h + 1, 0));
		}
	}

	cout << sousa.size() << endl;

	for (const auto& e : sousa)
	{
		cout << e.first.first+1 << " " << e.first.second + 1 << " " << e.second.first + 1 << " " << e.second.second + 1 << "\n";
	}

	//cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 8176
#include <iostream>
using namespace std;
int main(void){
    long long N,i,j;
    double p;
    cin>>N;
    double a[N+1],b[N+1];
    for(i=0;i<N+1;i++){
        a[i]=0;
    }
    a[0]=1;
    for(i=0;i<N;i++){
        cin>>p;
        b[0]=a[0]*(1-p);
        for(j=1;j<N+1;j++){
            b[j]=a[j]*(1-p)+a[j-1]*p;
        }
        for(j=0;j<N+1;j++){
            a[j]=b[j];
        }
    }
    p=0;
    for(i=N/2+1;i<N+1;i++){
        p+=a[i];
    }
    printf("%.12f\n",p);
}

Measured memory_bytes: 256
#include <stdio.h>
#define ORDERMAX 2000000
#define MAX 2000000001
#define NIL -1073741824

void insert(int);
int extractMax(void);
void scan(void);
void swapping(int *,int *);
void perfecttree(int);

int A[MAX],H;

int main(){
  scan();
  
  return 0;
}

void scan(void){
  char order[8];
  int key;
  while(1){
    scanf("%s",order);
    if(order[2] == 's'){
      scanf("%d",&key);
      insert(key);
    }
    else if(order[2] == 'd') break;
    else printf("%d\n",extractMax());
  }
}

void insert(int key){
  int i;
  H++;
  A[H] = NIL;
  i = H;

  if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[i / 2] < A[i]){
    swapping(&A[i],&A[i / 2]);
    i = i / 2;
  }
}

void swapping(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

int extractMax(void){
  int ret;
  if(H < 1) return NIL;
  ret = A[1];
  A[1] = A[H];
  H--;
  perfecttree(1);
  return ret;
}

void perfecttree(int i){
  int big,left,right,j;
 
  left = 2 * i;
  right = 2 * i + 1;
  
  if(left < H + 1 && A[left] > A[i]) big = left;
  else big = i;
  if(right < H + 1 && A[right] > A[big]) big = right;
  
  if(big != i){
    swapping(&A[i],&A[big]);
    perfecttree(big);
  }
}



Measured memory_bytes: 5684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = size(s);
    bool ok = false;
    for(int i = 0; i < n; i++) {
        string ss = string(n, '.');
        for(int j = 0; j < n; j++) {
            ss[j] = s[(i + j) % n];
        }
        if(ss == t) ok = true;
    }
    if(ok) Yes(); else No();
}

Measured memory_bytes: 3604
import java.util.*;

/*
問題文
正整数 N 及び、長さ N の英小文字から成る文字列 S が与えられます。

この文字列が、ある文字列を二度繰り返したものであるかを判定してください。
則ち、文字列 T であって、S=T+T となるものが存在するかを判定してください。

制約
1≤N≤100
S は英小文字から成る
|S|=N

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        String first = s.substring(0, n/2);
        String end = s.substring(n/2, n);

        if (n % 2 == 1 || !first.equals(end)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

        sc.close();
    }
}

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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

void beet() {
  int64 N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  using int128 = __int128_t;
  map< int64, int128 > mp;
  auto rec = MFP([&](auto rec, int64 N) -> int128 {
    if(N == 1) return D;
    if(mp.count(N)) return mp[N];
    int128 ret = (int128) D * N;
    if(N / 2 > 0) chmin(ret, rec(N / 2) + (N % 2) * D + A);
    if(N / 3 > 0) chmin(ret, rec(N / 3) + (N % 3) * D + B);
    if(N / 5 > 0) chmin(ret, rec(N / 5) + (N % 5) * D + C);
    if((N + 1) / 2 < N) chmin(ret, rec((N + 1) / 2) + (2 - (N % 2)) % 2 * D + A);
    if((N + 2) / 3 < N) chmin(ret, rec((N + 2) / 3) + (3 - (N % 3)) % 3 * D + B);
    if((N + 4) / 5 < N) chmin(ret, rec((N + 4) / 5) + (5 - (N % 5)) % 5 * D + C);
    return mp[N] = ret;
  });
  cout << (int64) rec(N) << "\n";
}

int main() {
  int T;
  cin >> T;
  while(T--) beet();
}



Measured memory_bytes: 4696
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int h,a;
  cin >> h >> a;
  cout << (h-1)/a+1 << endl;
  return 0;
}


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

int NN[100002];

const int MOD = 1000000007;

long long int kaizyodp[100002];

int n_1comdp[100002];
int lcomdp[100002];


long long int kaizyo(long long int n) {  // n!
	if (kaizyodp[n] != -1) return kaizyodp[n];
	else if (n == 1 || n == 0) return (long long int)1;
	else return kaizyodp[n] = (long long int)((n * kaizyo(n - 1)) % MOD);
}

long long int ruizyo(long long int n, long long int m) {  // n^m
	if (m == 1) return (long long int)n % MOD;
	else if (m % 2 == 0) {
		return (long long int)(ruizyo(((n * n) % MOD), m / 2) % MOD);
	}
	else {
		return (long long int)((n * ruizyo(n, m - 1)) % MOD);
	}
}


int combination(long long int n, long long int m) {
	if (n < m || m < 0) return 0;
	return (((kaizyo(n) * ruizyo(kaizyo(m), MOD - 2)) % MOD) * ruizyo(kaizyo(n - m), MOD - 2)) % MOD;
}


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

	memset(NN, 0, sizeof(NN));
	memset(kaizyodp, -1, sizeof(kaizyodp));
	memset(n_1comdp, 0, sizeof(n_1comdp));
	memset(lcomdp, 0, sizeof(lcomdp));

	int snum = 0;
	int endnum = 0;

	for (int i = 1; i <= n + 1; i++) {
		if (NN[a[i]] == 0) NN[a[i]] = i;
		else {
			snum = NN[a[i]];
			endnum = i;
			break;
		}
	}

	long long int l = snum - 1 + (n + 1 - endnum);


	/*for (long long int i = 1; i < 100002; i++) {
		n_1comdp[i] = combination(n + 1, i);
		lcomdp[i] = combination(l, i);
	}*/

	cout << n << endl;

	for (int i = 2; i <= n + 1; i++) {
		cout << (combination(n + 1, i) - combination(l, i - 1) + MOD) % MOD << endl;
		//cout << (n_1comdp[i] - lcomdp[i - 1] + MOD) % MOD << endl;
	}
	return 0;
}



Measured memory_bytes: 5120
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),max=-1,min=Integer.MAX_VALUE;
		
		for(int i=0;i<n;i++)
		{
			int curr=sc.nextInt();
			
			min=Math.min(min,curr);max=Math.max(max,curr);
		}
		
		out.println(max-min);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 22228