akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<utility>
#include<cstdlib>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int ,int> P;
typedef pair<P, int> PP;

const int NUM = 1 << 18;

vector<int> prv[NUM];
vector<int> nxt[NUM];

int le[NUM];
int ri[NUM];

int ans[NUM];
int N;
int M;

int in[NUM];

void input(){
	scanf("%d", &N);
	M = 1 << N;
	for(int i = 0; i < M; ++i){
		scanf("%d", in + i);
	}
}

void no(){
	printf("NO\n");
	exit(0);
}

vector<P> ps[NUM];

int rev(int x){
	int ans = 0;
	for(int i = 0; i < N; ++i){
		if((x >> i) & 1){
			ans += (1 << (N - i - 1));
		}
	}
	return ans;
}

void solve(){
	for(int i = 0; i < M; ++i){
		if(in[i] == 0){
			int id = rev(i);
			le[id] = 0;
			ri[id] = (1 << N) - 1;
		}else{
			int id = rev(i);
			le[id] = in[i] - 1;
			ri[id] = in[i] - 1;
		//	printf("%d %d\n", id, in[i] - 1);
		}
	}
	for(int i = 0; i < M; ++i){
		for(int j = 0; j < N; ++j){
			int x = i ^ (1 << j);
			if(x < i){
				prv[i].push_back(x);
			}else{
				nxt[i].push_back(x);
			}
		}
	}
	for(int i = 0; i < M; ++i){
		for(int j = 0; j < prv[i].size(); ++j){
			le[i] = max(le[i], le[prv[i][j]] + 1);
		}
	}
	for(int i = M - 1; i >= 0; --i){
		for(int j = 0; j < nxt[i].size(); ++j){
			ri[i] = min(ri[i], ri[nxt[i][j]] - 1);
		}
	}
	for(int i = 0; i < M; ++i){
		//printf("%d %d %d\n", le[i], ri[i], i);
		if(le[i] < 0 || ri[i] >= M || le[i] > ri[i]){
			no();
		}
	}
	for(int i = 0; i < M; ++i){
		ps[le[i]].push_back(P(ri[i], i));
	}
	priority_queue<P, vector<P>, greater<P> > que;
	for(int i = 0; i < M; ++i){
		for(int j = 0; j < ps[i].size(); ++j){
			que.push(ps[i][j]);
		}
		P p = que.top();
		que.pop();
		//printf("%d %d %d\n", i, p.first, p.second);
		if(p.first < i) no();
		ans[p.second] = i;
//		ans[i] = p.second;
	}
	/*
	for(int i = 0; i < NUM; ++i){
		pps[i] = PP(P(le[i], ri[i]), i);
	}
	sort(pps, pps + M);
	int cur = 0;
	for(int i = 0; i < M; ++i){
		int l = pps[i].first.first;
		int r = pps[i].first.second;
		int id = pps[i].second;
		if(cur < l || r < cur) no();
		ans[id] = cur;
		cur++;
	}*/
	printf("YES\n");
	for(int i = 0; i < M; ++i){
		printf("%d%c", ans[i] + 1, i + 1 == M ? '\n' : ' ');
	}
}

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


Measured memory_bytes: 66688
input_list = list(map(int, input().split()))
num_f = input_list[0]
num_s = input_list[1]
f_str = str(num_f) * num_s
s_str = str(num_s) * num_f
list_ans = [f_str, s_str]
print(sorted(list_ans)[0])

Measured memory_bytes: 2940
n, m = map(int, input().split())
a = []

for i in range(n):
    a.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)



Measured memory_bytes: 6016
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N,T;
  cin >> N >> T;
  int c[N],t[N];
  for(int i = 0; i < N; i++){
    cin >> c[i] >> t[i];
  }

  int Ans = 1010;

  for(int i = 0; i < N; i++){
    if(t[i] <= T) Ans = min(Ans,c[i]);
  }

  if(Ans == 1010) printf("TLE\n");
  else printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>


using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

ll gcd(ll a, ll b){

    if(a < b){
        ll temp = a;
        a = b;
        b = temp;
    }

	if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}

ll cnt(ll a, ll b, ll coeff){

    ll min_c = a / coeff;
    if(a % coeff != 0) min_c += 1;

    if(DEBAG){
        cout << "min_c " << min_c * coeff << endl; 
    }
    if(min_c * coeff > b) return 0;


    return (b - min_c * coeff) / coeff + 1;
}


int main(){

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll gcdcd = C * D / gcd(C, D) ;
    ll all_count =  B - A + 1;
    ll c = cnt(A, B, C);
    ll d = cnt(A, B, D);
    ll cd = cnt(A, B, gcdcd);
    if(DEBAG){
        cout << all_count << endl;
        cout << c << endl;
        cout << d << endl;
        cout << cd << endl;
    }
    cout << all_count - c - d + cd << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuples (x : y : _) = [(x, y), (y,x)]

main = do
    [n, m] <- getIntList
    edges <- sort . concatMap toTuples <$> replicateM m getIntList
    let nodes = map (map snd) $ groupBy (\a b -> fst a == fst b) edges
    print $ solve nodes n

solve nodes n = dfs 1 1 [1]
    where dfs node depth visited
              | depth == n = 1
              | null nexts = 0
              | otherwise = sum $ map (\w -> dfs w (depth+1) (w : visited)) nexts
            where nexts = filter (`notElem` visited) (nodes !! (node - 1))

Measured memory_bytes: 1020
n = int(input())
s_lst, s_dic_lst = [], []
min_idx = 51

for i in range(n):
    s_in = input()
    s_dic = {chr(j):0 for j in range(ord('a'), ord('a')+26)}

    if len(s_in) < min_idx:
        min_idx = i

    for j in s_in:
        s_dic[j] += 1

    s_dic_lst.append(s_dic)

min_dic = s_dic_lst[min_idx]

for i in range(n):
    if i != min_idx:
        for key in min_dic:
            if min_dic[key] > s_dic_lst[i][key]:
                min_dic[key] = s_dic_lst[i][key]

ans_lst = []

for key in min_dic:
    for j in range(min_dic[key]):
        ans_lst.append(key)

ans_lst.sort()

print("".join(ans_lst))


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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];
    int mn = (n != 1 ? pow(10, n - 1) : 0), mx = pow(10, n);
    if(m == 0) {
        cout << mn << endl;
        return 0;
    }
    FOR(i, mn, mx) {
        rep(j, m) {
            int x = (i / (int)pow(10, n - s[j])) % 10;
            if(x != c[j]) break;
            if(j == m - 1) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
# ABC138 D - Ki
from collections import deque
N,Q = map(int, input().split())
G = [[] for _ in range(N)]

c = [0]*N

for i in range(N-1):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    c[p-1] += x

q = deque([0])
flg = [False]*N

while q:
    v = q.pop()
    flg[v] = True
    for e in G[v]:
        if flg[e]:
            continue
        c[e] += c[v]
        q.append(e)
print(*c)


Measured memory_bytes: 56084
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    string s;
    cin >> s;
    ll q;
    cin >> q;
    rep(i,q){
        string op;
        cin >> op;
        if(op == "replace"){
            ll a,b;
            string p;
            cin >> a >> b >> p;
            s.replace(a,b-a+1,p);
        }
        else if(op == "reverse"){
            ll a,b;
            cin >> a >> b;
            rep(j,(b-a+1)/2){
                char t=s.at(a+j);
                s.at(a+j) = s.at(b-j);
                s.at(b-j) = t;
            }
        }
        else{
            ll a,b;
            cin >> a >> b;
            cout << s.substr(a,b-a+1) << endl;
        }
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci S(N);
    int sum = 0;
    REP(i,N) {
        cin >> S[i];
        sum += S[i];
    }
    sort(S.begin(),S.end());
    if(sum%10 != 0) {
        cout << sum << endl;
        return 0;
    }
    REP(i,N) {
        if(S[i]%10 == 0) continue;
        else {
            cout << sum-S[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int max(int m1,int m2){
    return m1<m2?m2:m1;
}

int main(){
    int t1,t2,sum,a,i,j;
    for(;scanf("%d %d %d",&t1,&t2,&sum),sum;){
        static int A[10000];
        for(j=0;j<1001;j++)A[j]=0;
        int m=0;
        for(i=1;i<sum;i++){
            a=i*(100+t1)/100;
            A[a]=i;
        }
        for(i=1;i<sum;i++){
            if(A[i]==0&&A[sum-i]==0)continue;
            m=max(A[i]*(100+t2)/100+A[sum-i]*(100+t2)/100,m);
        }
        printf("%d\n",m);
    }
    return 0;
}

Measured memory_bytes: 608
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = nextInt(sc)
	}

	m, g, cnt := shellSort(a, n)
	fmt.Println(m)
	fmt.Println(strings.Trim(fmt.Sprint(g), "[]"))
	fmt.Println(cnt)
	for i := int64(0); i < n; i++ {
		fmt.Println(a[i])
	}
}

func shellSort(a []int64, n int64) (int64, []int64, int64) {
	var cnt int64
	m, g := calcM(n)
	for i := int64(0); i < m; i++ {
		cnt = insertionSort(a, n, g[i], cnt)
	}
	return m, g, cnt
}

func insertionSort(a []int64, n int64, g int64, cnt int64) int64 {
	for i := g; i <= n-1; i++ {
		v := a[i]
		j := i - g
		for j >= 0 && a[j] > v {
			a[j+g] = a[j]
			j = j - g
			cnt++
		}
		a[j+g] = v
	}
	return cnt
}

func calcM(n int64) (int64, []int64) {
	if n == 1 {
		return 1, []int64{0}
	}
	var cnt int64
	c := int64(1)
	var g []int64
	for c < n {
		g = append(g, c)
		c = c*3 + 1
		cnt++
	}
	for i := len(g)/2 - 1; i >= 0; i-- {
		opp := len(g) - 1 - i
		g[i], g[opp] = g[opp], g[i]
	}
	return cnt, g
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 17496
dict={}
N = int(input())
for _ in range(N):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 1

max_ = max(dict.values())
A = [k for k,v in dict.items() if v == max_]
A.sort()

for a in A:
    print(a)

Measured memory_bytes: 35336
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int ddx[] = {0,-1,-1,0,1,1};
const int ddy[] = {1,0,-1,-1,0,1};

typedef pair<pair<int,int>,int>  qp;

int &qy(qp &q){
    return q.first.first;
}
int &qx(qp &q){
    return q.first.second;
}
int &qd(qp &q){
    return q.second;
}

qp make_qp(int y,int x,int depth){
    return mp(mp(y,x),depth);
}

int main(){
    while(true){
        const int width = 200;
        const int height = 200;
        const char got = 'o',emp = '.',obj = 'x';
        vector<vector<char> > F(height,vector<char>(width,emp));
        int t,n;
        cin >> t >> n;
        if(t==0) break;
        rep(i,n){
            int x,y;
            cin >> x >> y;
            x+=width/2;y+=height/2;
            F[y][x] = obj;
        }
        int sx,sy;
        cin >> sx >> sy;
        sx+=width/2;sy+=height/2;

        queue<qp> Q;
        F[sy][sx] = got;
        Q.push(make_qp(sy,sx,0));

        while(!Q.empty()){
            qp q = Q.front();
            Q.pop();
            if(qd(q) == t) continue;
            rep(i,6){
                int ny = qy(q) + ddy[i];
                int nx = qx(q) + ddx[i];
                if(F[ny][nx] == emp){
                    F[ny][nx] = got;
                    Q.push(make_qp(ny,nx,qd(q)+1));
                }
            }
        }
        int cnt = 0;
        rep(i,height) rep(j,width){
            if(F[i][j] == got){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

using namespace std;

int n;

int main() {
	scanf("%d", &n);
	if (n < 1200)
		printf("ABC\n");
	else if (n < 2800)
		printf("ARC\n");
	else
		printf("AGC\n");
	return 0;
}


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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

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

  vector<int> nums = {a, b, c};
  sort(nums.begin(), nums.end());

  rep (i, nums.size()) nums[i] -= nums[2];

  // nums[0] == nums[1] を作るために必要な最小操作数
  int ans = 0;
  ans += ((nums[1] - nums[0]) / 2) + ((nums[1] - nums[0]) % 2);

  // 2つ選んで1を足す
  ans += nums[2] - nums[1];

  if (nums[0] % 2 != nums[1] % 2) ans++;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
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;}


signed main(){
	int aa,bb,a,b;
	cin>>aa>>bb>>a>>b;
	if(a==-1||b==-1){
		if(aa==bb)cout<<"Draw"<<endl;
		else if(aa<bb)cout<<"Alice"<<endl;
		else cout<<"Bob"<<endl;
	}else if(a==b)cout<<"Draw"<<endl;
	else{
		if(a>b)cout<<"Alice"<<endl;
		else cout<<"Bob"<<endl;
	}
}



Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.Stack;


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

		while(true){
			
			int N = sc.nextInt();
			int M = sc.nextInt();
			if(N == 0 && M == 0){
				break;
			}
			int r = sc.nextInt();
			int[][] log = new int[4][r]; 
			for(int i = 0; i < r; i++){
				for(int j = 0; j < 4; j++){
					log[j][i] = sc.nextInt();
				}
			}
			int q = sc.nextInt();
			int[][] question = new int[3][q];
			for(int i = 0; i < q; i++){
				for(int j = 0; j < 3; j++){
					question[j][i] = sc.nextInt();
				}
			}
			
			for(int i = 0; i < q; i++){
				Stack<Integer> stack = new Stack<Integer>();
				int sum = 0;
				for(int j = 0; j < r; j++){
					if(question[1][i] < log[0][j] && !stack.empty()){
						if(question[0][i] > log[0][j -1]){
							sum = sum + question[1][i] - question[0][i];
							break;
						}else if(question[1][i] > log[0][j - 1]){
							sum = sum + question[1][i] - log[0][j - 1];
							break;	
						}else{
							break;
						}
					}
					if(question[0][i] < log[0][j] && !stack.empty()){
						if(question[0][i] > log[0][j -1]){
							sum = sum + log[0][j] - question[0][i];
						}else{
							sum = sum + log[0][j] - log[0][j - 1];
						}
					}
					if(question[2][i] == log[2][j] && log[3][j] == 1){
						stack.push(0);
					}
					if(question[2][i] == log[2][j] && log[3][j] == 0){
						stack.pop();
					}
				}
				System.out.println(sum);
				
			}
		}
		
	}

}

Measured memory_bytes: 13000
use proconio::input;

fn main() {
    input!(n: usize, mut a:[i64; n]);
    for i in 0..n {
        a[i] -= i as i64;
    }
    a.sort();
    let med = a[n / 2];
    println!("{}", a.iter().map(|&x| (x - med).abs()).sum::<i64>());
}


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

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(d <= t*s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a, b;
		String op;

		
		
		do{
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();
		if(0<=a && a <= 20000 && 0<=b && b <= 20000){
			if( op.equals("+")){
				System.out.println(a+b);
			}else if( op.equals("-")){
				System.out.println(a-b);
			}else if(op.equals("*")){
				System.out.println(a*b);
			}else if(op.equals("/") && b != 0){
				System.out.println(a/b);
			}else if(op.equals("?")){
				break;
			}
		}
		
		}while(true);
		
		}
		



		}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> A(n);

    vector<int> d(k);
    for (int j = 0; j < k; j++)
    {
        cin >> d[j];
        vector<int> a(d[j]);
        for (int i = 0; i < d[j]; i++)
        {
            cin >> a[i];
            A[a[i]-1]++;
        }
    }


    int count=0;
    for(int i=0; i<n; i++){
        if(A[i]==0){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	if n%2 == 0 {
		fmt.Println(n / 2)
	} else {
		fmt.Println(n/2 + 1)
	}
}


Measured memory_bytes: 640
S = input()
nr = 0
nl = 0
prev = 'R'
s = ''
for c in S:
    if c == 'R':
        if prev == 'R':
            nr += 1
        else:
            s += '0 ' * (nr - 1)
            s += str((nr + 1) // 2 + nl // 2) + ' '
            s += str(nr // 2 + (nl + 1) // 2) + ' '
            s += '0 ' * (nl - 1)
            nr = 1
            nl = 0
            prev = 'R'
    else:
        if prev == 'R':
            prev = 'L'
        nl += 1
s += '0 ' * (nr - 1)
s += str((nr + 1) // 2 + nl // 2) + ' '
s += str(nr // 2 + (nl + 1) // 2) + ' '
s += '0 ' * (nl - 1)
print(s[:-1] + '\n')

Measured memory_bytes: 4072
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main(){
int n;cin>>n;
map<int,pair<int,int>> m;
//m[0].first=m[0].second=0;
for(int i=0;i<n;i++){
    int a;cin>>a;
    cin>>m[a].first;
    cin>>m[a].second;
}
for(auto it=m.begin();it!=m.end();it++){
    if((it->first-it->second.first-it->second.second)%2||it->first<it->second.first+it->second.second){
        cout<<"No";return 0;
    }
}
cout<<"Yes";
}


Measured memory_bytes: 6528
import sys

N = int(input())

scores = []
sum_score = 0
for _ in range(N):
    s = int(input())
    scores.append(s)
    sum_score += s

if sum_score % 10 != 0:
    print(sum_score)
    sys.exit(0)

tmp_max = 0
for s in scores:
    tmp = sum_score - s
    if tmp % 10 == 0:
        tmp = 0
    if tmp > tmp_max:
        tmp_max = tmp

print(tmp_max)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	ll Q;
	cin >> N >> Q;
	cin >> S;
	vl sum(N+1);
	sum[0] = 0;
	for (i = 0; i < N-1; i++) {
		if (S.substr(i, 2) == "AC") {
			sum[i + 1] = sum[i] + 1;
		}
		else {
			sum[i + 1] = sum[i];
		}
	}
	for (k = 0; k < Q; k++) {
		ll l, r;
		cin >> l >> r;
		cout << sum[r - 1] - sum[l - 1] << endl;
	}
}


Measured memory_bytes: 1792
N, A, B = map(int, input().split())

num_sum = 0
for i in range(N+1):
    res = 0
    num = i
    while num > 0:
        q, mod = divmod(num, 10)
        res += mod
        num = q
    if (res >= A) and (res <= B):
        num_sum += i

print(num_sum)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2;
    cin>>s1>>s2;
    ll ans = 0;
    FOR(i,0,3){
        if(s1[i] == s2[i])ans++;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int height[10];
    for(int i = 0; i < 10; i++) cin >> height[i];

    int tmp;
    for(int i = 0; i < 10; i++) {
        for(int j = 9; j > i; j--) {
            if(height[j] < height[j-1]) {
                tmp = height[j];
                height[j] = height[j-1];
                height[j-1] = tmp;
            }
        }
    }

    cout << height[9] << endl;
    cout << height[8] << endl;
    cout << height[7] << endl;
    
    return 0;
}

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

int N, K;
vector<int> d;
vector<vector<int>> A;

void input(){
 
  cin >> N >> K;
  d.resize(K);
  A.resize(K, vector<int>());
  for(int i = 0; i < K; i++){
    cin >> d[i];
    A[i].resize(d[i]);
    for(int j = 0; j < d[i]; j++){
      cin >> A[i][j];
    }
  }
}

void solve(){
  int sum  = 0;
  for(int i = 1; i <= N; i++){
    bool have = false;
    for(auto v : A){
      for(auto p : v){
        if(p == i) have = true;
      }
    }
    if(!have) sum++;
  }
  cout << sum << endl;
}

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

Measured memory_bytes: 3648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	while (1) {
		int x, y, z; cin >> x >> y >> z;

		if (x == -1 && y == -1 && z == -1)break;

		char ans;
		if (x != -1 && y != -1) {
			if (x + y >= 80) ans = 'A';
			if (x + y < 80 && x + y >= 65)ans = 'B';
			if (x + y < 65 && x + y >= 50)ans = 'C';
			if (x + y < 50 && x + y >= 30) {
				if (z >= 50) {
					ans = 'C';
				}
				else {
					ans = 'D';
				}
			}

			if (x + y < 30)ans = 'F';
		}
		else {
			ans = 'F';
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll d = c-a-b;
    if (d>=0 && d*d>4*a*b) puts("Yes"); 
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;
/*
int n,m;
int h[10000];
ul t[10000];

ul dp(int p){
	if(t[p]!=-1)return t[p];
	ul res = 0;
	if(p==n-1){res=0;}
	else if(p==n-2){res = abs(h[n-1]-h[n-2]);}
	else {res=min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]));}
	return t[p]=res;
}*/

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
	cin>>n;
	vector<int> h(n);
	rep(i, n){
		cin>>h[i];
		//t[i] = -1;
	}
	vector<int> tab(n-1);
	//tab[n-1] = 0;
	tab[n-2] = abs(h[n-1]-h[n-2]);
	for(int i = n-3;i>=0;i--){
		tab[i] = min(tab[i+1]+abs(h[i]-h[i+1]), tab[i+2]+abs(h[i]-h[i+2]));
	}
	//rep(i, n)cerr<<tab[i]<<endl;
	cout << tab[0] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n,y;

	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			int k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
		
	}


	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()


## 分断する位置についてのループ
cnt = 0
for n in range(1,N):
  before = A[:n]
  after = A[n:]
  
  ## 一致する文字数のカウント

  _cnt = []
  for bef in before:
    if bef in after:
      _cnt.append(bef)
      
  cnt = max(cnt,len(set(_cnt)))

print(cnt)

Measured memory_bytes: 3060
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int S = s.length();
		int T = t.length();

		int[][] dp = new int[S+1][T+1];
		for (int i=1;i<S+1;i++) {
			for (int j=1;j<T+1;j++) {
				if (s.charAt(i-1)==(t.charAt(j-1))) {
					dp[i][j]=Math.max(dp[i-1][j-1]+1,dp[i][j-1]);
					dp[i][j]=Math.max(dp[i][j],dp[i-1][j]);
				}else {
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}

		String str = "";
		int i = S;
		int j = T;
		while  (i>0&&j>0) {
			if (dp[i][j]==dp[i-1][j]) {
				i--;
			}else if (dp[i][j]==dp[i][j-1]) {
				j--;
			}else {
				str = t.charAt(j-1)+str;
				i--;
				j--;
			}
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 85892
def main():
    N = int(input())

    # K > 1

    def divisor_set(x):
        ret = set()
        if x > 1:
            ret.add(x)

        d = 2
        while d * d <= x:
            if x % d == 0:
                ret.add(d)
                ret.add(x // d)
            d += 1
        return ret

    # N % K == 1
    # (N-1) % K == 0
    # K > 1

    ans = 0
    ans += len(divisor_set(N - 1))

    # N % K == 0
    # N //= K ---> M
    # (M-1) % K == 0

    for k in divisor_set(N):
        x = N
        while x % k == 0:
            x //= k
        if x % k == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){//ntってなに？？現在地？
	for( int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v]) return v;
	}
	return -1;
}

void dfs_visit(int r) {
	for ( int i =0; i<n;i++) nt[i] = 0;

	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;

	while( !S.empty() ) {
		int u = S.top();
		int v = next(u);
		if(v != -1){
			if (color[v] == WHITE) {
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}else {
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}

void dfs() {
	for (int i = 0; i<n;i++) {
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 0;

	for(int u = 0; u<n;u++) {
		if(color[u] == WHITE) dfs_visit(u);
	}
	for ( int i =0; i<n ;i++) {
		cout << i+1 << " " << d[i] << " " << f[i] << endl;
	}
}

int main(){
	int u, k, v;

	cin >> n;
	for (int i =0; i<n;i++){
		for (int j =0;j<n;j++)M[i][j] = 0;
	}

	for (int i =0;i<n;i++){
		cin >> u >> k;
		u--;
		for ( int j = 0; j < k;j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}

	}

	dfs();
	return 0;
}



Measured memory_bytes: 3136
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    vector<int> ans(q);

    bool prime[100100];
    for(int i = 0; i <= 100000; i++) prime[i] = true;

    prime[0] = false;
    prime[1] = false;

    for(int i = 2; i * i <= 100000; i++){
        if(prime[i]){
            for(int j = 2; i * j <= 100000; j++){
                prime[i * j] = false;
            }
        }
    }

    ll sum[100100] = {0};

    for(int i = 1; i <= 100000; i++){
        if(prime[i]){
            if((i + 1) % 2 == 0 && prime[(i + 1) / 2] == true){
            sum[i] = sum[i - 1] + 1;
            } else {
                sum[i] = sum[i - 1];
            }
        } else {
            sum[i] = sum[i - 1];
        }
    }

    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        ans[i] = sum[r] - sum[l - 1];
    }

    for(int i = 0; i < q; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1920
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

r,d,x=mp()
for i in range(10):
    x=r*x-d
    print(x)

Measured memory_bytes: 77184
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	ar := make([][]int, h)
	for i := range ar {
		ar[i] = make([]int, w)
		for j := range ar[i] {
			fmt.Scan(&ar[i][j])
		}
	}
	ans := make([]string, 0, h*w)
	for i := 0; i < h; i++ {
		for j := 0; j < w-1; j++ {
			if ar[i][j]%2 == 1 {
				ar[i][j+1]++
				ans = append(ans, fmt.Sprintf("%d %d %d %d", i+1, j+1, i+1, j+2))
			}
		}
	}
	for i := 0; i < h-1; i++ {
		if ar[i][w-1]%2 == 1 {
			ar[i+1][w-1]++
			ans = append(ans, fmt.Sprintf("%d %d %d %d", i+1, w, i+2, w))
		}
	}
	fmt.Println(len(ans))
	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 13696
#include<iostream>
#include<cstring>
using namespace std;
char map[8][8];

bool check(int x,int y){
    int dx[]={-1, -1, -1, 1, 1, 1, 0, 0};
    int dy[]={ 0, 1, -1, 0, 1, -1, 1, -1};
    for(int i=0;i<8;i++){
        for(int j=1;;j++){
            int new_x=x+dx[i]*j;
            int new_y=y+dy[i]*j;
            if(new_x<0 || new_y<0 || new_x>=8 || new_y>=8)
                break;
            if(map[new_x][new_y]=='Q')
                return false;
        }
    }
    return true;
}
void dfs(int row){
    if(row>=8){
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++)
                cout<<map[i][j];
            cout<<endl;
        }
        return;
    }
    for(int i = 0; i < 8; i++)
        if(map[row][i] == 'Q'){
           dfs(row + 1);
           return;
        }
             
    for(int col=0;col<8;col++){
        if(check(row,col)){
            map[row][col]='Q';
            dfs(row+1);
            map[row][col]='.';
        }
    }
}
int main(){

    int n,x,y;cin>>n;
    for(int i=0;i<8;i++)
        for(int j=0;j<8;j++)
            map[i][j]='.';
    while(n--){
        cin>>x>>y;
        map[x][y]='Q';
    }
    dfs(0);
    
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int a,b;
    cin>>a>>b;
    int x=(int)ceil((double)(a)*12.5);
    chmax(x,(int)ceil((double)(b)*10));
    if(x>=(a+1)*12.5)cout<<-1<<endl;
    else if(x>=(int)((b+1)*10))cout<<-1<<endl;
    else cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int dp[S+5];
int n,m;
bool mark[S+5];

int Solve(int i)
{
    if(i==n)return 1;
    if(dp[i]!=-1)return dp[i];
    int sum=0;
    if(!mark[i+1] && i+1<=n)sum=Solve(i+1);
    if(!mark[i+2] && i+2<=n)sum+=Solve(i+2);
    return dp[i]=sum%mod;
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    while(cin>>n>>m)
    {
        memset(mark,false,sizeof mark);
        for(int i=0;i<m;i++)
        {
            int x;
            cin>>x;
            mark[x]=true;
        }
        memset(dp,-1,sizeof dp);
        cout<<Solve(0)<<endl;
    }
    return 0;
}
 









 




























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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N,M;
int d[410],cnt[410];
int x[22];
set<vector<int> > res;

void dfs(int l,int r){
  //dbg(l); dbg(r);
  //rep(i,10)dbg(cnt[i]);
  if(l+1>=r){
    vector<int> tmp;
    rep(j,N-1)tmp.push_back(x[j+1]-x[j]);
    res.insert(tmp); return ;
  }
  int mx=-1;
  rep(i,401)if(cnt[i]>0)maxch(mx,i);
  if(mx==-1)return ;
  //dbg(mx);

  // left
  x[r-1]=x[0]+mx;
  bool ok=true;
  vector<int> sav;
  repl(i,r,N){
    int crtd=x[i]-x[r-1];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  repl(i,0,l+1){
    int crtd=x[r-1]-x[i];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  if(ok)dfs(l,r-1);
  rep(i,sav.size())cnt[sav[i]]++;

  // left
  x[r-1]=x[N-1]-mx;
  ok=true;
  sav.clear();
  repl(i,r,N){
    int crtd=x[i]-x[r-1];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  repl(i,0,l+1){
    int crtd=x[r-1]-x[i];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  if(ok)dfs(l,r-1);
  rep(i,sav.size())cnt[sav[i]]++;

  // right
  x[l+1]=x[N-1]-mx;
  ok=true;
  sav.clear();
  repl(i,0,l+1){
    int crtd=x[l+1]-x[i];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  repl(i,r,N){
    int crtd=x[i]-x[l+1];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  if(ok)dfs(l+1,r);
  rep(i,sav.size())cnt[sav[i]]++;

  // right
  x[l+1]=mx-x[0];
  ok=true;
  sav.clear();
  repl(i,0,l+1){
    int crtd=x[l+1]-x[i];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  repl(i,r,N){
    int crtd=x[i]-x[l+1];
    if(crtd<0||cnt[crtd]==0){
      ok=false; break;
    }
    cnt[crtd]--;
    sav.push_back(crtd);
  }
  if(ok)dfs(l+1,r);
  rep(i,sav.size())cnt[sav[i]]++;

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    cin>>N;
    if(N==0)break;
    int mx=0;
    M=N*(N-1)/2;
    memset(cnt,0,sizeof(cnt));
    rep(i,M){
      cin>>d[i];
      cnt[d[i]]++;
    }
    sort(d,d+M);
    x[0]=0;
    x[N-1]=d[M-1]; cnt[d[M-1]]--; M--;
    res.clear();
    dfs(0,N-1);
    for(vector<int> ans : res){
      cout<<ans[0];
      repl(j,1,ans.size())cout<<" "<<ans[j];
      cout<<endl;
    }
    cout<<"-----"<<endl;
  }
  return 0;
}



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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int X = cin.nextInt();
        int Y = cin.nextInt();
        int Z = cin.nextInt();


        int max = 0;
        while(true) {
            int tmp = max * Y + Z * (max + 1);
            if (tmp > X) {
                Console.WriteLine(max -1);
                return;
            }
            max ++;
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

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

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


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

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

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  cout<<ceil((a+b)/2.0)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 string t;
 cin>>t;
 ll n=t.length();
 ll l=0,r=n-1,ans=0;
 while(l<r){
 //cout<<l<<" "<<r<<" "<<t[l]<<" "<<t[r]<<endl;
 if(t[l]==t[r]){
   l++;
   r--;
  }
 else if(t[r]=='x'){
   ans++;
   r--;
  }
  else if(t[l]=='x'){
   ans++;
   l++;
  }
  else{
   puts("-1");
   return 0;
  }
 }
 pr(ans);
return 0;}


Measured memory_bytes: 3760
import numpy as np
x = int(input())
a = np.arange(14)+1

a = np.where((a%3)*(a%5)<1, 0, a)

b = sum(a>0)
q = x//15
print(q*60+ b*15*q*(q-1)//2+  + sum(a[:x%15]) + 15*q*sum(a[:x%15] > 0))

Measured memory_bytes: 27288