akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
    

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int res = 0;
    for (int i = 0; i < n; i++)
        if (a[a[i]] == i)
            res++;
    cout << res / 2 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

string s,t;

int main() {
    cin >> s >> t;
    int n = s.size();
    vector<int> a(n);
    vector<int> b(n);
    REP(i,n){
        a[i] = (int)(char)s[i]-97;
    }
    REP(i,n){
        b[i] = (int)(char)t[i]-97;
        
    }
    /*int c[2][26];
    REP(i,n){
        c[
     }*/
    vector<int> c(26,0);
    vector<int> d(26,0);
    REP(i,n){
        c[a[i]]++;
        d[b[i]]++;
    }
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    bool flag = true;
    REP(i,26){
        if(c[i]!=d[i]){
            flag = false;
        }
    }
    
    string res;
    if(flag){
        res = "Yes";
    }else{
        res = "No";
    }
    put(res);
    return 0;
}


Measured memory_bytes: 2312
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# s = input()


a, b = list(map(int, input().split()))
c, d = list(map(int, input().split()))
if d == 1:
    print(1)
else:
    print(0)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a[200000] = {}, sum = 0, dif[200005] = {}, cnt[200005] = {};

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	rep(i, n + 1) {
		sum += cnt[i] * (cnt[i] - 1) / 2;
		dif[i] = cnt[i] * (cnt[i] - 1) / 2 - (cnt[i] - 1) * (cnt[i] - 2) / 2;
	}
	rep(i, n)cout << sum - dif[a[i]] << endl;
	return 0;
}

Measured memory_bytes: 6272
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N+1];
        int[] b = new int[N+1];
        int[] c = new int[N];
        for(int i = 1; i <= N; i++) {
            a[i] = sc.nextInt();
        }
        for(int i = 1; i <=  N; i++) {
            b[i] = sc.nextInt();
        }
        for(int i = 1; i < N; i++) {
            c[i] = sc.nextInt();
        }
        
        int sum = 0;
        for(int i = 1; i <= N; i++) {
            sum += b[a[i]];
            if(a[i-1] == a[i] - 1) {
                sum += c[a[i-1]];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
n = int(input())
s =[input() for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for A in s:
    if A[0]=='M':
        m+=1
    elif A[0]=='A':
        a+=1
    elif A[0]=='R':
        r+=1
    elif A[0]=='C':
        c+=1
    elif A[0]=='H':
        h+=1
x = []
for i in [m,a,r,c,h]:
    if i != 0:
        x.append(i)
if len(x)<3:
    print(0)
elif len(x)==3:
    print(x[0]*x[1]*x[2])
elif len(x)==4:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3])
else:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3]
         +x[0]*x[1]*x[4]+x[0]*x[2]*x[4]+x[1]*x[2]*x[4]
         +x[2]*x[3]*x[4]+x[1]*x[3]*x[4]+x[0]*x[3]*x[4])

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        if (a[0] > b[0]) {
            cout << "GREATER" << endl;
        } else if (b[0] > a[0]) {
            cout << "LESS" << endl;
        } else {
            cout << "EQUAL" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{

	string S;
	cin >> S;

	int v0=0;
	int v1=0;
	for(int i=0; i<S.length(); i++){
		if(i%2){
			if(S.at(i)=='0'){
				v0++;
			}else{
				v1++;
			}
		}else{
			if(S.at(i)=='1'){
				v0++;
			}else{
				v1++;
			}
		}
	}

	if(v1>v0){
		cout << v0 << endl;
	}else{
		cout << v1 << endl;
	}

	return 0;
}

Measured memory_bytes: 512
object Main
  extends App {

  case class State[S, A](run: S => (S, A)) { self =>
    def map[B](f: A => B): State[S, B] = {
      //      State((s: S) => (s, f(self.run(s)._2)))
      flatMap(a => State.unit(f(a)))
    }

    def flatMap[B](f: A => State[S, B]): State[S, B] =
      State((s: S) => {
        val (s1, a) = self.run(s)
        f(a).run(s1)
      })
  }

  object State {
    def unit[S, A](a: A): State[S, A] = State(s => (s, a))
  }

  implicit class StreamOps[S, A](stream: Stream[State[S, A]]) {
    def sequence: State[S, Stream[A]] =
      stream.foldLeft(State.unit[S, Stream[A]](Stream.empty[A]))(
        (acc, h) => acc.flatMap(st => h.map(a => a #:: st))
      )
  }

  def f(a: Int): State[(Seq[Int], Seq[Int]), Option[Int]] =
    State { case (stack: Seq[Int], trail: Seq[Int]) =>
      if (a == 0) ((stack.tail, stack.head +: trail), Some(stack.head)) else ((a +: stack, trail), None)
    }

  //  import scala.collection.immutable.Stack
  //  Stream
  //    .continually(readLine)
  //    .takeWhile(_ != null)
  //    .map(_.toInt)
  //    .foldLeft(Stack.empty[Int]) {
  //      case (stack, h) =>
  //        if (h == 0) stack.pop2 match {
  //          case (e, tail) => println(e); tail
  //        } else stack.push(h)
  //    }

  Stream
    .continually(readLine)
    .takeWhile(_ != null)
    .map(_.toInt)
    //  val track = Seq(1, 6, 0, 8, 10, 0, 0, 0)
    .map(f)
    .sequence
    .run((Nil, Nil))
    ._1._2
    .reverse
    .foreach(println)
}


Measured memory_bytes: 44260
n, d = gets.chomp.split.map(&:to_i)
cnt = 0
(1..n).each do |i|
  if i % ( ( d * 2 ) + 1 ) == 0 then
    cnt += 1
  end
end
if n % ( ( d * 2 ) + 1 ) == 0 then
  puts cnt
else
  puts cnt + 1
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int count=0,buff1,buff2;

		for(int i=4;i<=m;i++) {
			for(int j=1;j<=d;j++) {
				buff1 = j%10;
				buff2 = j/10;
				//System.out.println(buff1 +" "+buff2);
				if(buff1!=1 && buff2!=1) {
					if(i == buff1*buff2) {
						count++;
					}
				}

			}
		}
		System.out.println(6-m-d);


	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  ll h,w;
  cin >> h >> w;
  ll p = ((h+1LL)/2LL)*((w+1LL)/2LL);
  ll q = (h/2LL)*(w/2LL);
  //cout << p << endl;
  //cout << q << endl;
  if(h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  }
  cout << p+q <<endl;
  
}




Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000 - n%1000)


Measured memory_bytes: 68332
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n,a,b;
	cin >> n >> a >> b;

	int k = n/(a+b);
	int ans = k*a;

	int res = n-k*(a+b);
	ans += min(res,a);
	cout << ans << endl;
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc158.contest.atcoder.jp/tasks/abc158_b

Measured memory_bytes: 3616
import java.util.*;

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

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		int area = a * b;
		int around = 2 * (a + b);

		System.out.print(area + " ");
		System.out.println(around);

	}
}

Measured memory_bytes: 26112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
  int d, n;

  cin >> d >> n;

  if(n == 100) n++;
  for(int i = 0; i < d; i++)
    n *= 100;

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{

     public static void main(String []args){
        
        Scanner sc=new Scanner(System.in);
        List<Integer> li=new ArrayList<Integer>();
        int x=sc.nextInt();
        int y=sc.nextInt();
        for(int i=0;i<y;i++)
        li.add(sc.nextInt());
        for(int i=0;i<=x;i++)
        {
            int sub=x-i;
            int add=x+i;
            if(!(li.contains(sub) )){
                
              System.out.println(sub);
              System.exit(0);}
            if(!( li.contains(add))){
               System.out.println(add);
               System.exit(0);}
        }
       System.out.println("-1");  
     }
}

Measured memory_bytes: 36076
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(b-a)<=d && abs(c-b)<=d) cout << "Yes" << endl;
  else if(abs(a-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

struct Point {
    int x;
    int y;
};

int main() {
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for (int i = 0; i < k + 1; i++) {
        for (int j = 0; j < k + 1; j++) {
            int l = s - i - j;
            if (0 <= l && l <= k) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, k;
    cin >> n >> k;
    ll c = 0;
    while (n > 0)
    {
        c++;
        n /= k;
    }
    cout << c << '\n';
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
long cakes(long *a,long *b,long *c,long *d,int n,int m,int mode){
  int i,j;
  long tmp;
  
  for(i=0;i<n;i++){
    if(mode%2==0){
      d[i]=a[i];
    } else {
      d[i]=0-a[i];
    }
    
    if((mode%4)/2==0){
      d[i]+=b[i];
    } else {
      d[i]-=b[i];
    }
    
    if((mode%8)/4==0){
      d[i]+=c[i];
    } else {
      d[i]-=c[i];
    }
  }
  
  for(i=n-1;i>0;i--){
    for(j=0;j<i;j++){
      if(d[j]<d[j+1]){
        tmp=d[j];
        d[j]=d[j+1];
        d[j+1]=tmp;
      }
    }
  }
    
  tmp=0;
  for(i=0;i<m;i++){
    tmp+=d[i];
  }
  
  return tmp;
}
int main(){
  int n,m,i,mode;
  long *a,*b,*c,*d;
  long result,result_max;
  
  scanf("%d %d",&n,&m);
  a=(long*)malloc(sizeof(long)*n);
  b=(long*)malloc(sizeof(long)*n);
  c=(long*)malloc(sizeof(long)*n);
  d=(long*)malloc(sizeof(long)*n);
  
  for(i=0;i<n;i++){
    scanf("%ld %ld %ld",&a[i],&b[i],&c[i]);
  }
  
  for(i=0;i<8;i++){
    result=cakes(a,b,c,d,n,m,i);
    if(i==0 || (i!=0 && result_max<result)){
      result_max=result;
    }
  }
  
  printf("%ld",result_max);
  free(a);
  free(b);
  free(c);
  free(d);
}

Measured memory_bytes: 256
// Last Change: 11/07/2019 19:24:34.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, W, H;
  cin >> N >> W >> H;
  // vector<ll> x(N);
  // vector<ll> y(N);
  // vector<ll> w(N);
  vector<int> row(W + 1, 0), col(H + 1, 0);

  ll x, y, w;
  for (ll i = 0; i < N; ++i) {
    cin >> x >> y >> w;
    ++row[max(0LL, x - w)];
    --row[min(W, x + w) ];
    ++col[max(0LL, y - w)];
    --col[min(H, y + w) ];
  }
  ll tmp = 0;
  for (ll i = 0; i < W; ++i) {
    tmp += row[i];
    if (tmp > 0) {
      row[i] = 1;
    } else {
      row[i] = 0;
    }
  }
  tmp = 0;
  for (ll i = 0; i < H; ++i) {
    tmp += col[i];
    if (tmp > 0) {
      col[i] = 1;
    } else {
      col[i] = 0;
    }
  }


  int flag = 2;
  for (ll i = 0; i < W; ++i) {
    if (row[i] == 0) {
      --flag;
      break;
    }
  }
  for (ll i = 0; i < H; ++i) {
    if (col[i] == 0) {
      --flag;
      break;
    }
  }
  if (flag == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  cout<<" "<<3;
  for(int i=4;i<=n;++i){
    if(i%3==0) cout<<" "<<i;
    else{
      int a=i;
      while(a){
        if(a%10==3) cout<<" "<<i,a=0;
        a/=10;
      }
    }
  }
  cout<<endl;
}



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

char s[8008];
int ex, ey;
bool dp[2][16006];
vector<int> dv[2];

bool foo(int dist, vector<int> & mv) {
  memset(dp,0,sizeof(dp));
  int f = 0;
  dp[0][8000] = true;
  for(int x : mv) {
    for(int i=0;i<=16000;i++) {
      if(!dp[f][i]) continue;
      dp[!f][i+x] = dp[!f][i-x] = true;
    }
    memset(dp[f],0,sizeof(dp[f]));
    f = !f;
  }
  return dp[f][dist];
}

int main() {
  scanf("%s%d%d",s,&ex,&ey);
  ex += 8000;
  ey += 8000;
  int i=0;
  while(s[i] == 'F') {
    i++;
    ex--;
  }
  if(ex<0) {
    puts("No");
    return 0;
  }
  int d=0, dir=0;
  for(;s[i];i++) {
    if(s[i] == 'T') {
      if(d) dv[dir].push_back(d);
      dir = !dir;
      d = 0;
    } else {
      d++;
    }
  }
  if(d) dv[dir].push_back(d);
  puts((foo(ex, dv[0]) && foo(ey, dv[1]))?"Yes":"No");

}


Measured memory_bytes: 256
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() //single long
private fun readDouble() = readLn().toDouble() //single double

private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map{it.toLong()} // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(){
    val n = readInt()

    val diceOutput = mutableListOf<List<Int>>()
    for(i in 0 until n){
        diceOutput.add(readInts())
    }

    var counter = 0

    for(i in 0 until n){
        if(diceOutput[i][0] == diceOutput[i][1]){
            counter++
            if(counter == 3){
                println("Yes")
                exitProcess(0)
            }
        }else{
            counter = 0
        }
    }

    println("No")
}

Measured memory_bytes: 37948
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;

int main(){
	cin >> s;
	n = strlen(s);
	for(i=0;i<n;i++){
		if(s[i] == 'o')a++;
	}
	YES((15-n + a) >= 8);
	return 0;
}

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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << (A + B) << endl;
  }
  else if (op == '-') {
    cout << (A - B) << endl;
  }
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    A, B, Q = map(int, input().split())
    S = [-10**50]
    T = [-10**50]
    for _ in range(A): S.append(int(input()))
    for _ in range(B): T.append(int(input()))
    S.append(10**50)
    T.append(10**50)

    for _ in range(Q):
        x = int(input())
        idx1 = bisect_left(S, x)
        idx2 = bisect_left(T, x)
        ans = 10 ** 11
        cand1 = (x - S[idx1 - 1]) + abs(S[idx1 - 1] - T[idx2 - 1])
        ans = min(ans, cand1)
        cand2 = (x - S[idx1 - 1]) + (T[idx2] - S[idx1 - 1])
        ans = min(ans, cand2)
        cand3 = (S[idx1] - x) + (S[idx1] - T[idx2 - 1])
        ans = min(ans, cand3)
        cand4 = (S[idx1] - x) + abs(S[idx1] - T[idx2])
        ans = min(ans, cand4)
        cand5 = (x - T[idx2 - 1]) + abs(T[idx2 - 1] - S[idx1 - 1])
        ans = min(ans, cand5)
        cand6 = (x - T[idx2 - 1]) + (S[idx1] - T[idx2 - 1])
        ans = min(ans, cand6)
        cand7 = (T[idx2] - x) + (T[idx2] - S[idx1 - 1])
        ans = min(ans, cand7)
        cand8 = (T[idx2] - x) + abs(T[idx2] - S[idx1])
        ans = min(ans, cand8)
        print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 132060
import math
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
Alice = []
Bob = []
for i in range (N):
  if i % 2 == 0:
    Alice.append(a[i])
  else:
    Bob.append(a[i])
print(sum(Alice)-sum(Bob))


Measured memory_bytes: 3060
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

bool ok(ll a,ll b,ll c)
{
	ll x;
	if(a+b>c) return false;
	else x=c-a-b;
	if(x*x>a*b*4ll) return true;
	else return false;
}

int main()
{	
	ll a,b,c;
	cin>>a>>b>>c;
	if(ok(a,b,c)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}		

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

int main()
{
    ll N;
    map<string, ll> S;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        string temp;
        cin >> temp;
        ++S[temp];
    }
    int maxv = 0;
    for (const auto &x : S)
    {
        ll v = x.second;
        if (v > maxv)
            maxv = v;
    }
    for (auto it = S.begin(); it != S.end(); ++it)
    {
        if (it->second == maxv)
        {
            cout << it->first << endl;
        }
    }
}

Measured memory_bytes: 25216
a,A=map(int,input().split())
b,B=map(int,input().split())
c,C=map(int,input().split())
d,D=map(int,input().split())


if (a == 1):
    print(A*6000)
elif (a == 2):
    print(A*4000)
elif (a == 3):
    print(A*3000)
elif (a == 4):
    print(A*2000)


if (b == 1):
    print(B*6000)
elif (b == 2):
    print(B*4000)
elif (b == 3):
    print(B*3000)
elif (b == 4):
    print(B*2000)


if (c == 1):
    print(C*6000)
elif (c == 2):
    print(C*4000)
elif (c == 3):
    print(C*3000)
elif (c == 4):
    print(C*2000)


if (d == 1):
    print(D*6000)
elif (d == 2):
    print(D*4000)
elif (d == 3):
    print(D*3000)
elif (d == 4):
    print(D*2000)



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int a,b;
    cin >> a >> b;
    
    cout << a-b+1 << endl;
}







Measured memory_bytes: 256
def main():
	N = int(input())
	A = [int(a) - 1 for a in input().split(" ")]
	int_cnt = [0] * N
	for a in A:
		int_cnt[a] += 1
	S = sum([combination_2(c) for c in int_cnt])
	for i in range(N):
		x = int_cnt[A[i]]
		print(S - combination_2(x) + combination_2(x - 1))

def combination_2(n):
	return int(n * (n - 1) / 2)

main()

Measured memory_bytes: 32148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
string compare(string a, string b)
{
    if (a.size() > b.size())
    {
        return a;
    }
    else if (b.size() > a.size())
    {
        return b;
    }
    else
    {
        return (a.compare(b) > 0) ? a : b;
    }
}
int LenInfo[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M)
    {
        cin >> A[i];
    }
    vector<string> dp(N + 1);
    vector<bool> exist(N + 1, false);
    dp[0] = "";
    exist[0] = true;
    dp[1] = "";
    FORS(i, 2, N)
    {
        dp[i] = "";
        REP(j, M)
        {
            int cost = LenInfo[A[j]];
            //   cout << cost << "\n";
            int lastIndex = i - cost;
            if (lastIndex >= 0 && exist[lastIndex])
            {
                string tmp = dp[lastIndex] + to_string(A[j]);
                //cout << A[j] << " " << lastIndex << "\n";
                //cout << "tmp" << tmp << "\n";
                dp[i] = compare(dp[i], tmp);
            }
        }
        if (dp[i] != "")
            exist[i] = true;
        //cout << i << " " << dp[i] << "\n";
    }
    cout << dp[N] << "\n";
}

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

const int MAX_N = 1e5 + 5, MAX_M = 40;
int n, x, ans, p;
int a[MAX_N];
int l[MAX_N];
bool cnt[MAX_M];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
		
	for (int i = 0; i < n; i++)
		x ^= a[i];
		
	for (int i = 0; i < n; i++) {
		l[i] = __builtin_ctz(a[i]);
		cnt[l[i]]++;
	}
		
	
	for (int i = 31; ~i; i--)
		if (((x >> i) & 1) ^ p) {
			if (!cnt[i]) {
				printf("-1");
				return 0;
			}
			
			p = !p;
			cnt[i] = false;
			ans++;
		}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1024
import collections
N,M = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(M)]
a.sort()
B = collections.Counter(x[0] for x in a)[1]
C = set([])
for i in range(B):
    C.add(a[i][1])
for i in range(M):
    if a[i][0] in C and a[i][1] == N:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

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


int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
    }
    ans=max(ans,now);
    return;
  }

  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  dfs(vector<int>(1,1));
  cout<<ans<<endl;
  return 0;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n;
    cin >> n;

    pii pos = {0, 0};

    bool sim = true;
    int at = 0;
    fo(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = (abs(x - pos.ff) + abs(y - pos.ss));

        if ( ( dist & 1) != ((t - at) & 1) or t - at < dist ) sim = false;
        at = t;
        pos = {x, y};
    }

    cout << (sim ? "Yes\n" : "No\n");

    return 0;
}

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

const ll MOD = 1e9+7;

ll powMod(ll a, ll n) {
    ll ans = 1;
    while (n) {
        if (n&1) ans = ans*a%MOD;
        a = a*a%MOD;
        n >>= 1;
    }
    return ans;
}

void solve() {
    ll n;
    cin >> n;
    ll ans = powMod(10, n)-2*powMod(9, n)+powMod(8, n);
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    cin >> N >> M;
    ll H[N];
    ll i;
    for(i=0;i<N;i++){
        cin >> H[i];
    }
    vector<ll> p[N];
    ll a,b;
    for(i=0;i<M;i++){
        cin >> a >> b;
        p[a-1].push_back(b-1);
        p[b-1].push_back(a-1);
    }
    ll ans=0;
    ll t;
    for(i=0;i<N;i++){
        t=1;
        for(auto itr=p[i].begin();itr!=p[i].end();itr++){
            if(H[i]<=H[*itr])t=0;
        }
        ans+=t;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 10212
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char s[N] , t[N];
int n;
int main() {
    cin >> n >> s >> t;
    for (int i = n ; i >= 0 ; -- i) {
        bool flag = 1;
        for (int j = 0 ; j < i ; ++ j) {
            if (s[n - i + j] != t[j]) {
                flag = 0;
                break;
            }
        }
        if (flag) {
            cout << n + n - i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 100005
  #define INF 1000000000000
  #define eps 1e-6
  int dp[N];
  int32_t main()
  {         
    IOS


    //dp[i] denotes the minimum cost to win over h points

    int h,n;
    cin >> h >> n;

      for(int i = 1; i <=h; i++)dp[i] = INF;


    vector<pair<int,int>> v;

    for(int i = 1; i <=n; i++)
    {
      int x, y;
      cin >> x >> y;
      v.PB(MP(x,y));
    }




    for(int i = 1; i <= h; i++)
    {
      for(auto j: v)
      {
        if(i < j.first)dp[i] = min(dp[i],j.second);
        else dp[i] = min(dp[i],dp[i-j.first] + j.second);
      }
    }

    dp[0] = 0;



    cout << dp[h];  
    return 0; 
}

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


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
class BAnOddProblem {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin >> n;

        vector<int> a(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            if (i % 2 == 1 && a[i] % 2 == 1){
                ans++;
            }
        }
        cout << ans << endl;

	}
};


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


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
6 3
2 1
2 3
4 1
4 2
6 1
2 6
4 6
6 5
)");
#define cin input
#endif

void visit(int v, vector<int>& p, vector<set<int>>& c, int d)
{
	if (p[v] > 0)
		return;
	for (int i : c[v])
	{
		visit(i, p, c, d + 1);
	}
}

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

	vector<int> p(n);
	vector<int> w(n);
	vector<set<int>> c(n);

	REP (i, n + m - 1)
	{
		int a, b;
		cin >> a >> b;
		c[--a].insert(--b);
		++w[b];
	}

	REP (i, n)
	{
		if (w[i])
			continue;

		p[i] = -1;
		
		set<int> q = {i};

		while (q.size())
		{
			set<int> n;

			for (int j : q)
			{
				for (int k : c[j])
				{
					if (--w[k])
						continue;
					p[k] = j;
					n.insert(k);
				}
			}

			swap(q, n);
		}

		break;
	}

	REP (i, n)
		cout << (p[i] + 1) << endl;

	return 0;
}


Measured memory_bytes: 15616
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;


#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2


int main(){
  int n; cin >> n;
  int T; cin >> T;
  int A[n+1][3];
  for (int i=0; i<n; i++){
    cin >> A[i][0] >> A[i][1];
  }
  int min = (1<<21);
  for (int i=0; i<n; i++){
    if (T>= A[i][1] && min > A[i][0]) min = A[i][0]; 
  }
  if (min == (1<<21)) cout << "TLE" << endl;
  else {
    cout << min << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
/* b 600pts */
#include <bits/stdc++.h>
#define N 100005

using namespace std;

const int mod = 1e9 + 7;

int n;
int x[N], d[N], g[N];
int fac[N], ifac[N];

inline int fpm(int x, int y) {
	int res = 1;
	while(y) {
		if(y & 1) res = 1LL * res * x % mod;
		x = 1LL * x * x % mod, y >>= 1;
	}
	return res;
}

inline int perm(int s, int r) { return 1LL * fac[s] * ifac[s - r] % mod; }
inline int comb(int s, int r) { return 1LL * perm(s, r) * ifac[r] % mod; }

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &x[i]);
		if(i > 1) d[i - 1] = x[i] - x[i - 1];
	}
	
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = 1LL * i * fac[i - 1] % mod;
	ifac[n] = fpm(fac[n], mod - 2);
	for(int i = n; i; --i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	
	--n;
	for(int i = 1; i <= n; ++i) {
		g[i] = 1LL * comb(n, i) * fac[n - i] % mod * fac[i - 1] % mod;
		g[i] = (g[i] + g[i - 1]) % mod;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		ans = (ans + 1LL * d[i] * g[i]) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var a = o.m(h);
  var ans = [[0]];
  for(var i = 0; i < h; i++){
    for(var j = 0; j < w-1; j++){
      if(a[i][j] & 1){
        ans.push([i+1,j+1,i+1,j+2]);
        a[i][j]--;a[i][j+1]++;
      }
    }
    if(i === h-1)break;
    if(a[i][j] & 1){
      ans.push([i+1,j+1,i+2,j+1]);
      a[i][j]--;a[i+1][j]++;
    }
  }
  ans[0][0] = ans.length-1;
  return ans.map(a=>a.join(" ")).join("\n");
}

Measured memory_bytes: 68432
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    s = input()
    return s[:4] + ' ' + s[4:]

print(f())


Measured memory_bytes: 6952
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    long long int A, B, K;
    cin >> A >> B >> K;
    set<long long int> st;
    st.insert(A);
	st.insert(B);
    for(long long int a=A; a<min(A+K, B); a++) {
        st.insert(a);
    }
    for(long long int b=B; b>max(B-K, A); b--) {
        st.insert(b);
    }
    for(auto itr=st.begin(); itr!=st.end(); itr++) {
        cout << *itr << endl;
    }


    return 0;
    
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


/*
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 400;

ll dp[N+1][N+1];
ll pref[N+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
ll a[N+1];

ll n;

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

	for(int i=1; i<=n; ++i)
		dp[i][i]=0;

	for(int i=1; i<n; ++i)
		dp[i][i+1]=a[i]+a[i+1];

	for(int i=2; i<n; ++i){
		for(int j=1; j+i<=n; ++j){
			dp[j][j+i]=1e18;
			for(int k=j; k<i+j; ++k){
				dp[j][j+i]=min(dp[j][j+i], dp[j][k]+dp[k+1][i+j]+pref[i+j]-pref[j-1]);
			}
		}
	}
	cout << dp[1][n] << ends;
}




Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
char s[105], t[105];
int main(){
	int n;
	scanf("%d", &n);
	scanf("%s", s+1);
	scanf("%s", t+1);
	int ans = 2*n;
	for(int i=1;i<=n;i++){
		int k = 1;
		bool ok = 1;
		for(int j=n-i+1;j<=n;j++,k++){
			if(s[j] == t[k]) continue;
			ok = 0;
		}
		if(ok) ans = 2*n-i;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;



int main() {

    int a=0;
    int b=0;
    cin >> a >> b;
    int cnt = 1;

    if( a - b <= 0) cnt = 1;
    else{
        int sum = a-b;
        while(sum >0){

            cnt++;
            sum -= b;

        }

    }
    
    
    cout << cnt << endl;

    return 0;

}
   

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

#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define fi first
#define se second

using pii = pair<int,int>;
using vint = vector<char>;
using vvint = vector<vector<char>>;
using bit = bitset<400>;

int w,h;
bool inside(int a, int b){
	return 0<=a&&a<h&&0<=b&&b<w;	
}

int dd[] = {0,1,0,-1,0};


int main(){
	while(cin>>w>>h,w){
		pii start;
		pii goal;
		bit vv(0);		
		rep(i,h) rep(j,w){
			int t;
			cin>>t;
			if(t==1) vv[i*20+j]=1;
			if(t==2){
				start = pii(i,j);
			}
			if(t==3){
				goal = pii(i,j);
			}
		}
		bool ok = false;
		queue<pair<pii,bit>> q;
		q.push(make_pair(start, vv));
		int ans = 20;
		rep(_,11){
			int qs = q.size();
			rep(i,qs){
				pii now = q.front().fi;
				bit vv = q.front().se;
				// rep(ii,h){
				// 	rep(jj,w){
				// 		cout<<vv[ii][jj]<<" ";
				// 	}
				// 	cout<<endl;
				// }
				q.pop();
				rep(j,4){
					pii next = now;
					next.fi += dd[j];
					next.se += dd[j+1];
					// cout<<next.fi<<" "<<next.se<<" "<<inside(next.fi, next.se)<<endl;
					if(inside(next.fi, next.se) && vv[next.fi*20+next.se]==0){
						// cout<<"hoge"<<endl;
						while(inside(next.fi, next.se)&&vv[next.fi*20+next.se]==0){
							// cout<<"vv "<<vv[next.fi*20+next.se]<<endl;
							if(next == goal) ans = min(ans, _+1);
							next.fi += dd[j];
							next.se += dd[j+1];
						}
						if(inside(next.fi, next.se)){
							vv[next.fi*20+next.se] = 0;
							next.fi -= dd[j];
							next.se -= dd[j+1];
							q.push(make_pair(next, vv));
							next.fi += dd[j];
							next.se += dd[j+1];
							vv[next.fi*20+next.se] = 1;
						}
					}
				}
			}
		}
		cout<<(ans<=10?ans:-1)<<endl;
	}
}

Measured memory_bytes: 16608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int n,k,a[mx],jaw=1e9;
int cel(int a,int b){
	int ret=a/b;
	if(a%b)ret++;
	return ret;
}
int main(){
	cin>>n>>k;
	int di;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==1)di=i;
	}
	for(int kiri=di-k+1;kiri<=min(n,di+k-1);kiri++){
		int sa=kiri-1;
		int du=k;
		int ti=n-sa-du;
	//	debug(sa);
	//	debug(du);
	//	debug(ti);
		jaw=min(jaw,1+cel(sa,k-1)+cel(ti,k-1));
	//	debug(jaw);
	}
	cout<<jaw<<endl;
}




Measured memory_bytes: 640
def make_2d_array(n, m, init)
  n.times.map{[init] * m}
end

def min(a, b)
  a < b ? a : b
end

n, _   = gets.split(' ').map(&:to_i)
# Available coins
coins = gets.split(' ').map(&:to_i)

# Initialize DP table
dp_table = make_2d_array(coins.size+1, n+1, nil)
(1..n).each{|j|
  dp_table[0][j] = Float::INFINITY
}
dp_table[0][0] = 0


(1..coins.size).each{|i|
  (0..n).each{|j|
    coin = coins[i-1]
    if 0 <= j - coin
      dp_table[i][j] = min(dp_table[i-1][j], dp_table[i][j - coin] + 1)
    else
      dp_table[i][j] = dp_table[i-1][j]
    end
  }
}


puts(dp_table[-1][-1])


Measured memory_bytes: 15120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	int n,a;
	bool f=true;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==0&&(a%3!=0&&a%5!=0)){
			f=false;
			break;
		}
	}
	if(f){
		cout<<"APPROVED"<<endl;
	}else{
		cout<<"DENIED"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int n,k;
vector<int> v;

int main(){
	int a;
	int i;
	while(scanf("%d %d",&n,&k) && (n || k) ){
		v.clear();
		for(i=0;i<n;i++){
			scanf("%d",&a);
			v.push_back(a);
		}
		a = 0;
		for(i=0;i<k;i++){
			a+=v[i];
		}
		//printf("%d-%d,%d\n",i-k,i,a);
		int max = a;
		for(;i<n;i++){
			a = a - v[i - k] + v[i];
			//printf("%d-%d,%d\n",i-k,i,a);
			if(max < a){max = a;}
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
int c[100];
int dp[100000];

int main(){
	cin >> n >> m;
	REP(i, m)cin >> c[i];
	fill(dp, dp + 100000, INF);
	dp[0] = 0, dp[1] = 1;
	REP(i, m){
		FOR(j, 2, 50001){
			if (j >= c[i]){
				dp[j] = min(dp[j], dp[j - c[i]] + 1);
			}
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1556