akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] c = new String[]{
				"100101","10011010","0101","0001","110",
				"01001","10011011","010000","0111","10011000",
				"0110","00100","10011001","10011110","00101",
				"111","10011111","1000","00110","00111",
				"10011100","10011101","000010","10010010","10010011","10010000"
		};
		
		
		while(sc.hasNext()){
			StringBuffer sb = new StringBuffer();
			StringBuffer ans = new StringBuffer();
			String s = sc.nextLine();
			
			int p, q;
			for(int i=0;i<s.length();i++){
				p = s.codePointAt(i);
				if(p>=65 && p<=90) sb.append(c[p-65]);
				else if(p==32) sb.append("101");
				else if(p==39) sb.append("000000");
				else if(p==44) sb.append("000011");
				else if(p==45) sb.append("10010001");
				else if(p==46) sb.append("010001");
				else if(p==63) sb.append("000001");
			}
			
			p = sb.length()%5;
			if(p!=0){
				for(int i=0;i<5-p;i++) sb.append("0");
			}
			
			for(int i=0;i<sb.length();i+=5){
				p = 0;
				q = 16;
				for(int j=0;j<5;j++){
					p += (sb.codePointAt(i+j)-48)*q;
					q /= 2;
				}
				if(p<=25) ans.append((char)(p+65));
				else if(p==26) ans.append(" ");
				else if(p==27) ans.append(".");
				else if(p==28) ans.append(",");
				else if(p==29) ans.append("-");
				else if(p==30) ans.append("'");
				else if(p==31) ans.append("?");
			}
	
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 27436
package main

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

const MAX_N = 100010

type key struct {
	a, b int
}

var edges [MAX_N][]int
var cost map[key]int
var N, Q, K int
var result map[key]int64

func dfs(pos, pre int, sum int64) {
	result[key{K, pos}] = sum
	result[key{pos, K}] = sum
	for _, next := range edges[pos] {
		if next == pre {
			continue
		}
		dfs(next, pos, sum+int64(cost[key{pos, next}]))
	}

}
func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	cost = make(map[key]int)
	result = make(map[key]int64)
	for i := 0; i < N-1; i++ {
		a, b, c := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
		a--
		b--
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
		cost[key{a, b}] = c
		cost[key{b, a}] = c
	}
	Q, K = fsc.NextInt(), fsc.NextInt()
	K--
	dfs(K, -1, 0)
	for i := 0; i < Q; i++ {
		a, b := fsc.NextInt(), fsc.NextInt()
		a--
		b--
		fmt.Println(result[key{a, K}] + result[key{K, b}])
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 60032
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n;
	cin >> n;
	vector<tuple<string, int, int>> r(n);
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		r[i] = make_tuple(s, -p, i + 1);
	}

	sort(r.begin(), r.end());
	for (int i = 0; i < n; i++) {
		cout << get<2>(r[i]) << endl;
	}
}


Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string inp;
	getline(cin, inp);
	replace(ALL(inp), ',', ' ');
	replace(ALL(inp), '.', ' ');
	stringstream ss(inp);
	vector<string>words;
	string s; while (ss >> s) if (3 <= s.length() && s.length() <= 6)words.push_back(s);
	auto itr = unique(ALL(words));
	REP(i, itr - words.begin()) {
		if (i != 0)cout << ' ';
		cout << words[i];
	}
	cout << endl;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll d, g, p[11], c[11];
	cin >> d >> g;
	ll ans = 1e9;
	for (int i = 0; i < d; i++)cin >> p[i] >> c[i];
	for (int i = 0; i < (1 << d); i++) {
		ll cnt = 0, num = 0;
		for (int j = 0; j < d; j++) {
			if (i&(1 << j)) {
				cnt += (j + 1) * 100 * p[j] + c[j];
				num += p[j];
			}
		}
		if (cnt >= g)ans = min(ans, num);
		else {
			ll yan = g - cnt;
			for (int j = 0; j < d; j++) {
				if (!(i&(1 << j))) {
					ll yojo = (yan + (j + 1) * 100 - 1) / ((j + 1) * 100);
					if (yojo < p[j])ans = min(ans, num + yojo);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    s=STR()
    if '7' in s:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 9060
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){

  int n;
  int MS[15][15];

  while( cin >> n ){
    if( n == 0 ) break;

    for( int i = 0 ; i < 15 ; i++ ){
      for( int j = 0 ; j < 15 ; j++ ){
	MS[i][j] = 0;
      }
    }

    MS[n/2+1][n/2] = 1;
    int i,j;
    i = n/2+1;
    j = n/2;

    for( int N = 2 ; N <= n*n ; N++ ){
      i++;
      j++;
      if( i >= n ){
	i = 0;
      }
      if( j >= n ){
	j = 0;
      }
      if( MS[i][j] > 0 ){
	i++;
	j--;
	if( j < 0 ){
	  j = n - 1;
	}
	if( i >= n ){
	  i = 0;
	}
      }
      MS[i][j] = N;
    }

    for( int i = 0 ; i < n ; i++ ){
      for( int j = 0 ; j < n ; j++ ){
	printf("%4d",MS[i][j]);
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val S = N.toString.map(_ - '0').toArray
    val n = S.length

    def set(f: Int, b: Boolean) = f | (if (b) 1 else 0)

    def cnt(k: Int, f3: Int, f5: Int, f7: Int, less: Int, zero: Int): Int = {
      if (k == n)
        f3 & f5 & f7
      else {
        var res = 0
        Seq(3, 5, 7).foreach { d =>
          if (less == 1 || S(k) >= d) {
            res += cnt(k + 1, set(f3, d == 3), set(f5, d == 5), set(f7, d == 7), set(less, d < S(k)), 0)
          }
        }
        if (zero == 1) res += cnt(k + 1, f3, f5, f7, 1, 1)
        res
      }
    }

    val ans = cnt(0, 0, 0, 0, 0, 1)
    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 35188
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
a = [0] + a
c = 0
for i in range(n):
    t = a[i] - a[i + 1]
    if t > 0:
        a[i + 1] += t
        c += t
print(c)

Measured memory_bytes: 98836
//O(1)
#include <iostream>
using namespace std;

int main() {
	long long int X, A, B;
	cin >> X >> A >> B;
	if (A - B >= 0) cout << "delicious" << endl;
	else if ((A - B) * -1 <= X) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <sstream>

class schedule_element {
public:
    schedule_element()
        : _name(), _time()
    {}

    schedule_element(const std::string& name, std::size_t time)
        : _name(name), _time(time)
    {
    }

    std::size_t process(std::size_t q)
    {
        if (q >= _time) {
            const std::size_t time = _time;
            _time = 0;
            return time;
        }

        _time -= q;
        return q;
    }

    const std::string& name() const 
    {
        return _name;
    }

    bool is_finish() const
    {
        return _time == 0;
    }

private:
    std::string _name;
    std::size_t _time;
};

class round_robin_schedule {
public:
    round_robin_schedule(int n)
        : _schedules(new schedule_element[n]),
        _n(n),
        _head(0),
        _tail(0)
    {}

    ~round_robin_schedule()
    {
        delete[] _schedules;
    }

    void enqueue(const schedule_element& schedule)
    {
        _schedules[_tail] = schedule;
        increment(_tail, _n);
    }

    void enqueue(const std::string& name, std::size_t time)
    {
        this->enqueue(schedule_element(name, time));
    }

    schedule_element dequeue()
    {
        schedule_element tmp = _schedules[_head];
        increment(_head, _n);
        return tmp;
    }

    bool is_empty() const
    {
        return _head == _tail;
    }
    
private:
    static void increment(int& idx, const int n)
    {
        ++idx;
        if (idx == n) {
            idx = 0;
        }
    }

private:
    schedule_element* _schedules;
    int _n;
    int _head;
    int _tail;
};

void process(
    round_robin_schedule& schedules,
    std::size_t q,
    std::size_t sum)
{
    if (schedules.is_empty()) {
        return;
    }

    auto schedule = schedules.dequeue();
    sum += schedule.process(q);
    if (schedule.is_finish()) {
        std::cout << schedule.name() << " " << sum << std::endl;
    }
    else {
        schedules.enqueue(schedule);
    }

    process(schedules, q, sum);
    return;
}

void process(
    round_robin_schedule& schedules,
    std::size_t q)
{
    process(schedules, q, 0);
    return;
}

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

    std::string buf;

    getline(std::cin, buf);
    const int n
        = std::stoi(buf.substr(0, buf.find(' ')));
    const std::size_t q
        = std::stoi(buf.substr(buf.find(' ') + 1, buf.size()));

    round_robin_schedule schedules(n + 1);
    for (int i = 0; i < n; ++i) {
        getline(std::cin, buf);
        schedules.enqueue(
            buf.substr(0, buf.find(' ')),
            std::stoi(buf.substr(buf.find(' ') + 1, buf.size())));
    }
    process(schedules, q);

    return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n;
    cin >> n;
    ll a[n];
    fo(i, n){
        ll b, c;
        cin >> b >> c;
        if(b == c){
            a[i] = 1;
        }
        else a[i] = 0;
    }
    fo(i, n - 2){
        if(a[i] && a[i + 1] && a[i + 2]){
            Yes;
            return;
        }
    }
    No;
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long l = a[0];
            for(int i = 1; i < n; i++)
            {
                l = Lcm(l, a[i]);
            }
            var ans =(double)l/(double)a.Select(x => l / x).Sum();
            Console.WriteLine(ans);
        }
        static long Gcd(long a, long b)
        {
            return (a < b) ? Gcd(b, a)
                 : (b > 0) ? Gcd(b, a % b)
                           : a;
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }

    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <stdio.h>

constexpr unsigned int mod = 1'000'000'007;
unsigned long long int power(unsigned long long int&& a, unsigned int n){
    unsigned long long int res = 1;
    while(n){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

unsigned int A[100001];

int main(void){
    unsigned int n, k; scanf("%u%u", &n, &k);
    unsigned long long res = 0;
    for(unsigned int i = 1; i <= k; ++i){
        const unsigned int t = i - A[i];
        (res += t * power(k / i, n)) %= mod;
        for(unsigned int j = i << 1; j <= k; j += i) A[j] +=  t;
    }
    printf("%llu\n", res);
    return 0;
}

Measured memory_bytes: 3608
from functools import lru_cache

MOD = 10 ** 9 + 7

s = input()
s = s[::-1]
dp0 = [0] * len(s)
dp1 = [0] * len(s)  # smaller
if s[0] == "0":
    dp1[0] = 1
else:
    dp1[0] = 3
dp0[0] = 3

for i in range(1, len(s)):
    if s[i] == "1":
        dp1[i] = dp0[i-1] + dp1[i-1] * 2
    else:
        dp1[i] = dp1[i-1]
    dp0[i] = dp0[i-1] * 3

    dp0[i] %= MOD
    dp1[i] %= MOD

print(dp1[-1])


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(all(A), greater<int>());

    vector<vector<ll>> dp(N + 1, vector<ll>(1e5 + 1));
    const int mod = 1e9 + 7;
    dp[0][X] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 1e5 + 1; j++) {
            dp[i + 1][j % A[i]] += dp[i][j];
            dp[i + 1][j % A[i]] %= mod;
            dp[i + 1][j] += dp[i][j] * (N - i - 1);
            dp[i + 1][j] %= mod;
        }
    }

    ll ans = 0;
    for (ll j = 0; j < 1e5 + 1; j++) {
        ans += dp[N][j] * j;
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 158592
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const int MAX_V=10;
int d[MAX_V][MAX_V];
int V;
void wf(){
    REP(k,V)REP(i,V)REP(j,V){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
}
int main(){
    V=10;
    int h,w;
    cin>>h>>w;
    REP(i,10){
        REP(j,10){
            int c;
            cin>>c;
            d[i][j]=c;
        }
    }
    wf();
    int ans=0;
    REP(i,h){
        REP(j,w){
            int t;
            cin>>t;
            if(t==-1)continue;
            ans+=d[t][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	int v[n],a[n],b[n];
	vector<pii> even,odd;
	map<int,int> mpe,mpo;
	for(int i=0;i<n;i+=2){
		cin>>v[i];cin>>v[i+1];
		if(mpe.find(v[i])!=mpe.end())mpe[v[i]]++;
		else mpe[v[i]]=1;
		if(mpo.find(v[i+1])!=mpo.end())mpo[v[i+1]]++;
		else mpo[v[i+1]]=1;
	}
	for(map<int,int>::iterator ite=mpe.begin();ite!=mpe.end();ite++){
		even.pb(pii(ite->second,ite->first));
	}
	for(map<int,int>::iterator ite=mpo.begin();ite!=mpo.end();ite++){
		odd.pb(pii(ite->second,ite->first));
	}
	sort(all(even));
	sort(all(odd));
	bool flg=false;
	if(even[even.size()-1].second!=odd[odd.size()-1].second){
		for(int i=0;i<n;i+=2){
			a[i]=even[even.size()-1].second;
			a[i+1]=odd[odd.size()-1].second;
		}
	}else{
		flg=true;
		for(int i=0;i<n;i+=2){
			a[i]=even[even.size()-1].second;
			a[i+1]=odd[odd.size()-2].second;
			b[i]=even[even.size()-2].second;
			b[i+1]=odd[odd.size()-1].second;
		}
	}
	if(!flg){
		int cnt=0;
		rep(i,n)if(v[i]!=a[i])cnt++;
		cout<<cnt<<endl;
	}else{
		int cnt1,cnt2;
		cnt1=cnt2=0;
		rep(i,n){
			if(v[i]!=a[i])cnt1++;
			if(v[i]!=b[i])cnt2++;
		}
		cout<<min(cnt1,cnt2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 6908
let cnt = ref 0

let merge a l m r =
  let init_ary n p = Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i)) in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let rec doit = function
    | (_, _, k) when k = r -> ()
    | (i, j, k) ->
      incr cnt;
      if ai.(i) <= aj.(j) then begin
        a.(k) <- ai.(i);
        doit (i + 1, j, k + 1)
      end else begin
        a.(k) <- aj.(j);
        doit (i, j + 1, k + 1)
      end in
  doit (0, 0, l)

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Array.iteri (fun i e -> if i <> 0 then print_string " "; print_int e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 19472
#include<bits/stdc++.h>
#define to first
#define wgt second 

using namespace std;

const int MAXN=1010;

typedef pair<int,int> pii;
typedef vector<pii> vec;
typedef vector<vec> Graph;

Graph G(MAXN);
int n,d[MAXN],times[MAXN];
bool negative_cycle; 

void SPFA(int s)
{
	queue<int> que;
	negative_cycle=false;
	memset(times,0,sizeof(times));
	fill(d,d+n,INT_MAX);
	d[s]=0;
	times[s]=1;
	que.push(s);
	while(!que.empty())
	{
		int u=que.front();que.pop();
		for(int i=0;i<G[u].size();i++)
			if(d[G[u][i].to]>d[u]+G[u][i].wgt)
			{
				d[G[u][i].to]=d[u]+G[u][i].wgt;
				que.push(G[u][i].to);
				times[G[u][i].to]++;
				if(times[G[u][i].to]>n)
				{
					negative_cycle=true;
					while(que.empty()) que.pop();
					return ;
				}
			}
	}
}

int main()
{
	int e,r;
	scanf("%d%d%d",&n,&e,&r);
	for(int i=0;i<e;i++)
	{
		int s,t,d;
		scanf("%d%d%d",&s,&t,&d);
		G[s].push_back(make_pair(t,d));
	}
	SPFA(r);
	if(negative_cycle)
		printf("NEGATIVE CYCLE\n");
	else
		for(int i=0;i<n;i++)
			if(d[i]==INT_MAX)
				printf("INF\n");
			else
				printf("%d\n",d[i]);
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if (K <= A) {
    cout << K << endl;
    return;
    }
    if ( K <= (A+B)) {
        cout << A << endl;
        return;
    }
    ll o = K-A-B;
    cout << A-o << endl;

}


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


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(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

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	int a, b, x;

	cin >> a >> b >> x;

	if (a <= x&&x <= a + b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=50000;
bitset<M> tmp[M],zen;
int n,m,type;
vp a;
string s;

int main(){
	cin>>n>>m>>type;
	a=vp(m);
	s=string(m,'^');
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		a[i]={u-1,v-1};
	}
	if(type==1){
		for(int i=0;i<n;i++) tmp[i][i]=zen[i]=true;
		for(int i=m-1;i>=0;i--){
			int u=a[i].first,v=a[i].second;
			tmp[u]|=tmp[v];
			tmp[v]|=tmp[u];
		}
		int v=-1;
		for(int i=0;i<n;i++) zen&=tmp[i];
		for(int i=0;i<n;i++) if(zen[i]) v=i;
		if(v==-1){
			cout<<-1<<endl;
			return 0;
		}
		vi b(n);
		b[v]++;
		for(int i=m-1;i>=0;i--){
			int u=a[i].first,v=a[i].second;
			if(b[v]) s[i]='v';
			if(b[u]||b[v]) b[u]=b[v]=1;
		}
		cout<<s<<endl;
		return 0;
	}
	if(n==2){
		cout<<-1<<endl;
		return 0;
	}
	vi b;
	for(int i=0;i<m;i++){
		int u=a[i].first,v=a[i].second;
		if(v<3) b.push_back(i);
	}
	if(b.empty()){
		cout<<s<<endl;
		return 0;
	}
	int sz=b.size(),x=0,y=1;
	if(a[b[0]].second==1) y=2;
	for(int i=0;i<sz-1;i++){
		int u=a[b[i]].first,v=a[b[i]].second;
		int u_=a[b[i+1]].first,v_=a[b[i+1]].second;
		if(y==u||y==v) swap(x,y);
		if(a[b[i]]==a[b[i+1]]){
			if(x==v) x=u;
		}
		else{
			if(u==u_||u==v_) s[b[i]]='v';
			if(s[b[i]]=='^'){
				if(x==v) x=u;
			}
			else{
				if(x==u) x=v;
			}
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 306944
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
x  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

sum_ = 0
for i in range(x+1):
    sum_ += i

    if sum_ >= x:
        print(i)
        break


Measured memory_bytes: 38512
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll C[200010];
P cpair;
ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    cin>>N;
	for(ll i=0;i<N;i++){
		cin>>C[i];
	}
	sort(C,C+N);
	ll ans=0;
	for(ll i=0;i<N;i++){
		ll u=N-1-i;
		ll tmp=u*modpow(2,u-1,MOD)%MOD;
		tmp=(tmp+modpow(2,u,MOD))%MOD;
		tmp=(tmp*C[i]%MOD*modpow(2,i,MOD))%MOD;
		ans=(ans+tmp)%MOD;
	}
	cout<<ans*modpow(2,N,MOD)%MOD;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int H, W, N;
    cin >> H >> W >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    int res = 0;
    int count = 0;
    while(N > 0) {
        if (H>=W) {
            N -= H;
        } else {
            N -= W;
        }
        ++count;
    }
    cout << count << endl;
    return 0;
}

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

struct grid {
    ll x;
    ll y;
};
void main_()
{
    ll N;
    cin >> N;
    vector<grid> balls;
    map<pair<ll, ll>, bool> balls_set;
    for (ll i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        balls.push_back({ x, y });
        balls_set.emplace(make_pair(x, y), false);
    }

    if (N == 1) {
        cout << 1 << endl;
        return;
    }

    set<pair<ll, ll>> balls_diff;
    for (ll i = 0; i < N - 1; ++i) {
        for (ll j = i + 1; j < N; ++j) {
            ll diff_x = balls[i].x - balls[j].x;
            ll diff_y = balls[i].y - balls[j].y;
            balls_diff.emplace(diff_x, diff_y);
            balls_diff.emplace(-diff_x, -diff_y);
        }
    }

    ll ans = 1e9 + 7;
    for (auto&& bd : balls_diff) {
        auto bs_w = balls_set;
        ll cost = 0;
        for (auto&& bs : bs_w) {
            if (bs.second) {
                continue;
            }
            bs.second = true;
            ll nx = bs.first.first + bd.first;
            ll ny = bs.first.second + bd.second;
            decltype(begin(bs_w)) it;
            while ((it = bs_w.find(make_pair(nx, ny))) != end(bs_w)) {
                it->second = true;
                nx += bd.first;
                ny += bd.second;
            }
            nx = bs.first.first - bd.first;
            ny = bs.first.second - bd.second;
            while ((it = bs_w.find(make_pair(nx, ny))) != end(bs_w)) {
                it->second = true;
                nx -= bd.first;
                ny -= bd.second;
            }
            cost++;
        }
        ans = min(cost, ans);
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        String str = sc.next();

        if(str.equals("ABC")){
            System.out.println("ARC");
        }
        else{
            System.out.println("ABC");
        }
    }
}

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO;

	string s, t;
	cin >> s >> t;
	
	int cnt = 0;
	
	for (int i = 0; i< (int) s.size() - (int)t.size()+1; ++i) {
		int cur = 0;
		string a = s.substr(i, (int) t.size());
		//cout << a << endl;
		for (int j = 0; j < (int) t.size(); ++j) {
			if (a[j] == t[j]) {
				++cur;
				//cout << a[j] << endl;
			}
		}
		//cout <<  a << " " << cur << endl;
		cnt = max(cnt, cur);
	}
	
	cout << (t.size()-cnt);
	
}
/*
	int tt;
	cin >> tt;
	while (tt--){
		
	}	
*/


Measured memory_bytes: 3604
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100001
memo[0] = 1
memo[1] = 1
def stairs(x):
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)


Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans = "";
  for (int i = 0; i < 2 * N; i++) {
    if (i % 2 == 0) {
      ans += S.at(i / 2);
    }
    else {
      ans += T.at(i / 2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//21-03-2K20

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305
int main()
{
    fastio;
    int n,i,sum;
    cin>>n;
    int b[n-1];

    for(i=0;i<n-1;i++)
        cin>>b[i];
    sum=b[0];

    for(i=0;i<n-2;i++)
        sum+=min(b[i],b[i+1]);

    sum+=b[n-2];

    cout<<sum<<"\n";    //:D
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, x; cin >> N >> x;
    if(x == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }

    if(N == 2){
        cout << "Yes" << endl;
        for(int i=1; i<=3; ++i) cout << i << endl;
        return 0;
    }

    vector<int> ans(2*N-1);
    if(x == 2){
        ans[N-2] = x+1;
        ans[N-1] = x;
        ans[N]   = x-1;
        ans[N+1] = x+2;
        int id = 1;
        for(int i=0; i<N-2; ++i){
            if(id == x-1) id = x+3;
            ans[i] = id++;
        }
        for(int i=N+2; i<2*N-1; ++i){
            if(id == x-1) id = x+3;
            ans[i] = id++;
        }
    }
    else {
        ans[N-2] = x-1;
        ans[N-1] = x;
        ans[N]   = x+1;
        ans[N+1] = x-2;
        int id = 1;
        for(int i=0; i<N-2; ++i){
            if(id == x-2) id = x+2;
            ans[i] = id++;
        }
        for(int i=N+2; i<2*N-1; ++i){
            if(id == x-2) id = x+2;
            ans[i] = id++;
        }
    }

    cout << "Yes" << endl;
    for(int i=0; i<2*N-1; ++i) cout << ans[i] << endl;
}

Measured memory_bytes: 2304
/*************************************************************************
  >         File: A.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 24 Sep 2016 08:02:17 PM CST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  std::string s;
  std::cin >> s;
  std::cout << s.substr(0, 4) + " " + s.substr(4) << std::endl;


  return 0;
}


Measured memory_bytes: 256
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
//#define F(i,n) for(ll i=0;i<n;i++)
//#define MOD 1000000007
#define MAX 200005
#define LM LLONG_MAX
#define sz size()
//#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
		const ll N=1e5;
		ll i,j,k;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
/* void DFS(ll x,ll col)
{
    cnt[col]++;
    visited[x]=col+1;
    
    for(auto p:v[x])
    {
        if(visited[p]==0)
        {
            DFS(p,col^1);
        }
        else if(visited[x]==visited[p])
        {
            ok=true;
        }
        
    }
}*/
 
void solve()
{
;
	ll s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe";
	else cout<<"safe";
	
}

int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3640
import java.util.*;

public class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int result = 0;
    int cnt = 0;
    
    ArrayList<Integer> bndList = new ArrayList<Integer>();
    
    for(int i = 0; i<=n; i++){
      	if(i != 0){
        int l = sc.nextInt();
      	result = result + l;
        }
      	bndList.add(result);
    }
    
    for (int i=0; i<bndList.size(); ++i){
      int z = bndList.get(i);
      if(z <= x){
        cnt++;
      }
    }
    System.out.println(cnt);  
  }
 }


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

class ScoreBoard{
public:
    //  1: win
    // -1: lose
    // enum
    vector<vector<int>> board;
    vector<int> wincounts;
    
    ScoreBoard(int N){
        board = vector<vector<int>>(N, vector<int>(N));
        wincounts.resize(N);
    }
    void update(int x, int y){
        board[x][y] = 1;
        board[y][x] = -1;
        wincounts[x]++;
    }
    void remove(int x, int y){
        board[x][y] = board[y][x] = 0;
        wincounts[x]--;
    }
    bool allok(){
        for(int i=0; i<board.size(); i++)
            if(wincounts[i] > (board.size()-1)/2)
                return false;
        return true;
    }
    bool ok(int x, int y){
        return wincounts[x] < (board.size()-1)/2;
    }
    void view(){
        cout << "============" << endl;
        for(int x=0; x<board.size(); x++){
            for(int y=0; y<board.size(); y++){
                if(x == y)
                    cout << ". ";
                else
                    cout << (board[x][y]==1) << " ";
            }
            cout << endl;
        }
    }
    int dfs(vector<int> &X, vector<int> &Y, int idx){
        if(X.size() == idx){
//            view();
            return 1;
        }
        
        int res = 0;
        if(ok(X[idx], Y[idx])){
            update(X[idx], Y[idx]);
            res += dfs(X, Y, idx+1);
            remove(X[idx], Y[idx]);
        }
        if(ok(Y[idx], X[idx])){
            update(Y[idx], X[idx]);
            res += dfs(X, Y, idx+1);
            remove(Y[idx], X[idx]);
        }
        return res;
    }
};


int main(){
    int N, M;
    while(cin >> N, N){
        cin >> M;
        auto sb = ScoreBoard(N);
        
        for(int i=0; i<M; i++){
            int x, y; cin >> x >> y;
            x--; y--;
            sb.update(x, y);
        }
        
        vector<int> X, Y;
        for(int x=0; x<N; x++){
            for(int y=x+1; y<N; y++){
                if(sb.board[x][y] != 0)
                    continue;
                X.push_back(x);
                Y.push_back(y);
            }
        }
        if(sb.allok())
            cout << sb.dfs(X, Y, 0) << endl;
        else
            cout << 0 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e7+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }

void solve() {
    int k;
    string s;
    cin>>k;
    cin>>s;
    int len=sz(s);    
    if(len<=k) cout<<s<<endl;
    else {
		    int yo=len-k;
		    string p="";
		    rep(i,0,k)
		     p+=s[i];
		    p+="...";
		     
		     cout<<p<<endl; 
		}
    				   
 }

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


Measured memory_bytes: 3676
import math
while True:
    n = int(input())
    if n == 0 :
        break
    sum = []
    for i in range(n):
        x = int(input())
        sum.append(x)
    sum.sort()
    del sum[n-1]
    del sum[0]
    rsum = 0
    for i in range(n-2):
        rsum = rsum + sum[i]
    average = rsum/(n-2)
    result = math.floor(average)
    print(result)
    


Measured memory_bytes: 5664
import bisect
x = int(input())
def primes(n):
  is_prime = [True] * (n + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(n**0.5) + 1):
    if not is_prime[i]:
      continue
    for j in range(i * 2, n + 1, i):
      is_prime[j] = False
  return [i for i in range(n + 1) if is_prime[i]]

prime_list = primes(x+500)
index = bisect.bisect_left(prime_list,x)
print(prime_list[index])


Measured memory_bytes: 39664
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;

    std::set<int> s;
    for (int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;
        s.insert(tmp);
    }

    std::cout << s.size() << std::endl;
}

Measured memory_bytes: 256
W,H = (int(num) for num in input().split())
p = [int(input()) for _ in range(W)]
p.sort()
q = [int(input()) for _ in range(H)]
q.sort()
p_cnt = H+1 #何本取るか
q_cnt = W+1
gr_cnt = (W+1) * (H+1) - 1
p_idx = 0
q_idx = 0
ans = 0

while gr_cnt > 0:
    if (p_idx < W and q_idx < H and p[p_idx] <= q[q_idx]) or q_idx >= H:
        nt = min(p_cnt,gr_cnt)
        #print(gr_cnt,nt,p[p_idx])
        ans += p[p_idx] * nt
        gr_cnt -= nt
        q_cnt -= 1
        p_idx += 1
    elif (p_idx < W and q_idx < H and p[p_idx] > q[q_idx]) or p_idx >= W:
        nt = min(q_cnt,gr_cnt)
        #print(gr_cnt,nt,q[q_idx])
        ans += q[q_idx] * nt
        gr_cnt -= nt
        p_cnt -= 1
        q_idx += 1
    
        
print(ans)

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

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

int main() {
  int a;
  cin>>a;
  if(a%10==3){
    cout<<"bon"<<endl;
  }else if(a%10==0||a%10==1||a%10==6||a%10==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef long long ll;

ll gcd(ll a,ll b){
  return b == 0 ? a : gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a/gcd(a,b) * b;
}
/*
 */
ll compute(ll a,ll b,ll x,ll y){
  ll l = lcm(a*x,b*y);
  return l/a + l/b;
}

const int N = 110;
int node[N][2];
int p[N][2];
int w[N];

ll solve(int now){
  
  ll t[2];
  rep(i,2){
    if (node[now][i] != 0)t[i]=solve(node[now][i]-1);
    else t[i] = 1;
  }
  w[now] = compute(p[now][0],p[now][1],t[0],t[1]);
  return w[now];
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n){
      w[i] = -1;
      cin>>p[i][0]>>p[i][1];
      cin>>node[i][0]>>node[i][1];
    }
    rep(i,n){
      if (w[i] == -1)solve(i);
    }
    cout << *max_element(w,w+n) << endl;
  }
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

bool used[30];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  vector<string> st;
  REP(i, s.size()) {
    REP(j, 26) {
      if(!used[j] && s[i]-'a' < j) {
        string t = s.substr(0, i) + (char)('a'+j);
        st.PB(t);
        break;
      }
    }
    used[s[i]-'a'] = true;
  }
  REP(j, 26) {
    if(!used[j]) {
      string t = s + (char)('a'+j);
      st.PB(t);
      break;
    }
  }

  sort(ALL(st));
  if(st.size() == 0) cout << -1 << endl;
  else cout << st[0] << endl;

  return 0;
}

Measured memory_bytes: 256