akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, maxxx = 0, cnt = 0;
	cin >> n;
	
	int nums[n];
	for (int i = 0; i < n; i++) cin >> nums[i];
	
	for (int i = 0; i < n-1; i++)
	{
		if (nums[i]>=nums[i+1]) cnt++;
		else
		{
			maxxx = max(maxxx, cnt);
			cnt = 0;
		}
	}
	cout << max(maxxx, cnt) << "\n";
}

Measured memory_bytes: 640
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
A = np.array(A)
ans = list()
for i in range(N):
  a = A[i]
  num = 0
  while a%2==0:
    a /= 2.0
    num += 1
  ans.append(num)
print(min(ans))

Measured memory_bytes: 27128
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ii pair<int,int>
#define setin set.insert
using namespace std;
vector<int>v;
set<int>set;
vector<ii>vp;
ll ans,count,mx,mn;
int i;
int main()
{
    ll A,B,C,K;
    cin >> A >>B >> C >> K;
    ll s=0;
    if(K>=A)
        s+=(A*1);
    else
        s+=(K*1);
    K=K-A;
    if(K>0)
    {
        K=K-B;
        if(K>0)
        {
            if(K>=C)
                s+=(C*-1);
            else
                s+=(K*-1);
        }
    }
    cout << s << endl;
    return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void dfs(ll a, Array& ans, ll con){
	ans.push_back(a);
	if(con==10) return;
	con++;
	ll d = a%10;
	if(d>0) dfs(a*10+d-1,ans,con);
	dfs(a*10+d,ans,con);
	if(d<9) dfs(a*10+d+1,ans,con);
}

void solve(){
	ll k;
	cin>>k;
	Array ans;
	rep(i, 1, 10) dfs(i,ans,1);
	sort(all(ans));
	cout<<ans[k-1]<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
//#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
const ll chk1=2e9;
const ll chk2=-2e9;

int main()
{ 

    fast;

    ll a,b;
    cin>>a>>b;

    cout<<max(a+b,max(a-b,a*b));
  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>


using namespace std;

namespace {

}

int main()
{
	set<char> head = { 'M', 'A', 'R', 'C', 'H' };

	int N = 0;
	cin >> N;

	map<char, int> number;

	for (int i = 0; i < N; ++i){
		string s;
		cin >> s;
		if (head.find(s[0]) != head.end()){ // なければ追加。
			++number[s[0]];
		}
	}

	long long sum = 0;
	set<set<char>> used;
	for (auto& elem1 : number){ 
		for (auto& elem2 : number){
			if (elem1.first == elem2.first){
				continue;
			}
			for (auto& elem3 : number){
				set<char> curCmb = { elem1.first, elem2.first, elem3.first };
				if (curCmb.size() < 3){
					continue;
				}

				if (used.find(curCmb) == used.end()){
					// まだ使用していない。
					used.insert(curCmb);
					sum += static_cast<long long>(number[elem1.first]) * number[elem2.first] * number[elem3.first];
				}
			}
		}
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
  int n, i;
  int cnt = 1;
  char S[200000][11];
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
  {
    scanf("%s", S[i]);
  }
  
  qsort(S, n, 11, strcmp);
  
  for(i = 1; i < n; i++)
  {
    if(strcmp(S[i], S[i - 1]) != 0)
      ++cnt;
  }
  
  printf("%d", cnt);

  return 0;
}

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

int main()
{
    int X; cin >> X;

    int tenth_first = X - X / 100 * 100; // Xの下二桁
    int tf_5 = tenth_first / 5; // 105円のパソコンの数
    // tfをなるべく少ない数の品物で支払いたいので、105円で支払う

    int mn_money; // 下二桁解消のために最低でもかかるお金
    if (tenth_first % 5 == 0)
    {
        mn_money = 105 * tf_5;
    }
    else
    {
        mn_money = 105 * tf_5 + (100 + tenth_first % 5);
    }

    if (X >= mn_money) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(a: int):
    return a+a*a+a**3


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    print(solve(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75100
from collections import deque

def solve(N, P, Q):
    stack = deque()
    vals = [i for i in range(1, N + 1)]
    for idx, next_val in enumerate(vals):
        stack.append([[next_val], vals[: idx] + vals[idx + 1:]])
    a, b = -1, -1
    counter = 0
    while stack:
        cur_list, rest = stack.popleft()
        if not rest:
            counter += 1
            a = counter if cur_list == P else a
            b = counter if cur_list == Q else b
            if 0 < a and 0 < b:
                print(abs(a - b))
                return

        for idx, next_val in enumerate(rest):
            stack.append([cur_list + [next_val], rest[: idx] + rest[idx + 1:]])

if __name__ == "__main__":
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    solve(N, P, Q)


Measured memory_bytes: 73436
n = int(input())
data = list(map(int, input().split()))
result = 0
re = []

for i in range(len(data)):
  for j in range(i + 1, len(data)):
    for k in range(j + 1, len(data)):
      if data[i] == data[j] or data[i] == data[k] or data[j] == data[k] or data[i]== data[j] == data[k]:
        result += 0
      else:
        lists = [data[i],data[j],data[k]]
        lists = sorted(lists)
        if lists[0]+lists[1] > lists[2] :
          result += 1


print(result)

Measured memory_bytes: 9172
module Main (main) where

import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [x,a,b] <- readInts
  putStrLn $ solve x a b

solve :: Int -> Int -> Int -> String
solve x a b = pretty (xa < xb)
  where
    xa = abs (x-a)
    xb = abs (x-b)

pretty :: Bool -> String
pretty b = if b then "A" else "B"

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

Measured memory_bytes: 380
#include<stdio.h>
#include<math.h>

int main (void)
{
	int num,input;
	int i;
	int max=-1000001,min=1000001;
	long int sum = 0;
	
	scanf("%d",&num);
	for(i = 0 ; i < num ; i++)
	{
		scanf("%d",&input);
		if(input > max )
		{
			max = input;
		}
		if(input < min)
		{
			min = input;
		}
		sum = sum + input;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
bool isPalimdrome(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}
/* main */
int main(){
    string S;
    cin >> S;
    bool ans = true;
    if (!isPalimdrome(S)) ans = false;
    if (!isPalimdrome(S.substr(0, S.size() / 2))) ans = false;
        cout << (ans ? "Yes" :"No") << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstdio>

using namespace std;

struct list {
	int key;
	list *next,*prev;
};

list *head, *tail, *p;

void insert_x(int key) {
	list *make = new list;
	make->key = key;
	if (head == NULL) {
		head = tail = make;
		make->next = make->prev = NULL;
	}
	else {
		head->prev = make;
		make->next = head;
		head = make;
	}
}

void deleteFirst() {
	list* tmp = head;
	if (head == tail) {
		head = tail = NULL;
	}
	else {
		head = head->next;
		head->prev = NULL;
	}
	delete tmp;
}
void deleteLast() {
	list* tmp = tail;
	if (tail == head) {
		head =  tail = NULL;
	}
	else {
		tail = tail->prev;
		tail->next = NULL;
	}
	delete tmp;
}
void delete_x(int key) {
	p = head;
	while (p->key != key) {
		if (p->next == NULL)
			return;
		p = p->next;
	}
	if (p == head)
		deleteFirst();
	else if (p == tail)
		deleteLast();
	else {
		p->prev->next = p->next;
		p->next->prev = p->prev;
		delete p;
	}
}

int main() {
	head = tail = p = NULL;
	int n=0;
	char command[12];
	int key =0;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%s", command);
		if (strcmp(command, "insert") == 0) {
			scanf("%d", &key);
			insert_x(key);
		}
		else if (strcmp(command, "delete") == 0) {
			scanf("%d", &key);
			delete_x(key);
		}
		else if (strcmp(command, "deleteFirst") == 0) {
			deleteFirst();
		}
		else if (strcmp(command, "deleteLast") == 0) {
			deleteLast();
		}
	}

	while(true){
		if (head->next != NULL) {
			cout << head->key << " ";
			head = head->next;
		}
		else {
			cout << head->key << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 32364
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            long N = cin.NextLong();
            long K = cin.NextLong();
            N = N % K;
            if (Math.Abs(N - K) < N) N = Math.Abs(N - K);
            Console.WriteLine(N);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

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

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27552
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int dig = 0, num = N;
  while (num != 0) {
    dig += num % 10;
    num /= 10;
  }
  if (N % dig == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	int s, l, p;
	int dp[400] = {};
	for (int i = 0; i < n; ++i) {
		cin >> s >> l >> p;
		for (int j = 0; j <= 393; ++j) {
			for (int k = s; k <= l; ++k) {
				if (j >= k) dp[j] = max(dp[j], dp[j - k] + p);
			}
		}
		
	}
	bool flag = true;
	int m; cin >> m;
	vector<int> w(m);
	for (int i = 0; i < m; ++i) {
		cin >> w[i];
		if (dp[w[i]] == 0) flag = false;
	}
	if (flag)
		for (int i = 0; i < m; ++i) cout << dp[w[i]] << endl;
	else cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 3104
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, Q;
int C[500000];
vector<pair<int,pair<int, int>>> query[800];
int ans[500000] ={};

signed main(){
    cin >> N >> Q;
    rep(i, N){
        cin >> C[i];
        C[i]--;
    }
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        query[(l-1)/800].pb({ r, {l-1,i} });
    }

    rep(i, 800){
        vector<int> cnt(N, 0);
        int tmp = 0;
        int L = 800*i;
        int R = 800*i;
        sort(all(query[i]));
        rep(j, query[i].size()){
            int l = query[i][j].second.first;
            int r = query[i][j].first;
            int a = query[i][j].second.second;
            while(R < r){
                cnt[C[R]]++;
                if(cnt[C[R]] == 1) tmp++;
                R++;
            }
            while(L < l){
                cnt[C[L]]--;
                if(cnt[C[L]] == 0) tmp--;
                L++;
            }
            while(L > l){
                cnt[C[L-1]]++;
                if(cnt[C[L-1]] == 1) tmp++;
                L--;
            }
            ans[a] = tmp;
        }
    }

    rep(i, Q) cout << ans[i] << endl;
}

Measured memory_bytes: 18272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int x = in.nextInt();

            int cnt = 0;
            for (int i = 0; i <= a; i++) {
                for (int j = 0; j <= b; j++) {
                    for (int k = 0; k <= c; k++) {
                        if (i * 500 + j * 100 + k * 50 == x) cnt++;
                    }
                }
            }

            out.println(cnt);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[1<<18];
int d[111];
int inD[20];

int main(){

	REP(i,111)d[i] = -1;
	REP(i,(1<<18))dp[i] = INF;

	int N,M,K;cin >> N >> M >> K;
	REP(i,M){
		cin >>inD[i];inD[i]--;
		d[inD[i]] = i;
	}

	vector<vector<int>> v;
	REP(i,N){
		vector<int> tmp(K);
		REP(j,K){
			cin >> tmp[j];
			tmp[j]--;
		}
		v.PB(tmp);
	}

	dp[(1<<M)-1] = 0;
	queue<int> q;
	q.push((1<<M)-1);

	while(!q.empty()){
		int now = q.front();q.pop();
		//cout << bitset<10>(now) << endl;
		REP(i,K){
			int tmp = 0;
			REP(j,M){
				if(now & (1<<j)){
					int hoge = d[v[inD[j]][i]];
			//		cout << "    " << inD[j] << " " << v[inD[j]][i] << " " << hoge << endl;
					if(hoge != -1)tmp |= (1 << hoge);
				}
			}
			//cout << " " << bitset<10>(tmp) << endl;
			if(dp[tmp] > dp[now] + 1){
				dp[tmp] = dp[now] + 1;
				q.push(tmp);
			}
		}
	}

	cout << dp[0] << endl;


	return 0;
}



Measured memory_bytes: 5336
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.text.DecimalFormat;


/* Name of the class has to be "Main" only if the class is public. */
public class Main
 
 
{
    static Scanner in = new Scanner(System.in);
   
    public static void solve()
    {
        DecimalFormat df = new DecimalFormat("#.####################");
        double a=in.nextDouble(),b=in.nextDouble();
        double h=in.nextDouble(),m=in.nextDouble();
        
        
        double angle=Math.abs(30*h - 11*m/2.0);
        
       double ans=Math.toRadians(angle);
      // System.out.println(ans);
        
        double c= Math.sqrt(a*a + b*b - 2.0*a*b*Math.cos(ans));
        
        System.out.println(df.format(c));
        
    }
    

    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		int t=1;
		//in.nextLine();
		
		while(t>0)
		{
		    
		    solve();
		    t--;
		}
		
		
	
	//	System.out.println(x);
	}
}


Measured memory_bytes: 37492
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	vector<int> vec;
	int q;
	cin >> q;
	REP(i, q) {
		int mode;
		cin >> mode;
		switch(mode) {
			case 0:
				int x;
				cin >> x;
				vec.push_back(x);
				break;
			case 1:
				int p;
				cin >> p;
				cout << vec.at(p) << endl;
				break;
			case 2:
				vec.pop_back();
				break;
		}
	}
}


Measured memory_bytes: 3880
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(val) cout << "!!!" << #val << ": " << val << endl
#define mod 1000000007
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    string str;
    LL k;
    cin >> str >> k;

    rep(i, min((long long)str.length(), k)) {
        if (str[i] != '1') {
            cout << str[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}


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

using ll = long long;
ll n;
std::vector<int> vec;

int main() {
    std::cin >> n;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    int res = 0;
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i] == res + 1) {
            res++;
        }
    }
    if (res == 0) {
        std::cout << -1 << std::endl;
        return 0;
    }
    std::cout << (n - res) << std::endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    string S; cin >> S;
    vector<vector<i64>> G(10);
    REP(i, N) {
        i64 si = S[i] - '0';
        G[si].pb(i);
    }

    i64 cnt = 0;
    REP(i, 1000) {
        i64 x = i;
        vector<i64> digits(3);
        RREP(j, 3) {
            digits[j] = x % 10;
            x /= 10;
        }
        bool ok = true;
        i64 prev = -1;
        REP(j, 3) {
            i64 d = digits[j];
            auto ub = upper_bound(G[d].begin(), G[d].end(), prev);
            if (ub == G[d].end()) {
                ok = false;
                break;
            }
            prev = *ub;
        }
        if (ok) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 768
using System;

namespace agc012a
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            Array.Sort(a);
            long sum = 0;
            int count = 1;
            int max_array_num = 3*N-2;
            while(count<=N){
                sum += a[max_array_num];
                max_array_num -= 2;
                count++;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 41804
<?php
/**
 * ABC125 
 * C - GCD on Blackboard
 */

$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

// 累積GCDを計算
$gcd_list_left = [(int) $a[0]];
$gcd_list_right = [(int) $a[$n - 1]];
$gcd_memo = [];
for ($i = 1; $i < $n - 1; $i++) {
    $gcd_list_left[$i] = gcd($gcd_list_left[$i - 1], $a[$i]);
    $gcd_list_right[$i] = gcd($gcd_list_right[$i - 1], $a[$n - 1 - $i]);
}

// gcd((左累積GCD), (右累積GCD))
$gcd[0] = $gcd_list_right[$n - 2];
$gcd[$n - 1] = $gcd_list_left[$n - 2];
for ($i = 1; $i < $n - 1; $i++) {
    $gcd[$i] = gcd($gcd_list_left[$i - 1], $gcd_list_right[$n - 1 - $i - 1]);
}

echo max($gcd), "\n";

function gcd($a, $b): int {
    return $gcd_memo[$a][$b] ?? ($b == 0 ? $a : gcd($b, $a % $b));
}


Measured memory_bytes: 27372
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  if (b - a < 2) {
    cout << 1 + k << endl;
  } else {
    ll biscuit = 1;
    if (biscuit < a) {
      biscuit = a;
      k -= a - 1;
    }
    biscuit += k / 2 * (b - a);
    if (k % 2 == 1) biscuit++;
    cout << biscuit << endl;
  }
  return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;
	string s,t;cin>>s>>t;

	for(int i=0; i<n; i++){
		cout<<s[i];
		cout<<t[i];
	}

	cout<<endl;
}




Measured memory_bytes: 256
#include <iostream>

int cnt_power(int n, int p)
{
  int cnt = 0;
  while ( true ) {
    if (n % p == 0) {
      n = n / p;
      cnt++;
    } else {
      break;
    }
  }
  return cnt;
}

int main()
{
  int N;
  std::cin >> N;
  int ans = 10000;
  for ( int i = 0; i < N; i++ ) {
    int a;
    std::cin >> a;
    int cnt = cnt_power(a, 2);
    if ( cnt < ans ) {
      ans = cnt;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
long long d[100000+5],ans[100000+5];
int main()
{
	int n,i;
	cin>>n;
	long long s1=0,s=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
		d[i]*=2;
		s+=d[i];
		if(i%2) s1+=d[i];
	}
	s=s/2;
	ans[1]=s1-s;
	for(i=1;i<n;i++)
	{
		ans[i+1]=d[i]-ans[i];
	}
	for(i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int a[405],b[405];
int main()
{
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>b[i];
	a[1]=b[1];a[n]=b[n-1];
	for(int i=2;i<n;i++)
	{
		if(b[i]>b[i-1])a[i]=b[i-1];
		else a[i]=b[i];
	}
	for(int i=1;i<=n;i++)
		sum+=a[i];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="SUN"){
		cout<<'7'<<endl;
	}
	if(a=="SAT"){
		cout<<'1'<<endl;
	}
	if(a=="FRI"){
		cout<<'2'<<endl;
	}
	if(a=="THU"){
		cout<<'3'<<endl;
	}
	if(a=="WED"){
		cout<<'4'<<endl;
	}
	if(a=="TUE"){
		cout<<'5'<<endl;
	}
	if(a=="MON"){
		cout<<'6'<<endl;
	}
	return  0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from math import pi
from bisect import bisect_left
def resolve():
    x1,y1,x2,y2=map(int,input().split())
    if(x1>x2): x1,y1,x2,y2=x2,y2,x1,y1 # x1<=x2
    trans=False
    if(y1>y2):
        y1,y2=-y1,-y2 # y1<=y2
        trans=True

    n=int(input())
    XY=[]
    for i in range(n):
        x,y=map(int,input().split())
        if(trans): y=-y
        if(x1<=x<=x2 and y1<=y<=y2):
            XY.append((x,y))

    d=(x2-x1)+(y2-y1) # マンハッタン
    d*=100
    l=min(x2-x1,y2-y1)

    # XYのLISを求めて、その個数*(20-5pi)を引けばよい
    XY.sort()
    C=[INF]*(n+1)
    for x,y in XY:
        i=bisect_left(C,y)
        C[i]=y
    k=C.index(INF)
    # LISの数が l より大きい時 -> 1回は無駄にしてしまう
    if(k>l):
        d-=(k-1)*(20-5*pi)
        d+=10*pi-20
    else:
        d-=k*(20-5*pi)
    print(d)
resolve()

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

int n, h[100005], dp[100005];
//dp[] : 過去に求めた値をメモしておく

int cost(int x);

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1;i <= n;i ++){
    cin >> h[i];
  }
  dp[0] = 1e9; //大きな値で初期化
  cout << cost(n) << '\n';
  return 0;
}

int cost(int x){
  if(x == 1){
    dp[x] = 0;
    return dp[x];
  }
  dp[x] = min(dp[x - 2] + abs(h[x], h[x - 2]), cost(x - 1) + abs(h[x], h[x - 1]));
  return dp[x];
}


Measured memory_bytes: 7488
#include <iostream>
using namespace std;
int n,a[(int)1e5+1],temp,oddc,sum;
int main(void){
    cin>>n;
    for(int i=1;i<n+1;i++){
        cin>>temp;
        a[temp]++;
    }
    for(int i=0;i<(int)1e5+1;i++){
        if(a[i]>0){
            if(a[i]%2 == 0)oddc+=1;
            sum+=1;
        }
    }
    cout<<((oddc%2==1) ? sum-1 : sum)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
int v[2][100001]={};
int main(){
    int n,vi[2];
    scanf("%d",&n);
    for(int i=0;i<n;i+=2){
        scanf("%d%d",&vi[0],&vi[1]);
        v[0][vi[0]]++;
        v[1][vi[1]]++;
    }
    int maxi[2][2]={};
    for(int i=0;i<2;i++){
        for(int j=1;j<=100000;j++){
            if(v[i][j]>v[i][maxi[i][0]]){
                maxi[i][1]=maxi[i][0];
                maxi[i][0]=j;
            }else if(v[i][j]>v[i][maxi[i][1]]){
                maxi[i][1]=j;
            }
        }
    }
    if(maxi[0][0]==maxi[1][0]){
        printf("%d",n-v[0][maxi[0][0]]-std::max(v[0][maxi[0][1]],v[1][maxi[1][1]]));
    }else{
        printf("%d",n-v[0][maxi[0][0]]-v[1][maxi[1][0]]);
    }
    return 0;
}

Measured memory_bytes: 896
N = int(input())
ans = [0 for i in range(N)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x**2 + y ** 2 + z ** 2 + x * y + y * z + x * z 
            if tmp <= N:
                ans[tmp - 1] += 1
for i in range(N):
    print(ans[i])

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

template <typename T> class SegmentTree{
	public :
		int n;
		SegmentTree(int size,T o): out_of_range(o){
			for(n=1;n<size;n<<=1);
			data=vector<T>(2*n,out_of_range);
			lazy=vector<bool>(2*n,false);
		}

		void update(int a,int b,T x,int k,int l,int r){
			if(r<=a || b<=l) return;
			if(a<=l&&r<=b){data[k]=x,lazy[k]=true;return;}
			if(lazy[k]) lazy_evaluate(k);
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
			data[k]=min(data[k*2+1],data[k*2+2]);
		}

		T query(int a,int b,int k,int l,int r){
			if(r<=a||b<=l) return out_of_range;
			if(a<=l&&r<=b) return data[k];
			if(lazy[k]) return data[k];
			T vl = query(a,b,k*2+1,l,(l+r)/2);
			T vr = query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}

	private:
		vector<T> data;
		vector<bool> lazy;
		const T out_of_range;

		inline void lazy_evaluate(int k){
			data[k*2+1]=data[k];lazy[k*2+1]=true;
			data[k*2+2]=data[k];lazy[k*2+2]=true;
			lazy[k]=false;
		}
};


int main(void){
	int N,Q;
	cin >>  N >> Q;
	SegmentTree<int> rmq(N,INT_MAX);

	for(int i=0;i<Q;i++){
		int type;
		cin >> type;
		if(type){
			int s,t;
			cin >> s >> t;
			cout << rmq.query(s,t+1,0,0,rmq.n) << endl;
		}else{
			int a,x;
			cin >> a >> x;
			rmq.update(a,a+1,x,0,0,rmq.n);
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void abc_170a();
void abc_171a();
void abc_172a();
void abc_173a();
void abc_174a();
void abc_175a();

void abc_170b();
void abc_171b();
void abc_172b();


int main()
{
  //abc_170a();
  //abc_171a();
  //abc_172a();
  //abc_173a();
  //abc_174a();
  //abc_175a();

  //abc_170b();
  //abc_171b();
  abc_172b();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}

void abc_171a()
{
  char c;
  cin >> c;

  if (c == tolower(c)) cout << "a\n";
  else cout << "A\n";
}

void abc_172a()
{
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << "\n";
}

void abc_173a()
{
  int N;
  cin >> N;

  if (N % 1000) cout << 1000 - N % 1000 << "\n";
  else cout << "0\n";
}

void abc_174a()
{
  int x;
  cin >> x;

  if (x >= 30) cout << "Yes\n";
  else cout << "No\n";
}

void abc_175a()
{
  string s;
  cin >> s;

  int cnt = 0, tmp = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == 'S')
    {
      tmp = 0;
    }
    else
    {
      ++tmp;
      cnt = tmp;
    }
  }

  cout << cnt << "\n";
}


void abc_170b()
{
  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= x; ++i)
  {
    int n_c = i, n_t = x - i;
    if (n_c * 2 + n_t * 4 == y)
    {
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
}

void abc_171b()
{
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];

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

  int price = 0;
  for (int i = 0; i < K; ++i)
  {
    price += p[i];
  }
  cout << price << "\n";
}

void abc_172b()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] != t[i]) ++cnt;
  }

  cout << cnt << "\n";
}

Measured memory_bytes: 3820
#include<iostream>
using namespace std;
int n,k,c=0;
int main(){
    cin>>n>>k;
    if((n-1)*(n-2)/2<k){cout<<-1<<endl;return 0;}
    cout<<n-1+(n-2)*(n-1)/2-k<<endl;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            cout<<i<<" "<<j<<endl;
            if(++c==(n-1+(n-2)*(n-1)/2-k))goto END;
        }
    }
    END:
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  if(n*a < b){
    cout << n * a << endl;
  }else{
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl();
    ll test=0;
    for(int i=1;i<=n;i++)
        if(i%3!=0&&i%5!=0)
            test+=i;
        cout<<test<<endl;
    return 0;   
}




 
 


Measured memory_bytes: 3660
#include<iostream>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	
	ll x[n][n],y[n][n];
	
	int i=0;
	while(i<n)
	{
		x[i][i]=a[i];
		y[i][i]=0;
		i++;
	}
	
	for(int k=1;k<n;k++)
	{
		
		int i=0,j=k;
		while(i<n&&j<n)
		{
			ll q=a[i]+y[i+1][j];
			ll w=a[j]+y[i][j-1];
			
			if(q>=w)
			{
				x[i][j]=q;
				y[i][j]=x[i+1][j];
			}
			else
			{
				x[i][j]=w;
				y[i][j]=x[i][j-1];
			}
			i++;j++;
		}
		
	}
	
//    for(int i=0;i<n;i++)
//    {
//    	for(int j=0;j<n;j++)
//    	{
//    		cout<<x[i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	cout<<"*******************"<<endl;
//	 for(int i=0;i<n;i++)
//    {
//    	for(int j=0;j<n;j++)
//    	{
//    		cout<<y[i][j]<<" ";
//		}
//		cout<<endl;
//	}

cout<<x[0][n-1]-y[0][n-1];
}

Measured memory_bytes: 139904
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
const int MD = 1e9+7;
int n, a, b, z[500005], pr[1<<20];
long long ans, d[2][1<<20];
int main(){
	scanf("%d", &n);
	rep(i,1<<20) d[0][i] = 1;
	rep(i,n){
		scanf("%d", &a);
		b ^= a;
		if(b){
			(d[0][b] += (z[i] - z[pr[b]]) * d[1][b]) %= MD;
			(d[1][b] +=  d[0][b]) %= MD;
			pr[b] = i;
		}else{
			z[i]++;
			if(d[1][0]) (d[1][0] *= 2) %= MD;
			else d[1][0]++;
		}
		z[i+1] += z[i];
	}
	if(b) ans = d[0][b];
	else rep(i,1<<20) (ans += d[1][i]) %= MD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 22656
import itertools

h, w, k = map(int, input().split())

lines = []
for i in range(h):
    lines.append(input())

result = 0

h_indexes = range(h)
w_indexes = range(w)

for i in range(h + 1):
    for j in range(w + 1):
        for h_index_list in itertools.combinations(h_indexes, i):
            for w_index_list in itertools.combinations(w_indexes, j):
                cnt = 0
                for h_index in h_index_list:
                    for w_index in w_index_list:
                        if '#' == lines[h_index][w_index]:
                            cnt += 1
                if cnt == k:
                    result += 1

print(result)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int a[500][500];

int main2() {
  int H = nextInt();
  int W = nextInt();
  REP(i, H) REP(j, W) a[i][j] = nextInt();


  vector<int> ans;
  REP(i, H) REP(j, W) {
    if (a[i][j] % 2 == 0) {
      //
    } else {
      int i2 = -1, j2 = -1;
      if (j+1 < W) { i2 = i; j2 = j+1; }
      else if (i+1 < H) { i2 = i+1; j2 = j; }


      if (i2 >= 0) {
        ans.push_back(i + 1);
        ans.push_back(j + 1);
        ans.push_back(i2 + 1);
        ans.push_back(j2 + 1);
        a[i][j]--;
        a[i2][j2]++;
      }
    }
  }
  cout << ans.size()/4 << endl;
  for (int i = 0; i < (int)ans.size(); i += 4) {
    cout << ans[i] << " " << ans[i+1] << " " << ans[i+2] << " " << ans[i+3] << endl;
  }

  // cout << "---" << endl;
  // REP(i, H) {
    // pv(a[i], a[i]+W);
  // }
  // cout << "---" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 5104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5+5;
int dp[N], h[N];

class BFrog2 {
public:
    int n, k;
    int rec(int i) {
        if(i == n - 1) return 0;
        if(dp[i] != -1) return dp[i];
        int res = INT_MAX;
        for(int j = i+1; j < n and j <= i+k; ++j) res = min(res, abs(h[i] - h[j]) + rec(j));
        return dp[i] = res;
    }
	void solve(std::istream& in, std::ostream& out) {
        in >> n >> k;
        for(int i = 0; i < n; ++i) in >> h[i];
        memset(dp, -1, sizeof dp);
        out << rec(0);
	}
};


int32_t main() {
	BFrog2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N,M;
  cin>>N>>M;
  cout<<max(N-M,0)<<endl;
}

Measured memory_bytes: 3600
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

p_index = 0
q_index = 0
for i, perm in enumerate(permutations(range(1, n+1))):
    if perm == p:
        p_index = i
    if perm == q:
        q_index = i
print(abs(p_index - q_index))

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    vi a(5);
    int k;
    rep(i,5){
        cin >> a[i];
    }
    cin >> k;
    bool ok = true;
    rep(i,5){
        repk(j,i+1,5){
        if(abs(a[i]-a[j]) >  k){ok = false;break;}
        }    
    }
    if(ok) cout << "Yay!" <<endl;
    else cout <<":(" << endl;
    return 0;
}

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

int L, R;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>L>>R;
	if(R-L > 2018)	cout<<0;
	else{
		int ans = 987654321;
		for(int i = L;i<=R;i++)
			for(int j = i+1;j<=R;j++){
				ans = min(ans, (i%2019)*(j%2019)%2019);
			}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    vector<pll> A(N);
    rep(i, N) {
        ll a;
        cin >> a;
        A[i] = {a, i + 1};
    }

    sort(all(A));
    rep(i, N) { cout << A[i].second << " "; }
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n, r;
    cin >> n >> r;
    if (n >= 10) {
        dump(r);
    }
    else {
        dump(r + (100 * (10 - n)));
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]

E = [[] for _ in [0]*N]
for u,v in AB:
    E[u-1].append(v-1)
    E[v-1].append(u-1)

def dist_bfs(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        qq = []
        for i in q:
            di = d[i]
            for j in E[i]:
                if d[j]!=-1:continue
                d[j] = di+1
                q.append(j)
        q = qq
    return d

d = dist_bfs(N,E,0)

co = sum(c%2 for c in d)
ce = N - co
check = False
for a,b in AB:
    a-=1
    b-=1
    if (d[a]+d[b])%2==0:
        check = True
        break
if check:
    ans = N*(N-1)//2 - M
else:
    ans = co*ce - M
print(ans)

Measured memory_bytes: 43928