akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

var (
	sc = NewScanner(os.Stdin)
	//sc = NewScanner(strings.NewReader("3 4 10 40"))
)

func main() {
	float64s := sc.ReadLine().Float64s()
	A, B, H, M := float64s[0], float64s[1], float64s[2], float64s[3]

	jishin := 30 * (H + M/60)
	byoshin := 6 * M

	radian := (jishin - byoshin) * math.Pi / 180
	distance := math.Sqrt(math.Pow(A, 2) + math.Pow(B, 2) - 2*A*B*math.Cos(radian))

	fmt.Println(distance)
}

type Scanner struct {
	scanner *bufio.Scanner
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{scanner: bufio.NewScanner(r)}
}

func (sc *Scanner) ReadLine() Value {
	if sc.scanner.Scan() {
		return Value(sc.scanner.Text())
	}
	panic(sc.scanner.Err())
}

func (sc *Scanner) ReadLines(n int) Values {
	a := make(Values, n)
	for i := range a {
		a[i] = sc.ReadLine()
	}
	return a
}

type Value string

func (v Value) String() string {
	return string(v)
}

func (v Value) Strings() []string {
	return strings.Split(string(v), " ")
}

func (v Value) Int() int {
	n, err := strconv.Atoi(v.String())
	if err != nil {
		panic(err)
	}
	return n
}

func (v Value) Ints() []int {
	strings := v.Strings()
	ints := make([]int, len(strings))

	for i, s := range strings {
		n, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		ints[i] = n
	}
	return ints
}

func (v Value) Float64() float64 {
	f, err := strconv.ParseFloat(v.String(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func (v Value) Float64s() []float64 {
	strings := v.Strings()
	float64s := make([]float64, len(strings))

	for i, s := range strings {
		f, err := strconv.ParseFloat(s, 64)
		if err != nil {
			panic(err)
		}
		float64s[i] = f
	}
	return float64s
}

type Values []Value

func (v Values) Strings() [][]string {
	a := make([][]string, len(v))
	for i, value := range v {
		a[i] = value.Strings()
	}
	return a
}

func (v Values) Ints() [][]int {
	a := make([][]int, len(v))
	for i, value := range v {
		a[i] = value.Ints()
	}
	return a
}

func (v Values) Float64s() [][]float64 {
	a := make([][]float64, len(v))
	for i, value := range v {
		a[i] = value.Float64s()
	}
	return a
}


Measured memory_bytes: 1732
#include<stdio.h>
#include<math.h>
int main(){
	int i, ii;
	char op[1000];
	int a[1000];
	int b[1000];
	int ans[1000];
	for(i=0;i < 1000;i++){
		a[i] = 0;
	}
	for(i=0;i < 1000;i++){
		b[i] = 0;
	}
	for(i=0;i < 1000;i++){
		op[i] = ' ';
	}
	for(i=0;i < 1000;i++){
		ans[i] = 0;
	}
	
	i = 0;
	ii = 0;
	while(1){
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if(op[i] == '?') break;
		ii++;
		i++;
		if(i > 1000) break;
	}
	i = 0;
	while(i <= ii){
		if(op[i] == '+'){
			ans[i] = a[i] + b[i];
		}else if(op[i] == '-'){
			ans[i] = a[i] - b[i];
		}else if(op[i] == '*'){
			ans[i] = a[i] * b[i];
		}else if(op[i] == '/'){
			ans[i] = a[i] / b[i];
		}else{
			break;
		}
		i++;
	}
	
	for(i=0;i<ii;i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n+1];
    for (int i = 0; i < n; i++) cin >> a[i];
    a[n] = 0;
    long long ans = 1000, st = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < a[i+1]) {
            long long k = ans / a[i];
            ans -= a[i] * k;
            st += k;
        } else if (a[i] > a[i+1]) {
            ans += a[i] * st;
            st = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  char b;
  string s="ACTG";
  cin>>b;
  for(int i=0;i<4;i++){
    if(b==s[i])cout<<s[(i+2)%4];
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int count = 0;

        for (int i = 0 ; i < N ; i++) {
            int h = scanner.nextInt();
            if (h >= K) count++;
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 58792
#include <iostream>
#include <vector>

using namespace std;

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

    int n, x, flag = 1;
    cin >> n;
    while (n--) {
        cin >> x;
        if (x % 2 == 0) {
            if (x % 3 && x % 5) flag = 0;
        }
    }
    if (flag) cout << "APPROVED\n";
    else cout << "DENIED\n";
    return 0;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin.split('\n')[0].split(' ')

const al = a.split('').pop()

const bs = b.split('').shift()

const bl = b.split('').pop()

const cs = c.split('').shift()

console.log(al === bs && bl === cs ? 'YES' : 'NO')


Measured memory_bytes: 7372
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    lint x, y;
    cin >> x >> y;
    vector<lint> a;
    while(x <= y){
        a.push_back(x);
        x *= 2;
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll s;cin>>s;
  ll x[3],y[3];

  REP(i,3){
    x[i] = 0;
    y[i] = 0;
  }
  ll t = (ll)sqrt(s-0.5) + 1;
  //cout<<(ll)sqrt(s-0.5) * (ll)sqrt(s-0.5)<<endl;
  //cout<<"t = "<<t<<endl;
  t = min((ll)pow(10,9),t);
  //cout<<t<<endl;
  if(t*(t-1)>=s){
    x[1] = t;
    y[2] = t-1;
  }else{
    x[1] = t;
    y[2] = t;
  }

  ll p = x[1]*y[2] - s;
  //cout<<"p = "<<p<<endl;
  for(ll i = 1;i<=(ll)sqrt(p);i++){
    if(p%i==0){
      x[2] = i;
      y[1] = p/i;
    }
  }

  REP(i,3){
    cout<<x[i]<<" "<<y[i]<<" ";
  }
  cout<<endl;




 

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
#include <sstream>
#include <set>

using namespace std;    
 
static int64_t getMinCost(multiset<int64_t> &leftNodes,
		      multiset<int64_t> &rightNodes,
		      int64_t curmincost,
		      int64_t minpos,
		      int64_t loff,
		      int64_t roff)
{
    if (leftNodes.size() == 0) {
	return curmincost;
    }

    auto ilmax = leftNodes.end();
    ilmax--;
    int64_t lmax = *ilmax - loff;
    auto irmin = rightNodes.begin();
    int64_t rmin = *irmin + roff;
    
    if (lmax <= minpos) {
	if (minpos <= rmin) {
	    return curmincost;	    
	}
	return minpos - rmin + curmincost;
    } else {
	return lmax - minpos + curmincost;
    }
}
 
int main(void){
    int64_t n;
    int64_t mincost;
    multiset<int64_t> leftNodes;
    multiset<int64_t> rightNodes;
    stringstream st;
    string line;
      
    getline(cin, line);
    st.str(line);
    st >> n;
    
    int64_t nl, nr;
    int64_t l, r;
    int64_t loff, roff;
    loff = 0;
    roff = 0;    
    mincost = 0;    
    for (int64_t i = 0; i < n; i++) {
	getline(cin, line);
	st.str(line);
	st.clear();
	st.seekg(0);
	st >> nl >> nr;
	if (i >= 1) {
	    
	    mincost = getMinCost(leftNodes, rightNodes, mincost, l, loff, roff);

	    if (leftNodes.size() == 0) {
		leftNodes.insert(l);
		rightNodes.insert(l);
	    } else {
		auto ilmax = leftNodes.end();
		ilmax--;
		int64_t lmax = *ilmax - loff;
		if (lmax <= l) {
		    auto irmin = rightNodes.begin();
		    int64_t rmin = *irmin + roff;
		    if (l <= rmin) {
			leftNodes.insert(l + loff);
			rightNodes.insert(l - roff);
		    } else {
			rightNodes.insert(l - roff);
			rightNodes.insert(l - roff);

			leftNodes.insert(rmin + loff);
			rightNodes.erase(irmin);
		    }
		} else {
		    leftNodes.insert(l + loff);
		    leftNodes.insert(l + loff);

		    rightNodes.insert(lmax - roff);
		    leftNodes.erase(ilmax);
		}
	    }
	    roff += r - l;
	    loff += nr - nl;

#if 0
	    for (auto e : leftNodes) {
		cout << e - loff << " ";
	    }
	    for (auto e : rightNodes) {
		cout << e + roff << " ";
	    }	    
	    cout << endl;
#endif	
	}
	l = nl;
	r = nr;
    }
 
    mincost = getMinCost(leftNodes, rightNodes, mincost, l, loff, roff);
 
    cout << mincost << endl;
    return 0;
 
    
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  if(N%2==1){
  int right=0;
    for(int i=(N+1)/2;i<N;i++)
      if(s.at(i)==s.at(i-1))
        right++;
    else
      break;
    int left=0;
    for(int i=(N-3)/2;0<=i;i--)
      if(s.at(i)==s.at(i+1))
        left++;
    else
      break;
    int ans=min(right,left);
    ans+=(N+1)/2;
    cout<<ans<<endl;
  
  }else{
  if(s.at((N-2)/2)!=s.at(N/2))
    cout<<N/2<<endl;
    else{
    int right=0;
    for(int i=(N+2)/2;i<N;i++)
      if(s.at(i)==s.at(i-1))
        right++;
    else
      break;
    int left=0;
    for(int i=(N-4)/2;0<=i;i--)
      if(s.at(i)==s.at(i+1))
        left++;
      else
        break;
       int ans=min(left,right);
      ans+=1+N/2;
      cout<<ans<<endl;
    
    }
  }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
  fast();
  int a=D(),b=D();
  if(a==1&&b!=1){
    cout<<"Alice"<<endl;
    return 0;
  }
  if(b==1&&a!=1)
  {
     cout<<"Bob"<<endl;
    return 0;
  }
  if(a>b)
   cout<<"Alice"<<endl;
  else if(b>a)
    cout<<"Bob"<<endl;
  else
    cout<<"Draw"<<endl;
}



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

int gcd(int a,int b){
  if(a<b) swap(a,b);
  return b? gcd(b,a%b):a;
}

int main(){
  int x,y;
  cin>>x>>y;
  cout<<gcd(x,y)<<endl;
  return 0;
}

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

using namespace std;
#define ll long long
#define mod 1000000007

ll dp[3001][3001][2], help[3001][3001][2];
vector<ll> v, pre;

ll f(ll l, ll r, ll player) {
    if (l > r) return 0;
    else if (l == r) return v[l];

    if (dp[l][r][player] != -1) return dp[l][r][player];

    ll score1 = v[l] + pre[r] - pre[l] - f(l + 1, r, 1 - player);
    ll score2 = v[r] + pre[r - 1] - (l ? pre[l - 1] : 0) - f(l, r - 1, 1 - player);

    if (score1 > score2) {
        help[l][r][player] = 0;
    } else {
        help[l][r][player] = 1;
    }
    dp[l][r][player] = max(score1, score2);
    return dp[l][r][player];
}

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

    ll n;
    cin >> n;
    v.resize(n);
    pre.resize(n);

    memset(dp, -1, sizeof(dp));

    for (auto &i : v) {
        cin >> i;
    }

    pre[0] = v[0];
    for (ll i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + v[i];
    }

    f(0, n - 1, 0);

    if (help[0][n - 1][0] == 0) {
        cout << f(0, n - 1, 0) - f(1, n - 1, 1);
    } else {
        cout << f(0, n - 1, 0) - f(0, n - 2, 1);
    }
}


Measured memory_bytes: 226428
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val in = List.fill(n, 4)(sc.nextInt())
  val buildings: List[Building] = (1 to 4).map(n => createEmptyBuilding(n, 3, 10)).toList

  for (data <- in) {
    updateTenant(buildings, data)
  }

  printAns(buildings)

  def createEmptyBuilding(buildNo: Int, level: Int, room: Int): Building = {
    val floorList: List[Floor] = (1 to level).map(l => Floor(l, scala.collection.mutable.Seq.fill(room)(0))).toList
    Building(buildNo, floorList)
  }

  def updateTenant(bldgs: List[Building], d: List[Int]): Unit = {
    val target = bldgs(d(0) - 1).floorList(d(1) - 1).tenant(d(2) - 1)
    target match {
      case 0 => bldgs(d(0) - 1).floorList(d(1) - 1).tenant.update(d(2) - 1, d(3))
      case _ => bldgs(d(0) - 1).floorList(d(1) - 1).tenant.update(d(2) - 1, target + d(3))
    }
  }

  def printAns(bldgs: List[Building]): Unit = {
    for (b <- bldgs) {
      b.buildNo match {
        case 4 => b.floorList.foreach(f => println(" " + f.tenant.mkString(" ")))
        case _ =>
          b.floorList.foreach(f => println(" " + f.tenant.mkString(" ")))
          println("####################")
      }
    }
  }

  case class Building(buildNo: Int, floorList: List[Floor])

  case class Floor(level: Int, tenant: scala.collection.mutable.Seq[Int])

}

Measured memory_bytes: 47352
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = mutableListOf<Int>()
    val bb = mutableListOf<Int>()

    repeat(n) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        aa.add(a)
        bb.add(b)
    }

    var cnt = 0L

    for (i in n-1 downTo 0) {
        val a = aa[i] + cnt
        val b = bb[i]
        cnt += if (a % b == 0L) 0 else b - (a % b)
    }

    println(cnt)
}

Measured memory_bytes: 63652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,ans=2,m;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	if(n==2){
		print1(1);
		return 0;
	}
	rep2(i,2,n-1){
		if(i*i>n-1) break;
		if((n-1)%i==0) ans+=1+(i*i!=n-1);
	}
	rep2(i,2,n){
		if(i*i>n) break;
		if(n%i==0){
			m=n;
			while(m%i==0) m/=i;
			if(m%i==1) ans++;
		}
	}
	print1(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int ans = -1;
  for(int i=1;i<1300;i++){
    int ei = i*8/100;
    int ten = i*10/100;
    if(ei == a && ten == b){
      if(ans != -1){
        ans = min(ans,i);
      }else{
        ans = i;
      }
    }
  }
  /*
  int ei = a*100/8;
  int ten = b*100/10;
  int ans = -1;
  if(ei/10 == b){
    ans = ei;
  }
  if(ten*8/100 == a){
    if(ans == -1){
      ans = ten;
    }else{
      ans = min(ei,ten);
    }
  }
  */

  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;


namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(ab[0]*ab[1] - ab[0] - ab[1] + 1);
        }
    }
}


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

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N), sum(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
    sum[i + 1] %= K;
  }

  map<int, int> mp;
  queue<int> que;
  int ans = 0;

  for (int i = 0; i <= N; i++) {
    sum[i] = (sum[i] - i) % K;
    if (sum[i] < 0)
      sum[i] += K;

    ans += mp[sum[i]];
    mp[sum[i]]++;

    que.push(sum[i]);
    if (que.size() >= K) {
      mp[que.front()]--;
      que.pop();
    }
  }

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

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

#define INT int
#define REP(i,a,b) for(INT i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    //基本的には一番大きな値に合わせる。
    int m = max(max(a,b), max(b,c));
    int d = (m*3 - (a+b+c));
    if(d%2 == 1) d+=3;
    
    cout << d/2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 2000 + 5;
int n, a[maxN];
vector<int> G[maxN];

int f[maxN], g[maxN], sz[maxN];

void dfs(int u, int fa) {
	f[u] = 0;
	g[u] = 0;
	sz[u] = a[u];
	int mxdif = 0;
	for(int v : G[u]) if(v != fa) {
		dfs(v, u);
		sz[u] += sz[v];
		g[u] += g[v] + sz[v];
		chmax(mxdif, g[v] + f[v] + sz[v] + sz[v]);
	}
	if(g[u] - mxdif < 0) f[u] = mxdif - g[u];
	else f[u] = (g[u] & 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	string s; cin >> s;
	for(int i = 0; i < n; ++i) a[i + 1] = s[i] - '0';
	for(int i = 1; i < n; ++i) {
		int x, y; cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = maxN * maxN;
	for(int u = 1; u <= n; ++u) {
		dfs(u, -1);
		if(f[u] == 0) chmin(ans, g[u] / 2);
//		display(u);
//		displaya(f, 1, n);
//		displaya(g, 1, n);
	}
	if(ans == maxN * maxN) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
s = input()

ans = 0
for i in range(len(s)):
    s2 = s[:i]

    # check
    f = True
    if len(s2) % 2 == 1:
        f = False
    else:
        for i in range(len(s2) // 2):
            if s2[i] != s2[i + len(s2) // 2]:
                f = False
    if f:
        ans = max(ans, len(s2))
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n;
    cin >> n;
    string s[n];
    for(ll i = 0; i < n; i++)
        cin >> s[i];
    sort(s, s+n);
    ll ans = 1;
    for(ll i = 1; i < n; i++){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9884
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
ll merge(ll *a, int left, int mid, int right) {
	ll n1 = mid - left;
	ll n2 = right - mid;
	vector<int> L(n1 + 1);
	vector<int> R(n2 + 1);
	for (size_t i = 0; i < n1; i++)
	{
		L[i] = a[left + i];
	}
	for (size_t i = 0; i < n2; i++)
	{
		R[i] = a[mid + i];
	}

	L[n1] = INF;
	R[n2] = INF;
	ll i = 0;
	ll j = 0;
	ll r = 0;
	for (size_t k = left; k < right; k++)
	{
		if (L[i] <= R[j]) {
			a[k] = L[i];
			i++;
		}
		else {
			a[k] = R[j];
			r += n1 - i;
			j++;
		}
	}
	return r;
}
ll mergeSort(ll *a, int left, int right) {
	ll res = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		res = mergeSort(a, left, mid);
		res += mergeSort(a, mid, right);
		res += merge(a, left, mid, right);
	}
	return res;
}

void solv() {
	int n;
	cin >> n;
	int a[2000100];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int c[10010];
	memset(c, 0, sizeof(c));
	for (size_t i = 0; i < n; i++)
	{
		c[a[i]]++;
	}
	for (size_t i = 1; i < 10010; i++)
	{
		c[i] += c[i - 1];
	}

	int b[2000010];
	memset(b, 0, sizeof(b));
	for (int i = n - 1; i >= 0; i--)
	{
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}

	for (size_t i = 1; i <= n; i++)
	{
		if (i > 1) cout << " ";
		cout << b[i];
	}
	cout << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



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

#define fastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    fastIO;
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<int> max_happiness_a(N), max_happiness_b(N), max_happiness_c(N);
    max_happiness_a[0] = a[0];
    max_happiness_b[0] = b[0];
    max_happiness_c[0] = c[0];
    for (int i = 1; i < N; i++)
    {
        max_happiness_a[i] = max(max_happiness_b[i - 1], max_happiness_c[i - 1]) + a[i];
        max_happiness_b[i] = max(max_happiness_c[i - 1], max_happiness_a[i - 1]) + b[i];
        max_happiness_c[i] = max(max_happiness_a[i - 1], max_happiness_b[i - 1]) + c[i];
    }
    cout << max(max_happiness_a[N - 1], max(max_happiness_b[N - 1], max_happiness_c[N - 1]));
}

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

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

template<typename T>
struct cumulative_sum {
    int n;
    T ZERO;
    std::vector<T> data;
    template<typename I> cumulative_sum(I begin, I end, T ZERO = T())
        : n(end - begin), ZERO(ZERO), data(n + 1, ZERO) {
        std::copy(begin, end, data.begin() + 1);
        for (int i = 0; i < n; i++) { data[i + 1] += data[i]; }
    }
    T get_sum(int l, int r) const {
        if (l >= r || l > n || r < 0) { return ZERO; }
        if (l < 0) { l = 0; }
        if (r > n) { r = n; }
        return data[r] - data[l];
    }
};

int N;
int W[110];
signed main() {
    cin >> N;
    rep(i, N) { cin >> W[i]; }
    cumulative_sum<int> cs(W, W + N);
    int ans = LLONG_MAX;
    rep(i, N) {
        chmin(ans, abs(cs.get_sum(0, i) - cs.get_sum(i, N)));
    }
    cout << ans << endl;
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


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

  int a[100];

  for (int i=1;i<=n;i++) {
    cin>>a[n-i];
  }
  for (int i=0;i<(n-1);i++)cout << a[i] << " ";

  cout << a[n-1] << endl;

  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,a;
    cin>>n;
    for(i=n;i>=1;i--)
    {
        a=sqrt(i);
        if(i%a==0&&i/a==a)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main()
{
    int n, cn;
    int max = 1;
    string s;
    cin >> n;
    map<std::string, int> dictionary;
    rep(i, n)
    {
        cin >> s;
        cn = dictionary.count(s);
        if (cn)
        {
            dictionary[s]++;
            chmax(max, dictionary[s]);
        }
        else
        {
            dictionary.insert(std::make_pair(s, 1));
        }
    }

    vector<string> arr;
    for (auto x : dictionary)
    {
        if (x.second == max)
            arr.push_back(x.first);
    }
    sort(arr.begin(), arr.end());

    for (auto x : arr)
    {
        cout << x << endl;
    }
}

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

int main(){
  int h, w, k; cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++){
    cin >> s.at(i);
  }
  vector<vector<int>> sb(h);
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (s.at(i).at(j) == '#') sb.at(i).push_back(j);
    }
  }
  vector<vector<int>> ans(h, vector<int>(w));
  int num = 0;
  for (int i = 0; i < h; i++){
    int j = 0;
    for (int k = 0; k < sb.at(i).size(); k++){
      num++;
      while (j <= sb.at(i).at(k)){
        ans.at(i).at(j) = num;
        j++;
      }
    }
    while (j < w){
      ans.at(i).at(j) = num;
      j++;
    }
  }
  for (int i = 0; i < h; i++){
    if (sb.at(i).size() == 0){
      int flag = 0;
      int j = i+1;
      while (j < h){
        if (sb.at(j).size()){
          for (int k = 0; k < w; k++){
            ans.at(i).at(k) = ans.at(j).at(k);
          }
          flag = 1;
        }
        if (flag) break;
        j++;
      }
      if (!flag){
        int j = i-1;
        while (j >= 0){
          if (sb.at(j).size()){
            for (int k = 0; k < w; k++){
              ans.at(i).at(k) = ans.at(j).at(k);
            }
            flag = 1;
          }
          if (flag) break;
          j--;
        }
      }
    }
  }
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cout << ans.at(i).at(j) << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1920
unittest
{
	assert( [ "3 4 9 0" ].solve == "5.000000000" );
	assert( [ "3 4 10 40" ].solve == "4.564257194" );
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = 0L;
	auto b = 0L;
	auto h = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s %s %s"( a, b, h, m );
	
	auto pa = Point( 0, 0 ) + Vector( a, ( h * 60 + m ) * PI / 360 );
	auto pb = Point( 0, 0 ) + Vector( b, m * PI / 30 );
	return format( "%0.9f", pa.distance( pb ) );
}

// 座標
struct Point
{
	real x = 0;
	real y = 0;
	
	void opOpAssign( string OP )( Vector v ) if( OP == "+" ){ this.x += v.x; this.y += v.y; }
	void opOpAssign( string OP )( Vector v ) if( OP == "-" ){ this.x -= v.x; this.y -= v.y; }
	auto opBinary( string OP )( Vector v ){ auto l = this; l.opOpAssign!OP( v ); return l; }
	
	auto distance( Point p ){ return hypot( p.x - this.x, p.y - this.y ); }
	auto angle( Point p ){ return atan2( p.y - this.y, p.x - this.x ); }
	auto toString(){ return format( "Point(%f, %f)", this.x, this.y ); }
}

// ベクトル
struct Vector
{
	real m = 0;
	real d = 0;		// 0が+x方向、PI_2が+y方向、PIが-x方向、PI_2*3が-y方向
	
	this( real m, real d )
	{
		this.m = m;
		this.d = d;
		if( this.d < -2 * PI || 2 * PI < this.d ) this.d %= PI * 2;
		if( this.d < -PI ) this.d += PI * 2;
		if(  PI < this.d ) this.d -= PI * 2;
	}
	
	this( Point a, Point b )
	{
		this = Vector( a.distance( b ), a.angle( b ) );
	}
	
	auto opUnary( string OP )() if( OP == "+" ){ return this; }
	auto opUnary( string OP )() if( OP == "-" ){ return Vector( m, d + PI ); }
	void opOpAssign( string OP )( real m ) if( OP == "+"  ){ this.m += m; }
	void opOpAssign( string OP )( real m ) if( OP == "-"  ){ this.m -= m; }
	void opOpAssign( string OP )( real m ) if( OP == "*"  ){ this.m *= m; }
	void opOpAssign( string OP )( real m ) if( OP == "/"  ){ this.m /= m; }
	void opOpAssign( string OP )( real m ) if( OP == "^^" ){ this.m ^^= m; }
	auto opBinary( string OP )( real m ){ auto l = this; l.opOpAssign!OP( m ); return l; }
	
	void opOpAssign( string OP )( Vector v ) if( OP == "+" ){ this = Point( 0, 0 ).vector( Point( 0, 0 ) + this + v ); }
	void opOpAssign( string OP )( Vector v ) if( OP == "-" ){ this = Point( 0, 0 ).vector( Point( 0, 0 ) + this - v ); }
	auto opBinary( string OP )( Vector v ){ auto l = this; l.opOpAssign!OP( v ); return l; }
	
	auto turn( real d ){ return Vector( this.m, this.d + d ); }
	auto x(){ return this.m * cos( this.d ); }
	auto y(){ return this.m * sin( this.d ); }
	auto angleBetween( Vector v ){ auto d = abs( this.d - v.d ); return ( d <= PI ) ? d : 2 * PI - d; }
	auto toString(){ return format( "Vector(%f, %f)", this.m, this.d ); }
}


Measured memory_bytes: 3068
import numpy as np

N = int(input())
h = np.array(list(map(int, input().split())))

ans = 0
while sum(h) != 0:
    cost = True
    for i in range(N):
        if h[i] != 0:
            h[i] -= 1
            if cost:
                ans += 1
                cost = False
        else:
            cost = True

print(ans)


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

int main(void){
    int a, b;
    cin >> a >> b;
    if(b==100){
        for(int i{100}; i<=1000; ++i){
                if((a*1000+b) == (i*i)){
                    cout << "Yes" << endl;
                    return(0);
                }
                else if((a*1000+b)<(i*i)){
                    cout << "No" << endl;
                    return(0);
                }
        }
    }

        
    else if(b>9){
        for(int i{10}; i<=1000; ++i){
                if((a*100+b) == (i*i)){
                    cout << "Yes" << endl;
                    return(0);
                }
                else if((a*100+b)<(i*i)){
                    cout << "No" << endl;
                    return(0);
                }
        }
    }

    else{
        for(int i{2}; i<=1000; ++i){
                if((a*10+b) == (i*i)){
                    cout << "Yes" << endl;
                    return(0);
                }
                else if((a*10+b)<(i*i)){
                    cout << "No" << endl;
                    return(0);
                }
        }
    }
    cout << "No" << endl;
    return(0);
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

n=int(input())
A= [[int(i) for i in input().split()] for j in range(n)]

MOD=10**9+7
_ALL=1<<n
dp = [0]*(_ALL)
dp[0] = 1

for m in range(1,n+1):
    a = 2**m-1
    while a < _ALL:
        ans=0
        for c in range(n):
            if 1<<c&a and A[m-1][c]:
                ans += dp[a^1<<c]
                ans%=MOD
        dp[a] = ans
        x = a & -a
        y = a + x
        a = (((a & ~y) // x) >> 1) | y

#print(dp)
print(dp[2**n-1])

Measured memory_bytes: 57452
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (n, m) = toTuple(readInts())
var ai: [Int] = []
for _ in 0..<m {
  ai.append(contentsOf: readInts())
}
for i in 1...n {
  print(ai.filter { $0 == i }.count)
}

Measured memory_bytes: 13600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i=0;
	cin>>a>>b;
	int c=b;
	while(c!=0)
	{
		c=c/10;
		i++;
	}
	int s=a*pow(10,i)+b;
	if(int(sqrt(s))*int(sqrt(s))==s)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

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

    int count = 0;
    int start = 1;

    for (int i = 1; i <= N; i++){
        int x;
        cin >> x;
        
        if (start != x){
            count++;
        }
        else {
            start++;
        }
    }

    if (start == 1 && count == N){
        cout << -1 << endl;
    }
    else {
        cout << count << endl;
    }
}


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

void Make(int cur, vector<vector<int> > &adj, vector<vector<int> > &G, vector<bool> &used){

    used[cur] = true;
    for(auto nxt : adj[cur]){
        if(used[nxt]) continue;
        G[cur].push_back(nxt);
        Make(nxt, adj, G, used);
    }
}

int dfs(int cur, vector<vector<int> > &G, vector<int> &A){

    if(G[cur].size() == 0){
        cerr << cur << " " << A[cur] << endl;
        return A[cur];
    }

    int sum = 0;
    
    vector<int> vec;    
    for(auto nxt : G[cur]){
        int val = dfs(nxt, G, A);
        if(val < 0){
            cerr << cur << " " << -1 << endl;
            return -1;
        }
        vec.push_back(val);
        sum += val;
    }

    int ret = 2 * A[cur] - sum;
    //cout << cur << " " << sum << " " << A[cur] << " " << ret << endl;
    if(ret < 0){
        cerr << cur << " " << -1 << endl;
        return -1;
    }

    vec.push_back(ret);

    int n = (int)vec.size();
    sum += ret;
    assert(sum % 2 == 0);

    bool ok = true;
    for(int i = 0; i < n; i++){
        if(vec[i] > sum / 2){
            cerr << cur << " " << -1 << endl;            
            return -1;
        }
    }

    cerr << cur << " " << ret << endl;
    return ret;
}

signed main(){

    int N; cin >> N;
    vector<int> A(N);
    vector<vector<int> > adj(N); // {node}
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N - 1; i++){
        int a, b; cin >> a >> b; a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<bool> used(N, false);
    vector<vector<int> > G(N);  // 0 を根とする 根付き木

    
    Make(0, adj, G, used);    

    int val = (G[0].size() == 1 ? A[0] : 0);
    if(dfs(0, G, A) == val) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

const int INF = 1e9;

int main()
{
  int n, m, s;
  cin >> n >> m >> s;
  
  vector<vector<P>> e(n, vector<P>(0));
  rep(i, m)
  {
    int a, b, c;
    cin >> a >> b >> c;
    e[a].emplace_back(P(b, c));
  }
  
  vector<int> d(n, INF);
  queue<int> q;
  int cnt = 0;
  
  q.push(s);
  d[s] = 0;
  while(q.size())
  {
    int a = q.front();
    q.pop();
    
    for(auto x : e[a])
    {
      int nd = d[a] + x.second;
      if(nd < d[x.first])
      {
        q.push(x.first);
        d[x.first] = nd;
      }
    }
  }
  
  rep(i, n)
  {
    if(d[i] == INF) cout << "INF\n";
    else cout << d[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 12264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void chmax(int& a, int b) {
  if (a == -1) a = b;
  if (a > b) a = b;
}
int main () {
  int nin[10];
  int six[10];
  nin[0] = 0;
  nin[1] = 9;
  six[0] = 0;
  six[1] = 6;
  for (int i = 2; i < 8; i ++) {
    nin[i] = nin[i - 1] * 9;
  }
  for (int i = 2; i < 10; i ++) {
    six[i] = six[i - 1] * 6;
  }
  int num_with[1000000];
  ll I_ma = 1000000;
  for (int i = 0; i < 1000000; i ++) num_with[i] = -1;
  ll with[18];
  for (int i = 0; i < 6; i ++) {
    with[i] = nin[i + 1];
  }
  for (int i = 6; i < 13; i ++) {
    with[i] = six[i - 5];
  }
  //for (int i = 0; i < 13; i ++) cout << with[i] << endl;
  num_with[0] = 0;
  for (int i = 0; i < 1000000; i ++) {
    if (num_with[i] != -1) {
      for (int j = 0; j < 13; j ++) {
        if (i + with[j] < I_ma) {
          chmax(num_with[i + with[j]], num_with[i] + 1);
        }
      }
    }
  }
  int N;
  cin >> N;
  int count = 0;
  while (num_with[N] == -1) {
    N --;
    count ++;
  }
  cout << num_with[N] + count << endl;
}

Measured memory_bytes: 7504
import scala.io.StdIn.{readInt,readLine}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val n = readInt()
    var dices = List.empty[Array[Int]]
    for(_ <- 1 to n){
      dices :+= readLine().split(" ").map(_.toInt)
    }
    println(if(differentFromEachOther(dices)) "Yes" else "No")
  }

  def differentFromEachOther(dices:List[Array[Int]]): Boolean ={
    for(i <- 0 until dices.size){
      val dice1List = createDiceArray(dices(i))
      for(j <- (i + 1) until dices.size) {
        if (diceEqual(dice1List, dices(j))) return false
      }
    }
    return true
  }

  def diceEqual(dice1List:List[Array[Int]], dice2:Array[Int]) : Boolean = {
    for(i <- dice1List){
      if(i sameElements dice2) return true
    }
    return false
  }

  def createDiceArray(dice:Array[Int]) : List[Array[Int]] = {
    var dices = List.empty[Array[Int]]
    for(i <- createDiceArray(dice,"WNNNW"); j <- createDiceArray(i,"HHH")){
      dices +:= j
    }
    dices
  }

  def createDiceArray(dice:Array[Int],commands:String) : List[Array[Int]] = {
    var dices = List(dice)
    for(cmd <- commands.toCharArray){
      dices :+= getNextStatus(cmd,dices.last)
    }
    dices
  }

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd match {
    case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
    case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
    case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  }
}

Measured memory_bytes: 49188
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ld ans = 0;
   
   for(ll i=1;i<=n;i+=2)
       ans++;
   
   ans/=n;
   cout<<fixed<<setprecision(20)<<ans;
   
   return 0;
}

Measured memory_bytes: 256
/******Old_school_@123******/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)
 
typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}
 
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1;// cin>>t;  
      while(t--){
          lld k; cin>>k;
        string s; cin>>s;
        lld len=sz(s);
        if(len<=k)
          cout<<s<<nl;
        else
          cout<<s.substr(0,k)<<"...";
      }
}
 

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int tinh(int n)
{
    int dem = 0;
    for (int i = 1 ; i <= n -1 ; i++ )
    {
        for (int j = i+1; j <= n; j++)
        {
            dem++;
        }
    }
    return dem;
}
int main()
{
    int n, m;
    cin >> n >> m;
    cout << tinh(n)+tinh(m);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7
n=I()
A=LI()
ret=sum(A)
r=0
for i in range(n):
    r+=(ret-A[i])*A[i]
    r%=mod

print(r*pow(2,mod-2,mod)%mod)


Measured memory_bytes: 102528
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            j += 1
            exit()

else:
    print("-1 -1 -1")

Measured memory_bytes: 9120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		char[] c = s.toCharArray();
		boolean check = true;
		
		for(int i=0;i<c.length;i++) {
			char a = c[i];
			if(i%2==0) {
				if(a == 'L') {
					check = false;
				}
			}else {
				if(a == 'R') {
					check = false;
				}
			}
		}
		
		if(check) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();	
	}
}

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

int main() {
    std::string C1, C2;
    std::cin >> C1 >> C2;
    
    if (C1[0]==C2[2] && C1[1]==C2[1] && C1[2]==C2[0])
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi A(N), B(N); F0R(i, N) cin >> A[i] >> B[i];
    sort(all(A));
    sort(all(B));
    ll X, Y; 
    if (N % 2 == 1) {
        X = A[N/2];
        Y = B[N/2];
    } else {
        X = A[N/2 - 1] + A[N/2];
        Y = B[N/2 - 1] + B[N/2];
    }

    cout << Y-X+1 << nl;
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

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

    bool ok = false;
    for (int i = a; i <= b; ++i) {
        if(i % k == 0){
            ok = true;
        }
    }


    cout << (ok ? "OK" : "NG") << endl;
    

    return 0;
}


Measured memory_bytes: 3652