akhauriyash/Code-Regression huggingface dataset:
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -10 ** 20
for i in range(1, 2 ** 10):
    cnt = [0] * n
    calc = 0
    for j in range(10):
        if i >> j & 1:
            for k in range(n):
                if f[k][j] == 1:
                    cnt[k] += 1
                
    for k in range(n):
        calc += p[k][cnt[k]] 
    
    ans = max(ans, calc)

print(ans)
            


Measured memory_bytes: 3064
from math import sqrt, floor
N = int(input())

def factorize(n):
    a = []
    count = 0
    temp = n
    if temp % 2 == 0:
        while temp % 2 == 0:
            count += 1
            temp //= 2
        a.append(count)
    for i in range(3,floor(sqrt(n)) + 1,2):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            a.append(count)
    if temp != 1: a.append(1)
    #if a == []: a.append(1)
    return a

ans = 0
for i in factorize(N):
    ans += int((-1 + sqrt(1 + 8 * i)) / 2)
print(ans)


Measured memory_bytes: 63180
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int x[100];
  int y[100];
  int i;
  for(i=0;i<n;i++) scanf("%d%d",x+i,y+i);
  int min=y[0];
  int index=0;
  for(i=1;i<n;i++){
    if(y[i]<min){
      min=y[i];
      index=i;
    }
  }
  if(min<0){
    int add=-min;
    for(i=0;i<n;i++) y[i]+=add;
  }
  int64 s=0;
  for(i=0;i+1<n;i++){
    s+=(x[i+1]-x[i])*(y[i]+y[i+1]);
  }
  s+=(x[0]-x[n-1])*(y[0]+y[n-1]);
  s=ABS(s);
  printf("%lld.%d\n",s/2,(s%2==0?0:5));
  return;
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2044
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <functional>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const double PI = atan2(0, -1);

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
  int a, b, x;
  cin >> a >> b >> x;
  int v = a * a * b;
  double ans, tg;
  if (x * 2 >= v) {
    int delta = v - x;
    tg = (double)2 * delta / (a * a * a);
  } else {
    double c = (double)2 * x / (b * a);
    tg = b / c;
  }
  ans = atan(tg);
  ans *= (double)180 / PI;
  cout << ans << '\n';
}

Measured memory_bytes: 4072
/*
知らなかったこと
"あるグラフが２部グラフであるためには,
グラフに奇数本の辺からなる閉路（奇サイクル）が含まれないことが
必要十分である"

長さ３に着目する理由

二部グラフでは同じグループの頂点間に辺は無い
奇数回の移動では同じグループの頂点にはたどり着けないため,辺が追加されることも無い

二部グラフでないならば, 任意の２頂点の間に奇数長のパスが存在する
・・・グラフが完全グラフになるまで辺を追加する

二部グラフを分けたときに同じグループの頂点同士の距離は必ず偶数になる
*/

// http://ronly.hatenablog.com/entry/2017/10/15/134854

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
using namespace std;

const long long inf = 1e10;
const long long mod = 1e9+7;

using G = vector<vector<int>>;

G graph;

int color[101010];

bool dfs(int v, int c){
    
    color[v] = c;
    
    for (int i = 0; i < graph[v].size(); i++){
        
        if (color[graph[v][i]] == c) return false; // 隣接頂点が同じ色で塗られているため二部グラフではない
        if (color[graph[v][i]] == 0 && !dfs(graph[v][i],-c)) return false; 
        // 隣接頂点が塗られておらず, かつ, その隣接頂点をvと同じ色で塗らなければならないならば, 二部グラフではない
    }
    
    return true;
}


int main(){
    long long n, m;
    cin >> n >> m;
    
    graph = G(n);
    
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        
        x--, y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    
    long long B = 0, W = 0;
    
    if(dfs(0,1)){
        
        for (int i = 0; i < n; i++){
            if (color[i] == 1) B++;
            else W++;
        }
        
        cout << B * W - m << endl;
    }
    else{
        cout << (n * (n-1)) / 2 - m << endl;
    }
}




Measured memory_bytes: 6528
package main

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

var words = []string{"maerd", "remaerd", "esare", "resare"}

func reverseString(s string) string {
	t := make([]byte, len(s))
	for i, b := range []byte(s) {
		t[len(s)-1-i] = b
	}
	return string(t)
}

func main() {
	s := reverseString(readString())

	for {
	next:
		if s == "" {
			fmt.Println("YES")
			return
		}
		for _, w := range words {
			if strings.HasPrefix(s, w) {
				s = s[len(w):]
				goto next
			}
		}
		fmt.Println("NO")
		return
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

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


Measured memory_bytes: 1152
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

flag = True

for x in a:
    if flag:
        b.append(x)
        flag = False
    else:
        b.appendleft(x)
        flag = True
if flag:
    print(*b)
else:
    print(*list(b)[::-1])


Measured memory_bytes: 32480
import java.util.Scanner;

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

        sc.close();

        s = s.substring(0, s.length() - 1);

        boolean flg = true;

        while (flg) {
            String top = s.substring(0, s.length() / 2);
            String bottom = s.substring(s.length() / 2);
            if (top.equals(bottom)) {
                flg = false;
            } else {
                s = s.substring(0, s.length() - 1);
            }
        }

        System.out.println(s.length());

    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define LEN 100005

void insertionsort(int A[],int n){
    int v, i, j, k;

    for(i = 1; i < n; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && v < A[j]){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for(k = 0; k < n - 1;k++){
            printf("%d ", A[k]);
        }
        printf("%d\n", A[k]);
    }
}

int gcd(int x, int y){
    int r;
    while(y > 0){
        r = x % y;
        if(r == 0){
            return y;
        }
        x = y;
        y = r;
    }
    return 1;
}

int  main(void){
    int i, n, x, y;
    int a[100];

    scanf("%d %d", &x, &y);
    /*for(i = 0; i< n; i++){
        scanf("%d", &a[i]);
    }*/
    x = gcd(x, y);
    printf("%d\n", x);
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int sum_ch = 0;
    for(int i = 0; i < N; i++){
        sum_ch += (D-1)/A[i] + 1;
    }

    cout << X + sum_ch << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    bool ok = false;
    for(int i=a; i<=b; i++)
    {
        if(i%k == 0) ok = true;
    }
    if(ok) cout << "OK";
    else cout << "NG";
    return 0;
}

Measured memory_bytes: 3584
N,x = map(int,input().split())
A = list(map(int,input().split()))

ans = A[0]-x if A[0]>x else 0
back = min(A[0],x)
for a in A[1:]:
    if back+a > x:
        ans += back+a-x
        back = x-back
    else:
        back = a
        
print(ans)

Measured memory_bytes: 14132
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n;
	cin >> n;
	int l=n/100;
	int r=n%100;
	if(1<=l && l<=12){
		if(1<=r && r<=12){
			cout << "AMBIGUOUS" << endl;
		} else {
			cout << "MMYY" << endl;
		}
	} else {
		if(1<=r && r<=12){
			cout << "YYMM" << endl;
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char s[5];
	int i,a[26]={0};
	gets(s);
	for(i=0;i<4;i++)
	{
		a[s[i]-'A']++;
	}
	for(i=0;i<26;i++)
	{
		if(a[i]!=2&&a[i]!=0)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto x = RD;
	auto y = RD;
	long[long] g = [1:0, 2:2, 3:0, 4:1, 5:0, 6:1, 7:0, 8:0, 9:1, 10:0, 11:1, 12:0];

	auto ans = g[x] == g[y];

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


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

  cout << z << " " << x << " " << y;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<stack>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
int main() {
	ll N, T;
	cin >> N >> T;
	ll t[N + 1];
	for (ll i = 0; i < N; i++) {
		cin >> t[i];
	}
	ll sum = T;
	for (ll i = 0; i < N - 1; i++) {
		if (t[i + 1] - t[i] >= T)
			sum += T;
		else
			sum += t[i + 1] - t[i];
	}
	cout << sum << endl;
}




Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	n := getNextInt64(scanner)
	x := minint(b-1, n)
	fmt.Fprintln(writer, a*x/b-a*(x/b))
}

func minint(a, b int64) int64 {
	if a < b {
		return a
	}

	return b
}


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

int main() {
  vector <int> so;
  bool s[310000] = {0};

  bool flg;
  for(int i=2;i<300000;i++) {
    if((i % 7 == 1 || i % 7 == 6) && s[i] == 0) {
      so.push_back(i);
      for(int j=2;j*i<=300000;j++) s[i*j] = 1;
    }else s[i] = 1;
  } 
  
  //cout << "ok" << endl;
  
  //  for(int i=2;i<=300000;i++) if(s[i] == 0) cout << i << endl;

  int n;
  while(1) {

    cin >> n;
    if(n == 1) break;

    cout << n << ":";
    for(int i=0;i<so.size();i++) {
      if(n % so[i] == 0) cout <<" "<< so[i];
    }
    cout << endl;

  }
  
  return 0;
  
}

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

int main() {
	vector<vector<int> > matrix;
	vector<int> vec;
	int N,M,ans;
	cin >> N >> M;
	matrix.resize(N);
	for(int i=0;i<N;++i){
		matrix[i].resize(M);
	}
	vec.resize(M);
	for(int i=0;i<N;++i) {
		for(int j=0;j<M;++j) {
			scanf("%d",&matrix[i][j]);
		}
	}
	for(int i=0;i<M;++i) {
		scanf("%d",&vec[i]);
	}
	for(int i=0;i<N;++i) {
		ans=0;
		for(int j=0;j<M;j++) {
			ans+=matrix[i][j]*vec[j];
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

vector<int> eratosthenes(int n)
{
  vector<int> a(n + 1, 1);
  int p = 2;
  while (p <= sqrt(n))
  {
    for(int i = 2; i <= n; i++)
    {
      if(a[i] != 0 && i != p)
      {
        if(i % p == 0)
        {
          a[i] = 0;
        }
      }
    }
    for(int i = p + 1; i <= n; i++)
    {
      if(a[i] != 0)
      {
        p = i;
        break;
      }
    }
  }
  vector<int> result;
  for(int i = 2; i <= n; i++)
  {
    if(a[i] != 0)
    {
      result.push_back(i);
    }
  }
  return result;
}

int main() {
  int n;
  cin >> n;
  vector<int> primes;
  primes = eratosthenes(55555);
  int count = 0;
  for(auto prime : primes)
  {
    if(prime % 5 == 1)
    {
      cout << prime << " ";
      count++;
    }
    if(count == n) break;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll INF = 1LL << 62;
const ll MAXN = 16;

ll N;

ll X[MAXN];
ll Y[MAXN];
ll P[MAXN];

ll CX[MAXN][1 << MAXN];
ll CY[MAXN][1 << MAXN];

ll calcCost(int xmask, int ymask)
{
    ll cost = 0;
    rep (i, N) { cost += min(CX[i][xmask], CY[i][ymask]) * P[i]; }

    return cost;
}

ll dfs(int index, int last, int xmask, int ymask)
{
    if (index + last > N) { return INF; }
    if (index == N || last == 0) { return calcCost(xmask, ymask); }

    const auto a = dfs(index + 1, last, xmask, ymask);
    const auto b = dfs(index + 1, last - 1, xmask | (1<<index), ymask);
    const auto c = dfs(index + 1, last - 1, xmask, ymask | (1<<index));

    return min(a, min(b, c));
}

int main()
{
    cin >> N;
    rep (i, N) { cin >> X[i] >> Y[i] >> P[i]; }


    rep (i, N) rep (j, 1<<N)
    {
        CX[i][j] = abs(X[i]);
        CY[i][j] = abs(Y[i]);

        rep (k, N)
        {
            if ((j>>k)&1) { CX[i][j] = min(CX[i][j], abs(X[i] - X[k])); }
            if ((j>>k)&1) { CY[i][j] = min(CY[i][j], abs(Y[i] - Y[k])); }
        }
    }


    rep (i, N + 1) { cout << max(0LL, dfs(0, i, 0, 0)) << endl; }

    return 0;
}


Measured memory_bytes: 11356
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

signed main()
{
	int t, x;
	cin >> t >> x;


	cout << fixed << setprecision(10);
	cout << t / (double)x << endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
struct Card {
    char suit;
    int number;
    int order;
};
 
int partition(vector<Card>& A, int p, int r)
{
    int x = A[r].number;
    int i = p - 1;
 
    for (int j = p; j < r; ++j)
        if (A[j].number <= x){
            i++;
            swap(A[i],A[j]);
        }
    swap(A[i + 1], A[r]);
    return i + 1;
}
 
void quickSort(vector<Card>& A, int p, int r)
{
    if (p < r)
    {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}
 
int main(){
    int n;
    cin >> n;
 
    vector<Card> A(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> A[i].suit >> A[i].number;
        A[i].order = i;
    }
 
    quickSort(A, 0, n - 1);
 
    bool stable = true;
    for (int i = 0; i < n; ++i)
        if (A[i].number == A[i + 1].number && A[i].order > A[i + 1].order)
            stable = false;
 
    cout << (stable ? "Stable" : "Not stable") << endl;
 
    for (int i = 0; i < n; ++i)
        cout << A[i].suit << " " << A[i].number << endl;
 
    return 0;
}

Measured memory_bytes: 2324
#include<bits/stdc++.h>
using namespace std;
vector<int> c,d;
vector<vector<int>> a;
int n,m,x,sum=0,res=1200001;
int search(int cnt){
  if(cnt>=n) {
    bool solve=true;
    --cnt;
    for(int i=0; i<m; ++i) solve&=(d[i]>=x);
    if(solve==true) return sum; else return res;
  }
  for(int i=0; i<2; ++i){
    if(i==1) {sum+=c[cnt]; for(int j=0; j<m; ++j) d[j]+=a[cnt][j];}
    res=min(res,search(cnt+1));
  }
  for(int i=0; i<m; ++i) d[i]-=a[cnt][i];
  sum-=c[cnt];
  if(cnt==0&&res==1200001) return -1; else return res;
}

int main(void){
  cin>>n>>m>>x;
  c.resize(n); d.resize(m);
  a.resize(n); for(int i=0; i<n; ++i) a[i].resize(m);
  for(int i=0; i<n; ++i){
    cin>>c[i];
    for(int j=0; j<m; ++j) cin>>a[i][j];
  }
  cout<<search(0)<<endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
const ll HMOD = (ll)4222234727;
const ll hashprime = (ll)31;
 
const int maxn = 200005;


int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        if(s.substr(i, 3) == "ABC") ans += 1;
    }
    cout << ans << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
if A[0] > x:
    cnt += (A[0]-x)
    A[0] = x
for i in range(1,N):
    if A[i]+A[i-1] > x:
        cnt += (A[i]+A[i-1]-x)
        A[i] -= (A[i]+A[i-1]-x)
print(cnt)

Measured memory_bytes: 84796
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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 SQ(a) ((a)*(a))
#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 SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
vector<ll> slidingWindow(vector<ll>& a, int K){
  vector<ll> res;

  int n = a.size();
  deque<ll> deq;
  for(int i=0; i<n; i++){
    while(!deq.empty() && a[deq.back()] <= a[i]) deq.pop_back();
    deq.push_back(i);
    
    if(i - K + 1 >= 0){
      res.emplace_back(a[deq.front()]);
      if(deq.front() == i - K + 1) deq.pop_front();
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
 
  int N, M, K; cin >> N >> M >> K;
  vector<ll> A(N);
  vector<ll> dp(N);
  REP(i,N) {
    cin >> A[i];
    dp[i] = A[i];
  }

  for(int i=1; i<K; i++){
    
    vector<ll> dp2(N);

    /* j-M-1~j-1の最大値をみるため0で埋める */
    reverse(all(dp));
    dp.resize(N+M-1);
    reverse(all(dp));

    auto v = slidingWindow(dp, M);
    
    for(int j=i; j<N; j++){
      dp2[j] = max(dp2[j], v[j-1] + 1LL * (i+1) * A[j]);
    }

    REP(i,N) dp[i] = dp2[i];
    dp.resize(N);
  }
  cout << *max_element(all(dp)) << endl;
  return 0;
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h==0&&w==0){
      break;
    }
    rep(i, h){
      rep(j, w){
        if(i==0||i==h-1){
          cout << "#";
        }
        else{
          if(j==0||j==w-1){
            cout << "#";
          }
          else{
            cout << ".";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>


int main() {
  
  int n;
  int S[10000];
  int q;
  int T[500];
  int i, j;
  int count = 0;

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);

  for(i=0; i<q; i++)
    scanf("%d", &T[i]);

  /*Linear search*/
  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }

  printf("%d\n", count);
 
  
  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

int a[100010];

int main(){
    for(int i=1;i<100010;i+=2){
        if(is_prime(i) && is_prime((i+1)/2)) a[i]=1;
    }


    vector<int> sum(100010,0);
    rep(i,100005){
        sum[i+1]=sum[i]+a[i];
    }

    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<sum[r+1]-sum[l]<<endl;
    }

}


Measured memory_bytes: 4020
#include<cstdio>
#include<cstring>

const int Maxv = 300005, Mod = 998244353; 
long long inv[Maxv], fac[Maxv], ans, a, b, n, k, tmp; 

long long Pow(long long c, int d){
    long long res = 1; 
    while (d) {
        if (d & 1) {
            res = res * c % Mod; 
        }
        c = c * c % Mod; 
        d >>= 1; 
    }
    return res; 
}

long long C(long long c, long long d){
    return fac[c] * inv[d] % Mod * inv[c - d] % Mod; 
}

int main(){
    scanf("%lld%lld%lld%lld", &n, &a, &b, &k); 
    fac[0] = inv[0] = 1; 
    for (int i = 1; i < Maxv; i++) {
        fac[i] = fac[i - 1] * i % Mod; 
        inv[i] = Pow(fac[i], Mod - 2); 
    }
    for (int i = 0; i * a <= k && i <= n; i++) {
        tmp = k - i * a; 
        if (tmp % b == 0) {
            tmp /= b; 
            if (tmp <= n) {
                ans = (ans + C(n, i) * C(n, tmp)) % Mod; 
            }
        }
    }
    printf("%lld\n", ans); 
    return 0; 
}

Measured memory_bytes: 4864
import Data.Char
readEnd :: IO String
readEnd = do
  l <- getLine
  if l == "END_OF_TEXT" then return ""
  else do
    ln <- readEnd
    return (l ++ "\n" ++ ln)

main = do
  w <- getLine
  c <- readEnd
  putStrLn . show . length . filter (==w) . words . map toLower $ c

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n; cin>>n;
    vector<lP> schedule;

    rep(i,n){
        ll x,l;
        cin>>x>>l;
        ll pre=x-l;
        ll aft=x+l;
        P robo={aft,pre};
        schedule.push_back(robo);
    }

    sort(schedule.begin(),schedule.end());

    ll ans=0;
    ll t=-INF; //tは最後に選んだ仕事の終了時刻
    rep(i,n){
        if(schedule[i].second>=t){
            ans++;
            t=schedule[i].first;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A, B, answer = 0;
  cin >> N >> A >> B;
  int X[N];
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  for (int i = 1; i < N; i++) {
    answer += min(1ll*A*(X[i]-X[i-1]),B);
  }
  cout << answer;
}


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

int main() {
  ll K, N;
  cin >> K >> N;
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  ll max_d = 0;
  rep(i, N-1){
    max_d = max(max_d, A.at(i+1) - A.at(i));
  }
  cout << K - max(max_d, K-A.at(N-1)+A.at(0)) << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int frag[101];

int main(void)
{
    int n;
    int array[n];
    int ans = 0;

    scanf("%d", &n);

    for(int i=0;i<n;i++){
        scanf("%d", &array[i]);
        frag[array[i]]=1;
    }
    
    for(int i=1;i<=101;i++){
        ans += frag[i];
        
    }

    printf("%d\n", ans);

    return 0;







}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;
const double EPS=1e-9;
inline int sign(double a){return a<-EPS?-1:a>EPS;}
inline int cmp(double a,double b){return sign(a-b);}
//点
struct P{
    double x,y;
    P(){}
    P(double _x,double _y):x(_x),y(_y){}
    P operator + (P p){return P(x+p.x,y+p.y);}
    P operator - (P p){return P(x-p.x,y-p.y);}
    P operator * (double k){return P(x*k,y*k);}
    P operator / (double k){return P(x/k,y/k);}
    double dot(P p){return x*p.x+y*p.y;}
    double det(P p){return x*p.y-y*p.x;}
    double distTo(P p){return (*this-p).abs();}
    double alpha(){return atan2(y,x);}
    void read(){scanf("%lf%lf", &x, &y);}
    void write(){printf("%.10lf %.10lf\n", x, y);}
    double abs(){return sqrt(abs2());}
    double abs2(){return x*x+y*y;}
    P rot90(){return P(-y,x);}
    P unit(){return *this/abs();}
    int quad(){return sign(y)==1||(sign(y)==0&&sign(x)>=0);}
    P rot(double an){return P(x*cos(an)-y*sin(an),x*sin(an)+y*cos(an));}
    bool operator < (P p)const{int c=cmp(x,p.x);if(c)return c==-1;return cmp(y,p.y)==-1;}
    bool operator == (P o)const{return cmp(x,o.x)==0&&cmp(y,o.y)==0;}
};

int main(int argc, char const *argv[])
{
    P p1, p2, p, x;
    p1.read(); p2.read();
    int q;
    scanf("%d", &q);
    while (q--) {
        p.read();
        double k1 = (p-p1).dot(p2-p1);
        double k2 = (p2-p1).abs();
        k1 /= k2;
        x = (p2 - p1) * k1/k2;
        (x+p1).write();
    }
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
using namespace std;

string target,start;
map<string,string> pattern;
set<string> app;

string replaceAll(string s,string f,string t){
  string r;
  for(int pos=0; (pos = s.find(f)) != s.npos; ){
    r+=s.substr(0,pos)+t;
    s = s.substr( pos+f.size() );
  }
  return r+s ;
}

int bfs() {
    queue<pair<string, int> > Q;
    Q.push(make_pair(start,0));
    while(!Q.empty()) {
        string now = Q.front().first;
        int turn = Q.front().second;
        Q.pop();
        if(now.length() > target.length()) continue;
        if(app.find(now) != app.end()) continue;
        app.insert(now);
        //cout<<now<<" turn: "<<turn<<endl;
        if(now == target) return turn;
        for(map<string,string>::iterator it = pattern.begin();
            it != pattern.end(); ++it) {
            string nn = replaceAll(now, (*it).first, (*it).second);
            Q.push(make_pair(nn,turn+1));
        }
    }
    return -1;
}

int main() {
    int n;
    string s,t;
    while(cin>>n, n) {
        pattern.clear();
        app.clear();
        for(int i=0; i<n; ++i) {
            cin>>s>>t;
            pattern[s] = t;
        }
        cin>>start;
        cin>>target;
        cout<<bfs()<<endl;
    }
}

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


int main()
{
    int n = 0;
    cin >> n;
    int r_min = 2e9;
    int dif = -2e9;
    for (int i = 0; i != n; ++i){
        int r = 0;
        cin >> r;
        if (r - r_min > dif) dif = r - r_min;
        if (r < r_min) r_min = r;
    }
    cout << dif << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        for (int j = i + 1; j < s.size(); j++) {
            if (s[i] > s[j]) {
                char k = s[j];
                s[j] = s[i];
                s[i] = k;
            }
        }
    }
    for (int i = 0; i < t.size(); i++) {
        for (int j = i + 1; j < t.size(); j++) {
            if (t[i] < t[j]) {
                char l = t[j];
                t[j] = t[i];
                t[i] = l;
            }
        }
    }
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;

int N, K, Q;

int main() {
	cin >> N >> K >> Q;
	vector <int> b(N, -Q+K);
	int temp;
	for (int i = 0; i < Q; i++) {
		cin >> temp;
		b[temp-1]++;
	}
	for (int i = 0; i < N; i++) {
		if (b[i] > 0) {
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
    }
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f;
}
char s[200005],t[200005];
int tot,sum[100005];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='x') t[++tot]=s[i];
		else sum[tot]++;
	}
	for(int i=1;i<=tot;i++)
	{
		if(t[i]!=t[tot-i+1])
		{
			puts("-1");
			return 0;
		}
	}
	int ans=0;
	for(int i=0;i<=tot;i++)
	{
		ans+=abs(sum[i]-sum[tot-i]);
		if(sum[i]<sum[tot-i])
		sum[i]=sum[tot-i];
		else sum[tot-i]=sum[i];
	}
	cout<<ans;
}


Measured memory_bytes: 896
def main():
    _ = input()
    li = list(map(int, input().split()))

    cnt = 0
    while True:
        if 1 in [x % 2 for x in li]:
            break
        else:
            cnt += 1
            li = [x // 2 for x in li]
    print(cnt)


if __name__ == '__main__':
    main()


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

const int msize = 2e6;
int n, a[msize];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);	cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    for (char c = getchar(); isdigit(c); c = getchar()) a[n++] = c - '0';
    int ans = n;
    for (int i = 1; i < n; ++i)
        if (a[i] != a[i - 1]) ans = min(ans, max(i, n - i));
    cout << ans;
}



Measured memory_bytes: 1024
A,B,K = map(int,input().split())
ans = []
for i in range(A,A+K):
  if i <= B:
    ans.append(i)
#print(ans)
for j in range(B,B-K,-1):
  #print("j",j)
  if j >= A+K:
    ans.append(j)
ans.sort()
for k in ans:
  print(k)


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	searchFavoriteFood(n, m)
}

func searchFavoriteFood(n, m int) {
	kindlist := make([]int, m)
	for i := 0; i < n; i++ {
		var favoriteNum int
		fmt.Scan(&favoriteNum)
		for j := 0; j < favoriteNum; j++ {
			var tmp int
			fmt.Scan(&tmp)
			kindlist[tmp-1]++
		}
	}

	cnt := 0
	for i := 0; i < m; i++ {
		if kindlist[i] == n {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }




int N, T;

signed main() {
	int arr[5], k;
	cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4] >> k;

	bool ans = false;
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (abs(arr[i] - arr[j]) > k) {
				ans = true;
			}
		}
	}
	if (ans) {
		cout << ":(\n";
	}
	else {
		cout << "Yay!\n";
	}


	return 0;
}

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

int main(){
  string s; cin>>s;
  int n=s.size();
  vector<vector<long long>> ans(n+1,vector<long long>(13,0));
  ans[0][0]=1;
  for(int i=0;i<n;i++){
    if(s[i]=='?'){
      for(int k=0;k<13;k++){
        for(int j=0;j<10;j++){
          ans[i+1][(k*10+j)%13]+=ans[i][k];
        }
      }
    }else{
      for(int k=0;k<13;k++){
        ans[i+1][(10*k+(s[i]-'0'))%13]+=ans[i][k];
      }
    }
    for(int k=0;k<13;k++){
      ans[i+1][k]%=1000000007;
    }
  }
  cout<<ans[n][5]<<endl;
}   

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

int main()
{
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int lsum = 0, lmax = 0, diff;
	for (int i = 0; i < n; i++) {
		if (i < n - 1)
			diff = a[i+1] - a[i];
		else
			diff = a[0]+k - a[n-1];
		lmax = max(lmax, diff);
		lsum += diff;
	}
	lsum -= lmax;
	cout << lsum << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;
    bool ok = true;
    if (b - a > k) ok = false;
    if (c - a > k) ok = false;
    if (d - a > k) ok = false;
    if (e - a > k) ok = false;
    if (c - b > k) ok = false;
    if (d - b > k) ok = false;
    if (e - b > k) ok = false;
    if (d - c > k) ok = false;
    if (e - c > k) ok = false;
    if (e - d > k) ok = false;

    if (ok) std::cout << "Yay!" << std::endl;
    else std::cout << ":(" << std::endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int a, b; cin >> a >> b;
    int now = b-a;

    int tmp = now;
    int ans = 0;
    FOR(i, 1, now) {
        ans += i;
    }

    ans -= a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    if(a > 0) cout << "Positive" << endl;
    else if(b >= 0) cout << "Zero" << endl;
    else if((b - a) % 2 == 1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

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

int main() {
    vector<int> a(3);
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a.begin(), a.end());
    printf("%d\n", a[2]*10 + a[0] + a[1]);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int R,C,v[22][22][19][5],dy[]={0,0,-1,1},dx[]={-1,1,0,0},a;
char c[22][22];

void f(int y,int x,int m,int d){
	if(v[y][x][m][d])return;
	v[y][x][m][d]=1;
	if(c[y][x]=='<')d=0;
	if(c[y][x]=='>')d=1;
	if(c[y][x]=='^')d=2;
	if(c[y][x]=='v')d=3;
	if(c[y][x]=='_')d=!m;
	if(c[y][x]=='|')d=!m+2;
	if(isdigit(c[y][x]))m=c[y][x]-'0';
	if(c[y][x]=='+')m=(m+1)%16;
	if(c[y][x]=='-')m=(m+15)%16;
	if(c[y][x]=='@')a=1;
	f((y+dy[d]+R)%R,(x+dx[d]+C)%C,m,d);
	if(c[y][x]=='?')rep(i,4)f((y+dy[i]+R)%R,(x+dx[i]+C)%C,m,i);
}

int main(){
	cin>>R>>C;
	rep(i,R)cin>>c[i];
	f(0,0,0,1);
	cout<<(a?"YES":"NO")<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
vector <int> adj[100005];


int main()
{
    int n;
    cin>>n;
    
    int a[n][3];
    for (int i = 0; i<n; i++)
        for (int j = 0; j<3; j++)
            cin>>a[i][j];
        
    int dp[n][3];
    memset (dp, 0, sizeof(dp));
            
    for (int j = 0; j<3; j++)
        dp[0][j] = a[0][j];
        
    for (int i = 1; i<n; i++)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2])+a[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1])+a[i][2];
        //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]));
    
    return 0;
}


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int ll

void do_it(vector<int> &v,int n){
    int g=v[0];
    for(int i=1;i<n;i++){
        g=__gcd(g,v[i]);
    }
    if(g==1){
        cout<<"setwise coprime\n";
    }else{
        cout<<"not coprime\n";
    }
}

void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    unordered_set<int> st;
    for(auto &x:v)cin>>x;
    for(auto x:v){
        int num=x;
        if(num%2==0){
            if(st.count(2)){
                do_it(v,n);
                return;
            }
            st.insert(2);
        }
        while(num%2==0){
            num/=2;
        }
        // deb(num);
        for(int i=3;i*i<=num;i+=2){
            if(num%i==0){
                // deb(i);
                if(st.count(i)){
                    do_it(v,n);
                    return;
                }
                while(num%i==0)num/=i;
            }
        }
        if(num>2){
            // deb(n);
            if(st.count(num)){
                do_it(v,n);
                return;
            }
            st.insert(num);
        }
    }
    cout<<"pairwise coprime\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans;
int main () {
	
	cin>>n>>m>>k;
	for (int i=0; i<=n; i++) {
		for (int j=0; j<=m; j++) {
			if (k==j*n+i*m-i*j*2) return 0*printf("Yes\n");
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;
typedef pair<pii, int> EDGE;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a != b && b != c && a != c) cout << 3 << endl;
	else if ((a == b && a != c)||(b==c&&a!=b) ||(c==a&&a!=b)) cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256