akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
using namespace std;

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

  stack<char> s;
  for(int i = 0; i < x.size(); i++){
    if(x[i] == 'S'){
      s.push(x[i]);
    }else{
      if(s.empty()){
        s.push(x[i]);
      }else if(s.top() == 'T'){
        s.push(x[i]);
      }else{
        s.pop();
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 644
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    a, b = input_nums()
    if a > 9 or b > 9:
        print(-1)
    else:
        print(a * b)

if __name__ == '__main__':
    main()

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

int main() {
  vector<int> penki(101, 0);
  for(int i = 0; i < 3; i++) {
  	int a;
    cin >> a;
    penki.at(a) = 1;
  }
  int b = 0;
  for (int i = 0; i < 101; i++) {
  	b += penki.at(i);
  }
  
  cout << b << endl;
}



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

int main(){
	ll A,B,C;cin>>A>>B>>C;
	ll na,nb,nc;
	ll ret=0;
	for(;;){
		if(A%2||B%2||C%2)break;
		++ret;
		na=B*0.5+C*0.5;
		nb=A*0.5+C*0.5;
		nc=A*0.5+B*0.5;
		A=na;
		B=nb;
		C=nc;
		if(na%2||nb%2||nc%2)break;
		if(na==nb&&nb==nc){ret=-1;break;}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,c;
bool f[111];
int r[111];
int main(void){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    for(int j = a; j <= b; j++){
      r[j] = max(r[j],b);
    }
  }
  for(int i = 1; i <= n; i++){
    if(f[i]) continue;
    if(!r[i]){
      cout << "Impossible" << endl;
      return 0;
    }
    c++;
    for(int j = i; j <= r[i]; j++) f[j] = true;
  }
  cout << c << endl;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#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/2
 
using namespace std;
int MOD = 1000000007;
signed main(){
 
    int k,a,b;
    cin >> k >> a >> b;

    if(b-a <= 2 || k < a+1){
        cout << 1+k << endl;
        return 0;
    }
    int ans = a;
    k -= a-1;
    if(k%2 == 0){
        ans += (k/2)*(b-a);
    }else{
        ans += (k/2)*(b-a)+1;
    }
    cout << ans << endl;


    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static long[] p;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long x = sc.nextLong();
    p = new long[n + 1];
    p[0] = 1;
    for(int i = 1; i <= n; i++) {
      p[i] = 2 * p[i - 1] + 3;
    }
    System.out.println(func(n, x));
  }

  public static long func(int s, long t) {
    if(s == 0) return 1;
    if(t == 1) {
      return 0;
    } else if(t <= (1 + p[s - 1])) {
      return func(s - 1, t - 1);
    } else if(t == (2 + p[s - 1])) {
      return (1 + func(s - 1, p[s - 1]));
    } else if(t < (3 + (2 * p[s - 1]))) {
      return (1 + func(s - 1, p[s - 1]) + func(s - 1, t - (2 + p[s - 1])));   
    } else {
      return (2 * func(s - 1, p[s - 1]) + 1);  
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];
vector<int> G[MAX_N];

bool used[MAX_N];
int dp[MAX_N];

void loop(int v) {
	used[v] = true;
	dp[v] = 0; 
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(A[v] > A[n]) {
			loop(n);
			dp[v] |= (dp[n] ^ 1);
		}
	}
}

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	rep(i, 0, N) {
		if(!used[i]) loop(i);
	}
	vector<int> ans;
	rep(i, 0, N) {
		if(dp[i]) ans.pb(i);
	}
	rep(i, 0, sz(ans)) {
		cout << ans[i] + 1 << " ";
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 5632
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int n;
  cin>>n;
  ll ans=0;
  REP(i,n){
    int x;
    cin>>x;
    ans+=x-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func binarySearch(a []int, left, right, key int) bool {
	if left > right {
		return false
	}

	mid := (left + right) / 2
	if a[mid] == key {
		return true
	}
	if a[mid] < key {
		return binarySearch(a, mid+1, right, key)
	} else {
		return binarySearch(a, left, mid-1, key)
	}
}

func main() {
	n := scanInt()
	s := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = scanInt()
	}
	sort.Ints(s)

	q := scanInt()
	count := 0
	for i := 0; i < q; i++ {
		if binarySearch(s, 0, n-1, scanInt()) {
			count++
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 1212
#include <bits/stdc++.h> 
using namespace std;
int n,k,ans,p;
int GuiLv[12][6]= {
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}
};
int main() {
    scanf("%d%d",&n,&k);
    ans=((n-2)/11)*5;
    if(n<=2)
        for(int i=0; i<p; i++)
            for(int j=0; j<5; j++) {
                if(GuiLv[i][j]==k)
                    ans++;
            }
    else
        for(int i=0; i<(n-2)%11; i++)
            for(int j=0; j<5; j++)
                if(GuiLv[i][j]==k)
                    ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, Z, W;
  cin >> N >> Z >> W;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  ll ans = abs(A.front() - W);
  if (N >= 2)
    ans = max(abs(A.at(N - 2) - A.at(N - 1)), abs(A.at(N - 1) - W));
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b=ml()
legs=0
f=0
for i in range(a+1):
    if (i*2+(a-i)*4)==b:
        f=1

if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65200
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp1[n+1],dp2[n+1],dp3[n+1];
    dp1[0]=dp2[0]=dp3[0]=0;
    for(int i=1;i<=n;i++){
        dp1[i]=max(dp2[i-1],dp3[i-1])+a[i];
        dp2[i]=max(dp3[i-1],dp1[i-1])+b[i];
        dp3[i]=max(dp1[i-1],dp2[i-1])+c[i];
    }
    int ma=max(dp1[n],dp2[n]),ans=max(ma,dp3[n]);
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;

		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int N = vs[0];
			int M = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			PriorityQueue<int> queue = new AtCoder.PriorityQueue<int>(true);
			foreach (int item in a) {
				queue.Enqueue(item);
			}
			//System.Diagnostics.Debug.WriteLine(queue);

			for (int i = 0; i < M; i++) {
				int item = queue.Dequeue();
				item /= 2;
				queue.Enqueue(item);
			}
			//System.Diagnostics.Debug.WriteLine(queue);

			long ans = 0;
			foreach (var item in queue) {
				ans += item;
			}
			Console.WriteLine(ans);

		}
	}

	#region PriorityQueue

	public class PriorityQueue<T> where T : IComparable
	{
		private readonly List<T> _Heap;
		private readonly Comparison<T> _Compare;

		public int Count { get { return _Heap.Count; } }

		public PriorityQueue() : this(false) { }
		public PriorityQueue(bool reverse)
		{
			_Heap = new List<T>();
			if (!reverse) {
				_Compare = (T x, T y) => Comparer<T>.Default.Compare(x, y);
			} else {
				_Compare = (T x, T y) => Comparer<T>.Default.Compare(y, x);
			}
		}

		public void Enqueue(T item)
		{
			_Heap.Add(item);
			int i = _Heap.Count - 1;
			while (i > 0) {
				int p = (i - 1) / 2;
				if (_Compare(_Heap[p], item) <= 0) {
					break;
				}
				_Heap[i] = _Heap[p];
				i = p;
			}
			_Heap[i] = item;
		}

		public T Dequeue()
		{
			var ret = _Heap[0];
			int size = _Heap.Count - 1;
			var x = _Heap[size];
			var i = 0;
			while (i * 2 + 1 < size) {
				var a = i * 2 + 1;
				var b = i * 2 + 2;
				if (b < size && _Compare(_Heap[b], _Heap[a]) < 0) {
					a = b;
				}
				if (_Compare(_Heap[a], x) >= 0) {
					break;
				}
				_Heap[i] = _Heap[a];
				i = a;
			}
			_Heap[i] = x;
			_Heap.RemoveAt(size);
			return ret;
		}

		public T Peek()
		{
			return _Heap[0];
		}

		public void Clear()
		{
			_Heap.Clear();
		}

		public List<T>.Enumerator GetEnumerator()
		{
			return _Heap.GetEnumerator();
		}

		public override string ToString()
		{
			return string.Join(" ", _Heap);
		}
	}

	#endregion

}


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

int main(){
    int sum_left = 0, sum_right = 0;
    vector <int> numbers;
    for(int i = 0; i < 4; i++){
        int a;
        cin >> a;
        numbers.push_back(a);
    }
    for(int i = 0; i < 4; i++){
        if(i < 2) sum_left+=numbers[i];
        else sum_right+=numbers[i];
    }
    if(sum_left == sum_right) cout << "Balanced" << endl;
    else if(sum_left > sum_right) cout << "Left"<< endl;
    else cout << "Right" << endl;
    return 0;
}


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

using namespace std;

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

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

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

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

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, a[60];
	cin>>n>>k;
	REP(i, n){
		cin>>a[i];
	}
	vi ans;
	int before=-1;
	REP(i, k+1){
		int mi=200, idx=0;
		REP(j, n){
			if(j!=before && a[j]<mi){
				if(a[j]==0){
					cout<<-1<<'\n';
					return 0;
				}
				mi=a[j];
				idx=j;
			}
		}
		REP(j, n){
			if(j!=before && j!=idx){
				ans.push_back(j+1);
				--a[j];
			}
		}
		ans.push_back(idx+1);
		--a[idx];
		before=idx;
	}
	cout<<ans.size()<<'\n';
	REP(i, ans.size()){
		cout<<ans[i]<<' ';
	}
	return 0;
}


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

using namespace std ;

#define LL long long
#define int long long

signed main()
{
    LL n ;
    scanf("%lld" , &n ) ;
    if( n % 2 == 1 ) printf("0\n") ;
    else{
        int ans = 0 , now = 10 ;
        for(int i = 1 ; now <= n ; now *= 5 , i++ ){
            ans += 1ll * ( n / now ) ;
        }
        cout << ans ;
    }
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.{immutable, mutable}


object Main {
  def read(): (Int, Int, Int, Int, immutable.IndexedSeq[Long], immutable.IndexedSeq[Long], immutable.IndexedSeq[Long]) = {
    val sc = new Scanner(System.in)
    val x, y, z, k = sc.nextInt()
    val a = for (_ <- 0 until x) yield sc.nextLong()
    val b = for (_ <- 0 until y) yield sc.nextLong()
    val c = for (_ <- 0 until z) yield sc.nextLong()
    (x, y, z, k, a, b, c)
  }

  def solve(x: Int, y: Int, z: Int, k: Int, a: immutable.IndexedSeq[Long], b: immutable.IndexedSeq[Long], c: immutable.IndexedSeq[Long]): Unit = {
    val sortedA = a.sortBy(n => -n)
    val sortedB = b.sortBy(n => -n)
    val sortedC = c.sortBy(n => -n)

    def value(x: (Int, Int, Int)) = sortedA(x._1) + sortedB(x._2) + sortedC(x._3)

    val touched = mutable.Set.empty[(Int, Int, Int)]

    val queue = new mutable.PriorityQueue[(Int, Int, Int)]()(Ordering.by[(Int, Int, Int), Long](value))
    queue.+=((0, 0, 0))

    def enqueueIfNonTouched(ai:Int, bi:Int, ci:Int): Unit ={
      if(!touched.contains((ai,bi,ci))){
        touched.add(ai,bi,ci)
        queue.+=((ai,bi,ci))
      }
    }
    for (_ <- 0 until k) {
      val x = queue.dequeue()
        println(value(x))
        val (indexA, indexB, indexC) = x
        if (sortedA.isDefinedAt(indexA + 1)) enqueueIfNonTouched(indexA + 1, indexB, indexC)
        if (sortedB.isDefinedAt(indexB + 1)) enqueueIfNonTouched(indexA, indexB + 1, indexC)
        if (sortedC.isDefinedAt(indexC + 1)) enqueueIfNonTouched(indexA, indexB, indexC + 1)
    }
  }

  def printResult(result: IndexedSeq[Long]) = {
    result.foreach(println)
  }


  def main(args: Array[String]): Unit = {
    val (x, y, z, k, a, b, c) = read()
    solve(x, y, z, k, a, b, c)
  }
}

Measured memory_bytes: 38960
import java.util.*;
 
public class Main {
	     
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int cnt = 0;
		int[][] a = new int[20000][2];
		for(int i=1;i<=200;i++){
			for(int j=i+1;j<=200;j++){
				a[cnt][0] = i;
				a[cnt][1] = j;
				cnt++;
			}
		}
		
		Arrays.sort(a, new Comparator<int[]>(){
			public int compare(int[] o1, int[] o2) {
				if(o1[0]*o1[0]+o1[1]*o1[1]==o2[0]*o2[0]+o2[1]*o2[1]) return o1[0]-o2[0];
				return (o1[0]*o1[0]+o1[1]*o1[1]) - (o2[0]*o2[0]+o2[1]*o2[1]);
			}
		});
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h==0 && w==0) break;
			
			for(int i=0;i<20000;i++){
				if(a[i][0]==h && a[i][1]==w){
					System.out.println(a[i+1][0] + " " + a[i+1][1]);
					break;
				}
			}
		}
    }   
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

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

  bool ok=false;
  int k=1;
  while(k*(k-1)<=2*n){
    if(k*(k-1)==2*n){
      ok=true;
      break;
    }
    k++;
  }

  if(!ok){
    prt("No");
    return 0;
  }

  vector<vector<int>> v(k);
  int num=1;
  rep(i,k-1){
    rep(j,i+1){
      v[i].push_back(num);
      if(j==i){
        v[k-1].push_back(num);
      } else {
        v[j].push_back(num);
      }
      num++;
    }
  }

  prt("Yes");
  prt(k);
  rep(i,k){
    cout << v[i].size() << " ";
    rep(j,v[i].size()){
      cout << v[i][j] << (j!=v[i].size()-1 ? " " : "\n");
    }
  }
}


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

using namespace std;
#define pb push_back
#define int long long
int n,m,check=0,c[100005],num[2];
vector<int> graph[100005];
bool vis[100005];
void dfs(int u,int color){
    num[color]++;
    vis[u]=1;
    for(int i=0;i<graph[u].size();i++){
        int v=graph[u][i];
        if(vis[v]==0){
            c[v]=1-color;
            dfs(v,1-color);
        }
    }
}
signed main(){
    cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    c[1]=0;
    dfs(1,0);
    for(int i=1;i<=n;i++){
        for(int j=0;j<graph[i].size();j++){
            int v=graph[i][j];
            if(c[v]==c[i])
                check=1;
        }
    }
    if(check==1)
        cout<<n*(n-1)/2-m;
    else
        cout<<num[0]*num[1]-m;
}

Measured memory_bytes: 8064
#include <iostream>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    int c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,any=0;
    for (int i = 0; i < n; i++) {
        int a = 0;
        cin >> a;
        if (a < 400) {
            c1 = 1;
        } else if (a < 800) {
            c2 = 1;
        } else if (a < 1200) {
            c3 = 1;
        } else if (a < 1600) {
            c4 = 1;
        } else if (a < 2000) {
            c5 = 1;
        } else if (a < 2400) {
            c6 = 1;
        } else if (a < 2800) {
            c7 = 1;
        } else if (a < 3200) {
            c8 = 1;
        } else {
            any++;
        }
    }
 
    int min = c1+c2+c3+c4+c5+c6+c7+c8;
    int max = min + any;
 
    if (min == 0 && any > 0) {
        min = 1;
        max = any;
    }
/*
レート 1-399：灰色
レート 400-799：茶色
レート 800-1199：緑色
レート 1200-1599：水色
レート 1600-1999：青色
レート 2000-2399：黄色
レート 2400-2799：橙色
レート 2800-3199：赤色
*/
 
    cout << min << " " << max << endl;
 
    return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a + b;
    ll x = n / c, y = n % c;
    ll res = x * a + min(y, a);
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

const ll MAXN=1000010;

ll bit[MAXN];
void add(ll a, ll w) {
for (ll x = a; x <= MAXN; x += (x & -x)) bit[x] += w;
}
ll sum(ll a) {
    if(!a) return 0;
 ll ret = 0;
for (ll x = a; x > 0; x -= (x & -x)) ret += bit[x];
 return ret;
}
vector<P> d[MAXN];

int main(){
    ll N,Q; cin>>N>>Q;
    vec c(N+1,0);
    rep(i,N) cin>>c[i+1];
    rep(i,Q){
        ll l,r; cin>>l>>r;
        l--; d[r].pb(mp(i,l));
    }
    vec ans(Q);
    vec memo(N+1,-1);
    REP(i,1,N+1) {
        if(memo[c[i]]!=-1) add(memo[c[i]],-1);
        memo[c[i]]=i;
        add(i,1);
        ll X=sum(i);
        rep(j,d[i].size()) {
            ll q=d[i][j].first, l=d[i][j].second;
            ans[q]=X-sum(l);
        }
    }
    rep(i,Q) cout<<ans[i]<<endl;

}

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> coo(N,vector<int>(2));
  vector<int> tmp(N);
  double ave = 0;
  double Na=1.0;
  for(int i=1; i<=N; i++) Na*=i;
  
  for(int i=0; i<N; i++){
    cin >> coo.at(i).at(0) >> coo.at(i).at(1);
  }
  for(int i=0; i<N; i++){
    tmp.at(i) = i;
  }
  
  do{
    for(int i=0; i<N-1; i++){
     ave += (sqrt(pow(coo.at(tmp.at(i)).at(0)-coo.at(tmp.at(i+1)).at(0),2.0)+
         pow(coo.at(tmp.at(i)).at(1)-coo.at(tmp.at(i+1)).at(1),2.0)));
    }
  }while(next_permutation(tmp.begin(),tmp.end()));
  cout << fixed << setprecision(10);
  cout << ave / Na << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	unordered_map<long long, int> d;
	++d[0];
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		sum += A;
		++d[sum];
	}
	long long ans = 0;
	for (pair<long long, int> i : d) {
		ans += 1LL * i.second * (i.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8520
// AOJ 3131 Prize
// 2020.1.15 bal4u

#include <stdio.h>

typedef long long ll;

ll N, K;
int ok(ll x) {
	ll s = 0; int i;
	for (i = 0; i < N; ++i) {
		s += x;
		x >>= 1;
		if (x == 0) break;
	}
	return (s <= K);
}
	
int main()
{
	ll l, r;
	
	scanf("%lld%lld", &N, &K);
	if (N == 1 || K == 1) { printf("%lld\n", K); return 0; }
    l = 0, r = K;
    while (l+1 < r) {
      ll m = (l + r) / 2;
      if (ok(m)) l = m; else r = m;
    }
	printf("%lld\n", l);
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

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

  int xmax = x, ymin = y;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    xmax = max(xmax, tmp);
  }

  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    ymin = min(ymin, tmp);
  }

  if (x < y && xmax < ymin)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool prime[1000000];


void mainmain(){
	int n;
	rep(i,1000000){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(ll i = 2; i*i<=1000000;i++){
		if(prime[i]){
			for(int j = i*i;j < 1000000;j+=i){
				prime[j]=false;
			}
		}
	}
	while(cin>>n,n){
		int ans = 0;
		reep(i,n+1,2*n+1){
			ans += prime[i];
		}
		cout<<ans<<endl;
	}
}


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

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade

double dp[302][302][302];
	
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); 	
	int n;
	cin >> n;
	vi count(4,0);
	for (int i = 0; i < n; i++){
		int x; 
		cin >> x;
		count[x]++;
	}

	for(int three = 0; three <= count[3]; three++){
		for(int two = 0; two <= count[3] + count[2]; two++){
			for(int one = 0; one <= n; one++){
				if(three == 0 and two == 0 and one == 0) {dp[three][two][one] = 0; continue;};
				double answer = 0;
				double probability = (double)n/(three + two + one);
				if(three){
					answer += (dp[three - 1][two + 1][one] + probability)*((double)three/(three + two + one));
				}
				if(two){
					answer += (dp[three][two - 1][one + 1] + probability)*((double)two/(three + two + one));
				}
				if(one){
					answer += (dp[three][two][one - 1] + probability)*((double)one/(three + two + one));
				}
				dp[three][two][one] = answer;
			}
		}
	}
	
	cout << setprecision(9) << fixed << dp[count[3]][count[2]][count[1]] << endl;
	return 0;
}
 


Measured memory_bytes: 215296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >>S;
for (int i = 0; i < 3; i++) {
 if(S.at(i)==S.at(i+1)){
   cout<<"Bad"<<endl;
   return 0;
 }
}
        cout<<"Good"<<endl;
 
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {
	long long int n;
	long long int mini = LLINF;
	long long int total = 0;
	long long int point = 0;
	long long int first, second, third, forth, fifth;
	

	cin >> n;

	vector<long long int> a(n);

	FOR(i, 0, n - 1) {
		cin >> a[i];
		a[i] -= (i + 1);
		total += a[i];
	}

	sort(a.begin(), a.end());
	
	if (n % 2 == 0) {
		first = a[(n / 2) - 1];
		second = a[(n / 2)];
		
		point = 0;
		FOR(i, 0, n-1) {
			point += abs(a[i] - first);
		}
		if (point < mini) {
			mini = point;
		}
		point = 0;
		FOR(i, 0, n - 1) {
			point += abs(a[i] - second);
		}
		if (point < mini) {
			mini = point;
		}
	}
	else {
		first = a[(n / 2)];
		point = 0;
		FOR(i, 0, n - 1) {
			point += abs(a[i] - first);
		}
		if (point < mini) {
			mini = point;
		}
	}

	cout << mini << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n],b[n];
  for(int i = 0; n > i; i++){
    cin >> a[i];
  }
  for(int i = 0; n > i; i++){
    cin >> b[i];
  }
  int ret = 0;
  for(int i = 0; n > i; i++){
    if(a[i] > b[i])ret += a[i]-b[i];
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    now = s[0]
    for j in range(n):
        if (i>>j) & 1 == 1:
            ans += int(now)
            now = s[j+1]
        else:
            now += s[j+1]
    ans += int(now)
print(ans)

Measured memory_bytes: 67244
let n, t = Scanf.scanf "%d %d\n" (fun n t -> n, t)
let ar = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))
let rec f i sum =
  if i = n then (sum + t)
  else if (ar.(i) - ar.(i-1)) <= t then f (i + 1) (sum + ar.(i) - ar.(i - 1))
  else f (i + 1) (sum + t)
let () =
  f 1 0 |> Printf.printf "%d\n"

Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
    // Your code here!
int S; int h,m,s;
scanf("%d",&S);

h=S/60/60;
m=(S-h*3600)/60; //m=S/60;
s=S%60;

printf("%d:%d:%d\n",h,m,s);
//printf("%d %d\n",a*b,a+a+b+b);
//puts("Hello World");//printf("Hello world\n");
    
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main()
{
  const long double INF=2;
  string c;
  cin>>c;
  for(int i=0; i<c.size(); i+=INF)
  {
    if(i%2==0)cout<<c[i];
  }
  return 0;
}

Measured memory_bytes: 512
# https://atcoder.jp/contests/abc123/tasks/abc123_b

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


orders = [a, b, c, d, e]


def last_order(nums):
    cnt = 130
    num = 0

    for i in nums:
        if i % 10 != 0:
            if cnt > int(str(i)[-1]):
                cnt = int(str(i)[-1])
                num = i

    return num


def move_up(num):
    if num % 10 != 0:
        return  num + (10 - (num % 10))
    else:
        return num

last = last_order(orders)
if last:
    orders.remove(last)

total_time = 0

for i in orders:
    total_time = total_time + move_up(i)

print(total_time + last)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pii pair<int,int>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<ctype.h>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
const int N=1e6+10;
const int maxn=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
const int inf=99999999;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	long long n,a,b,res;
	cin>>n>>a>>b;
	long long k=b-a;
	if(k%2==0)
		res=k/2;
	else
	{
		long long c=n-b,d=a-1;
		if(c<d)
			res=(n-b+1)+(b-a-1)/2;
		else
			res=a+(b-a-1)/2;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
std::vector<int> vtr[M];
set<int> st;
ll dfs(int x)
{
	int sb = 1;
	for(auto u:vtr[x])
		sb = sb + dfs(u);
	// cout<<sb<<endl;
	st.insert(sb);
	return sb;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	s = "#"+s;
	int n=sz(s)-1;
	if(s[n]=='1' || s[1]=='0')
	{
		cout<<"-1\n";
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[n-i])
		{
			cout<<"-1\n";
			return 0;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		if(s[i]=='0')
			continue;
		int j=i+1;
		while(j<n-1 && s[j]=='0')
			j++;
		for(int k=i;k<j;k++)
		{
			vtr[j].pb(k);
		}
	}
	dfs(n);
	for(int i=1;i<n;i++)
	{
		if(s[i]=='1')
		{
			if(st.find(i)==st.end())
			{
				cout<<"-1\n";
				return 0;
			}
		}
		else
		{
			if(st.find(i)!=st.end() || st.find(n-i)!=st.end())
			{
				cout<<"-1\n";
				return 0;
			}
		}

	}
	for(int i=1;i<=n;i++)
	{
		for(auto u:vtr[i])
			cout<<i<<" "<<u<<"\n";
	}
	return 0;
}

Measured memory_bytes: 16364
n = int(input())
arr = [0] * (n+1)
for i in range(1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      if i*i+j*j+k*k + i*j+j*k+k*i <= n:
        arr[i*i+j*j+k*k + i*j+j*k+k*i] += 1
for i in range(1, n+1):
  print(arr[i])

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

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   String[] surface =  br.readLine().split(" ");
   String[] order = br.readLine().split("");

   Dise dice1 = new Dise();
   dice1.setSurface(surface);
   dice1.SetDice(1, 2 , 3);
   dice1.RollDice(order);


  }
}


class Dise{

	int[] surface = new int [6];
    int Top,Bottom,Right,Left,Front,Back;


	void setSurface(String[] SurfaceString){

		for(int i = 0; i < 6; i++){

			surface[i] = Integer.parseInt( SurfaceString[i] );

		}

	}

    void SetDice(int top, int front, int right){
	   Top  = top - 1;
       Front = front - 1;
       Right = right - 1;
       Bottom = 5- (top - 1);
       Back = 5- (front - 1);
       Left = 5- (right - 1);
    }//SetDice

    void RollDice(String[] RollString){
    	for(int i = 0; i < RollString.length ; i++){

    		if( RollString[i].equals("W") ){

    			Bottom = Left;
    			Left = Top;
    			Top = 5 - Bottom;
    			Right = 5 - Left;

    		}else if( RollString[i].equals("S")){

    			Bottom = Front;
    			Front = Top;
    			Top = 5 - Bottom;
    			Back = 5 - Front;

    		}else if( RollString[i].equals("E")){

    			Bottom = Right;
    			Right = Top;
    			Top = 5 - Bottom;
    			Left = 5 - Right;

    		}else{

    			Bottom = Back;
    			Back = Top;
    			Top = 5 - Bottom;
    			Front = 5 - Back;

    		}
    	}

    	System.out.println( surface[Top] );
    }//RollDice

}

Measured memory_bytes: 24372
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(register int i=(a);i>=(b);--i)
#define LL long long
#define MaxN 2000010
using namespace std;
int N,M,A[MaxN],Now,Vis[MaxN];
int main(){
	scanf("%d%d",&N,&M);
	if(N==1){printf(M==1?"Yes\n1\n":"No");return 0;}
	if(N==2){printf(M==2?"Yes\n1\n2\n3\n":"No");return 0;}
	if((M==1)||(M==2*N-1)){puts("No");return 0;};
	A[N]=M,A[N+1]=1,A[N-1]=2*N-1;
	Vis[1]=Vis[M]=Vis[2*N-1]=1;
	For(i,1,2*N-1){
		if(i>=N-1&&i<=N+1)continue;
		while(Vis[++Now]);A[i]=Now;
	}
	puts("Yes");For(i,1,2*N-1)printf("%d\n",A[i]);
	return 0;
}

Measured memory_bytes: 5632
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

## 計算量: H*N

H, N = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

inf = float("inf")
dp = [inf for i in range(H+1)] ## i: 体力
dp[0] = 0

for i in range(1, H+1):
  for j in range(N):
    dp[i] = min(dp[i], dp[max(i - AB[j][0], 0)] + AB[j][1])
    
print(dp[H])

Measured memory_bytes: 67816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k;cin>>n>>k;
    vector< pair<ll,ll> > a(n);
    for(ll i=0;i<n;i++)cin>>a[i].second>>a[i].first;
    sort(a.rbegin(),a.rend());
    ll sum=0,cnt=0,ans=0;
    vector<ll> extra,vis(n+1,0);
    for(ll i=0;i<k;i++){
        sum+=a[i].first;
        if(vis[a[i].second]==0)vis[a[i].second]++,cnt++;
        else vis[a[i].second]++,extra.push_back(i);
    }
    ans = max(ans , sum + cnt*cnt);
    for(ll i=k;i<n;i++){
        if(vis[a[i].second])continue;
        if(extra.size()==0)break;

        ll j = extra.back();
        extra.pop_back();

        vis[a[j].second]--;
        sum-=a[j].first;

        vis[a[i].second]++;
        sum+=a[i].first;
        cnt++;

        ans = max(ans , sum + cnt*cnt);
    }

    cout<<ans;
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ll a,b,n;
	cin >> a>>b>>n;
	ll x = min(n, b - 1);
	ll RightFromula = a*x / b;
	ll LeftFromula = x / b;
	LeftFromula *= a;
	cout << RightFromula-LeftFromula << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e18+7;

int main() {
    ios::sync_with_stdio(false);   
    Int a, b;
    cin >> a >> b;
    Int res = 0;
    for (Int i = 0; i < 2; i++) {
    if (a > b) {
        res += a;
        a--;
    }
    else {
        res += b;
        b--;
    }
    }
    dump(res);
    return 0;
}

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

struct E
{
    long long s,t;
    long long num;
    long long w;
} sun[100010];

bool cmp(E a,E b)
{
    if(a.s==b.s)
        return a.t<b.t;
    else
        return a.s<b.s;
}

bool cmp1(E a,E b)
{
    return a.w<b.w;
}

int main()
{
    long long n,m;
    while (scanf("%lld %lld",&n,&m)!=EOF)
    {
        long long i,j;
        for(i=0; i<m; i++)
        {
            scanf("%lld %lld",&sun[i].s,&sun[i].t);
            sun[i].w=i;
        }
        sort(sun,sun+m,cmp);
          int h=1;
          int k=1;
        for(j=0; j<m; j++)
        {
           if(h==sun[j].s)
           {
               sun[j].num=k++;
           }
           else
           {
               k=1;
               j--;
               h++;
           }
        }
        sort(sun,sun+m,cmp1);
        for(i=0; i<m; i++)
            printf("%.6lld%.6lld\n",sun[i].s,sun[i].num);
    }
}


Measured memory_bytes: 4608
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL n, l;
  cin >> n >> l;
  vector<LL> a(n);

  REP(i,n){
    cin >> a[i];
  }

  bool flag = true;

  REP(i,n-1){
    if(a[i]+a[i+1]>=l){
      flag = false;
      cout << "Possible" << endl;
      for (LL j = 0; j < i;++j){
        cout << j+1 << endl;
      }
      for (LL j = n-2; j > i;--j){
        cout << j+1 << endl;
      }
      cout << i + 1 << endl;
      break;
    }
  }
  if(flag){
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 1664
#include <iostream>
    #include <iomanip>
     
    using namespace std;
     
    int main()
    {
    	int N; cin >> N;
     
      	int tmp = (N + 1)/ 2;
     
    	cout << fixed << setprecision(10) << double(tmp) / double(N) << endl;
    }

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;

	int ans;
	if (A == 0){
		ans = 1;
	}
	if (B == 0){
		ans = 2;
	}
	if (C == 0){
		ans = 3;
	}
	if (D == 0){
		ans = 4;
	}
	if (E == 0){
		ans = 5;
	}

		cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>

using namespace std;


int main()
{

	int n; int  k;
	int digit[10], temp;
	for(int i = 0; i < 10; i++)
		digit[i] = 1;
	cin>>n>>k;
	for(int i = 0; i<k; i++)
	{
			cin>>temp;
			digit[temp] = 0;
	}
	int ans = -1;
	for(int i= 0; i<10 ; i++)
		for(int j = 0; j < 10 ; j++)
			for(int k = 0; k < 10 ; k++)
				for(int l = 0; l < 10 ; l++)
					for(int p = 0; p<10 ; p++)	
				{
						int sum = (p+l*10+k*100+j*1000+i*10000); 
						int valid = 1;
						int num[5] = {-1, -1, -1, -1, -1};
						while(sum > 0 && valid)
						{
							valid = valid && digit[sum%10];
							sum= sum/10;
						}
						if( valid && ((p+l*10+k*100+j*1000+i*10000) >= n))
						{
								ans = p+l*10+k*100+j*1000+i*10000;
								i=11, j=11, k=11,l=11, p=11;
						}
				}
cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
int m,n,order[252];
bool g[255][255]={};//g[a][b]:=a->b
int main()
{
	while(cin>>m&&m){
		fill(g[0], g[255], false);
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>order[i];
			g[i][i]=true;
		}
		g[0][0]=g[n+1][n+1]=true;
		for(int i=0;i<=n;i++){
			for(int j=1;j<=m;j++){
				int tmp=i+j+order[i+j];
				if(tmp<0)tmp=0;
				else if(tmp>n+1)tmp=n+1;
				g[i][tmp]=true;
			}
		}
		for(int k=0;k<=n+1;k++)
			for(int i=0;i<=n+1;i++)
				for(int j=0;j<=n+1;j++)
					if(g[i][k]&&g[k][j])g[i][j]=true;
		bool flg=true;
		for(int i=0;i<=n;i++)if(g[0][i]&&!g[i][n+1])flg=false;
		if(flg)printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        int data;
        int count = 1;

        while(true) {
			data = Integer.parseInt(br.readLine());
			if(data == 0) {
				break;
			}

			sb.append("Case " + count + ": " + data + "\n");
			count++;
        }
        System.out.print(sb);
	}

}

Measured memory_bytes: 31116