akhauriyash/Code-Regression huggingface dataset:
a= [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
#define MAX 10000000

int top;
int S[MAX];

void initialize(){
        top = 0;
    }

bool isEmpty(){
    return top==0;
} 
bool isFull(){
    return top >= MAX-1;
}
void push(int x){
    if(isFull()) return;
    top++;
    S[top] = x;
}
int pop(){
    if(isEmpty()) return -1;
    top--;
    return S[top+1];
}

int main(){
    int x;
    string s; 

    initialize();
    while((cin >> s)){
        if(cin.eof()) break;
        if(s == "+"){
            int b = pop();
            int a = pop();
            push(a+b);
        }
        else if(s == "-"){
            int b = pop();
            int a = pop();
            push(a-b);
        }
        else if(s == "*"){
            int b = pop();
            int a = pop();
            push(a*b);
        }
        else{
            x = stoi(s);
            push(x);
        }
    }
    cout << pop() << endl;
    return 0;
}




Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            int N = S.length();

            int[] M = new int[N + 1];

            for (int i = 0; i < N; i++) {
                M[i] = S.charAt(N - 1 - i) - '0';
            }

            long ans = 0;
            for (int i = 0; i <= N; i++) {
                if (M[i] == 10) {
                    M[i + 1]++;
                    continue;
                }

                if (M[i] <= 4) {
                    ans += M[i];
                } else if (M[i] == 5) {
                    if (M[i + 1] >= 5) {
                        M[i + 1]++;
                    }
                    ans += 5;
                } else if (M[i] >= 6) {
                    ans += (10 - M[i]);
                    M[i + 1]++;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 36808
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.array;

void main() {
	while (true) {
	int N = readln.chomp.to!int;
	if (N == 0) return;
	char[] c = cast(char[])readln;
	int[char] field;
	field['S'] = field['M'] = field['L'] = 0;
	int[char][] hands = new int[char][N];
	foreach (ref hand; hands) {
		hand['S'] = hand['M'] = hand['L'] = 0;
	}
	foreach (i; 0..100) {
		final switch (c[i]) {
		case 'M':
			hands[i % N][c[i]]++;
			break;
		case 'S':
			hands[i % N][c[i]]++;
			field['M'] += hands[i%N]['M'];
			field['S'] += hands[i%N]['S'];
			field['L'] += hands[i%N]['L'];
			hands[i%N]['M'] = 0;
			hands[i%N]['S'] = 0;
			hands[i%N]['L'] = 0;
			break;
		case 'L':
			hands[i % N][c[i]]++;
			hands[i%N]['M'] += field['M'];
			hands[i%N]['S'] += field['S'];
			hands[i%N]['L'] += field['L'];
			field['M'] = 0;
			field['S'] = 0;
			field['L'] = 0;
			break;
		}
	}
	int[] cards = new int[N];
	foreach (int i, h; hands) {
		foreach (k; h.keys) {
			cards[i] += h[k];
		}
	}
	cards.sort;
	foreach (card; cards) {
		write(to!string(card) ~ ' ');
	}
	writeln(field['S'] + field['M'] + field['L']);
	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int h, n;
    cin >> h >> n;
    int a;
    REP(i, n) {
        cin >> a;
        h -= a;
        if (h <= 0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <iomanip>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  string s;
  cin >> s;
  int i,j;
  for(i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      break;
    }
  }
  for(j = s.size() - 1; j >= 0; j--){
    if(s[j] == 'Z'){
      break;
    }
  }
  FINA(j-i+1);
  //  cout << s.substr(i, j-i+1) << endl;

 return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 100010

typedef struct{
  int a;
  int b;
}data;

int comp(const void* x,const void* y){
  data p=*((data*)x),q=*((data*)y);
  if(p.a!=q.a)return p.a-q.a;
  p.b-q.b;
}

data war[MAX];

int H[MAX]={};

void init_heap(int* heap);
void put_heap(int* heap, int x);
int pull_heap(int* heap);        // take min item
int flag_heap(int* heap, int itr, int temp);

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int i;
  for(i=0;i<m;i++){
    scanf("%d%d",&((war[i]).a),&((war[i]).b));
  }
  qsort(war,m,sizeof(data),comp);

  int count=0;
  for(i=0;i<m;i++){
    data x=war[i];

    if(H[1]<=x.a){
      count++;
      init_heap(H);
    }
    put_heap(H,x.b);
  }
  
  printf("%d",count);
  return 0;
}


void init_heap(int* heap){
  heap[0]=0;
}


void put_heap(int* heap, int x){
  heap[0]++;
  int i=heap[0];
  while(i>1 && heap[i/2]>x){
    heap[i]=heap[i/2];
    i/=2;
  }
  heap[i]=x;
}


int pull_heap(int* heap){
  int x=heap[1],temp=heap[heap[0]],flag,itr=1,itr2;
  heap[0]--;
  flag=flag_heap(heap,itr,temp);
  while(flag){
    itr2=2*itr+(flag-1); //flag=1 ->left child, 2->right child.
    heap[itr]=heap[itr2];
    itr=itr2;
    flag=flag_heap(heap,itr,temp);
  }
  heap[itr]=temp;
  return x;
}

int flag_heap(int* heap, int itr,int temp){
  int a,flag;
  if(heap[0]<itr*2) flag=0;
  else if(heap[0]==itr*2)
    flag=(temp<heap[itr*2]?0:1);
  else if(heap[itr*2]<heap[itr*2+1])
    flag=(temp<heap[itr*2]?0:1);
  else flag=(temp<heap[itr*2+1]?0:2);

  //  flag= 0,1,or 2
  return flag;
}

/// confirm df==0 ///


Measured memory_bytes: 1788
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb(n) push_back(n)
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
char s[4];
void solve(){
	cin>>s;
	if(s[1]=='R')
		cout<<"ABC";
	else
		cout<<"ARC";
	return;
}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int x, y, z, qaq, ans;
int main()
{
	cin >> x >> y >> z;
	qaq = z;
	while(qaq + y + z <= x){
		qaq += y + z;
		ans ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin>>n;
    int f=0;
    for(int i=1; i<=9; ++i)
    {
        if(n%i==0){
            if((n/i)>=1&&(n/i)<=9){
                f=1;
                break;
            }
        }
    }
    if(f==1) cout<<"Yes";
    else cout<<"No";
    
    cout<<'\n';
}


Measured memory_bytes: 256
def read():
    K = int(input())
    A, B = map(int, input().split())
    return K, A, B

def solve(K, A, B):
    for i in range(A, B+1):
        if i % K == 0:
            return 'OK'
    return 'NG'


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 9184
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[][] A=new int[2][N];

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

			for (int j = 0; j < N; j++) {
				A[i][j]=sc.nextInt();
			}

		}

		int[][] dp=new int[2][N];

		dp[0][0]=A[0][0];

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

			dp[1][0]=dp[0][0]+A[1][0];

		for (int i = 1; i < N; i++) {
			dp[1][i]=A[1][i]+Math.max(dp[1][i-1],dp[0][i]);
		}

		int ans=dp[1][N-1];

		System.out.println(ans);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left == NIL || z->right == NIL){
    y = z;
  } else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  
  if(y != z)
    z->key = y->key; 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25140
#include <iostream>
#include <vector>
#include <cstdlib>
#include <iomanip>
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; }

double dp[3000][3000] = {0};

int main() {
  int N; cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];
  
  dp[0][0] = 1.0;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N;  ++j) {
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1.0-p[i]);
    }
  }
  
  double ans = 0.0;
  for (int j = (N+1)/2; j <= N; ++j) {
    ans += dp[N][j];
  }
  cout << fixed << setprecision(10) << ans << endl;
  
  return 0;
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len(stuff) (int) stuff.size()

#define int long long
// #define float long double 
#define ll long long
#define ld long double

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const int inf = (int) 1e16;
const int upper = (int) 2e5 + 50;
const int M = (ll) 1e9 + 7;
const int mod = (ll) 998244353;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);	 
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif	
	int n, k; cin >> n >> k;
	string s; cin >> s;
	s[k - 1] -= 'A', s[k - 1] += 'a';
	cout << s;
 	end_routine();		
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[] = new int[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		Queue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
		for(int t:A) pq.offer(t);
		for(int i=0;i<M;i++) {
			int t = pq.poll();
			t /= 2;
			pq.offer(t);
		}
		long ans=0;
		while(pq.peek()!=null) {
			ans += pq.poll();
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 52108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACirclePond solver = new ACirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACirclePond {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            w.println(2 * Math.PI * s.nextInt());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            Dictionary<string, int> dic = new Dictionary<string, int>();

            for(int i = 0; i < w.Length; ++i)
            {
                string a = w.Substring(i, 1);
                if (dic.ContainsKey(a))
                {
                    dic[a]++;
                }
                else
                {
                    dic.Add(a, 1);
                }
            }
            bool flg = true;
            foreach(var d in dic)
            {
                if(d.Value % 2 != 0)
                {
                    Console.WriteLine("No");
                    Console.ReadLine();
                    return;
                }
            }
            Console.WriteLine("Yes");
            Console.ReadLine();
            return;
        }
    }
}


Measured memory_bytes: 13152
#if 0
20分

#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
ll ll_max = numeric_limits<ll>::max();
ll ll_min = numeric_limits<ll>::min();
int int_max = numeric_limits<int>::max();
int int_min = numeric_limits<int>::min();
int W, H;
int islands[50][50];
queue<pair<int, int> > now;
vector<pair<int, int> > not_reached;
int dirs[8][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}, {1, -1}, {1, 1}, {-1, 1}, {-1, -1}};
bool check_point(pair<int, int> point) {
    bool ret = true;
    ret &= point.first > -1;
    ret &= point.second > -1;
    ret &= point.first < H;
    ret &= point.second < W;
    ret &= islands[point.first][point.second] == 1;
    return ret;
}
void bfs() {
    while (!now.empty()) {
        pair<int, int> start = now.front();
        now.pop();
        for (auto dir : dirs) {
            auto next = make_pair(start.first + dir[0], start.second + dir[1]);
            if (check_point(next)) {
                // cout << "next:" << next.first << ", " << next.second << endl;
                now.push(next);
                auto next_it = find(not_reached.begin(), not_reached.end(), next);
                if (next_it != not_reached.end())
                    not_reached.erase(next_it);
                islands[next.first][next.second] = 2;
            }
        }
    }
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    while (cin >> W >> H && W && H) {
        rep(h, H) {
            rep(w, W) {
                cin >> islands[h][w];
                if (islands[h][w] == 1)
                    not_reached.push_back(make_pair(h, w));
            }
        }
        int cnt = 0;
        while (!not_reached.empty()) {
            ++cnt;
            queue<pair<int, int> > empty;
            swap(now, empty);
            now.push(not_reached.back());
            not_reached.pop_back();
            bfs();
        }
        cout << cnt << endl;
    }

    return 0;
}


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

int n=4, a, v[10];
int main() {
	while(n--) cin >> a, v[a] = 1;
	puts(v[1] && v[9] && v[7] && v[4] ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MAXN=200017;
using namespace std;

int a[MAXN];
int dp[MAXN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    
    for(int i=0; i<n; i++) dp[a[i]]=dp[a[i]-1]+1;
    
    int maxx=0;
    for(int i=1; i<=n; i++) maxx=max(maxx, dp[i]);
    
    cout<<n-maxx<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  string A = "Three"; 
  cin >> N;
  
  
  for(int i = 0;i < N;i++){
    cin >> S;
    if(S == "Y"){
    A = "Four";
    }
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

vector<long long> divisor(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (n / i != i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto div = divisor(n);
  ll ans = LINF;
  for (auto e : div)
    chmin(ans, e+n/e-2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<chrono>
#include<random>
#define ll long long
#define int ll
#define INF 1e+18
#define EPS 1e-18
#define pii pair<int,int>
#define endl "\n"
#define all(mas) mas.begin(),mas.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define forn_(i,n) for(int i = n - 1; i >= 0; i--)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e5 + 1;
int n, m, mas[MAXN];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int r = INF, l = -INF;
	cin >> n >> m;

	forn(i,m) {
		int a, b; cin >> a >> b;
		l = max(l, a);
		r = min(r, b);
	}

	cout << max(0ll, r - l + 1);
	return 0;
}

Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    multiset<ll> s;
    vector<ll> v(n);
    for(ll i=0; i<n; i++){
        ll x;
        cin>>x;
        v[i]=x;
        s.insert(x);
    }
    ll ans = 0;
    for(auto ele: v){
        s.erase(s.lower_bound(ele));
        ll flag = 1;
        for(ll i=1; i*i<=ele; i++){
            if(ele%i==0){
                if(s.find(i)!=s.end()){
                    flag = 0;
                    break;
                }
                if(i*i!=ele){
                    ll fac2 = ele/i;
                    if(s.find(fac2)!=s.end()){
                        flag = 0;
                        break;
                    }
                }
            }
        }
        if(flag){
            ans++;
        }
        s.insert(ele);
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int f(int n, vector<int> &h, vector<int> &dp) {
	if(n == 0) return 0;
	if(n == 1) return abs(h[1] - h[0]);
	if(dp[n] != -1) return dp[n];
	int x = min(f(n - 1, h, dp) + abs(h[n] - h[n - 1]), f(n - 2, h, dp) + abs(h[n] - h[n - 2]));
	dp[n] = x;
	return x;
}

void solve() {
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, -1);
	cout << f(n - 1, h, dp) << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 7160
object Main {
  def main(args: Array[String]): Unit = {
    val Array(n,k) = io.StdIn.readLine().split(" ")

    val snukes = new Array[Boolean](n.toInt)
    
    for(i <- 0 until k.toInt) {
      io.StdIn.readLine()
      val notHave = io.StdIn.readLine().split(" ").map(_.toInt)
      notHave.foreach(s => {
        snukes(s - 1) = true
      })
    }

    println(snukes.filter(b => !b).size)


  }
}

Measured memory_bytes: 55040
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    100256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
ll n;
double a, dp[N] = {1};
void solve()
{
    cin >> n;
    cout.precision( 10 );
    for( int i = 1; i <= n; i ++ )
    {
        cin >> a;
        for( int j = i + 1; j > 0; j -- )
            dp[j] += (dp[j - 1] - dp[j] ) * a;
    }
    cout << dp[ (n + 1) / 2 ];
}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}














Measured memory_bytes: 256
program choosing_points
  implicit none
  integer :: n, d1, d2, i, j, m, c(600,600,2) = 0, a, b, k
  read(*,*) n, d1, d2
  m = 2*n
  call coloring(c(1:m,1:m,1),d1)
  call coloring(c(1:m,1:m,2),d2)
  do a = 0, 1
    do b = 0, 1
      k = 0
      do i = 1, m
        do j = 1, m
          if (c(i,j,1) == a .and. c(i,j,2) == b) k = k+1
        end do
      end do
      if (k < n*n) cycle
      k = 0
      do i = 1, m
        do j = 1, m
          if (c(i,j,1) == a .and. c(i,j,2) == b) then
            write(*,'(i0,x,i0)') i-1, j-1
            k = k+1
            if (k == n*n) stop
          end if
        end do
      end do
    end do
  end do
  stop
contains
  recursive subroutine coloring(c,d)
    implicit none
    integer, intent(in) :: d
    integer, intent(inout) :: c(:,:)
    integer :: h, w, i, j
    h = size(c(:,1))
    w = size(c(1,:))
    if (mod(d,2) == 1) then
      do i = 1, h
        do j = 1, w
          c(i,j) = mod(i+j,2)
        end do
      end do
      return
    end if
    if (mod(d,4) == 2) then
      do i = 1, h
        do j = 1, w
          c(i,j) = mod(i,2)
        end do
      end do
      return
    end if
    call coloring(c(1:h:2,1:w:2),d/4)
    call coloring(c(2:h:2,1:w:2),d/4)
    call coloring(c(1:h:2,2:w:2),d/4)
    call coloring(c(2:h:2,2:w:2),d/4)
    return
  end subroutine coloring
end program choosing_points

Measured memory_bytes: 3712
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  int n;
  cin >> n;
  vector<int> a(n), c(n - 1);
  rep(i, n) {
    cin >> a[i];
    --a[i];
  }
  ll ans = 0;
  rep(i, n) {
    int b;
    cin >> b;
    ans += b;
  }
  rep(i, n - 1) cin >> c[i];

  rep(i, n - 1) {
    if (a[i + 1] - a[i] == 1) ans += c[a[i]];
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	long long total = 0;

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		total += 1ll * (i + 1) * (n - i);
	}

	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		if(u > v) swap(u, v);
		
		total -= 1ll * u * (n - v + 1);

	}

	cout << total;
	
	return 0;
}


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Obj[] arr = new Obj[m];
		for (int i = 0; i < m; i++) {
			Obj o = new Obj();
			o.b = sc.nextInt();
			o.c = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Arrays.parallelSort(a);
		Arrays.parallelSort(arr);

		int k = 0;
		end:
		for (int i = 0; i < arr.length; i++) {
			Obj o = arr[i];
			for (int j = 0; j < o.b && k < n; j++, k++) {
				if (a[k] < o.c) {
					a[k] = o.c;
				} else {
					break end;
				}
			}
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
		System.out.println(ans);
	}

	static class Obj implements Comparable<Obj>{
		int b, c;

		public int compareTo(Obj o) {
			return o.c - c;
		}
	}
}


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

using namespace std;

int main(){
  string s;
  cin>>s;
  int a=0,b=0;
  for(int i=0;i<3;i++){
    if(s[i]=='A'){
      a++;
    }
    else{
      b++;
    }
  }
  if(a!=0 && b!=0){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
  return 0;
}

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

int d[55][55];

int main() {
  int h,w;
  cin>>h>>w;
  char s[55][55];
  int cnt=0;
  rep(i,h) rep(j,w) {
    cin>>s[i][j];
    if (s[i][j]=='#') cnt++;
  }
  queue<P> q;
  q.push({0,0});
  d[0][0]=1;
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  while (!q.empty()) {
    int x,y;
    tie(x,y)=q.front(); q.pop();
    rep(i,4) {
      int nx=x+dx[i],ny=y+dy[i];
      if (nx>=0&&nx<h&&ny>=0&&ny<w) {
	if (!d[nx][ny]&&s[nx][ny]=='.') {
	  d[nx][ny]=d[x][y]+1;
	  q.push({nx,ny});
	}
      }
    }
  }
  if (d[h-1][w-1]==0) cout<<-1<<endl;
  else cout<<h*w-d[h-1][w-1]-cnt<<endl;
  return 0;
}



Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
a = []
for _ in range(h):
    a.append(input())
INF = 10**9
dxdy = [(-1,0), (0,-1), (0,1), (1,0)]
step = [[INF]*w for _ in range(h)]
step[ch-1][cw-1] = 0
q = deque([(ch-1, cw-1)])
nq = deque()
while True:
    while q:
        y, x = q.popleft()
        nq.append((y, x))
        for dy, dx in dxdy:
            if not (0<=x+dx<w and 0<=y+dy<h):
                continue
            if a[y+dy][x+dx]=='#':
                continue
            if step[y+dy][x+dx]>step[y][x]:
                step[y+dy][x+dx] = step[y][x]
                q.append((y+dy, x+dx))
    while nq:
        y, x = nq.popleft()
        for i in range(25):
            dy = i//5-2
            dx = i%5-2
            if not (0<=x+dx<w and 0<=y+dy<h):
                continue
            if a[y+dy][x+dx]=='#':
                continue
            if step[y+dy][x+dx]>step[y][x]+1:
                step[y+dy][x+dx] = step[y][x]+1
                q.append((y+dy, x+dx))
    if not q:
        break
if step[dh-1][dw-1]==INF:
    print(-1)
else:
    print(step[dh-1][dw-1])

Measured memory_bytes: 92468
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    v_ = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v_[b].append(a)
    dp = [0]*n
    for y in range(1,n)[::-1]:
        v_[y].sort()
        d = dp[y]
        for x in v_[y]:
            dp[x] += (d+1)/len(v[x])
    ans = dp[0]
    p = [0]*n
    p[0] = 1
    for x in range(n-1):
        d = p[x]/len(v[x])
        for y in v[x]:
            p[y] += d
    for a in range(n-1):
        if len(v[a]) == 1:
            continue
        m = max([dp[b] for b in v[a]])
        for b in v[a]:
            if dp[b] == m:
                break
        l = dp[0]
        k = dp[a]
        dp[a] = 0
        le = len(v[a])-1
        for y in v[a]:
            if y == b:
                continue
            dp[a] += (dp[y]+1)/le
        d = l+p[a]*(dp[a]-k)
        dp[0] = l
        if 0 < d < ans:
            ans = d
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65244
// AOJ ALDS1_6_A Counting Sort
// 2018.4.27 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20]; int w;
void mypr(int n)
{
	w = 0;
	if (!n) { buf[w++] = '0'; return; }
	while (n) buf[w++] = n%10 + '0', n/=10;
}

#define MAX_N 10000
int f[MAX_N+2];

int main()
{
	int N, i, j, c;

	N = in();
	for (i = 0; i < N; i++) f[in()]++;
	for (i = 0; ; i++) if (c = f[i]) break;
	mypr(i); j = w; while (j--) pc(buf[j]);
	while (--c) { pc(' '); j = w; while (j--) pc(buf[j]); }
	while (++i <= MAX_N) if (c = f[i]) {
		mypr(i); 
		while (c--) { pc(' '); j = w; while (j--) pc(buf[j]); }
	}
	pc('\n');
	return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define inf 1e13
typedef pair<int,int>P;
#define fi first
#define se second
int n,m,a,b,c;
int par[111111],ran[111111];
int f[111111];
bool used[111111];
vector<P>v[111111];
void init(int n){
	rep(i,n){
		par[i]=i;
		ran[i]=0;
	}
}
int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(ran[x]<ran[y])par[x]=y;
	else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}
bool bfs(int x){
	f[x]=0;
	queue<int>q;
	q.push(x);
	used[x]=false;
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(P e:v[p]){
			if(f[e.fi]!=inf){
				if(f[e.fi]!=f[p]+e.se){
					return false;
				}
			}
			else{
				f[e.fi]=f[p]+e.se;
				q.push(e.fi);
				used[e.fi]=false;
			}
		}
	}
	return true;
}
signed main(){
	cin>>n>>m;
	init(n);
	fill(f,f+n,inf);
	fill(used,used+n,false);
	rep(i,m){
		cin>>a>>b>>c;
		a--,b--;
		unite(a,b);
		v[a].push_back({b,c});
		v[b].push_back({a,-c});
		used[a]=used[b]=true;
	}
	rep(i,n){
		if(used[i]){
			if(!bfs(i)){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;
int main() {
	ll x;
	cin >> x;
	cout << (1 - x) << endl;
}

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

#define SWAP(a, b) (a += b,b = a - b,a -= b)
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> b >> n;
  //vector<int> v(n), c(n);
  rep(i, n){
    cin >> a;
    ans += a;
  }
  if(ans >= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  //cout <<  << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int N; cin >> N;
  string S, T; cin >> S >> T;
  rep(i,N) cout << S[i] << T[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const int inf=1e9+5;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>> p(n,vector<int>(m,0));
    vector<int> c(n,0);
    rep(i,n){
        cin>>c[i];
        rep(j,m) cin>>p[i][j];
    }
    int ans=inf,cnt=0;
    rep(i,1<<n){
        cnt=0;
        vector<int> che(n,0),ach(m,0);
        rep(j,n){
            if(i>>j&1) che[j]=1;
        }
        rep(j,n){
            if(che[j]==1){
                cnt+=c[j];
                rep(K,m){
                    ach[K]+=p[j][K];
                }
            }
        }
        bool ok=true;
        rep(j,m){
            if(ach[j]<x) ok=false;
        }
        if(ok) ans=min(ans,cnt);
    }
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h> 
using namespace std; 
int main(){ 
int count[10001],
tmp,num=3; 
for(int i=0;i<10001;i++)
count[i]=0;
 for(int i=0;i<10;i++){ 
scanf("%d",&tmp);
 count[tmp]++; } 
for(int i=10000;i>=0&&num>0;i--){
 if(count[i]>0){ 
for(int k=0;k<count[i]&&num>0;k++){
 printf("%d\n",i);
 num--;
 } 
} 
} 
return 0; }


Measured memory_bytes: 2748
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[][] c=new int[3][3];
    int[] a=new int[3];
    int[] b=new int[3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        c[i][j]=sc.nextInt();
      }
    }
    if(c[0][1]-c[0][0]==c[1][1]-c[1][0]&&
       c[1][1]-c[1][0]==c[2][1]-c[2][0]){
      if(c[0][2]-c[0][1]==c[1][2]-c[1][1]&&
         c[1][2]-c[1][1]==c[2][2]-c[2][1]){
        if(c[1][0]-c[0][0]==c[1][1]-c[0][1]&&
           c[1][1]-c[0][1]==c[1][2]-c[0][2]){
          if(c[2][0]-c[1][0]==c[2][1]-c[1][1]&&
             c[2][1]-c[1][1]==c[2][2]-c[1][2]){
            System.out.println("Yes");
            return;
          }
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21840
#include <iostream>

using namespace std;

int main(){
	string s;
	cin>>s;
	if(s.length()<26){
		string c = string(26, '0');
		for(int x=0; x<s.length(); x++){
			c[s[x]-'a'] = '1';
		}
		for(int x=0; x<26; x++){
			if(c[x]=='0'){
				s += ('a'+x);
				break;
			}
		}
		cout << s << endl;
	} else {
		int x = 24;
		for(; x>=0; x--){
			if(s[x]<s[x+1])
				break;
		}
		if(x==-1)
			cout << -1 << endl;
		else {
			string c = string(26, '0');
			for(int y=0; y<x; y++){
				c[s[y]-'a'] = '1';
			}
			for(int y=s[x]-'a'+1; y<26; y++){
				if(c[y]=='0'){
					s[x] = y+'a';
					break;
				}
			}
			cout << s.substr(0, x+1) << endl;
		}
	}
	return 0;
}


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

#define dump(a) (cerr << #a << " = " << (a) << endl)

#define REP(i,a,b) for(int i=(a);i < (int)(b); i++)
#define rep(i,n) REP(i,0,n)
#define ALL(v) begin(v), end(v)
const int MAX = 10010;
int prime[MAX];
int main(){
  int n;
  for(int i = 0;i < MAX;i++){
    prime[i] = 1;
  }
  prime[0] = 0;
  prime[1] = 0;

  for(int i = 2;i < MAX;i++){
    if(prime[i] == 0)continue;
    for(int j = i*2;j < MAX;j+=i){
      prime[j] = 0;
    }
  }

  while(cin >> n && n){
    int ans = 0;
    for(int i = 1;i <= n;i++){
      int sum = 0;
      if(!prime[i])continue;
      for(int j = i;j <= n;j++){
	if(prime[j])sum+=j;
	if(sum == n){
	  ans++;
	  break;
	}
	if(sum > n)break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3692
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    vl t(2), a(2), b(2);
    for (int i = 0; i < 2; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < 2; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < 2; ++i) {
        cin >> b[i];
    }
    if (a[0] < b[0]) {
        swap(a[0], b[0]);
        swap(a[1], b[1]);
    }
    ll d = t[0] * (a[0] - b[0]);                        // > 0
    ll e = t[0] * (a[0] - b[0]) + t[1] * (a[1] - b[1]); // < 0

    if (d > 0 && e > 0) {
        cout << 0 << "\n";
        return 0;
    }
    if (e == 0) {
        cout << "infinity"
             << "\n";
        return 0;
    }
    ll ret = 1;
    if (d + e < 0) {
        ret = 1;
    } else if (d + e == 0) {
        ret = 2;
    } else {
        ret += 2 * ((d - 1) / (-e));
        if ((d + e) % e == 0)
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] alpha = new char[26];
    for(int i = 0; i < 26; i++){
      alpha[i] = (char)(97 + i);
    }
    int[] count = new int[26];
    String ans = "None";
    for(int i = 0; i < s.length(); i++){
      for(int j = 0; j < 26; j++){  
        if(s.charAt(i) == alpha[j]) {
          count[j]++;
          break;
        }
      }
    }
    for(int i = 0; i < 26; i++){  
      if(count[i] == 0) {
        ans =String.valueOf(alpha[i]);
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23904